 // global variables


if (window.Event && document.captureEvents !=undefined) document.captureEvents(Event.MOUSEMOVE);

var pixelsLat = new Array();
var pixelsLng = new Array();


pixelsLat["7"] = '0.007935939296047181';
pixelsLng["7"] = '0.010986328125';
pixelsLat["8"] = '0.00396791367726172';
pixelsLng["8"] = '0.005493164062499986';
pixelsLat["9"] = '0.0019840476643974013';
pixelsLng["9"] = '0.00274658203125';
pixelsLat["10"] = '0.0009920105074774526';
pixelsLng["10"] = '0.001373291015625';
pixelsLat["11"] = '0.0004960097527921973';
pixelsLng["11"] = '0.0006866455078124716';
pixelsLat["12"] = '0.0002480038973327865';
pixelsLng["12"] = '0.00034332275390625';
pixelsLat["13"] = '0.00012400195473554731';
pixelsLng["13"] = '0.000171661376953125';
pixelsLat["14"] = '0.00006200097812639882';
pixelsLng["14"] = '0.0000858306884765625';
pixelsLat["15"] = '0.000031000505214827';
pixelsLng["15"] = '0.00004291534423828125';
pixelsLat["16"] = '0.00001550024860507193';
pixelsLng["16"] = '0.000021457672119140625';
pixelsLat["17"] = '0.000007750124304010341';
pixelsLng["17"] = '0.000010728836059556101';
pixelsLat["18"] = '0.0000038750621522041225';
pixelsLng["18"] = '0.000005364418029770946';
var bringingupbox = false;
var currentResultsInRadius=0;
var doubleclick=false;
var moving=false;
var b=navigator.userAgent.toLowerCase();
var ie = ((b.indexOf("msie") != -1));

var lastPhotoHighlighted=0;
var zoom = null;
var zoom2 = null;
var map = null;
var map2 = null;
var onMap = 0;
var onMapNos = new Array();
var loading = false;
var geocoder = null;
var mouseX=0;
var mouseY=0;
var layerY=0;
var viewableBox = null;
var listpins = new Array();

// should be defined in client website as an include

var ext = "png";
var lat = "";
var lng = "";
var debugSize=0;

var zoomTranslate = new Array();
zoomTranslate[20] = 1;
zoomTranslate[19] = 2;
zoomTranslate[18] = 2;
zoomTranslate[17] = 4;
zoomTranslate[16] = 5;
zoomTranslate[15] = 6;
zoomTranslate[14] = 7;
zoomTranslate[13] = 8;
zoomTranslate[12] = 9;
zoomTranslate[11] = 10;
zoomTranslate[10] = 11;
zoomTranslate[9] = 12;
zoomTranslate[8] = 13;
zoomTranslate[7] = 14;
zoomTranslate[6] = 15;
zoomTranslate[5] = 16;
zoomTranslate[4] = 17;
zoomTranslate[3] = 18;
zoomTranslate[2] = 19;
zoomTranslate[1] = 20;

zoomTranslate[16] = 1;
zoomTranslate[15] = 2;
zoomTranslate[14] = 3;
zoomTranslate[13] = 4;
zoomTranslate[12] = 5;
zoomTranslate[11] = 6;
zoomTranslate[10] = 7;
zoomTranslate[9] = 8;
zoomTranslate[8] = 9;
zoomTranslate[7] = 10;
zoomTranslate[6] = 11;
zoomTranslate[5] = 12;
zoomTranslate[4] = 13;
zoomTranslate[3] = 14;
zoomTranslate[2] = 15;
zoomTranslate[1] = 16;

// *********************************************
/*
Class: SETTINGS
Topic:deCarta_WAI_API

*/

function myMouseOut(e)
{
	document.getElementById("rolloverdiv").style.display='none';
	return true;
}

function myMouseOver(e)
{
	if (!e.elementID) return;
	var bits=e.elementID.split("_");
	bits.pop();
	e.elementID = bits.join("_");
	
	for (i in mapmanager.pins)
	{
		if (mapmanager.pins[i].shapeID==e.elementID)
		{
			var labelSize = mapmanager.pins[i].label.split(",").length;
			var center = map.LatLongToPixel (new VELatLong (mapmanager.pins[i].lat, mapmanager.pins[i].lng));
			if (settings.rolloverType=="numbers" && labelSize>1)
			layermanager.setDivContent("rolloverdiv",labelSize + " " + settings.showInfo[mapmanager.pins[i].set]["plural"]); //"<br>"));
			if (settings.rolloverType=="address" || labelSize==1)
			layermanager.setDivContent("rolloverdiv",mapmanager.pins[i].label.replaceAll(",",settings.rolloverSeparator).replaceAll(":",", "));
			document.getElementById("rolloverdiv").style.top=(map.GetTop() + center.y+settings.offsetY)+"px";
			document.getElementById("rolloverdiv").style.left=(map.GetLeft() + center.x+settings.offsetX)+"px";
			document.getElementById("rolloverdiv").style.display='block';
		}
	}
	return true;
}

function ShapeHandler(e)
{
	if (!e.elementID) return;
	var bits=e.elementID.split("_");
	bits.pop();
	e.elementID = bits.join("_");
	
	for (i in mapmanager.pins)
	{
		if (mapmanager.pins[i].shapeID==e.elementID)
		{
		var b = settings.box; //document.getElementById("boxside") ? "boxside" : "boxover";
//		alert ("box="+b);
      if( mapmanager.pins[i].set != "restaurants" && mapmanager.pins[i].set != "schools" && mapmanager.pins[i].set != "pubs" ) {
        layermanager.bringUpBox2(mapmanager.pins[i].id, mapmanager.pins[i].type,mapmanager.pins[i].set, b);
      } else if( mapmanager.pins[i].set == "schools" ) {
        window.open(mapmanager.pins[i].url, null, "new_win"+i);
      }
		}
	}
}

function debug (txt)
{
	document.getElementById('debug_div').innerHTML = txt;
}

function SETTINGS ()//lat, lng, zoom, highlight)
{
	this.offsetY=100;
	this.offsetX=-100;
	this.box="boxside";
	this.col1=0;
	this.col2=0;
	this.col3=0;
	this.fixRolloverX=0;
	this.fixRolloverY=0;
	this.alterUrlLocation=false;
	this.rolloverSeparator = "<br>";
	this.rolloverType = "address";
	this.addtolist_0 = "property NOT added";
	this.addtolist_1 = "property added";
	this.addtolist_2 = "property already added";
	this.jumptoproperty = false;

	this.removetolist_0 = "property NOT removed";
	this.removetolist_1 = "property removed";
	this.scaleGraphic = "img/scaleline.gif";
	this.mirrorRadius=false;
	this.rolloverUrl=false;
	this.ids = param("ids");
	this.infodiv=false;
	this.url_thumbnails="getImage.php";
	this.FYI="";
	this.tooHighText="Your currently too high up to view these on map";
	this.showOverview=true;
	this.newPos=false;
	this.poiNumber=true;
        this.poiList=false;
	this.panning=false;
	this.alternateNumberDiv="";
	this.tooHighIndicator="";

	this.directionsText = "Click a start point on the map;<br>Continue clicking the left mouse button with all points you want. <br><b>Right clicking will bring up the directions</b>";
	this.storeClickIds=true;
	this.bubblestyle="bubble";
	this.recordRightClick=true;
	this.townsinview = false;
	this.noload = false;

	this.mirrordivs = new Array();
	this.listview_text = "see in list";
	this.trackinform = new Array();
	this.trackinformtype = new Array();
	this.trackinformname = "aspnetForm";
	this.padding=60;
        this.map_height = 200;
        this.map_width = 200; 
	this.showScale=true;
	this.statusPrefix = "";// &nbsp;";
	this.multiplier = new Array(0,1,1,1,1,1,1,1,1,3,3,10,12,14,15,17,18);

	this.showInfo = new Array();
	this.fullUrls = new Array();
	this.minZoom=3;
	this.maxZoom=8;
	this.copyright = " ";//<img src='images/rocketmaplogo.jpg'>";
	this.type = param("type");
	this.radius = param("radius") ? param("radius") : 0;
	this.configuration = "glossy-TELEATLAS-tile";
	this.maptype = param("maptype") ? param("maptype") : "STREET";
	this.transparentconfiguration = "transparent-tile-eur";
	this.lng = param("lng") ? param("lng").replace ("-00.","-0.") : "0";
	this.lat = param("lat") ? param("lat") : "51";
	if (!param("z") && param("radius"))
	{
	//alert ("no z");
	if (param("radius") == "0.25") this.zoomlevel = 6;
	if (param("radius") == "0.5") this.zoomlevel = 7;
	if (param("radius") == "0.75") this.zoomlevel = 7;
	if (param("radius") == "1") this.zoomlevel = 8;
	if (param("radius") == "5") this.zoomlevel = 10;
	if (param("radius") == "10") this.zoomlevel = 11;
	if (param("radius") == "25") this.zoomlevel = 12;
	if (param("radius") == "40") this.zoomlevel = 13;
	if (param("radius") == "50") this.zoomlevel = 13;
	}
	else
	this.zoomlevel = 1 * param("z");

	this.highlight = param("highlight");
	this.url_mapdata = "populate_map.php";
	this.url_boxover = "populate_map.php";
	this.url_boxside = "populate_map.php";
	this.url_fitmapdata = "/staging2/xml/fit_map.php";
	this.url_slideshow = "../slideshow/";
	this.url_listview = "../search/";
	this.url_mapview = "../mapping/";
	this.url_thumbnailview = "../thumbnails/";
	this.div_fulldetails = false;
	this.proxy = "/proxy/";
	this.set_to_count = "properties";
	this.icon_height=44;
	this.icon_width=49;

	this.trackimage=false;
	this.photomax = 20;
        this.photoshowmax = 2;
        this.photodistance = 107;
        this.photoheight = 75;
        this.photowidth = 100;
        this.photomove=200;
        this.photoenablemove=1;
        this.photoleft=30;
        this.photomoveincrement=20;
        this.photodisplaywidth=600;
        this.photodisplaycenter=150;
}

/*
Function: modify
elegant way of altering any field within the object
Parameters:
	field - field name
	value - value to set
*/
SETTINGS.prototype.modify = function (field,value) { if (""+typeof(value)!="string") eval ("this."+field+"="+value); else eval ("this."+field+"='"+value+"'") }

SETTINGS.prototype.addArray = function (field,value) { eval ("this."+field+"[this."+field+".length]='"+value+"'")};

var settings = new SETTINGS(); 

function createNewDiv (name, background, pos, top, left, height,width,innerhtml, zindex)
{
	var nd = document.createElement(name);
	nd.style.top = top + "px";
	nd.style.left = left + "px";
	nd.style.height = height + "px";
	nd.style.width = width + "px";
	nd.style.background = "url("+background+")";
	nd.style.position = pos;
	nd.innerHTML = innerhtml;
	nd.style.zIndex = zindex;
	return nd;
	
}

