var myControlPosition=function(){
return new GControlPosition(G_ANCHOR_TOP_RIGHT,new GSize(7,70));
};
function WayPointsInProgressControl(){
}
WayPointsInProgressControl.prototype=new GControl();
WayPointsInProgressControl.prototype.initialize=function(_1){
var _2=document.createElement("div");
var _3=document.createElement("div");
this.setButtonStyle_(_3);
_2.appendChild(_3);
_3.appendChild(document.createTextNode("End at first point"));
GEvent.addDomListener(_3,"click",function(){
endCourseAtFirst(_1);
});
var _4=document.createElement("div");
this.setButtonStyle_(_4);
_2.appendChild(_4);
_4.appendChild(document.createTextNode("End at last point"));
GEvent.addDomListener(_4,"click",function(){
endCourseAtLast(_1);
});
var _5=document.createElement("div");
this.setButtonStyle_(_5);
_2.appendChild(_5);
_5.appendChild(document.createTextNode("Remove last point"));
GEvent.addDomListener(_5,"click",function(){
removeLastCoursePoint(_1);
});
_1.getContainer().appendChild(_2);
return _2;
};
WayPointsInProgressControl.prototype.getDefaultPosition=myControlPosition;
WayPointsInProgressControl.prototype.setButtonStyle_=function(_6){
_6.style.backgroundColor="white";
_6.style.font="small Arial";
_6.style.border="1px solid black";
_6.style.padding="2px";
_6.style.marginBottom="3px";
_6.style.textAlign="center";
_6.style.width="6em";
_6.style.cursor="pointer";
};
function StartControl(){
}
StartControl.prototype=new WayPointsInProgressControl();
StartControl.prototype.initialize=function(_7){
var _8=document.createElement("div");
var _9=document.createElement("div");
this.setButtonStyle_(_9);
_8.appendChild(_9);
_9.appendChild(document.createTextNode("Clear All"));
GEvent.addDomListener(_9,"click",function(){
clearAll(_7);
});
var _a=document.createElement("div");
this.setButtonStyle_(_a);
_8.appendChild(_a);
_a.appendChild(document.createTextNode("Start a Course"));
GEvent.addDomListener(_a,"click",function(){
startCourse(_7);
});
var _b=document.createElement("div");
this.setButtonStyle_(_b);
_8.appendChild(_b);
_b.appendChild(document.createTextNode("Start a Circle"));
GEvent.addDomListener(_b,"click",function(){
enterCircleMode(_7);
});
_7.getContainer().appendChild(_8);
return _8;
};
function CircleInProgressControl(){
}
CircleInProgressControl.prototype=new WayPointsInProgressControl();
CircleInProgressControl.prototype.initialize=function(_c){
var _d=document.createElement("div");
var _e=document.createElement("div");
this.setButtonStyle_(_e);
_d.appendChild(_e);
_e.appendChild(document.createTextNode("Clear"));
GEvent.addDomListener(_e,"click",function(){
clearAll(_c);
});
var _f=document.createElement("div");
this.setButtonStyle_(_f);
_d.appendChild(_f);
_f.appendChild(document.createTextNode("Erase last"));
GEvent.addDomListener(_f,"click",function(){
eraseLastCircle(_c);
});
var _10=document.createElement("div");
this.setButtonStyle_(_10);
_d.appendChild(_10);
_10.appendChild(document.createTextNode("Leave circle mode"));
GEvent.addDomListener(_10,"click",function(){
leaveCircleMode(_c);
});
_c.getContainer().appendChild(_d);
return _d;
};

