
function check_email(e) {
	ok = "1234567890qwertyuiop[]asdfghjklzxcvbnm.@-_QWERTYUIOPASDFGHJKLZXCVBNM";

	for(i=0; i < e.length ;i++){
		if(ok.indexOf(e.charAt(i))<0){ 
		return (false);
		}	
	} 

	if (document.images) {
		re = /(@.*@)|(\.\.)|(^\.)|(^@)|(@$)|(\.$)|(@\.)/;
		re_two = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
		if (!e.match(re) && e.match(re_two)) {
			return (-1);		
		} 

	}

}

// next function //

function isNumberKey(evt)
  {
	 var charCode = (evt.which) ? evt.which : event.keyCode
	 if (charCode > 31 && (charCode < 48 || charCode > 57))
		return false;

	 return true;

}

// next function //

//contact form //
function submitCheckContact() {

	if (document.contactForm.name.value.replace(/\s+/i,"")=="") {
		 alert("Please enter your name");
		 document.contactForm.name.style.background = "#FFFFB7";
		 document.contactForm.name.focus();
		 return false;
	}
	if (document.contactForm.pc.value.replace(/\s+/i,"")=="") {
		 alert("Please enter your post code");
		 document.contactForm.pc.style.background = "#FFFFB7";
		 document.contactForm.pc.focus();
		 return false;
	}
	if(!check_email(document.contactForm.email.value)){
		alert("Please enter a valid email address.");
		document.contactForm.email.focus();
		if(document.all || document.getElementByID){
		document.contactForm.email.style.background = "#FFFFB7";
		}
		return false;
		}
	if (document.contactForm.phone.value.replace(/\s+/i,"")=="") {
		 alert("Please enter a contact number");
		 document.contactForm.phone.style.background = "#FFFFB7";
		 document.contactForm.phone.focus();
		 return false;
	}
	return true;
}

//subscribe
function subCheck() {

	if (document.subForm.firstName.value.replace(/\s+/i,"")=="") {
		 alert("Please enter your first name");
		 document.subForm.firstName.style.background = "#FFFFB7";
		 document.subForm.firstName.focus();
		 return false;
	}
	if (document.subForm.lastName.value.replace(/\s+/i,"")=="") {
		 alert("Please enter your last name");
		 document.subForm.lastName.style.background = "#FFFFB7";
		 document.subForm.lastName.focus();
		 return false;
	}
	if(!check_email(document.subForm.email.value)){
		alert("Please enter a valid email address.");
		document.subForm.email.focus();
		if(document.all || document.getElementByID){
			document.subForm.email.style.background = "#FFFFB7";
		}
	return false;
	}
	if (document.subForm.address.value.replace(/\s+/i,"")=="") {
		 alert("Please enter your address");
		 document.subForm.address.style.background = "#FFFFB7";
		 document.subForm.address.focus();
		 return false;
	}
	if (document.subForm.suburb.value.replace(/\s+/i,"")=="") {
		 alert("Please enter your suburb");
		 document.subForm.suburb.style.background = "#FFFFB7";
		 document.subForm.suburb.focus();
		 return false;
	}
	if (document.subForm.postCode.value.replace(/\s+/i,"")=="") {
		 alert("Please enter post code");
		 document.subForm.postCode.style.background = "#FFFFB7";
		 document.subForm.postCode.focus();
		 return false;
	}
	if (document.subForm.country.value.replace(/\s+/i,"")=="") {
		 alert("Please enter a country");
		 document.subForm.country.style.background = "#FFFFB7";
		 document.subForm.country.focus();
		 return false;
	}
	if (document.subForm.phone.value.replace(/\s+/i,"")=="") {
		 alert("Please enter a phone number");
		 document.subForm.phone.style.background = "#FFFFB7";
		 document.subForm.phone.focus();
		 return false;
	}
	return true;
}