// JavaScript Document


<!--
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->

function validatePhoneNumber(elementValue)
{
	var phoneNumberPattern = /^\(?(\d{3})\)?[- ]?(\d{3})[- ]?(\d{4})$/;
	if(phoneNumberPattern.test(elementValue))
	{
		return false;
		
	}
	else
	{
		return true;
	}
}



function validate1()
{
		document.f1.username.value="";
		return false;
}

function validate2()
{
		document.f1.pwd.value="";
		return false;
}

function searchvalidate1()
{
		document.searchfrm1.categorydetails.value="";
		return false;
}

function searchvalidate2()
{
		document.searchfrm1.addressdetails.value="";
		return false;
}

function signupvalidate()
{
	
	if(document.f2.fname.value=="")
	{
		alert("Please Enter First Name");
		document.f2.fname.focus();
		return false;
	}
	if(document.f2.lname.value=="")
	{
		alert("Please Enter Last Name");
		document.f2.lname.focus();
		return false;
	}
	if(document.f2.email.value=="")
	{
		alert("please Enter Email Address");
		document.f2.email.focus();
		return false;
	}
	if(document.f2.email.value!="")
	{
		apos=document.f2.email.value.indexOf("@")
		dotpos=document.f2.email.value.lastIndexOf(".")
		if (apos<1||dotpos-apos<2) 
		{
			alert("Please Enter Valid Email Address");
			document.f2.email.focus();
			return false
		}
	}	
	
	if(document.f2.username.value=="")
	{
		alert("Please Enter User Name");
		document.f2.username.focus();
		return false;
	}
	
	if(document.f2.pwd.value=="")
	{
		alert("Please Enter Password");
		document.f2.pwd.focus();
		return false;
	}
	if(document.f2.confirmpwd.value=="")
	{
		alert("Please Enter Confirm Password");
		document.f2.confirmpwd.focus();
		return false;
	}
	if(document.f2.pwd.value!=document.f2.confirmpwd.value)
	{
		alert("Confirm Password is not Correct");
		document.f2.confirmpwd.value="";		
		document.f2.confirmpwd.focus();
		return false;
	}	
	if(document.f2.address1.value=="")
	{
		alert("Please Enter Address 1");
		document.f2.address1.focus();
		return false;
	}
	if(document.f2.country.value=="select")
	{
		alert("Please Select Country");
		document.f2.country.focus();
		return false;
	}
	if(document.f2.select_state.value=="")
	{
		alert("Please Enter State");
		document.f2.select_state.focus();
		return false;
	}
	if(document.f2.phone.value=="")
	{
		alert("Please Enter Phone No");
		document.f2.phone.focus();
		return false;
	}
	
	else
	{
		if(validatePhoneNumber(document.f2.phone.value))
		{
		alert("Please Enter valid Phone No");
		document.f2.phone.focus();
		return false;
		}
	}
	if(document.f2.postcode.value=="")
	{
		alert("Please Enter Post Code");
		document.f2.postcode.focus();
		return false;
	}
	
	var check = 0;
	for (var i = 0; i < 2; i++)
	{
		var checked = document.f2.gender[i].checked;
		if (checked)
		{
			check = 1;
		}
	}
	if (!check==1)
	{
		alert("Please choose Any one Gender");
		return false;
	}
	if(document.f2.usertype.value=="select")
	{
		alert("Please Select User Type");
		document.f2.usertype.focus();
		return false;
	}
	
	if(document.f2.txtNumber.value=="")
	{
		alert("Please Insert Verification");
		document.f2.txtNumber.focus();
		return false;
	}
	
}	

