
// cross domain usage
if (document.domain.split('.').length > 2) 
{
document.domain = document.domain.substring(document.domain.indexOf('.') + 1);
}

var box;
var startX;
var startY;
var endX;
var endY;
var fromParent = false;
var strUrl = new String("");
var strTest = new String("");
var dragging = false;
var mapOffsetLeft;
var mapOffsetTop;
var mapBodyClientLeft;
var mapBodyClientTop;
var sStartLng;
var sStartLat;
var sEndLng;
var sEndLat;
var sCenterLng;
var sCenterLat;
var sZoomLevel;
var sMapScale;
var newX;
var newY;
var sTrans;
var zoom;
var pinAdjust; // added for pin adjustment

pinAdjust = false; //added for pin adjustment

sStartLng = 0;
sStartLat = 0;
sEndLng = 0;
sEndLat = 0;
zoom = false;
var magicDomain = "";
var loginDomain = "";



// Summary: Initializes variables and displays listing data for the first listing
// Requirements:
//		- The showDetail function
function initPage() 
{
	document.forms["MapForm"].item("hdnNewPoi").value = "0";
	showDetail(1);
	
	try
	{
		if (typeof(window.opener.MagicDomain) != 'undefined')
		{
			magicDomain = window.opener.MagicDomain;
		}
		else if (typeof(window.opener.parent.MagicDomain) != 'undefined')
		{
			magicDomain = window.opener.parent.MagicDomain;
		}
		
		if (typeof(window.opener.LoginDomain) != 'undefined')
		{
			loginDomain = window.opener.LoginDomain;
		}
		else if (typeof(window.opener.parent.LoginDomain) != 'undefined')
		{
			loginDomain = window.opener.parent.LoginDomain;
		}
	}
	catch(ex)
	{}
}

// Summary: Initializes variables for the MapCma page
function initPageMapCma() 
{
	sMapScale = parseFloat(document.forms["MapForm"].hdnMapscale.value);
	getOffSets();
}


// Summary: Initializes variables for the MapPoi page
function initPageMapPoi() 
{
	sMapScale = parseFloat(document.forms["MapForm"].hdnMapscale.value);
	getOffSets();
}

// Summary: Initializes variables for the PageMoveLocation page
function initPageMoveLocation() 
{
	sMapScale = parseFloat(document.forms["MapForm"].hdnMapscale.value);
	getOffSets();
}

// Summary: Initializes variables for the MapWithZoom page and calls parent page 
//			functions to initialize that page
function initPageMapWithZoom() 
{
	sMapScale = parseFloat(document.forms["MapForm"].hdnMapscale.value);
	var strGeoCode;
	var strGeoLat;
	var strGeoLng;
	var strGeoResults;
	var oParent;
	strGeoCode = document.forms["MapForm"].geocode.value;
	getOffSets();
	strGeoLat = document.forms["MapForm"].geoLat.value;
	strGeoLng = document.forms["MapForm"].geoLng.value;
	strGeoResults = document.forms["MapForm"].geoResults.value;
	oParent = self.parent.frames;
	if ( oParent.length > 0 ) {
		if ( strGeoCode == "True" ) {
			self.parent.receiveGeoCodes(strGeoLng, strGeoLat, strGeoResults);
		}
	}

	sStartLng = document.forms[0].startLng.value;
	sStartLat = document.forms[0].startLat.value;
	sEndLng = document.forms[0].endLng.value;
	sEndLat = document.forms[0].endLat.value;
	sCenterLng = document.forms[0].centerLng.value;
	sCenterLat = document.forms[0].centerLat.value;
	sZoomLevel = document.forms[0].zoomLevel.value;
	sTrans = document.forms["MapForm"].trans.value;

	if ( oParent.length > 0 ) {
		self.parent.receiveCoordinates(sStartLng, sStartLat, sEndLng, sEndLat, sCenterLng, sCenterLat, sMapScale);
	}
}

//Summary: set the pin adjust enviroment var and the cursor style
function SetPin()
{
	pinAdjust = true;
	document.getElementById("MapImage").style.cursor = "hand";	
}

