var formFrom;$(document).ready(function(){document.getElementById("to").value="";document.getElementById("from").value="";$('div#optionsPanel li.saveIt').one("click",function(){var t = new Array(routeId);$start=t[0];$finish=t[1];t.splice(0,2);$waypoints=t.join();$.ajax({type:"POST",url:"/assets/scripts/save_route.php",data:({start:$start,finish:$finish,waypoints:$waypoints}),success:function(url){$link="http://veer.me.uk/r/?route="+url;$('div#optionsPanel li.saveIt').css({'background-position':'-108px -220px','cursor':'default'}).html("<p>Your link is: <br />"+$link+"</p>");$('div#optionsPanel li.email').slideDown(1000);}});});$('ul#routeOpts li').hover(function(){$(this).css('background-color','#E7B248');},function(){$(this).css('background-color','#feb75c');});$('div#optionsPanel li.printIt').click(function(){var points=routeId.join();window.open("../print/?points="+points,"_blank","location = no, toolbar = no, scrollbars=yes");});$('p.directions').click(function(){$('#hero').hide();$('#suggNav').slideUp();$('#suggestPanal').css({'display':'none'})
$('#directionsCont').css({'display':'none'});$('#location').css({'display':'block'});$('#canvas_map').animate({width:'70%'},1100);});$('p#closeHero').click(function(){$('#hero').hide();});$('div#min').click(function(){if($(this).attr("class")=="min"){$('#suggNav').slideUp("slow");$('#suggestPanal').animate({height:'20px'},800);$(this).attr({'class':'max'});}else{$('#suggestPanal').animate({height:'300px'},800);$('#suggNav').slideDown("slow");$(this).attr({'class':'min'});}});$('p.max').click(function(){$('#suggestPanal').animate({height:'300px'},800);$('#suggNav').slideDown("slow");$('p.max').hide();$('p.min').show();});$('input#submitBtn').click(function(){$('#directionsCont').css({'display':'none'});$('#location').css({'display':'none'});$('#canvas_map').animate({width:'100%'},800);$('#suggestPanal').fadeIn("slow");$('#suggNav').fadeIn("slow");$('div#bad').show();$('div#good').show();});$('input#emailL').keyup(function(){var email=$('input#emailL').val();if(email!=0){if(isValidEmailAddress(email)){$('div#optionsPanel ul#routeOpts li.email input#sendL').show();}else{$('input#sendL').hide();}}});function isValidEmailAddress(emailAddress){var pattern=new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);return pattern.test(emailAddress);}
$('input#sendL').click(function(){var emailAddy=document.getElementById("emailL").value;$('div#optionsPanel li.email').html("Please wait, sending");$('div#optionsPanel li.email').css({'cursor':'default'});$.ajax({type:"POST",url:"/assets/scripts/email_link.php",data:({email:emailAddy,url:$link}),success:function(){$('div#optionsPanel li.email').html("The email has been sent successfully to: "+emailAddy);}});});$('#savePoint').bind("click keyup",function(){var point=$(this).val();searching='from';geo.getLatLng(point,function(result){var bloggg;map.clearOverlays();map.addOverlay(new GMarker(result,{draggable:true}));var lat=result.lat();var lng=result.lng();$('input#lat').val(lat);$('input#lng').val(lng);bloggg=true;});});$('input#savePointBtn').click(function(){$name=$('input#title').val();$lat=$('input#lat').val();$lng=$('input#lng').val();$url=$('input#link').val();var theData="desc="+$name+"&lng="+$lng+"&lat="+$lat+"&url="+$url;$.ajax({type:"POST",url:"/assets/scripts/save-point-form.php",data:theData,success:function(){alert("bingo, big girl");}});});$('#from').bind("click keyup blur",function(){from=$(this).val();searching='from';geo.getLocations(from,function(result){checkPoint(result);});});$('input#to').bind("click keyup blur",function(){to=$(this).val();searching='to';geo.getLocations(to,function(result){checkPoint(result);});});$('div#bad').click(function(){$('#flickrImages').css({'display':'none'});$('#wiki').css({'display':'none'});map.removeOverlay(marker);$suggest=poiId[suggestedId];currentSuggested++;var next=currentSuggested;$.post("/assets/scripts/process_rating.php",{id:$suggest,vote:0});badPoints[badPoints.length]=new GLatLng(poiLat[suggestedId],poiLon[suggestedId]);if(closePoints.length<=next){$('div#suggestedPoint').html("<h2>Ooops, it seems that we have no more places to show you! Why not finish your route, or try another journey?</h2>");$('div#bad').hide();$('div#good').hide();$('div#wiki').html("");$('div#flickrImages').html("");}else{showPoint(next);}});$('div#good').click(function(){if(suggestWork==false){$('#flickrImages').css({'display':'none'});$('#wiki').css({'display':'none'});map.removeOverlay(marker);$suggest=poiId[suggestedId];routeId[routeId.length]=$suggest;$next=currentSuggested;$.post("/assets/scripts/process_rating.php",{id:$suggest,vote:1});var check=new GLatLng(poiLat[suggestedId],poiLon[suggestedId]);viaPoints[viaPoints.length]=check;viaRef[viaRef.length]=suggestedId;gdir.clear();suggestWork=true;direct();}});$('div#finish').click(function(){var journey=$('#right').html();$('#suggNav').slideUp();$('#suggestPanal').fadeOut("slow");map.removeOverlay(marker);gdir.clear();var via="";for(var v=0;v<viaPoints.length;v++){via+=" to:"+viaPoints[v];}
gdir2.load("from: "+start+via+" to: "+end);$('#directionsCont').css({'display':'block'});$('div#optionsPanel li.email').css({'display':'none'});$('div#optionsPanel').prepend(journey);});});function loadxml(targeturl,targetcallback){$.ajax({type:"GET",url:targeturl,dataType:"xml",success:targetcallback});}
var photoObject={};function getPhotos(id){$photoLat=poiLat[id];$photoLng=poiLon[id];$photoTag=poiDesc[id];$url="/assets/scripts/flickr_req_xml.php?tags="+$photoTag;loadxml($url,function(xml){if($(xml).find("photos").attr("total")!=0){var p=0;var htmlImage=new String("<p><strong>You might find these photos from Flickr useful:</strong></p>");while(p<4&&p<=$(xml).find("photos").attr("total"))
$(xml).find("photo").each(function(){$src='http://farm'+$(this).attr("farm")+'.static.flickr.com/'+$(this).attr("server")+'/'+$(this).attr("id")+'_'+$(this).attr("secret")+'_s.jpg';htmlImage+="<img src=\""+$src+"\" />";p++;});document.getElementById("flickrImages").innerHTML=htmlImage;$('#flickrImages').css({'display':'inline'});}else{document.getElementById("flickrImages").innerHTML="<p>We don't seem to be able to find any related images from Flickr for this location, why not try clicking the associated link above to find out more information?</p>";}});}
function getWikiTitle(title){var url='/assets/scripts/yahoo_req_xml.php?title='+title;var t=loadxml(url,function(xml){if($(xml).find("ResultSet").attr("totalResultsReturned")>0){var wikiTitle;wikiTitle=$(xml).find("Title").text();wikiTitle=wikiTitle.replace(/ - Wikipedia, the free encyclopedia/,"");getWiki(wikiTitle);}else{$('#wiki').html("<p>We don't seem to be able to find a Wikipedia article for this location, why not try clicking the associated link above to find out more information?</p>").show();}});}
function getWiki(title){var loc='/assets/scripts/wiki_req_xml.php?title='+title;loadxml(loc,function(xml){var wikiLink=$(xml).find('Url').text();var wikiDesc=$(xml).find('Description').text();$('#wiki').html("<h2>From Wikipedia:</h2><p>\""+wikiDesc+"\"</p><p><a target=\"_blank\" href=\"../outbound/?url="+wikiLink+"\">View Entire Wikipedia Article</a></p>").show();});}

