var Jajax_http = createajax();

function createajax() {
	var ajobj=null;

	if (window.XMLHttpRequest) { // Mozilla, Safari,...
           ajobj = new XMLHttpRequest();            
        } else if (window.ActiveXObject) { // IE
            try {
                ajobj = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
                try {
                    ajobj = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (e) {}
            }
        }
		else
			return false
	return ajobj;
}

function time_fn() {
	var d = new Date();
	var t = d.getTime();
	return t;
	
}

function clear_brands_models() {
	document.getElementById('brand_div').innerHTML='<select name="selBrand" class="txtarea"><option value="">- Select Your Brand -</option></select>';
	document.getElementById('model_div').innerHTML='<select name="selModel" class="txtarea"><option value="">- Select Your Model -</option></select>';
}
	
function gen_brands() {
	clear_brands_models();
	Jajax_http.open('GET','/ajax_get_options.php?selVehi='+document.amcoform.selVehi.options[document.amcoform.selVehi.selectedIndex].value+'&'+time_fn(),true);
	Jajax_http.setRequestHeader('Content-Type','application/x-www-form-urlencoded;charset=UTF-8');
	Jajax_http.send(null);
	
	Jajax_http.onreadystatechange = formatResponse_brands;
}

function formatResponse_brands() {
	if(Jajax_http.readyState==4 && Jajax_http.status==200) {
		document.getElementById('brand_div').innerHTML=Jajax_http.responseText;
	}
}

function gen_models() {
	Jajax_http.open('GET','/ajax_get_options.php?selBrand='+document.amcoform.selBrand.options[document.amcoform.selBrand.selectedIndex].value+'&'+time_fn(),true);
	Jajax_http.setRequestHeader('Content-Type','application/x-www-form-urlencoded;charset=UTF-8');
	Jajax_http.send(null);
	
	Jajax_http.onreadystatechange = formatResponse_Models;
}

function formatResponse_Models() {
	if(Jajax_http.readyState==4 && Jajax_http.status==200) {
		document.getElementById('model_div').innerHTML=Jajax_http.responseText;
	}
}


