/*variables*/
var posx=0,posy=0,tmpX=0,tmpY=0,ratioA=22,ratioB=34,totalwidth=537,cost=497.0,laminationPerFoot=3,laminationCost=0,logoCost=0,titleCost=0,layer1Cost=0,layer2Cost=0,citylat=0,citylon=0,mapwidth=520,mapheight=520,alaskaLeft=30.0,alaskaTop=100.0,hawaiiLeft=130.0,hawaiiTop=100.0,titleLeft=30.0,titleTop=10.0,legendLeft=30.0,legendTop=200.0,logoLeft=130.0,logoTop=30.0;
var orientation="Landscape",mapname="cust-Classroom",action="SETMAPBOUNDS",focus="USA",background="",units="meters",extralayer="",tempSrc="",title="",titleSize="m",titleFont="Arial",titleColor="black",detail="med",logoURL="",logoSize="m";
var shiptofirstname="",shiptolastname="",shiptoemail="",shiptostreet="",shiptocity="",shiptostate="",shiptozip="",shiptocountryname="";
var calendar=false,alaska=false,hawaii=false,fadingMap=false;
var addLeft,addTop,dragObj,x1,y1,x2,y2;
if(units=="dd"){x1=-127.403303833817;y1=23;x2=-63.3284081533734;y2=50;}
else if(units=="meters"){x1=-14400000;y1=2000000;x2=-7200000;y2=6700000;}
var receiveReq = getXmlHttpRequestObject();

function getXmlHttpRequestObject() {
	if(window.XMLHttpRequest){return new XMLHttpRequest();}
	else if(window.ActiveXObject){return new ActiveXObject("Microsoft.XMLHTTP");}
	else{alert('Status: Cound not create XmlHttpRequest Object.  Consider upgrading your browser.');}
}
/*listeners*/
if(window.addEventListener){ //Firefox
	window.addEventListener("mousemove",getMousePos,false);
	window.addEventListener("mouseup",fn_Msup,false);
}
else if(document.attachEvent){ //Internet Explorer
	document.attachEvent("onmousemove",getMousePos);
	document.attachEvent("onmouseup",fn_Msup);
}
/*mouse functions*/
function getMousePos(e){
	if(!e)var e=window.event||window.Event;
	if("undefined"!=typeof e.pageX){
		posx=e.pageX;
		posy=e.pageY;
	}else{
		posx=e.clientX+document.body.scrollLeft;
		posy=e.clientY+document.body.scrollTop;
	}
	if(dragObj){fn_Msmv();}
}
function fn_Msdn(a){
	dragObj=document.getElementById(a);
	tmpX=posx-getLeft(dragObj);
	tmpY=posy-getTop(dragObj);
}
function fn_Msmv(){
	if(dragObj){
		checkBounds((posx-tmpX),(posy-tmpY),dragObj);
		/*makes it drag properly in IE*/
		if(!e){var e=window.event||window.Event;}
		e.returnValue=false;
	}
}
function fn_Msup(){
	if(dragObj){
		var addSides=parseInt((totalwidth-mapwidth)/2);
		var tempLeft=parseInt(dragObj.style.left)-26-addSides;
		var tempTop=parseInt(dragObj.style.top)-8;
		if(dragObj.id=="alaskaDiv"){alaskaLeft=tempLeft;alaskaTop=tempTop;}
		else if(dragObj.id=="hawaiiDiv"){hawaiiLeft=tempLeft;hawaiiTop=tempTop;}
		else if(dragObj.id=="titleDiv"){titleLeft=tempLeft;titleTop=tempTop;}
		else if(dragObj.id=="legendDiv"){legendLeft=tempLeft;legendTop=tempTop;}
		else if(dragObj.id=="logoDiv"){logoLeft=tempLeft;logoTop=tempTop;}
		dragObj=null;
	}
}
function checkBounds(compareLeft,compareTop,obj){
	/*make sure it doesn't drag outside the bounds*/
	var addSides=parseInt((totalwidth-mapwidth)/2);
	var objectWidth=parseInt(obj.offsetWidth);
	var maxLeft=(parseInt(mapwidth)+addSides)-objectWidth+20;
	var objectHeight=parseInt(obj.offsetHeight);
	var maxTop=parseInt(mapheight)-objectHeight+10;
	
	if(compareLeft>maxLeft){obj.style.left=maxLeft+"px";}
	else if(compareLeft<(26+addSides)){obj.style.left=(26+addSides)+"px";}
	else{obj.style.left=compareLeft+"px";}
	
	if((compareTop)>maxTop){obj.style.top=maxTop+"px";}
	else if((compareTop)<8){obj.style.top="8px";}
	else{obj.style.top=(compareTop)+"px";}
}