function SLIDER(name, objName, divGraphic, top,left, width, height, pos, backgroundGraphic, sTop,sLeft, sWidth, sHeight, cName, cursorGraphic, cursorGraphicOn, cWidth, cHeight, cLeft, levels,  tops, zoomIn, zoomOut, blankGif)
{
	this.levels = levels;
	this.tops = tops;
	this.div = name;
	this.objName = objName;
	this.cursorName = cName;
	this.cursorOn = cursorGraphicOn;
	this.cursorHeight=Math.ceil(cHeight/2);
	this.ref = document.getElementById(this.div);
	this.ref.style.top = top + "px";
	this.sTop = sTop;
	this.dTop = top;
	this.ref.style.left = left + "px";
	this.ref.style.width = width + "px";
	/*this.ref.style.background = "url("+divGraphic+")";*/
	this.ref.style.height = height + "px";
	this.ref.style.position = pos;
	this.ref.style.zIndex = 500;
	this.slider = document.createElement("SLIDECONTAINER");
	/*this.slider.style.background = "url("+backgroundGraphic+")";*/
	this.slider.style.padding = "0px 0px 0px 0px";
  	this.slider.style.position="absolute";
	this.scrollHeight = sHeight;
	this.pixelsPerLevel = Math.abs(1*sHeight/1*levels.length);
  	this.slider.style.height=sHeight+"px";
  	this.slider.style.width=sWidth+"px";
//	this.slider.onclick=this.click();
  	this.slider.style.top=sTop+"px";
  	this.slider.style.left=sLeft+"px";
  	this.slider.style.zIndex=600;
  	this.ref.appendChild(this.slider);

  	this.ref.appendChild(zoomIn);
  	this.ref.appendChild(zoomOut);
	this.sliderHeight = sHeight;

	this.divider = Math.abs (1*sHeight/(levels.length+1));

	this.slider.innerHTML= "<div id='barsBackground' style='overflow:hidden;height:"+sHeight+";'><img src='"+backgroundGraphic+"'></div><div id=\""+cName+"\" style='background:url("+cursorGraphic+") no-repeat;z-index:400;padding:0px 0px 0px 0px;position:absolute;top:0px;left:"+cLeft+"px;backgroundcolor:blue;height:"+cHeight+"px;width:"+cWidth+"px' onmouseover=\"document.getElementById('"+cName+"').style.background='url("+this.cursorOn+") no-repeat'\" onmouseout=\"document.getElementById('"+cName+"').style.background='url("+cursorGraphic+") no-repeat'\" onmousedown=\""+this.objName+".dragInit (event)\"></div><div id=\"bl\" style='position:absolute; top:0px; left:0px; height:"+sHeight+"px;width:"+sWidth+"px;z-index:399;' onclick='"+objName+".click(event)'></div><div id='sliderBackground'><img id='sliderBackgroundImg' src='"+divGraphic+"'></div>";
	this.cTop = 0;
	this.cLeft = 0;
	this.cursor = document.getElementById(cName);	
	this.highlightLevel(settings.zoomlevel);
	
}

SLIDER.prototype.highlightLevel = function (level) 
{
	var c=0;
	var lastlevel = 0;
	for(i in this.levels)
	{
		if (this.levels[i]>=level)
		{
		//	this.cursor.style.top = (this.divider*(c+1) - this.cursorHeight)+"px";
			this.cursor.style.top = this.tops[i] + "px";
			settings.zoomlevel = this.levels[i];
			if (zoom)
			{
		//	alert (settings.zoomlevel + " " + map.getZoomController().getZoomLevel());
			}
			// here
			return;
		}
		c++;
		lastlevel=i;
	}
	this.cursor.style.top = slider.tops[lastlevel] + "px";
	settings.zoomlevel = slider.levels[lastlevel];
	if (!zoom) return; //alert ('no zoom');

//	alert ('no level found for ' + i + " "  + level);
}

SLIDER.prototype.zoomOut = function () 
{
	settings.zoomlevel2 = settings.zoomlevel;
	var c=0;
	for(i=0; i<this.levels.length; i++)
	{
		if (this.levels[i]==settings.zoomlevel2)
		{
			
			if (c<this.levels.length-1)
			{	
			this.highlightLevel (this.levels[c+1]);
			map.SetZoomLevel (21-this.levels[c+1]);
			if (settings.mirrorRadius) this.mirrorRadius(this.levels[c+1]);
			return;
			}
		}
		c++;
	}
}

SLIDER.prototype.mirrorRadius = function (level)
{
	var setvalue=1;
	if (level == "8") setvalue = 1;
        if (level == "10") setvalue = 5;
        if (level == "11") setvalue = 10;
        if (level == "12") setvalue = 25;
        if (level == "13") setvalue = 40;
        if (level == "14") setvalue = 50;
	
	document.forms.aspnetForm.MRadiusRad.value = setvalue;
	document.forms.aspnetForm.Mradius.value = setvalue;
	settings.radius = setvalue;
	if (document.getElementById("bigMapOverlay"))
	document.getElementById("bigMapOverlay").src = "../images/mapoverlay"+setvalue+"miles.png";
	document.getElementById("RadiusRad").style.background='#d2d6c1';
	setTimeout ("document.getElementById('RadiusRad').style.background='white'",2000);
}

SLIDER.prototype.zoomIn = function () 
{
	settings.zoomlevel2 = settings.zoomlevel;
	var c=0;
	for(i=0; i<this.levels.length; i++)
	{
		if (this.levels[i]==settings.zoomlevel2)
		{
			if (c>0)
			{	
			this.highlightLevel (this.levels[c-1]);
			map.SetZoomLevel (21-this.levels[c-1]);
			if (settings.mirrorRadius) this.mirrorRadius(this.levels[c-1]);
			return;
			}
		}
		c++;
	}
}

SLIDER.prototype.click = function (event) 
{
	if (!window.event && !event) return; 
	this.y = getY(event); 

	var pos = this.y - this.dTop - this.sTop; 
	var which = (pos/this.divider);

	if (which%1>0.5) which = Math.ceil(which);
	else which = Math.floor(which);
	if (which==0) which = 1;

	if (which>this.levels.length) which = this.levels.length;
//	this.cursor.style.top = ((which * this.divider) - this.cursorHeight) + "px";

	which--;

	this.cursor.style.top = this.tops[which] + "px";
	map.SetZoomLevel (zoomTranslate[this.levels[which]]);
	if (settings.mirrorRadius) this.mirrorRadius(this.levels[which]);

}

SLIDER.prototype.dragInit = function (event) 
{ 
	if (!window.event && !event) return; 
	this.x = getX(event); 
	this.y = getY(event); 
	this.cLeft = this.x ? this.x : 0; 
	this.cTop = this.y ? this.y : 0; 

	this.oLeft = this.x;
	this.oTop = this.y;

	this.startLeft = parseInt(this.cursor.style.left, 10); 
	this.startTop   = parseInt(this.cursor.style.top,  10); 
	if (isNaN(this.startLeft)) this.startLeft = 0; 
	if (isNaN(this.startTop))  this.startTop  = 0; 
	if (window.event) 
	{ 
		document.attachEvent("onmousemove", startDrag); 
		document.attachEvent("onmouseup",   endDrag); 
		window.event.cancelBubble = true; 
		window.event.returnValue = false; 
	} 
	else 
	{ 
		document.addEventListener("mousemove", startDrag,   true); 
		document.addEventListener("mouseup",   endDrag, true); 
		event.preventDefault(); 
	} 
}

function startDrag(Event) { slider.dragStart(Event); }
function endDrag(Event) { slider.dragStop(Event); }

SLIDER.prototype.dragStart = function (event)
{
	this.x = getX(event); this.y = getY(event); 
	
	this.cursor.style.top  = (this.startTop  + this.y - this.oTop) + "px"; 
	if (1*this.cursor.style.top.replace("px","")<0) this.cursor.style.top = "0px";
	if (1*this.cursor.style.top.replace("px","")>this.sliderHeight) this.cursor.style.top = this.sliderHeight+"px";
	if (window.event){ window.event.cancelBubble = true; window.event.returnValue = false; } else event.preventDefault();
}

SLIDER.prototype.dragStop = function (event)
{
	var pos = this.cursor.style.top.replace("px",""); 
	var which = (pos/this.divider);

	if (which%1>0.5) which = Math.ceil(which);
	else which = Math.floor(which);
	if (which==0) which = 1;

	if (which>this.levels.length) which = this.levels.length;
//	this.cursor.style.top = ((which * this.divider) - this.cursorHeight) + "px";
	which--;

	this.cursor.style.top = this.tops[which] + "px";

	map.SetZoomLevel (this.levels[which]);
	settings.zoomlevel = this.levels[which];
	if (settings.mirrorRadius) this.mirrorRadius(this.levels[which]);

	if (window.event) 
	{ 
		document.detachEvent("onmousemove", startDrag); 
		document.detachEvent("onmouseup",   endDrag); 
	} 
	else 
	{ 
		document.removeEventListener("mousemove", startDrag, true); 
		document.removeEventListener("mouseup",   endDrag, true); 
	} 
	return;

	//alert (pos/this.divider);
}

var dO = new Object();
dO.zIndex = 0;

function COOKIES ()
{
}

String.prototype.replaceAll = function( 
strTarget, // The substring you want to replace
strSubString // The string you want to replace in.
){
var strText = this;
var intIndexOfMatch = strText.indexOf( strTarget );
 

// Keep looping while an instance of the target string
// still exists in the string.
while (intIndexOfMatch != -1){
// Relace out the current instance.
strText = strText.replace( strTarget, strSubString )
 

// Get the index of any next matching substring.
intIndexOfMatch = strText.indexOf( strTarget );
}
 

// Return the updated string with ALL the target strings
// replaced out with the new substring.
return( strText );
}


// *********************************************
/*
Class: PIN

*/
function PIN(id,lat,lng,kd,marker,type,image,set,label, inradius) { this.id=id; this.icon = null; this.display=true; this.label = label; this.pin = null; this.image = image; this.click=null; this.mouseover=null; this.lat=lat; this.lng=lng; this.kd=marker; this.type=type; this.latlng=(1*lat) + " " + (1*lng); this.set=set; this.inradius=inradius; }

// *********************************************
/*
Class: MAPBOUNDARY
*/
function MAPBOUNDARY () { this.tLLat = 0; this.tLLng = 0; this.bRLat = 0; this.bRLng = 0; }

/*
Function: flatten
flattens the boundary box and returns as a string
*/

MAPBOUNDARY.prototype.flatten = function () { return "&y1="+this.tLLat+"&x1="+this.tLLng+"&y2="+this.bRLat+"&x2="+this.bRLng; }

var mapboundary = new MAPBOUNDARY();

// *****************************************************************************************************************
/*
class: REQUESTMANAGER
*/
function REQUESTMANAGER() { this.div = ""; if(window.XMLHttpRequest) this.r = new XMLHttpRequest(); else if (window.ActiveXObject) try { this.r= new ActiveXObject("Msxml.XMLHTTP"); } catch(e) { this.r= new ActiveXObject("Microsoft.XMLHTTP"); } }

REQUESTMANAGER.prototype.handleFitMap = function () { 
if (this.r.readyState == 4) 
{ 
	var temp = new Array(); 


	if (settings.text_plot)
        //layermanager.setDivContent('loadinginnerdiv',settings.text_plot);
		showHideImg('text_load','text_process','text_plot');
        else
	{
	layermanager.setDivContent('loadinginnerdiv',' &nbsp; plotting...<div id="counter" style="display:inline"></div>'); 
	layermanager.startCounter(1); 
	}

	var rD = this.r.responseXML; 
	if (rD) 
	if (rD.documentElement) { 

                        for (i in settings.showInfo)
                        {
                                settings.showInfo[i]["hidetotal"]=0;
te = rD.documentElement.getElementsByTagName('p'); var minLat = 300; var minLng = 300; var maxLat = -300; var maxLng = -300; 
for (var i=0; i<te.length; i++) 
{ 
	temp.push( new VELatLong (te[i].getAttribute('lat'), te[i].getAttribute('lng'))); 
	if (te[i].getAttribute('lat')<minLat) minLat = te[i].getAttribute('lat'); 	if (te[i].getAttribute('lat')>maxLat) maxLat = te[i].getAttribute('lat'); 
	if (te[i].getAttribute('lng')<minLng) minLng = te[i].getAttribute('lng'); 	if (te[i].getAttribute('lng')>maxLng) maxLng = te[i].getAttribute('lng'); 
} 
}

var lat = ((maxLat - minLat)/2) + 1*minLat; 
var lng = ((minLng - maxLng)/2) + 1*maxLng; 
//var bb = new BoundingBox (new VELatLong (maxLat,maxLng), new VELatLong (minLat,minLng));
//alert (bb);
//alert (zoom.getZoomLevelToFitBoundingBox(bb));
settings.zoomlevel=getZoomLevelToFitPositions(temp); 
if (1*settings.zoomlevel>1*slider.levels[slider.levels.length-1])
{
	settings.zoomlevel = slider.levels[slider.levels.length-1];
}
slider.highlightLevel(settings.zoomlevel);
if (settings.mirrorRadius) slider.mirrorRadius(settings.zoomlevel);
//alert (settings.zoomlevel);
//map.SetZoomLevel(settings.zoomlevel);
//map.SetCenter (new VELatLong(lat,lng)); 
//alert (settings.zoomlevel);
map.LoadMap(new VELatLong(lat, lng), 21-settings.zoomlevel ,'r' ,false);
var shape = new VEShape(VEShapeType.Polygon, [new VELatLong(60,-7),
                                                   new VELatLong(60,5),
                                                   new VELatLong(40,5),
                                                   new VELatLong(40,-7)]);
var fillColor = new VEColor(settings.col1,settings.col2,settings.col3,0.3);

shape.SetFillColor(fillColor);
shape.SetLineColor(fillColor);
map.AddShape(shape);
shape.HideIcon();
if(!settings.showdashboard)
	map.HideDashboard();
map.AttachEvent("onclick",ShapeHandler);
map.AttachEvent("ondoubleclick", cdc);
map.AttachEvent("onmousewheel", cdc);
map.AttachEvent("onendpan",populateTimed);
map.AttachEvent("onendzoom",populateTimed);
map.AttachEvent("onmouseover",myMouseOver);
map.AttachEvent("onmouseout",myMouseOut);

//alert (lat+" "+lng);
setTimeout("mapmanager.doZoom2()",1000);


//alert (map.getZoomController().getZoomLevel());

//settings.pin1 = new Pin (new VELatLong (maxLat,maxLng), "y",null,null)
//settings.pin2 = new Pin (new VELatLong (minLat,minLng), "x",null,null);
document.getElementById("map").style.display='block';
settings.FYI=te.length + " from list on map";
} 
else {}} // layermanager.setDivContent('loadinginnerdiv',' &nbsp;data error 2'); setTimeout ("mapmanager.redoMap()",5000); } } 

}


