function createRequestObject()
{
var xmlhttp = false;
if (window.XMLHttpRequest) { // Mozilla, Safari, ...
            xmlhttp = new XMLHttpRequest();
            if (xmlhttp.overrideMimeType) {
                xmlhttp.overrideMimeType('text/xml');
                // See note below about this line
            }
        }
		else
		{
		try
	{
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch (e)
 	{
		try 
		{
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  		} 
		catch (E) 
		{
			xmlhttp = false;
		}
 	}
	}
	if (!xmlhttp && typeof XMLHttpRequest!='undefined')
	{
		xmlhttp = new XMLHttpRequest();
	}
	return xmlhttp;
}

function displayMake(keyword)
{
      
	if(keyword)
    {
  	    var request = createRequestObject();
		request.open("GET", "dosql.php?makeid="+keyword);
		request.onreadystatechange = function() 
		{ 
			if(request.readyState == 4) 
	       	{
				response = request.responseText;
      			document.getElementById('model').options.length=0;
				options = response.split("|");
				options.sort()
				for( var i = 0; i < options.length; i++ )
					if (options[i]!="") {
						nameValue=options[i].split("~"); 
						document.getElementById('model').options[i] = new Option(nameValue[0], nameValue[1]); 
					}
        	   }
			 
	   	};
		request.send(null);
	}	 
	 
}
 function chkZipcode() {
		var state,country,city,zip;
		x=document.getElementById("state");
 		var len=x.options.length;
		var state="";
		for(i=0;i<len;i++) {
			if(x.options[i].selected) {
				state=x.options[i].text;
			}
		}
 		y=document.getElementById("country");
		var len2=y.options.length;
		var country="";
		for(j=0;j<len2;j++) {
			if(y.options[j].selected) {
			country=y.options[j].text;
			}
		}
 		city=document.mosForm.city.value;
	    zip=document.mosForm.zipcode.value;
    	if(country=='United States') {
		  verifyZipcode(zip ,state ,city );
	    } else {
			document.getElementById("ziperror").innerHTML="";	
		}
		 
 	 	
}
function chkSelectedItem(obj) {
	len = obj.options.length;
	i = 0;
	reTxt =0;
	for (i = 0; i < len; i++) {
		if(obj.options[i].selected) {
			if(obj.options[i].value!="") {
				reTxt = 1;
			} 
		}
	}	
	if(reTxt==1) {
		return true;
	} else {
		return false;
	}
}
 function isNumber(val)
{
if (isNaN(val))
{
alert('Please enter whole numbers only.');
document.mosForm.numemp.value="";
document.mosForm.numemp.focus();
return false;
}
else
{
return true;
} 
}


function numbersonly(str ,e)
{
 	var key;
	var keychar;
	var e=e;
   	if (window.event)
	   key = window.event.keyCode;
	else if (e)
	   key = e.which;
	else
	   return true;
	 keychar = String.fromCharCode(key);
	// control keys
	if ((key==null) || (key==0) || (key==8) ||
		(key==9) || (key==13) || (key==27))
	   return true;
	// numbers
	else if (((str).indexOf(keychar) > -1))
	   return true;
	else
	{
	   alert("Please enter whole numbers only.");
	   return false;
	}
	 
}