function addbranchvalidate()
{
	if(document.addbranch.CompanyName.value=="")
	{
		alert("please Enter Company Name");
		document.addbranch.CompanyName.focus();
		return false;
	}
	if(document.addbranch.Companyurl.value=="")
	{
		alert("please Enter Company URL");
		document.addbranch.Companyurl.focus();
		return false;
	}
	/*if(document.addbranch.Contactperson.value=="")
	{
		alert("please Enter Contact Person");
		document.addbranch.Contactperson.focus();
		return false;
	}*/
	/*if(document.addbranch.House.value=="")
	{
		alert("please Enter House No");
		document.addbranch.House.focus();
		return false;
	}*/
	if(document.addbranch.Street.value=="")
	{
		alert("please Enter Street");
		document.addbranch.Street.focus();
		return false;
	}
	if(document.addbranch.City.value=="")
	{
		alert("please Enter City");
		document.addbranch.City.focus();
		return false;
	}
	if(document.addbranch.State.value=="")
	{
		alert("please Enter State");
		document.addbranch.State.focus();
		return false;
	}
	if(document.addbranch.ZIP.value=="")
	{
		alert("please Enter Zip Value");
		document.addbranch.ZIP.focus();
		return false;
	}
	if(isNaN(document.addbranch.ZIP.value))
	{
		alert("Zip Value should be numeric.");
		document.addbranch.ZIP.focus();
		return false;	
	}
	if(document.addbranch.Primaryphone.value=="")
	{
		alert("please Enter Phone No");
		document.addbranch.Primaryphone.focus();
		return false;
	}
	else
	{
		if(validatePhoneNumber(document.addbranch.Primaryphone.value))
		{
		alert("Please Enter valid Phone No");
		document.addbranch.Primaryphone.focus();
		return false;
		}
	}
	
	if((document.addbranch.Alternatephone.value)&&(validatePhoneNumber(document.addbranch.Alternatephone.value)))
		{
		alert("Please Enter valid Phone No");
		document.addbranch.Alternatephone.focus();
		return false;
		}
	
	if(document.addbranch.email.value=="")
	{
		alert("please Enter Email Address");
		document.addbranch.email.focus();
		return false;
	}
	if(document.addbranch.email.value!="")
	{
		apos=document.addbranch.email.value.indexOf("@")
		dotpos=document.addbranch.email.value.lastIndexOf(".")
		if (apos<1||dotpos-apos<2) 
		{
			alert("Please Enter Valid Email Address");
			document.addbranch.email.focus();
			return false
		}
	}	
	if(document.addbranch.ParentCategory.value=="")
	{
		alert("Please Select Category");
		document.addbranch.ParentCategory.focus();
		return false;
	}
	if(document.addbranch.SubCategory.value=="")
	{
		alert("Please Select Sub Category");
		document.addbranch.SubCategory.focus();
		return false;
	}
	if(document.addbranch.Aboutus.value=="")
	{
		alert("please Enter About Us");
		document.addbranch.Aboutus.focus();
		return false;
	}
}

