﻿var veui;function initPage(){veui=new VEUI();veui.aZ=veui.e("veID").innerHTML;veui.aX=veui.e("verDiv").innerHTML;veui.bC();veui.am();veui.previewClick();};function closePage(){GUnload();};var veui=null;function VEUI(){this.map=null;this.aZ="";this.aX="";this.ad=[];this.mapHeight=720;this.x= -118.493556;this.y=34.013467;this.z=14;this.mapType=0;this.wheelScroll=1;this.topMargin=0;this.mode3d=1;this.mode3dOn=0;this.searchOn=1;this.trafficOn=0;this.pitch= -45;this.heading=0;this.altitude=10000;this.feedBounds=0;this.sidebarWidth=250;this.sidebarVisible=1;this.cK="";this.cw=1;};VEUI.prototype.e=function(a){return document.getElementById(a);};VEUI.prototype.dL=function(a){GLog.write(a);};VEUI.prototype.av=function(pFloat,pDp){var m=Math.pow(10,pDp);return parseInt(pFloat*m,10)/m;};VEUI.prototype.locKeyPress=function(bp){var aY=bp.keyCode;if(aY==13){gotoLocation();return false;}return true;};VEUI.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);};VEUI.prototype.geoKeyPress=function(bp){var aY=bp.keyCode;if(aY==13){this.geocodeFind();return false;}return true;};VEUI.prototype.geocodeFind=function(){var cA=this.e("geocodeName").value;var cq=new GClientGeocoder(new GGeocodeCache());cq.getLatLng(cA,function(bn){var aw=[];aw[G_GEO_SUCCESS]="Success";aw[G_GEO_MISSING_ADDRESS]="Missing Address: The address was either missing or had no value.";aw[G_GEO_UNKNOWN_ADDRESS]="Unknown Address:  No corresponding geographic location could be found for the specified address.";aw[G_GEO_UNAVAILABLE_ADDRESS]="Unavailable Address:  The geocode for the given address cannot be returned due to legal or contractual reasons.";aw[G_GEO_BAD_KEY]="Bad Key: The API key is either invalid or does not match the domain for which it was given";aw[G_GEO_TOO_MANY_QUERIES]="Too Many Queries: The daily geocoding quota for this site has been exceeded.";aw[G_GEO_SERVER_ERROR]="Server error: The geocoding request could not be successfully processed.";if(bn){map.setCenter(bn);veui.aG(true);}else{var aW=cq.getCache().get(cA);var ca="";if(aW){var ca="Error "+aW.Status.code+" : ";if(aw[aW.Status.code]){ca+=aw[aW.Status.code];}alert(ca);}}});};function VFeed(){this.bl="";this.ar="";this.ap="";};VEUI.prototype.addFeedClick=function(){var ab=new VFeed();ab.bl=this.e("feedUrl").value;ab.ar=this.e("feedTitle").value;ab.ap=this.e("feedColour").value;this.ad.push(ab);this.e("feedUrl").value="";this.e("feedTitle").value="";this.e("feedColour").value="";this.am();};VEUI.prototype.resetFeedClick=function(){this.ad=[];this.am();};VEUI.prototype.am=function(){var aa="<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.ad.length==1?"":"s";aa+=this.ad.length+" feed"+s+" defined";if(this.ad.length>0){aa+=" &nbsp;&nbsp;<input type='button' onclick='veui.resetFeedClick()' value='Reset' style='color:darkred' />";}aa+="</td></tr><tr><td>";for(var i=0;i<this.ad.length;i++){var ab=this.ad[i];aa+="<table style='width:100%;border:solid 1px black'><tr><td style='font-weight:bold;color:"+ab.ap+"'>"+ab.ar+"</td>";aa+="<td style='width:100px;border:solid 1px black;background-color:gainsboro;font-weight:bold;cursor:pointer' onmouseover='veui.controlHi(this)' onmouseout='veui.controlLo(this)' onclick='veui.feedUp("+i+")' align='center'>Move Up</td>";aa+="<td style='width:100px;border:solid 1px black;background-color:gainsboro;font-weight:bold;cursor:pointer' onmouseover='veui.controlHi(this)' onmouseout='veui.controlLo(this)' onclick='veui.feedDown("+i+")' align='center'>Move Down</td>";aa+="<td style='width:100px;border:solid 1px black;background-color:gainsboro;font-weight:bold;color:darkred;cursor:pointer' onmouseover='veui.controlHi(this)' onmouseout='veui.controlLo(this)' onclick='veui.feedDelete("+i+")' align='center'>Delete</td>";aa+="</tr><tr><td colspan='4'>";aa+=ab.bl+"</td></tr></table>";aa+="</td></tr><tr><td>";}aa+="</td></tr></table>";this.e("feedDisplay").innerHTML=aa;};VEUI.prototype.controlHi=function(a){a.style.backgroundColor="dodgerblue";};VEUI.prototype.controlLo=function(a){a.style.backgroundColor="gainsboro";};VEUI.prototype.feedUp=function(a){if(a>0){var cH=this.ad[a-1];var bw=this.ad[a];this.ad[a-1]=bw;this.ad[a]=cH;}this.am();};VEUI.prototype.feedDown=function(a){if(a<this.ad.length-1){var cU=this.ad[a+1];var bw=this.ad[a];this.ad[a+1]=bw;this.ad[a]=cU;}this.am();};VEUI.prototype.feedDelete=function(a){for(var i=a;i<this.ad.length;i++){this.ad[i]=this.ad[i+1];}this.ad.length--;this.am();};VEUI.prototype.bC=function(){var aT=this.e("mapDiv");var dg=new GLatLng(this.y,this.x);map=new GMap2(aT);map.addControl(new GSmallMapControl());map.addControl(new GMapTypeControl());map.enableDoubleClickZoom();map.enableContinuousZoom();map.setCenter(dg,this.z);map.setMapType(G_NORMAL_MAP);GEvent.addListener(map,"moveend",function(){veui.aG(true);});this.aG(false);};VEUI.prototype.aG=function(){var bt=map.getCenter();var x=bt.lng();var y=bt.lat();var z=map.getZoom();veui.e("xMap").value=veui.av(x,7);veui.e("yMap").value=veui.av(y,7);veui.e("zMap").value=z;};VEUI.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);}};VEUI.prototype.cu=function(){var ag="";ag+="vMC.x="+this.x+"\r\n";ag+="vMC.y="+this.y+"\r\n";ag+="vMC.z="+this.z+"\r\n";ag+="vMC.mapType="+this.mapType+"\r\n";ag+="vMC.wheelScroll="+this.wheelScroll+"\r\n";ag+="vMC.mode3d="+this.mode3d+"\r\n";ag+="vMC.mode3dOn="+this.mode3dOn+"\r\n";ag+="vMC.pitch="+this.pitch+"\r\n";ag+="vMC.heading="+this.heading+"\r\n";ag+="vMC.altitude="+this.altitude+"\r\n";ag+="vMC.topMargin="+this.topMargin+"\r\n";ag+="vMC.trafficOn="+this.trafficOn+"\r\n";ag+="vMC.searchOn="+this.searchOn+"\r\n";ag+="vMC.feedBounds="+this.feedBounds+"\r\n";ag+="vMC.sidebarWidth="+this.sidebarWidth+"\r\n";ag+="vMC.sidebarVisible="+this.sidebarVisible+"\r\n";ag+="var myFeeds=[\r\n";for(var i=0;i<this.ad.length;i++){var ab=this.ad[i];ag+="[\""+ab.bl+"\",\""+ab.ar+"\",\""+ab.ap+"\"]";if(i<this.ad.length-1){ag+=",";}ag+="\r\n";}ag+="]\r\n\r\nvMC.initVMC(myFeeds);\r\n\r\n";this.cK=ag;};VEUI.prototype.cn=function(){var bL="vesave.aspx?id="+this.aZ;GDownloadUrl(bL,veui.bN,this.cK);};VEUI.prototype.bN=function(dU){var bf=veui.e("scriptText").value;veui.e("previewDiv").innerHTML=bf;};VEUI.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.mode3d=this.e("mode3dSelect").selectedIndex==0?0:1;this.mode3dOn=this.e("mode3dOnSelect").selectedIndex==0?0:1;this.heading=parseInt(this.e("headingText").value);this.pitch=parseInt(this.e("pitchText").value);this.altitude=parseInt(this.e("altitudeText").value);this.trafficOn=this.e("trafficSelect").selectedIndex==0?0:1;this.searchOn=this.e("searchSelect").selectedIndex==0?0:1;this.feedBounds=this.e("feedBoundsSelect").selectedIndex==0?0:1;this.sidebarWidth=parseInt(this.e("sidebarWidthText").value);if(this.sidebarWidth<250){this.sidebarWidth=250;}this.sidebarVisible=this.e("sidebarVisibleSelect").selectedIndex==0?0:1;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 bf="<iframe  style=\"width:100%;height:"+this.mapHeight+"px;padding:0;border:solid 1px black\" "+"src=\""+this.aX+"?data="+this.aZ+"&v="+this.cw+"\" "+"marginwidth=\"0\" marginheight=\"0\" frameborder=\"0\" scrolling=\"no\"></iframe>";this.e("scriptText").value=bf;veui.e("customFile1").innerHTML="<a target='_blank' href='http://data.mapchannels.com/ve/data/"+this.aZ+".js' style='color:Green;text-decoration:underline'>http://data.mapchannels.com/ve/data/"+this.aZ+".js</a>";veui.e("customFile2").innerHTML="<b>&lt;div id='VMCData' style='display:none'&gt;"+this.aZ+".js&lt;/div&gt;</b>";veui.e("customFile3").innerHTML="<a target='_blank' href='http://data.mapchannels.com/ve/data/"+this.aZ+".js' style='color:Green;text-decoration:underline'>"+this.aZ+".js</a>";this.cw++;this.cu();this.cn();}