
function ValidateZip(strZip)
{ 			
	var IsUSA = /^\d{5}(-\d{4})?$/;
	var IsCA = /^[A-Za-z]\d[A-Za-z]( |-)?\d[A-Za-z]\d$/;
	
	if(! IsUSA.test(strZip) && !IsCA.test(strZip))
	{
		return false;
	}
	else
	{
		return true;
	}
}

function GetCountryCode(strZip)
{
	var IsUSA = /^\d{5}(-\d{4})?$/;
	var IsCA = /^[A-Za-z]\d[A-Za-z]( |-)?\d[A-Za-z]\d$/;
	if(IsUSA.test(strZip))
	{
		return "US";
	}
	if(IsCA.test(strZip))
	{
		return "CA";
	}
} 

function GetDealers(zip, cid, pageName)
{
	if(ValidateZip(zip))
	{
		var strCountryCode;
		strCountryCode = GetCountryCode(zip);
		document.location.href = pageName + "?Zip=" + zip + "&cid=" + cid + "&searchid=" + "1" + "&Country="+strCountryCode;
	}
	else
	{
		alert('Please enter a valid zip/postal code');
	}
}