/*
function: doRequest
handles the request to a url

Parameters: 
	func - function for callback
	url - url for request
*/
REQUESTMANAGER.prototype.doRequest = function (func,url) {  
if (this.r) {this.r.abort();} this.r.open ("GET", url,"true"); 


this.r.onreadystatechange = function () {eval ("mapmanager.requestmanager."+func+"()"); };  
try { this.r.send(null); } catch (e) { alert (e); }
}

function showImg(img,div) {document.getElementById(img).style.visibility = 'visible';document.getElementById(div).style.zIndex=499;}
function showHideImg(id1,id2,id3) {document.getElementById(id1).style.visibility='hidden';document.getElementById(id2).style.visibility='hidden';document.getElementById(id3).style.visibility='visible';}

REQUESTMANAGER.prototype.handleHTMLRequest = function () { if (this.r.readyState == 4) {layermanager.setDivContent(this.div, this.r.responseText); bringingupbox=false; if (this.div=="rolloverdiv") { clearTimeout(layermanager.timer); layermanager.timer= setTimeout("layermanager.divStatus('rolloverdiv','none')",5000); } if (this.div=='boxover'){showImg(settings.url_boxover_img_id,settings.url_boxover_img_div);this.div='';}  } }
//REQUESTMANAGER.prototype.handleHTMLRequest = function () { if (this.r.readyState == 4) { layermanager.setDivContent(this.div, this.r.responseText); bringingupbox=false; if (this.div=="rolloverdiv") { clearTimeout(layermanager.timer); layermanager.timer= setTimeout("layermanager.divStatus('rolloverdiv','none')",5000); }  } }

/* 
function: handleRequest
one fo the callbacks which populates icons
*/
REQUESTMANAGER.prototype.handleRequest = function ()
{

        if (this.r.readyState == 4)
        {
		for (i in settings.showInfo) 
		{
		if (settings.poiNumber==true) settings.showInfo[i]["nos"]=0;
		if (settings.poiList==true) layermanager.setDivContent("list"+i,"");
		}


	if (settings.text_process)
	{
		showHideImg('text_plot','text_load','text_process');
		//layermanager.setDivContent('loadinginnerdiv',settings.text_process);
	}
	else
	{
		layermanager.setDivContent('loadinginnerdiv',' &nbsp; requesting data...<div id="counter" style="display:inline"></div>');
		layermanager.startCounter(1);
	}
                var rD = this.r.responseXML;
               
		if (rD)
		{
                if (rD.documentElement)
                {
			
			var ts = rD.documentElement.getElementsByTagName('total');
		currentResultsInRadius = ts[0].getAttribute("withinradius");
		
    //doZoom( 21 - parseInt(param("zoom")) );
    
		if(document.getElementById('resultsNum'))
		  document.getElementById('resultsNum').innerHTML = currentResultsInRadius;
      
    
		
		if (ts[0].getAttribute("count") && document.getElementById("toohighwarning"))
		document.getElementById("toohighwarning").style.display='block';
		else if (document.getElementById("toohighwarning"))
		document.getElementById("toohighwarning").style.display='none';
		
		if (settings.tooHighIndicator!="")
		{
			function setIndicator(id, val)
			{
				if (val!=null)
				document.getElementById(id+"_indicator").innerHTML=settings.tooHighIndicator;
				else
				document.getElementById(id+"_indicator").innerHTML="";

			}

			setIndicator ("schools", ts[0].getAttribute("schoolstoohigh"));
			setIndicator ("trains", ts[0].getAttribute("trainstoohigh"));
			
		}
		if (settings.alternateNumberDiv)
		{
		layermanager.setDivContent(settings.alternateNumberDiv,ts[0].getAttribute("withinradius"));
		}
 			for (i in settings.showInfo)
        		{
				settings.showInfo[i]["hidetotal"]=0;
				if (ts[0].getAttribute(i+"toohigh")!=null)
				settings.showInfo[i]["hidetotal"] = ts[0].getAttribute(i+"toohigh");
				if (ts[0].getAttribute(i)!=null)
				settings.showInfo[i]["nos"] = ts[0].getAttribute(i);
			}
			mapmanager.loadElement (rD);

			 var n = 0;
                        for (i=0; i<settings.mirrordivs.length; i++)
                        {
                                n = ts[0].getAttribute(settings.mirrordivs[i]);
                                if (!n) n = 0;

                                layermanager.setDivContent("numbers_"+settings.mirrordivs[i], n);
                        }

                        pt = window.setTimeout("mapmanager.plot()", 100);
                        
                        
                        
                }
		}
		else
		{
			  layermanager.divStatus ('loadingdiv','none');
      
			//setTimeout ("mapmanager.populate()",2000);
		}
        }
	doubleclick=false;
}

// *********************************************
/*
Class: MAPMANAGER
handles functions which deal with deCarta's MAP object
one instance - *mapmanager*
*/
function MAPMANAGER()
{
this.pagecurrent=1;
this.pagetotal=1;
this.pagepagination=false;
this.pageper=10;
this.pagestart=1;
this.pagestop=10000;

this.tips=new Array("right click to do reverse-geocode","click on the arrows on left to expand options","interactive directions allows you to use waypoints","the map will scale to the size of the page","if you cluster icons you will be able to navigate through them");
this.highlightInstance = null;
this.highlightId = null;
this.highlightI=null;
this.doPopulate=true;
this.icons = null;
this.iconmanager = null;
this.requestmanager = new REQUESTMANAGER();
this.pins2 = new Array();
this.pins = new Array();
this.p = 0;
}

MAPMANAGER.prototype.loadCookies = function (c)
{
//	debug ("GET COOKIE - " + getcookie("gmap"));
        var bits = getcookie("gmap").split ("&");
        var bits2 = null;

        for (var i=1; i<bits.length; i++)
        {
                bits2=bits[i].split("-");

                if (param(bits2[0]))
                bits2[1] = param(bits2[0]);

                if (bits2[1]=="true")
                eval ("document.forms."+settings.trackinformname+".M"+bits2[0]+".checked=true");
		
                else if (bits2[1]=="false")
                eval ("document.forms."+settings.trackinformname+".M"+bits2[0]+".checked=false");
                else if (bits2[1])
                {
                eval ("document.forms."+settings.trackinformname+".M"+bits2[0]+".value=\""+bits2[1]+"\"");
        //      alert (eval("document.forms."+settings.trackinformname+"."+bits2[0]+".value"));
                }
        }
}

MAPMANAGER.prototype.updateCookies = function (c)
{
        setcookie ("gmap",c,365);
}


MAPMANAGER.prototype.viewInList = function ()
{
	var url = settings.url_viewinlist + "?z="+settings.zoomlevel+"&type="+settings.type+ mapboundary.flatten() + this.formTracker(0) + "&onlyids="  + settings.ids + "&a=list_view";
	document.location=url;

}

MAPMANAGER.prototype.fitMap = function ()
{
	url = settings.url_fitmapdata + "?type="+settings.type+"&ids=" + param("ids");
//	window.open (url);

	if (param("minLat") && param("minLng"))
	{
		var maxLat = param("maxLat");
		var minLat = param("minLat");
		var maxLng = param("maxLng");
		var minLng = param("minLng");

		var bb = new BoundingBox (new VELatLong (param("maxLat"),param("maxLng")), new VELatLong (param("minLat"),param("minLng")));
		settings.zoomlevel = zoom.getZoomLevelToFitBoundingBox(bb);

		var lat = ((maxLat - minLat)/2) + 1*minLat;
		var lng = ((minLng - maxLng)/2) + 1*maxLng;
		map.centerOnPosition (new VELatLong(lat,lng));
	}	
	mapmanager.requestmanager.doRequest ("handleFitMap",url);
}

LAYERMANAGER.prototype.movePhoto = function(plusminus,increments,moveby) {

        if (plusminus=="+" && this.photoleft==settings.photoleft) return;

        DHTML = (document.getElementById || document.all || document.layers)
        if (!DHTML) return;
        var x = document.getElementById('photocontainer');

        if (plusminus=="-" && -1*this.photoleft+moveby>this.photol) return;

        if (this.photoleft>settings.photoleft)
        {
                this.photoleft=settings.photoleft;//setting.photoleft;
                increments=0;
                moveby=0;
        }

        if (plusminus!="0")
        eval ("this.photoleft"+plusminus+"=1*increments");

        document.getElementById("photocontainer").style.left=this.photoleft + "px";

        var left = -1*this.photoleft + (settings.photoleft);
        var right = settings.photodisplaywidth + (-1*this.photoleft);

//      alert (document.getElementById("photocontainer").style.top);

        if (document.layers)
        {
                x.style.clip.left = left;
                x.style.clip.right = right;
        }
        else if (document.getElementById || document.all)
        {
                if (left>0)
                left+="px";
                x.style.clip = ("rect(0 "+right+"px "+settings.photoheight+"px "+left+")");
        }

        if (increments<moveby && moveby)
        this.phototimer = setTimeout("layermanager.movePhoto('"+plusminus+"',"+(increments)+","+moveby+")",40);

}


LAYERMANAGER.prototype.layerAtCurrentLocation = function (thediv,msg) { layermanager.moveDiv (thediv); layermanager.setDivContent (thediv,msg); layermanager.divStatus (thediv,'block'); setTimeout ("layermanager.divStatus('"+thediv+"','none')",2000); }

MAPMANAGER.prototype.randomTips = function ()
{
	var ran_number= Math.floor(Math.random()*this.tips.length-1)+1;	
	return this.tips[ran_number];

}

MAPMANAGER.prototype.openIcon = function (id) { mapmanager.showInfoWindow(this.pins[id].pin); }

MAPMANAGER.prototype.customBubble =function (background,closei,b_height,b_width, c_top, c_left, o_top, o_left)
{
return;
var myInfoBubble = document.createElement("DIV");
  myInfoBubble.style.width=b_width+"px";
  myInfoBubble.style.height=b_height+"px";
  var img = document.createElement("img");
  img.src=background;
  img.style.position="absolute";
  img.style.top="0px";
  img.style.left="0px";
  // make it transparent in IE
/*
  if(Utilities.ie6){
    img.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled='true',"+
    "src='/rocketmap/img/info.png')";
    img.src = "/rocketmap/img/x.gif";
  }
*/
  img.style.zIndex=1;

  // add to DIV
  myInfoBubble.appendChild(img);
  myInfoBubble.style.position="absolute";
  myInfoBubble.style.zIndex=200;
  myInfoBubble.style.display="none";

  // create Objects and add to Map
  //var closeButton = new Icon(closei,c_left,c_top,19,19);
 // var infoWindow = new InfoWindow(myInfoBubble,o_left,o_top,closeButton);
if (!map) return; //alert ("no map");
  //map.addCustomInfoWindow(infoWindow);
}


