addLoadListener(initEvents);
function initEvents()
{
  var starReport = document.getElementById("comments_product_id_1709");
  attachEventListener(starReport, "click", engageStar, false);
  document.forms[0].onsubmit = validatStarReport;

  var staffSatisfaction = document.getElementById("comments_product_id_1");
  attachEventListener(staffSatisfaction, "click", engageStaff, false);
  document.forms[10].onsubmit = validatStaffSatisfaction;

}

function engageStar(event)
{
  if (typeof event == "undefined")
  {
    event = window.event;
  }
  alert("Have you entered the total number of employee & employer survey's you require?  E.g. If you have a client with 10 employees you would enter 11 as a quantity.  Remainder of note regarding email links is then entered.");
  stopEvent(event);
  return false;
}

function engageStaff(event)
{
  if (typeof event == "undefined")
  {
    event = window.event;
  }
  alert("Have you entered the total number of employee & employer survey's you require?  E.g. If you have a client with 10 employees you would enter 11 as a quantity.  Remainder of note regarding email links is then entered.");
  stopEvent(event);
  return false;
}

function validatStarReport(event)
{
  var quantity = document.getElementById('comments_product_id_1709');

  if (quantity.value != "")
  {
    /* Continue with submission */
    return true;
  }
  else
  {
    alert("Please enter a number of participants before you continue");

    /* Abort submission */
    return false;
  }
}

function validatStaffSatisfaction(event)
{
  var quantity = document.getElementById('comments_product_id_1');

  if (quantity.value != "")
  {
    /* Continue with submission */
    return true;
  }
  else
  {
    alert("Please enter a number of participants before you continue");

    /* Abort submission */
    return false;
  }
}


function stopEvent(event)
{
  if (typeof event.stopPropagation != "undefined")
  {
    event.stopPropagation();
  }
  else
  {
    event.cancelBubble = true;
  }
  return false;
}

function attachEventListener(target, eventType, functionRef, capture)
{
  if (typeof target.addEventListener != "undefined")
  {
    target.addEventListener(eventType, functionRef, capture);
  }
  else if (typeof target.attachEvent != "undefined")
  {
    target.attachEvent("on" + eventType, functionRef);
  }
  else
  {
    eventType = "on" + eventType;

    if (typeof target[eventType] == "function")
    {
      var oldListener = target[eventType];

      target[eventType] = function()
      {
        oldListener();

        return  functionRef();
      }
    }
    else
    {
      target[eventType] = functionRef;
    }
  }

  return true; 
}

function addLoadListener(fn)
{
  if (typeof window.addEventListener != 'undefined')
  {
    window.addEventListener('load', fn, false);
  }
  else if (typeof document.addEventListener != 'undefined')
  {
    document.addEventListener('load', fn, false);
  }
  else if (typeof window.attachEvent != 'undefined')
  {
    window.attachEvent('onload', fn);
  }
  else
  {
    var oldfn = window.onload;
    if (typeof window.onload != 'function')
    {
      window.onload = fn;
    }
    else
    {
      window.onload = function()
      {
        oldfn();
        fn();
      };
    }
  }
}
