﻿function initPage(){hmui=new HMUI();hmui.bn=hmui.e("hmID").innerHTML;hmui.bo=hmui.e("verDiv").innerHTML;hmui.cx();hmui.T();hmui.previewClick();};function closePage(){GUnload();};var hmui=null;function HMUI(){this.map=null;this.bn="";this.bo="";this.r=[];this.mapHeight=720;this.x= -73.986182;this.y=40.756683;this.z=15;this.mapType=0;this.wheelScroll=0;this.googleBar=0;this.topMargin=0;this.headerRows=1;this.googleEarthLayer=0;this.panMarkerStyle=1;this.panSidebarStyle=1;this.panOrder=0;this.panPageSize=25;this.panImageSize=1;this.trafficLayer=1;this.streetviewLayer=1;this.weatherOption=1;this.slideshowOption=1;this.eb="";this.dE=1;};HMUI.prototype.e=function(a){return document.getElementById(a);};HMUI.prototype.ff=function(a){GLog.write(a);};HMUI.prototype.aw=function(pFloat,pDp){var m=Math.pow(10,pDp);return parseInt(pFloat*m,10)/m;};HMUI.prototype.locKeyPress=function(bU){var bp=bU.keyCode;if(bp==13){gotoLocation();return false;}return true;};HMUI.prototype.gotoLocation=function(){var x=parseFloat(this.e("xLoc").value);var y=parseFloat(this.e("yLoc").value);var z=parseFloat(this.e("zLoc").value);map.setCenter(new GLatLng(y,x),z);};HMUI.prototype.geoKeyPress=function(bU){var bp=bU.keyCode;if(bp==13){this.geocodeFind();return false;}return true;};HMUI.prototype.geocodeFind=function(){var bs=this.e("geocodeName").value;var bc=new GClientGeocoder(new GGeocodeCache());bc.getLatLng(bs,function(bl){var B=[];B[G_GEO_SUCCESS]="Success";B[G_GEO_MISSING_ADDRESS]="Missing Address: The address was either missing or had no value.";B[G_GEO_UNKNOWN_ADDRESS]="Unknown Address:  No corresponding geographic location could be found for the specified address.";B[G_GEO_UNAVAILABLE_ADDRESS]="Unavailable Address:  The geocode for the given address cannot be returned due to legal or contractual reasons.";B[G_GEO_BAD_KEY]="Bad Key: The API key is either invalid or does not match the domain for which it was given";B[G_GEO_TOO_MANY_QUERIES]="Too Many Queries: The daily geocoding quota for this site has been exceeded.";B[G_GEO_SERVER_ERROR]="Server error: The geocoding request could not be successfully processed.";if(bl){map.setCenter(bl);hmui.ar(true);}else{var I=bc.getCache().get(bs);var aU="";if(I){var aU="Error "+I.Status.code+" : ";if(B[I.Status.code]){aU+=B[I.Status.code];}alert(aU);}}});};function HFeed(){this.cR="";this.G="";this.ac="";};HMUI.prototype.addFeedClick=function(){var d=new HFeed();d.cR=this.e("feedUrl").value;d.G=this.e("feedTitle").value;d.ac=this.e("feedColour").value;this.r.push(d);this.e("feedUrl").value="";this.e("feedTitle").value="";this.e("feedColour").value="";this.T();};HMUI.prototype.resetFeedClick=function(){this.r=[];this.T();};HMUI.prototype.T=function(){var f="<table cellspacing=4 cellpadding=4 style='width:100%; border:solid 1px black'><tr style='color:white;background-color:gray;font-weight:bold'><td align='center' style='width:100%'>";var s=this.r.length==1?"":"s";f+=this.r.length+" feed"+s+" defined";if(this.r.length>0){f+=" &nbsp;&nbsp;<input type='button' onclick='hmui.resetFeedClick()' value='Reset' style='color:darkred' />";}f+="</td></tr><tr><td>";for(var i=0;i<this.r.length;i++){var d=this.r[i];f+="<table style='width:100%;border:solid 1px black'><tr><td style='font-weight:bold;color:"+d.ac+"'>"+d.G+"</td>";f+="<td style='width:100px;border:solid 1px black;background-color:gainsboro;font-weight:bold;cursor:pointer' onmouseover='hmui.controlHi(this)' onmouseout='hmui.controlLo(this)' onclick='hmui.feedUp("+i+")' align='center'>Move Up</td>";f+="<td style='width:100px;border:solid 1px black;background-color:gainsboro;font-weight:bold;cursor:pointer' onmouseover='hmui.controlHi(this)' onmouseout='hmui.controlLo(this)' onclick='hmui.feedDown("+i+")' align='center'>Move Down</td>";f+="<td style='width:100px;border:solid 1px black;background-color:gainsboro;font-weight:bold;color:darkred;cursor:pointer' onmouseover='hmui.controlHi(this)' onmouseout='hmui.controlLo(this)' onclick='hmui.feedDelete("+i+")' align='center'>Delete</td>";f+="</tr><tr><td colspan='4'>";f+=d.cR+"</td></tr></table>";f+="</td></tr><tr><td>";}f+="</td></tr></table>";this.e("feedDisplay").innerHTML=f;};HMUI.prototype.controlHi=function(a){a.style.backgroundColor="dodgerblue";};HMUI.prototype.controlLo=function(a){a.style.backgroundColor="gainsboro";};HMUI.prototype.feedUp=function(a){if(a>0){var dS=this.r[a-1];var cf=this.r[a];this.r[a-1]=cf;this.r[a]=dS;}this.T();};HMUI.prototype.feedDown=function(a){if(a<this.r.length-1){var eg=this.r[a+1];var cf=this.r[a];this.r[a+1]=cf;this.r[a]=eg;}this.T();};HMUI.prototype.feedDelete=function(a){for(var i=a;i<this.r.length;i++){this.r[i]=this.r[i+1];}this.r.length--;this.T();};HMUI.prototype.cx=function(){var da=this.e("mapDiv");var eE=new GLatLng(this.y,this.x);map=new GMap2(da);map.addControl(new GSmallMapControl());map.addControl(new GMapTypeControl());map.enableDoubleClickZoom();map.enableContinuousZoom();map.setCenter(eE,this.z);map.setMapType(G_NORMAL_MAP);GEvent.addListener(map,"moveend",function(){hmui.ar(true);});this.ar(false);};HMUI.prototype.ar=function(){var aX=map.getCenter();var x=aX.lng();var y=aX.lat();var z=map.getZoom();hmui.e("xMap").value=hmui.aw(x,7);hmui.e("yMap").value=hmui.aw(y,7);hmui.e("zMap").value=z;};HMUI.prototype.xyzView=function(){var x=parseFloat(this.e("xMap").value);var y=parseFloat(this.e("yMap").value);var z=parseInt(this.e("zMap").value);if(isNaN(x)){alert("invalid x value : "+this.e("xMap").value);}else if(isNaN(y)){alert("invalid y value : "+this.e("yMap").value);}else if(isNaN(z)){alert("invalid z value : "+this.e("zMap").value);}else{map.setCenter(new GLatLng(y,x),z);}};HMUI.prototype.dx=function(){var C="";C+="hmap.x="+this.x+"\r\n";C+="hmap.y="+this.y+"\r\n";C+="hmap.z="+this.z+"\r\n";C+="hmap.mapType="+this.mapType+"\r\n";C+="hmap.wheelScroll="+this.wheelScroll+"\r\n";C+="hmap.googleBar="+this.googleBar+"\r\n";C+="hmap.headerRows="+this.headerRows+"\r\n";C+="hmap.googleEarthLayer="+this.googleEarthLayer+"\r\n";C+="hmap.topMargin="+this.topMargin+"\r\n";C+="hmap.panPageSize="+this.panPageSize+"\r\n";C+="hmap.panMarkerStyle="+this.panMarkerStyle+"\r\n";C+="hmap.panSidebarStyle="+this.panSidebarStyle+"\r\n";C+="hmap.panOrder="+this.panOrder+"\r\n";C+="hmap.panImageSize="+this.panImageSize+"\r\n";C+="hmap.trafficLayer="+this.trafficLayer+"\r\n";C+="hmap.streetviewLayer="+this.streetviewLayer+"\r\n";C+="hmap.weatherOption="+this.weatherOption+"\r\n";C+="hmap.slideshowOption="+this.slideshowOption+"\r\n\r\n";C+="var myFeeds=[\r\n";for(var i=0;i<this.r.length;i++){var d=this.r[i];C+="[\""+d.cR+"\",\""+d.G+"\",\""+d.ac+"\"]";if(i<this.r.length-1){C+=",";}C+="\r\n";}C+="]\r\n\r\nhmap.initHMap(myFeeds);\r\n\r\n";this.eb=C;};HMUI.prototype.ds=function(){var by="hmsave.aspx?id="+this.bn;GDownloadUrl(by,hmui.cS,this.eb);};HMUI.prototype.cS=function(fl){var bD=hmui.e("scriptText").value;hmui.e("previewDiv").innerHTML=bD;};HMUI.prototype.previewClick=function(){this.x=parseFloat(this.e("xMap").value);this.y=parseFloat(this.e("yMap").value);this.z=parseInt(this.e("zMap").value);this.mapType=this.e("gmType").selectedIndex;this.mapHeight=parseInt(this.e("pxHeight").value);this.wheelScroll=this.e("mousewheelSelect").selectedIndex==0?0:1;this.googleBar=this.e("googlebarSelect").selectedIndex==0?0:1;this.headerRows=this.e("headerRowsSelect").selectedIndex+1;this.googleEarthLayer=this.e("geSelect").selectedIndex==0?0:1;this.panSidebarStyle=this.e("panSidebarSelect").selectedIndex;this.panMarkerStyle=this.e("panMarkerSelect").selectedIndex;this.panOrder=this.e("panOrderSelect").selectedIndex;switch(this.e("panPageSizeSelect").selectedIndex){default:this.panPageSize=25;break;case 1:this.panPageSize=50;break;case 2:this.panPageSize=100;break;}this.panImageSize=this.e("panImageSizeSelect").selectedIndex;this.streetviewLayer=this.e("streetviewSelect").selectedIndex;this.trafficLayer=this.e("trafficSelect").selectedIndex;this.weatherOption=this.e("weatherSelect").selectedIndex;this.slideshowOption=this.e("slideshowSelect").selectedIndex;if(isNaN(this.x)){alert("invalid x value : "+this.e("xMap").value);return;}if(isNaN(this.y)){alert("invalid y value : "+this.e("yMap").value);return;}if(isNaN(this.z)){alert("invalid zoom value : "+this.e("zMap").value);return;}if(isNaN(this.mapHeight)){alert("invalid height value : "+this.e("pxHeight").value);return;}var bD="<iframe  style=\"width:100%;height:"+this.mapHeight+"px;padding:0;border:solid 1px black\" "+"src=\""+this.bo+"?data="+this.bn+"&v="+this.dE+"\" "+"marginwidth=\"0\" marginheight=\"0\" frameborder=\"0\" scrolling=\"no\"></iframe>";this.e("scriptText").value=bD;hmui.e("customFile1").innerHTML="<a target='_blank' href='http://data.mapchannels.com/hm/data/"+this.bn+".js' style='color:Green;text-decoration:underline'>http://data.mapchannels.com/hm/data/"+this.bn+".js</a>";hmui.e("customFile2").innerHTML="<b>&lt;div id='hmapData' style='display:none'&gt;"+this.bn+".js&lt;/div&gt;</b>";hmui.e("customFile3").innerHTML="<a target='_blank' href='http://data.mapchannels.com/hm/data/"+this.bn+".js' style='color:Green;text-decoration:underline'>"+this.bn+".js</a>";this.dE++;this.dx();this.ds();}