GPolygon.prototype.Contains=function(point){var j=0;var oddNodes=false;var x=point.lng();var y=point.lat();for(var i=0;i<this.getVertexCount();i++){j++;if(j==this.getVertexCount()){j=0;}
if(((this.getVertex(i).lat()<y)&&(this.getVertex(j).lat()>=y))||((this.getVertex(j).lat()<y)&&(this.getVertex(i).lat()>=y))){if(this.getVertex(i).lng()+(y-this.getVertex(i).lat())/(this.getVertex(j).lat()-this.getVertex(i).lat())*(this.getVertex(j).lng()-this.getVertex(i).lng())<x){oddNodes=!oddNodes}}}
return oddNodes;}
GPolygon.prototype.Area=function(){var a=0;var j=0;var b=this.Bounds();var x0=b.getSouthWest().lng();var y0=b.getSouthWest().lat();for(var i=0;i<this.getVertexCount();i++){j++;if(j==this.getVertexCount()){j=0;}
var x1=this.getVertex(i).distanceFrom(new GLatLng(this.getVertex(i).lat(),x0));var x2=this.getVertex(j).distanceFrom(new GLatLng(this.getVertex(j).lat(),x0));var y1=this.getVertex(i).distanceFrom(new GLatLng(y0,this.getVertex(i).lng()));var y2=this.getVertex(j).distanceFrom(new GLatLng(y0,this.getVertex(j).lng()));a+=x1*y2-x2*y1;}
return Math.abs(a*0.5);}
GPolygon.prototype.Distance=function(){var dist=0;for(var i=1;i<this.getVertexCount();i++){dist+=this.getVertex(i).distanceFrom(this.getVertex(i-1));}
return dist;}
GPolygon.prototype.Bounds=function(){var bounds=new GLatLngBounds();for(var i=0;i<this.getVertexCount();i++){bounds.extend(this.getVertex(i));}
return bounds;}
GPolygon.prototype.GetPointAtDistance=function(metres){if(metres==0)return this.getVertex(0);if(metres<0)return null;var dist=0;var olddist=0;for(var i=1;(i<this.getVertexCount()&&dist<metres);i++){olddist=dist;dist+=this.getVertex(i).distanceFrom(this.getVertex(i-1));}
if(dist<metres){return null;}
var p1=this.getVertex(i-2);var p2=this.getVertex(i-1);var m=(metres-olddist)/(dist-olddist);return new GLatLng(p1.lat()+(p2.lat()-p1.lat())*m,p1.lng()+(p2.lng()-p1.lng())*m);}
GPolygon.prototype.GetPointsAtDistance=function(metres){var next=metres;var points=[];if(metres<=0)return points;var dist=0;var olddist=0;for(var i=1;(i<this.getVertexCount());i++){olddist=dist;dist+=this.getVertex(i).distanceFrom(this.getVertex(i-1));while(dist>next){var p1=this.getVertex(i-1);var p2=this.getVertex(i);var m=(next-olddist)/(dist-olddist);points.push(new GLatLng(p1.lat()+(p2.lat()-p1.lat())*m,p1.lng()+(p2.lng()-p1.lng())*m));next+=metres;}}
return points;}
GPolygon.prototype.GetIndexAtDistance=function(metres){if(metres==0)return this.getVertex(0);if(metres<0)return null;var dist=0;var olddist=0;for(var i=1;(i<this.getVertexCount()&&dist<metres);i++){olddist=dist;dist+=this.getVertex(i).distanceFrom(this.getVertex(i-1));}
if(dist<metres){return null;}
return i;}
GPolygon.prototype.Bearing=function(v1,v2){if(v1==null){v1=0;v2=this.getVertexCount()-1;}else if(v2==null){v2=v1+1;}
if((v1<0)||(v1>=this.getVertexCount())||(v2<0)||(v2>=this.getVertexCount())){return;}
var from=this.getVertex(v1);var to=this.getVertex(v2);if(from.equals(to)){return 0;}
var lat1=from.latRadians();var lon1=from.lngRadians();var lat2=to.latRadians();var lon2=to.lngRadians();var angle=-Math.atan2(Math.sin(lon1-lon2)*Math.cos(lat2),Math.cos(lat1)*Math.sin(lat2)-Math.sin(lat1)*Math.cos(lat2)*Math.cos(lon1-lon2));if(angle<0.0)angle+=Math.PI*2.0;angle=angle*180.0/Math.PI;return parseFloat(angle.toFixed(1));}
GPolyline.prototype.Contains=GPolygon.prototype.Contains;GPolyline.prototype.Area=GPolygon.prototype.Area;GPolyline.prototype.Distance=GPolygon.prototype.Distance;GPolyline.prototype.Bounds=GPolygon.prototype.Bounds;GPolyline.prototype.GetPointAtDistance=GPolygon.prototype.GetPointAtDistance;GPolyline.prototype.GetPointsAtDistance=GPolygon.prototype.GetPointsAtDistance;GPolyline.prototype.GetIndexAtDistance=GPolygon.prototype.GetIndexAtDistance;GPolyline.prototype.Bearing=GPolygon.prototype.Bearing;

