var field_main;

function do_blink(field)
{
	var errorcolor="#ff0000";
	field.focus();
	field.select();
	field.style.background=errorcolor;
    field_main=field;
	setInterval("temp()",500);
	
}

function temp(field)
{
	var okcolor="#ffffff";
	field_main.style.background=okcolor;
}

// client registration validation starts
function ClientRegistartionForm(f)
{
		
	if(f.fname.value == "")
	{
		alert("First Name is Mandatory.");
		do_blink(f.fname);
		return(false);
	}
	else
	{
		var strRegExp = "[^A-Za-z\\s]";
		var check = f.fname.value.search(strRegExp);
		 if(check >= 0) 
    	{
			alert("Only alphabetic characters and space allowed.");
			do_blink(f.fname);
			return(false);
		}
	}
	
	if(f.interest.value == "")
	{
		alert("Area of Interest is Mandatory.");
		do_blink(f.interest);
		return(false);
		
	}
	if(f.interest.value == 0)
	{
		if(f.interestother.value == "")
		{
			alert("Area of Interest is Mandatory.");
			do_blink(f.interestother);
			return(false);
		}
		
	}
	
	if(f.address.value == ""){
		alert("Address is Mandatory.");
		do_blink(f.address);
		return(false);
	}
	if(f.country.value == ""){
		alert("Country is Mandatory.");
		do_blink(f.country);
		return(false);
	}
	
	
	
	
		
	if(f.city.value == ""){
		alert("City is Mandatory.");
		do_blink(f.city);
		return(false);
	}
	else
	{
		var strRegExp = "[^A-Za-z0-9\\s]";
		var check = f.city.value.search(strRegExp);
		 if(check >= 0) 
    	{
			alert("Only alpha-numeric characters and space allowed.");
			do_blink(f.city);
			return(false);
		}
	}
	if(f.phone.value == "")
	{
		alert("Phone is Mandatory.");
		do_blink(f.phone);
		return(false);
	}
	else
	{
		if(f.phone.value.length < 7)
		{
			alert("Minimum seven digit for phone number.");
			do_blink(f.phone);
			return(false);
		}
		if(isNaN(f.phone.value)){
			alert("Phone must be number.");
			do_blink(f.phone);
			return(false);
		}
	}
	
	if(f.email.value == ""){
		alert("Email is Mandatory.");
		do_blink(f.email);
		return(false);
	}
	else
	{
		var f1=f.email.value;
		var emailFilter=/^.+@.+\..{2,3}$/;
		if (!(emailFilter.test(f1))) 
		{ 
		  	alert("Email address is incorrect.");
			do_blink(f.email);
			return(false);
		}
		var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/;
		 if (f1.match(illegalChars)) 
		 {
			 	alert("Email address contains illegal characters.");
				do_blink(f.email);
				return(false);
		 }
		
		
	}
	if(f.password.value == ""){
		alert("Password is Mandatory.");
		do_blink(f.password);
		return(false);
	}
	
	if(f.password.value.length < 6){
		alert("Minimum six digit for password.");
		do_blink(f.password);
		return(false);
	}
	if(f.cpassword.value == ""){
		alert("Confirm Password is Mandatory.");
		do_blink(f.cpassword);
		return(false);
	}
	else
	{
		if(f.password.value != f.cpassword.value){
			alert("Password and Confirm Password did not matched.");
			return(false);
			
		}
	}
	//f.submit();
	return(true);
}
// client registration validation ends