function resetMap(){
	/*reset variables*/
	ratioA=22;ratioB=34;
	laminationCost=0;logoCost=0;titleCost=0;layer1Cost=0;layer2Cost=0;cost=497.0;
	mapwidth=520;mapheight=520;alaskaLeft=30.0;alaskaTop=100.0;hawaiiLeft=130.0;hawaiiTop=100.0;titleLeft=30.0;titleTop=10.0;legendLeft=30.0;legendTop=200.0;
	citylat=0;citylon=0;
	calendar=false;alaska=false;hawaii=false;
	orientation="Landscape";mapname="cust-Classroom";focus="USA";background="";extralayer="";title="";titleSize="m";titleFont="Arial";titleColor="black";detail="med";
	if(units=="dd"){x1=-127.403303833817;y1=23;x2=-63.3284081533734;y2=50;}
	else if(units=="meters"){x1=-14400000;y1=2000000;x2=-7200000;y2=6700000;}
	/*reset options*/
	document.getElementById("custSize22x34").checked=true;
	document.getElementById("detailLevelMed").checked=true;
	document.getElementById("custOrientationLandscape").checked=true;
	document.getElementById("customMapColorsClassroom").checked=true;
	document.getElementById("laminationExtra").checked=false;
	document.getElementById("alaskaExtra").checked=false;
	document.getElementById("hawaiiExtra").checked=false;
	document.getElementById("logoExtra").checked=false;
	document.getElementById("titleExtra").checked=false;
	document.getElementById("layer1Extra").checked=false;
	document.getElementById("layer2Extra").checked=false;
	document.getElementById("searchcity").value="";
	document.getElementById("searchst").value="";
	document.getElementById("CityFrame").style.display="none";
	document.getElementById("logoToAdd").value="";
	document.getElementById("titleToAdd").value="";
	document.getElementById("titleFontFamily").value="Arial";
	document.getElementById("titleFontColor").value="black";
	document.getElementById("titleFontSizeMedium").checked=true;
	document.getElementById("layer1ToAdd").value="";
	document.getElementById("layer2ToAdd").value="";
	document.getElementById("choose700").style.display="none";
	document.getElementById("dragInfo").innerHTML="";
	document.getElementById("alaskaDiv").innerHTML="";
	document.getElementById("hawaiiDiv").innerHTML="";
	document.getElementById("titleDiv").innerHTML="";
	document.getElementById("legendDiv").innerHTML="";
	document.getElementById("displaySize").innerHTML=ratioA+"\" x "+ratioB+"\"";
	document.getElementById("orderFrame").src="mapsOrder.asp?step=1";
	document.getElementById("orderFrame").style.display="none";
	document.getElementById("readyToOrder").style.display="block";
	changeMapType("Custom");
	/*refresh map*/
	updateCost();
	changeMap();
}
/*refresh map functions*/
function changeMap(){
	clearOptions();
	showLoading();
	document.getElementById("titleDiv").innerHTML=title;
	var url="mapsProxy.asp";
	var params="getMap=yes&action=SETMAPBOUNDS&ratioA="+ratioA+"&ratioB="+ratioB+"&orientation="+orientation+"&mapname="+mapname+"&x1="+x1+"&y1="+y1+"&x2="+x2+"&y2="+y2+"&extralayer="+extralayer+"&focus="+focus+"&clat="+citylat+"&clon="+citylon+"&alaska="+alaska+"&hawaii="+hawaii+"&mapwidth="+mapwidth+"&mapheight="+mapheight+"&detail="+detail;
	getMap(url,params,"handleGetMap");
}
function previewPrint(){
	showLoading();
	var url="mapsProxy.asp";
	var params="getMap=yes&large=yes&action=SETMAPBOUNDS&ratioA="+ratioA+"&ratioB="+ratioB+"&orientation="+orientation+"&mapname="+mapname+"&x1="+x1+"&y1="+y1+"&x2="+x2+"&y2="+y2+"&extralayer="+extralayer+"&focus="+focus+"&clat="+citylat+"&clon="+citylon+"&alaska="+alaska+"&hawaii="+hawaii+"&title="+title.replace(/\s/,"%20")+"&hleft="+hawaiiLeft+"&htop="+hawaiiTop+"&aleft="+alaskaLeft+"&atop="+alaskaTop+"&ttop="+titleTop+"&tleft="+titleLeft+"&mapwidth="+mapwidth+"&mapheight="+mapheight+"&tsize="+titleSize+"&tfont="+titleFont+"&tcolor="+titleColor+"&lleft="+legendLeft+"&ltop="+legendTop+"&detail="+detail+"&lurl="+logoURL+"&lgleft="+logoLeft+"&lgtop="+logoTop+"&lgsize="+logoSize;
	getMap(url,params,"handleGetLargeMap");
}
function nextStep(){
	document.getElementById("orderFrame").style.display="block";
	document.getElementById("readyToOrder").style.display="none";
}
function submitOrder(){
	var url="mapsProxy.asp";
	var params="getMap=yes&large=full&action=SETMAPBOUNDS&ratioA="+ratioA+"&ratioB="+ratioB+"&orientation="+orientation+"&mapname="+mapname+"&x1="+x1+"&y1="+y1+"&x2="+x2+"&y2="+y2+"&extralayer="+extralayer+"&focus="+focus+"&clat="+citylat+"&clon="+citylon+"&alaska="+alaska+"&hawaii="+hawaii+"&title="+title.replace(/\s/,"%20")+"&hleft="+hawaiiLeft+"&htop="+hawaiiTop+"&aleft="+alaskaLeft+"&atop="+alaskaTop+"&ttop="+titleTop+"&tleft="+titleLeft+"&mapwidth="+mapwidth+"&mapheight="+mapheight+"&tsize="+titleSize+"&tfont="+titleFont+"&tcolor="+titleColor+"&lleft="+legendLeft+"&ltop="+legendTop+"&detail="+detail+"&lurl="+logoURL+"&lgleft="+logoLeft+"&lgtop="+logoTop+"&lgsize="+logoSize+"&fname="+shiptofirstname.replace(/\s/,"%20")+"&lname="+shiptolastname.replace(/\s/,"%20")+"&email="+shiptoemail.replace(/\s/,"%20")+"&addrStreet="+shiptostreet.replace(/\s/,"%20")+"&addrCity="+shiptocity.replace(/\s/,"%20")+"&addrState="+shiptostate.replace(/\s/,"%20")+"&addrZip="+shiptozip.replace(/\s/,"%20")+"&addrCountry="+shiptocountryname.replace(/\s/,"%20");
	getMap(url,params,"handleNextStep");
}
function getMap(url,params,handle){
	if (receiveReq.readyState == 4 || receiveReq.readyState == 0) {
		receiveReq.open("POST", url, true);
		receiveReq.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		receiveReq.onreadystatechange = function(){
			if(handle=="handleGetMap"){handleGetMap();}
			else if(handle=="handleGetLargeMap"){handleGetLargeMap();}
			else if(handle=="handleNextStep"){handleNextStep();}
		};
		receiveReq.send(params);
	}
}
function handleNextStep(){
	if(receiveReq.readyState==4){
		rText=receiveReq.responseText;
	}
}
function handleGetLargeMap(){
	if(receiveReq.readyState==4){
		//parse response
		rText=receiveReq.responseText;
		var rTextAry=rText.split("|");
		var mainSrc=rTextAry[0];
		var AKsrc=rTextAry[1];
		var HIsrc=rTextAry[2];
		var LGsrc=rTextAry[3];
		if(mainSrc.substring(0,4)!="http"){alert(rText);}
		else{
			//alert(rText);
			window.open(mainSrc);
		}
		hideLoading();
	}
}
function handleGetMap(){
	if(receiveReq.readyState==4){
		//parse response
		rText=receiveReq.responseText;
		var rTextAry=rText.split("|");
		var mainSrc=rTextAry[0];
		if(mainSrc.substring(0,4)!="http"){alert(rText);}
		else{
			var AKsrc=rTextAry[1];
			var HIsrc=rTextAry[2];
			var LGsrc=rTextAry[3];
			mapwidth=rTextAry[4];
			mapheight=rTextAry[5];
			//alert(rText);
			var mapImg=document.getElementById("customMapPreviewIMG");
			if(fadingMap==false){mapImg.src=mainSrc;}
			else{
				tempSrc=mainSrc;
				setTimeout("document.getElementById('customMapPreviewIMG').src=tempSrc;",800);
			}
			/*alaska*/
			if(AKsrc!=""){setTimeout("document.getElementById('alaskaDiv').innerHTML='<img src=\""+AKsrc+"\">';",800);}
			else{document.getElementById("alaskaDiv").innerHTML="";}
			/*hawaii*/
			if(HIsrc!=""){setTimeout("document.getElementById('hawaiiDiv').innerHTML=\"<img src='"+HIsrc+"'>\";",800);}
			else{document.getElementById("hawaiiDiv").innerHTML="";}
			/*drag directions*/
			if(HIsrc!=""||AKsrc!=""){document.getElementById("dragInfo").innerHTML="Drag the inset to reposition!";}
			else{document.getElementById("dragInfo").innerHTML="";}
			/*legend*/
			if(LGsrc!=""){document.getElementById("legendDiv").innerHTML="<span style='font-weight:bold;font-size:10px;'>Legend</span><br><img src='"+LGsrc+"' width='50'>";}
			else{document.getElementById("legendDiv").innerHTML="";}
			
			var ak=document.getElementById("alaskaDiv");
			var hi=document.getElementById("hawaiiDiv");
			var ttl=document.getElementById("titleDiv");
			var lg=document.getElementById("legendDiv");
			if(alaska){checkBounds(getLeft(ak),getTop(ak),ak);}
			if(hawaii){checkBounds(getLeft(hi),getTop(hi),hi);}
			checkBounds(getLeft(ttl),getTop(ttl),ttl);
			checkBounds(getLeft(lg),getTop(lg),lg);
		}
		hideLoading();
	}
}
function showLoading(){
	document.getElementById("LoadingIMG").src="/images/Plotter_loading.gif";
	document.getElementById("placeholder").style.display="block";
	document.getElementById("pleasewait").style.display="block";
	//fade image
	fadingMap=true;
	setMapOpacity(90,true);
	setTimeout("setMapOpacity(80,true);",140);
	setTimeout("setMapOpacity(70,true);",210);
	setTimeout("setMapOpacity(60,true);",280);
	setTimeout("setMapOpacity(50,true);",350);
	setTimeout("setMapOpacity(40,true);",420);
	setTimeout("setMapOpacity(30,true);",490);
	setTimeout("setMapOpacity(20,true);",560);
	setTimeout("setMapOpacity(10,true);",630);
	setTimeout("setMapOpacity(0,false);",700);
}
function hideLoading(){
	//scroll new image out
	if(fadingMap==false){scrollMapOut();}
	else{setTimeout("scrollMapOut();",800);}
}
function setMapOpacity(opac,fMap){
	if(opac==100){document.getElementById("customMapPreviewIMG").style.border="thick solid #00134F";}/*3B5F29*/
	document.getElementById("customMapPreview").style.opacity=opac/100;
	document.getElementById("customMapPreview").style.filter="alpha(opacity="+opac+")";
	fadingMap=fMap;
}
function scrollMapOut(){
	setMapOpacity(100,false);
	var maxTop=95;
	setMapTempHeight(-400,500);
	setTimeout("setMapTempHeight(-350,450);",50);
	setTimeout("setMapTempHeight(-300,400);",100);
	setTimeout("setMapTempHeight(-250,350);",150);
	setTimeout("setMapTempHeight(-200,300);",200);
	setTimeout("setMapTempHeight(-150,250);",250);
	setTimeout("setMapTempHeight(-100,200);",300);
	setTimeout("setMapTempHeight(-50,150);",350);
	setTimeout("setMapTempHeight(0,100);",400);
	setTimeout("setMapTempHeight(50,50);",450);
	setTimeout("setMapTempHeight(96,0);",500);
	setTimeout("document.getElementById(\"placeholder\").style.display=\"none\";",500);
	setTimeout("document.getElementById(\"LoadingIMG\").src=\"/images/Plotter_loadingstill.gif\";",500);
	setTimeout("document.getElementById(\"pleasewait\").style.display=\"none\";",500);
}
function setMapTempHeight(ht,ht2){
	document.getElementById("customMapPreview").style.top=ht+"px";
	document.getElementById("customMapPreview").style.clip="rect("+ht2+"px,610px,auto,auto)";
}