LatLon.distHaversine=function(lat1,lon1,lat2,lon2){var R=6371;var dLat=(lat2-lat1).toRad();var dLon=(lon2-lon1).toRad();lat1=lat1.toRad(),lat2=lat2.toRad();var a=Math.sin(dLat/2)*Math.sin(dLat/2)+
Math.cos(lat1)*Math.cos(lat2)*Math.sin(dLon/2)*Math.sin(dLon/2);var c=2*Math.atan2(Math.sqrt(a),Math.sqrt(1-a));var d=R*c;return d;}
function LatLon(lat,lon){this.lat=lat;this.lon=lon;}
LatLon.prototype.toString=function(){return this.lat.toLat()+', '+this.lon.toLon();}
String.prototype.parseDeg=function(){if(!isNaN(this))return Number(this);var degLL=this.replace(/^-/,'').replace(/[NSEW]/i,'');var dms=degLL.split(/[^0-9.,]+/);for(var i in dms)if(dms[i]=='')dms.splice(i,1);switch(dms.length){case 3:var deg=dms[0]/1+dms[1]/60+dms[2]/3600;break;case 2:var deg=dms[0]/1+dms[1]/60;break;case 1:if(/[NS]/i.test(this))degLL='0'+degLL;var deg=dms[0].slice(0,3)/1+dms[0].slice(3,5)/60+dms[0].slice(5)/3600;break;default:return NaN;}
if(/^-/.test(this)||/[WS]/i.test(this))deg=-deg;return deg;}
Number.prototype.toRad=function(){return this*Math.PI/180;}
Number.prototype.toDeg=function(){return this*180/Math.PI;}
Number.prototype.toBrng=function(){return(this.toDeg()+360)%360;}
Number.prototype.toDMS=function(){var d=Math.abs(this);d+=1/7200;var deg=Math.floor(d);var min=Math.floor((d-deg)*60);var sec=Math.floor((d-deg-min/60)*3600);if(deg<100)deg='0'+deg;if(deg<10)deg='0'+deg;if(min<10)min='0'+min;if(sec<10)sec='0'+sec;return deg+'\u00B0'+min+'\u2032'+sec+'\u2033';}
Number.prototype.toLat=function(){return this.toDMS().slice(1)+(this<0?'S':'N');}
Number.prototype.toLon=function(){return this.toDMS()+(this>0?'E':'W');}
Number.prototype.toPrecision=function(fig){if(this==0)return 0;var scale=Math.ceil(Math.log(this)*Math.LOG10E);var mult=Math.pow(10,fig-scale);return Math.round(this*mult)/mult;}