var piOver4=Math.PI/4;
var twoPi=Math.PI*2;
var piOver2=Math.PI/2;
var radiansToDegrees=180/Math.PI;
var kilometersPerNM=1.852;
var milesPerNM=1.150779448;
var vectorColor="#ff0000";
var vectorWeight=3;
var vectorOpacity=0.8;
var NAUTICAL_MILES_UNITS=0;
var MILES_UNITS=1;
var KILOMETERS_UNITS=2;
function getDistanceMultiplier(_1){
var _2=1;
if(_1==MILES_UNITS){
_2=milesPerNM;
}else{
if(_1==KILOMETERS_UNITS){
_2=kilometersPerNM;
}
}
return _2;
}
function reduceLat(_3){
var _4=_3-Math.PI*Math.floor((_3+piOver2)/Math.PI);
return _4;
}
function reduceLng(_5){
var _6=_5-twoPi*Math.floor((_5+Math.PI)/twoPi);
return _6;
}
function reduceAzimuth(_7){
var _8=_7-twoPi*Math.floor(_7/twoPi);
return _8;
}
function EarthVector(_9,_a){
this.distanceNM=_9;
this.azimuth=reduceAzimuth(_a);
this.azimuthDegrees=_a*radiansToDegrees;
}
function getVector(){
return this.vector;
}
function computeRhumbLineVector(){
this.deltaLng=this.endPoint.lngRadians()-this.startPoint.lngRadians();
var gb=Math.tan(piOver4+(this.endPoint.latRadians()/2));
var ga=Math.tan(piOver4+(this.startPoint.latRadians()/2));
var X=Math.log(gb)-Math.log(ga);
var _e=Math.atan2(this.deltaLng,X);
var _f=0;
var _10=Math.cos(_e);
if(Math.abs(_10)>0.0001){
var _11=(this.endPoint.lat()-this.startPoint.lat());
_f=60*_11/_10;
}else{
var _12=Math.abs(this.endPoint.lng()-this.startPoint.lng());
_f=60*_12*Math.cos(this.startPoint.lat());
}
this.vector=new EarthVector(_f,_e);
}
function rhumbLineLine(){
var _13=new GPolyline([this.startPoint,this.endPoint],vectorColor,vectorWeight,vectorOpacity,_optsNotClickable);
return _13;
}
function RhumbLineCourse(_14,_15){
this.startPoint=_14;
this.endPoint=_15;
this.computeRhumbLineVector=computeRhumbLineVector;
this.getLine=rhumbLineLine;
this.getVector=getVector;
this.computeRhumbLineVector();
}
function computeGreatCircleVector(){
this.deltaLng=reduceLng(this.endPoint.lngRadians()-this.startPoint.lngRadians());
var _16=Math.sin(this.deltaLng);
var _17=Math.cos(this.deltaLng);
this.sinStartLat=Math.sin(this.startPoint.latRadians());
this.cosStartLat=Math.cos(this.startPoint.latRadians());
this.sinEndLat=Math.sin(this.endPoint.latRadians());
this.cosEndLat=Math.cos(this.endPoint.latRadians());
this.distanceRadians=Math.acos(this.sinStartLat*this.sinEndLat+this.cosStartLat*this.cosEndLat*_17);
this.distanceDegrees=radiansToDegrees*this.distanceRadians;
var _18=60*this.distanceDegrees;
var Y=_16*this.cosEndLat;
var X=this.cosStartLat*this.sinEndLat-this.sinStartLat*this.cosEndLat*_17;
azimuth=Math.atan2(Y,X);
this.vector=new EarthVector(_18,azimuth);
}
function getLatFromLng(_1b){
var _1c=_1b-this.startPoint.lngRadians();
var _1d=Math.sin(_1c);
var _1e=Math.cos(_1c);
var Y=this.sinStartLat*_1e*this.sinAzimuth+_1d*this.cosAzimuth;
var X=this.cosStartLat*this.sinAzimuth;
var _21=reduceLat(Math.atan2(Y,X));
return (_21);
}
function computeVertex(){
if(this.sinAzimuth==0){
return (new GLatLng(twoPi,this.startPoint.lngRadians()));
}
var _22=reduceLng(Math.atan(1/this.sinStartLat/Math.tan(this.vector.azimuth))+this.startPoint.lngRadians());
var _23=this.getLatFromLng(_22);
this.vertex=new GLatLng(_23*radiansToDegrees,_22*radiansToDegrees);
}
function createWayPoints(){
this.sinAzimuth=Math.sin(this.vector.azimuth);
this.cosAzimuth=Math.cos(this.vector.azimuth);
this.longitudeIncrementRadians=this.longitudeIncrement/radiansToDegrees;
var _24=Math.abs(this.deltaLng)/this.longitudeIncrementRadians;
var _25=Math.floor(_24);
var _26=new Array();
_26.push(this.startPoint);
if(_25>1){
if(this.deltaLng<0){
this.longitudeIncrementRadians*=-1;
}
var _27;
var _28=this.startPoint.lngRadians();
for(_27=0;_27<_25;_27++){
var _29=reduceLng(_28+this.longitudeIncrementRadians);
var _2a=this.getLatFromLng(_29);
var _2b=new GLatLng(_2a*radiansToDegrees,_29*radiansToDegrees);
_26.push(_2b);
_28=_29;
}
}
_26.push(this.endPoint);
var _2c=new GPolyline(_26,vectorColor,vectorWeight,vectorOpacity,_optsNotClickable);
return (_2c);
}
function GreatCircleCourse(_2d,_2e){
this.longitudeIncrement=3;
this.startPoint=_2d;
this.endPoint=_2e;
this.computeGreatCircleVector=computeGreatCircleVector;
this.getLatFromLng=getLatFromLng;
this.computeVertex=computeVertex;
this.getLine=createWayPoints;
this.getVector=getVector;
this.computeGreatCircleVector();
}
function bestCourseGetLine(){
if(this.courseLine==null){
this.courseLine=this.course.getLine();
}
return (this.courseLine);
}
function bestCourseGetVector(){
return (this.course.vector);
}
function BestCourse(_2f,_30){
this.getLine=bestCourseGetLine;
this.getVector=bestCourseGetVector;
this.course=new GreatCircleCourse(_2f,_30);
}
function directSolution(_31,_32,_33){
var _34=(_33/60)/radiansToDegrees;
var _35=Math.sin(_31.latRadians());
var _36=Math.cos(_31.latRadians());
var _37=Math.sin(_32);
var _38=Math.cos(_32);
var _39=Math.sin(_34);
var _3a=Math.cos(_34);
var X=(_36*_3a)-(_35*_38*_39);
var Y=_39*_37;
var _3d=Math.asin((_35*_3a)+(_36*_39*_38));
var _3e=_31.lngRadians()-Math.atan2(Y,X);
return (new GLatLng(_3d*radiansToDegrees,_3e*radiansToDegrees));
}