// supplier registartion validation starts
function SupplierRegistartionForm(f)
{
		
	if(f.company.value == ""){
		alert("Company Name is Mandatory.");
		do_blink(f.company);
		return(false);
	}
	else
	{
		
		var strRegExp = "[^A-Za-z0-9\\s]";
		var check = f.company.value.search(strRegExp);
		 if(check >= 0) 
		{
			alert("Only alpha-numeric characters and space allowed.");
			do_blink(f.company);
			return(false);
		}
		
	}
	if(f.fname.value == ""){
		alert("First Name is Mandatory.");
		do_blink(f.fname);
		return(false);
	}
	else
	{
		var strRegExp = "[^A-Za-z\\s]";
		var check = f.fname.value.search(strRegExp);
		 if(check >= 0) 
    	{
			alert("Only alphabetic characters and space allowed.");
			do_blink(f.fname);
			return(false);
		}
	}
	

	
	if(f.department.value != "")
	{
		var strRegExp = "[^A-Za-z0-9\\s]";
		var check = f.department.value.search(strRegExp);
		 if(check >= 0) 
    	{
			alert("Only alpha-numeric characters and space allowed.");
			do_blink(f.department);
			return(false);
		}
	}
	
	
	
	if(f.address.value == ""){
		alert("Address is Mandatory.");
		do_blink(f.address);
		return(false);
	}
	if(f.country.value == ""){
		alert("Country is Mandatory.");
		do_blink(f.country);
		return(false);
	}
	
	
	if(f.city.value == ""){
		alert("City is Mandatory.");
		do_blink(f.city);
		return(false);
	}
	else
	{
		var strRegExp = "[^A-Za-z0-9\\s]";
		var check = f.city.value.search(strRegExp);
		 if(check >= 0) 
    	{
			alert("Only alpha-numeric characters and space allowed.");
			do_blink(f.city);
			return(false);
		}
	}
	if(f.phone.value == "")
	{
		alert("Phone is Mandatory.");
		do_blink(f.phone);
		return(false);
	}
	else
	{
		if(f.phone.value.length < 7)
		{
			alert("Minimum seven digit for phone number.");
			do_blink(f.phone);
			return(false);
		}
		if(isNaN(f.phone.value)){
			alert("Phone must be number.");
			do_blink(f.phone);
			return(false);
		}
	}
	if(f.email.value == ""){
		alert("Email is Mandatory.");
		do_blink(f.email);
		return(false);
	}
	else
	{
		var f1=f.email.value;
		var emailFilter=/^.+@.+\..{2,3}$/;
		if (!(emailFilter.test(f1))) 
		{ 
		  	alert("Email address is incorrect.");
			do_blink(f.email);
			return(false);
		}
		var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/;
		 if (f1.match(illegalChars)) 
		 {
			 	alert("Email address contains illegal characters.");
				do_blink(f.email);
				return(false);
		 }
		
		
	}
	if(f.password.value == ""){
		alert("Password is Mandatory.");
		do_blink(f.password);
		return(false);
	}
	if(f.password.value.length < 6){
		alert("Minimum six digit for password.");
		do_blink(f.password);
		return(false);
	}
	if(f.cpassword.value == ""){
		alert("Confirm Password is Mandatory.");
		do_blink(f.cpassword);
		return(false);
	}
	else
	{
		if(f.password.value != f.cpassword.value){
			alert("Password and Confirm Password did not matched.");
			return(false);
			
		}
	}
	f.submit();
	return(true);
}
// supplier registartion validation ends

// vender registartion validation starts
function VenderRegistartionForm(f)
{
		
	if(f.company.value == ""){
		alert("Company Name is Mandatory.");
		do_blink(f.company);
		return(false);
	}
	else
	{
		
		var strRegExp = "[^A-Za-z0-9\\s]";
		var check = f.company.value.search(strRegExp);
		 if(check >= 0) 
		{
			alert("Only alpha-numeric characters and space allowed.");
			do_blink(f.company);
			return(false);
		}
		
	}
	if(f.fname.value == ""){
		alert("First Name is Mandatory.");
		do_blink(f.fname);
		return(false);
	}
	else
	{
		var strRegExp = "[^A-Za-z\\s]";
		var check = f.fname.value.search(strRegExp);
		 if(check >= 0) 
    	{
			alert("Only alphabetic characters and space allowed.");
			do_blink(f.fname);
			return(false);
		}
	}
	
	
	
	
	
	
	if(f.address.value == ""){
		alert("Address is Mandatory.");
		do_blink(f.address);
		return(false);
	}
	if(f.country.value == ""){
		alert("Country is Mandatory.");
		do_blink(f.country);
		return(false);
	}
	
	
		
	if(f.city.value == ""){
		alert("City is Mandatory.");
		do_blink(f.city);
		return(false);
	}
	else
	{
		var strRegExp = "[^A-Za-z0-9\\s]";
		var check = f.city.value.search(strRegExp);
		 if(check >= 0) 
    	{
			alert("Only alpha-numeric characters and space allowed.");
			do_blink(f.city);
			return(false);
		}
	}
	if(f.phone.value == "")
	{
		alert("Phone is Mandatory.");
		do_blink(f.phone);
		return(false);
	}
	else
	{
		if(f.phone.value.length < 7)
		{
			alert("Minimum seven digit for phone number.");
			do_blink(f.phone);
			return(false);
		}
		if(isNaN(f.phone.value)){
			alert("Phone must be number.");
			do_blink(f.phone);
			return(false);
		}
	}
	
	if(f.email.value == ""){
		alert("Email is Mandatory.");
		do_blink(f.email);
		return(false);
	}
	else
	{
		var f1=f.email.value;
		var emailFilter=/^.+@.+\..{2,3}$/;
		if (!(emailFilter.test(f1))) 
		{ 
		  	alert("Email address is incorrect.");
			do_blink(f.email);
			return(false);
		}
		var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/;
		 if (f1.match(illegalChars)) 
		 {
			 	alert("Email address contains illegal characters.");
				do_blink(f.email);
				return(false);
		 }
		
		
	}
	if(f.password.value == ""){
		alert("Password is Mandatory.");
		do_blink(f.password);
		return(false);
	}
	if(f.password.value.length < 6){
		alert("Minimum six digit for password.");
		do_blink(f.password);
		return(false);
	}
	if(f.cpassword.value == ""){
		alert("Confirm Password is Mandatory.");
		do_blink(f.cpassword);
		return(false);
	}
	else
	{
		if(f.password.value != f.cpassword.value){
			alert("Password and Confirm Password did not matched.");
			return(false);
			
		}
	}
	f.submit();
	return(true);
}
// vender registartion validation ends

