function EmailCheck(myForm)
{
    errorArray = new Array(50);
    for (var i=0; i < errorArray.length; i++)
    {
        errorArray[i] = "";
    }
    var errorCount = 0;
    var errors = false;

    if (myForm.email.value == "")
    {
        errorArray[errorCount++] = "You must fill in your Email Address.";
        errors = true;
        emailerror=true;
        
    } else {
        if (!ValidateEmail(myForm.email.value)) {
        errorArray[errorCount++] = "Your Email Address is invalid.";
        errors = true;
        emailerror=true;
        }
    }
       
    if (errors)
    {
        var errormessage = "";
        for (var i=0; i < errorCount; i++)
        {
            errormessage = errormessage + errorArray[i] + "\n";
        }
        alert("Error(s):\n\n" + errormessage + "\n" );
        return false;
    }
    else
    {
        return true;
    }
}

function ValidateEmail(pString)
{
    var a;
    pString = trim(pString);
    if (!(pString==""))
    {         
       if(pString.search(/\.\./) != -1) 
          return false; 
       if(pString.search(/^([A-Z0-9_\-]+[A-Z0-9_\.\-]*[A-Z0-9_\-]|[A-Z0-9]{1})@[A-Z0-9_\-]+[A-Z0-9_\.\-]*\.[A-Z0-9_\-]+$/i) == -1)
          return false; 
       else
          return true;
    }
    else return false;
}

function trim(pString)
{
    /*trim leading and trailing blanks*/

    if(pString=="")
        return pString;
    var i=0;
    while (pString.charAt(i)==" " && i < pString.length)i++;
    start = i;
    if (start==pString.length)
      return "";
    i=pString.length - 1
    while (pString.charAt(i)==" " && i > 0)i--;
    end= i+1;

    return pString.substring(start, end);
}

function checkRadioControl(strFieldName){
     var objFormField = strFieldName
     intControlLength = objFormField.length
     bolSelected = false;
     for (i=0;i<intControlLength;i++){
          if(objFormField[i].checked){
                    bolSelected = true;
                    break;
          }
     }     
     if(! bolSelected){
          return false;
     }else{
          return true;
     }
}

function chkSelections(oSelect, limit){
    var count = 0;
     var i = 0;
     for(i ; i < oSelect.length; i++)
		{ 
			if(oSelect[i].selected)
				{
				oHistory = i;
				count++;
				}
			if(count > limit)
				{ 
				oSelect[oHistory].selected = false;
				alert("You're only allowed a maximum of " + limit + " selections.");
				break;
				}
		}
}

 function getSelected(opt) {
      var selected="";
      var index = 0;
      for (var intLoop=0; intLoop < opt.length; intLoop++) {
         if (opt[intLoop].selected) {
			selected = selected + " - " + opt[intLoop].value;
         }
      }
      return selected;
   }