var map = null;
var r = null;
function PIN(id,lat,lng,kd,marker,type,image,set,label, newtype,orig_set)
{
this.id=id;
this.icon = null;
if (label)
this.label = label.replace ("AMPERSAND","&");
//if (label) this.label = label + "property";
this.pin = null;
this.photox = null;
this.image = image;
this.click=null;
this.newtype=newtype;
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.orig_set=orig_set;
}
function createNewDiv (name, background, pos, top, left, height,width,innerhtml, zindex,background_repeat)
{
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+")";
if (background_repeat != undefined && background_repeat!="" ) {
//alert(background_repeat);
nd.style.backgroundRepeat = background_repeat;
}
nd.style.position = pos;
nd.innerHTML = innerhtml;
nd.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;
//alert('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.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.onc17-lick=this.click();
this.slider.style.top=sTop+"px";
this.slider.style.left=sLeft+"px";
this.slider.style.zIndex=100;
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= "
";
this.cTop = 0;
this.cLeft = 0;
this.cursor = document.getElementById(cName);
this.highlightLevel(settings.zoomlevel);
}
SLIDER.prototype.highlightLevel = function (level)
{
var c=0;
for(i in this.levels)
{
// alert (this.levels[i] + ">=" + (17-level));
if (this.levels[i]>=(17-level))
{
settings.zoomlevel=level;
// alert ((17-level) + " " + i);
// this.cursor.style.top = (this.divider*(c+1) - this.cursorHeight)+"px";
this.cursor.style.top = this.tops[i] + "px";
return;
}
// alert ("A"+ this.levels[i] + ">=" + (17-level));
c++;
}
// alert ('end' + level);
}
SLIDER.prototype.zoomOut = function ()
{
var c=0;
for(i in this.levels)
{
// alert (this.levels[i]+" " + (17-settings.zoomlevel));
if (this.levels[i]>=17-settings.zoomlevel)
{
if (c0)
{
this.highlightLevel (17-this.levels[c-1]);
map.setZoom (17-this.levels[c-1]);
settings.zoomlevel = 17-this.levels[c-1];
this.cursor.style.top = this.tops[c-1] + "px";
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.setZoom (17-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.setZoom (17-this.levels[which]);
settings.zoomlevel = 17-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);
}
function SETTINGS ()//lat, lng, zoom, highlight)
{
this.loadingText1="1) getting data ";
this.loadingText2="2) processing";
this.loadingText3="3) moving";
this.overviewMap=false;
this.bubbleType="pane";
this.maxLevel = 9;
this.url_thumbnails="thumbnail.php";
this.bubble_url = "restaurant_small.php";
this.bubble_height=200;
this.bubble_width=300;
this.bubblefull_url = "restaurant_large.php";
this.bubblefull_height=400;
this.bubblefull_width=500;
this.photoTimeout=400;
this.icon_width=32;
this.icon_height=22;
this.photomax = 20;
this.photoshowmax = 5;
this.photodistance = 107;
this.photoheight = 75;
this.photowidth = 100;
this.photomove=400;
this.photoenablemove=1;
this.photoleft=30;
this.photomoveincrement=20;
this.photodisplaywidth=600;
this.photodisplaycenter=250;
this.no_populate = false;
this.listview_text = "see in list";
this.trackinform = new Array();
this.trackinformtype = new Array();
this.mirrordivs = new Array();
this.trackinformname = "myform";
this.padding=0;
this.map_height = 200;
this.map_width = 200;
this.showScale=true;
this.statusPrefix = "";
this.multiplier = new Array(0,1,1,1,1,1,1,1,1,1,1,1,1,1,3,1,1);
this.showInfo = new Array();
this.showInfo["restaurants"]= new Array();
this.showInfo["restaurants"]["single"] = "restaurant";
this.showInfo["restaurants"]["plural"] = "restaurants";
this.showInfo["properties"]= new Array();
this.showInfo["properties"]["single"] = "property";
this.showInfo["properties"]["plural"] = "properties";
this.showInfo["schools"]= new Array();
this.showInfo["schools"]["single"] = "school";
this.showInfo["schools"]["plural"] = "schools";
this.showInfo["trains"]= new Array();
this.showInfo["trains"]["single"] = "train";
this.showInfo["trains"]["plural"] = "trains";
this.showInfo["offices"]= new Array();
this.showInfo["offices"]["single"] = "office";
this.showInfo["offices"]["plural"] = "offices";
this.fullUrls = new Array();
this.fullUrls["properties"] = "../panes/pane_property.php";
this.fullUrls["schools"] = "../panes/pane_school.php";
this.minZoom=3;
this.maxZoom=8;
this.copyright = " ";//
";
this.image_greyout = "";
this.type = param("type");
this.lng = param("lng");
this.lat = param("lat");
//alert (this.lat + "," + this.lng);
this.postcode = param("postcode");
if (param("level"))
this.zoomlevel = 17 - 1 * param("level");
else
this.zoomlevel = 17 - 1 * param("zoom");
this.highlight = param("highlight");
this.url_mapdata = "populate_map.php";
this.url_postcodecheck = "postcode_check.php";
this.url_properties= "please define";
this.url_schools= "please define";
this.url_offices= "please define";
this.trackimage=true;
this.mirror_numbers=true;
}
SETTINGS.prototype.alterShowInfo = function (name,sing,value) { this.showInfo[name][sing] = value};
SETTINGS.prototype.addArray = function (field,value) { eval ("this."+field+"[this."+field+".length]='"+value+"'")};
SETTINGS.prototype.modify = function (field,value) { eval ("this."+field+"='"+value+"'")};
var settings = new SETTINGS();
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.photol=0;}
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'); map.closeInfoWindow(); layermanager.divStatus("cuisinediv","none"); layermanager.divStatus("areadiv","none");}
LAYERMANAGER.prototype.setDivContent =function (thediv, content) {
if (!document.getElementById(thediv)) return;
document.getElementById(thediv).innerHTML=content; if(typeof propertyFunctionOnload == 'function') { propertyFunctionOnload(thediv, content);}}
LAYERMANAGER.prototype.appendDivContent = function (thediv, content) { i
if (!document.getElementById(thediv)) return;
document.getElementById(thediv).innerHTML+=content; }
LAYERMANAGER.prototype.divStatus = function (thediv,status) {
//console.log(thediv);
document.getElementById(thediv).style.display=status;
}
LAYERMANAGER.prototype.divCoordinates = function (thediv,x,y) {
document.getElementById(thediv).style.left=(x+20)+"px"; document.getElementById(thediv).style.top=(y+20)+"px"; }
var layermanager = new LAYERMANAGER();
function REQUESTMANAGER() { this.r=null;}
REQUESTMANAGER.prototype.postcodeRequest = function ()
{
if (this.r.readyState == 4)
{
var rD = this.r.responseXML;
if (rD.documentElement)
{
var pc = rD.documentElement.getElementsByTagName('postcode');
if (pc.length>0)
{
var lat = pc[0].getAttribute('lat');
var lng = pc[0].getAttribute('lng');
if (lat)
{
map.panTo(new GLatLng(lat,lng));
}
else
{
alert ("Sorry, we couldn't match the postcode");
// layermanager.divStatus("status","block");
// layermanager.setDivContent("status","not found");
}
}
}
}
}
REQUESTMANAGER.prototype.handleHTMLRequest = function () { if (this.r.readyState == 4) { layermanager.setDivContent(this.div, this.r.responseText); if (this.div=="rolloverdiv") { clearTimeout(layermanager.timer); layermanager.timer= setTimeout("layermanager.divStatus('rolloverdiv','none')",5000); } } }
REQUESTMANAGER.prototype.handleRequest = function ()
{
if (this.r.readyState == 4)
{
for (i in settings.showInfo) settings.showInfo[i]["nos"]=0;
var rD = this.r.responseXML;
if (rD.documentElement)
{
mapmanager.loadElement (rD);
layermanager.setDivContent("status", settings.loadingText2);
var te = rD.documentElement.getElementsByTagName('total');
var n = 0;
for (i=0; i=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)
}
}
function gptr () {
var b=map.getBounds(); var sw = b.getSouthWest(); var ne = b.getNorthEast();
return "&x1="+sw.lng()+"&y1="+ sw.lat() + "&x2="+ne.lng() + "&y2="+ ne.lat() + "&map_height="+settings.map_height+"&map_width="+settings.map_width;
}
LAYERMANAGER.prototype.showIcon = function(id, current)
{
recordStat("bubble");
current++;
mapmanager.pins[id].pin.openInfoWindowHtml('');
return false;
}
MAPMANAGER.prototype.plot=function ()
{
// layermanager.setDivContent ('status','plotting...');
layermanager.setDivContent("status",settings.loadingText3);
try {
freeze_map();
}
catch(err) {
//console.log('no_function', err);
}
var txt=settings.statusPrefix;
var comma="";
var desc="";
var props=0;
for (i in settings.showInfo) { if (i) { desc = settings.showInfo[i]["nos"]==1 ? settings.showInfo[i]["single"] : settings.showInfo[i]["plural"]; if (settings.showInfo[i]["nos"]>0) { txt+= comma + settings.showInfo[i]["nos"] + " " + desc; comma=", "; if(i=="properties") props=settings.showInfo[i]["nos"]; } }
}
if(txt!=settings.statusPrefix) txt += settings.listview_text;
if(props) txt += ""+settings.listview_button+"";
layermanager.setDivContent("listviewdiv", txt);
var c=0;
for (i in this.pins) //
-"+this.pins2[i].lat+","+this.pins2[i].lng+"
"+i);
this.pins[i] = this.pins2[i]; //swap over
this.pins2[i]=null;
}
else
{
var pos1= new GLatLng((this.pins[i].lat), (this.pins[i].lng));
var o = new Object();
if (this.pins[i].newtype)
o.icon=this.icons[this.pins[i].newtype];
else
o.icon=this.icons[this.pins[i].type];
o.title=this.pins[i].label;
this.pins[i].pin=new GMarker (pos1, o);
var p = this.pins[i].pin;
//alert (this.pins[i].type);
if (settings.bubbleType=="pane")
eval ('this.pins[i].click=GEvent.addListener(this.pins[i].pin, "click", function() { if (mapmanager.'+this.pins[i].set+'Click) mapmanager.'+this.pins[i].set+'Click("'+i+'"); recordStat("bubble"); mapmanager.openPane("'+this.pins[i].id+'","'+this.pins[i].set+'");})');
if (settings.bubbleType=="google") {
//added original set if icons from multiple query sets
eval ('this.pins[i].click=GEvent.addListener(this.pins[i].pin, "click", function() { recordStat("bubble");setTimeout(\'mapmanager.highlightPhoto("'+i+'",1)\',2000); mapmanager.pins["'+i+'"].pin.openInfoWindowHtml(\'\');}) ');
}
eval ('this.pins[i].mouseover=GEvent.addListener(this.pins[i].pin, "mouseover", function() { mapmanager.highlightPhoto("'+i+'",1);}) ');
map.addOverlay (this.pins[i].pin);
}
c++;
}
layermanager.divStatus ('loading','none');
this.loading=false;
for (i in this.pins2) //mapboundary.tLLat) return true;
if (latmapboundary.bRLng) return true;
return false;
}
MAPMANAGER.prototype.removeOutOfBounds=function () { for (i in this.pins) { if (this.outOfBounds(this.pins[i].lat, this.pins[i].lng)) { map.removeOverlay (this.pins[i].pin); if (this.pins[i].click) GEvent.removeListener(this.pins[i].click); if (this.pins[i].mouseover) GEvent.removeListener(this.pins[i].mouseover);this.pins[i]=null; } } }
MAPMANAGER.prototype.formTracker = function (savecookie)
{
var r = "";
var c = "";
var e = "";
for (i=0; i
");
this.photoshowing++;
}
}
}
}
}
var mapmanager = new MAPMANAGER();
function init()
{
recordStat("init");
layermanager.setDivContent("photocontainer", "loading ");
//alert (settings.zoomlevel);
if (GBrowserIsCompatible())
{
map = new GMap2(document.getElementById("map"));
if (settings.overviewMap)
{ map.addControl(new GOverviewMapControl(new GSize(150, 150))); var omap=document.getElementById("map_overview"); var mapdiv =document.getElementById("map"); omap.style.position = "relative"; omap.style.right = "0px"; omap.style.bottom = "8px"; mapdiv.appendChild(omap);}
map.setCenter(new GLatLng(settings.lat, settings.lng), settings.zoomlevel);
}
GEvent.addListener(map, "moveend", moveend)
GEvent.addListener(map, "movestart", movestart)
GEvent.addListener(map, "zoomend", zoomend)
//map.addControl(new TextualZoomControl());
mapmanager.loadCookies();
if (settings.no_populate!="true") mapmanager.populate();
if (settings.trackimage=="true") layermanager.movePhoto("0",0,0);
if (settings.postcode) mapmanager.checkPostcode(settings.postcode);
// var geocoder = new GClientGeocoder();
// geocoder.getLatLng("18 Glen Road, Fleet, UK",function (point) {alert (point)});
// geocoder.getLatLng("1600 Amphitheatre Parkway, Mountain View, CA, USA",function (point) {alert (point)});
}
function zoomend() { recordStat("zoom");mapmanager.loading=true; mapmanager.doZoom(); }
function movestart() { layermanager.divStatus("status","block"); layermanager.setDivContent("status",settings.loadingText3);recordStat("pan");}
function moveend() {if (mapmanager.loading) return; mapmanager.populate(); }
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";
}
document.write ("");
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)); }
//added in path so cookie valid over whole domain
function setcookie(n,v,d){ n = settings.type + n;
var cS=n+"="+escape(v)+";EXPIRES="+getexpirydate(d)+";path=/";
//console.log(cS);
document.cookie=cS; if(!getcookie(n)){ return false; } else{ return true; } }
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 showlocations (loc,div,url)
{
mapmanager.requestmanager.div = div;
layermanager.divStatus(div,"block");
mapmanager.requestmanager.doRequest ("handleHTMLRequest",url+"?location="+loc);
}
function csb (min_level, max_level) { var scaleGraphics=''; var graphic = ""; var temp_height = scale_icon_height; var vspace=0; var md = 17-max_level; for (i=17-min_level; i>=md; i--) { graphic = cl==i ? scale_on_icon : scale_off_icon; scaleGraphics += "
"; temp_height-=2; vspace+=1; } var previous = cl; if (od!=md || cl!=ol) slb ("scale","
" + scaleGraphics + "
"); od = md; ol = cl; }
function SCALEBARS (div, levels, start_level, onoff_graphics, plus_onoff_graphics, minus_onoff_graphics,vspace)
{
this.div=div;
this.levels = levels
this.level = start_level;
this.onoff_graphics = onoff_graphics;
this.plus_onoff_graphics = plus_onoff_graphics;
this.minus_onoff_graphics = minus_onoff_graphics;
this.vspace = vspace;
this.refresh();
}
SCALEBARS.prototype.zoom = function (which)
{
var clevel = 17-settings.zoomlevel;
for (i=0; i
";
}
SCALEBARS.prototype.refresh = function ()
{
var inner = "| "+this.zoomIcons("plus","click to zoom in")+" | ";
for (i=0; i ";
}
inner += " | "+this.zoomIcons("minus", "click to zoom out")+" |
";
document.getElementById(this.div).innerHTML=inner;
eval("document.images.imglevel"+this.level+".src=this.onoff_graphics[1]");
}
function googleMapInsertSmall(width, height, lat, lng, level, name) { level=17-level;document.write ("
please wait... map loading
"); setTimeout("googleMapInsertSmall2(" + lat + "," + lng + "," + level + ",'"+ name +"',false)",800); }
function googleMapInsertSmallWithOverview(width, height, lat, lng, level, name) { level=17-level;document.write ("
please wait... map loading
"); setTimeout("googleMapInsertSmall2(" + lat + "," + lng + "," + level + ",'"+ name +"',true)",800); }
function googleMapInsertSmall2(lat,lng, level, name, overview) { map = new GMap2(document.getElementById("map")); if (settings.hybrid) map.addControl(new GMapTypeControl());
if (settings.zm) map.addControl(new GSmallMapControl());
if (overview)
{ map.addControl(new GOverviewMapControl(new GSize(150, 150))); var omap=document.getElementById("map_overview"); var mapdiv =document.getElementById("map"); omap.style.position = "relative"; omap.style.right = "0px"; omap.style.bottom = "8px"; mapdiv.appendChild(omap);}
map.setCenter(new GLatLng(lat,lng), level); map.addOverlay(new GMarker (new GLatLng(lat, lng),mapmanager.icons[name])); recordStat("small"); }
function flashZoomToNewLevel(level) {
if (!level || !map) return;
// 17 = 1 16 = 2 15 = 3 14 = 4 14 = 5
if(settings.zoomlevel!=level){
settings.zoomlevel=level;
map.setZoom (17 - settings.zoomlevel);
}
}