// Summary: adjust the pin to the point that was single clicked and 
//			reset the cursor and pinAdjust enviroment var
function AdjustPin()
{
	var pinX = window.event.x;
	var pinY = window.event.y;
	
	if(pinAdjust) {
		document.forms["MapForm"].hdnNewPinIntX.value = pinX;
		document.forms["MapForm"].hdnNewPinIntY.value = pinY;
		document.forms["MapForm"].hdnMapLeft.value = document.images["MapImage"].offsetLeft;
		document.forms["MapForm"].hdnMapTop.value = document.images["MapImage"].offsetTop;
		document.forms["MapForm"].hdnBodyLeft.value = document.body.clientLeft;
		document.forms["MapForm"].hdnBodyTop.value = document.body.clientTop;
		
		NewPin();
		pinAdjust = false;
		
		document.getElementById("MapImage").style.cursor = "crosshair";
	}
	event.returnValue = false;
}

//Summary: go back to the enter listing page
function GoHome()
{
	var adjustNum;
	adjustNum = parseInt(document.forms["MapForm"].hdnAdjustNum.value);
	geoCodePage = history.go(-adjustNum);
}


// Summary: Submits the parcel map form
function ParcelMap()
{
	// The following line needs to be uncommentted in order to pop up a resizable window
	//document.forms["ParcelForm"].submit();
	
	// The following code needs to be uncommented in order to pop up a fixed size window.  
	var parcelMapUrl;
	var parcelForm;
	var parcelWin;
	
	parcelForm = document.getElementById("ParcelForm");
	parcelMapUrl = parcelForm.action;
	//parcelMapUrl = 'http://parcels.rapmls.com/parcelmap-staging/?';
	parcelMapUrl += "SessionNumber=" + document.getElementById("SessionNumber").value + "&";
	parcelMapUrl += "MLS=" + document.getElementById("MLS").value + "&";
	parcelMapUrl += "ListingRID=" + document.getElementById("ListingRID").value + "&";
	parcelMapUrl += "LoginDomain=" + document.getElementById("LoginDomain").value + "&";
	parcelMapUrl += "MagicDomain=" + document.getElementById("MagicDomain").value;
	
	//alert(parcelMapUrl);
	parcelWin = window.open(parcelMapUrl, 'parcelMapWin', 'menubar=no,toolbar=no,resizable=no,directories=no,scrollbars=no,status=no,height=710,width=980');
	parcelWin.focus();
	window.close();
}

// Summary: Resets the hidden fields that are used for setting up the Aerial Map/Street Map button
//			whenever a single listing is clicked on the MapWithAddress page
function ResetMapButtons()
{
	document.forms["MapForm"].hdnImageType.value = "map";
	document.forms["MapForm"].hdnShowHideButtons.value = "aerial";
	UpdateDisplay();
}

// Summary: Updates the visibility of aerial map data, sets the text on the map button
//			and re-enables the map button on the MapWithAddress page
function UpdateDisplay() 
{
	var doc;
	var sTrans;
	var mapType;
	var mapIcons;
	var mapButtons;
	var aerialEnabled;
	var parcelEnabled;
	
	doc = document;
	if( self.parent.frames.length > 0 )
	{
		if( self.parent.frames["mapFrame"] )
		{
			doc = self.parent.document;
		}
	}
	
	sTrans = doc.forms["MapForm"].trans.value;
	if (sTrans == "MapWithAddress")
	{
		aerialEnabled = doc.forms["MapForm"].hdnAerialEnabled.value;
		if (aerialEnabled == "True") {
			mapType=doc.forms["MapForm"].hdnImageType.value;
			mapButtons=doc.forms["MapForm"].hdnShowHideButtons.value;

			if (mapType == "gex") {
				doc.getElementById("AerialDisclaimer").style.visibility="visible";
				doc.getElementById("OrderImage").style.visibility="visible";
				doc.getElementById("Report").disabled=true;
			}
			else 
			{
				doc.getElementById("AerialDisclaimer").style.visibility="hidden";
				doc.getElementById("OrderImage").style.visibility="hidden"
				doc.getElementById("Report").disabled=false;
			}
			
			if (mapButtons == "street") {
				doc.getElementById("hbtnAerialMap").value="Street Map";
			}
			if (mapButtons == "aerial") {
				doc.getElementById("hbtnAerialMap").value="Aerial Photo";
			}
			doc.getElementById("hbtnAerialMap").disabled = false;
		}
	}
}