//  client/supplier/vender login validation starts
function ClientLogin(f)
{
	if(f.email.value == ""){
		alert("Email is Mandatory.");
		do_blink(f.email);
		return(false);
	}
	else
	{
		var f1=f.email.value;
		var emailFilter=/^.+@.+\..{2,3}$/;
		if (!(emailFilter.test(f1))) 
		{ 
		  	alert("Email address is incorrect.");
			do_blink(f.email);
			return(false);
		}
		var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/;
		 if (f1.match(illegalChars)) 
		 {
			 	alert("Email address contains illegal characters.");
				do_blink(f.email);
				return(false);
		 }
		
		
	}
	if(f.pass.value == ""){
		alert("Password is Mandatory.");
		do_blink(f.pass);
		return(false);
	}
	f.submit();
	return true;
	

}
//  client/supplier/vender login validation ends

// support validation

function CheckSupport(f)
{
	if(f.name.value == ""){
		alert("Name is Mandatory.");
		do_blink(f.name);
		return(false);
	}
	if(f.email.value == ""){
		alert("Email is Mandatory.");
		do_blink(f.email);
		return(false);
	}
	else
	{
		var f1=f.email.value;
		var emailFilter=/^.+@.+\..{2,3}$/;
		if (!(emailFilter.test(f1))) 
		{ 
		  alert("Email address is incorrect.");
		  do_blink(f.email);
			return(false);
		}
		var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/;
		 if (f1.match(illegalChars)) 
		 {
			 alert("Email address is not valid.");
			 do_blink(f.email);
			 return(false);
		 }
		
		
	}
	
	if(f.address.value == ""){
		alert("Address is Mandatory.");
		do_blink(f.address);
		return(false);
	}
	if(f.phone.value == "")
	{
		alert("Phone is Mandatory.");
		do_blink(f.phone);
		return(false);
	}
	else
	{
		if(f.phone.value.length < 7)
		{
			alert("Minimum seven digit for phone number.");
			do_blink(f.phone);
			return(false);
		}
		if(isNaN(f.phone.value)){
			alert("Phone must be number.");
			do_blink(f.phone);
			return(false);
		}
	}
	if(isNaN(f.fax.value)){
		alert("Fax must be number.");
		do_blink(f.fax);
		return(false);
	}
	if(f.comment.value == ""){
		alert("Comment is Mandatory.");
		do_blink(f.comment);
		return(false);
	}
	if(f.code_check.value == ""){
		alert("Code is Mandatory.");
		do_blink(f.code_check);
		return(false);
	}
	
	
	return true;
		
}
//------------------------
// contact us validation

function CheckContactform(f)
{
	if(f.name.value == ""){
		alert("Name is Mandatory.");
		do_blink(f.name);
		return(false);
	}
	if(f.address.value == ""){
		alert("Address is Mandatory.");
		do_blink(f.address);
		return(false);
	}
	
	if(f.email.value == ""){
		alert("Email is Mandatory.");
		do_blink(f.email);
		return(false);
	}
	else
	{
		var f1=f.email.value;
		var emailFilter=/^.+@.+\..{2,3}$/;
		if (!(emailFilter.test(f1))) 
		{ 
		  alert("Email address is incorrect.");
		  do_blink(f.email);
			return(false);
		}
		var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/;
		 if (f1.match(illegalChars)) 
		 {
			 alert("Email address is not valid.");
			 do_blink(f.email);
			 return(false);
		 }
		
		
	}
	if(f.phone.value == "")
	{
		alert("Phone is Mandatory.");
		do_blink(f.phone);
		return(false);
	}
	else
	{
		if(f.phone.value.length < 7)
		{
			alert("Minimum seven digit for phone number.");
			do_blink(f.phone);
			return(false);
		}
		if(isNaN(f.phone.value)){
			alert("Phone must be number.");
			do_blink(f.phone);
			return(false);
		}
	}
	if(f.comment.value == ""){
		alert("Comment is Mandatory.");
		do_blink(f.comment);
		return(false);
	}
	if(f.code_check.value == ""){
		alert("Code is Mandatory.");
		do_blink(f.code_check);
		return(false);
	}
	
	
	return true;
		
}