function formatFloat(_1){
var _2;
if(_1<1){
var _3=Math.round(_1*100)/100;
_2=_3.toString();
}else{
if(_1<10){
var _3=Math.round(_1*10)/10;
_2=_3.toString();
}else{
_2=Math.round(_1);
}
}
return _2;
}
function format10(_4){
var _5;
if(_4>=10){
_5=""+_4;
}else{
_5="0"+_4;
}
return _5;
}
function format100(_6){
var _7;
if(_6>=100){
_7=""+_6;
}else{
if(_6>=10){
_7="0"+_6;
}else{
_7="00"+_6;
}
}
return _7;
}
function myLatToString(_8){
var _9=_8.lat();
var _a;
if(_9<0){
_a="S";
_9=_9*-1;
}else{
_a="N";
}
var _b=Math.floor(_9);
var _c=Math.floor((_9*60)-(_b*60));
var _d=Math.floor((_9*3600)-(_b*3600)-(_c*60));
return format10(_b)+" "+format10(_c)+" "+format10(_d)+" "+_a;
}
function myLngToString(_e){
var _f=_e.lng();
var _10;
if(_f<0){
_10="W";
_f=_f*-1;
}else{
_10="E";
}
var _11=Math.floor(_f);
var _12=Math.floor((_f*60)-(_11*60));
var _13=Math.floor((_f*3600)-(_11*3600)-(_12*60));
return format100(_11)+" "+format10(_12)+" "+format10(_13)+" "+_10;
}