// Summary: Alternates between the aerial map and street map images in the 
//			MapWithAddress button
function GexMap() 
{
	var objBtn;
	var strBtn;
	var strGexImage;
	var strMapImage;
	objBtn = document.getElementById("hbtnAerialMap");
	strBtn = objBtn.value;
	objBtn.disabled = true;
	if (strBtn == "Aerial Photo") 
	{
		document.forms["MapForm"].hdnImageType.value="gex";
		document.forms["MapForm"].hdnShowHideButtons.value="street";
		document.frames[0].document.forms["MapForm"].hdnMapType.value = "aerial";
		strGexImage = document.frames["mapFrame"].document.forms["MapForm"].hdnScriptGex.value;
		document.frames[0].document.images["MapImage"].src = strGexImage;
	} 
	else 
	{
		document.forms["MapForm"].hdnImageType.value="map";
		document.forms["MapForm"].hdnShowHideButtons.value="aerial";
		document.frames[0].document.forms["MapForm"].hdnMapType.value = "map";
		strMapImage = document.frames["mapFrame"].document.forms["MapForm"].hdnMapImageURL.value;
		document.frames[0].document.images["MapImage"].src = strMapImage;
	}
}


// Summary: Opens a new window with the link to purchase an aerial image
function OrderImage() 
{
	sTrans = document.forms["MapForm"].trans.value;
	if (sTrans == "MapWithAddress") 
	{
		strUrl = document.frames["mapFrame"].document.forms["MapForm"].hdnOrderImageUrl.value;
		window.open(strUrl,"OrderImage","");
	}
	//alert("This link is under construction; when it is finished it will open a new window to order images");
}

// Summary: Prevents a user from displaying an aerial map if the map is not centered on a single listing
function AerialNotAvailable() 
{
	if( document.forms["MapForm"].hdnNewPoi.value == "0" )
	{
		strMsg = "This feature is only available for a single listing. To center on one listing, click on the address above."
		alert(strMsg);
	}
	else
	{
		GexMap();
	}
}

// Summary: Initializes the image offsets
function getOffSets() {
	mapOffsetLeft = document.images["MapImage"].offsetLeft;
	mapOffsetTop = document.images["MapImage"].offsetTop;
	mapBodyClientLeft = document.body.clientLeft;
	mapBodyClientTop = document.body.clientTop;
}

function chkIncludeMapInSearch( blnChecked )
{
	try
	{
		if(self.parent.document.forms["InputForm"]) {
			if(self.parent.document.forms["InputForm"].Include_Map_In_Search)
				self.parent.document.forms["InputForm"].Include_Map_In_Search.checked = blnChecked;
		}
	}
	catch(err)
	{
	}
}