//--------------

/*
* Functie om shadobox te sluiten
*/
function closeShadowBox()
{
       // Sluit Shadowbox
       window.parent.Shadowbox.close();
}

/*
* Functie om Shadowbox te sluiten en de pagina te verversen
*/
function closeAndReload()
{
       // Sla eerst de parent target op
       var parentStore = window.parent;
       
       // Sluit Shadowbox
       closeShadowBox();
       
       // Refresh de pagina
       parentStore.location.reload();
}

function CheckSubNewsletter(f)
{
	if(f.name.value == ""){
		alert("Name is Mandatory.");
		do_blink(f.name);
		return(false);
	}
	if(f.email.value == ""){
		alert("Email is Mandatory.");
		do_blink(f.email);
		return(false);
	}
	else
	{
		var f1=f.email.value;
		var emailFilter=/^.+@.+\..{2,3}$/;
		if (!(emailFilter.test(f1))) 
		{ 
		  alert("Email address is incorrect.");
		  do_blink(f.email);
			return(false);
		}
		var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/;
		 if (f1.match(illegalChars)) 
		 {
			 alert("Email address is not valid.");
			 do_blink(f.email);
			 return(false);
		 }
		
		
	}
	
	var department = document.getElementsByName('department[]');
	for(i=0;i<department.length;i++)
	{
		if(department[i].value == "")
		{
			 alert("Department is mandatory.");
			 return(false);
		}
		else if(department[i].value == 0)
		{
			 if(f.otherdept.value == "")
			 {
				 alert("Other Department is mandatory.");
			 	 return(false);
			 }
		}
	}
	
	f.submit();
	return true;	
}
//quote

