var clcks = 0;
var notime = true;
var DEFAULT_WIDTH = "110px";

function check_makes(select,make) {
    if (select.isoMake.value == make) {
	alert('You have already completed a quote for a ' + make);
	select.isoMake.selectedIndex = 0;
	select.isoModel.selectedIndex = 0;		
	select.aicTrim_ID.selectedIndex = 0;				
	return false;
    }
    return true;
}

function resizeDropDownWidth (id)
{
    var txt1 = "";
    var sze = 0;
    var sze1 = 0;
    
    var formObj = document.getElementById(id);
    
    for (i=0; i<formObj.length; i++) {
	txt1 = formObj.options[i].text;
	
	sze1 = txt1.length * 6;
	if (sze1 > sze){
	    sze = sze1;
	}
    }
    
    sze += "px";
    formObj.style.width = sze;
}

function revertDropDownWidth (id) 
{
    //	if (clcks == 0){
    document.getElementById("slt"+id).style.width = DEFAULT_WIDTH;
    //	}
}


function xmlHttpRequest_init()
{
    var oXMLHTTP=false;
    /*@cc_on @*/
    /*@if (@_jscript_version >= 5)
    // JScript gives us Conditional compilation, we can cope with old IE versions.
    // and security blocked creation of the objects.
    try {
    oXMLHTTP = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
    try {
    oXMLHTTP = new ActiveXObject("Microsoft.XMLHTTP");
    } catch (e) {
    oXMLHTTP = false;
    }
    }
    @end @*/
    
    // For Mozilla browsers
    if (!oXMLHTTP && typeof XMLHttpRequest!='undefined') {
	oXMLHTTP = new XMLHttpRequest();
    }
    
    return oXMLHTTP;
}

function changeList(item, model, id, formName, fallbackURL, trim_id)
{
    document.forms[formName].trim.length = 0;
    document.forms[formName].trim.options[0]=new Option('please wait..','');
    document.forms[formName].trim.disabled=true;

    if (!trim_id) {
	trim_id = 'trim_id';
    }
    var oXMLHTTP = xmlHttpRequest_init();	
    
    if (oXMLHTTP) {
	
	// Prepare the XMLHTTP object for a HTTP POST to our validation ASP page
	// Due to security reason, the domain of the URL request destination must be 
	// the same as the one that serves up the page containing the script.
	var sURL = location.protocol + "//" + location.host + "/Components/trimList.php?make=" + escape(item) + "&model=" + escape(model) + "&trim_id=" + escape(trim_id);
	
	oXMLHTTP.open("GET", sURL, true);
	
	// With IE browser, data are being cached in the client's system. 
	// Changing the header would allow the application to reset.
	oXMLHTTP.setRequestHeader('If-Modified-Since','Mon, 20 Nov 1995 00:00:01 GMT');
	
	// Execute the request
	oXMLHTTP.send(null);
	
	// Determine the state change status
	oXMLHTTP.onreadystatechange=function() {
	    if (oXMLHTTP.readyState==4 && oXMLHTTP.status == 200) {
		//alert (oXMLHTTP.responseText);
		document.getElementById(id).innerHTML = oXMLHTTP.responseText;
	    }
	}
    }
    else {
	// For users with browsers that don't support XMLHttpRequest Object
	//document.formName.action=fallback;
	//document.formName.submit();
	document.forms[formName].action=fallback;
	document.forms[formName].submit();
    }
}