function wayPointToElement(_1){
var _2=document.createElement("tr");
var _3=(Math.round(this.pointNumber/2)*2)==this.pointNumber;
if(_3){
_2.className="ptsroweven";
}else{
_2.className="ptsrowodd";
}
var _4;
var _5=getDistanceMultiplier(_1);
_4=document.createElement("td");
_4.appendChild(document.createTextNode(this.courseNumber.toString()));
_4.className="numcol";
_2.appendChild(_4);
_4=document.createElement("td");
_4.appendChild(document.createTextNode(this.pointNumber.toString()));
_4.className="numcol";
_2.appendChild(_4);
_4=document.createElement("td");
_4.appendChild(document.createTextNode(myLatToString(this.point)));
_4.className="llcol";
_2.appendChild(_4);
_4=document.createElement("td");
_4.appendChild(document.createTextNode(myLngToString(this.point)));
_4.className="llcol";
_2.appendChild(_4);
var _6;
var _7;
if(this.vectorFromLastPoint==null){
_6=" ";
_7=" ";
totalDistanceString=" ";
}else{
_6=formatFloat(this.vectorFromLastPoint.distanceNM*_5);
_7=(Math.round(this.vectorFromLastPoint.azimuthDegrees)).toString();
totalDistanceString=formatFloat(this.totalDistanceNM*_5);
}
_4=document.createElement("td");
_4.appendChild(document.createTextNode(_6));
_4.className="distcol";
_2.appendChild(_4);
_4=document.createElement("td");
_4.appendChild(document.createTextNode(_7));
_4.className="distcol";
_2.appendChild(_4);
_4=document.createElement("td");
_4.appendChild(document.createTextNode(totalDistanceString));
_4.className="distcol";
_2.appendChild(_4);
return _2;
}
function wayPointUpdateElement(_8){
var _9=this.tableRowElement.childNodes[2];
_9.replaceChild(document.createTextNode(myLatToString(this.point)),_9.childNodes[0]);
_9=this.tableRowElement.childNodes[3];
_9.replaceChild(document.createTextNode(myLngToString(this.point)),_9.childNodes[0]);
if(this.vectorFromLastPoint!=null){
var _a=getDistanceMultiplier(_8);
_9=this.tableRowElement.childNodes[4];
_9.replaceChild(document.createTextNode(formatFloat(this.vectorFromLastPoint.distanceNM*_a)),_9.childNodes[0]);
_9=this.tableRowElement.childNodes[5];
_9.replaceChild(document.createTextNode(Math.round(this.vectorFromLastPoint.azimuthDegrees)),_9.childNodes[0]);
_9=this.tableRowElement.childNodes[6];
_9.replaceChild(document.createTextNode(formatFloat(this.totalDistanceNM*_a)),_9.childNodes[0]);
}
return this.tableRowElement;
}
function wayPointUpdate(_b,_c,_d){
if(this.courseLine!=null){
_b.removeOverlay(this.courseLine);
this.courseLine=null;
}
this.point=_c;
if(this.lastWayPoint!=null){
var _e=new BestCourse(this.lastWayPoint.point,_c);
this.vectorFromLastPoint=_e.getVector();
this.totalDistanceNM=this.lastWayPoint.totalDistanceNM+this.vectorFromLastPoint.distanceNM;
this.courseLine=_e.getLine();
_b.addOverlay(this.courseLine);
}else{
this.totalDistanceNM=0;
this.vectorFromLastPoint=null;
}
if(this.tableRowElement!=null){
this.updateElement(_d);
}else{
this.tableRowElement=this.toElement(_d);
}
}
function WayPoint(_f,_10,_11,_12,_13,_14){
this.toElement=wayPointToElement;
this.updateElement=wayPointUpdateElement;
this.update=wayPointUpdate;
this.courseNumber=_10;
this.pointNumber=_11;
this.lastWayPoint=_13;
this.name=_11.toString();
this.update(_f,_12,_14);
}

function WindowSize(_1,_2){
this.width=_1;
this.height=_2;
}
function getWindowSize(){
var _3,_4;
if(self.innerHeight){
_3=self.innerWidth;
_4=self.innerHeight;
}else{
if(document.documentElement&&document.documentElement.clientHeight){
_3=document.documentElement.clientWidth;
_4=document.documentElement.clientHeight;
}else{
if(document.body){
_3=document.body.clientWidth;
_4=document.body.clientHeight;
}
}
}
return new WindowSize(_3,_4);
}
var mapWidthOffset=680;
var mapHeightOffset=190;
var mapWidthInnerOffset=10;
function resizeBody(){
if(!_fullyLoaded){
return;
}
var _5=_map.getCenter();
if(_5==null){
return;
}
var _6=getWindowSize();
var _7=_6.width;
var _8=_6.height;
var _9=_innerElement.offsetWidth-_tableElement.offsetWidth-mapWidthInnerOffset;
if(_9<0){
_9=_7-mapWidthOffset;
}
_mapElement.style.width=_9+"px";
var _a=_8-mapHeightOffset;
_mapElement.style.height=_a+"px";
_map.checkResize();
_map.setCenter(_5);
}

