function contactvalid()
{
	
	if(document.contactus.custname.value == "")
	{
		alert("Please Enter the Name");
		document.contactus.custname.select();
		return false;
	}
	id1=document.contactus.email.value.indexOf("@")
	id2=document.contactus.email.value.indexOf(".")
	if (document.contactus.email.value=="")
	{
		alert("Please enter the Email ID");
		document.contactus.email.focus();
		return false;
	}

	if(id1==-1)
			{
			alert("Invalid Email Id:");
			document.contactus.email.focus();
			return false;
			}	
	if(id2==-1)
		{
		alert("Please Enter Domain Name Also:");
		document.contactus.email.focus();
		return false;
		}
	var iChars = "!#$%^&*()+=-[]\\\';,/{}|\":<>?";

	  for (var i = 0; i < document.contactus.email.value.length; i++) 
	  {
		if (iChars.indexOf(document.contactus.email.value.charAt(i)) != -1) 
		{
		alert ("Your username has special characters. \nThese are not allowed.\n Please remove them and try again.");
		document.contactus.email.focus();
		return false;
		}
	  }
	//if(document.contactus.company.value == "")
	//{
		//alert("Please Enter the Company Name");
	//	document.contactus.company.select();
		//return false;
	//}
	if(document.contactus.city.value == "")
	{
		alert("Please Enter the City Name and State Name");
		document.contactus.city.select();
		return false;
	}
	if(document.contactus.phone.value == "")
	{
		alert("Please Enter the Phone Number");
		document.contactus.phone.select();
		return false;
	}
	var num=document.contactus.phone.value;
	for(i=0;i<num.length;i++)
	{ 
		var number=num.substring(i,i+1);	
		if(!((((number>=0) && (number<=9)) || (number=='-'))))
		{
			alert("Enter only numbers in Phone Number");
			document.contactus.phone.focus();
			return false;
		}
	}
	if(document.contactus.year.value == "")
	{
		alert("Please Enter the Year");
		document.contactus.year.select();
		return false;
	}
	var num=document.contactus.year.value;
	for(i=0;i<num.length;i++)
	{ 
		var number=num.substring(i,i+1);	
		if(!((((number>=0) && (number<=9)))))
		{
			alert("Enter only numbers in Year");
			document.contactus.year.focus();
			return false;
		}
	}
	if(document.contactus.make.value == "")
	{
		alert("Please Enter the Make Name");
		document.contactus.make.select();
		return false;
	}
	if(document.contactus.carinfo.value == "")
	{
		alert("Please Enter the Carinfo");
		document.contactus.carinfo.select();
		return false;
	}
	if(document.contactus.part.value == "")
	{
		alert("Please Enter the Part Name");
		document.contactus.part.select();
		return false;
	}
return true;	
}


//Keepshopping validation---------!>
function check1()
{
	return true;
}
//Viewcart validation
function discountvalidation()
	{
		if(document.discount.promocode.value=="")
		 {
		 	alert("Please enter the Coupon Code");
			document.discount.promocode.select();
			return false;
		}
		var iChars = "!@#$%^&*()+=-[]\\\';,./{}|\":<>?";
		for(var i=0;i<document.discount.promocode.value.length;i++)
		{
			if(iChars.indexOf(document.discount.promocode.value.charAt(i)) != -1)
			{
				alert("Coupon Code Has Special Characters. \nThese Are Not Allowed.\n Please Remove Them And Try Again.");
				document.discount.promocode.select();
				return false;
			}
		}
	  return true;		
	}



function FnEvents()
{
var eve;
eve = document.parts.descriptform.value;
if (eve == 1)
{
alert("Please Select a Part");
document.parts.descriptform.focus();
}
else
document.location.href=eve;
}


function check()
{
	document.form.submit();
	return true;
}
function RTrim(VALUE)
	{
		var w_space = String.fromCharCode(32);
		var v_length = VALUE.length;
		var strTemp = "";
		if(v_length < 0)
		{
			return"";
		}
		var iTemp = v_length -1;
		while(iTemp > -1)
			{
				if(VALUE.charAt(iTemp) == w_space)
				{}
				else
				{
				strTemp = VALUE.substring(0,iTemp +1);
				break;
				}
				iTemp = iTemp-1;
			} //End While
		return strTemp;
	} //End Function




function URLMove()
    {
		var murlYear=document.epc.year.value;
        var murlMake=document.epc.make.value;
        MakeOne=murlMake.replace(/\s/g,"~");
        URL = 'http://www.buyautoparts.com/modelcategory-'+murlYear+'-'+MakeOne+'.html';
        window.location.replace(URL);
        return false;       
    }

function partsearch()
    {
       
		var murlYear=document.frm.year.value;
        var murlMake=document.frm.make.value;
        MakeOne=murlMake.replace(/\s/g,"~");
        URL = 'http://www.buyautoparts.com/modelcategory-'+murlYear+'-'+MakeOne+'.html';
        window.location.replace(URL);
        return false;       
    }

function searchURLMove()
    {
        var murlProduct="";
		murlProduct=SearchBox2.product.value;
		//if(murlProduct!="" && )
		if ( murlProduct.length<3 )
		{
		alert("To search, you must enter at least 3 characters.");
		return false;
		}
		else if(murlProduct!="" )
		{
			if (!regular(murlProduct)) 
			{
				alert("Don't give Blank Space and Special Character")
				return false;
			}
			else
			{
				murlProduct=murlProduct.replace("-","~");
				var Searchmurl="";
				Searchmurl="http://www.buyautoparts.com/searchParts-"+murlProduct+".html";
				//alert (murl);
				SearchBox2.method="post";
				SearchBox2.action=Searchmurl;
				SearchBox2.submit=true;
			}

        }

    }
function regular(string) 
{
	//if (!string) return false;
	var Chars = "0123456789-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";

	for (var i = 0; i < string.length; i++)
	{ 
		if (Chars.indexOf(string.charAt(i)) == -1)
		return false;
	}
return true;
}


//=========Login validation===========//
function formvalidate()
{
	if (document.loginform.username.value=="")
	{
		alert("Please Enter User Name");
		document.loginform.username.select();
		document.loginform.username.focus();
		return false;
	}
	if (document.loginform.password.value=="")
	{
		alert("Please Enter Password");
		document.loginform.password.select();
		document.loginform.password.focus();
		return false;
	}
}


function MM_openBrWindow(theURL,winName,features) { //v2.0
//alert(theURL)
  window.open(theURL,winName,features);
}




function shipSameAsBill()
{
	
	if (document.custdetails.shipsameasbill.checked == true)
	{
		document.custdetails.sfirstname.value=document.custdetails.bfirstname.value;
		document.custdetails.slastname.value=document.custdetails.blastname.value;
		document.custdetails.saddress1.value=document.custdetails.baddress1.value;
		document.custdetails.saddress2.value=document.custdetails.baddress2.value;
		document.custdetails.scity.value=document.custdetails.bcity.value;
		document.custdetails.sstate.value=  document.custdetails.bstate.value;
		document.custdetails.sphone.value=  document.custdetails.bphone.value;
		document.custdetails.szip.value = document.custdetails.bzip.value;
		document.custdetails.scountry.value=  document.custdetails.bcountry.value;
	}
	else
	{
		document.custdetails.sfirstname.value="";
		document.custdetails.slastname.value="";
		document.custdetails.saddress1.value="";
		document.custdetails.saddress2.value="";
		document.custdetails.scity.value="";
		document.custdetails.sstate.value =  "";
		document.custdetails.sphone.value="";
		document.custdetails.szip.value = "";
		document.custdetails.scountry.value =  "";
	}	
	
}

