﻿var trm;var map;function TripMap(){this.ak=[];this.aZ=[];this.bJ=[];this.ao=[];this.B=[];this.ae=[];this.o=null;this.Q=null;this.as=null;this.R=[true,true,true,true,true];this.ai="";this.ab=null;this.bN=false;this.ad=null;this.aj=false;};function loadPage(){trm=new TripMap();trm.bt();trm.bq();trm.bs();trm.L();};function unloadPage(){GUnload();};TripMap.prototype.bs=function(){for(var i=0;i<basegrid.length;i++){var t=new Cell();t.bv(basegrid[i]);this.bJ.push(t);this.ao[t.am]=t;}};TripMap.prototype.by=function(x,y){var nx=x.toString();while(nx.length<3){nx="0"+nx;}var ny=y.toString();while(ny.length<3){ny="0"+ny;}return ny+nx;};function Cell(){this.am="";this.bE= -1;this.ac=[];};Cell.prototype.bv=function(a){this.am=a[0];this.bE=a[1];};Cell.prototype.bu=function(){var aA="grid/"+this.am+".js?v=1";var aR=new JSON(aA);aR.bI();aR.bH();};function loadPlaces(a){var bi=a[0];var aL=a[1];var t=trm.ao[bi];var aC=aL.length;for(var i=0;i<aC;i++){var c=new Place(aL[i]);if(!trm.ae[c.id]){t.ac.push(c);trm.ae[c.id]=c;}}trm.L();};TripMap.prototype.bq=function(){var j="";for(var i=0;i<cities.length;i++){var g=new City(cities[i]);if(g.x&&g.y){this.ak.push(g);this.aZ[g.id]=g;}}};function City(a){this.id=a[0];this.D=a[1];this.af=this.D.toLowerCase();this.x=a[2];this.y=a[3];this.C=new GLatLng(this.y,this.x);this.bj=new GLatLng(a[5],a[4]);this.bL=new GLatLng(a[7],a[6]);this.an=new GLatLngBounds(this.bj,this.bL);this.l=null;this.bw=a[0].substr(0,2);this.be=0;this.aa=document.createElement("div");this.aa.innerHTML="<div id='r"+this.id+"' class='plrow' onclick='cityClick(\""+this.id+"\",0)' onmouseover='rowHi(this)' onmouseout='rowLo(this)'>"+"<img src='img/markers/d/red.png' height=11 width=11 /> <b>"+this.D+"</b> &nbsp;"+this.bw+"</div>";};City.prototype.ap=function(){if(this.bO>6){return;}var g=this;var f=new GIcon();f.image="img/markers/d/red.png";f.iconSize=new GSize(11,11);f.printImage=f.image;f.mozPrintImage=f.image;f.iconAnchor=new GPoint(6,6);f.infoWindowAnchor=new GPoint(6,6);var A=new GMarker(this.C,{"icon":f});map.addOverlay(A);this.l=A;this.at=this.D;this.I=0;GEvent.addListener(A,'click',function(bM){g.P(true);});GEvent.addListener(A,"mouseover",function(){trm.aI(g,6,-6);});GEvent.addListener(A,"mouseout",function(){trm.aH();});};City.prototype.az=function(){if(this.l){this.l.show();}else{this.ap();}};City.prototype.ah=function(){if(this.l){this.l.hide();}};function cityZoom(){var g=trm.Q;if(g){var J=g.an.getCenter();var k=map.getBoundsZoomLevel(g.an);if(k>16){k=16;}if(k<11){k=11;}map.setCenter(J,k);}map.closeInfoWindow();};TripMap.prototype.L=function(){var k=map.getZoom();var F=map.getBounds();var bd=F.getNorthEast();var aQ=F.getSouthWest();var aK=parseInt(aQ.lng()+180);var aJ=parseInt(aQ.lat()+90);var aN=parseInt(bd.lng()+180.0);var aO=parseInt(bd.lat()+90.0);var bP=(aO-aJ+1)*(aN-aK+1);var aq=[];if(k>10){var al=this.B.length;for(var i=0;i<al;i++){var c=this.B[i];if(!F.contains(c.C)|| !this.bb(c)){c.ah();}}for(var y=aJ;y<=aO;y++){for(var x=aK;x<=aN;x++){var id=this.by(x,y);var t=this.ao[id];if(t){if(t.ac.length>0){var aC=t.ac.length;for(var i=0;i<aC;i++){var c=t.ac[i];if(F.containsLatLng(c.C)){if(this.bb(c)){c.az();aq.push(c);}}}}else{t.bu();}}}}}else{var al=this.B.length;for(var i=0;i<al;i++){var c=this.B[i];c.ah();}var bf=this.ak.length;for(var i=0;i<bf;i++){var g=this.ak[i];if(F.intersects(g.an)){g.az();aq.push(g);}else{g.ah();}}}this.B=aq;if(this.B.length>0){var s=this.B.length==1?"":"s";eid("countDiv").innerHTML=this.B.length+" marker"+s;}else{eid("countDiv").innerHTML="";}this.B.sort(sortAtoZ);var ba=eid("indexDiv");ba.innerHTML="";for(var i=0;i<this.B.length;i++){var c=this.B[i];ba.appendChild(c.aa);}this.bm();if(initialPlaceID){var c=trm.ae[initialPlaceID];if(c){c.P(true);initialPlaceID="";}}};function sortAtoZ(a,b){return(a.af>b.af);};TripMap.prototype.bm=function(){var k=map.getZoom();var aX=(k>10);eid("cityFilters").style.display=aX?"none":"inline";eid("placeFilters").style.display=aX?"inline":"none";};function clickCategory(a){trm.R[a]=true;for(var i=1;i<=4;i++){if(i!=a){trm.R[i]=false;}eid("c"+i).checked=trm.R[i];}trm.L();};function checkCategory(a){var id=parseInt(a.id.substr(1));trm.R[id]=a.checked;trm.L();};function setFilterText(a){trm.ai=a.value.toLowerCase();trm.L();};function searchInit(){eid("filterText").focus();if(eid("filterText").value){eid("filterText").value="";trm.ai="";trm.L();}};TripMap.prototype.bb=function(r){if(this.ai&&(r.af.indexOf(this.ai)<0)){return false;}if(!this.R[r.T]){return false;}return true;};function JSON(fullUrl){this.bA=fullUrl;this.bK='&noCacheIE='+(new Date()).getTime();this.aF=document.getElementsByTagName("head").item(0);this.bF='JscriptId'+JSON.bG++;};JSON.bG=1;JSON.prototype.bI=function(){this.O=document.createElement("script");this.O.setAttribute("type","text/javascript");this.O.setAttribute("charset","utf-8");this.O.setAttribute("src",this.bA+this.bK);this.O.setAttribute("id",this.bF);};JSON.prototype.bQ=function(){this.aF.removeChild(this.O);};JSON.prototype.bH=function(){this.aF.appendChild(this.O);};TripMap.prototype.bl=function(a){if(typeof(Lat49)!="undefined"){var J=map.getCenter();Lat49.updateAdByLatLon("adcontainer",J.lat(),J.lng(),map.getZoom());}};function layerPanoramio(){if(!trm.ab){trm.ab=new GLayer("com.panoramio.all");}trm.aB= !trm.aB;if(trm.aB){map.addOverlay(trm.ab);}else{map.removeOverlay(trm.ab);}eid("panoramioLink").style.color=trm.aB?"black":"gray";};function layerWikipedia(){if(!trm.ad){trm.ad=new GLayer("org.wikipedia.en");}trm.aj= !trm.aj;if(trm.aj){map.addOverlay(trm.ad);}else{map.removeOverlay(trm.ad);}eid("wikipediaLink").style.color=trm.aj?"black":"gray";};function viewCities(){eid("cityViewLink").style.color="black";eid("placeViewLink").style.color="gray";};function viewPlaces(){eid("cityViewLink").style.color="gray";eid("placeViewLink").style.color="black";};TripMap.prototype.aE=function(id){};function rowHi(a){if(a&&a.id&&a.id.length>1){var id=a.id.substr(1);if(trm.o&&trm.o.id==id){a.style.color="white";a.style.backgroundColor="#505050";}else{a.style.color="black";a.style.backgroundColor="#D0D0D0";}}};function rowLo(a){if(a&&a.id&&a.id.length>1){var id=a.id.substr(1);if(trm.o&&trm.o.id==id){a.style.color="white";a.style.backgroundColor="#505050";}else{a.style.color="black";a.style.backgroundColor="white";}}};TripMap.prototype.aE=function(id){};function placeClick(id,K){var c=trm.ae[id];if(c){c.P(K);}};function cityClick(id,K){var g=trm.aZ[id];if(g){g.P(K);}};TripMap.prototype.bt=function(){var aU={};aU.showOnLoad=true;var bc={};bc.googleBarOptions=aU;var bk=eid("mapDiv");map=new GMap2(bk,bc);map.enableDoubleClickZoom();map.enableContinuousZoom();map.enableScrollWheelZoom();map.addMapType(G_PHYSICAL_MAP);map.addControl(new GMapTypeControl(),new GControlPosition(G_ANCHOR_TOP_RIGHT,new GSize(56,0)));map.addControl(new GLargeMapControl3D(),new GControlPosition(G_ANCHOR_TOP_RIGHT,new GSize(0,0)));map.addControl(new GScaleControl(),new GControlPosition(G_ANCHOR_BOTTOM_LEFT,new GSize(310,5)));map.setCenter(new GLatLng(initialY,initialX),initialZ);this.G=document.createElement("toolDiv");this.G.className="markerTooltip";map.getPane(G_MAP_FLOAT_PANE).appendChild(this.G);this.G.style.visibility="hidden";this.H=document.createElement("div");this.H.className="markerTooltip";document.body.appendChild(this.H);this.as=new GStreetviewClient();GEvent.addListener(map,"moveend",function(){trm.L(false);trm.bl();trm.aY();});var bD=new GAdsManager(map,"pub-5408854154696215",{maxAdsOnMap:10,style:"adunit",channel:"4650782832"});bD.enable();if(typeof(Lat49)!="undefined"){Lat49.initAds(939,"http://www.tripgeo.com/img/iepngfix.htc");}map.enableGoogleBar();this.aY();};TripMap.prototype.aY=function(){var J=map.getCenter();var y=formatFloat(J.lat(),6);var x=formatFloat(J.lng(),6);var z=map.getZoom();eid("coordsDiv").innerHTML="lat:<b>"+y+"</b> lng:<b>"+x+"</b> zoom:<b>"+z+"</b>";var aA="PlaceAdd.aspx?x="+x+"&y="+y+"&z="+z;eid("addLink").href=aA;};function zoomIn(){map.zoomIn();};function zoomOut(){map.zoomOut();};function worldZoom(){map.setCenter(new GLatLng(20,10),2);};function tripOptions(){};function StreetView(a){var V=a.split("_");this.x=parseFloat(V[0].substr(1));this.y=parseFloat(V[1]);this.b=parseFloat(V[2]);this.p=parseFloat(V[3]);this.z=parseInt(V[4]);};function Place(a){this.id=a[0];var x=a[1];var y=a[2];this.C=new GLatLng(y,x);this.D=a[4];this.T=a[3];this.be=1;this.l=null;this.af=this.D.toLowerCase();this.ag=null;this.aG=0;if(a.length>5){for(var i=5;i<a.length;i++){var bp=a[i].substr(0,1);switch(bp){case "s":this.ag=new StreetView(a[i]);break;case "e":this.aG=a[i].substr(1);break;}}}this.aa=document.createElement("div");var M="";switch(this.T){case 1:M="img/markers/d/blue.png";break;case 2:M="img/markers/d/green.png";break;case 3:M="img/markers/d/yellow.png";break;case 4:M="img/markers/d/purple.png";break;default:M="img/markers/d/white.png";break;}this.aa.innerHTML="<div id='r"+this.id+"' class='plrow' onclick='placeClick(\""+this.id+"\",0)' onmouseover='rowHi(this)' onmouseout='rowLo(this)'>"+"<img src='"+M+"' height=10 width=6 /> "+this.D+"</div>";};Place.prototype.ap=function(){var c=this;var f=new GIcon();switch(this.T){case 1:f.image="img/markers/d/blue.png";break;case 2:f.image="img/markers/d/green.png";break;case 3:f.image="img/markers/d/yellow.png";break;case 4:f.image="img/markers/d/purple.png";break;default:f.image="img/markers/d/white.png";break;}f.iconSize=new GSize(12,20);f.printImage=f.image;f.mozPrintImage=f.image;f.iconAnchor=new GPoint(6,19);f.infoWindowAnchor=new GPoint(6,19);var A=new GMarker(this.C,{"icon":f});this.at=this.D;this.I=0;this.l=A;map.addOverlay(A);GEvent.addListener(A,"click",function(a){c.P(true);});GEvent.addListener(A,"mouseover",function(){trm.aI(c,6,-6);});GEvent.addListener(A,"mouseout",function(){trm.aH();});};Place.prototype.az=function(){if(this.l){this.l.show();}else{this.ap();}};Place.prototype.ah=function(){if(this.l){this.l.hide();}};Place.prototype.P=function(K){if(trm.o){var ay=eid("r"+trm.o.id);trm.o=null;rowLo(ay);}trm.o=this;var ar=eid("r"+this.id);rowHi(ar);if(K){trm.aE(this.id);}var j="<a target='_blank' href='Place.aspx?id="+this.id+"'>"+this.D+"</a><br/>";j+="<p style='font-size:10px'><a href='javascript:zoomIn()' style='color:dodgerblue'>Zoom In</a> <a href='javascript:zoomOut()' style='color:dodgerblue'>Zoom Out</a>";if(userStatus>=100){j+="&nbsp; <a target='_blank' href='PlaceEdit.aspx?id="+this.id+"' style='color:darkred'>Edit</a>";}j+="</p><input id='placeProfileBox' type='checkbox' checked=true onclick='placeProfileClick()' />";j+="<a href='javascript:placeProfileClick()' style='color:black'>Info</a> &nbsp;";if(this.T==2){j+="<input id='placeCalendarBox' type='checkbox' onclick='placeCalendarClick()' />";j+="<a href='javascript:placeCalendarClick()' style='color:black'>Calendar</a> &nbsp;";}var aV="gray";if(this.ag){aV="black";}j+="<input id='placeStreetViewBox' type='checkbox' onclick='placeStreetViewClick()' />";j+="<a href='javascript:placeStreetViewClick()' style='color:"+aV+"'>Street View</a> &nbsp;";j+="<input id='placeBingBox' type='checkbox' onclick='placeBingMapCheck()' />";j+="<a href='javascript:placeBingMapClick()' style='color:black'>Bing</a> &nbsp;";j+="<br/>";if(this.l){this.l.openInfoWindowHtml(j);}if(this.T==3){placeStreetViewClick();}else{placeProfileClick();}};City.prototype.P=function(K){if(trm.Q){var ay=eid("r"+trm.Q.id);trm.Q=null;rowLo(ay);}trm.Q=this;var ar=eid("r"+this.bC);rowHi(ar);if(K){trm.aE(this.bC);}var j="<b>"+this.D+"</b>"+"<p><a href='javascript:cityZoom()'>Zoom In</a></p>";if(this.l){this.l.openInfoWindowHtml(j);}eid("infoDiv").innerHTML="<iframe height=360 width=700 marginwidth=0 marginheight=0 scrolling=yes frameborder=0 src='cityhtml/"+this.id+".htm' />";};function placeProfileClick(){placeInfoViewCheck(1);var c=trm.o;if(c){var v="<iframe height=360 width=700 marginwidth=0 marginheight=0 scrolling=yes frameborder=0 src='PlaceInfo.aspx?id="+c.id+"' />";}else{v="";}eid("infoDiv").innerHTML=v;};function placeCalendarClick(){placeInfoViewCheck(1);var c=trm.o;if(c){var v="<iframe height=360 width=700 marginwidth=0 marginheight=0 scrolling=yes frameborder=0 src='http://events.mapchannels.com/tripgeo/"+c.aG+".htm' />";}else{v="";}eid("infoDiv").innerHTML=v;};function placeStreetViewClick(){placeInfoViewCheck(3);trm.as;if(trm.o){var pt=trm.o.C;if(trm.o.ag){var U=trm.o.ag;var v="<iframe height=360 width=700 marginwidth=0 marginheight=0 scrolling=no frameborder=0 "+"src='tripview/streetview.htm?x="+U.x+"&y="+U.y+"&d="+U.b+"&p="+U.p+"&z="+U.z+"' />";eid("infoDiv").innerHTML=v;}else{trm.as.getNearestPanoramaLatLng(pt,initPanorama);}}};function initPanorama(pt){if(pt){var v="<iframe height=360 width=700 marginwidth=0 marginheight=0 scrolling=no frameborder=0 src='tripview/streetview.htm?x="+pt.lng()+"&y="+pt.lat()+"' />";eid("infoDiv").innerHTML=v;}else{eid("infoDiv").innerHTML="<br/><center>no nearby streetview is available</center>";}};function placeBingMapClick(){placeInfoViewCheck(4);var pt=trm.o.C;var x=pt.lng();var y=pt.lat();var v="<iframe height=360 width=700 marginwidth=0 marginheight=0 scrolling=no frameborder=0 "+"src='tripview/bingmap.htm?x="+x+"&y="+y+"' />";eid("infoDiv").innerHTML=v;};function placeInfoViewCheck(a){if(eid("placeProfileBox")){eid("placeProfileBox").checked=(a==1);}if(eid("placeCalendarBox")){eid("placeCalendarBox").checked=(a==2);}if(eid("placeStreetViewBox")){eid("placeStreetViewBox").checked=(a==3);}if(eid("placeBingBox")){eid("placeBingBox").checked=(a==4);}};TripMap.prototype.aI=function(r,av,bg){if(!r.I){r.I=this.bB(r.at);}var aT=this.bz(r.C);var aS=true;if(aT<(r.I+av)){var bn=this.bx(r.C);if(aT<bn){aS=false;}}if(r.I>0){this.G.style.width=r.I+"px";}this.G.innerHTML="<div class='markerTooltip'>"+r.at+"</div>";var z=map.getZoom();var aW=map.getCurrentMapType().getProjection().fromLatLngToPixel(map.fromDivPixelToLatLng(new GPoint(0,0),true),z);var aP=map.getCurrentMapType().getProjection().fromLatLngToPixel(r.C,z);var x=aP.x-aW.x;var y=aP.y-aW.y;if(aS){x+=av;}else{x-=(av+r.I);}y+=bg;var bo=new GControlPosition(G_ANCHOR_TOP_LEFT,new GSize(x,y));bo.apply(this.G);this.G.style.visibility="visible";};TripMap.prototype.aH=function(){this.G.style.visibility="hidden";};TripMap.prototype.bB=function(bh){var aM=0;if(this.H){this.H.style.display="inline";this.H.innerHTML=bh;aM=this.H.offsetWidth;this.H.style.display="none";}return aM;};TripMap.prototype.bz=function(au){var k=map.getZoom();var aD=map.getCurrentMapType().getProjection().fromLatLngToPixel(au,k);var F=map.getBounds();var ne=F.getNorthEast();var aw=map.getCurrentMapType().getProjection().fromLatLngToPixel(ne,k);var ax=(aw.x-aD.x);return ax;};TripMap.prototype.bx=function(au){var k=map.getZoom();var aD=map.getCurrentMapType().getProjection().fromLatLngToPixel(au,k);var F=map.getBounds();var sw=F.getSouthWest();var aw=map.getCurrentMapType().getProjection().fromLatLngToPixel(sw,k);var ax=(aD.x-aw.x);return ax;};function eid(id){return document.getElementById(id);};function formatFloat(n,d){var m=Math.pow(10,d);return parseInt(n*m,10)/m;}