MAPMANAGER.prototype.scaleGraphic = function ()
{
return;
	var gxzoom = zoom.getGXConvertedZoomLevel();
        var cir = 40030173.6; // circumference of the earth
        var tmp =(1/Math.sin( (map.GetCenter().GetLatitude()*Math.PI/180)));
        var metersPerPixel = (cir/(Math.pow(2,gxzoom) * 256 * tmp ))


/*	var metersPerPixelDebug="";
	var l = 1;
	var mpp = 0;	
	for (gxzoom2=20; gxzoom2>=4;gxzoom2--)
	{
        tmp =(1/Math.sin( (map.GetCenter().gGetLatitude()*Math.PI/180)));
        mpp = (cir/(Math.pow(2,gxzoom2) * 256 * tmp ))

		metersPerPixelDebug+="<br>"+l+":::"+mpp;
		l++;
	}
	layermanager.setDivContent("tempdiv",metersPerPixelDebug);
*/	
	var scale = 1000;	
	var kilometer = Math.round(scale/metersPerPixel);
	while (kilometer>200)
	{
		scale-=100;	
		kilometer = Math.round(scale/metersPerPixel);
	}
	if (scale==0)
	scale = 1000;	
	kilometer = Math.round(scale/metersPerPixel);
	while (kilometer>150)
	{
		scale-=20;	
		kilometer = Math.round(scale/metersPerPixel);
	}


	var displayScale = (""+scale).replace (/000/,'k');
	layermanager.setDivContent("scalediv","<img src='"+settings.scaleGraphic+"' height=10 width='"+kilometer+"'> <b>"+displayScale+"m</b>");

//	kilometer = kilometer * 0.000621371192;
	var oscale = scale;
	scale = scale * 0.000621371192;
	var remainder = scale%0.1;
	kilometer = kilometer * ((scale-remainder)/scale);
	scale = scale-remainder;
	scale = scale.toFixed(1);

	if (scale>0)
	layermanager.appendDivContent("scalediv","<br><img src='"+settings.scaleGraphic+"' height=10 width='"+kilometer+"'> <b>"+scale+" miles</b>");
}

MAPMANAGER.prototype.createPrintLink = function () { var cp = map.getCenterPosition(); var url="print.php?icons="+document.forms.controlform.iconstyle.value+"&style="+document.forms.controlform.mapstyle.value+"&z="+zoom.getZoomLevel()+"&lat="+cp.getLat()+"&lng="+cp.getLon()+"&maptype="+settings.maptype; for (i in settings.showInfo) { if (i!="properties" && i!="offices") url+="&"+i+"=" + eval ("document.forms."+settings.trackinformname+"."+i+".checked"); } window.open (url,"print"); }

MAPMANAGER.prototype.createEmailLink = function () { var cp = map.getCenterPosition(); var url="email.php?icons="+document.forms.controlform.iconstyle.value+"&style="+document.forms.controlform.mapstyle.value+"&z="+zoom.getZoomLevel()+"&lat="+cp.getLat()+"&lng="+cp.getLon() + "&height="+document.getElementById('map').style.height+"&width="+document.getElementById('map').style.width; window.open (url,"email","scrollbars=no,height=245,width=300"); }

MAPMANAGER.prototype.startInteractiveDirections = function () { mapmanager.recordStartStop=1; mapmanager.clickPositions = new Array(); mapmanager.directionType="interactive"; layermanager.divStatus("dirinst","block");//layermanager.layerAtCurrentLocation("rolloverdiv",settings.directionsText); 
}

MAPMANAGER.prototype.showDirections = function (r)
{
layermanager.divStatus("measurediv","block");
layermanager.setDivContent("measurediv","<table width=100% cellpadding=3><tr><td><img src='img/icon_car.gif'></td><td>"+ r.TotalDistance + " miles (" + r.TotalTime+ ")<br><a href='javascript:layermanager.divStatus(\"measurediv\",\"none\")'>Close</a></td></tr></table>");

if (mapmanager.directionType=="atob") return;
var directions = "";
var c=0;

for (i in r.RouteInstructions)
{
	if (r.RouteInstructions[i].Instruction)
        directions+="<br>" + (++c) + ") " + r.RouteInstructions[i].Instruction;
}

layermanager.setDivContent("directionsinner","<a href='javascript:layermanager.setDivContent(\"directionsinner\",\"\"); layermanager.divStatusArray (new Array(\"directionsinner\",\"directionsheading\") ,\"none\");'>close</a><br>&nbsp;<br><b>Total time: </b>" + r.TotalTime + "<br><b>Miles: </b>" + r.TotalDistance+directions);
layermanager.divStatusArray (new Array("directionsinner","directionsheading") ,"block");
settings.showingDirections=true;
}


MAPMANAGER.prototype.plotDirections = function ()
{
this.clearMap();
this.routePlotted=true;

if (this.toAddress && this.fromAddress)
{
	this.clickPositions=new Array (this.fromAddress,this.toAddress);
	map.addPin(new Pin (this.fromAddress, "",null,icons["startflag"]));
	map.addPin(new Pin (this.toAddress, "",null,icons["endflag"]));
	
	this.toAddress = this.fromAddress = "";
}
map.routeMap( mapmanager.clickPositions, mapmanager.showDirections);
//mapmanager.redoMap();

var c=1;
var flag = "";

for (i=0; i<this.clickPositions.length; i++)
{
	flag="continueflag";
	if (c==this.clickPositions.length) flag = "endflag";
	if (c==1) flag = "startflag";
	map.addPin(new Pin (this.clickPositions[i], "",null,icons[flag]));
	c++;
}

}

MAPMANAGER.prototype.doDirections = function (from,to)
{
	mapmanager.directionType="atob";
	this.toAddress="";
	this.fromAddress="";
	var fA = new FreeFormAddress(from,mapmanager.locale);
	var fT = new FreeFormAddress(to,mapmanager.locale);
	geocoder.geocode (fA,function (pos,addr) { if (!pos[0]) alert ("couldn't match from address"); else { mapmanager.fromAddress=pos[0]; if (mapmanager.toAddress) mapmanager.plotDirections(); } });	
	geocoder.geocode (fT,function (pos,addr) { if (!pos[0]) alert ("couldn't match to address"); else { mapmanager.toAddress=pos[0]; if (mapmanager.fromAddress) mapmanager.plotDirections(); } });	

}

MAPMANAGER.prototype.loadElement = function(rD) { 
	var dids= new Array(); 
	var listnumbers=0;
	if (settings.trackimage==true) { layermanager.setDivContent("photocontainer"," "); layermanager.photoleft=settings.photoleft; this.photoshowing=0; }

	layermanager.photos=new Array(); layermanager.photoleft=settings.photoleft; var done=0; 

	this.pins=new Array(); 

	var te = rD.documentElement.getElementsByTagName('p'); 

	for (var i=0; i<te.length; i++) 
	{  
		var t = te[i].getAttribute('id').split (","); 

		if (settings.poiList==true)
		{
			var n = te[i].getAttribute('k').split (",");
			for (j=0; j<t.length; j++)
			{
				layermanager.appendDivContent("list"+te[i].getAttribute('set'),"<br><a onmouseover='mapmanager.highlightIcon(\""+t+"\")' onmouseout='mapmanager.unsetHighlight()' href='javascript:void(mapmanager.openIcon(\""+t+"\"))' class='blacklink'> &nbsp; &nbsp;"+n[j]+ ""+ "</a>");
				listnumbers++;
			}
		}


		
		if (settings.showInfo[te[i].getAttribute('set')])
		settings.showInfo[te[i].getAttribute('set')]["nos"]+=t.length; 


		layermanager.appendDivContent("infodiv","<font color=blue><br>PIN "+ te[i].getAttribute('id')+"</font>");
		this.pins[te[i].getAttribute('id')] = new PIN(te[i].getAttribute('id'), te[i].getAttribute('lat'), te[i].getAttribute('lng'), te[i].getAttribute('k'),'false', te[i].getAttribute('type'), te[i].getAttribute('image'), te[i].getAttribute('set'), te[i].getAttribute('k'), te[i].getAttribute('r')); 
    var url = te[i].getAttribute('url');
    
    ///Redirect on icon click
    if(url)
      this.pins[te[i].getAttribute('id')].url = url;
      

		
		if (settings.trackimage==true && this.photoshowing<settings.photomax && !dids[te[i].getAttribute('id')])
		{
			dids[te[i].getAttribute('id')]=true;
			if (!this.photoshowing) layermanager.photol=0;

			var ids = te[i].getAttribute('id').split(',');
			for (var i2=0;i2<ids.length; i2++)
			{
				if (this.photoshowing==settings.photomax) 
				{
					i2=10000000;
					layermanager.appendDivContent("infodiv","RETURNING");
				}
				else
				{
				var j = ids[i2];
				mapmanager.pins[te[i].getAttribute('id')].photox = layermanager.photol;
				layermanager.photol+=1*settings.photodistance;
				var ext = i2;
				if (i2==0) ext="";

				if (i==0 ) layermanager.divStatusArray(new Array("trackimagediv","thumbheading"),"block");

				layermanager.appendDivContent("photocontainer","<a href='javascript:void(layermanager.showIcon(\""+te[i].getAttribute('id')+"\",\""+i2+"\"))'><img onmouseout='mapmanager.unsetHighlight()' onmouseover='mapmanager.highlightIcon(\""+te[i].getAttribute('id')+"\",\""+i2+"\");mapmanager.highlightPhoto(\""+j+ext+"\",0)' src='"+settings.url_thumbnails+"?set="+te[i].getAttribute('set')+"&id="+j+"&type=b' border=0 id='photo"+j+""+ext+"' alt=\""+te[i].getAttribute('k')+"\" height="+settings.photoheight+" width="+settings.photowidth+"></a> &nbsp;");
				this.photoshowing++;
				}
			}
		}
	} 
	this.pagetotal = Math.ceil(listnumbers/this.pageper);
	layermanager.setDivContent("listnumbers",listnumbers);
	layermanager.setDivContent("listnumbersoutof",listnumbers);
	this.pagepins=listnumbers;
	this.pagecurrent=1;

} 

MAPMANAGER.prototype.rerunpaginate = function (val)
{
	this.pagecurrent=val;
	this.paginate();

}

MAPMANAGER.prototype.paginate = function ()
{
	this.pagestart = 1*(this.pagecurrent*this.pageper) - (this.pageper-1);
	this.pagestop = 1*this.pagestart + this.pageper-1;
	if (this.pagestop>this.pagepins)
	this.pagestop=this.pagepins;
	layermanager.setDivContent("listnumbers",this.pagestart+"-"+this.pagestop);
	
	var c = 1;
	var pages="";
	for (i=1; i<=this.pagetotal; i++)
	pages+="<option value='"+i+"'>"+i;
	layermanager.setDivContent ("listinfo"," &nbsp;Page: <select onchange='mapmanager.rerunpaginate(this.value)' name='pagecurrent'>"+pages+"</select>");
	for (i in this.pins)
	{
		if (this.pins[""+i])
		{
		if (c>=1*this.pagestart && c<=1*this.pagestop) this.pins[""+i].pin.show();
		else
		this.pins[""+i].pin.hide();
		c++;
		}
	}
}