// Summary: Draws a box over the map image after a user performs a zoom to box 
function drawBox() 
{
	var boxTop;
	var boxLeft;
	
	if (box != null) 
	{
		document.body.removeChild(box);
		box = null;
	}
	
	strTest = document.forms["MapForm"].hdnShowBox.value;
	
	if (strTest == "yes") 
	{
		mapOffsetLeft = document.images["MapImage"].offsetLeft;
		mapOffsetTop = document.images["MapImage"].offsetTop;
		mapBodyClientLeft = document.body.clientLeft;
		mapBodyClientTop = document.body.clientTop;
		boxTop =  parseInt(document.forms["MapForm"].hdnBoxStartY.value)  + mapOffsetTop + mapBodyClientTop;
		boxLeft = parseInt(document.forms["MapForm"].hdnBoxStartX.value) + mapOffsetLeft + mapBodyClientLeft;
		boxRight = parseInt(document.forms["MapForm"].hdnBoxEndX.value) + mapOffsetLeft + mapBodyClientLeft;
		boxBottom = parseInt(document.forms["MapForm"].hdnBoxEndY.value) + mapOffsetTop + mapBodyClientTop;
		
		box = document.createElement("DIV")
		box.style.width = "0";
		box.style.height = "0";
		box.style.fontSize = "0";
		box.style.borderColor = "red";
		box.style.borderWidth = "2";
		box.style.borderStyle = "solid";
		box.style.cursor = 2;
	 	box.style.position = "absolute";
		box.zIndex = 2;
		box.style.top = boxTop;
		box.style.left = boxLeft;
		box.style.width = boxRight - boxLeft;
		box.style.height = boxBottom - boxTop;
		document.body.appendChild(box);
		chkIncludeMapInSearch(true);
	}
	else
	{
		chkIncludeMapInSearch(false);
	}
}

// Summary: Initializes the drawing of the box when a user first starts to click and
//				drag over the map image
function OnMouseDown() 
{
	if (box != null) 
	{
		document.body.removeChild(box);
		box = null;
	}
	box = document.createElement("DIV");
	box.style.width = "0";
	box.style.height = "0";
	box.style.fontSize = "0";
	box.style.borderColor = "red";
	box.style.borderWidth = "2";
	box.style.borderStyle = "dashed";
	box.style.position = "absolute";
	box.style.cursor = "crosshair";
	box.zIndex = 2;
	startX = event.clientX;
	startY = event.clientY;
	document.body.appendChild(box);
	document.images["MapImage"].setCapture();
	window.event.returnValue = false;
}

// Summary: Draws the box as a user click and drags on the map image
function OnMouseMove() 
{
	if( event.button == 1 )
	{
		if (!( startX || startY )) return false;
			
		if (sMapScale <= 6000) 
		{
			window.status = "Already at maximum zoom -- you need to zoom out first to search inside the rectangle";
		}
		newX = event.clientX;
		newY = event.clientY;

		if (newX - startX  >= 0) 
		{
			box.style.left = startX - document.body.clientLeft;
			box.style.width = newX - startX;
		} 
		else 
		{
			box.style.left = newX - document.body.clientLeft;
			box.style.width = startX - newX;
		}
		if (newY - startY >= 0) 
		{
			box.style.top = startY - document.body.clientTop;
			box.style.height = newY - startY;
		} 
		else 
		{
			box.style.top = newY - document.body.clientTop;
			box.style.height = startY - newY;
		}
	}
}

function OnMouseUp()
{
	
	document.images["MapImage"].releaseCapture();
	
	if(!( newX || newY )) return false;
	
	endX = newX;
	endY = newY;

	if (startX < endX) 
	{
		document.forms["MapForm"].hdnBoxStartX.value = startX - mapOffsetLeft;
		document.forms["MapForm"].hdnBoxEndX.value = endX - mapOffsetLeft;
	} 
	else 
	{
		document.forms["MapForm"].hdnBoxStartX.value = endX - mapOffsetLeft;
		document.forms["MapForm"].hdnBoxEndX.value = startX - mapOffsetLeft;
	}
	if (startY < endY) 
	{
		document.forms["MapForm"].hdnBoxStartY.value = startY - mapOffsetTop;
		document.forms["MapForm"].hdnBoxEndY.value = endY - mapOffsetTop;
	} 
	else 
	{
		document.forms["MapForm"].hdnBoxStartY.value = endY - mapOffsetTop;
		document.forms["MapForm"].hdnBoxEndY.value = startY - mapOffsetTop;
	}
		
	ZoomToBox();
}

function OnDragStart()
{
	event.returnValue = false;
}