var _geocoder;
var _addressToGeoCode;
function foundLocation(_1){
if((_1==null)||(_1.Status.code!=G_GEO_SUCCESS)){
alert("\""+_addressToGeoCode+"\" not found");
}else{
var _2=_1.Placemark[0];
var _3=new GLatLng(_2.Point.coordinates[1],_2.Point.coordinates[0]);
_map.setCenter(_3);
var _4=new GMarker(_3,{title:_2.address});
_map.addOverlay(_4);
_4.openInfoWindowHtml(_2.address);
GEvent.trigger(_map,"click",_4,_3);
}
}
function findLocation(){
_addressToGeoCode=document.forms[0].q.value;
_geocoder.getLocations(_addressToGeoCode,foundLocation);
}
function initGeoCoder(){
_geocoder=new GClientGeocoder();
}

function wayPointsManagerNumberOfPoints(){
var _1=this.wayPointsList.length;
return _1;
}
function wayPointsManagerPushWayPoint(_2){
if(this.wayPointsList!=null){
return this.wayPointsList.push(_2);
}
return null;
}
function wayPointsManagerGetFirstWayPoint(){
var _3=null;
if(this.numberOfPoints()>0){
_3=this.wayPointsList[0];
}
return _3;
}
function removeLastWayPoint(){
var _4=null;
if(this.numberOfPoints()>0){
_4=this.wayPointsList.pop();
}
return _4;
}
function getLastWayPoint(){
var _5=null;
var _6=this.numberOfPoints();
if(_6>0){
_5=this.wayPointsList[_6-1];
}
return _5;
}
function addWayPointTableElement(_7){
this.tBodyElement.appendChild(_7.tableRowElement);
}
function removeWayPointTableElement(_8){
if(_8.tableRowElement!=null){
this.tBodyElement.removeChild(_8.tableRowElement);
}
}
function wayPointsUpdateElements(_9){
for(var d=0;d<this.wayPointsList.length;d++){
var _b=this.wayPointsList[d];
_b.tableRowElement=_b.updateElement(_9,_b.tableRowElement);
}
}
function WayPointsManager(_c,_d){
this.numberOfPoints=wayPointsManagerNumberOfPoints;
this.pushWayPoint=wayPointsManagerPushWayPoint;
this.getFirstWayPoint=wayPointsManagerGetFirstWayPoint;
this.getLastWayPoint=getLastWayPoint;
this.removeLastWayPoint=removeLastWayPoint;
this.addWayPointTableElement=addWayPointTableElement;
this.removeWayPointTableElement=removeWayPointTableElement;
this.updateElement=wayPointsUpdateElements;
this.courseNumber=_c;
this.wayPointsList=new Array();
this.tBodyElement=_d;
}