MAPMANAGER.prototype.highlightPhoto = function(id,domove)
{

        if (!document.getElementById('photo'+id)) return;
        if (this.lastPhotoHighlighted && document.getElementById('photo'+this.lastPhotoHighlighted))
        {
        document.getElementById('photo'+this.lastPhotoHighlighted).height=settings.photoheight;
        document.getElementById('photo'+this.lastPhotoHighlighted).width=settings.photowidth;
        document.getElementById('photo'+this.lastPhotoHighlighted).style.border="0px";
        }
        document.getElementById('photo'+id).height=settings.photoheight-6;
        document.getElementById('photo'+id).width=settings.photowidth-6;
        document.getElementById('photo'+id).style.border="solid 3px #F68A03";
        this.lastPhotoHighlighted=id;


        if (settings.photoshowmax>=mapmanager.photoshowing) return;

        if (domove)
        {
        var move = 1*layermanager.photoleft + (mapmanager.pins[id].photox) - settings.photoleft;
        if (move<0) layermanager.movePhoto ("+",-1*move,-1*move)
        else layermanager.movePhoto ("-",move,move)


        }
}


MAPMANAGER.prototype.doZoom2 = function () { 
this.clearMap(); 
this.routePlotted=false; 
layermanager.divStatus ('loadingdiv','block'); 
settings.zoomlevel = 21-map.GetZoomLevel(); 
//alert ("dozoom2="+settings.zoomlevel);
setTimeout("mapmanager.redoMap()",10); 
this.scaleGraphic(); 
        settings.lat = map.GetCenter().Latitude;
        settings.lng = map.GetCenter().Longitude;
if (document.forms.aspnetForm.Mlat) document.forms.aspnetForm.Mlat.value=settings.lat;
if (document.forms.aspnetForm.Mlng) document.forms.aspnetForm.Mlng.value=settings.lng;

}

MAPMANAGER.prototype.plot=function ()
{
	this.plotting=true;
	if (settings.text_plot)
        //layermanager.setDivContent('loadinginnerdiv',settings.text_plot);
		showHideImg('text_load','text_process','text_plot');

	var txt=settings.statusPrefix;
	var comma="";
	var desc="";
	var propnums = 0;
	for (i in settings.showInfo)
	{
	if (i)
	{

	desc = settings.showInfo[i]["nos"]==1 ? settings.showInfo[i]["single"] :  settings.showInfo[i]["plural"];
	if (i!="properties") //settings.showInfo[i]["nos"] && i!="properties")
	{
	if (settings.showInfo[i]["nos"]>0)
	{
	txt+= comma + settings.showInfo[i]["nos"] + " " + desc;
	comma=", ";
	}
	layermanager.setDivContent("num"+i, "( <b>" + settings.showInfo[i]["nos"] +" </b>)");
	if (settings.showInfo[i]["hidetotal"]>0)
	{
	layermanager.setDivContent("num"+i, "( <b><font color=red>" + settings.showInfo[i]["hidetotal"] +" </font></b>)");
	txt+= comma + "<a onclick='layermanager.layerAtCurrentLocation(\"rolloverdiv\",settings.tooHighText);'><font color=red style='border-bottom:dashed blue 1px'>"+settings.showInfo[i]["hidetotal"] + " " + desc + "</font></a>";
	settings.FYI="You are too high for the <font color=red style='border-bottom:dashed blue 1px'>highlighted</font> places above";
	comma=", ";
	}
	}
	else
	propnums+=settings.showInfo[i]["nos"];
	}
	}
	layermanager.setDivContent("statusinnerdiv",txt);

	if (settings.mirrorPropertyNumbers)
	layermanager.setDivContent("propertynumbers",propnums);
	
	
	var oPinRadius = 1;
	var oPin2Radius = 1;

	var c=0;
	var selbox;
	var selboxSize=0;

	if (settings.jumptoproperty)
	{
		selbox = document.forms.jumpproperty.id2;
		selbox.options.length=0;
		selbox.options[selbox.options.length] = new Option("Properties on map","");	
	}
	
	for (i in this.pins) //<pins.length; i++)
	{
		layermanager.appendDivContent("infodiv","<br>checking "+i);

		if (settings.jumptoproperty && this.pins[i].set=="properties" && this.pins[i].inradius==1)
		{
			var ps = this.pins[i].id.split(",");
			selbox.size=ps.length;
			var ls = this.pins[i].label.split(",");

			for (var lps=0; lps<ps.length; lps++)
			{
			selbox.options[selbox.options.length] = new Option(ls[lps].replaceAll(":",", "),ps[lps]);	
			selboxSize++;
			}
		}

		if (this.pins2[""+i])
		{
			layermanager.appendDivContent("infodiv","<br><br>=="+this.pins2[i].lat+","+this.pins2[i].lng+"<br>"+i + " " + this.pins2[i].label);
			oPinRadius = this.pins[""+i].inradius;
			oPin2Radius = this.pins2[""+i].inradius;
			//alert ('swap in ' + i + this.pins2[""+i].pin);


//alert ('swap out ' + i );
//			if (this.pins2[""+i].inradius==1 && this.pins[""+i].inradius==0) setActive=1; this.pins[""+i].pin.setIcon(this.icons[this.pins[i].type]);	

			this.pins[""+i] = this.pins2[""+i]; //swap over
			//this.pins[""+i].inradius = this.pins2[""+i].inradius; //swap over

//			alert (this.pins[i].pin.src);


			if (!this.pins[""+i].pin) {}
			else if (oPin2Radius=="0" && oPinRadius=="1") this.pins[""+i].pin.SetCustomIcon(this.icons[this.pins[i].type]);
			else if (oPin2Radius=="1" && oPinRadius=="0") this.pins[""+i].pin.SetCustomIcon(this.icons[this.pins[i].type+"_off"]);	
			else if (oPin2Radius=="0" && oPinRadius=="0") this.pins[""+i].pin.SetCustomIcon(this.icons[this.pins[i].type+"_off"]);	

			//this.pins[i].pin.src='x.gif';

			if (this.pins[""+i].pin)
			{
				if (oPinRadius=="1" && this.pins[""+i].pin.src!=this.icons[this.pins[i].type]) // && this.pins[""+i].pin.getIcon()!=this.icons[this.pins[i].type])
				this.pins[""+i].pin.SetCustomIcon(this.icons[this.pins[i].type]);

				if (oPinRadius=="0" && this.pins[""+i].pin.src!=this.icons[this.pins[i].type+"_off"])// && this.pins[""+i].pin.getIcon()!=this.icons[this.pins[i].type+"_off"])
				{
//			ni	alert (this.pins[""+i].pin.src + "!=" + this.icons[this.pins[i].type]);
				this.pins[""+i].pin.SetCustomIcon(this.icons[this.pins[i].type+"_off"]);
//				console.log ("set " + i + " off");
				}
			}
			this.pins2[""+i]=null;
		}
		else
		{
			layermanager.appendDivContent("infodiv","<br><br>+"+this.pins[i].lat+","+this.pins[i].lng+"<br>"+this.pins[i].id + " i= " + i + " = "  + this.pins[i].label);
			var ti = this.icons[this.pins[i].type];

			if (this.pins[i].inradius==0)
			ti = this.icons[this.pins[i].type+"_off"];
			var pos1 = new VELatLong(1*this.pins[i].lat, 1*this.pins[i].lng);
			
			var p = new VEShape(VEShapeType.Pushpin, pos1);
			p.SetTitle(this.pins[i].label.replaceAll(",",settings.rolloverSeparator).replaceAll(":",", "));
			//alert (ti);
			p.SetCustomIcon(ti);
			//var p = new Pin (pos1, "<iframe frameborder=0 id=propertyiframe src='smallpin.php?id="+this.pins[i].id+"&type="+this.pins[i].type+"'></iframe>",null,ti);
			this.pins[""+i].pin=p;

/*
			if (settings.bubblestyle=="rocketboxover" || settings.bubblestyle=="rocketboxside")
			this.pins[""+i].click=p.AttachEvent( "onclick",listenBoxOver);
			else if (settings.bubblestyle=="box")
			this.pins[""+i].click=p.AttachEvent( "onclick",listenHighlightPin);
			else if (settings.bubblestyle=="bubble")
			this.pins[""+i].click=p.AttachEvent( "onclick",showInfoWindow);	

			this.pins[""+i].mouseover=p.AttachEvent( "onmouseover",listenPinRollover);
*/
			map.AddShape (p);
			this.pins[i].shapeID = p.GetID();
		//	alert (p.getY());
			//document.getElementById("rolloverdiv").innerHTML="blah";
//			document.getElementById("rolloverdiv").style.display="block";	
//			document.getElementById("rolloverdiv").style.top=(1*200+1*p.getY()) + "px";
//			document.getElementById("rolloverdiv").style.left=(1*300+1*p.getX()) + "px";
//			alert ('h');

			
		}
		c++;
	}

	if (settings.jumptoproperty)
	{
	selbox.size = ++selboxSize;
	if(selbox.size>25){selbox.size=25;}
	if (selbox.size==1 || param2("developments")=="true") 
	document.getElementById("jumptocontainer").style.display='none';
	else
	document.getElementById("jumptocontainer").style.display='block';
	}

//	if (settings.pin1) map.addPin(settings.pin1);
///	if (settings.pin1) map.addPin(settings.pin2);
	if (settings.FYI!="") layermanager.setDivContent("fyidiv","<table width=100% cellpadding=3><tr><td><img src='img/icon_info.gif'></td><td>"+settings.FYI + "</td></tr></table>");
	else
	layermanager.setDivContent("fyidiv","<table width=100% cellpadding=3><tr><td>?</td><td>"+mapmanager.randomTips() + "</td></tr></table>");
	settings.FYI="";

	if (layermanager.divContent('statusinnerdiv'))
	layermanager.divStatus ('statusdiv','block');

	for (i in this.pins2) //<pins.length; i++)
	if (this.pins2[i]!=null)
	{
	layermanager.appendDivContent("infodiv","<br><br><b>-</b> "+this.pins2[i].lat+","+this.pins2[i].lng+"<br>"+i + " " + this.pins2[i].label);
	this.DeleteShape2(i);
	}
	clearTimeout(layermanager.counterTimer);

        if (this.pagepagination) this.paginate();

	loading=false;
	layermanager.divStatus ('loadingdiv','none');
	this.plotting=false;
  pngfix();
}

function listenHighlightPin(e) { mapmanager.highlightPin(e); }
function listenBoxOver(e) { 
if (settings.bubblestyle=="rocketboxover") mapmanager.bringUpBox(e,"boxover"); 
if (settings.bubblestyle=="rocketboxside") mapmanager.bringUpBox(e,"boxside"); 
}
function listenTransparentPin(e) { mapmanager.pinPopup(e,"transparent",40,100);}
function listenGooglePin(e) { mapmanager.pinPopup(e,"google",40,100);}
function listenPinRollover(e) { layermanager.pinRollover(e); }


MAPMANAGER.prototype.removeOutOfBounds=function () { for (i in this.pins) { if (!this.inBoundary(this.pins[i].lat, this.pins[i].lng)) { 
if (i=="each") return;

if (!this.pins[i].pin) return true;
map.DeleteShape (this.pins[i].pin); 
if (this.pins[i].click) EventRegistry.removeListener(this.pins[i].click); if (this.pins[i].mouseover) EventRegistry.removeListener(this.pins[i].mouseover); this.pins[i]=null; } } }

MAPMANAGER.prototype.storePin=function(id,set)
{
//	alert ("storing pin " + id + " plus " + set);
}

MAPMANAGER.prototype.showInfoWindow=function(pin) { layermanager.divStatus("rolloverdiv","none"); for (i in this.pins) { if (this.pins[i].latlng==pin.toString()) { this.doPopulate=false; 
pin.showInfoWindow(); 
map.panToPosition(new VELatLong(this.pins[i].latlng)); 
_populateBubbleInner (this.pins[i]);
mapmanager.highlightIcon (this.pins[i].id); 
return; } } }

