
//validate comp form
function CheckCompForm() {
	// The fields are checked for blanks
	if (document.compForm.firstname.value   == "" ||
	    document.compForm.surname.value   == "" ||
	    document.compForm.email.value  == "" ) {
	    	alert( "You haven't completed the form.\nPlease ensure that all required fields are filled in.");
		}
		
	// check for valid email address
	else if (document.compForm.email.value.length <= 6 ||
      		 document.compForm.email.value.indexOf ('@', 0) == -1 ||
      		 document.compForm.email.value.indexOf ('.', 0) == -1){
				 alert("Sorry, " + document.compForm.email.value + " is not a valid email address.");  
			 }
  	else { 
 		document.compForm.submit()
	}
}


//validate newsletter form
function CheckNewsletterForm() {
	// The fields are checked for blanks
	if (document.newsletterForm.firstname.value   == "" ||
	    document.newsletterForm.surname.value   == "" ||
	    document.newsletterForm.email.value  == "" ) {
	    	alert( "You haven't completed the form.\nPlease ensure that all required fields are filled in.");
		}
		
	// check for valid email address
	else if (document.newsletterForm.email.value.length <= 6 ||
      		 document.newsletterForm.email.value.indexOf ('@', 0) == -1 ||
      		 document.newsletterForm.email.value.indexOf ('.', 0) == -1){
				 alert("Sorry, " + document.newsletterForm.email.value + " is not a valid email address.");  
			 }
  	else { 
 		document.newsletterForm.submit()
	}
}


//validate survey form
function CheckSurveyForm() {
	// The fields are checked for blanks
	if (document.surveyForm.firstname.value   == "" ||
	    document.surveyForm.surname.value   == "" ||
	    document.surveyForm.email.value  == "" ) {
	    	alert( "You haven't completed the form.\nPlease ensure that all required fields are filled in.");
		}
		
	// check for valid email address
	else if (document.surveyForm.email.value.length <= 6 ||
      		 document.surveyForm.email.value.indexOf ('@', 0) == -1 ||
      		 document.surveyForm.email.value.indexOf ('.', 0) == -1){
				 alert("Sorry, " + document.surveyForm.email.value + " is not a valid email address.");  
			 }
  	else { 
 		document.surveyForm.submit()
	}
}

//validate unsubscribe form
function CheckUnsubscribeForm() {
	// The fields are checked for blanks
	if (document.unsubscribeForm.email.value  == "" ) {
	    	alert( "You haven't completed the form.\nPlease ensure that all required fields are filled in.");
		}
		
	// check for valid email address
	else if (document.unsubscribeForm.email.value.length <= 6 ||
      		 document.unsubscribeForm.email.value.indexOf ('@', 0) == -1 ||
      		 document.unsubscribeForm.email.value.indexOf ('.', 0) == -1){
				 alert("Sorry, " + document.unsubscribeForm.email.value + " is not a valid email address.");  
			 }
  	else { 
 		document.unsubscribeForm.submit()
	}
}


//popup
function popUp(URL, w, h)
{
    var day = new Date();
    var id = day.getTime();
    eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=no,scrollbars=yes,location=no,statusbar=no,menubar=no,resizable=yes,width=" + w + ",height=" + h + ",left=212,top=184');");
} 
