function openTab(whichTab) {
//NOTE!! this code will break if there are more than 10 tabs
	setTabLookAll("detail","Active");
	setTabLook(whichTab,"detail","Hilite");

	var divNum = eval(whichTab.id.charAt(whichTab.id.length - 1));

//alert("this is tab number:" + whichTab.id.charAt(whichTab.id.length - 1));
//alert(divNum + " -- " + divNamesArray[divNum] + " -- " + document.getElementById(divNamesArray[divNum]));
//alert("about to show div:" + document.getElementById(divNamesArray[divNum]));
	meDiv_showMe(document.getElementById(divNamesArray[divNum]));
}


/////////////////////////////////////////////map interactions

var mapNotInit = true;
//setting mapLoc to Rob's local Apache for now
//var mapLoc = "http://atprod.homes.com:8080/TrueNorth/"

//var mapLoc = "http://pattymcnease.com.cameronr.homes.com/TrueNorth/AABA/"
var mapLoc = "http://atprod.homes.com:8080/TrueNorth/AABA/"
detailMap_zoomLevel = 0;

function setMapZoom(zl) {
//just sets the zoom in the UI and the local zoom variable. Does not request the new map.
//alert("setting map zoom:" + imgName + " to "+ zl);
	var oldZoom = detailMap_zoomLevel;
	if (zl != oldZoom) {
		searchPage_currZoom = zl;

		if (oldZoom < 10) {
			oldZoom = "0" + oldZoom;
		} else {
			oldZoom = oldZoom.toString();
		}

		var oldDot = document.getElementById("detailMapzoomImg" + oldZoom);
		if (oldDot) {
			oldDot.src = "/images/maps/zoomDot_off.gif";
		}

		detailMap_zoomLevel =  zl;

		if (zl < 10) {
			zl = "0" + zl;
		} else {
			zl = zl.toString();
		}

		var zoomDot = document.getElementById("detailMapzoomImg" + zl);
		zoomDot.src = "/images/maps/zoomDot_on.gif";

	}
}


function mapClick(evt,whichMap) {	
	document.getElementById("detailMapmapGrayOutAllDiv").style.visibility = "visible";
	document.getElementById("detailMapmapInterstitialDiv").style.visibility = "visible";

	var mode = FormUtils_getRadioButtonValue(whichMap + "mapClickSelect");

	var stdParams = "";

if (mode == "zoom") mode = "zoomin";

	if (mode == "zoomin") {
		newZoom = detailMap_zoomLevel - 1;
		if (newZoom > 0) {
			setMapZoom(newZoom);
		} else {
			mode = "center";
		}
	}

	stdParams = "bn=sMap&cmd=" + mode + "&";

	if (mode == "zoomin") {
		stdParams += "l=" + (newZoom + 1) + "&";
	}
	

	if (evt.offsetX) { //mozilla
		stdParams += "x=" +evt.offsetX + "&y=" +evt.offsetY + "&t=" + (new Date()).getTime();
	} else { //ie
	    var mozX = window.pageXOffset + evt.clientX - CssUtils_findPosX(document.getElementById(whichMap));
	    var mozY = window.pageYOffset + evt.clientY - CssUtils_findPosY(document.getElementById(whichMap));

		stdParams += "x=" + mozX + "&y=" + mozY + "&t=" + (new Date()).getTime();
	}

	document.getElementById(whichMap).src = mapLoc + "drawMap.jsp?" + stdParams;
}


function mapTabClick(mapWidth,mapHeight,longitude,latitude,addy,city,state,zip) {
	if (mapNotInit) {
		if (longitude == 0 && latitude ==0) {
			document.getElementById("detailMap").src = mapLoc + "drawMapInit.jsp?w="+mapWidth+"&h="+mapHeight+"&ad="+addy+"&ci="+city + "&st="+state + "&zp="+zip + "&t=" + (new Date()).getTime();
		} else {
			document.getElementById("detailMap").src = mapLoc + "drawMapInit.jsp?w="+mapWidth+"&h="+mapHeight+"&lo="+longitude+"&la="+latitude + "&t=" + (new Date()).getTime();
		}
		mapNotInit = false;
	}
}

