function checkData(w) {

	if (w.salutation  && w.salutation.value == "")
	{	alert("Please enter your salutation");
		w.salutation.focus();
		return false;
	}

	if (w.firstname  && !validName(w.firstname.value, "First Name"))
	{	w.firstname.focus();
		return false;
	}

	if (w.lastname && !validName(w.lastname.value, "Last Name"))
	{	w.lastname.focus();
		return false;
	}
	
	if (w.yourname  && !validName(w.yourname.value, "Your Name"))
	{	w.yourname.focus();
		return false;
	}
	
	if(w.youremail && w.youremail.value == "")
	{	alert("Please enter your email");
		w.youremail.focus();
		return false;
	}
	
	if (w.friendname  && !validName(w.friendname.value, "Friends Name"))
	{	w.friendname.focus();
		return false;
	}

	if(w.friendemail && w.friendemail.value == "")
	{	alert("Please enter your friend's email");
		w.friendemail.focus();
		return false;
	}
	
	if(w.phone1 && !validNums(w.phone1.value, "Phone Number"))
	{	w.phone1.focus();
		return false;
	}
	
	if(w.fax1 && !validNums(w.fax1.value, "Fax Number"))
	{	w.fax1.focus();
		return false;
	}
	
	if(w.required_email && w.required_email.value == "")
	{	alert("Please enter an email address");
		w.required_email.focus();
		return false;
	}
	
	if(w.appointment_date && w.appointment_date.value == "")
	{	alert("Please enter an appointment date");
		w.appointment_date.focus();
		return false;
	}
	
	if(w.appointment_time && w.appointment_time.value == "")
	{	alert("Please enter an appointment time");
		w.appointment_time.focus();
		return false;
	}
	
	if(w.store_location && w.store_location.value == "null")
	{	alert("Please enter a store location");
		w.store_location.focus();
		return false;
	}
	
	if(w.treatments_packages && w.treatments_packages.value == "")
	{	alert("Please enter the type of treatments/packages");
		w.treatments_packages.focus();
		return false;
	}

	if(w.comments_book && w.comments_book.value == "")
	{	alert("Please enter comments");
		w.comments_book.focus();
		return false;
	}
	
	if(w.address && w.address.value == "")
	{	alert("Please enter your address");
		w.address.focus();
		return false;
	}

	
	if(w.suburb && !validSuburb(w.suburb.value, "Suburb"))
	{	w.suburb.focus();
		return false;
	}
	
	if(w.city && !validCity(w.city.value, "City"))
	{	w.city.focus();
		return false;
	}

	// required field
	if (w.state.selectedIndex == 0)
	{	alert("Please choose a State.");
		w.state.focus();
		return false;
	}

	// if not empty, validate the contents
	if (w.post && !validpost(w.post.value, "Post Code"))
	{	w.post.focus();
		return false;
	}
	
	if(w.store_location_vip && w.store_location_vip.value == "null")
	{	alert("Please enter a store location");
		w.store_location_vip.focus();
		return false;
	}
	
	if (w.f_phone && w.f_phone.value == "")
	{	w.f_phone.focus();
		alert("Please enter your phone number.");
		return false;
	}

	// if not empty, validate the contents
	if (w.capital_to_invest && w.capital_to_invest.value == "null")
	{	alert("Please select an investment amount.");
		w.capital_to_invest.focus();
		return false;
	}

	// if not empty, validate the contents
	if (w.investment_time_frame && w.investment_time_frame.value == "null")
	{	alert("Please select an time frame.");
		w.investment_time_frame.focus();
		return false;
	}
	
	// if not empty, validate the contents
	if (w.desired_location && w.desired_location.value == "")
	{	alert("Please enter your desired location.");
		w.desired_location.focus();
		return false;
	}
	
	// required field
	if (w.enquiry && w.enquiry.value == "")
	{	alert("Please enter your enquiry.");
		w.enquiry.focus();
		return false;
	}

	if (w.product_description_quantity && w.product_description_quantity.value == "")
	{	w.product_description_quantity.focus();
		alert("Please enter the product description and quantity");
		return false;
	}	

	if (w.delivery_address && !validAddress(w.delivery_address.value, "Delivery Address"))
	{	w.delivery_address.focus();
		return false;
	}	
	
	
	if (w.mobile_phone && w.mobile_phone.value == "")
	{	w.mobile_phone.focus();
		alert("Please enter your mobile phone number.");
		return false;
	}
	
	// required field
	if (w.comments && w.comments.value == "")
	{	w.comments.focus();
		alert("Please enter your comments.");
		return false;
	}
	
	// required field
	if (w.send_info_by[0].checked == false && w.send_info_by[1].checked == false)
	{	w.send_info_by.focus();
		alert("Please enter your contact preference.");
		return false;
	}
		
	if (w.last_visited_beauty_clinic && w.last_visited_beauty_clinic.value == "")
	{	w.last_visited_beauty_clinic.focus();
		alert ("Please enter all required fields");
		return false;
	}
	
	if (w.how_many_visits_in_last_12_months && w.how_many_visits_in_last_12_months.value == "")
	{	w.how_many_visits_in_last_12_months.focus();
		alert ("Please enter all fields");
		return false;
	}
	
	if (w.how_you_feel_about_encouraging_men_to_salons && w.how_you_feel_about_encouraging_men_to_salons.value == "")
	{	w.how_you_feel_about_encouraging_men_to_salons.focus();
		alert ("Please enter all fields");
		return false;
	}

	if (w.payment_details && w.payment_details.value == "")
	{	w.payment_details.focus();
		alert ("Please enter your payment details");
		return false;
	}
	
	if (w.what_would_attract_men_to_salons && w.what_would_attract_men_to_salons.value == "")
	{	w.what_would_attract_men_to_salons.focus();
		alert ("Please enter all fields");
		return false;
	}

	return true;
}