function editprofilevalidate()
{
if(document.editprofile.CompanyName.value=="")
	{
		alert("please Enter Company Name");
		document.editprofile.CompanyName.focus();
		return false;
	}
	if(document.editprofile.Companyurl.value=="")
	{
		alert("please Enter Company URL");
		document.editprofile.Companyurl.focus();
		return false;
	}
	/*if(document.editprofile.Contactperson.value=="")
	{
		alert("please Enter Contact Person");
		document.editprofile.Contactperson.focus();
		return false;
	}*/
	/*if(document.editprofile.House.value=="")
	{
		alert("please Enter House No");
		document.editprofile.House.focus();
		return false;
	}*/
	if(document.editprofile.Street.value=="")
	{
		alert("please Enter Street");
		document.editprofile.Street.focus();
		return false;
	}
	if(document.editprofile.City.value=="")
	{
		alert("please Enter City");
		document.editprofile.City.focus();
		return false;
	}
	if(document.editprofile.State.value=="")
	{
		alert("please Enter State");
		document.editprofile.State.focus();
		return false;
	}
	if(document.editprofile.ZIP.value=="")
	{
		alert("please Enter ZIP Value");
		document.editprofile.ZIP.focus();
		return false;
	}
	if(isNaN(document.editprofile.ZIP.value))
	{
		alert("ZIP code should be numeric");
		document.editprofile.ZIP.focus();
		return false;
	}
	
	
	if(document.editprofile.Primaryphone.value=="")
	{
		alert("please Enter Phone No");
		document.editprofile.Primaryphone.focus();
		return false;
	}
	/*
	if(isNaN(document.editprofile.Primaryphone.value))
	{
		alert("Phone No should be numeric");
		document.editprofile.Primaryphone.focus();
		return false;
	}*/
	
	
	else
	{
		if(validatePhoneNumber(document.editprofile.Primaryphone.value))
		{
		alert("Please Enter valid Phone No");
		document.editprofile.Primaryphone.focus();
		return false;
		}
	}
	
	if((document.editprofile.Alternatephone.value)&&(validatePhoneNumber(document.editprofile.Alternatephone.value)))
		{
		alert("Please Enter valid Phone No");
		document.editprofile.Alternatephone.focus();
		return false;
		}
	
if(document.editprofile.email.value=="")
	{
		alert("please Enter Email Address");
		document.editprofile.email.focus();
		return false;
	}
	if(document.editprofile.email.value!="")
	{
		apos=document.editprofile.email.value.indexOf("@")
		dotpos=document.editprofile.email.value.lastIndexOf(".")
		if (apos<1||dotpos-apos<2) 
		{
			alert("Please Enter Valid Email Address");
			document.editprofile.email.focus();
			return false
		}
	}	
	if(document.editprofile.Aboutus.value=="")
	{
		alert("please Enter About Us");
		document.editprofile.Aboutus.focus();
		return false;
	}
}

function commandvalidate()
{
	if(document.commandtitle.forum_details.value=="")
	{
		alert("Please Enter Comments")
		document.commandtitle.forum_details.focus();
		return false;		
	}
}

function createtopicvalidate()
{

	if(document.commandtitle.topic.value=="Select")
	{
		alert("Please Select Topic")
		document.commandtitle.topic.focus();
		return false;		
	}
	if(document.commandtitle.forum_details.value=="")
	{
		alert("Please Enter Discuss Question")
		document.commandtitle.forum_details.focus();
		return false;		
	}
}

function topicvalidate()
{
	if(document.commandtitle.topic.value=="")
	{
		alert("Please Enter Topic")
		document.commandtitle.topic.focus();
		return false;		
	}
}

function forgotvalidationvalidate()
{
if(document.forgotpass.email.value=="")
	{
		alert("please Enter Email Address");
		document.forgotpass.email.focus();
		return false;
	}
	if(document.forgotpass.email.value!="")
	{
		apos=document.forgotpass.email.value.indexOf("@")
		dotpos=document.forgotpass.email.value.lastIndexOf(".")
		if (apos<1||dotpos-apos<2) 
		{
			alert("Please Enter Valid Email Address");
			document.forgotpass.email.focus();
			return false
		}
	}	
}



function productvalidate()
{
    if(document.addproduct.product_name.value=="")
	{
		alert("Please Enter Product Name");
		document.addproduct.product_name.focus();
		return false;
	}
	if(document.addproduct.product_desc.value=="")
	{
		alert("Please Enter Product Desc");
		document.addproduct.product_desc.focus();
		return false;
	}
	if(document.addproduct.price.value=="")
	{
		alert("Please Enter Price");
		document.addproduct.price.focus();
		return false;
	}
	if(document.addproduct.category.value=="")
	{
		alert("Please Enter Category");
		document.addproduct.category.focus();
		return false;
	}
	if(document.addproduct.subcategory.value=="")
	{
		alert("Please Enter Sub Category");
		document.addproduct.subcategory.focus();
		return false;
	}
}