function CheckQuote(f)
{
	
	if(f.fname.value == ""){
		alert("First Name is Mandatory.");
		do_blink(f.fname);
		return(false);
	}
	else
	{
		var strRegExp = "[^A-Za-z\\s]";
		var check = f.fname.value.search(strRegExp);
		 if(check >= 0) 
    	{
			alert("Only alphabetic characters and space allowed.");
			do_blink(f.fname);
			return(false);
		}
	}
	
	if(f.email.value == ""){
		alert("Email is Mandatory.");
		do_blink(f.email);
		return(false);
	}
	else
	{
		var f1=f.email.value;
		var emailFilter=/^.+@.+\..{2,3}$/;
		if (!(emailFilter.test(f1))) 
		{ 
		  	alert("Email address is incorrect.");
			do_blink(f.email);
			return(false);
		}
		var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/;
		 if (f1.match(illegalChars)) 
		 {
			 	alert("Email address contains illegal characters.");
				do_blink(f.email);
				return(false);
		 }
	}
	
	
	if(f.interest.value == "")
	{
		alert("Area of Interest is Mandatory.");
		do_blink(f.interest);
		return(false);
		
	}
	if(f.interest.value == 0)
	{
		if(f.interestother.value == "")
		{
			alert("Area of Interest is Mandatory.");
			do_blink(f.interestother);
			return(false);
		}
		
	}
	if(f.address.value == ""){
		alert("Address is Mandatory.");
		do_blink(f.address);
		return(false);
	}
	if(f.country.value == ""){
		alert("Country is Mandatory.");
		do_blink(f.country);
		return(false);
	}
	if(f.city.value == ""){
		alert("City is Mandatory.");
		do_blink(f.city);
		return(false);
	}
	else
	{
		var strRegExp = "[^A-Za-z0-9\\s]";
		var check = f.city.value.search(strRegExp);
		 if(check >= 0) 
    	{
			alert("Only alpha-numeric digit and space allowed.");
			do_blink(f.city);
			return(false);
		}
	}
	if(f.phone.value == "")
	{
		alert("Phone is Mandatory.");
		do_blink(f.phone);
		return(false);
	}
	else
	{
		if(f.phone.value.length < 7)
		{
			alert("Minimum seven digit for phone number.");
			do_blink(f.phone);
			return(false);
		}
		if(isNaN(f.phone.value)){
			alert("Phone must be number.");
			do_blink(f.phone);
			return(false);
		}
	}
	
	
	
	//f.submit();
	return(true);
}
function CheckSimpleQuote(f)
{
	
	if(f.whichproduct.value == ""){
		alert("Product is Mandatory.");
		do_blink(f.whichproduct);
		return(false);
	}
	if(f.fname.value == ""){
		alert("First Name is Mandatory.");
		do_blink(f.fname);
		return(false);
	}
	else
	{
		var strRegExp = "[^A-Za-z\\s]";
		var check = f.fname.value.search(strRegExp);
		 if(check >= 0) 
    	{
			alert("Only alphabetic characters and space allowed.");
			do_blink(f.fname);
			return(false);
		}
	}
	
	if(f.email.value == ""){
		alert("Email is Mandatory.");
		do_blink(f.email);
		return(false);
	}
	else
	{
		var f1=f.email.value;
		var emailFilter=/^.+@.+\..{2,3}$/;
		if (!(emailFilter.test(f1))) 
		{ 
		  	alert("Email address is incorrect.");
			do_blink(f.email);
			return(false);
		}
		var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/;
		 if (f1.match(illegalChars)) 
		 {
			 	alert("Email address contains illegal characters.");
				do_blink(f.email);
				return(false);
		 }
	}
	
	
	if(f.interest.value == "")
	{
		alert("Area of Interest is Mandatory.");
		do_blink(f.interest);
		return(false);
		
	}
	if(f.interest.value == 0)
	{
		if(f.interestother.value == "")
		{
			alert("Area of Interest is Mandatory.");
			do_blink(f.interestother);
			return(false);
		}
		
	}
	if(f.address.value == ""){
		alert("Address is Mandatory.");
		do_blink(f.address);
		return(false);
	}
	if(f.country.value == ""){
		alert("Country is Mandatory.");
		do_blink(f.country);
		return(false);
	}
	if(f.city.value == ""){
		alert("City is Mandatory.");
		do_blink(f.city);
		return(false);
	}
	else
	{
		var strRegExp = "[^A-Za-z0-9\\s]";
		var check = f.city.value.search(strRegExp);
		 if(check >= 0) 
    	{
			alert("Only alpha-numeric characters and space allowed.");
			do_blink(f.city);
			return(false);
		}
	}
	if(f.phone.value == "")
	{
		alert("Phone is Mandatory.");
		do_blink(f.phone);
		return(false);
	}
	else
	{
		if(f.phone.value.length < 7)
		{
			alert("Minimum seven digit for phone number.");
			do_blink(f.phone);
			return(false);
		}
		if(isNaN(f.phone.value)){
			alert("Phone must be number.");
			do_blink(f.phone);
			return(false);
		}
	}
	
	
	//f.submit();
	return(true);
}

function CheckTellafriend(f)
{
	if(f.name.value == ""){
		alert("Your information name is Mandatory.");
		do_blink(f.name);
		return(false);
	}
	if(f.email.value == ""){
		alert("Your information email is Mandatory.");
		do_blink(f.email);
		return(false);
	}
	else
	{
		var f1=f.email.value;
		var emailFilter=/^.+@.+\..{2,3}$/;
		if (!(emailFilter.test(f1))) 
		{ 
		  alert("Your information email address is incorrect.");
		  do_blink(f.email);
			return(false);
		}
		var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/;
		 if (f1.match(illegalChars)) 
		 {
			 alert("Your information email address is not valid.");
			 do_blink(f.email);
			 return(false);
		 }
		
		
	}
	if(f.rname.value == ""){
		alert("Recipient's name is Mandatory.");
		do_blink(f.rname);
		return(false);
	}
	if(f.friendmail1.value == ""){
		alert("Recipient's email is Mandatory.");
		do_blink(f.friendmail1);
		return(false);
	}
	else
	{
		var f1=f.friendmail1.value;
		var emailFilter=/^.+@.+\..{2,3}$/;
		if (!(emailFilter.test(f1))) 
		{ 
		  alert("Recipient's email address is incorrect.");
		  do_blink(f.friendmail1);
			return(false);
		}
		var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/;
		 if (f1.match(illegalChars)) 
		 {
			 alert("Recipient's email address is not valid.");
			 do_blink(f.friendmail1);
			 return(false);
		 }	
	}
	
	
	f.submit();
	return true;	
}