var geo;var reasons=[];var searching;reasons[G_GEO_SUCCESS]="Success";reasons[G_GEO_MISSING_ADDRESS]="Missing Address: The address was either missing or had no value.";reasons[G_GEO_UNKNOWN_ADDRESS]="Unknown Address:  No corresponding geographic location could be found for the specified address.";reasons[G_GEO_UNAVAILABLE_ADDRESS]="Unavailable Address:  The geocode for the given address cannot be returned due to legal or contractual reasons.";reasons[G_GEO_BAD_KEY]="Bad Key: The API key is either invalid or does not match the domain for which it was given";reasons[G_GEO_TOO_MANY_QUERIES]="Too Many Queries: The daily geocoding quota for this site has been exceeded.";reasons[G_GEO_SERVER_ERROR]="Server error: The geocoding request could not be successfully processed.";function checkPoint(result){map.clearOverlays();if(result.Status.code==G_GEO_SUCCESS){if(result.Placemark.length>1){textbox=document.getElementById("didYouMean");textbox.innerHTML="Did you mean:";for(var i=0;i<result.Placemark.length;i++){var p=result.Placemark[i].Point.coordinates;var address=result.Placemark[i].address;textbox.innerHTML+="<br>"+(i+1)+": <a onClick='setPoint("+p[1]+", "+p[0]+", \""+address+"\", 1);' href='javascript:place("+p[1]+","+p[0]+")'>"+address+"<\/a>";}}
else{textbox=document.getElementById("location");var p=result.Placemark[0].Point.coordinates;var address=result.Placemark[0].address;place(p[1],p[0]);setPoint(p[1],p[0],address);}}
else{var reason="Code "+result.Status.code;if(reasons[result.Status.code]){reason=reasons[result.Status.code]}
textbox=document.getElementById("didYouMean");if(searching=="from"){textbox.innerHTML="Could not find '"+from+"' "+reason;}else{textbox.innerHTML="Could not find '"+to+"' "+reason;}}}
function setPoint(p1,p0,address,multiple){document.getElementById("didYouMean").innerHTML=" ";if(searching=="from"){if(multiple==1){document.getElementById("from").value=address;};placemarkStart=address;formFrom=p1+","+p0;document.getElementById("fromTown").innerHTML="<h2>You are currently leaving from: "+address+"</h2>";document.getElementById("fromTown").innerHTML+="<p>If this is not correct try another search term</p>";}else{if(multiple==0){document.getElementById("to").value=address;};formTo=p1+","+p0;placemarkEnd=address;document.getElementById("toTown").innerHTML="<h2>And going to: "+address+"</h2>";document.getElementById("toTown").innerHTML+="<p>If this is not correct try another search term</p>";}}
function place(lat,lng){var point=new GLatLng(lat,lng);map.setCenter(point,14);map.addOverlay(new GMarker(point,{draggable:false}));textbox=document.getElementById("directions");textbox.innerHTML="";}