function createblog()
{
    if(document.frm1.topic.value=="Select")
	{
		alert("Please Select Topic");
		document.frm1.topic.focus();
		return false;
	}
    if(document.frm1.title.value=="")
	{
		alert("Please Enter Blog Title");
		document.frm1.title.focus();
		return false;
	}
	/*if(document.frm1.blogimg.value=="")
	{
		alert("Please Insert Blog Image");
		document.frm1.blogimg.focus();
		return false;
	}*/
	if(document.frm1.description.value=="")
	{
		alert("Please Enter Description");
		document.frm1.description.focus();
		return false;
	}
}

function addclassifidesvalidate()
{
	if(document.frm1.Googleadclient.value=="")
	{
		alert("Please Enter Google ad client");
		document.frm1.Googleadclient.focus();
		return false;
	}
	if(document.frm1.Googleadslot.value=="")
	{
		alert("Please Enter Google ad slot");
		document.frm1.Googleadslot.focus();
		return false;
	}
	if(document.frm1.GoogleAdsScript.value=="")
	{
		alert("Please Enter Google Ads Script");
		document.frm1.GoogleAdsScript.focus();
		return false;
	}
}

function createads()
{
    if(document.frm1.adsname.value=="")
	{
		alert("Please Enter Your Ads Name");
		document.frm1.adsname.focus();
		return false;
	}
	if(document.frm1.blogimg.value=="")
	{
		alert("Please select your ads image");
		document.frm1.blogimg.focus();
		return false;
	}
	if(document.frm1.description.value=="")
	{
		alert("Please Enter Description");
		document.frm1.description.focus();
		return false;
	}
}


/*NEW*/
function RegistrationValidation()
{
	if(document.addbranch.CompanyName.value=="")
	{
		alert("please Enter Company Name");
		document.addbranch.CompanyName.focus();
		return false;
	}
	if(document.addbranch.Companyurl.value=="")
	{
		alert("please Enter Company URL");
		document.addbranch.Companyurl.focus();
		return false;
	}
	if(document.addbranch.Contactperson.value=="")
	{
		alert("please Enter Contact Person");
		document.addbranch.Contactperson.focus();
		return false;
	}
	if(document.addbranch.House.value=="")
	{
		alert("please Enter House No");
		document.addbranch.House.focus();
		return false;
	}
	if(document.addbranch.Street.value=="")
	{
		alert("please Enter Street");
		document.addbranch.Street.focus();
		return false;
	}
	if(document.addbranch.City.value=="")
	{
		alert("please Enter City");
		document.addbranch.City.focus();
		return false;
	}
	if(document.addbranch.State.value=="")
	{
		alert("please Enter State");
		document.addbranch.State.focus();
		return false;
	}
	if(document.addbranch.ZIP.value=="")
	{
		alert("please Enter Zip Value");
		document.addbranch.ZIP.focus();
		return false;
	}
	if(document.addbranch.Primaryphone.value=="")
	{
		alert("please Enter Phone No");
		document.addbranch.Primaryphone.focus();
		return false;
	}
	if(document.addbranch.email.value=="")
	{
		alert("please Enter Email Address");
		document.addbranch.email.focus();
		return false;
	}
	if(document.addbranch.email.value!="")
	{
		apos=document.addbranch.email.value.indexOf("@")
		dotpos=document.addbranch.email.value.lastIndexOf(".")
		if (apos<1||dotpos-apos<2) 
		{
			alert("Please Enter Valid Email Address");
			document.addbranch.email.focus();
			return false
		}
	}	
	if(document.addbranch.ParentCategory.value=="")
	{
		alert("Please Select Category");
		document.addbranch.ParentCategory.focus();
		return false;
	}
	if(document.addbranch.SubCategory.value=="")
	{
		alert("Please Select Sub Category");
		document.addbranch.SubCategory.focus();
		return false;
	}
	if(document.addbranch.Aboutus.value=="")
	{
		alert("please Enter About Us");
		document.addbranch.Aboutus.focus();
		return false;
	}
}
