function isEmailAddr(s) {
	var rv = false;
	if ((s == null) || (s.length == 0)) rv = false;
	else {
		var reEmail = /([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		rv = reEmail.test(s);
	}
	if (rv) return rv;
	else {
		return false;
	}
}


function checkoutValidate(theForm)
{
	if (theForm.firstName.value == "") {
		alert("Please enter your first name");
		theForm.firstName.focus();
		returnObjById("starFName").style.color = "red"
		return false;
	}
	else
	{
		returnObjById("starFName").style.color = "#3A7491"
	}
	
	if (theForm.lastName.value == "") {
		alert("Please enter your last name");
		theForm.lastName.focus();
		returnObjById("starLName").style.color = "red"
		return false;
	}
	else
	{	
		returnObjById("starLName").style.color = "#3A7491"
	}
	
	if(theForm.emailAddress.value == "")
	{
		alert("Please enter your email address");
		theForm.emailAddress.focus();
		returnObjById("starEmail").style.color = "red"
		return false;
	}
	else
	{
		returnObjById("starEmail").style.color = "#3A7491"
	}
	
	if (!isEmailAddr(theForm.emailAddress.value)) {
		alert("Please enter your email address correctly");
		theForm.emailAddress.focus();
		returnObjById("starEmail").style.color = "red"
		return false;
	}
	else
	{
		returnObjById("starEmail").style.color = "#3A7491"
	}

	if (theForm.contactPhone.value == "") {
		alert("Please enter your contact phone number");
		theForm.contactPhone.focus();
		returnObjById("starPhone").style.color = "red"
		return false;
	}
	else
	{
		returnObjById("starPhone").style.color = "#3A7491"
	}

	
	if (theForm.salonName.value == "") {
		alert("Please enter your salon name");
		theForm.salonName.focus();
		returnObjById("starSalonName").style.color = "red"
		return false;
	}	
	else
	{
		returnObjById("starSalonName").style.color = "#3A7491"
	}

	
	if (!theForm.customerType[0].checked && !theForm.customerType[1].checked && !theForm.customerType[2].checked && !theForm.customerType[3].checked) {
		alert("Please specify your occupation");
		theForm.customerType[0].focus();
		returnObjById("starBuyerType").style.color = "red"
		return false;
	}
	else
	{
		returnObjById("starBuyerType").style.color = "#3A7491"
	}
	
	if (!theForm.operateType[0].checked && !theForm.operateType[1].checked && !theForm.operateType[2].checked && !theForm.operateType[3].checked && !theForm.operateType[4].checked) {
		alert("Please specify the operation type of your salon");
		theForm.operateType[0].focus();
		returnObjById("starBusinessType").style.color = "red"
		return false;
	}
	else
	{
		returnObjById("starBusinessType").style.color = "#3A7491"
	}

	if (theForm.streetNo.value == "") {
		alert("Please enter your street number");
		theForm.streetNo.focus();
		returnObjById("starStreetNo").style.color = "red"
		return false;
	}
	else
	{
		returnObjById("starStreetNo").style.color = "#3A7491"
	}

	if (theForm.city.value == "") {
		alert("Please enter your city");
		theForm.city.focus();
		returnObjById("starCity").style.color = "red"
		return false;
	}
	else
	{
		returnObjById("starCity").style.color = "#3A7491"
	}

	if (theForm.zip.value == "") {
		alert("Please enter your zip/postal code");
		theForm.zip.focus();
		returnObjById("starZip").style.color = "red"
		return false;
	}
	else
	{
		returnObjById("starZip").style.color = "#3A7491"
	}

	
	if (theForm.pstreetNo.value != "" || theForm.pcity.value != "" || theForm.pzip.value !="" || theForm.pcountry.options[theForm.pcountry.selectedIndex].value != "New Zealand") {
		if(trim(theForm.pstreetNo.value) == "")
		{
			alert("Please enter your street number for delivery address");
			theForm.pstreetNo.focus();
			returnObjById("starPStreetNo").style.color = "red"
			return false;
		}
		else
		{
			returnObjById("starPStreetNo").style.color = "#3A7491"
		}

		
		if(theForm.pcity.value == "")
		{
			alert("Please enter your city for delivery address");
			theForm.pcity.focus();
			returnObjById("starPCity").style.color = "red"
			return false;
		}
		else
		{
			returnObjById("starPCity").style.color = "#3A7491"
		}		
		
		if(theForm.pzip.value == "")
		{
			alert("Please enter your zip/postal code for delivery address");
			theForm.pzip.focus();
			returnObjById("starPZip").style.color = "red"
			return false;
		}
		else
		{
			returnObjById("starPZip").style.color = "#3A7491"
		}

	}

	if(!theForm.acceptTerms.checked)
	{
		alert("You need to accept the Terms and Conditions to process your order");
		theForm.acceptTerms.focus();
		return false;
	}
	
	return true;	

}