function Validate_Contact(NForm){
	return Validate_Name(NForm) &&
			Validate_Email(NForm) &&
			Validate_Subject(NForm) &&
			Validate_Message(NForm) &&
			true;
}
function Validate_Name(NForm){
 	NForm.name.focus();
 	if(NForm.name.value.length==0){ 
  		alert("You must enter Name"); 
  		return false; 
 	}
	return true;
}
function Validate_Email(NForm){
	NForm.email.focus();
	if(NForm.email.value.length==0){ 
		alert("Please enter Valid EMAIL!"); 
	  return false; 
	}else{
		NForm.email.focus();
		var str = NForm.email.value;
		var reg1 = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/; 
		var reg2 = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/;
		if (!reg1.test(str) && reg2.test(str)) {
			return true;
		}else{
			alert("Please enter Valid EMAIL!"); 
			return false; 
		}
	  return false;
	 }
}
function Validate_Subject(NForm){
 	NForm.subject.focus();
 	if(NForm.subject.value.length==0){ 
  		alert("You must enter Subject"); 
  		return false; 
 	}
	return true;
}
function Validate_Message(NForm){
 	NForm.message.focus();
 	if(NForm.message.value.length==0){ 
  		alert("You must enter Message"); 
  		return false; 
 	}
	return true;
}
function Validate_Contact(NForm){
	return Validate_Name(NForm) &&
			Validate_Mobile(NForm) &&
			Validate_Email(NForm) &&
			Validate_Address(NForm) &&
			true;
}
function Validate_Registration(NForm){
	return Validate_Username(NForm) &&
				Validate_Password(NForm) &&
				Validate_VerifyPassword(NForm) &&
				Validate_Company(NForm) &&
				Validate_Email(NForm) &&
				Validate_Phone(NForm) &&
				Validate_Address(NForm) &&
				true;
}
function Validate_Phone(NForm){
 	NForm.phone.focus();
 	if(NForm.phone.value.length==0){ 
	  	alert("You must enter Phone"); 
  		return false; 
 	}
	  return true;
}
function Validate_Username(NForm){
 	NForm.username.focus();
 	if(NForm.username.value.length==0){ 
	  	alert("You must enter Username"); 
  		return false; 
 	}
	  return true;
}
function Validate_Password(NForm){
 	NForm.password.focus();
 	if(NForm.password.value.length==0){ 
	  	alert("You must enter Password"); 
  		return false; 
 	}
	  return true;
}
function Validate_OldPassword(NForm){
 	NForm.opassword.focus();
 	if(NForm.opassword.value.length==0){ 
	  	alert("You must enter Old Password"); 
  		return false; 
 	}
	  return true;
}
function Validate_VerifyPassword(NForm){
	NForm.vpassword.focus();
	if(NForm.password.value!=NForm.vpassword.value){
		alert("Please Verify your Password.");
		return false;
	}
	return true;
}
function Validate_LoginForm(NForm){
	return Validate_Username(NForm) &&
				Validate_Password(NForm) &&
				true;
}
function Validate_ChangePassword(NForm){
	return Validate_OldPassword(NForm) &&
			Validate_Password(NForm) &&
			Validate_VerifyPassword(NForm) &&
			true;
}
function Validate_Company(NForm){
 	NForm.company.focus();
 	if(NForm.company.value.length==0){ 
	  	alert("You must enter Company"); 
  		return false; 
 	}
	  return true;
}
function Validate_ProducerContact(NForm){
	return Validate_Name(NForm) &&
			Validate_Email(NForm) &&
			Validate_Phone(NForm) &&
			Validate_Subject(NForm) &&
			Validate_Comment(NForm) &&
			true;
}
function Validate_Comment(NForm){
 	NForm.comment.focus();
 	if(NForm.comment.value.length==0){ 
	  	alert("You must enter Comment"); 
  		return false; 
 	}
	  return true;
}
function Validate_Inquiry(NForm){
	return Validate_Company(NForm) &&
			Validate_Brand(NForm) &&
			Validate_Product(NForm) &&
			Validate_Name(NForm) &&
			Validate_Email(NForm) &&
			Validate_Subject(NForm) &&
			Validate_Message(NForm) &&
			true;
}
function Validate_Brand(NForm){
 	NForm.brand.focus();
 	if(NForm.brand.value.length==0){ 
	  	alert("You must enter Brand"); 
  		return false; 
 	}
	  return true;
}
function Validate_Product(NForm){
 	NForm.product.focus();
 	if(NForm.product.value.length==0){ 
	  	alert("You must enter Product"); 
  		return false; 
 	}
	  return true;
}
function do_brand(id){
	x_sfi_GetProducerBrand(id,do_brand_res);
}
function do_brand_res(res){
	if(res){
		var ar_res=res.split("#;#");
		var brand=document.getElementById('brand');
		brand.length=0;
		var optn=document.createElement("OPTION");
		optn.text='Chose Brand';
		optn.value='';
		brand.options[0]=optn;
		for(var i=0;i<ar_res.length;i++){
			var ar=ar_res[i].split("#@#");
				var optn=document.createElement("OPTION");
				optn.text=ar[1];
				optn.value=ar[0];
				brand.options[brand.length]=optn;
		}
	}
}
function do_product(brand_id){
	x_sfi_GetProducerBrandProduct(brand_id,document.getElementById('company').value,do_product_res);
}
function do_product_res(res){
	if(res){
		var ar_res=res.split("#;#");
		var product=document.getElementById('product');
		product.length=0;
		var optn=document.createElement("OPTION");
		optn.text='Chose Brand';
		optn.value='';
		product.options[0]=optn;
		for(var i=0;i<ar_res.length;i++){
			var ar=ar_res[i].split("#@#");
				var optn=document.createElement("OPTION");
				optn.text=ar[1];
				optn.value=ar[0];
				product.options[product.length]=optn;
		}
	}
}