function geoCircleToElement(_1){
var _2=document.createElement("tr");
var _3=(Math.round(this.circleNumber/2)*2)==this.circleNumber;
if(_3){
_2.className="ptsroweven";
}else{
_2.className="ptsrowodd";
}
var _4;
var _5=getDistanceMultiplier(_1);
_4=document.createElement("td");
_4.appendChild(document.createTextNode(this.circleNumber.toString()));
_4.className="numcol";
_2.appendChild(_4);
_4=document.createElement("td");
_4.appendChild(document.createTextNode(" "));
_4.className="numcol";
_2.appendChild(_4);
_4=document.createElement("td");
_4.appendChild(document.createTextNode(myLatToString(this.centerPoint)));
_4.className="llcol";
_2.appendChild(_4);
_4=document.createElement("td");
_4.appendChild(document.createTextNode(myLngToString(this.centerPoint)));
_4.className="llcol";
_2.appendChild(_4);
var _6=formatFloat(this.radiusNM*_5);
_4=document.createElement("td");
_4.appendChild(document.createTextNode(_6));
_4.className="distcol";
_2.appendChild(_4);
_4=document.createElement("td");
_4.appendChild(document.createTextNode(" "));
_4.className="distcol";
_2.appendChild(_4);
var _7;
if(this.circumferenceNM==null){
_7=" ";
}else{
_7=formatFloat(this.circumferenceNM*_5);
}
_4=document.createElement("td");
_4.appendChild(document.createTextNode(_7));
_4.className="distcol";
_2.appendChild(_4);
return _2;
}
function geoCircleUpdateElement(_8){
var _9=getDistanceMultiplier(_8);
var _a=formatFloat(this.radiusNM*_9);
var _b=this.tableRowElement.childNodes[4];
_b.replaceChild(document.createTextNode(formatFloat(_a)),_b.childNodes[0]);
var _c=formatFloat(this.circumferenceNM*_9);
_b=this.tableRowElement.childNodes[6];
_b.replaceChild(document.createTextNode(formatFloat(_c)),_b.childNodes[0]);
return this.tableRowElement;
}
function geoCircleRemoveLines(_d){
if(this.circleLine!=null){
_d.removeOverlay(this.circleLine);
}
if(this.innerCircleLine!=null){
_d.removeOverlay(this.innerCircleLine);
}
}
function geoCircleRemoveOverlays(_e){
this.removeLines(_e);
if(this.centerMarker!=null){
_e.removeOverlay(this.centerMarker);
}
}
function geoCircleUpdate(_f,_10,_11,_12){
this.removeLines(_f);
this.updateEdge(_10,_11);
_f.addOverlay(this.circleLine);
if(this.innerCircleLine!=null){
_f.addOverlay(this.innerCircleLine);
}
this.updateElement(_12);
}
function geoCircleComputeFromTwoPoints(_13,_14){
var _15=new BestCourse(this.centerPoint,_13);
var _16=_15.getVector();
if(!_14&&(this.radiusNM==_16.distanceNM)){
return;
}
this.radiusNM=_16.distanceNM;
var _17=null;
if(_14){
_17=3;
}else{
_17=12;
}
var _18=new Array();
for(var _19=0;_19<=360;_19+=_17){
var _1a=_19/radiansToDegrees;
var _1b=directSolution(this.centerPoint,_1a,this.radiusNM);
_18.push(_1b);
}
this.circleLine=new GPolyline(_18,vectorColor,vectorWeight,vectorOpacity,_optsNotClickable);
if(_14){
var _1c=new Array();
var _1d=this.radiusNM*0.95;
this.circumferenceNM=0;
var _1e=_18[0];
_1c.push(_1e);
for(var p=1;p<_18.length;p++){
var _20=_18[p];
var _21=new BestCourse(_1e,_20);
var _22=_21.getVector();
this.circumferenceNM+=_22.distanceNM;
var _23=(Math.round(p/2)*2)==p;
if(_23){
_1c.push(_20);
}else{
var _1a=(p*_17)/radiansToDegrees;
var _24=directSolution(this.centerPoint,_1a,_1d);
_1c.push(_24);
}
_1e=_20;
}
this.innerCircleLine=new GPolyline(_1c,vectorColor,1,0.5,_optsNotClickable);
}else{
this.innerCircleLine=null;
}
}
function GeoCircle(map,_26,_27){
this.toElement=geoCircleToElement;
this.updateElement=geoCircleUpdateElement;
this.update=geoCircleUpdate;
this.removeOverlays=geoCircleRemoveOverlays;
this.removeLines=geoCircleRemoveLines;
this.updateEdge=geoCircleComputeFromTwoPoints;
this.circleNumber=_26;
this.centerPoint=_27;
this.radiusNM=0;
this.circumferenceNM=null;
var _28="Circle # "+_26.toString();
this.centerMarker=new GMarker(_27,{title:_28,icon:_wayPointIcon,clickable:true});
map.addOverlay(this.centerMarker);
this.tableRowElement=this.toElement(0);
}

