if(!this.JSON){this.JSON={};}
(function(){function f(n){return n<10?'0'+n:n;}
if(typeof Date.prototype.toJSON!=='function'){Date.prototype.toJSON=function(key){return isFinite(this.valueOf())?this.getUTCFullYear()+'-'+
f(this.getUTCMonth()+1)+'-'+
f(this.getUTCDate())+'T'+
f(this.getUTCHours())+':'+
f(this.getUTCMinutes())+':'+
f(this.getUTCSeconds())+'Z':null;};String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(key){return this.valueOf();};}
var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={'\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','"':'\\"','\\':'\\\\'},rep;function quote(string){escapable.lastIndex=0;return escapable.test(string)?'"'+string.replace(escapable,function(a){var c=meta[a];return typeof c==='string'?c:'\\u'+('0000'+a.charCodeAt(0).toString(16)).slice(-4);})+'"':'"'+string+'"';}
function str(key,holder){var i,k,v,length,mind=gap,partial,value=holder[key];if(value&&typeof value==='object'&&typeof value.toJSON==='function'){value=value.toJSON(key);}
if(typeof rep==='function'){value=rep.call(holder,key,value);}
switch(typeof value){case'string':return quote(value);case'number':return isFinite(value)?String(value):'null';case'boolean':case'null':return String(value);case'object':if(!value){return'null';}
gap+=indent;partial=[];if(Object.prototype.toString.apply(value)==='[object Array]'){length=value.length;for(i=0;i<length;i+=1){partial[i]=str(i,value)||'null';}
v=partial.length===0?'[]':gap?'[\n'+gap+
partial.join(',\n'+gap)+'\n'+
mind+']':'['+partial.join(',')+']';gap=mind;return v;}
if(rep&&typeof rep==='object'){length=rep.length;for(i=0;i<length;i+=1){k=rep[i];if(typeof k==='string'){v=str(k,value);if(v){partial.push(quote(k)+(gap?': ':':')+v);}}}}else{for(k in value){if(Object.hasOwnProperty.call(value,k)){v=str(k,value);if(v){partial.push(quote(k)+(gap?': ':':')+v);}}}}
v=partial.length===0?'{}':gap?'{\n'+gap+partial.join(',\n'+gap)+'\n'+
mind+'}':'{'+partial.join(',')+'}';gap=mind;return v;}}
if(typeof JSON.stringify!=='function'){JSON.stringify=function(value,replacer,space){var i;gap='';indent='';if(typeof space==='number'){for(i=0;i<space;i+=1){indent+=' ';}}else if(typeof space==='string'){indent=space;}
rep=replacer;if(replacer&&typeof replacer!=='function'&&(typeof replacer!=='object'||typeof replacer.length!=='number')){throw new Error('JSON.stringify');}
return str('',{'':value});};}
if(typeof JSON.parse!=='function'){JSON.parse=function(text,reviver){var j;function walk(holder,key){var k,v,value=holder[key];if(value&&typeof value==='object'){for(k in value){if(Object.hasOwnProperty.call(value,k)){v=walk(value,k);if(v!==undefined){value[k]=v;}else{delete value[k];}}}}
return reviver.call(holder,key,value);}
text=String(text);cx.lastIndex=0;if(cx.test(text)){text=text.replace(cx,function(a){return'\\u'+
('0000'+a.charCodeAt(0).toString(16)).slice(-4);});}
if(/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,'@').replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,']').replace(/(?:^|:|,)(?:\s*\[)+/g,''))){j=eval('('+text+')');return typeof reviver==='function'?walk({'':j},''):j;}
throw new SyntaxError('JSON.parse');};}}());function LatLon(lat,lon,rad){if(typeof(rad)=='undefined')rad=6371;this._lat=typeof(lat)=='number'?lat:typeof(lat)=='string'&&lat.trim()!=''?+lat:NaN;this._lon=typeof(lat)=='number'?lon:typeof(lon)=='string'&&lon.trim()!=''?+lon:NaN;this._radius=typeof(rad)=='number'?rad:typeof(rad)=='string'&&trim(lon)!=''?+rad:NaN;}
LatLon.prototype.distanceTo=function(point,precision){if(typeof precision=='undefined')precision=4;var R=this._radius;var lat1=this._lat.toRad(),lon1=this._lon.toRad();var lat2=point._lat.toRad(),lon2=point._lon.toRad();var dLat=lat2-lat1;var dLon=lon2-lon1;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.toPrecisionFixed(precision);}
LatLon.prototype.bearingTo=function(point){var lat1=this._lat.toRad(),lat2=point._lat.toRad();var dLon=(point._lon-this._lon).toRad();var y=Math.sin(dLon)*Math.cos(lat2);var x=Math.cos(lat1)*Math.sin(lat2)-
Math.sin(lat1)*Math.cos(lat2)*Math.cos(dLon);var brng=Math.atan2(y,x);return(brng.toDeg()+360)%360;}
LatLon.prototype.finalBearingTo=function(point){var lat1=point._lat.toRad(),lat2=this._lat.toRad();var dLon=(this._lon-point._lon).toRad();var y=Math.sin(dLon)*Math.cos(lat2);var x=Math.cos(lat1)*Math.sin(lat2)-
Math.sin(lat1)*Math.cos(lat2)*Math.cos(dLon);var brng=Math.atan2(y,x);return(brng.toDeg()+180)%360;}
LatLon.prototype.midpointTo=function(point){lat1=this._lat.toRad(),lon1=this._lon.toRad();lat2=point._lat.toRad();var dLon=(point._lon-this._lon).toRad();var Bx=Math.cos(lat2)*Math.cos(dLon);var By=Math.cos(lat2)*Math.sin(dLon);lat3=Math.atan2(Math.sin(lat1)+Math.sin(lat2),Math.sqrt((Math.cos(lat1)+Bx)*(Math.cos(lat1)+Bx)+By*By));lon3=lon1+Math.atan2(By,Math.cos(lat1)+Bx);return new LatLon(lat3.toDeg(),lon3.toDeg());}
LatLon.prototype.destinationPoint=function(brng,dist){dist=typeof(dist)=='number'?dist:typeof(dist)=='string'&&dist.trim()!=''?+dist:NaN;dist=dist/this._radius;brng=brng.toRad();var lat1=this._lat.toRad(),lon1=this._lon.toRad();var lat2=Math.asin(Math.sin(lat1)*Math.cos(dist)+
Math.cos(lat1)*Math.sin(dist)*Math.cos(brng));var lon2=lon1+Math.atan2(Math.sin(brng)*Math.sin(dist)*Math.cos(lat1),Math.cos(dist)-Math.sin(lat1)*Math.sin(lat2));lon2=(lon2+3*Math.PI)%(2*Math.PI)-Math.PI;return new LatLon(lat2.toDeg(),lon2.toDeg());}
LatLon.intersection=function(p1,brng1,p2,brng2){brng1=typeof brng1=='number'?brng1:typeof brng1=='string'&&trim(brng1)!=''?+brng1:NaN;brng2=typeof brng2=='number'?brng2:typeof brng2=='string'&&trim(brng2)!=''?+brng2:NaN;lat1=p1._lat.toRad(),lon1=p1._lon.toRad();lat2=p2._lat.toRad(),lon2=p2._lon.toRad();brng13=brng1.toRad(),brng23=brng2.toRad();dLat=lat2-lat1,dLon=lon2-lon1;dist12=2*Math.asin(Math.sqrt(Math.sin(dLat/2)*Math.sin(dLat/2)+
Math.cos(lat1)*Math.cos(lat2)*Math.sin(dLon/2)*Math.sin(dLon/2)));if(dist12==0)return null;brngA=Math.acos((Math.sin(lat2)-Math.sin(lat1)*Math.cos(dist12))/(Math.sin(dist12)*Math.cos(lat1)));if(isNaN(brngA))brngA=0;brngB=Math.acos((Math.sin(lat1)-Math.sin(lat2)*Math.cos(dist12))/(Math.sin(dist12)*Math.cos(lat2)));if(Math.sin(lon2-lon1)>0){brng12=brngA;brng21=2*Math.PI-brngB;}else{brng12=2*Math.PI-brngA;brng21=brngB;}
alpha1=(brng13-brng12+Math.PI)%(2*Math.PI)-Math.PI;alpha2=(brng21-brng23+Math.PI)%(2*Math.PI)-Math.PI;if(Math.sin(alpha1)==0&&Math.sin(alpha2)==0)return null;if(Math.sin(alpha1)*Math.sin(alpha2)<0)return null;alpha3=Math.acos(-Math.cos(alpha1)*Math.cos(alpha2)+
Math.sin(alpha1)*Math.sin(alpha2)*Math.cos(dist12));dist13=Math.atan2(Math.sin(dist12)*Math.sin(alpha1)*Math.sin(alpha2),Math.cos(alpha2)+Math.cos(alpha1)*Math.cos(alpha3))
lat3=Math.asin(Math.sin(lat1)*Math.cos(dist13)+
Math.cos(lat1)*Math.sin(dist13)*Math.cos(brng13));dLon13=Math.atan2(Math.sin(brng13)*Math.sin(dist13)*Math.cos(lat1),Math.cos(dist13)-Math.sin(lat1)*Math.sin(lat3));lon3=lon1+dLon13;lon3=(lon3+Math.PI)%(2*Math.PI)-Math.PI;return new LatLon(lat3.toDeg(),lon3.toDeg());}
LatLon.prototype.rhumbDistanceTo=function(point){var R=this._radius;var lat1=this._lat.toRad(),lat2=point._lat.toRad();var dLat=(point._lat-this._lat).toRad();var dLon=Math.abs(point._lon-this._lon).toRad();var dPhi=Math.log(Math.tan(lat2/2+Math.PI/4)/Math.tan(lat1/2+Math.PI/4));var q=(!isNaN(dLat/dPhi))?dLat/dPhi:Math.cos(lat1);if(dLon>Math.PI)dLon=2*Math.PI-dLon;var dist=Math.sqrt(dLat*dLat+q*q*dLon*dLon)*R;return dist.toPrecisionFixed(4);}
LatLon.prototype.rhumbBearingTo=function(point){var lat1=this._lat.toRad(),lat2=point._lat.toRad();var dLon=(point._lon-this._lon).toRad();var dPhi=Math.log(Math.tan(lat2/2+Math.PI/4)/Math.tan(lat1/2+Math.PI/4));if(Math.abs(dLon)>Math.PI)dLon=dLon>0?-(2*Math.PI-dLon):(2*Math.PI+dLon);var brng=Math.atan2(dLon,dPhi);return(brng.toDeg()+360)%360;}
LatLon.prototype.rhumbDestinationPoint=function(brng,dist){var R=this._radius;var d=parseFloat(dist)/R;var lat1=this._lat.toRad(),lon1=this._lon.toRad();brng=brng.toRad();var lat2=lat1+d*Math.cos(brng);var dLat=lat2-lat1;var dPhi=Math.log(Math.tan(lat2/2+Math.PI/4)/Math.tan(lat1/2+Math.PI/4));var q=(!isNaN(dLat/dPhi))?dLat/dPhi:Math.cos(lat1);var dLon=d*Math.sin(brng)/q;if(Math.abs(lat2)>Math.PI/2)lat2=lat2>0?Math.PI-lat2:-(Math.PI-lat2);lon2=(lon1+dLon+3*Math.PI)%(2*Math.PI)-Math.PI;return new LatLon(lat2.toDeg(),lon2.toDeg());}
LatLon.prototype.lat=function(format,dp){if(typeof format=='undefined')return this._lat;return Geo.toLat(this._lat,format,dp);}
LatLon.prototype.lon=function(format,dp){if(typeof format=='undefined')return this._lon;return Geo.toLon(this._lon,format,dp);}
LatLon.prototype.toString=function(format,dp){if(typeof format=='undefined')format='dms';if(isNaN(this._lat)||isNaN(this._lon))return'-,-';return Geo.toLat(this._lat,format,dp)+', '+Geo.toLon(this._lon,format,dp);}
if(typeof(Number.prototype.toRad)==="undefined"){Number.prototype.toRad=function(){return this*Math.PI/180;}}
if(typeof(Number.prototype.toDeg)==="undefined"){Number.prototype.toDeg=function(){return this*180/Math.PI;}}
if(typeof(Number.prototype.toPrecisionFixed)==="undefined"){Number.prototype.toPrecisionFixed=function(precision){if(isNaN(this))return'NaN';var numb=this<0?-this:this;var sign=this<0?'-':'';if(numb==0){n='0.';while(precision--)n+='0';return n};var scale=Math.ceil(Math.log(numb)*Math.LOG10E);var n=String(Math.round(numb*Math.pow(10,precision-scale)));if(scale>0){l=scale-n.length;while(l-->0)n=n+'0';if(scale<n.length)n=n.slice(0,scale)+'.'+n.slice(scale);}else{while(scale++<0)n='0'+n;n='0.'+n;}
return sign+n;}}
if(typeof(String.prototype.trim)==="undefined"){String.prototype.trim=function(){return String(this).replace(/^\s\s*/,'').replace(/\s\s*$/,'');}}
var Geo={};Geo.parseDMS=function(dmsStr){if(typeof deg=='object')throw new TypeError('Geo.parseDMS - dmsStr is [DOM?] object');if(typeof dmsStr==='number'&&isFinite(dmsStr))return Number(dmsStr);var dms=String(dmsStr).trim().replace(/^-/,'').replace(/[NSEW]$/i,'').split(/[^0-9.,]+/);if(dms[dms.length-1]=='')dms.splice(dms.length-1);if(dms=='')return NaN;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:var deg=dms[0];if(/[NS]/i.test(dmsStr))deg='0'+deg;if(/[0-9]{7}/.test(deg))deg=deg.slice(0,3)/1+deg.slice(3,5)/60+deg.slice(5)/3600;break;default:return NaN;}
if(/^-|[WS]$/i.test(dmsStr.trim()))deg=-deg;return Number(deg);}
Geo.toDMS=function(deg,format,dp){if(typeof deg=='object')throw new TypeError('Geo.toDMS - deg is [DOM?] object');if(isNaN(deg))return'NaN';if(typeof format=='undefined')format='dms';if(typeof dp=='undefined'){switch(format){case'd':dp=4;break;case'dm':dp=2;break;case'dms':dp=0;break;default:format='dms';dp=0;}}
deg=Math.abs(deg);switch(format){case'd':d=deg.toFixed(dp);if(d<100)d='0'+d;if(d<10)d='0'+d;dms=d+'\u00B0';break;case'dm':var min=(deg*60).toFixed(dp);var d=Math.floor(min/60);var m=(min%60).toFixed(dp);if(d<100)d='0'+d;if(d<10)d='0'+d;if(m<10)m='0'+m;dms=d+'\u00B0'+m+'\u2032';break;case'dms':var sec=(deg*3600).toFixed(dp);var d=Math.floor(sec/3600);var m=Math.floor(sec/60)%60;var s=(sec%60).toFixed(dp);if(d<100)d='0'+d;if(d<10)d='0'+d;if(m<10)m='0'+m;if(s<10)s='0'+s;dms=d+'\u00B0'+m+'\u2032'+s+'\u2033';break;}
return dms;}
Geo.toLat=function(deg,format,dp){var lat=Geo.toDMS(deg,format,dp);return lat==''?'':lat.slice(1)+(deg<0?'S':'N');}
Geo.toLon=function(deg,format,dp){var lon=Geo.toDMS(deg,format,dp);return lon==''?'':lon+(deg<0?'W':'E');}
Geo.toBrng=function(deg,format,dp){deg=(Number(deg)+360)%360;var brng=Geo.toDMS(deg,format,dp);return brng.replace('360','0');}
jQuery.fn.startWait=function(basepath){var id=this.attr('id');this.append("<img id='"+id+"_wait' src='"+basepath+"/images/wait.gif' />");}
jQuery.fn.startWaitPrepend=function(basepath){var id=this.attr('id');this.prepend("<img id='"+id+"_wait' src='"+basepath+"/images/wait.gif' />");}
jQuery.fn.stopWait=function(){var id=this.attr('id');$("#"+id+"_wait").remove();}
jQuery.fn.mshow=function(){this.css('visibility','visible');this.show();}
jQuery.fn.loadAndShow=function(path,basepath,closebutton,callback){this.html('');this.mshow();this.startWait(basepath);if(callback)callback();var div=this;$.get(path,function(data){if(closebutton){div.html('<a href="Javascript:void(0)" onclick="$(\'#'+div.attr('id')+'\').hide()" class="close_button"></a><div class="clearer"></div>');}else{div.html('');}
div.append(data);if(callback)callback();});}
jQuery.fn.center=function(){this.css("position","absolute");this.css("top",($(window).height()-this.outerHeight())/2+$(window).scrollTop()+"px");this.css("left",($(window).width()-this.outerWidth())/2+$(window).scrollLeft()+"px");return this;}
jQuery.fn.mtoggle=function(linkObj,txtHide,txtShow){this.toggle();linkObj.html(this.is(':visible')?txtHide:txtShow);}
jQuery.fn.inputTip=function(tooltipClass){var input=$(this);var content=input.attr('tip');var tooltipObj=null;if(content!=''&&content!==undefined){var id='tooltip'+input.attr('id');var html='<div id="'+id+'" class="'+tooltipClass+'">'+content+'</div>';$(this).parent().prev().append(html);$('#'+id).prev().removeClass('inlinelabel');}}
jQuery.fn.geoLocalize=function(map,callback){if(navigator.geolocation){navigator.geolocation.getCurrentPosition(function(position){currentLocation=new google.maps.LatLng(position.coords.latitude,position.coords.longitude);map.setCenter(currentLocation);if(callback){callback(position);}},function(){});}}
autoCompleteGeocoder=new google.maps.Geocoder();geocoder=new google.maps.Geocoder();jQuery.fn.geoAC=function(language,callback){var div=this;this.blur(function(){geocoder.geocode({'address':div.val(),'language':language},function(results,status){if(status==google.maps.GeocoderStatus.OK){var geocodeResult=results[0];callback({label:geocodeResult.formatted_address,value:geocodeResult.formatted_address,location:geocodeResult.geometry.location,geometry:geocodeResult.geometry,address_components:geocodeResult.address_components,types:geocodeResult.types});}else{callback({error:true});}});});this.autocomplete({source:function(request,response){autoCompleteGeocoder.geocode({'address':request.term,'language':language},function(results,status){response($.map(results,function(item){return{label:item.formatted_address,value:item.formatted_address,location:item.geometry.location,geometry:item.geometry,address_components:item.address_components,types:item.types}}));})},select:function(event,ui){callback(ui.item);}});this.keypress(function(e){var code=(e.keyCode?e.keyCode:e.which);if(code==13){geocoder
geocoder.geocode({'address':div.val(),'language':language},function(results,status){if(status==google.maps.GeocoderStatus.OK){geocodeResult=results[0];callback({label:geocodeResult.formatted_address,value:geocodeResult.formatted_address,location:geocodeResult.geometry.location,geometry:geocodeResult.geometry,address_components:geocodeResult.address_components,types:geocodeResult.types});}else{callback({error:true});}});}});}
jQuery.getBounds=function(inBounds,radiusKm){var mBounds=inBounds;var ne=new LatLon(mBounds.getNorthEast().lat(),mBounds.getNorthEast().lng());var sw=new LatLon(mBounds.getSouthWest().lat(),mBounds.getSouthWest().lng());if(radiusKm>0){var ne2=ne.destinationPoint(45,radiusKm);var sw2=sw.destinationPoint(225,radiusKm);mBounds=new google.maps.LatLngBounds(new google.maps.LatLng(sw2._lat,sw2._lon),new google.maps.LatLng(ne2._lat,ne2._lon));}
return mBounds;}
jQuery.writeBoundsInInput=function(mBounds,lat,lng){var ne=mBounds.getNorthEast();var so=mBounds.getSouthWest();$("#"+lat+"Min").val(Math.min(ne.lat(),so.lat()));$("#"+lat+"Max").val(Math.max(ne.lat(),so.lat()));$("#"+lng+"Min").val(Math.min(ne.lng(),so.lng()));$("#"+lng+"Max").val(Math.max(ne.lng(),so.lng()));}