// Summary: Restores the pan buttons to their original images when the mouse leaves the images
function hideMouseoverImage(x) 
{
	switch(x) 
	{
		case "n":
			document.all.ibtnPanN.src = "graphics/pan_n1.gif";
			document.all.ibtnPanNW.src = "graphics/pan_nw1.gif";
			document.all.ibtnPanNE.src = "graphics/pan_ne1.gif";
			break;
		case "s":
			document.all.ibtnPanS.src = "graphics/pan_s1.gif";
			document.all.ibtnPanSW.src = "graphics/pan_sw1.gif";
			document.all.ibtnPanSE.src = "graphics/pan_se1.gif";
			break;
		case "e":
			document.all.ibtnPanE.src = "graphics/pan_e1.gif";
			document.all.ibtnPanSE.src = "graphics/pan_se1.gif";
			document.all.ibtnPanNE.src = "graphics/pan_ne1.gif";
			break;
		case "w":
			document.all.ibtnPanW.src = "graphics/pan_w1.gif";
			document.all.ibtnPanNW.src = "graphics/pan_nw1.gif";
			document.all.ibtnPanSW.src = "graphics/pan_sw1.gif";
			break;
		case "nw":
			document.all.ibtnPanNW.src = "graphics/pan_nw1.gif";
			break;
		case "sw":
			document.all.ibtnPanSW.src = "graphics/pan_sw1.gif";
			break;
		case "ne":
			document.all.ibtnPanNE.src = "graphics/pan_ne1.gif";
			break;
		case "se":
			document.all.ibtnPanSE.src = "graphics/pan_se1.gif";
			break;
	}
}

// Summary: Changes the pan images whenever they are moused over
function showMouseoverImage(x) 
{
	switch(x) 
	{
		case "n":
			document.all.ibtnPanN.src = "graphics/pan_n2.gif";
			document.all.ibtnPanNW.src = "graphics/pan_nw3.gif";
			document.all.ibtnPanNE.src = "graphics/pan_ne3.gif";
			break;
		case "s":
			document.all.ibtnPanS.src = "graphics/pan_s2.gif";
			document.all.ibtnPanSW.src = "graphics/pan_sw3.gif";
			document.all.ibtnPanSE.src = "graphics/pan_se3.gif";
			break;
		case "e":
			document.all.ibtnPanE.src = "graphics/pan_e2.gif";
			document.all.ibtnPanNE.src = "graphics/pan_en3.gif";
			document.all.ibtnPanSE.src = "graphics/pan_es3.gif";
			break;
		case "w":
			document.all.ibtnPanW.src = "graphics/pan_w2.gif";
			document.all.ibtnPanNW.src = "graphics/pan_wn3.gif";
			document.all.ibtnPanSW.src = "graphics/pan_ws3.gif";
			break;
		case "nw":
			document.all.ibtnPanNW.src = "graphics/pan_nw2.gif";
			break;
		case "sw":
			document.all.ibtnPanSW.src = "graphics/pan_sw2.gif";
			break;
		case "ne":
			document.all.ibtnPanNE.src = "graphics/pan_ne2.gif";
			break;
		case "se":
			document.all.ibtnPanSE.src = "graphics/pan_se2.gif";
			break;
	}
}

// Summary: Handles the map image double click event and recenters the map to the point that was double clicked
function centerMap() 
{
	var myX = window.event.x;
	var myY = window.event.y;
	
	document.forms["MapForm"].hdnRecenterX.value = myX;
	document.forms["MapForm"].hdnRecenterY.value = myY;
	
	RecenterMap();
}