var closeRank=new Array;var currentSuggested=new Number(0);var suggestedId;var rankArray=[];var rankArrayOne=[];function sortNumber(a,b)
{return b-a;}
function in_array(itemIs,theArray){var n=theArray.length;for(var i=0;i<n;i++){if(theArray[i]==itemIs){return i;}}
return false;}
function orderPoints(item){rankArray=[];rankArrayOne=[];var poiRef=0;for(var i=0;i<closePointIndex.length;i++){var rankClose=closePointIndex[i];rankArray[i]=poiRating[rankClose];rankArrayOne[i]=poiRating[rankClose];}
var rankedPoints=rankArrayOne.sort(sortNumber);for(var i=0;i<rankedPoints.length;i++){closeRank[i]=in_array(rankedPoints[i],rankArray);}
showPoint(currentSuggested);}
function showPoint(item){if(closePoints.length==0){$('div#suggestedPoint').html("<h2>Ooops, it seems that we have no more places to show you! Why not finish your route, or try another journey?</h2>");$('div#bad').hide();$('div#good').hide();}else{var CPI=closePointIndex[item];var placeTitle=poiDesc[CPI];suggestedId=CPI;document.getElementById("flickrImages").innerHTML=" ";getWikiTitle(placeTitle);getPhotos(suggestedId);var suggLoc=new GLatLng(poiLat[CPI],poiLon[CPI]);map.addOverlay(createMarker(suggLoc,CPI));$('#suggestedPoint').html("<p><strong>This is the recommended point, here is some information, do you want to add it to your route?</strong></p>");$('#suggestedPoint').append("<h1>"+placeTitle+"</h1>");var outbound=escape(poiURL[CPI]);$('#suggestedPoint').append("<p class=\"siteLink\"><a title=\"Opens in new window\" target=\"_blank\" href=\"../outbound/?url="+outbound+"\">Visit their website</a></p>");var rightDiv="<h2>Your current journey:</h2><ul id=\"theJourney\"><li class=\"start\">"+placemarkStart+"</li>";for(var f=0;f<viaRef.length;f++){rightDiv+="<li class=\"via\">"+poiDesc[viaRef[f]]+"</li>";}
rightDiv+="<li class=\"end\">"+placemarkEnd+"</li></ul>";$('#right').html(rightDiv);suggestWork=false;}};function suggestPoints(){removeDuplicates();for(var v=0;v<viaPoints.length;v++){findDuplicate(viaPoints[v],0);}
for(var b=0;b<badPoints.length;b++){findDuplicate(badPoints[b],0);}
orderPoints();};function removeDuplicates(l){for(var d=0;d<closePoints.length;d++){var place=d+1;findDuplicate(closePoints[d],place);}};function findDuplicate(needle,place){for(var i=place;i<closePoints.length;i++){if(needle.lat()==closePoints[i].lat()&&needle.lng()==closePoints[i].lng()){closePoints.splice(i,1);closePointIndex.splice(i,1);i--;}}}

