function testEmail(src) {
	var emailReg = "^[\\w-_\.]*[\\w-_\.]\@[\\w]\.+[\\w]+[\\w]$";
	var regex = new RegExp(emailReg);
	return regex.test(src);
}

function validateSubscribeForm() {
var winner;
winner = "winner";
firstname = document.forms['frmMain'].Name.value;
surname = document.forms['frmMain'].Surname.value;
email = document.forms['frmMain'].EmailAddr.value;
fsrc="http://www.vodacomdurbanjuly.co.za/durbanjuly3/thanks.php3?firstname=" + firstname+ "&surname=" + surname+ "&email=" + email+ "&winner=" + winner;
document.forms['frmMain'].RedirectURL.value = fsrc;

errormessagesub="";
inputErrorsub = false;	
if (!testEmail(document.forms['frmMain'].EmailAddr.value)){
	inputErrorsub = true;
	errormessagesub+= "You must supply a valid email address (or else how can we let you know if you're a winner?)\n";
	}	

	if (inputErrorsub){
	alert("ERROR:\n" + errormessagesub);
	return false
	}	
	else return true;	
	
}

function validatecheckbox()	
	{
		if (!document.forms['contactform'].terms.checked)
		{
			alert("Please indicate that you accept the terms and conditions");
			document.forms['contactform'].terms.checked = true;
		}
	}


//document.contactform.postal_building_name.value == "" && document.contactform.postal_street_name.value == "" && document.contactform.postal_town.value == "" && document.contactform.postal_postcode.value == "" && document.contactform.building_name.value == "" && document.contactform.street_name.value == "" && document.contactform.town.value == "" && document.contactform.postcode.value == "" && 
//document.contactform.liaison_person.value == "" && document.contactform.designation.value == "" && document.contactform.telephone.value == "" && document.contactform.fax.value == "" && document.contactform.cell.value == "" && document.contactform.mail.value == "" && document.contactform.exhibit_name.value == "" && document.contactform.exhibit_description.value == ""	
	
function validateContactForm() {
errormessagecon="";
inputErrorcon = false;
if ((document.forms['contactform'].company_name.value == "")) {
	inputErrorcon = true;
	errormessagecon+= "Please enter your company name.\n";
	}
	
if ((document.forms['contactform'].liaison_person.value == "")) {
	inputErrorcon = true;
	errormessagecon+= "Please enter contact person.\n";
	}

if ((document.forms['contactform'].exhibit_name.value == "")) {
	inputErrorcon = true;
	errormessagecon+= "Please enter the name the company wishes to exhibit as.\n";
	}
	
	
if (!testEmail(document.forms['contactform'].mail.value)){
	inputErrorcon = true;
	errormessagecon+= "Please enter your email address\n";
	}	
	
if (!document.forms['contactform'].agree.checked)
	{
	//alert("Please indicate that you accept the terms and conditions");
	inputErrorcon = true;
	errormessagecon+= "Please indicate that you accept the terms and conditions.\n"
	document.forms['contactform'].agree.focus;
	}
		
	if (inputErrorcon){
	alert("ERROR:\n" + errormessagecon);
	return false
	}	
	else return true;
	
	
}

function validatesimpleContactForm() {
errormessagecon="";
inputErrorcon = false;
if ((document.forms['frmMainsimpleContact'].Name.value == "")) {
	inputErrorcon = true;
	errormessagecon+= "Please enter your name\n";
	}
	
if ((document.forms['frmMainsimpleContact'].Phone.value == "")) {
	inputErrorcon = true;
	errormessagecon+= "Please enter your phone number\n";
	}

if (!testEmail(document.forms['frmMainsimpleContact'].Email.value)){
	inputErrorcon = true;
	errormessagecon+= "Please enter your email address\n";
	}	

		
	if (inputErrorcon){
	alert("ERROR:\n" + errormessagecon);
	return false
	}	
	else return true;
	
	
}  
  
function validateForm() {

errormessage="";
inputError = false;

if ((document.forms['tickets'].firstname.value == "")||(document.forms['tickets'].surname.value == "")) {
	inputError = true;
	errormessage+= "Please enter both your first name and your surname\n";
	}

if ((document.forms['tickets'].idnumber.value == "")&&(document.forms['tickets'].passport.value == "")) {
	inputError = true;
	errormessage+= "Please enter either a valid South African ID number or a Passport number\n";
	}

if (document.forms['tickets'].delivery.value == "") {
	inputError = true;
	errormessage+= "Please enter a delivery address\n";
	}

if (document.forms['tickets'].postal.value == "") {
	inputError = true;
	errormessage+= "Please enter a postal address\n";
	}

if (!testEmail(document.forms['tickets'].emailaddress.value)){
	inputError = true;
	errormessage+= "Please enter your email address\n";
	}

if ((document.forms['tickets'].cellphone.value == "")&&(document.forms['tickets'].landline.value == "")&&(document.forms['tickets'].fax.value == "")) {
	inputError = true;
	errormessage+= "Please enter either a phone or a fax number\n";
	}

if (document.forms['tickets'].quantity.value == "") {
	inputError = true;
	errormessage+= "You must purchase at least one ticket - please select the appropriate quantity of tickets\n";
	}

if (document.forms['tickets'].ccnumber.value == "") {
	inputError = true;
	errormessage+= "Please enter your credit card number\n";
	}

if (document.forms['tickets'].ccname.value == "") {
	inputError = true;
	errormessage+= "Please enter the name on your credit card \n";
	}

if (document.forms['tickets'].ccexpiry.value == "") {
	inputError = true;
	errormessage+= "Please enter the expiry date on your credit card \n";
	}

if (document.forms['tickets'].ccv.value == "") {
	inputError = true;
	errormessage+= "Please enter the CCV number on your credit card \n";
	}

if (document.forms['tickets'].cardtype.value == "") {
	inputError = true;
	errormessage+= "Please select the type of credit card \n";
	}

if (document.forms['tickets'].conditions.checked == false) {
	inputError = true;
	errormessage+= "You must agree to the terms and conditions \n";
	}

if (inputError){
	alert("ERROR:\n" + errormessage);
	return false
	}
	
else return true;

}


	
	
	
	
	
	
	
	
	
	
	