// Summary: Builds and displays the listing data table at the bottom of the MapWithAddress page for
//			the listing index passed in as the parameter
function showDetail(x) 
{
	var myTable;
	var myPOI;
	var newpoi = parseInt(document.forms["MapForm"].item("hdnNewPoi").value);
	
	if (newpoi == 0) 
	{
		myPOI = parseInt(x);
	}
	else 
	{
		myPOI = newpoi;
	}
	
	var myX = myPOI - 1;
	var mlnumber = "mlnumber_" + myPOI;
	var street = "street_" + myPOI;
	var city = "city_" + myPOI;
	var state = "state_" + myPOI;
	var zip = "zip_" + myPOI;
	var bedrooms = "bedrooms_" + myPOI;
	var bathrooms = "bathrooms_" + myPOI;
	var latitude = "latitude_" + myPOI;
	var longitude = "longitude_" + myPOI;
	var marketingremarks = "marketingremarks_" + myPOI;
	var propertytypedescription = "propertytypedescription_" + myPOI;
	var searchprice = "searchprice_" + myPOI;
	var squarefootage = "squarefootage_" + myPOI;
	var statusdescription = "statusdescription_" + myPOI;
	var thumbnailurl = "thumbnailurl_" + myPOI;
	var statuscolor = "statuscolor_" + myPOI;
	var areadescription = "areadescription_" + myPOI;
	var lotsquarefootage = "lotsquarefootage_" + myPOI;
	var thumbnailurl = "thumbnailurl_" + myPOI;
	var mapbookdisplay = "mapbookdisplay_" + myPOI;
	var mappageandcoordinates = "mappageandcoordinates_" + myPOI;
	var myMlNumber = document.forms["MapForm"].elements(mlnumber).value;   //A change is made for Safari(MAC): "item" was changed to "elements"
	var myStreet = document.forms["MapForm"].elements(street).value;
	var myCity = document.forms["MapForm"].elements(city).value;
	var myState = document.forms["MapForm"].elements(state).value;
	var myZip = document.forms["MapForm"].elements(zip).value;
	var myBedrooms = document.forms["MapForm"].elements(bedrooms).value;
	var myBathrooms = document.forms["MapForm"].elements(bathrooms).value;
	var myLatitude = document.forms["MapForm"].elements(latitude).value;
	var myLongitude = document.forms["MapForm"].elements(longitude).value;
	var myMarketingRemarks = document.forms["MapForm"].elements(marketingremarks).value;
	var myPropertyTypeDescription = document.forms["MapForm"].elements(propertytypedescription).value;
	var mySearchPrice = document.forms["MapForm"].elements(searchprice).value;
	var mySquareFootage = document.forms["MapForm"].elements(squarefootage).value;
	var myStatusDescription = document.forms["MapForm"].elements(statusdescription).value;
	var myStatusColor = document.forms["MapForm"].elements(statuscolor).value;
	var myAreaDescription = document.forms["MapForm"].elements(areadescription).value;
	var myLotSquareFootage = document.forms["MapForm"].elements(lotsquarefootage).value;
	var myThumbnailUrl = document.forms["MapForm"].elements(thumbnailurl).value;
	var myMapBookDisplay = document.forms["MapForm"].elements(mapbookdisplay).value;
	var myMapPageAndCoordinates = document.forms["MapForm"].elements(mappageandcoordinates).value;
		
	myTable =  "<table class='bgLightBlueBar' width='100%' height='150px'>";
	myTable += "<tr>";
	myTable += "<td width='25%' valign='middle' align='center' >";
	myTable += "<table cellpadding='0'; cellspacing='0';>";
	myTable += "<tr><td><img src='" + myThumbnailUrl + "'></td></tr>";
	//if ( intPictures > 1 ) {
	//	myTable += "<tr class='sBlackText'><td align='center'><a href='";
	//	myTable += myAdditionalPictures;
	//	myTable += "'>See Additional Pictures</a></td></tr>";
	//}
	myTable += "</table>";
	myTable += "<td valign='middle' align='left'>"
	//myTable += "<div id='ListingDetailTextDiv' align='center' valign='middle' width='100%'>
	myTable += "<table cellpadding='5' cellspacing='0' class='sBlackText'>";
	myTable += "<tr><td width='40%'><b>Listing # " + myMlNumber + "</b></td><td width='20%' align='left'><font color='" + myStatusColor + "'><b>" + myStatusDescription + "</b></font></td><td width='20%'><b>Price: </b>" + mySearchPrice + "</td><td nowrap><b>" + areaLabel + ": </b>" + myAreaDescription + "</td></tr>";
	myTable += "<tr><td><b>" + myStreet + "</b></td><td><b>Bedrooms: </b>" + myBedrooms + "</td><td><b>Square Footage: </b>" + mySquareFootage + "</td></tr>";
	myTable += "<tr><td><b>" + myCity + ",&nbsp;&nbsp;" + myState + "&nbsp;&nbsp;&nbsp;" + myZip + "</b></td><td><b>Bathrooms: </b>" + myBathrooms + "</td><td><b>Lot Size: </b>" + myLotSquareFootage + "</td></tr>";
	myTable += "<tr><td></td><td><b>Map Book:</b>&nbsp;" + myMapBookDisplay + "</td><td><b>Map Page:</b>&nbsp;" + myMapPageAndCoordinates + "</td></tr>";
	myTable += "<tr></tr>"
	myTable += "<tr></tr>"
	myTable += "<tr rowspan='5'><td colspan='3'>" + myMarketingRemarks + "</td></tr>";
	myTable += "</table></td>"
	myTable += "</table>";
	document.getElementById('ListingDetail').innerHTML = myTable;
	document.getElementById('ListingDetail').style.display = "block";
	
}

