function validate()
{
	//define error messages
	var msg = document.getElementById("strMessage");
	msg.innerHTML = "The following errors have occurred (Click on each error to rectify the respective field):";
	var strname = "<li><a href='#' onclick='javascript: document.form1.name.focus();'>Please enter a name.</a></li>";
	var strjob_title = "<li><a href='#' onclick='javascript: document.form1.job_title.focus();'>Please enter a job title</a></li>";
	var strcompany = "<li><a href='#' onclick='javascript: document.form1.company.focus();'>Please provide a company name.</a></li>";
	var strcountry = "<li><a href='#Country' onclick='javascript: document.form1.country.focus();'>Please select a country</a></li>";
	var stremail = "<li><a href='#' onclick='javascript: document.form1.email.focus();'>Please provide an email address.</a></li>";
	var stremail2 = "<li><a href='#' onclick='javascript: document.form1.email.focus();'>Please provide a valid email address.</a></li>";
	var straddress = "<li><a href='#' onclick='javascript: document.form1.address.focus();'>Please provide your address</a></li>";
	var strbusiness = "<li><a href='#' onclick='javascript: document.form1.business.focus();'>Please provide your nature of business</a></li>";
	var strtelephone = "<li><a href='#' onclick='javascript: document.form1.telephone.focus();'>Please provide your telephone number.</a></li>";
	var strfax = "<li><a href='#' onclick='javascript: document.form1.fax.focus();'>Please provide your fax number.</a></li>";


	var blnFlagError = false;
	//end of define error messages



	if (document.form1.name.value == "")
	{
		msg.innerHTML += strname;
		changeStyle("name", "input_style2");
		blnFlagError = true;
	} else if (document.form1.name.value != "") {
		changeStyle("name", "input_style");
	}
	

	if (document.form1.job_title.value == "")
	{
		msg.innerHTML += strjob_title;
		changeStyle("job_title", "input_style2");
		blnFlagError = true;
	} else if (document.form1.job_title.value != "") {
		changeStyle("job_title", "input_style");
	}


	if (document.form1.company.value == "")
	{
		msg.innerHTML += strcompany;
		changeStyle("company", "input_style2");
		blnFlagError = true;
	} else if (document.form1.company.value != "") {
		changeStyle("company", "input_style");
	}


	if (document.form1.address.value == "")
	{
		msg.innerHTML += straddress;
		changeStyle("address", "input_style2");
		blnFlagError = true;
	} else if (document.form1.address.value != "") {
		changeStyle("address", "input_style");
	}

	if (document.form1.business.value == "")
	{
		msg.innerHTML += strbusiness;
		changeStyle("business", "input_style2");
		blnFlagError = true;
	} else if (document.form1.business.value != "") {
		changeStyle("business", "input_style");
	}



	if (document.form1.country.selectedIndex<=0)
	{
		msg.innerHTML += strcountry;
		blnFlagError = true;
	} 


	if (document.form1.telephone.value == "")
	{
		msg.innerHTML += strtelephone;
		changeStyle("telephone", "input_style2");
		blnFlagError = true;
	} else if (document.form1.telephone.value != "") {
		changeStyle("telephone", "input_style");
	}


	if (document.form1.fax.value == "")
	{
		msg.innerHTML += strfax;
		changeStyle("fax", "input_style2");
		blnFlagError = true;
	} else if (document.form1.fax.value != "") {
		changeStyle("fax", "input_style");
	}


	if (document.form1.email.value == "")
	{
		msg.innerHTML += stremail;
		changeStyle("email", "input_style2");
		blnFlagError = true;
	} else if (document.form1.email.value != "") {
		if ((document.form1.email.value.indexOf("@") == -1) || (document.form1.email.value.indexOf(".")==-1) || (document.form1.email.value.indexOf(" ")>1) || (document.form1.email.value.indexOf(",")>0))
		{
			msg.innerHTML += stremail2;
			changeStyle("email", "input_style2");
			blnFlagError = true;
		} else if (document.form1.email.value != "") {
			changeStyle("email", "input_style");
		}

	}








	if (blnFlagError == true)
	{
		ErrorMsg.style.display = "block";
		blnFlagError = false;
		return false;
	}
	
}

function changeStyle(element, style)
{
	var id = document.getElementById(element);
	
	id.className = style;
}

function validateInvalidChars(element)
{
	var input = document.getElementById(element).value;
	
	var strInvalidChars = /[^a-zA-Z0-9_-]/i;	//check for characters not withstanding a to z, A to Z, 0 to 9, underscore and hyphen;
												//i = case insensitive
	var objRegExp = new RegExp(strInvalidChars);
	
	return objRegExp.test(input);	//true = input string is invalid (contains invalid chars);
									//false = input string is valid
}