/*change options*/
function changeMapType(type){
	document.getElementById("btnCellular").className="mapChoice";
	document.getElementById("btnBTA").className="mapChoice";
	document.getElementById("btnTerrain").className="mapChoice";
	document.getElementById("btn700").className="mapChoice";
	//document.getElementById("btnOwnership").className="mapChoice";
	document.getElementById("btnCustom").className="mapChoice";
	if(type!="700A"&&type!="700B"&&type!="700C"&&type!="700E"){document.getElementById("btn"+type).className="mapChoice selectedMapChoice";}
	else{document.getElementById("btn700").className="mapChoice selectedMapChoice";}
	if(type=="Cellular"||type=="BTA"||type=="Terrain"||type=="700A"||type=="700B"||type=="700C"||type=="700E"){extralayer=type;changeMap();}
	else if(type=="Custom"){extralayer="";changeMap();}
	if(type!="700"){document.getElementById("choose700").style.visibility="hidden";}
}
function changeDetailLevel(lvl){
	detail=lvl;
	changeMap();
}
function changeRatio(ratA,ratB){
	ratioA=ratA;
	ratioB=ratB;
	if(ratioA==11&&ratioB==17){cost=297;}
	else if(ratioA==17&&ratioB==22){cost=397;}
	else if(ratioA==22&&ratioB==34){cost=497;}
	else if(ratioA==24&&ratioB==36){cost=597;}
	else if(ratioA==34&&ratioB==44){cost=697;}
	else if(ratioA==36&&ratioB==44){cost=747;}
	else if(ratioA==44&&ratioB==78){cost=997;}
	document.getElementById("displaySize").innerHTML=ratioA+"\" x "+ratioB+"\"";
	addRemoveLamination();
	updateCost();
	changeMap();
}
function changeBackground(bg){
	background=bg;
	changeMap();
}
function changeFocusToUSA(){
	focus="USA";
	detail="med";
	citylat=0;
	citylon=0;
	changeMap();
}
function changeFocusTo(st){
	focus=st;
	detail="high";
	citylat=0;
	citylon=0;
	changeMap();
}
function changeFocusTo2(city,st,clat,clon){
	focus=st;
	detail="vhigh";
	citylat=clat;
	citylon=clon;
	changeMap();
}
function changeOrientation(orient){
	orientation=orient;
	changeMap();
}
function changeMapfile(which){
	mapname="cust-"+which;
	changeMap();
}
function addRemoveLamination(){
	if(document.getElementById("laminationExtra").checked){
		intRatioA=ratioA/12
		intRatioB=ratioB/12
		if(parseInt(intRatioA)!=intRatioA){intRatioA=parseInt((ratioA/12)+1);}//round it up
		if(parseInt(intRatioB)!=intRatioB){intRatioB=parseInt((ratioB/12)+1);}//round it up
		laminationCost=laminationPerFoot*parseInt(intRatioA*intRatioB);
	}
	else{laminationCost=0;}
	updateCost();
}
function addRemoveLogo(){
	if(document.getElementById("logoExtra").checked){logoCost=5;}
	else{logoCost=0;}
	updateCost();
}
function addRemoveTitle(){
	if(document.getElementById("titleExtra").checked){titleCost=2;}
	else{titleCost=0;}
	updateCost();
}
function addRemoveLayer1(){
	if(document.getElementById("layer1Extra").checked){layer1Cost=25;}
	else{layer1Cost=0;}
	updateCost();
}
function addRemoveLayer2(){
	if(document.getElementById("layer2Extra").checked){layer2Cost=25;}
	else{layer2Cost=0;}
	updateCost();
}
function addRemoveAddmapmenu(){
	if(document.getElementById("alaskaExtra").checked){alaska=true;}
	else{alaska=false;}
	if(document.getElementById("hawaiiExtra").checked){hawaii=true;}
	else{hawaii=false;}
	if(document.getElementById("logoExtra").checked&&document.getElementById("logoToAdd").value!=""){
		document.uploadFormLogo.submit();
	}
	else{document.getElementById("logoDiv").innerHTML="";logoURL="";}
	if(document.getElementById("titleExtra").checked){title=document.getElementById("titleToAdd").value;}
	else{title="";}
	if((document.getElementById("layer1Extra").checked&&document.getElementById("layer1ToAdd").value!="")||(document.getElementById("layer2Extra").checked&&document.getElementById("layer2ToAdd").value!="")){document.uploadFormData.submit();}
	else{}
	changeMap();
}
function setLogo(url){
	if(url!=""){document.getElementById("logoImg").src=url;logoURL=url;}
	else{document.getElementById("logoImg").src="/images/trans.gif";logoURL="";}
}
function changeTitleSize(sz){
	titleSize=sz;
	var td=document.getElementById("titleDiv");
	if(titleSize=="s"){td.style.fontSize="10px";}
	else if(titleSize=="m"){td.style.fontSize="14px";}
	else if(titleSize=="l"){td.style.fontSize="18px";}
}
function changeLogoSize(sz){
	logoSize=sz;
	var li=document.getElementById("logoImg");
	if(logoSize=="s"){li.width='30';}
	else if(logoSize=="m"){li.width='50';}
	else if(logoSize=="l"){li.width='80';}
}
function changeTitleFont(){
	titleFont=document.getElementById("titleFontFamily").value;
	document.getElementById("titleDiv").style.fontFamily=titleFont;
}
function changeTitleColor(){
	titleColor=document.getElementById("titleFontColor").value;
	document.getElementById("titleDiv").style.color=titleColor;
}