MAPMANAGER.prototype.removeRemainingProperties2=function () { for (i in this.pins2) { map.DeleteShape (this.pins2[i].pin); if (this.pins2[i].click) EventRegistry.removeListener(this.pins2[i].click); if (this.pins2[i].mouseover) EventRegistry.removeListener(this.pins2[i].mouseover); } this.pins2=new Array(); }
MAPMANAGER.prototype.DeleteShape2=function (i) { layermanager.appendDivContent("infodiv","<br>REM: <font color=red>"+i+"</font>"); if (this.pins2[i].pin) map.DeleteShape (this.pins2[i].pin); if (this.pins2[i].click) EventRegistry.removeListener(this.pins2[i].click); if (this.pins2[i].mouseover) EventRegistry.removeListener(this.pins2[i].mouseover); }

MAPMANAGER.prototype.clearMap=function () { 
for (i in this.pins) { 
//if (this.pins[i].pin) map.DeleteShape (this.pins[i].pin); 
//if (this.pins[i].click) EventRegistry.removeListener(this.pins[i].click); if (this.pins[i].mouseover) EventRegistry.removeListener(this.pins[i].mouseover); } this.pins=new Array(); map.removeAllPins()}
}}

MAPMANAGER.prototype.setBoundaryVars=function() { 
mapboundary.bRLat=map.PixelToLatLong(new VEPixel(0,0)).Latitude;
mapboundary.tLLng=map.PixelToLatLong(new VEPixel(0,0)).Longitude;
mapboundary.tLLat=map.PixelToLatLong(new VEPixel(map_width,map_height)).Latitude;
mapboundary.bRLng=map.PixelToLatLong(new VEPixel(map_width,map_height)).Longitude;
}

MAPMANAGER.prototype.inBoundary=function(lat,lng) { 

if (lat=="undefined") return false;


if (1*lat<1*mapboundary.tLLat || 1*lat>1*mapboundary.bRLat || 1*lng>1*mapboundary.bRLng || 1*lng < 1*mapboundary.tLLng) 
return false; 
else 
return true;
}



/*
function: addIcons
*/
MAPMANAGER.prototype.addIcons = function(i) {this.icons=i;}

/*
function: panTo
*/
MAPMANAGER.prototype.doPan = function(d) { eval ("map.pan"+d+"()"); }

/* 
function: panToPos
change *changelocationdiv2* div to hidden and pan to the position, then populate map 2 seconds later

Parameters: 

	pos - a VELatLong(lat, lng) object
*/
MAPMANAGER.prototype.panToPos = function(pos) { layermanager.divStatus ("changelocationdiv2","none"); map.panToPosition(new VELatLong(pos)); setTimeout("mapmanager.populate()",2000); }
MAPMANAGER.prototype.panToPos2 = function(pos) { layermanager.divStatus ("changelocationdiv2","none"); map.panToPosition(new VELatLong(pos));}
MAPMANAGER.prototype.panToPos3 = function(x,y) { layermanager.divStatus ("changelocationdiv2","none"); map.Pan(x,y);}
/* 
function: redoMap
remove pins2 and then repopulate
*/
MAPMANAGER.prototype.redoMap = function () { if (loading) return; this.clearMap(); this.populate(); }

/* 
function: populateFromArrays
*/
MAPMANAGER.prototype.populateFromArrays = function (url) { 
//alert (url);
//window.open(url,'debug');
this.pins = new Array(); 

this.requestmanager.doRequest ("handleRequest",url); 

if (param("test")=="true") window.open(url,'debug');
}

/* 
function: populate
place icons on map
*/

var working=false;
var repopulate=false;

function alterWorkingState()
{
	working=false;
	if (repopulate) 
	mapmanager.populate();
	repopulate=false;
}

MAPMANAGER.prototype.populate = function (replot)
{
	if (working==true) return repopulate=true;
	
	setTimeout ("alterWorkingState()",3000);
	working=true;
//if (this.plotting) return;// alert ('plotting');
	if (settings.alterUrlLocation)
	{
		alterUrl();
	}
	this.plotting=true;
	if (settings.removeids) settings.ids="";
	if (!this.doPopulate) return setTimeout("mapmanager.doPopulate=true",5000);
	//debug ("LOAD="+loading);

	if (loading) 
	{
		loading=false;
		layermanager.divStatus ('loadingdiv','none');
		
	}
	loading=true;

	layermanager.divStatus ('loadingdiv','block');
	layermanager.divStatus ('statusdiv','none');

	if (settings.text_load)
		//layermanager.setDivContent('loadinginnerdiv',settings.text_load);
		showHideImg('text_load','text_process','text_plot');
	else
	{
	layermanager.setDivContent('loadinginnerdiv',' &nbsp; loading data...<div id="counter"  style="display:inline"></div>');
	layermanager.startCounter(1);
	}

	this.setBoundaryVars();
	this.removeOutOfBounds();
	this.pins2=this.pins;
	layermanager.setDivContent("infodiv","- ");


	if (param2("action")=="fitmap")
	{
	  var z = zoomTranslate[map.GetZoomLevel()];
    //alert ("populate =" + z);
	}
	else //if (param2("z"))
	  var z = settings.zoomlevel-4;

/*
	else
	var z = zoomTranslate.indexOf(settings.zoomlevel);
*/

//	alert ("zl=" + z + " was " + settings.zoomlevel + "+4");
//	if (settings.normalzoom=="true") z = settings.zoomlevel;
	if (document.getElementById("type"))
	type = document.getElementById("type").value;
	else 
	type = param("type");

	this.populateFromArrays(settings.url_mapdata + "map_width="+settings.map_width+"&map_height="+settings.map_height+"&icon_height="+(settings.icon_height*settings.multiplier[z])+"&icon_width="+(settings.icon_width*settings.multiplier[z])+"&z="+z+"&type="+type+"&" + mapboundary.flatten() + this.formTracker(1) + "&townsinview="+settings.townsinview + "&onlyids="  + settings.ids + "&radius=" + settings.radius);
	settings.removeids=true;
}

MAPMANAGER.prototype.formTracker = function (savecookie) { 
var r = ""; 
var e = ""; 
var c = ""; 
for (i=0; i<settings.trackinform.length;i++) 
{ 
	e="value"; 
	if (settings.trackinformtype[i]=="checkbox") e="checked"; 
	r+="&"+settings.trackinform[i].substring(1)+"="+eval ("document.forms."+settings.trackinformname+"."+settings.trackinform[i]+"."+e);	 
	c+="&"+settings.trackinform[i].substring(1)+"-"+eval ("document.forms."+settings.trackinformname+"."+settings.trackinform[i]+"."+e);	
} 
//debug ("SET COOKIE - " + c);
if (savecookie) this.updateCookies(c);
return r; 
}

MAPMANAGER.prototype.unsetHighlight = function() { if (this.highlightInstance && this.pins[this.highlightId]) this.highlightInstance.setIcon(this.highlightI); this.highlightI= null; this.highlightInstance = null; }

MAPMANAGER.prototype.highlightPin = function(inst) { layermanager.setDivContent("infodiv",inst.toString()); for (i in this.pins) if (this.pins[i].latlng==inst.toString()) layermanager.showIcon(this.pins[i].id, this.pins[i].type); }
MAPMANAGER.prototype.bringUpBox = function (inst,boxid) { layermanager.setDivContent("infodiv",inst.toString()); for (i in this.pins) if (this.pins[i].latlng==inst.toString()) layermanager.bringUpBox2(this.pins[i].id, this.pins[i].type,this.pins[i].set,boxid); }

MAPMANAGER.prototype.pinPopup = function (inst,name,top,left) { alert(name); layermanager.setDivContent("infodiv",inst.toString()); for (i in this.pins) if (this.pins[i].latlng==inst.toString()) layermanager.showPinPopup(this.pins[i].id, this.pins[i].type); }

MAPMANAGER.prototype.showPinPopup = function(id) { if (!this.pins) return; this.unsetHighlight(); if (!this.pins[""+id].pin) return; this.highlightInstance = this.pins[id].pin; this.highlightId = id; this.highlightI= this.icons[this.pins[id].type]; this.pins[id].pin.setIcon(this.icons['flash']); } 

MAPMANAGER.prototype.highlightIcon = function(id) { if (!this.pins || !this.icons['flash']) return; this.unsetHighlight(); if (!this.pins[""+id].pin) return; this.highlightInstance = this.pins[id].pin; this.highlightId = id; this.highlightI= this.icons[this.pins[id].type]; this.pins[id].pin.setIcon(this.icons['flash']); } 

var mapmanager = new MAPMANAGER();

// *********************************************
/*
class: LAYERMANAGER
contains functions to deal with the divs on a page
one instance - *layermanager*
*/
function LAYERMANAGER() {this.counter=0; this.counterTimer=null; this.minimised=new Array(); this.photos=new Array(); this.firstphoto=1; this.lastphoto=1; this.phototimer=null; this.photoleft=settings.photoleft; this.timer=null; this.rolloverX=0;}

LAYERMANAGER.prototype.clearPhotoTimer = function() { if (this.phototimer) clearTimeout(this.phototimer);}

LAYERMANAGER.prototype.photoLeft = function(loop) {
this.clearPhotoTimer();
this.movePhoto ("-",settings.photomoveincrement,settings.photomove);
}

LAYERMANAGER.prototype.photoRight = function(loop) {
this.clearPhotoTimer();
this.movePhoto ("+",settings.photomoveincrement,settings.photomove);
}


LAYERMANAGER.prototype.divContent = function (thediv) { if (!document.getElementById(thediv)) return alert ("no div named " + thediv);if (document.getElementById(thediv).innerHTML!="") return true; else return false; }

LAYERMANAGER.prototype.divContentFromUrl = function (thediv,url) 
{ 
mapmanager.requestmanager.thediv;
layermanager.setDivContent(thediv,"");
mapmanager.requestmanager.doRequest ("handleHTMLRequest",url);
}

LAYERMANAGER.prototype.alternateDiv = function (thediv,arrow) { 
var newStatus = document.getElementById(thediv).style.display=="block"? "none" : "block";

document.getElementById(arrow).src= newStatus=="block" ? "img/arrow_up.gif" : "img/arrow_down.gif";

this.divStatus(thediv,newStatus);
}




LAYERMANAGER.prototype.layerAtCurrentPlace = function (thediv,msg) { layermanager.moveDiv (thediv); layermanager.setDivContent (thediv,msg); layermanager.divStatus (thediv,'block'); setTimeout ("layermanager.divStatus('"+thediv+"','none')",2000); }


LAYERMANAGER.prototype.closeFull = function() { this.divStatus("propertydiv","none"); this.divStatus("loadingdiv","none"); }


LAYERMANAGER.prototype.startCounter = function(value)
{
        if (value)
        {
        this.counter=value;
        clearTimeout(this.counterTimer);
        }
        else
        {
        this.counter++;
        }
        if (this.counter-1>0)
        this.setDivContent("counter",this.counter-1);

	if (this.counter==4) 
	{
//		layermanager.divStatus("loadingdiv","none");
		return; // layermanager.setDivContent('loadinginnerdiv','taking off grey'); // mapmanager.redoMap();
	}
        this.counterTimer = setTimeout("layermanager.startCounter(0)",1000);
}

/*
function: setDivContent
change the content of ay defined div

Parameters:
	thediv - div name
	content - html content for div

*/
LAYERMANAGER.prototype.setDivHeight =function (thediv, h) { document.getElementById(thediv).style.height=h+"px"; }
LAYERMANAGER.prototype.setDivWidth =function (thediv, w) { document.getElementById(thediv).style.width=w+"px"; }
LAYERMANAGER.prototype.setDivContent =function (thediv, content) { 
if (settings.infodiv==false && thediv=="infodiv") return; 
if (!document.getElementById(thediv)) return; 
//Utilities.purge(thediv); 
document.getElementById(thediv).innerHTML="";
//alert (thediv + " with " + content);
//if (document.getElementById(thediv))
//alert (thediv + " " + content);
document.getElementById(thediv).innerHTML=content; 
}
/*
function: appendDivContent
append to the existing content of a div

Parameters:
	thediv - div name
	content - html content for div
*/
LAYERMANAGER.prototype.appendDivContent = function (thediv, content) { if (settings.infodiv==false  && thediv=="infodiv") return; if (!document.getElementById(thediv)) return; document.getElementById(thediv).innerHTML+=content; }

