//idx version

var isBusy=false;
 ////utility fro drive directions
// resize fix for ns4
var origWidth, origHeight;
if (document.layers) {
	origWidth = window.innerWidth; origHeight = window.innerHeight;
	window.onresize = function() { if (window.innerWidth != origWidth || window.innerHeight != origHeight) history.go(0); }
}

var page_loaded; // set true onload (avoid errors onmouseover/out before page loaded)
function initInfoLyr() {
  page_loaded = true; 
  writeToLayer('drivedirinfo', origMsg); // write first message onload
}

function writeToLayer(id, sHTML) {
  if (!page_loaded) return;
  var el = (document.getElementById)? document.getElementById(id): (document.all)? document.all[id]: (document.layers)? document.layers[id]: null;
  if (!el) return;
  var cntnt = '<div class="info">' + sHTML + '</div>';
  if (typeof el.innerHTML!="undefined") {
      el.innerHTML = cntnt;
  } else if (document.layers) {
			el.document.write(cntnt);
			el.document.close();
  }
}

// Variables for layer content
var origMsg = '<div class="hot">Here is the write layer. Position and style it any way you like.</div>';
var dfltMsg = "";


////drive route:
function showDriveDiv(divname){

if (divname == 'drivedivfrom'){
	document.getElementById('drivedivto').style.display = 'none';
	document.getElementById('drivedivfrom').style.display = 'block';
	}
else {
	document.getElementById('drivedivfrom').style.display ='none';
	document.getElementById('drivedivto').style.display = 'block';
	}
}
function FindLoc(dir){
	
	if(dir =='from'){
		//alert(document.getElementById('txtFrom').value + document.getElementById('fromtxtTo').value);
		map.GetRoute(document.getElementById('txtFrom').value,document.getElementById('fromtxtTo').value,null,null,onGotRoute);
	}else if (dir =='to'){
		//alert(document.getElementById('totxtFrom').value + document.getElementById('txtTo').value);
		map.GetRoute(document.getElementById('totxtFrom').value,document.getElementById('txtTo').value,null,null,onGotRoute);
		}
  //map.GetRoute(document.getElementById('txtFrom').value,document.getElementById('txtTo').value,null,null,onGotRoute);
}

function onGotRoute(route){
		var boxhtml = "<table border='1' width='400' bgcolor='DEE7EF' cellspacing='0' cellpadding='0'><tr><td width='100%'><table border='0' width='100%' cellspacing='2' cellpadding='2' >";
		boxhtml = boxhtml + "<tr><td  class='xlBlue'>Route info:</td><td ><a href='JavaScript' onClick='hideMe();return false' class='xlBlue'>X</a></td></tr>";
		boxhtml = boxhtml + "<tr><td  bgcolor='#FFFFFF' style='padding:4px' colspan='2' class='smBlack'>";
		
		var routeinfo="";
		routeinfo+="Total distance: ";
		routeinfo+=   route.Itinerary.Distance+" ";
		routeinfo+=   route.Itinerary.DistanceUnit+"<br>";
		
		
		var steps="";
		var len = route.Itinerary.Segments.length;
		   for(var i = 0; i < len ;i++)
		   {
		      steps+=route.Itinerary.Segments[i].Instruction+" -- (";
		      steps+=route.Itinerary.Segments[i].Distance+") ";
		      steps+=route.Itinerary.DistanceUnit+"<br>";
		   }
		routeinfo+="Steps:\n"+steps;
		
		
		boxhtml = boxhtml + routeinfo;
		boxhtml = boxhtml + "</td></tr></table>";
		//document.getElementById('theLayer').innerHTML = boxhtml;
		//alert(document.getElementById('theLayer').innerHTML)
		//alert(boxhtml);
		showMe();
		writeToLayer('drivedirinfo', boxhtml);
		//myroutinfobox.style.visibility= ' ';
		//myroutinfobox.innerHTML = routeinfo;
}

function hideMe(){
	
		
	document.getElementById('drivedirinfo').style.display = 'none';

}

function showMe(){
	document.getElementById('drivedirinfo').style.display = 'block';

}


///utility fuctions for tabs
function setTab(activeTab,activeDiv){
	
var tabMap = document.getElementById('tabMap');
var tabPoly = document.getElementById('tabPoly');
var tabProxZip = document.getElementById('tabProxZip');

var divMapsearch = document.getElementById('divMapsearch');
var divPolysearch = document.getElementById('divPolysearch');
var divZipsearch = document.getElementById('divZipsearch');

if(activeTab =='tabPoly'){
	changeClass('tabProxZip','tabNormal');
	changeClass('tabMapsearch','tabNormal');
	hideDiv('divZipsearch');
	}else if (activeTab =='tabProxZip'){
	changeClass('tabPoly','tabNormal');
	changeClass('tabMapsearch','tabNormal');
	url = "getprops.cfm?all=1";
	icon = 'proximity';
	hideDiv('divPolysearch');
	}else{
	hideDiv('divPolysearch');
	hideDiv('divZipsearch');
	url = "getprops.cfm?all=1"; // The server-side script
	icon='searchlist';
	changeClass('tabPoly','tabNormal');
	changeClass('tabProxZip','tabNormal');
	}
	
	changeClass(activeTab,'tabActive');
	
	if(activeTab != 'tabMapsearch'){
	
		showDiv(activeDiv);}
	
}

function setTab2(activeTab,activeDiv)
{

if (activeDiv =='divMap'){

	hideDiv('divList');
	//changeClass('tabList','tabNormal');
	//changeClass('tabMap','tabActive');
	//map.AddControl(listViewControl);
}else{
	
	hideDiv('divMap');
	//changeClass('tabMap','tabNormal');
	//changeClass('tabList','tabActive');
	}
	showDiv(activeDiv);
	//changeClass(activeTab,'tabActive');

	
}
function hideDiv(id){
	if (document.getElementById) { // DOM3 = IE5, NS6
			document.getElementById(id).style.display = 'none';			
		
	} else { 
		if (document.layers) {	
						
				document.id.display = 'none';
			
		} else {
			
				document.all.id.style.display = 'none';
			
		}
	}
}
function showDiv(id){
	if (document.getElementById) { // DOM3 = IE5, NS6
		
			document.getElementById(id).style.display = 'block';			
			
	} else { 
		if (document.layers) {	
						
				document.id.display = 'block';
			
		} else {
			
				document.all.id.style.display = 'block';
			
		}
	}
}
function changeClass(aDiv,aClass){
	
	if (document.getElementById) { // DOM3 = IE5, NS6
	
		document.getElementById(aDiv).className = aClass;
	}else {
		if (document.layers) {
			document.aDiv.className = aClass;
		}else{
			document.all.aDiv.className = aClass;
		}
	}
	
}
function listView(){
	hideDiv('divMap');
	showDiv('divListing');
}

function mapView(){
	hideDiv('divListing');
	showDiv('divMap');
}

function flipchild(divid){
		
	obj = document.getElementById('child1');
	if(obj.style.display == 'none') {
		obj.style.display = '';
		
	}
	else {
		obj.style.display = 'none';
	}

}


function retData(hObj){
	//alert(hObj);
	//offAll();
	
	hObj.className="selected";
	//waitGen("dcHolder");
	
	//var url="getData.cfm?contentName="+tabName+"&nc="+Math.random();
	//loadData(url,"dcHolder");
}



function waitGen(divID){
document.getElementById(divID).innerHTML="<div style='font-weight:400;text-align:center;width:auto;padding-top:10px;color:#333333;font-size:11px;margin-top:50px;'><img src='/graphics/loading.gif'><br>Loading content...</div>";
}