function tableManagerAddWayPointList(){
var _1=this.wayPointsManagerList.length+this.circlesList.length+1;
var _2=new WayPointsManager(_1,this.tableBodyElement);
this.wayPointsManagerList.push(_2);
return _2;
}
function tableManagerAddCircle(_3,_4,_5){
var _6=this.wayPointsManagerList.length+this.circlesList.length+1;
var _7=new GeoCircle(_3,_6,_4);
this.circlesList.push(_7);
this.tableBodyElement.appendChild(_7.tableRowElement);
return _7;
}
function tableManagerRemoveLastCircle(){
var _8=this.circlesList.pop();
if((_8!=null)&&(_8.tableRowElement!=null)){
this.tableBodyElement.removeChild(_8.tableRowElement);
}
return _8;
}
function tableManagerRedrawPointsTable(_9){
for(var c=0;c<this.circlesList.length;c++){
var _b=this.circlesList[c];
_b.updateElement(_9);
}
for(var w=0;w<this.wayPointsManagerList.length;w++){
var _d=this.wayPointsManagerList[w];
_d.updateElement(_9);
}
}
function tableManagerInitTable(){
this.circlesList=new Array();
this.wayPointsManagerList=new Array();
}
function tableManagerClearTable(){
this.initTable();
for(var i=this.tableBodyElement.childNodes.length-1;i>=0;i--){
this.tableBodyElement.removeChild(this.tableBodyElement.childNodes[i]);
}
}
function tableManagerBuildHeader(){
var _f=document.createElement("thead");
var _10=document.createElement("tr");
_f.appendChild(_10);
_10.className="ptshdr";
var _11;
_11=document.createElement("th");
_11.appendChild(document.createTextNode("Course/ Circle #"));
_11.className="numcol";
_10.appendChild(_11);
_11=document.createElement("th");
_11.appendChild(document.createTextNode("Point #"));
_11.className="numcol";
_10.appendChild(_11);
_11=document.createElement("th");
_11.appendChild(document.createTextNode("Pt./Cntr. Latitude"));
_11.className="llcol";
_10.appendChild(_11);
_11=document.createElement("th");
_11.appendChild(document.createTextNode("Pt./Cntr. Longitude"));
_11.className="llcol";
_10.appendChild(_11);
_11=document.createElement("th");
_11.appendChild(document.createTextNode("Distance/ Radius"));
_11.className="distcol";
_10.appendChild(_11);
_11=document.createElement("th");
_11.appendChild(document.createTextNode("Azimuth (Deg)"));
_11.className="distcol";
_10.appendChild(_11);
_11=document.createElement("th");
_11.appendChild(document.createTextNode("Total Dist/ Circumference"));
_11.className="distcol";
_10.appendChild(_11);
return _f;
}
function TableManager(){
this.initTable=tableManagerInitTable;
this.addWayPointList=tableManagerAddWayPointList;
this.redrawPointsTable=tableManagerRedrawPointsTable;
this.clearTable=tableManagerClearTable;
this.addCircle=tableManagerAddCircle;
this.removeLastCircle=tableManagerRemoveLastCircle;
this.initTable();
this.tableElement=document.getElementById("pointsTable");
this.tableElement.appendChild(tableManagerBuildHeader());
this.tableBodyElement=document.createElement("tbody");
this.tableElement.appendChild(this.tableBodyElement);
}