/* 
function: divStatus
takes status and whethe or not to show it
*/
LAYERMANAGER.prototype.divStatus = function (thediv,status) { if(settings.noload && thediv=="loadingdiv") return; if (!document.getElementById(thediv)) alert (thediv); if (settings.div_fulldetails && status=="none" && thediv=="propertydiv") layermanager.divStatus('fulldetailsdiv','none'); document.getElementById(thediv).style.display=status; if (status=="none" && thediv=="propertydiv") { this.setDivContent("propertydiv","  "); } }

LAYERMANAGER.prototype.divStatusArray = function (thedivs,status)
{
	for (i in thedivs)
	this.divStatus(thedivs[i],status);
}


/* 
function: divStatusWithOpacity
takes status and whethe or not to show it blending it into the page
*/
LAYERMANAGER.prototype.divStatusWithOpacity = function (thediv,status) { if (settings.div_fulldetails && status=="none" && thediv=="propertydiv") layermanager.divStatus('fulldetailsdiv','none'); if (status=="block") { this.setOpacity (thediv,25); document.getElementById(thediv).style.display=status; setTimeout ("layermanager.opacityTimed('"+thediv+"',50,'block')",400); } else { this.setOpacity (thediv,50); setTimeout ("layermanager.opacityTimed('"+thediv+"',25,'none')",400); } }

LAYERMANAGER.prototype.setOpacity = function (thediv, opacity,status) { document.getElementById(thediv).style.filter="alpha(opacity="+opacity+")"; document.getElementById(thediv).style.opacity="."+opacity; }

LAYERMANAGER.prototype.minimise = function (thediv,closediv,newid,value) { this.divStatus(closediv,"none"); if (this.minimised[newid]!=null) this.divStatus(newid,"block"); else this.appendDivContent(thediv,value); this.minimised[newid]=true; }

LAYERMANAGER.prototype.maximise = function (closediv,todiv,id) { this.divStatus(closediv,"none"); if (settings.div_fulldetails) layermanager.divStatus('fulldetailsdiv','block'); this.divStatus(todiv,"block"); layermanager.setDivContent ("propertydiv","<iframe src='"+settings.fullUrls["properties"]+"?current=1&property="+id+"&type=b' scrolling=no height=300 width=90% frameborder=0></iframe>"); this.setOpacity (todiv,"75"); }

LAYERMANAGER.prototype.opacityTimed = function (thediv,opacity,status) { this.setOpacity (thediv,opacity); var o=opacity; if (o==0) this.divStatus(thediv,"none"); if (o==0 || o==75) return; if (status=="block") o=25+o; else o=1*o-25; setTimeout ("layermanager.opacityTimed('"+thediv+"',"+o+",'"+status+"')",400); }

/*
function: showIcon
show and alter *fulldetailsdiv* with property details

Parameters:
	id - property id
*/
LAYERMANAGER.prototype.showIcon = function(id,set)
{
	layermanager.divStatus('rolloverdiv','none');
	layermanager.divStatus('loadingdiv','block');
	document.getElementById('bubble').style.display='none';
//	document.getElementById('propertydiv').style.display='block';
	layermanager.divStatusWithOpacity('propertydiv','block');
	//if (settings.div_fulldetails) layermanager.divStatus('fulldetailsdiv','block');
	if (settings.storeClickIds) mapmanager.storePin(id,set);

	layermanager.setDivContent ("propertydiv"," <div onmouseover='isHot=1' onmouseout='isHot=0;ddEnabled=false'></div><font face='Arial'><iframe src='largepin.php?id="+id+"&type="+set+"&current=1' scrolling=no height=300 width=90% frameborder=0></iframe>");
	return false;
}
LAYERMANAGER.prototype.bringUpBox2 = function(id,type,set,boxid)
{
	if (bringingupbox) return; // alert ('loading still');
	bringingupbox=true;
	
	layermanager.divStatus('rolloverdiv','none');
	layermanager.divStatus('boxover','none');
	layermanager.divStatus('boxside','none');
	if (boxid=="boxover") layermanager.divStatus('loadingdiv','block');
	setTimeout("layermanager.divStatus('"+boxid+"','block')",300);

	mapmanager.requestmanager.div = boxid;
	var url= eval ("settings.url_"+boxid+"_"+set)+"property="+id+"&current=1&lat="+settings.lat+"&lng="+settings.lng+"&id="+id+"&set="+set+"&ids="+settings.ids+"&subset="+type + "&" + mapmanager.formTracker();
        mapmanager.requestmanager.doRequest ("handleHTMLRequest",url);
	return false;
}

/*
function: propertypopdown
set *rolloverdiv* to hidden
*/
LAYERMANAGER.prototype.propertypopdown = function() { layermanager.divStatus('rolloverdiv','none'); }

/*
function: moveDiv
perform rollover on icon
Parameters:
	which - div name
	what - not used
*/
LAYERMANAGER.prototype.moveDiv = function(which,what) { var extra = document.body.scrollTop; if (!ie) extra=0; 

var t = this.rolloverX;
if (this.rolloverX+mouseX+10<0) t=0;

if (settings.fixRolloverX) mouseX+=1*settings.fixRolloverX;
if (settings.fixRolloverY) mouseY+=1*settings.fixRolloverY;

document.getElementById(which).style.left=(t+mouseX+10) + "px"; document.getElementById(which).style.top=(extra+mouseY-10) + "px"; }


/*
function: pinRollover
perform rollover on icon
*/
LAYERMANAGER.prototype.pinRollover = function (inst) { for (i in mapmanager.pins) { if (mapmanager.pins[i].latlng==inst.toString()) {  

if (settings.rolloverUrl)
{
        mapmanager.requestmanager.div = "rolloverdiv";
        mapmanager.requestmanager.lat = mapmanager.pins[i].lat;
        mapmanager.requestmanager.lng = mapmanager.pins[i].lng;
	layermanager.setDivContent("rolloverdiv","loading...");
        mapmanager.requestmanager.doRequest ("handleHTMLRequest",settings.rolloverUrl+"?id="+mapmanager.pins[i].id+"&type="+mapmanager.pins[i].type+"&config="+settings.configuration+"&bubble="+mapmanager.bubbleStyle+"&lat="+mapmanager.pins[i].lat+"&lng="+mapmanager.pins[i].lng)
	layermanager.moveDiv ("rolloverdiv","click"); layermanager.divStatus('rolloverdiv','block');
}
else
{
var labelSize = mapmanager.pins[i].label.split(",").length;

if (settings.rolloverType=="numbers" && labelSize>1)
layermanager.setDivContent("rolloverdiv",labelSize + " " + settings.showInfo[mapmanager.pins[i].set]["plural"]); //"<br>")); 
if (settings.rolloverType=="address" || labelSize==1)
layermanager.setDivContent("rolloverdiv",mapmanager.pins[i].label.replaceAll(",",settings.rolloverSeparator).replaceAll(":",", ")); //"<br>")); 


layermanager.moveDiv ("rolloverdiv","click"); layermanager.divStatus('rolloverdiv','block'); clearTimeout(this.timer); this.timer=setTimeout("layermanager.propertypopdown()",2000); }}}
}


var layermanager = new LAYERMANAGER();
//var lm = layermanager;


// *********************************************
/*
class: MISCELLANEOUS
a set of funtions for doing various tasks
one instance - *miscellaneous*
*/
function MISCELLANEOUS() {}

/*
function: thumbnails
Alters the current location based on *SETTINGS.url_thumbnails*

See Also:
<slideshow> <mapview> <listview>
*/

MISCELLANEOUS.prototype.thumbnails = function() { document.location = settings.url_thumbnailview + "?type=b&minprice=0&maxprice=10000000&minbeds=0&" + mapboundary.flatten() + "&a=list_view"; }

/*
function: slideshow
Alters the current location based on *SETTINGS.url_slideshow*

See Also:
<thumbnails> <mapview> <listview>
*/

MISCELLANEOUS.prototype.slideshow = function() { document.location = settings.url_slideshow + "?type=b&minprice=0&maxprice=10000000&minbeds=0&" + mapboundary.flatten(); }

/*
function: mapview
Alters the current location based on *SETTINGS.url_mapview*

See Also:
<thumbnails> <slideshow> <listview>
*/

MISCELLANEOUS.prototype.mapview = function() { document.location= settings.url_mapview + "?type=b&action=fitmap&ids="+listpins.join(','); }

/*
function: listview
Alters the current location based on *SETTINGS.url_listview*

See Also:
<thumbnails> <slideshow> <mapview>
*/
MISCELLANEOUS.prototype.listview = function() { document.location = settings.url_listview + "?type=b&minprice=0&maxprice=10000000&minbeds=0&" + mapboundary.flatten() + "&a=list_view"; }

var miscellaneous = new MISCELLANEOUS();

// ******************************************************* END DEFINED CLASSES *************************************************************z


function cdc(e)
{
	return true;
}
/*
function init()
{

if(document.getElementById('map')) {

        settings.map_height = document.getElementById('map').style.height;
        settings.map_width = document.getElementById('map').style.width;
document.onclick = getXY; document.onmousemove = getXY; 
map = new VEMap("map"); 
map.SetDashboardSize(VEDashboardSize.Small);



//zoom = new ZoomController(settings.zoomlevel);
//map.addZoomController(zoom);

mapmanager.loadCookies(); 



if (param("action")=="fitmap") mapmanager.fitMap();
else
{

//var np = new VELatLong (settings.lat, settings.lng);
//alert (settings.zoomlevel);

settings.zoomlevel = parseInt(param("zoom"));

map.LoadMap(new VELatLong(settings.lat, settings.lng), 21-settings.zoomlevel ,'r' ,false);

var shape = new VEShape(VEShapeType.Polygon, [new VELatLong(60,-7),
                                                   new VELatLong(60,5),
                                                   new VELatLong(40,5),
                                                   new VELatLong(40,-7)]);
var fillColor = new VEColor(settings.col1,settings.col2,settings.col3,0.3);

shape.SetFillColor(fillColor);
shape.SetLineColor(fillColor);
map.AddShape(shape);
shape.HideIcon();
if(!settings.showdashboard)
	map.HideDashboard();
map.AttachEvent("onclick",ShapeHandler);
map.AttachEvent("ondoubleclick", cdc);
map.AttachEvent("onmousewheel", cdc);
map.AttachEvent("onendpan",populateTimed);
map.AttachEvent("onendzoom",populateTimed);
map.AttachEvent("onmouseover",myMouseOver);
map.AttachEvent("onmouseout",myMouseOut);

mapmanager.populate();
}
layermanager.divStatus ("map","block");
init2();

//doZoom( 21 - parseInt(param("zoom")) );

}}*/

function init()
{

if(document.getElementById('map')) {

settings.map_height = document.getElementById('map').style.height;
settings.map_width = document.getElementById('map').style.width;
document.onclick = getXY; document.onmousemove = getXY; 
map = new VEMap("map"); 
map.SetDashboardSize(VEDashboardSize.Small);



//zoom = new ZoomController(settings.zoomlevel);
//map.addZoomController(zoom);

mapmanager.loadCookies(); 



if (param("action")=="fitmap") mapmanager.fitMap();
else
{

//var np = new VELatLong (settings.lat, settings.lng);
//alert (settings.lat);
settings.zoomlevel = parseInt(param("zoom"));
map.LoadMap(new VELatLong(settings.lat, settings.lng), 21-settings.zoomlevel ,'r' ,false);


var shape = new VEShape(VEShapeType.Polygon, [new VELatLong(60,-7),
                                                   new VELatLong(60,5),
                                                   new VELatLong(40,5),
                                                   new VELatLong(40,-7)]);
var fillColor = new VEColor(settings.col1,settings.col2,settings.col3,0.3);

shape.SetFillColor(fillColor);
shape.SetLineColor(fillColor);
map.AddShape(shape);
shape.HideIcon();
if(!settings.showdashboard)
	map.HideDashboard();
map.AttachEvent("onclick",ShapeHandler);
map.AttachEvent("ondoubleclick", cdc);
map.AttachEvent("onmousewheel", cdc);
map.AttachEvent("onendpan",populateTimed);
map.AttachEvent("onendzoom",populateTimed);
map.AttachEvent("onmouseover",myMouseOver);
map.AttachEvent("onmouseout",myMouseOut);

mapmanager.populate();
}
layermanager.divStatus ("map","block");
init2();

}
}


