
function handleResponse(types,doc) {
	//alert("client: handling type: "+types);
	var theFormDiv = document.getElementById('theFormDiv');
	//theFormDiv.style.display = 'none';
	
	// get a reference to the types select list, which we will populate
	// with the data from the document loaded in the IFRAME
	// 1-13-04 rjs fixed for Netscape
	//var typesEl = document.forms.cars(types);
	var typesEl = document.forms['cars'].elements[types];
	//alert("selected for type: "+types+": "+modelsEl.options[modelsEl.selectedIndex].value)
	// clear earlier records from the model select list
	typesEl.length = 0
	
	// get a reference to the DIV containing the data for this state
	//var dataEl = doc.getElementById('models')
	var dataEl = doc.getElementById(types)
	//alert('Types: '+types)
		
	// get a reference to the collection of the children elements of
	// our DIV containing the data (this collection is the DIVs containing
	// the model names)
	
	var namesColl = dataEl.childNodes
	
	// for easy scripting, assign the number of models for this make
	// to a variable
	var numNames = namesColl.length
	//alert('number of models ' + numNames)
	
	// iterate through the collection of model names and
	// create an option element for each one
	for (var q=0; q<numNames; q++) {
		if (namesColl[q].nodeType!=1) continue; // it's not an element node, let's skedaddle
		var typeName = '' // used to store the text we'll use in the new option
		typeName += namesColl[q].id
		//alert ("Model name: "+modelName)
		
		// get a reference to the collection of the children elements of
		// this DIV (this collection contains the modelID for this model name)

		var typeIDColl = doc.getElementById(namesColl[q].id).childNodes
		var numIDs = typeIDColl.length	// should always be 1
		
		// iterate through this collection of modelIDs and each one to the string
		for (var r=0; r<numIDs; r++) {
			if (typeIDColl[r].nodeType!=1) continue; // it's not an element node, let's skedaddle
				// Make the Option value a specially formatted ID which contains both
				// the ID number and the option name so we can get both of them later
				// Note the use of '_+_' as a delimiter here and in a couple of places in search.php
				var typeID  =  typeIDColl[r].id + '_+_' + typeName;
			}
		
		// create a new option element and add it to the model form element
		typesEl.options[typesEl.length] = new Option(typeName,typeID)
		}
	
	//var responseMessage = document.getElementById('responseMessage');
	//var message = '<p>Your message has been sent! Thank you.<\/p>'
	//message += '<p><a href="#" onclick="showForm(); return false;">Send another message<\/a><\/p>'
	//responseMessage.innerHTML = message;
	//responseMessage.style.display = 'block';

  document.body.style.cursor = 'default' 

}

var IFrameObj; // our IFrame object
function callToServer(theFormName, theFormSourceType, theFormDestType, urlPrefix, includeDisabled) {
	 if (!document.createElement) {return true};
	 var IFrameDoc;

	// We'll build our URL by checking which make
	// has been selected in the drop down menu
	//var makeEl = document.forms[theFormName].make
	// 1-13-04 rjs fixed for Netscape
	//var sourceTypeEl = document.forms[theFormName](theFormSourceType);
	var sourceTypeEl = document.forms[theFormName].elements[theFormSourceType];
	var theSource = sourceTypeEl.options[sourceTypeEl.selectedIndex].value

	if (theSource=='') {return false}; // no make has been selected
	//var URL = "server.php?make="+theMake
	var URL = urlPrefix + "push_types.php?"+theFormSourceType+"="+theSource+"&types="+theFormDestType+"&includeDisabled="+includeDisabled
	//alert(URL)

  if (!IFrameObj && document.createElement) {
    // create the IFrame and assign a reference to the
    // object to our global variable IFrameObj.
    // this will only happen the first time 
    // callToServer() is called
   try {
      var tempIFrame=document.createElement('iframe');
      tempIFrame.setAttribute('id','RSIFrame');
      tempIFrame.style.border='0px';
      tempIFrame.style.width='0px';
      tempIFrame.style.height='0px';
      IFrameObj = document.body.appendChild(tempIFrame);
      
      if (document.frames) {
        // this is for IE5 Mac, because it will only
        // allow access to the document object
        // of the IFrame if we access it through
        // the document.frames array
        IFrameObj = document.frames['RSIFrame'];
      }
    } catch(exception) {
      // This is for IE5 PC, which does not allow dynamic creation
      // and manipulation of an iframe object. Instead, we'll fake
      // it up by creating our own objects.
      iframeHTML='\<iframe id="RSIFrame" style="';
      iframeHTML+='border:0px;';
      iframeHTML+='width:0px;';
      iframeHTML+='height:0px;';
      iframeHTML+='"><\/iframe>';
      document.body.innerHTML+=iframeHTML;
      IFrameObj = new Object();
      IFrameObj.document = new Object();
      IFrameObj.document.location = new Object();
      IFrameObj.document.location.iframe = document.getElementById('RSIFrame');
      IFrameObj.document.location.replace = function(location) {
        this.iframe.src = location;
      }
    }
  }
  
  if (navigator.userAgent.indexOf('Gecko') !=-1 && !IFrameObj.contentDocument) {
    // we have to give NS6 a fraction of a second
    // to recognize the new IFrame
    setTimeout('callToServer()',10);
    return false;
  }
  
  if (IFrameObj.contentDocument) {
    // For NS6
    IFrameDoc = IFrameObj.contentDocument; 
  } else if (IFrameObj.contentWindow) {
    // For IE5.5 and IE6
    IFrameDoc = IFrameObj.contentWindow.document;
  } else if (IFrameObj.document) {
    // For IE5
    IFrameDoc = IFrameObj.document;
  } else {
    return true;
  }

  document.body.style.cursor = 'wait' 
	//alert (URL);
  IFrameDoc.location.replace(URL);
  return false;
}

function buildQueryString(theFormName) {
  theForm = document.forms[theFormName];
  var qs = ''
  for (e=0;e<theForm.elements.length;e++) {
    if (theForm.elements[e].name!='') {
      qs+=(qs=='')?'?':'&'
      qs+=theForm.elements[e].name+'='+escape(theForm.elements[e].value)
      }
    }
  return qs
}