function validName(n, t)
{	if (n == "")
	{	alert("Please enter your "+ t +".")
		return false;
	}
	else
	{	var Chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ -";
		for (var i = 0; i < n.length; i++)
		{	if (Chars.indexOf(n.charAt(i)) == -1)
			{	alert ("Please enter a valid "+ t +".")
				return false
			}
		}
	}

	return true;
}

function validNums(n, t)
{	if (n == "")
	{	alert("Please enter a "+ t +".")
		return false;
	}
	else
	{	var Chars = "0123456789";
		for (var i = 0; i < n.length; i++)
		{	if (Chars.indexOf(n.charAt(i)) == -1)
			{	alert ("Please enter only numbers in "+ t +".")
				return false
			}
		}
	}
	
	return true;
}


function validEmail(e, t)
{	
	if (e == "")
	{
		alert("Please enter your "+t);
		return false;
	}
	var emailStr = e;
	var emailPat=/^(.+)@(.+)$/;
	var specialChars="\\(\\)<>@,;:\*\\\\\"\\.\\[\\]";
	var validChars="\[^\\s" + specialChars + "\]";
	var quotedUser="([^\"]*\")";
	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
	var atom=validChars + '+';
	var word="(" + atom + "|" + specialChars + ")";
	var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
	var matchArray=emailStr.match(emailPat);
	if (matchArray==null)
	{	alert("Your "+ t +" seems incorrect. Please check @ and .'s!");
		return false;
	}

	var user=matchArray[1];
	var domain=matchArray[2];
	if (user.match(userPat)==null)
	{	alert("Please do not use any symbols (ie. quotes or asterisks) other than @ in your "+ t +".");
		return false;
	}

	var IPArray=domain.match(ipDomainPat);
	if (IPArray!=null)
	{  for (var i=1;i<=4;i++)
		  {	if (IPArray[i]>255)
			{	alert("Destination IP address is invalid!");
				return false;
			}
		}
	}

	var domainArray=domain.match(domainPat)
	if (domainArray==null)
	{	alert("Your "+ t +" domain name doesn't seem to be valid.");
		return false;
	}

	var atomPat=new RegExp(atom,"g");
	var domArr=domain.match(atomPat);
	var len=domArr.length;
	if (domArr[domArr.length-1].length<2 || domArr[domArr.length-1].length>3)
	{	alert("Your "+ t +" must end in a three-letter domain, or two letter country.");
		return false;
	}

	var Chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
	if (domArr[domArr.length-1].length == 2 || domArr[domArr.length-1].length == 3)
	{	for (var i = 0; i < domArr[domArr.length-1].length; i++)
		{	if (Chars.indexOf(domArr[domArr.length-1].charAt(i)) == -1)
			{	alert("The domain name can only contain letters.");
				return false;
			}
		}
	}

	if (len<2 || len>3)
	{	alert("Your "+ t +" is missing a hostname!");
		return false;
	}

	return true;
}

function validCompany(n, t)
{	if (n == "")
	{	alert("Please enter your "+ t +".")
		return false;
	}
	else
	{	var Chars = "1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ -";
		for (var i = 0; i < n.length; i++)
		{	if (Chars.indexOf(n.charAt(i)) == -1)
			{	alert ("Please enter a valid "+ t +".")
				return false
			}
		}
	}

	return true;
}

function validAddress(n, t)
{	if (n == "")
	{	alert("Please enter your "+ t +".")
		return false;
	}
	else
	{	var Chars = "1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ/\ -";
		for (var i = 0; i < n.length; i++)
		{	if (Chars.indexOf(n.charAt(i)) == -1)
			{	alert ("Please enter a valid "+ t +".")
				return false
			}
		}
	}

	return true;
}

function validSuburb(n, t)
{	if (n == "")
	{	alert("Please enter your "+ t +".")
		return false;
	}
	else
	{	var Chars = "1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ -";
		for (var i = 0; i < n.length; i++)
		{	if (Chars.indexOf(n.charAt(i)) == -1)
			{	alert ("Please enter a valid "+ t +".")
				return false
			}
		}
	}

	return true;
}

function validCity(n, t)
{	if (n == "")
	{	alert("Please enter your "+ t +".")
		return false;
	}
	else
	{	var Chars = "1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ -";
		for (var i = 0; i < n.length; i++)
		{	if (Chars.indexOf(n.charAt(i)) == -1)
			{	alert ("Please enter a valid "+ t +".")
				return false
			}
		}
	}

	return true;
}


function validpost(z, t) {
	if (z == "")
	{	alert("Please fill in your "+ t +".");
		return false; 
	}
	else
	{	// check to see that the value contains at least 4 numbers
		if (z.length < 4)
		{	alert ("Please enter at least 4 numbers into the "+ t +" field.");
			return false;
		}
		// check to see that the value contains either 5 or 10 numbers
		if (z.length > 4 )
		{	alert ("Your post code must only contain 4 digits.");
			return false;
		}
		// check to see that the value contains only numbers
		var nums = "0123456789";
		for (var i = 0; i < z.length; i++)
		{	if (nums.indexOf(z.charAt(i)) == -1)
			{	alert ("Please enter only numbers into the "+ t +" field.");
				return false;
			}
		}
	}
	
	return true;
}