function init2()
{
//map2.centerOnPosition(new VELatLong (settings.lat, settings.lng)); 
//zoom2.hide();


_setMapSize(); 

if (!settings.showScale)
zoom.hide();
//timedZoom();

//setTimeout ("timedZoom()",1000);
//alert (settings.zoomlevel);
//map.SetZoomLevel(settings.zoomlevel);

_registerEvents();

setTimeout("_doDefaults()",3000);
setTimeout("mapmanager.scaleGraphic()",2000);

if (settings.trackimage==true) layermanager.movePhoto("0",0,0);
}

function populateTimed2()
{
	//if (map2.getCenterPosition().toString()!=settings.newPos)
	//{
//	settings.newPos = map2.getCenterPosition().toString();
	//map2.removeAllPins();
	//map.panToPosition(map2.getCenterPosition());
//	}
}

function populateTimed()
{
	var gc = map.GetCenter().toString().split(",");
	
	settings.lat = gc[0];
	settings.lng = gc[1];
//map.GetCenter().Latitude();
//	settings.lng = map.GetCenter().Longitude();
	if (document.forms.aspnetForm.Mlat) document.forms.aspnetForm.Mlat.value=settings.lat;
	if (document.forms.aspnetForm.Mlng) document.forms.aspnetForm.Mlng.value=settings.lng;
	
	if (0) //map.getCenterPosition().toString!=settings.newPos && 0)
	{
	alert('pan');
	settings.newPos = map.getCenterPosition().toString();
	//map2.panToPosition(map.getCenterPosition())
	}

	if (mapmanager.routePlotted) 
	{
		layermanager.setDivContent("directionsinner",""); 
		layermanager.divStatusArray (new Array("directionsinner","directionsheading") ,"none");
		mapmanager.routePlotted=false;
		//alterMapStyle("glossy-tile");
		
		map.setMapStyle(settings.configuration);	

		return setTimeout ("populateTimed()",2000);
	}
	if (settings.showingDirections)
	{
		layermanager.setDivContent("directionsinner",""); 
		layermanager.divStatusArray (new Array("directionsinner","directionsheading") ,"none");
		mapmanager.redoMap();
		settings.showingDirections=false;
	}
	if (doubleclick) return; //alert ('double click in place');
	mapmanager.populate();
//	mapmanager.load();
}

function timedZoom()
{
if (settings.zoomlevel != zoom.getZoomLevel())
map.SetZoomLevel(settings.zoomlevel);
//zoom2.zoomToNewLevel(12);
//layermanager.divStatus("map2","block");
if (document.getElementById("trailerscreen")) layermanager.divStatus ("trailerscreen","none");
layermanager.divStatus ("map","block");

}


function routeMap(from) {  map.routeMap( new Array(new VELatLong("51.27","-0.85"), new VELatLong(from)),callBack); }

function callBack(r) {
var directions = "";
var c=0;
for (i in r.RouteInstructions)
{
	directions+="<br>" + (++c) + ") " + r.RouteInstructions[i].Instruction;
}
layermanager.setDivContent("routediv","<a href='javascript:void(mapmanager.divStatusArray(new Array(\"routediv\",\"directionsheading\"),\"none\"))'>close</a><br>&nbsp;<br><b>Total time: </b>" + r.TotalTime + "<br><b>Miles: </b>" + r.TotalDistance+directions);
layermanager.divStatus ("routediv","block");
settings.showingDirections=true;

 }

function param(w) { var p= location.search; if (p.length==0) return ""; p= p.substring(1, p.length); var pairs = p.split("&"); for (var i=0; i<pairs.length; i++) { var pv = pairs[i].split("="); if (pv[0] == w) return pv[1]; } return ""; }

function getXY(e) { //mouseX = (!Utilities.ie7 && !Utilities.ie6) ? e.pageX : event.clientX; mouseY = (!Utilities.ie7 && !Utilities.ie6) ? e.pageY : event.clientY; 
}

function doZoom (l)
{
	if (l=="in") {settings.zoomlevel--; zoom.zoomInOneLevel()}
	else if (l=="out") {settings.zoomlevel++; zoom.zoomOutOneLevel()}
	else
	{
		settings.zoomlevel = l;
		map.SetZoomLevel(l);
	}
	setTimeout("mapmanager.redoMap()",3000);
}



function showPossibleAddresses(posArray, addressArray)
{
	var out = "";
	if (addressArray.length==0)
	{
		alert ('No matching addresses');
		return false;
	}
	for (i=0; i<addressArray.length; i++)
	{
		out+="<br>"+ (i+1) + ") " +"<a href='javascript:void (mapmanager.panToPos2(\"" + posArray[i] + "\"))'>"+addressArray[i] + "</a>";	
		if (i==10) i=100000;
	}
	layermanager.setDivContent("changelocationdiv2",out);
	layermanager.divStatus ("changelocationdiv2","block");
}

function movelocation(where)
{
	if (loading)
	{
	alert ('still loading');
	return false;
	}
	var address = new FreeFormAddress(where, mapmanager.locale);

	geocoder.geocode(address, showPossibleAddresses);

//	alert (address.toString());
//	map.panToPosition(address);
//	setTimeout ("populateMap()",2000);
}

function dragPrelim (id, top, bottom, left,right,dividers,direction, ongraphic, offgraphic, cursor, levels) { var x, y; dO.levels = levels; dO.elNode = document.getElementById(id); dO.direction = direction; dO.top = top; dO.bottom = bottom; dO.dividers = dividers; dO.on = ongraphic; dO.off = offgraphic; dO.cursor = cursor; dO.space = dO.bottom-dO.top; dO.elNode.style.zIndex = ++dO.zIndex; } 

function dragInit(event) { if (!window.event && !event) return; document.getElementById(dO.cursor).src=dO.on; var x = getX(event); var y = getY(event); dO.cSX = x; dO.cSY = y; dO.elStartLeft  = parseInt(dO.elNode.style.left, 10); dO.elStartTop   = parseInt(dO.elNode.style.top,  10); if (isNaN(dO.elStartLeft)) dO.elStartLeft = 0; if (isNaN(dO.elStartTop))  dO.elStartTop  = 0; if (window.event) { document.attachEvent("onmousemove", dragStart); document.attachEvent("onmouseup",   dragStop); window.event.cancelBubble = true; window.event.returnValue = false; } else { document.addEventListener("mousemove", dragStart,   true); document.addEventListener("mouseup",   dragStop, true); event.preventDefault(); } }

function getX(event) { if (window.event) return window.event.clientX + document.documentElement.scrollLeft + document.body.scrollLeft; else return event.clientX + window.scrollX; }
function getY(event) { if (window.event) return window.event.clientY + document.documentElement.scrollTop + document.body.scrollTop; else return event.clientY + window.scrollY; }

function zoomIn(id)
{
if (zoom.getZoomLevel()>1)
{
var nz = zoom.getZoomLevel()-1;
map.SetZoomLevel(nz);
document.getElementById(id).style.top  = (1*nz*dO.dividers+dO.top)+"px";
}
}

function zoomOut(id)
{
if (zoom.getZoomLevel()<dO.space/dO.dividers)
{
var nz = zoom.getZoomLevel()+1;
map.SetZoomLevel(nz);
document.getElementById(id).style.top  = (1*nz*dO.dividers+dO.top)+"px";
}
}

function dragClick(event,id) { var y = event.offsetY ?  event.offsetY : event.layerY; y-=1*dO.top; var scale = 1; for (i=0; i<=dO.space; i+=dO.dividers) { if (y<i) { document.getElementById(id).style.top  = (1*(i-dO.dividers)+dO.top)+"px"; alert (scale); return map.SetZoomLevel(scale); } scale++; } } 

function dragStart(event) { var x = getX(event); var y = getY(event); dO.elNode.style.top  = (dO.elStartTop  + y - dO.cSY) + "px"; if (dO.elStartTop  + y - dO.cSY <dO.top) dO.elNode.style.top  = dO.top+"px"; if (dO.elStartTop  + y - dO.cSY >dO.bottom) dO.elNode.style.top  = dO.bottom+"px"; if (window.event){ window.event.cancelBubble = true; window.event.returnValue = false; } else event.preventDefault(); }

function dragStop(event) { if (window.event) { document.detachEvent("onmousemove", dragStart); document.detachEvent("onmouseup",   dragStop); } else { document.removeEventListener("mousemove", dragStart,   true); document.removeEventListener("mouseup",   dragStop, true); } document.getElementById(dO.cursor).src=dO.off; var t = dO.elNode.style.top.replace ("px",""); var position = t - dO.top; var scale = 0; for (i=0; i<=dO.space; i+=dO.dividers) { if (position<i) { dO.elNode.style.top  = (i+dO.top)+"px"; return map.SetZoomLevel( dO.levels[scale-1]); } scale++; } }

function showStreets() { layermanager.divStatus("streetsdiv",'block'); }
function hideStreets() { layermanager.divStatus("streetsdiv",'none'); }

function showStreets2() { layermanager.divStatus("streets2div",'block'); }
function hideStreets2() { layermanager.divStatus("streets2div",'none'); }

function showInfoWindow(p) { mapmanager.showInfoWindow(p); }

function showlocations (loc,div,url)
{
	mapmanager.requestmanager.div = div;
	layermanager.divStatus(div,"block");
        mapmanager.requestmanager.doRequest ("handleHTMLRequest",url+"?location="+loc);
}

function getexpirydate( nodays){ var UTCstring; Today = new Date(); nomilli=Date.parse(Today); Today.setTime(nomilli+nodays*24*60*60*1000); UTCstring = Today.toUTCString(); return UTCstring; }

function getcookie(cN) { cN = settings.type + cN;

if (0)
{
        if (cN.match("bicon") && !cN.match("bicons"))
        {
        var num = cN.replace ("bicon","");
        var wholevalue  = getcookie ("icons");

        if (wholevalue)
        {
                var wvs = wholevalue.split(":");
        //alert ("look at " + num + " = " + wvs[num-1] + " from " + wholevalue);
                return wvs[num-1];
        }
        }
}

var cS=""+document.cookie; var i1=cS.lastIndexOf(cN); if (i1==-1 || cN=="") return ""; var i2=cS.indexOf(';',i1); if (i2==-1) i2=cS.length; return unescape(cS.substring(i1+cN.length+1,i2)); }


function setcookie(n,v,d){ n = settings.type + n; var cS=n+"="+escape(v)+";EXPIRES="+getexpirydate(d); document.cookie=cS; if(!getcookie(n)){ return false; } else{ return true; } }

function getZoomLevelToFitPositions(a)
{
	var tl_Lat=0; var tl_Lng=20; var br_Lat=90; var br_Lng=-20; var lat; var lng;

	for (i=0; i<a.length; i++)
	{
		lat = 1*a[i].Latitude; lng = 1*a[i].Longitude;
		if (lat>tl_Lat) tl_Lat=lat;
		if (lat<br_Lat) br_Lat=lat;
		if (lng<tl_Lng) tl_Lng=lng;
		if (lng>br_Lng) br_Lng=lng;
	}
	var latNum = tl_Lat-br_Lat;
	var lngNum = Math.abs(br_Lng-tl_Lng);
	var maxLat = 0;
	var maxLng = 0;
	var zoomlevel = 1;
	for (i=5; i<=18; i++)
	{
		maxLat = 1* pixelsLat[i] * map_height;		
		maxLng = 1* pixelsLng[i] * map_width;		
		if (maxLat>latNum && maxLng>lngNum)
		{
//		alert (maxLat + ">" + latNum + " with " + maxLng +  ">" + lngNum + " on level " + i  + "= translated = " + (zoomTranslate[i]+4));
		zoomlevel=zoomTranslate[i]+4;
		}
	}
	return zoomlevel; //zoomTranslate.indexOf(zoomlevel);
}