var poiLat=new Array();var poiLon=new Array();var poiDesc=new Array();var poiId=new Array();var poiRating=new Array();var poiURL=new Array();var routeId=new Array();var viaRef=new Array();var placemarkStart;var placemarkEnd;var suggestWork=new Boolean(false);var formFrom;var marker;var start=new String();var end=new String();var viaPoints=new Array();var badPoints=new Array();closePoints=new Array();closePointIndex=new Array();devLength=new Number(12);function initialise(){map=new GMap2(document.getElementById("canvas_map"));map.setCenter(new GLatLng(50.7235,-1.8775),11);var ui=map.getDefaultUI();ui.zoom.scrollwheel=false;map.setUI(ui);geo=new GClientGeocoder();geo.setBaseCountryCode('GB');gdir=new GDirections(map);gdir2=new GDirections(map,document.getElementById("directions"));GEvent.addListener(gdir,"load",onGDirectionsLoad);GEvent.addListener(gdir,"error",handleErrors);GDownloadUrl("markers_xml.php",function(data){var xml=GXml.parse(data);var markers=xml.documentElement.getElementsByTagName("marker");for(var i=0;i<markers.length;i++){poiDesc[i]=markers[i].getAttribute("name");poiLat[i]=markers[i].getAttribute("lat");poiLon[i]=markers[i].getAttribute("lng");poiId[i]=markers[i].getAttribute("id");poiRating[i]=markers[i].getAttribute("rating");poiURL[i]=markers[i].getAttribute("url");}});};function initDirect(){viaPoints=[];badPoints=[];routeId=[];viaRef=[];direct();};function direct(){start=formFrom;end=formTo;routeId[0]=start;routeId[1]=end;closePoints=[];closePointIndex=[];closeRank=[];currentSuggested=0;var via=new String();if(viaPoints.length>=1){for(var v=0;v<viaPoints.length;v++){via+=" to:"+viaPoints[v];}}
if(viaPoints.length<1){gdir.load("from: "+formFrom+" to: "+formTo);}else if(0<viaPoints.length){gdir.load("from: "+formFrom+via+" to: "+formTo);}};function handleErrors(){if(gdir.getStatus().code==G_GEO_UNKNOWN_ADDRESS)
alert("No corresponding geographic location could be found for one of the specified addresses. This may be due to the fact that the address is relatively new, or it may be incorrect.\nError code: "+gdir.getStatus().code);else if(gdir.getStatus().code==G_GEO_SERVER_ERROR)
alert("A geocoding or directions request could not be successfully processed, yet the exact reason for the failure is not known.\n Error code: "+gdir.getStatus().code);else if(gdir.getStatus().code==G_GEO_MISSING_QUERY)
alert("The HTTP q parameter was either missing or had no value. For geocoder requests, this means that an empty address was specified as input. For directions requests, this means that no query was specified in the input.\n Error code: "+gdir.getStatus().code);else if(gdir.getStatus().code==G_GEO_BAD_KEY)
alert("The given key is either invalid or does not match the domain for which it was given. \n Error code: "+gdir.getStatus().code);else if(gdir.getStatus().code==G_GEO_BAD_REQUEST)
alert("A directions request could not be successfully parsed.\n Error code: "+gdir.getStatus().code);else alert("An unknown error occurred.");};function onGDirectionsLoad(){document.getElementById("to").value=placemarkEnd;document.getElementById("from").value=placemarkStart;var poly=gdir.getPolyline();var stopDist=((poly.Distance())/10);var box=poly.Bounds();var boxSW=box.getSouthWest();var boxNE=box.getNorthEast();var points=poly.GetPointsAtDistance(stopDist);checkAllPoints(points);};function createMarker(point,index){marker=new GMarker(point);GEvent.addListener(marker,"mouseup",function(){marker.openInfoWindowHtml("<h2>"+poiDesc[index]+"</h2>");});return marker;};function checkAllPoints(points){for(var i=0;i<points.length;i++){var added=0;for(var t=0;t<poiLat.length;t++){if(added<3){var pointOne=new GLatLng(parseFloat(poiLat[t]),parseFloat(poiLon[t]));var pointTwo=points[i];var lat1=pointOne.lat();var lon1=pointOne.lng();var lat2=pointTwo.lat();var lon2=pointTwo.lng();var b=LatLon.distHaversine(lat1,lon1,lat2,lon2);if(b<devLength){closePoints[closePoints.length]=pointOne;closePointIndex[closePointIndex.length]=t;added++}}}}
suggestPoints(0);};