/*menu functions*/
function updateCost(){
	document.getElementById("dollarAmount").innerHTML=cost+laminationCost+logoCost+titleCost+layer1Cost+layer2Cost;
}
function moverOptions(a){
	var img=document.getElementById("btn"+a).src;
	if(img.indexOf("select")==-1){
	document.getElementById("btn"+a).src="/images/Plotter_btn"+a+"-large.gif";
	}
}
function moutOptions(a){
	var img=document.getElementById("btn"+a).src;
	if(img.indexOf("select")==-1){
	document.getElementById("btn"+a).src="/images/Plotter_btn"+a+"-small.gif";
	}
}
function showMenu(a){
	var menu=document.getElementById("menu"+a);
	if(menu.style.display=="none"){
		clearOptions();
		menu.style.display="block";
		document.getElementById("btn"+a).src="/images/Plotter_btn"+a+"-select.gif";
	}
	else{menu.style.display="none";
	document.getElementById("btn"+a).src="/images/Plotter_btn"+a+"-small.gif";
	}
}
function clearOptions(){
	document.getElementById("menuBaseMap").style.display="none";
	document.getElementById("menuLayout").style.display="none";
	document.getElementById("menuColorScheme").style.display="none";
	document.getElementById("menuAdd").style.display="none";
	document.getElementById("menuSize").style.display="none";
	document.getElementById("menuCart").style.display="none";
	document.getElementById("orderFrame").src="mapsOrder.asp?step=1";
	document.getElementById("orderFrame").style.display="none";
	document.getElementById("readyToOrder").style.display="block";
	document.getElementById("btnBaseMap").src="/images/Plotter_btnBaseMap-small.gif";
	document.getElementById("btnLayout").src="/images/Plotter_btnLayout-small.gif";
	document.getElementById("btnColorScheme").src="/images/Plotter_btnColorScheme-small.gif";
	document.getElementById("btnAdd").src="/images/Plotter_btnAdd-small.gif";
	document.getElementById("btnSize").src="/images/Plotter_btnSize-small.gif";
	document.getElementById("btnCart").src="/images/Plotter_btnCart-small.gif";
}
function dropDown700(){
	var c700=document.getElementById("choose700");
	if(c700.style.visibility=="hidden"){
		c700.style.visibility="visible";
	}
	else{c700.style.visibility="hidden";}
	changeMapType('700');
}