// Summary: Builds the map report url and directs the browser to that url
function MapReport()
{
	var mapReportUrl;
	var mapImage;
	
	mapReportUrl = document.forms[0].hdnMapReportUrl.value.replace( "&amp;", "" );
	mapImage = "&CurrentMap=" + escape( document.frames["mapFrame"].document.forms[0].hdnMapImageURL.value );
	
	 document.location = mapReportUrl + mapImage;	
	 //window.open(mapReportUrl + mapImage);
	
}

// Summary: Sets the selected table row's border styles 
// Parameters: 
//		rowIndex - The index of the row that needs the border styles to be set
//		borderStyle - The style string to be applied to the table cells' style.border attributes
// Requirements:
//		- The showDetail function
//		- All table cells to be set need to have their IDs set to td[rowIndex]_[cellIndex]
//		- A hidden input in forms[0] named selectedRowIndex
function SetBorderStyle( rowIndex, borderStyle )
{
	var cell;
	var counter;
	var cellsPerRow;
	
	// --- Determine how many cells are in the row --- |
	counter = 0;
	do
	{
		cell = document.getElementById( "td" + rowIndex + "_" + counter );
		if( cell )
		{
			counter++;
		}
		else
		{
			cellsPerRow = counter;
		}
	}while( cell )
	
	// --- Set the style for the cells --- |
	for( counter=0; counter<cellsPerRow; counter++ )
	{
		cell = document.getElementById( "td" + rowIndex + "_" + counter );
		
		// Determine if the left border needs to be set
		if( counter == 0 )
		{
			cell.style.borderLeft = borderStyle;
		}
		cell.style.borderBottom = borderStyle;
		cell.style.borderTop = borderStyle;
		// Determine if the right border needs to be set
		if( counter == cellsPerRow-1 )
		{
			cell.style.borderRight = borderStyle;
		}
	}
	
	document.forms[0].hdnNewPoi.value = rowIndex;
	showDetail( rowIndex );
}

// Summary: Sets the selected table row's border styles and 
//          undoes any previously selected table row's 
//			border styles
// Parameters: 
//		newRowIndex - The index of the row that needs the border styles to be set
// Requirements:
//		- The SetBorderStyle function
//		- A hidden input in forms[0] named selectedRowIndex
function SetBorderStyles( newRowIndex )
{
	var borderStyle = "solid 2px black";
	var oldRowIndex;
	
	oldRowIndex = document.forms[0].hdnNewPoi.value;
	
	if( oldRowIndex != "0" )
	{
		SetBorderStyle( oldRowIndex, "" );
	}
	
	SetBorderStyle( newRowIndex, borderStyle );
}

//Browser detection for public mapped listings display
function detectIE()
{
	var browser=navigator.appName;
	
	if(browser != "Microsoft Internet Explorer")
	{				
	document.getElementById('tdMapReport').style.display='none';
	document.getElementById('CloseBtn').style.display='none';
	}
}
