<!--//

GLOBAL_COUNT=0;
GLOBAL_AREAS= new Array();
GLOBAL_WIDTH=1;

function show_dealers(state_abbr) {
	nocache=Math.random();

	var dataSource='dealer.php?state_abbr='+state_abbr+'&nocache'+nocache;

	if(XMLHttpRequestObject) {
		var obj = document.getElementById('results');
		XMLHttpRequestObject.open("GET",dataSource);
		XMLHttpRequestObject.onreadystatechange = function() {
			if (XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status == 200) {
				obj.innerHTML = XMLHttpRequestObject.responseText;
			}
		}
		XMLHttpRequestObject.send(null);
	}
}

function scaleXY(elementid,scale){
  // avoid problems with 0 scales and image becoming so small it does not change size 
  // I think something breaks in firefox(1) when you shrink so much that all values in an coords= become 0
  // I think something breaks in iexplore(1) when you shrink so much that all values in an coords= become 0
  myscale=Math.max(0,scale);
  oldwidth=document.getElementById(elementid).width
  oldheight=document.getElementById(elementid).height
  newwidth=Math.round(Math.max(oldwidth*myscale,1));
  newheight=Math.round(Math.max(oldheight*myscale,1));
  if(oldwidth == newwidth) newwidth=+1;
  if(oldheight == newheight) newheight=+1;
  document.getElementById(elementid).width=newwidth;
  document.getElementById(elementid).height=newheight;
  scaleArea();
	document.getElementById(elementid).style.visibility="visible";
}

function getglobal(){ // place original AREA coordinate strings into a global array, called at load
    var arrayAreas = document.body.getElementsByTagName("AREA");
    GLOBAL_WIDTH= document.getElementById("usmap").width; // get original width
    for(var i = 0; i < arrayAreas.length; i++) {
          GLOBAL_AREAS[i]= arrayAreas[i].coords;
    }
    GLOBAL_COUNT++;
}

function scaleArea() {   // using values stored at load, recalculate new values for the current size
    var arrayAreas = document.body.getElementsByTagName("AREA");
    for(var i = 0; i < arrayAreas.length; i++) {
       ii=i+1;
       rescale= document.getElementById("usmap").width/GLOBAL_WIDTH ;
       sarray=GLOBAL_AREAS[i].split(",");      // convert coordinates to a numeric array assuming comma-delimited values
       var rarray =new Array();
       for(var j = 0; j < sarray.length; j++) {
          rarray[j]=parseInt(sarray[j])*rescale;  // rescale the values
          rarray[j]=Math.round(rarray[j]);
       }
       //alert( "GLOBAL " + GLOBAL_AREAS[i] + ":" + sarray.length + " SPLIT=" + sarray +rarray.length);  
       arrayAreas[i].coords=rarray.join(",");    // put the values back into a string
   }
}
//-->