var _fullyLoaded=false;
var _circleMode=false;
var _wayPointsListManager=null;
var _currentCircle=null;
var _tempWayPoint=null;
var _changeUnitsBoxElement;
var _currentDistanceUnits=NAUTICAL_MILES_UNITS;
var _mapElement;
var _tableElement;
var _innerElement;
var _map;
var _wayPointIcon;
var _adsManager;
var _optsNotClickable={clickable:false};
var startControl=null;
var wayPointsInProgressControl=null;
var circleInProgressControl=null;
function startCourse(_1){
removeTempWayPoint(_1);
_1.removeControl(startControl);
_1.addControl(wayPointsInProgressControl);
_wayPointsListManager=_tableManager.addWayPointList();
}
function endCourse(_2){
removeTempWayPoint(_2);
_2.removeControl(wayPointsInProgressControl);
_2.addControl(startControl);
_wayPointsListManager=null;
}
function endCourseAtLast(_3){
endCourse(_3);
}
function endCourseAtFirst(_4){
if(_wayPointsListManager==null){
return;
}
var _5=null;
if((_5=_wayPointsListManager.getFirstWayPoint())!=null){
var _6=createWayPoint(_4,_5.point);
_wayPointsListManager.pushWayPoint(_6);
}
endCourse(_4);
}
function removeLastCoursePoint(_7){
removeTempWayPoint(_7);
if(_wayPointsListManager==null){
return;
}
var _8;
if((_8=_wayPointsListManager.removeLastWayPoint())!=null){
_tempWayPoint=_8;
_7.removeOverlay(_8.marker);
_8.marker=null;
if(_wayPointsListManager.numberOfPoints()==0){
removeTempWayPoint(_7);
}else{
}
}
}
function chooseWayPoint(_9,_a,_b){
drawTempWayPoint(_9,_b);
var _c=_tempWayPoint;
_tempWayPoint=null;
var _a=new GMarker(_b,{title:_c.name,icon:_wayPointIcon});
_9.addOverlay(_a);
_c.marker=_a;
_wayPointsListManager.pushWayPoint(_c);
}
function createWayPoint(_d,_e){
if(_wayPointsListManager==null){
return null;
}
var _f=_wayPointsListManager.getLastWayPoint();
var _10=_wayPointsListManager.numberOfPoints();
var _11=new WayPoint(_d,_wayPointsListManager.courseNumber,_10,_e,_f,_currentDistanceUnits);
_wayPointsListManager.addWayPointTableElement(_11);
return (_11);
}
function removeTempWayPoint(map){
if(_tempWayPoint!=null){
if(_tempWayPoint.courseLine!=null){
map.removeOverlay(_tempWayPoint.courseLine);
}
_wayPointsListManager.removeWayPointTableElement(_tempWayPoint);
_tempWayPoint=null;
}
}
function drawTempWayPoint(map,_14){
if(_tempWayPoint!=null){
_tempWayPoint.update(map,_14,_currentDistanceUnits);
}else{
_tempWayPoint=createWayPoint(map,_14);
}
}
function startCircle(map,_16){
_currentCircle=_tableManager.addCircle(map,_16,_currentDistanceUnits);
}
function finishCircle(map,_18){
drawTempCircle(map,_18,true);
_currentCircle=null;
leaveCircleMode(map);
}
function eraseLastCircle(map){
_currentCircle=null;
var _1a=_tableManager.removeLastCircle();
if(_1a!=null){
_1a.removeOverlays(map);
}
}
function chooseCirclePoint(map,_1c,_1d){
if(_currentCircle==null){
startCircle(map,_1d);
}else{
finishCircle(map,_1d);
}
}
function drawTempCircle(map,_1f,_20){
if(_currentCircle!=null){
_currentCircle.update(map,_1f,_20,_currentDistanceUnits);
}
}
function changeUnits(){
_currentDistanceUnits=_changeUnitsBoxElement[_changeUnitsBoxElement.selectedIndex].value;
_tableManager.redrawPointsTable(_currentDistanceUnits);
if(_tempWayPoint!=null){
_tempWayPoint.updateElement(_currentDistanceUnits);
}
}
function createWayPointIcon(){
_wayPointIcon=new GIcon();
_wayPointIcon.image="blueX40.png";
_wayPointIcon.iconSize=new GSize(40,40);
_wayPointIcon.iconAnchor=new GPoint(20,20);
_wayPointIcon.infoWindowAnchor=new GPoint(24,16);
}
function clearAll(map){
map.clearOverlays();
_tableManager.clearTable();
_currentCircle=null;
_wayPointsListManager=null;
}
function enterCircleMode(map){
map.removeControl(startControl);
map.addControl(circleInProgressControl);
removeTempWayPoint(map);
_wayPointsListManager=null;
_circleMode=true;
}
function leaveCircleMode(map){
map.removeControl(circleInProgressControl);
map.addControl(startControl);
if(_currentCircle!=null){
_currentCircle.removeOverlays();
}
_currentCircle=null;
_circleMode=false;
}
function choosePoint(map,_25,_26){
if(_25&&_25 instanceof GMarker){
_26=_25.getLatLng();
}
if(_26==null){
return;
}
if(_circleMode){
chooseCirclePoint(map,_25,_26);
}else{
if(_wayPointsListManager!=null){
chooseWayPoint(map,_25,_26);
}
}
}
function drawTempPoint(map,_28){
if(_circleMode){
drawTempCircle(map,_28,false);
}else{
drawTempWayPoint(map,_28);
}
}
function load(){
var _29=false;
if(GBrowserIsCompatible()){
_29=true;
}
if(!_29){
window.location.replace("notCompatible.html");
return;
}
_tableManager=new TableManager();
_mapElement=document.getElementById("map");
_tableElement=document.getElementById("pointsTableDiv");
_innerElement=document.getElementById("inner");
_changeUnitsBoxElement=document.getElementById("changeUnitsBox");
changeUnits();
_map=new GMap2(_mapElement);
_map.setCenter(new GLatLng(41.3,-95.89),3);
_map.addControl(new GLargeMapControl());
_map.addControl(new GMapTypeControl());
startControl=new StartControl();
wayPointsInProgressControl=new WayPointsInProgressControl();
circleInProgressControl=new CircleInProgressControl();
GEvent.addListener(_map,"click",function(_2a,_2b){
choosePoint(_map,_2a,_2b);
});
GEvent.addListener(_map,"mousemove",function(_2c){
drawTempPoint(_map,_2c);
});
_map.addControl(startControl);
createWayPointIcon();
initGeoCoder();
adsManager=new GAdsManager(_map,"pub-2973724834177410");
adsManager.enable();
_fullyLoaded=true;
resizeBody();
}

