// JavaScript Document
function getXMLHTTP() { //fuction to return the xml http object

	var xmlhttp=false;	
	try{
		xmlhttp=new XMLHttpRequest();
	}
	catch(e)	{		
		try{			
			xmlhttp= new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch(e){
			try{
			req = new ActiveXObject("Msxml2.XMLHTTP");
			}
			catch(e1){
				xmlhttp=false;
			}
		}
	}
	
	
		
	return xmlhttp;

}

function getModel(make, model) {	
	//var strURL="includes/findModel.php?make="+make+"&model="+model;
	var strURL="content_include_files/AJAX_php/findModel.php?make="+make+"&model="+model;
	
	var req = getXMLHTTP();
	
	if (req) {
		
		req.onreadystatechange = function() {
			if (req.readyState == 4) {
				// only if "OK"
				if (req.status == 200) {	
					document.getElementById('modeldiv').innerHTML=req.responseText;						
				} else {
					//alert("There was a problem while using XMLHTTP 4:\n" + req.statusText);
				}
			}				
		}			
		req.open("GET", strURL, true);
		req.send(null);
	}		
}

function getBike(make, model, bikeId) {	
	//document.write(make);
	//document.write(stateId);

	//var strURL="includes/findBike.php?make="+make+"&model="+model+"&id="+bikeId;
	var strURL="content_include_files/AJAX_php/findBike.php?make="+make+"&model="+model+"&id="+bikeId;
	
	var req = getXMLHTTP();
		
	if (req) {
		
		req.onreadystatechange = function() {
			if (req.readyState == 4) {
				// only if "OK"
				if (req.status == 200) {						
					document.getElementById('resultdiv').innerHTML=req.responseText;						
				} else {
					//alert("There was a problem while using XMLHTTP 3:\n" + req.statusText);
				}
			}				
		}			
		req.open("GET", strURL, true);
		req.send(null);
	}		
}

//search model is a little different to get model
function searchModel(make, model) {		

	var strURL="content_include_files/AJAX_php/searchModel.php?make="+make+"&model="+model;
	var req = getXMLHTTP();
	
	if (req) {	
		req.onreadystatechange = function() {
			if (req.readyState == 4) {
				// only if "OK"
				if (req.status == 200) {						
					document.getElementById('modeldiv').innerHTML=req.responseText;						
				} else {
					//alert("There was a problem while using XMLHTTP 2:\n" + req.statusText);
				}
			}				
		}			
		req.open("GET", strURL, true);
		req.send(null);
	}
}

function getRegoField(rego, num, exp_mth, exp_yr) {	
	var strURL="content_include_files/AJAX_php/getRegoField.php?rego="+rego+"&num="+num+"&mth="+exp_mth+"&yr="+exp_yr;
	var req = getXMLHTTP();
	
	if (req) {	
		req.onreadystatechange = function() {
			if (req.readyState == 4) {
				// only if "OK"
				if (req.status == 200) {						
					document.getElementById('regodiv').innerHTML=req.responseText;						
				} else {
					//alert("There was a problem while using XMLHTTP 1:\n" + req.statusText);
				}
			}				
		}			
		req.open("GET", strURL, true);
		req.send(null);
	}		
}