/*stolen function*/
function OpenCityQuery(a){
	if (document.getElementById("searchcity").value!=''){
		if ((a == '1') && (document.getElementById("searchcity").value.length >= 3)){
			var CityFrame = document.getElementById('CityFrame');
					   
			CityFrame.style.display = "block"
			if(a == '1'){CityFrame.src = 'CityQuery.asp?city=' + document.getElementById("searchcity").value + '&state=' + document.getElementById("searchst").value + '&thisisfromaSearchTool=true&CityToSend=searchcity&StateToSend=searchst';}
	    }
	}else if (document.getElementById("searchst").value!=''){
		if ((a == '1') && (document.getElementById("searchst").value.length == 2)){
			var CityFrame = document.getElementById('CityFrame');
			CityFrame.style.display = "block"
			if(a == '1'){CityFrame.src = 'CityQuery.asp?state=' + document.getElementById("searchst").value + '&thisisfromaSearchTool=true&CityToSend=searchcity&StateToSend=searchst';}
		}
	}
}

/*general functions*/
function debug(text){
	//document.getElementById("debug").innerHTML=text;
}
function getLeft(obj){
	if(obj.style.left=='auto'||obj.style.left==''){return 0;}
	else{return parseInt(obj.style.left);}
}
function getTop(obj){
	if(obj.style.top=='auto'||obj.style.top==''){return 0;}
	else{return parseInt(obj.style.top);}
}
function format(expr, decplaces){
	var str= "" +Math.round(eval(expr)*Math.pow(10,decplaces));
	while (str.length <=decplaces) {
		str= "0" + str;
	}
	var decpoint=str.length-decplaces;
	return str.substring(0,decpoint)+"."+str.substring(decpoint,str.length);
}