function mySetDir(whichMapObj,whatDir) {
	document.getElementById(whichMapObj + "mapGrayOutAllDiv").style.visibility = "visible";
	document.getElementById(whichMapObj + "mapInterstitialDiv").style.visibility = "visible";

	whichMapObj = document.getElementById(whichMapObj);
	setDirection(mapLoc,whichMapObj,whatDir);
}



function zoomDotOver(tdObj) {
	tdId = tdObj.id;
	tdIdLength = tdObj.id.length;

	var grObj = document.getElementById(tdId.substring(0,tdIdLength - 10) + "zoomImg" + tdId.substring(tdIdLength-2,tdIdLength));
	grObj.src = imgLoc + "zoomDot_on.gif";
}

function zoomDotOut(tdObj){
	tdId = tdObj.id;
	tdIdLength = tdObj.id.length;

	if (parseInt(tdId.substring(tdIdLength-2,tdIdLength),10) != detailMap_zoomLevel) {
//alert("*"+ tdId.substring(0,tdIdLength - 10) + "zoomImg" + tdId.substring(tdIdLength-2,tdIdLength) + "*");
		var grObj = document.getElementById(tdId.substring(0,tdIdLength - 10) + "zoomImg" + tdId.substring(tdIdLength-2,tdIdLength));
		grObj.src = imgLoc + "zoomDot_off.gif";
	}
}

function zoomDotClick(tdObj) {
	tdIdLength = tdObj.id.length;

	var newZoom = parseInt(tdObj.id.substring(tdIdLength-2,tdIdLength),10);
	var mapImgId = "detailMap";

	//turn off highlight graphic on level that was previously hilit, if not this one
	if (detailMap_zoomLevel != newZoom) {
		if (detailMap_zoomLevel < 10) {
			detailMap_zoomLevel = "0" + detailMap_zoomLevel;
		} else {
			detailMap_zoomLevel = detailMap_zoomLevel.toString();
		}

		var oldZoomDot = document.getElementById(mapImgId + "zoomImg" + detailMap_zoomLevel);
		oldZoomDot.src = "/images/maps/zoomDot_off.gif";

		mySetZoom(mapImgId,newZoom);
		searchPage_currZoom = newZoom;
	}
}

function mySetZoom(whichMapObj,whatLevel) {
//position by whichMapObj
	document.getElementById(whichMapObj + "mapGrayOutAllDiv").style.visibility = "visible";
	document.getElementById(whichMapObj + "mapInterstitialDiv").style.visibility = "visible";

	document.getElementById(whichMapObj).src = mapLoc + "drawMap.jsp?bn=sMap&cmd=zoom&l=" + whatLevel + "&t=" + (new Date()).getTime();

	detailMap_zoomLevel = whatLevel;
}


function zoomPlus(imgObj) {
//the plus on the interface actually indicates we want to go to a lower-numbered zoom level
	var oldZoom = detailMap_zoomLevel;
	if (oldZoom > 1) {
		//need to switch the dot first
		setMapZoom(oldZoom - 1);
		mySetZoom(imgObj.id,oldZoom - 1);
	}
}

function zoomMinus(imgObj) {
//the minus on the interface actually indicates we want to go to a higher-numbered zoom level
	var oldZoom = detailMap_zoomLevel;
	if (oldZoom < 10) {
		//need to switch the dot first
		setMapZoom(oldZoom + 1);
		mySetZoom(imgObj.id,oldZoom + 1);
	}
}

function hideInterstitial() {
	document.getElementById("detailMapmapGrayOutAllDiv").style.visibility = "hidden";
	document.getElementById("detailMapmapInterstitialDiv").style.visibility = "hidden";
}

function mapIframe (iframeLoc) {
//only used for MQ/Canada
	if (mapNotInit) {
		document.getElementById("mapIframe").src=iframeLoc+ "&parentDomain=" + location.host;
		mapNotInit = false;
	}
}

