/*

<script src="//www.google.com/jsapi?key=ABQIAAAAbK02ADRtLTOb3L1uL2Gs1hRJik_ZEENuO7QpvsLXX3F0fhaiehRPECtz-r6-7J-B1js-KbjX4cBtWg"></script>
<!--ABQIAAAAbK02ADRtLTOb3L1uL2Gs1hQeiyPgaKHrnlsWgumBopUc2IJ_JhRc_WRYdBy3p_1H2ituAXFLBwPMkw-->

google.load("jquery", "1.4");
google.load("earth", "1");
google.load("maps", "2");

*/

// window.log business
window.log = function(){ log.history = log.history || []; log.history.push(arguments); if(this.console){ console.log( Array.prototype.slice.call(arguments)); } };

// Keep check on document.write()
//;(function(doc){ var write = doc.write; doc.write = function(q){ log('document.write(): ',arguments); if (/docwriteregexwhitelist/.test(q)) write.apply(doc,arguments); }; })(document);

// geoxml3.js. http://code.google.com/p/geoxml3/
if(!String.prototype.trim){String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g,"")}}geoXML3=window.geoXML3||{instances:[]};geoXML3.parser=function(f){var r=geoXML3.combineOptions(f,{singleInfoWindow:false,processStyles:true,zoom:true});var n=[];var i;var k;if(!r.infoWindow&&r.singleInfoWindow){r.infoWindow=new google.maps.InfoWindow()}var p=function(D,y){if(!k){k="geoXML3.instances["+(geoXML3.instances.push(this)-1)+"]"}if(typeof D==="string"){D=[D]}var C={parser:this,docSet:y||[],remaining:D.length,parseOnly:!(r.afterParse||r.processStyles)};var E,z;for(var A=0;A<D.length;A++){var B=D[A].split("?")[0];for(z=0;z<n.length;z++){if(B===n[z].baseUrl){E=n[z];E.reload=true;n.splice(z,1);break}}if(z>=n.length){E=new Object();E.baseUrl=B}E.url=D[A];E.internals=C;C.docSet.push(E);a(E.url,E)}};function a(y,z){geoXML3.fetchXML(y,function(A){w(A,z)})}var s=function(z){if(!z){z=n[0]}var y;if(!!z.markers){for(y=0;y<z.markers.length;y++){if(!!z.markers[y].infoWindow){z.markers[y].infoWindow.close()}z.markers[y].setVisible(false)}}if(!!z.ggroundoverlays){for(y=0;y<z.ggroundoverlays.length;y++){z.ggroundoverlays[y].setOpacity(0)}}if(!!z.gpolylines){for(y=0;y<z.gpolylines.length;y++){z.gpolylines[y].setMap(null)}}if(!!z.gpolygons){for(y=0;y<z.gpolygons.length;y++){z.gpolygons[y].setMap(null)}}};var x=function(z){if(!z){z=n[0]}var y;if(!!z.markers){for(y=0;y<z.markers.length;y++){z.markers[y].setVisible(true)}}if(!!z.ggroundoverlays){for(y=0;y<z.ggroundoverlays.length;y++){z.ggroundoverlays[y].setOpacity(z.ggroundoverlays[y].percentOpacity_)}}if(!!z.gpolylines){for(y=0;y<z.gpolylines.length;y++){z.gpolylines[y].setMap(r.map)}}if(!!z.gpolygons){for(y=0;y<z.gpolygons.length;y++){z.gpolygons[y].setMap(r.map)}}};var t={color:"ff000000",width:1,fill:true,outline:true,fillcolor:"3fff0000"};function h(A,B,y){var z=geoXML3.nodeValue;B[y]=B[y]||v(t);var C=A.getElementsByTagName("Icon");if(!!C&&!!C.length&&(C.length>0)){B[y].href=z(C[0].getElementsByTagName("href")[0]);B[y].scale=z(C[0].getElementsByTagName("scale")[0]);if(!isNaN(B[y].scale)){B[y].scale=1}}C=A.getElementsByTagName("LineStyle");if(!!C&&!!C.length&&(C.length>0)){B[y].color=z(C[0].getElementsByTagName("color")[0]),B[y].width=z(C[0].getElementsByTagName("width")[0])}C=A.getElementsByTagName("PolyStyle");if(!!C&&!!C.length&&(C.length>0)){B[y].outline=o(C[0].getElementsByTagName("outline")[0]);B[y].fill=o(C[0].getElementsByTagName("fill")[0]);B[y].fillcolor=z(C[0].getElementsByTagName("color")[0])}return B[y]}function v(A){if(A==null||typeof(A)!="object"){return A}var y=new A.constructor();for(var z in A){y[z]=v(A[z])}return y}function d(C,G,H){var E=geoXML3.nodeValue;var B=C.getElementsByTagName("Pair");var A=new Object();for(var z=0;z<B.length;z++){var D=E(B[z].getElementsByTagName("key")[0]);var y=E(B[z].getElementsByTagName("Style")[0]);var F=E(B[z].getElementsByTagName("styleUrl")[0]);if(!!y){h(y,A[D],H)}else{if(!!F&&!!G[F]){A[D]=v(G[F])}}}if(!!A.normal){G[H]=v(A.normal)}else{G[H]=v(t)}if(!!A.highlight){l(A.highlight)}G[H].map=v(A)}function o(y){var z=geoXML3.nodeValue(y);if(!z){return true}if(z){z=parseInt(z)}if(isNaN(z)){return true}if(z==0){return false}else{return true}}function u(A,J){var G=A.getElementsByTagName(J);var y=[];for(var E=0;E<G.length;E++){var z=G[E].getElementsByTagName("coordinates");if(!z){if(y.length>0){break}else{return[{coordinates:[]}]}}for(var C=0;C<z.length;C++){var F=geoXML3.nodeValue(z[C]).trim();F=F.replace(/,\s+/g,",");var I=F.split(/\s+/g);var H=I.length;var D=[];for(var B=0;B<H;B++){F=I[B].split(",");if(!isNaN(F[0])&&!isNaN(F[1])){D.push({lat:parseFloat(F[1]),lng:parseFloat(F[0]),alt:parseFloat(F[2])})}}y.push({coordinates:D})}}return y}var w=function(K,A){if(!K){geoXML3.log("Unable to retrieve "+A.url);if(r.failedParse){r.failedParse(A)}}else{if(!A){throw"geoXML3 internal error: render called with null document"}else{var ae;var P={};A.placemarks=[];A.groundoverlays=[];A.ggroundoverlays=[];A.networkLinks=[];A.gpolygons=[];A.gpolylines=[];var M=geoXML3.nodeValue;var B,U;nodes=K.getElementsByTagName("Style");nodeCount=nodes.length;for(ae=0;ae<nodeCount;ae++){thisNode=nodes[ae];var G=thisNode.getAttribute("id");if(!!G){B="#"+G;h(thisNode,P,B)}}nodes=K.getElementsByTagName("StyleMap");for(ae=0;ae<nodes.length;ae++){thisNode=nodes[ae];var G=thisNode.getAttribute("id");if(!!G){B="#"+G;d(thisNode,P,B)}}A.styles=P;if(!!r.processStyles||!r.createMarker){q(A)}if(!!A.reload&&!!A.markers){for(ae=0;ae<A.markers.length;ae++){A.markers[ae].active=false}}var y,Q,F,Y,ai,T;var y,F,Y,X,ai,J,ah;var ad=K.getElementsByTagName("Placemark");for(pm=0;pm<ad.length;pm++){Q=ad[pm];y={name:geoXML3.nodeValue(Q.getElementsByTagName("name")[0]),description:geoXML3.nodeValue(Q.getElementsByTagName("description")[0]),styleUrl:geoXML3.nodeValue(Q.getElementsByTagName("styleUrl")[0])};y.style=A.styles[y.styleUrl]||v(t);var W=Q.getElementsByTagName("Style");if(W&&(W.length>0)){var ab=h(Q,A.styles,"inline");l(ab);if(ab){y.style=ab}}if(/^https?:\/\//.test(y.description)){y.description=['<a href="',y.description,'">',y.description,"</a>"].join("")}var S=Q.getElementsByTagName("coordinates");var Z=null;if(!!S&&(S.length>0)){for(var E=0;E<S.length;E++){if(!S[E].parentNode||!S[E].parentNode.nodeName){}else{var aj=S[E].parentNode;Z=aj.nodeName;switch(Z){case"Point":y.Point=u(Q,"Point")[0];y.latlng=new google.maps.LatLng(y.Point.coordinates[0].lat,y.Point.coordinates[0].lng);X=1;break;case"LinearRing":J=Q.getElementsByTagName("Polygon");if(!y.Polygon){y.Polygon=[{outerBoundaryIs:{coordinates:[]},innerBoundaryIs:[{coordinates:[]}]}]}for(var I=0;I<J.length;I++){y.Polygon[I]={outerBoundaryIs:{coordinates:[]},innerBoundaryIs:[{coordinates:[]}]};y.Polygon[I].outerBoundaryIs=u(J[I],"outerBoundaryIs");y.Polygon[I].innerBoundaryIs=u(J[I],"innerBoundaryIs")}ah=y.Polygon[0].outerBoundaryIs;break;case"LineString":X=0;y.LineString=u(Q,"LineString");break;default:break}}}}if(!!r.pmParseFn){r.pmParseFn(Q,y)}A.placemarks.push(y);if(y.Point){if(!!google.maps){A.bounds=A.bounds||new google.maps.LatLngBounds();A.bounds.extend(y.latlng)}if(!!r.createMarker){r.createMarker(y,A)}else{var C=false;if(!!A){A.markers=A.markers||[];if(A.reload){for(var ac=0;ac<A.markers.length;ac++){if(A.markers[ac].getPosition().equals(y.latlng)){C=A.markers[ac].active=true;break}}}}if(!C){ai=c(y,A);ai.active=true}}}if(y.Polygon){if(!!A){A.gpolygons=A.gpolygons||[]}if(!!r.createPolygon){T=r.createPolygon(y,A)}else{T=b(y,A);T.active=true}if(!!google.maps){A.bounds=A.bounds||new google.maps.LatLngBounds();A.bounds.union(T.bounds)}}if(y.LineString){if(!!A){A.gpolylines=A.gpolylines||[]}if(!!r.createPolyline){T=r.createPolyline(y,A)}else{T=g(y,A);T.active=true}if(!!google.maps){A.bounds=A.bounds||new google.maps.LatLngBounds();A.bounds.union(T.bounds)}}}if(!!A.reload&&!!A.markers){for(ae=A.markers.length-1;ae>=0;ae--){if(!A.markers[ae].active){if(!!A.markers[ae].infoWindow){A.markers[ae].infoWindow.close()}A.markers[ae].setMap(null);A.markers.splice(ae,1)}}}if(!!A.reload&&!!A.groundoverlays){for(ae=0;ae<A.groundoverlays.length;ae++){A.groundoverlays[ae].active=false}}if(!!A){A.groundoverlays=A.groundoverlays||[]}var ag,N,O,af;var L=K.getElementsByTagName("GroundOverlay");for(ae=0;ae<L.length;ae++){Q=L[ae];ag={name:geoXML3.nodeValue(Q.getElementsByTagName("name")[0]),description:geoXML3.nodeValue(Q.getElementsByTagName("description")[0]),icon:{href:geoXML3.nodeValue(Q.getElementsByTagName("href")[0])},latLonBox:{north:parseFloat(geoXML3.nodeValue(Q.getElementsByTagName("north")[0])),east:parseFloat(geoXML3.nodeValue(Q.getElementsByTagName("east")[0])),south:parseFloat(geoXML3.nodeValue(Q.getElementsByTagName("south")[0])),west:parseFloat(geoXML3.nodeValue(Q.getElementsByTagName("west")[0]))}};if(!!google.maps){A.bounds=A.bounds||new google.maps.LatLngBounds();A.bounds.union(new google.maps.LatLngBounds(new google.maps.LatLng(ag.latLonBox.south,ag.latLonBox.west),new google.maps.LatLng(ag.latLonBox.north,ag.latLonBox.east)))}var V=Q.getElementsByTagName("color");if(V&&V.length&&(V.length>0)){ag.opacity=geoXML3.getOpacity(M(V[0]))}else{ag.opacity=0.45}A.groundoverlays.push(ag);if(!!r.createOverlay){r.createOverlay(ag,A)}else{var C=false;if(!!A){A.groundoverlays=A.groundoverlays||[];if(A.reload){overlayBounds=new google.maps.LatLngBounds(new google.maps.LatLng(ag.latLonBox.south,ag.latLonBox.west),new google.maps.LatLng(ag.latLonBox.north,ag.latLonBox.east));var H=A.groundoverlays;for(ae=H.length;ae--;){if((H[ae].bounds().equals(overlayBounds))&&(H.url_===ag.icon.href)){C=H[ae].active=true;break}}}}if(!C){af=j(ag,A);af.active=true}}if(!!A.reload&&!!A.groundoverlays&&!!A.groundoverlays.length){var H=A.groundoverlays;for(ae=H.length;ae--;){if(!H[ae].active){H[ae].remove();H.splice(ae,1)}}A.groundoverlays=H}}var R;var z=document.location.pathname.split("/");z=z.splice(0,z.length-1).join("/");var D=K.getElementsByTagName("NetworkLink");for(ae=0;ae<D.length;ae++){Q=D[ae];R={name:geoXML3.nodeValue(Q.getElementsByTagName("name")[0]),link:{href:geoXML3.nodeValue(Q.getElementsByTagName("href")[0]),refreshMode:geoXML3.nodeValue(Q.getElementsByTagName("refreshMode")[0])}};if(R.link.refreshMode===""){R.link.refreshMode="onChange"}if(R.link.refreshMode==="onInterval"){R.link.refreshInterval=parseFloat(geoXML3.nodeValue(Q.getElementsByTagName("refreshInterval")[0]));if(isNaN(R.link.refreshInterval)){R.link.refreshInterval=0}}else{if(R.link.refreshMode==="onChange"){R.link.viewRefreshMode=geoXML3.nodeValue(Q.getElementsByTagName("viewRefreshMode")[0]);if(R.link.viewRefreshMode===""){R.link.viewRefreshMode="never"}if(R.link.viewRefreshMode==="onStop"){R.link.viewRefreshTime=geoXML3.nodeValue(Q.getElementsByTagName("refreshMode")[0]);R.link.viewFormat=geoXML3.nodeValue(Q.getElementsByTagName("refreshMode")[0]);if(R.link.viewFormat===""){R.link.viewFormat="BBOX=[bboxWest],[bboxSouth],[bboxEast],[bboxNorth]"}}}}if(!/^[\/|http]/.test(R.link.href)){R.link.href=z+"/"+R.link.href}if((R.link.refreshMode==="onInterval")&&(R.link.refreshInterval>0)){setInterval(k+'.parse("'+R.link.href+'")',1000*R.link.refreshInterval)}else{if(R.link.refreshMode==="onChange"){if(R.link.viewRefreshMode==="never"){A.internals.parser.parse(R.link.href,A.internals.docSet)}else{if(R.link.viewRefreshMode==="onStop"){}}}}}}}if(!!A.bounds){A.internals.bounds=A.internals.bounds||new google.maps.LatLngBounds();A.internals.bounds.union(A.bounds)}if(!!A.markers||!!A.groundoverlays||!!A.gpolylines||!!A.gpolygons){A.internals.parseOnly=false}A.internals.remaining-=1;if(A.internals.remaining===0){if(r.zoom&&!!A.internals.bounds){r.map.fitBounds(A.internals.bounds)}if(r.afterParse){r.afterParse(A.internals.docSet)}if(!A.internals.parseOnly){for(var ae=(A.internals.docSet.length-1);ae>=0;ae--){n.push(A.internals.docSet[ae])}}}};var e=function(z){var y={};if(z){aa=z.substr(0,2);bb=z.substr(2,2);gg=z.substr(4,2);rr=z.substr(6,2);y.color="#"+rr+gg+bb;y.opacity=parseInt(aa,16)/256}else{y.color=m();y.opacity=0.45}return y};var m=function(){var y="#";var A=Math.random()*8388607;var z=A.toString(16);y+=z.substring(0,z.indexOf("."));return y};var l=function(z){var E=new google.maps.Point(0,0);if(!!z.href){var C=/\/(red|blue|green|yellow|lightblue|purple|pink|orange|pause|go|stop)(-dot)?\.png/;if(C.test(z.href)){var D=new google.maps.Point(16*z.scale,32*z.scale)}else{var D=new google.maps.Point(16*z.scale,16*z.scale)}z.icon=new google.maps.MarkerImage(z.href,new google.maps.Size(32*z.scale,32*z.scale),E,D,new google.maps.Size(32,32));var y=/\/(red|blue|green|yellow|lightblue|purple|pink|orange)(-dot)?\.png/;var B=new google.maps.Size(59,32);var A=new google.maps.Point(16,32);if(y.test(z.href)){z.shadow=new google.maps.MarkerImage("http://maps.google.com/mapfiles/ms/micons/msmarker.shadow.png",B,E,A)}else{if(z.href.indexOf("-pushpin.png")>-1){z.shadow=new google.maps.MarkerImage("http://maps.google.com/mapfiles/ms/micons/pushpin_shadow.png",B,E,A)}else{z.shadow=new google.maps.MarkerImage(z.href.replace(".png",".shadow.png"),B,E,A)}}}};var q=function(z){for(var y in z.styles){l(z.styles[y])}};var c=function(A,B){var z=geoXML3.combineOptions(r.markerOptions,{map:r.map,position:new google.maps.LatLng(A.Point.coordinates[0].lat,A.Point.coordinates[0].lng),title:A.name,zIndex:Math.round(A.Point.coordinates[0].lat*-100000)<<5,icon:A.style.icon,shadow:A.style.shadow});var y=new google.maps.Marker(z);if(!!B){B.markers.push(y)}var C=geoXML3.combineOptions(r.infoWindowOptions,{content:'<div class="geoxml3_infowindow"><h3>'+A.name+"</h3><div>"+A.description+"</div></div>",pixelOffset:new google.maps.Size(0,2)});if(r.infoWindow){y.infoWindow=r.infoWindow}else{y.infoWindow=new google.maps.InfoWindow(C)}google.maps.event.addListener(y,"click",function(){this.infoWindow.close();y.infoWindow.setOptions(C);this.infoWindow.open(this.map,this)});A.marker=y;return y};var j=function(C,B){if(!window.ProjectedOverlay){throw"geoXML3 error: ProjectedOverlay not found while rendering GroundOverlay from KML"}var z=new google.maps.LatLngBounds(new google.maps.LatLng(C.latLonBox.south,C.latLonBox.west),new google.maps.LatLng(C.latLonBox.north,C.latLonBox.east));var A=geoXML3.combineOptions(r.overlayOptions,{percentOpacity:C.opacity*100});var y=new ProjectedOverlay(r.map,C.icon.href,z,A);if(!!B){B.ggroundoverlays=B.ggroundoverlays||[];B.ggroundoverlays.push(y)}return y};var g=function(C,H){var J=[];for(var A=0;A<C.LineString.length;A++){var E=C.LineString[A].coordinates;var y=new google.maps.LatLngBounds();for(var B=0;B<E.length;B++){var K=new google.maps.LatLng(E[B].lat,E[B].lng);J.push(K);y.extend(K)}}var G=J[Math.floor(J.length/2)];var D=e(C.style.color);var I=geoXML3.combineOptions(r.polylineOptions,{map:r.map,path:J,strokeColor:D.color,strokeWeight:C.style.width,strokeOpacity:D.opacity,title:C.name});var F=geoXML3.combineOptions(r.infoWindowOptions,{content:'<div class="geoxml3_infowindow"><h3>'+C.name+"</h3><div>"+C.description+"</div></div>",pixelOffset:new google.maps.Size(0,2)});var z=new google.maps.Polyline(I);z.bounds=y;if(r.infoWindow){z.infoWindow=r.infoWindow}else{z.infoWindow=new google.maps.InfoWindow(F)}google.maps.event.addListener(z,"click",function(L){z.infoWindow.close();z.infoWindow.setOptions(F);if(L&&L.latLng){z.infoWindow.setPosition(L.latLng)}else{z.infoWindow.setPosition(G)}z.infoWindow.open(this.map)});if(!!H){H.gpolylines.push(z)}C.polyline=z;return z};var b=function(E,K){var y=new google.maps.LatLngBounds();var G=0;var O=[];for(var A=0;A<E.Polygon.length;A++){for(var B=0;B<E.Polygon[A].outerBoundaryIs.length;B++){var I=E.Polygon[A].outerBoundaryIs[B].coordinates;var N=[];for(var C=0;C<I.length;C++){var M=new google.maps.LatLng(I[C].lat,I[C].lng);N.push(M);y.extend(M)}O.push(N);G+=N.length}for(var B=0;B<E.Polygon[A].innerBoundaryIs.length;B++){var I=E.Polygon[A].innerBoundaryIs[B].coordinates;var N=[];for(var C=0;C<I.length;C++){var M=new google.maps.LatLng(I[C].lat,I[C].lng);N.push(M);y.extend(M)}O.push(N);G+=N.length}}var F=e(E.style.color);var H=e(E.style.fillcolor);if(!E.style.fill){H.opacity=0}var D=E.style.width;if(!E.style.outline){D=0;F.opacity=0}var L=geoXML3.combineOptions(r.polygonOptions,{map:r.map,paths:O,title:E.name,strokeColor:F.color,strokeWeight:D,strokeOpacity:F.opacity,fillColor:H.color,fillOpacity:H.opacity});var J=geoXML3.combineOptions(r.infoWindowOptions,{content:'<div class="geoxml3_infowindow"><h3>'+E.name+"</h3><div>"+E.description+"</div></div>",pixelOffset:new google.maps.Size(0,2)});var z=new google.maps.Polygon(L);z.bounds=y;if(r.infoWindow){z.infoWindow=r.infoWindow}else{z.infoWindow=new google.maps.InfoWindow(J)}google.maps.event.addListener(z,"click",function(P){z.infoWindow.close();z.infoWindow.setOptions(J);if(P&&P.latLng){z.infoWindow.setPosition(P.latLng)}else{z.infoWindow.setPosition(z.bounds.getCenter())}z.infoWindow.open(this.map)});if(!!K){K.gpolygons.push(z)}E.polygon=z;return z};return{options:r,docs:n,parse:p,hideDocument:s,showDocument:x,processStyles:q,createMarker:c,createOverlay:j,createPolyline:g,createPolygon:b}};geoXML3.getOpacity=function(b){if(!!b&&(b!=="")&&(b.length==8)){var a=parseInt(b.substr(0,2),16);return a/255}else{return 1}};geoXML3.log=function(a){if(!!window.console){console.log(a)}else{alert("log:"+a)}};geoXML3.combineOptions=function(c,b){var a={};if(!!c){for(var d in c){if(c.hasOwnProperty(d)){a[d]=c[d]}}}if(!!b){for(d in b){if(b.hasOwnProperty(d)&&(a[d]===undefined)){a[d]=b[d]}}}return a};geoXML3.fetchers=[];geoXML3.xmlParse=function(b){if(typeof ActiveXObject!="undefined"&&typeof GetObject!="undefined"){var a=new ActiveXObject("Microsoft.XMLDOM");a.loadXML(b);return a}if(typeof DOMParser!="undefined"){return(new DOMParser()).parseFromString(b,"text/xml")}return createElement("div",null)};geoXML3.fetchXML=function(a,d){function b(){d()}var c=new Object();if(!!geoXML3.fetchers.length){c=geoXML3.fetchers.pop()}else{if(!!window.XMLHttpRequest){c.fetcher=new window.XMLHttpRequest()}else{if(!!window.ActiveXObject){c.fetcher=new window.ActiveXObject("Microsoft.XMLHTTP")}}}if(!c.fetcher){geoXML3.log("Unable to create XHR object");d(null)}else{if(c.fetcher.overrideMimeType){c.fetcher.overrideMimeType("text/xml")}c.fetcher.open("GET",a,true);c.fetcher.onreadystatechange=function(){if(c.fetcher.readyState===4){if(!!c.xhrtimeout){clearTimeout(c.xhrtimeout)}if(c.fetcher.status>=400){geoXML3.log("HTTP error "+c.fetcher.status+" retrieving "+a);d()}else{d(geoXML3.xmlParse(c.fetcher.responseText))}geoXML3.fetchers.push(c)}};c.xhrtimeout=setTimeout(b,60000);c.fetcher.send(null)}};geoXML3.nodeValue=function(b){var c="";if(!b){return""}if(b.nodeType==3||b.nodeType==4||b.nodeType==2){c+=b.nodeValue}else{if(b.nodeType==1||b.nodeType==9||b.nodeType==11){for(var a=0;a<b.childNodes.length;++a){c+=arguments.callee(b.childNodes[a])}}}return c};

// jQuery Cycle Lite Plugin v1.1 (03/07/2011). http://malsup.com/jquery/cycle/lite/
;(function($){var ver="Lite-1.1";$.fn.cycle=function(options){return this.each(function(){options=options||{};if(this.cycleTimeout){clearTimeout(this.cycleTimeout);}this.cycleTimeout=0;this.cyclePause=0;var $cont=$(this);var $slides=options.slideExpr?$(options.slideExpr,this):$cont.children();var els=$slides.get();if(els.length<2){window.console&&console.log("terminating; too few slides: "+els.length);return ;}var opts=$.extend({},$.fn.cycle.defaults,options||{},$.metadata?$cont.metadata():$.meta?$cont.data():{});opts.before=opts.before?[opts.before]:[];opts.after=opts.after?[opts.after]:[];opts.after.unshift(function(){opts.busy=0;});var cls=this.className;opts.width=parseInt((cls.match(/w:(\d+)/)||[])[1])||opts.width;opts.height=parseInt((cls.match(/h:(\d+)/)||[])[1])||opts.height;opts.timeout=parseInt((cls.match(/t:(\d+)/)||[])[1])||opts.timeout;if($cont.css("position")=="static"){$cont.css("position","relative");}if(opts.width){$cont.width(opts.width);}if(opts.height&&opts.height!="auto"){$cont.height(opts.height);}var first=0;$slides.css({position:"absolute",top:0,left:0}).each(function(i){$(this).css("z-index",els.length-i);});$(els[first]).css("opacity",1).show();if($.browser.msie){els[first].style.removeAttribute("filter");}if(opts.fit&&opts.width){$slides.width(opts.width);}if(opts.fit&&opts.height&&opts.height!="auto"){$slides.height(opts.height);}if(opts.pause){$cont.hover(function(){this.cyclePause=1;},function(){this.cyclePause=0;});}var txFn=$.fn.cycle.transitions[opts.fx];txFn&&txFn($cont,$slides,opts);$slides.each(function(){var $el=$(this);this.cycleH=(opts.fit&&opts.height)?opts.height:$el.height();this.cycleW=(opts.fit&&opts.width)?opts.width:$el.width();});if(opts.cssFirst){$($slides[first]).css(opts.cssFirst);}if(opts.timeout){if(opts.speed.constructor==String){opts.speed={slow:600,fast:200}[opts.speed]||400;}if(!opts.sync){opts.speed=opts.speed/2;}while((opts.timeout-opts.speed)<250){opts.timeout+=opts.speed;}}opts.speedIn=opts.speed;opts.speedOut=opts.speed;opts.slideCount=els.length;opts.currSlide=first;opts.nextSlide=1;var e0=$slides[first];if(opts.before.length){opts.before[0].apply(e0,[e0,e0,opts,true]);}if(opts.after.length>1){opts.after[1].apply(e0,[e0,e0,opts,true]);}if(opts.click&&!opts.next){opts.next=opts.click;}if(opts.next){$(opts.next).bind("click",function(){return advance(els,opts,opts.rev?-1:1);});}if(opts.prev){$(opts.prev).bind("click",function(){return advance(els,opts,opts.rev?1:-1);});}if(opts.timeout){this.cycleTimeout=setTimeout(function(){go(els,opts,0,!opts.rev);},opts.timeout+(opts.delay||0));}});};function go(els,opts,manual,fwd){if(opts.busy){return ;}var p=els[0].parentNode,curr=els[opts.currSlide],next=els[opts.nextSlide];if(p.cycleTimeout===0&&!manual){return ;}if(manual||!p.cyclePause){if(opts.before.length){$.each(opts.before,function(i,o){o.apply(next,[curr,next,opts,fwd]);});}var after=function(){if($.browser.msie){this.style.removeAttribute("filter");}$.each(opts.after,function(i,o){o.apply(next,[curr,next,opts,fwd]);});};if(opts.nextSlide!=opts.currSlide){opts.busy=1;$.fn.cycle.custom(curr,next,opts,after);}var roll=(opts.nextSlide+1)==els.length;opts.nextSlide=roll?0:opts.nextSlide+1;opts.currSlide=roll?els.length-1:opts.nextSlide-1;}if(opts.timeout){p.cycleTimeout=setTimeout(function(){go(els,opts,0,!opts.rev);},opts.timeout);}}function advance(els,opts,val){var p=els[0].parentNode,timeout=p.cycleTimeout;if(timeout){clearTimeout(timeout);p.cycleTimeout=0;}opts.nextSlide=opts.currSlide+val;if(opts.nextSlide<0){opts.nextSlide=els.length-1;}else{if(opts.nextSlide>=els.length){opts.nextSlide=0;}}go(els,opts,1,val>=0);return false;}$.fn.cycle.custom=function(curr,next,opts,cb){var $l=$(curr),$n=$(next);$n.css(opts.cssBefore);var fn=function(){$n.animate(opts.animIn,opts.speedIn,opts.easeIn,cb);};$l.animate(opts.animOut,opts.speedOut,opts.easeOut,function(){$l.css(opts.cssAfter);if(!opts.sync){fn();}});if(opts.sync){fn();}};$.fn.cycle.transitions={fade:function($cont,$slides,opts){opts.cssBefore={opacity:0};opts.animOut={opacity:0};opts.animIn={opacity:1};}};$.fn.cycle.ver=function(){return ver;};$.fn.cycle.defaults={fx:"fade",timeout:4000,speed:2000,next:null,prev:null,before:null,after:null,height:"auto",sync:1,fit:0,pause:1,delay:0,slideExpr:null,cssBefore:{},cssAfter:{},animIn:{},animOut:{}};})(jQuery);

// jQuery date methods. https://github.com/vitch/jquery-methods/blob/master/date.js
Date.dayNames=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];Date.abbrDayNames=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];Date.monthNames=["January","February","March","April","May","June","July","August","September","October","November","December"];Date.abbrMonthNames=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];Date.firstDayOfWeek=1;Date.format="dd/mm/yyyy";Date.fullYearStart="20";(function(){function b(c,d){if(!Date.prototype[c]){Date.prototype[c]=d}}b("isLeapYear",function(){var c=this.getFullYear();return(c%4==0&&c%100!=0)||c%400==0});b("isWeekend",function(){return this.getDay()==0||this.getDay()==6});b("isWeekDay",function(){return !this.isWeekend()});b("getDaysInMonth",function(){return[31,(this.isLeapYear()?29:28),31,30,31,30,31,31,30,31,30,31][this.getMonth()]});b("getDayName",function(c){return c?Date.abbrDayNames[this.getDay()]:Date.dayNames[this.getDay()]});b("getMonthName",function(c){return c?Date.abbrMonthNames[this.getMonth()]:Date.monthNames[this.getMonth()]});b("getDayOfYear",function(){var c=new Date("1/1/"+this.getFullYear());return Math.floor((this.getTime()-c.getTime())/86400000)});b("getWeekOfYear",function(){return Math.ceil(this.getDayOfYear()/7)});b("setDayOfYear",function(c){this.setMonth(0);this.setDate(c);return this});b("addYears",function(c){this.setFullYear(this.getFullYear()+c);return this});b("addMonths",function(d){var c=this.getDate();this.setMonth(this.getMonth()+d);if(c>this.getDate()){this.addDays(-this.getDate())}return this});b("addDays",function(c){this.setTime(this.getTime()+(c*86400000));return this});b("addHours",function(c){this.setHours(this.getHours()+c);return this});b("addMinutes",function(c){this.setMinutes(this.getMinutes()+c);return this});b("addSeconds",function(c){this.setSeconds(this.getSeconds()+c);return this});b("zeroTime",function(){this.setMilliseconds(0);this.setSeconds(0);this.setMinutes(0);this.setHours(0);return this});b("asString",function(d){var c=d||Date.format;return c.split("yyyy").join(this.getFullYear()).split("yy").join((this.getFullYear()+"").substring(2)).split("mmmm").join(this.getMonthName(false)).split("mmm").join(this.getMonthName(true)).split("mm").join(a(this.getMonth()+1)).split("dd").join(a(this.getDate())).split("hh").join(a(this.getHours())).split("min").join(a(this.getMinutes())).split("ss").join(a(this.getSeconds()))});Date.fromString=function(o,n){var j=n||Date.format;var m=new Date("01/01/1977");var k=0;var c=j.indexOf("mmmm");if(c>-1){for(var g=0;g<Date.monthNames.length;g++){var e=o.substr(c,Date.monthNames[g].length);if(Date.monthNames[g]==e){k=Date.monthNames[g].length-4;break}}m.setMonth(g)}else{c=j.indexOf("mmm");if(c>-1){var e=o.substr(c,3);for(var g=0;g<Date.abbrMonthNames.length;g++){if(Date.abbrMonthNames[g]==e){break}}m.setMonth(g)}else{m.setMonth(Number(o.substr(j.indexOf("mm"),2))-1)}}var l=j.indexOf("yyyy");if(l>-1){if(c<l){l+=k}m.setFullYear(Number(o.substr(l,4)))}else{if(c<l){l+=k}m.setFullYear(Number(Date.fullYearStart+o.substr(j.indexOf("yy"),2)))}var h=j.indexOf("dd");if(c<h){h+=k}m.setDate(Number(o.substr(h,2)));if(isNaN(m.getTime())){return false}return m};var a=function(c){var d="0"+c;return d.substring(d.length-2)}})();

// jQuery date picker plug-in. http://www.kelvinluck.com/assets/jquery/datePicker/v2/demo/
(function(d){d.fn.extend({renderCalendar:function(t){var C=function(i){return document.createElement(i)};t=d.extend({},d.fn.datePicker.defaults,t);if(t.showHeader!=d.dpConst.SHOW_HEADER_NONE){var o=d(C("tr"));for(var x=Date.firstDayOfWeek;x<Date.firstDayOfWeek+7;x++){var h=x%7;var v=Date.dayNames[h];o.append(jQuery(C("th")).attr({scope:"col",abbr:v,title:v,"class":(h==0||h==6?"weekend":"weekday")}).html(t.showHeader==d.dpConst.SHOW_HEADER_SHORT?v.substr(0,1):v))}}var e=d(C("table")).attr({cellspacing:2}).addClass("jCalendar").append((t.showHeader!=d.dpConst.SHOW_HEADER_NONE?d(C("thead")).append(o):C("thead")));var f=d(C("tbody"));var z=(new Date()).zeroTime();z.setHours(12);var B=t.month==undefined?z.getMonth():t.month;var p=t.year||z.getFullYear();var m=(new Date(p,B,1,12,0,0));var l=Date.firstDayOfWeek-m.getDay()+1;if(l>1){l-=7}var q=Math.ceil(((-1*l+1)+m.getDaysInMonth())/7);m.addDays(l-1);var A=function(i){return function(){if(t.hoverClass){var r=d(this);if(!t.selectWeek){r.addClass(t.hoverClass)}else{if(i&&!r.is(".disabled")){r.parent().addClass("activeWeekHover")}}}}};var g=function(){if(t.hoverClass){var i=d(this);i.removeClass(t.hoverClass);i.parent().removeClass("activeWeekHover")}};var n=0;while(n++<q){var u=jQuery(C("tr"));var k=t.dpController?m>t.dpController.startDate:false;for(var x=0;x<7;x++){var j=m.getMonth()==B;var y=d(C("td")).text(m.getDate()+"").addClass((j?"current-month ":"other-month ")+(m.isWeekend()?"weekend ":"weekday ")+(j&&m.getTime()==z.getTime()?"today ":"")).data("datePickerDate",m.asString()).hover(A(k),g);u.append(y);if(t.renderCallback){t.renderCallback(y,m,B,p)}m=new Date(m.getFullYear(),m.getMonth(),m.getDate()+1,12,0,0)}f.append(u)}e.append(f);return this.each(function(){d(this).empty().append(e)})},datePicker:function(e){if(!d.event._dpCache){d.event._dpCache=[]}e=d.extend({},d.fn.datePicker.defaults,e);return this.each(function(){var g=d(this);var i=true;if(!this._dpId){this._dpId=d.event.guid++;d.event._dpCache[this._dpId]=new a(this);i=false}if(e.inline){e.createButton=false;e.displayClose=false;e.closeOnSelect=false;g.empty()}var f=d.event._dpCache[this._dpId];f.init(e);if(!i&&e.createButton){f.button=d('<a href="#" class="dp-choose-date" title="'+d.dpText.TEXT_CHOOSE_DATE+'">'+d.dpText.TEXT_CHOOSE_DATE+"</a>").bind("click",function(){g.dpDisplay(this);this.blur();return false});g.after(f.button)}if(!i&&g.is(":text")){g.bind("dateSelected",function(k,j,l){this.value=j.asString()}).bind("change",function(){if(this.value==""){f.clearSelected()}else{var j=Date.fromString(this.value);if(j){f.setSelected(j,true,true)}}});if(e.clickInput){g.bind("click",function(){g.trigger("change");g.dpDisplay()})}var h=Date.fromString(this.value);if(this.value!=""&&h){f.setSelected(h,true,true)}}g.addClass("dp-applied")})},dpSetDisabled:function(e){return b.call(this,"setDisabled",e)},dpSetStartDate:function(e){return b.call(this,"setStartDate",e)},dpSetEndDate:function(e){return b.call(this,"setEndDate",e)},dpGetSelected:function(){var e=c(this[0]);if(e){return e.getSelected()}return null},dpSetSelected:function(i,g,f,h){if(g==undefined){g=true}if(f==undefined){f=true}if(h==undefined){h=true}return b.call(this,"setSelected",Date.fromString(i),g,f,h)},dpSetDisplayedMonth:function(e,f){return b.call(this,"setDisplayedMonth",Number(e),Number(f),true)},dpDisplay:function(f){return b.call(this,"display",f)},dpSetRenderCallback:function(e){return b.call(this,"setRenderCallback",e)},dpSetPosition:function(e,f){return b.call(this,"setPosition",e,f)},dpSetOffset:function(e,f){return b.call(this,"setOffset",e,f)},dpClose:function(){return b.call(this,"_closeCalendar",false,this[0])},dpRerenderCalendar:function(){return b.call(this,"_rerenderCalendar")},_dpDestroy:function(){}});var b=function(h,g,e,j,i){return this.each(function(){var f=c(this);if(f){f[h](g,e,j,i)}})};function a(e){this.ele=e;this.displayedMonth=null;this.displayedYear=null;this.startDate=null;this.endDate=null;this.showYearNavigation=null;this.closeOnSelect=null;this.displayClose=null;this.rememberViewedMonth=null;this.selectMultiple=null;this.numSelectable=null;this.numSelected=null;this.verticalPosition=null;this.horizontalPosition=null;this.verticalOffset=null;this.horizontalOffset=null;this.button=null;this.renderCallback=[];this.selectedDates={};this.inline=null;this.context="#dp-popup";this.settings={}}d.extend(a.prototype,{init:function(e){this.setStartDate(e.startDate);this.setEndDate(e.endDate);this.setDisplayedMonth(Number(e.month),Number(e.year));this.setRenderCallback(e.renderCallback);this.showYearNavigation=e.showYearNavigation;this.closeOnSelect=e.closeOnSelect;this.displayClose=e.displayClose;this.rememberViewedMonth=e.rememberViewedMonth;this.selectMultiple=e.selectMultiple;this.numSelectable=e.selectMultiple?e.numSelectable:1;this.numSelected=0;this.verticalPosition=e.verticalPosition;this.horizontalPosition=e.horizontalPosition;this.hoverClass=e.hoverClass;this.setOffset(e.verticalOffset,e.horizontalOffset);this.inline=e.inline;this.settings=e;if(this.inline){this.context=this.ele;this.display()}},setStartDate:function(e){if(e){if(e instanceof Date){this.startDate=e}else{this.startDate=Date.fromString(e)}}if(!this.startDate){this.startDate=(new Date()).zeroTime()}this.setDisplayedMonth(this.displayedMonth,this.displayedYear)},setEndDate:function(e){if(e){if(e instanceof Date){this.endDate=e}else{this.endDate=Date.fromString(e)}}if(!this.endDate){this.endDate=(new Date("12/31/2999"))}if(this.endDate.getTime()<this.startDate.getTime()){this.endDate=this.startDate}this.setDisplayedMonth(this.displayedMonth,this.displayedYear)},setPosition:function(e,f){this.verticalPosition=e;this.horizontalPosition=f},setOffset:function(e,f){this.verticalOffset=parseInt(e)||0;this.horizontalOffset=parseInt(f)||0},setDisabled:function(e){$e=d(this.ele);$e[e?"addClass":"removeClass"]("dp-disabled");if(this.button){$but=d(this.button);$but[e?"addClass":"removeClass"]("dp-disabled");$but.attr("title",e?"":d.dpText.TEXT_CHOOSE_DATE)}if($e.is(":text")){$e.attr("disabled",e?"disabled":"")}},setDisplayedMonth:function(f,n,j){if(this.startDate==undefined||this.endDate==undefined){return}var i=new Date(this.startDate.getTime());i.setDate(1);var l=new Date(this.endDate.getTime());l.setDate(1);var h;if((!f&&!n)||(isNaN(f)&&isNaN(n))){h=new Date().zeroTime();h.setDate(1)}else{if(isNaN(f)){h=new Date(n,this.displayedMonth,1)}else{if(isNaN(n)){h=new Date(this.displayedYear,f,1)}else{h=new Date(n,f,1)}}}if(h.getTime()<i.getTime()){h=i}else{if(h.getTime()>l.getTime()){h=l}}var g=this.displayedMonth;var k=this.displayedYear;this.displayedMonth=h.getMonth();this.displayedYear=h.getFullYear();if(j&&(this.displayedMonth!=g||this.displayedYear!=k)){this._rerenderCalendar();d(this.ele).trigger("dpMonthChanged",[this.displayedMonth,this.displayedYear])}},setSelected:function(l,e,f,h){if(l<this.startDate||l.zeroTime()>this.endDate.zeroTime()){return}var g=this.settings;if(g.selectWeek){l=l.addDays(-(l.getDay()-Date.firstDayOfWeek+7)%7);if(l<this.startDate){return}}if(e==this.isSelected(l)){return}if(this.selectMultiple==false){this.clearSelected()}else{if(e&&this.numSelected==this.numSelectable){return}}if(f&&(this.displayedMonth!=l.getMonth()||this.displayedYear!=l.getFullYear())){this.setDisplayedMonth(l.getMonth(),l.getFullYear(),true)}this.selectedDates[l.asString()]=e;this.numSelected+=e?1:-1;var j="td."+(l.getMonth()==this.displayedMonth?"current-month":"other-month");var k;d(j,this.context).each(function(){if(d(this).data("datePickerDate")==l.asString()){k=d(this);if(g.selectWeek){k.parent()[e?"addClass":"removeClass"]("selectedWeek")}k[e?"addClass":"removeClass"]("selected")}});d("td",this.context).not(".selected")[this.selectMultiple&&this.numSelected==this.numSelectable?"addClass":"removeClass"]("unselectable");if(h){var g=this.isSelected(l);$e=d(this.ele);var i=Date.fromString(l.asString());$e.trigger("dateSelected",[i,k,g]);$e.trigger("change")}},isSelected:function(e){return this.selectedDates[e.asString()]},getSelected:function(){var f=[];for(var e in this.selectedDates){if(this.selectedDates[e]==true){f.push(Date.fromString(e))}}return f},clearSelected:function(){this.selectedDates={};this.numSelected=0;d("td.selected",this.context).removeClass("selected").parent().removeClass("selectedWeek")},display:function(e){if(d(this.ele).is(".dp-disabled")){return}e=e||this.ele;var m=this;var i=d(e);var l=i.offset();var n;var o;var g;var j;if(m.inline){n=d(this.ele);o={id:"calendar-"+this.ele._dpId,"class":"dp-popup dp-popup-inline"};d(".dp-popup",n).remove();j={}}else{n=d("body");o={id:"dp-popup","class":"dp-popup"};j={top:l.top+m.verticalOffset,left:l.left+m.horizontalOffset};var k=function(r){var p=r.target;var q=d("#dp-popup")[0];while(true){if(p==q){return true}else{if(p==document){m._closeCalendar();return false}else{p=d(p).parent()[0]}}}};this._checkMouse=k;m._closeCalendar(true);d(document).bind("keydown.datepicker",function(p){if(p.keyCode==27){m._closeCalendar()}})}if(!m.rememberViewedMonth){var h=this.getSelected()[0];if(h){h=new Date(h);this.setDisplayedMonth(h.getMonth(),h.getFullYear(),false)}}n.append(d("<div></div>").attr(o).css(j).append(d("<h2></h2>"),d('<div class="dp-nav-prev"></div>').append(d('<a class="dp-nav-prev-year" href="#" title="'+d.dpText.TEXT_PREV_YEAR+'">&lt;&lt;</a>').bind("click",function(){return m._displayNewMonth.call(m,this,0,-1)}),d('<a class="dp-nav-prev-month" href="#" title="'+d.dpText.TEXT_PREV_MONTH+'">&lt;</a>').bind("click",function(){return m._displayNewMonth.call(m,this,-1,0)})),d('<div class="dp-nav-next"></div>').append(d('<a class="dp-nav-next-year" href="#" title="'+d.dpText.TEXT_NEXT_YEAR+'">&gt;&gt;</a>').bind("click",function(){return m._displayNewMonth.call(m,this,0,1)}),d('<a class="dp-nav-next-month" href="#" title="'+d.dpText.TEXT_NEXT_MONTH+'">&gt;</a>').bind("click",function(){return m._displayNewMonth.call(m,this,1,0)})),d('<div class="dp-calendar"></div>')).bgIframe());var f=this.inline?d(".dp-popup",this.context):d("#dp-popup");if(this.showYearNavigation==false){d(".dp-nav-prev-year, .dp-nav-next-year",m.context).css("display","none")}if(this.displayClose){f.append(d('<a href="#" id="dp-close">'+d.dpText.TEXT_CLOSE+"</a>").bind("click",function(){m._closeCalendar();return false}))}m._renderCalendar();d(this.ele).trigger("dpDisplayed",f);if(!m.inline){if(this.verticalPosition==d.dpConst.POS_BOTTOM){f.css("top",l.top+i.height()-f.height()+m.verticalOffset)}if(this.horizontalPosition==d.dpConst.POS_RIGHT){f.css("left",l.left+i.width()-f.width()+m.horizontalOffset)}d(document).bind("mousedown.datepicker",this._checkMouse)}},setRenderCallback:function(e){if(e==null){return}if(e&&typeof(e)=="function"){e=[e]}this.renderCallback=this.renderCallback.concat(e)},cellRender:function(i,e,g,f){var j=this.dpController;var h=new Date(e.getTime());i.bind("click",function(){var m=d(this);if(!m.is(".disabled")){j.setSelected(h,!m.is(".selected")||!j.selectMultiple,false,true);if(j.closeOnSelect){if(j.settings.autoFocusNextInput){var l=j.ele;var k=false;d(":input",l.form).each(function(){if(k){d(this).focus();return false}if(this==l){k=true}})}else{j.ele.focus()}j._closeCalendar()}}});if(j.isSelected(h)){i.addClass("selected");if(j.settings.selectWeek){i.parent().addClass("selectedWeek")}}else{if(j.selectMultiple&&j.numSelected==j.numSelectable){i.addClass("unselectable")}}},_applyRenderCallbacks:function(){var e=this;d("td",this.context).each(function(){for(var f=0;f<e.renderCallback.length;f++){$td=d(this);e.renderCallback[f].apply(this,[$td,Date.fromString($td.data("datePickerDate")),e.displayedMonth,e.displayedYear])}});return},_displayNewMonth:function(f,e,g){if(!d(f).is(".disabled")){this.setDisplayedMonth(this.displayedMonth+e,this.displayedYear+g,true)}f.blur();return false},_rerenderCalendar:function(){this._clearCalendar();this._renderCalendar()},_renderCalendar:function(){d("h2",this.context).html((new Date(this.displayedYear,this.displayedMonth,1)).asString(d.dpText.HEADER_FORMAT));d(".dp-calendar",this.context).renderCalendar(d.extend({},this.settings,{month:this.displayedMonth,year:this.displayedYear,renderCallback:this.cellRender,dpController:this,hoverClass:this.hoverClass}));if(this.displayedYear==this.startDate.getFullYear()&&this.displayedMonth==this.startDate.getMonth()){d(".dp-nav-prev-year",this.context).addClass("disabled");d(".dp-nav-prev-month",this.context).addClass("disabled");d(".dp-calendar td.other-month",this.context).each(function(){var i=d(this);if(Number(i.text())>20){i.addClass("disabled")}});var h=this.startDate.getDate();d(".dp-calendar td.current-month",this.context).each(function(){var i=d(this);if(Number(i.text())<h){i.addClass("disabled")}})}else{d(".dp-nav-prev-year",this.context).removeClass("disabled");d(".dp-nav-prev-month",this.context).removeClass("disabled");var h=this.startDate.getDate();if(h>20){var f=this.startDate.getTime();var g=new Date(f);g.addMonths(1);if(this.displayedYear==g.getFullYear()&&this.displayedMonth==g.getMonth()){d(".dp-calendar td.other-month",this.context).each(function(){var i=d(this);if(Date.fromString(i.data("datePickerDate")).getTime()<f){i.addClass("disabled")}})}}}if(this.displayedYear==this.endDate.getFullYear()&&this.displayedMonth==this.endDate.getMonth()){d(".dp-nav-next-year",this.context).addClass("disabled");d(".dp-nav-next-month",this.context).addClass("disabled");d(".dp-calendar td.other-month",this.context).each(function(){var i=d(this);if(Number(i.text())<14){i.addClass("disabled")}});var h=this.endDate.getDate();d(".dp-calendar td.current-month",this.context).each(function(){var i=d(this);if(Number(i.text())>h){i.addClass("disabled")}})}else{d(".dp-nav-next-year",this.context).removeClass("disabled");d(".dp-nav-next-month",this.context).removeClass("disabled");var h=this.endDate.getDate();if(h<13){var e=new Date(this.endDate.getTime());e.addMonths(-1);if(this.displayedYear==e.getFullYear()&&this.displayedMonth==e.getMonth()){d(".dp-calendar td.other-month",this.context).each(function(){var j=d(this);var i=Number(j.text());if(i<13&&i>h){j.addClass("disabled")}})}}}this._applyRenderCallbacks()},_closeCalendar:function(e,f){if(!f||f==this.ele){d(document).unbind("mousedown.datepicker");d(document).unbind("keydown.datepicker");this._clearCalendar();d("#dp-popup a").unbind();d("#dp-popup").empty().remove();if(!e){d(this.ele).trigger("dpClosed",[this.getSelected()])}}},_clearCalendar:function(){d(".dp-calendar td",this.context).unbind();d(".dp-calendar",this.context).empty()}});d.dpConst={SHOW_HEADER_NONE:0,SHOW_HEADER_SHORT:1,SHOW_HEADER_LONG:2,POS_TOP:0,POS_BOTTOM:1,POS_LEFT:0,POS_RIGHT:1,DP_INTERNAL_FOCUS:"dpInternalFocusTrigger"};d.dpText={TEXT_PREV_YEAR:"Previous year",TEXT_PREV_MONTH:"Previous month",TEXT_NEXT_YEAR:"Next year",TEXT_NEXT_MONTH:"Next month",TEXT_CLOSE:"Close",TEXT_CHOOSE_DATE:"Choose date",HEADER_FORMAT:"mmmm yyyy"};d.dpVersion="$Id: jquery.datePicker.js 103 2010-09-22 08:54:28Z kelvin.luck $";d.fn.datePicker.defaults={month:undefined,year:undefined,showHeader:d.dpConst.SHOW_HEADER_SHORT,startDate:undefined,endDate:undefined,inline:false,renderCallback:null,createButton:true,showYearNavigation:true,closeOnSelect:true,displayClose:false,selectMultiple:false,numSelectable:Number.MAX_VALUE,clickInput:false,rememberViewedMonth:true,selectWeek:false,verticalPosition:d.dpConst.POS_TOP,horizontalPosition:d.dpConst.POS_LEFT,verticalOffset:0,horizontalOffset:0,hoverClass:"dp-hover",autoFocusNextInput:false};function c(e){if(e._dpId){return d.event._dpCache[e._dpId]}return false}if(d.fn.bgIframe==undefined){d.fn.bgIframe=function(){return this}}d(window).bind("unload",function(){var f=d.event._dpCache||[];for(var e in f){d(f[e].ele)._dpDestroy()}})})(jQuery);

jQuery.noConflict();
jQuery(function($){

	$("img[align=left]").addClass("l");
	$("img[align=right]").addClass("r");

	if ($("#reel").length > 0){
		$("#reel").cycle({ next:$("#reel") });
	}

	$("#sb-kmap a").click(function(e){
		e.preventDefault();
		$("#kmlmap").fadeToggle();
	});

	$(".gallery-thumb a").click(function(e){ return false; });

	if ($("#kmlmap").length > 0){
		var blockID = $("body").data("blockref");
		var mapLatLng = new google.maps.LatLng(-38.6856924, 176.0702098);
		var mapOption = {
			zoom: 8,
			center: mapLatLng,
			mapTypeId: google.maps.MapTypeId.SATELLITE
		}
		var kmlMap = new google.maps.Map(document.getElementById("kmlmap"), mapOption);
		var kmlParser = new geoXML3.parser({ map:kmlMap });
		kmlParser.parse("/data/uploads/"+blockID+"/"+blockID+".kml");

		//$("#kmlmap, #gepmap").hide();

	}

	$('.date-pick').datePicker({ clickInput:true })

	$("a[href^=http], area[href^=http]")
		.each(function(){
			if (this.href.indexOf(location.hostname) == -1){
				$(this).attr({ "target":"_blank", "rel":"external" })
					.click(function(){
						_gaq.push(["_trackEvent", "External Links", "click", $(this).attr("href")]);
					});
			}
		});

});

// Yep, Google Analytics
var _gaq = [['_setAccount', 'UA-XXXXXXXX-X'], ['_setDomainName', 'www.helisika.co.nz'], ['_trackPageview']];
(function(d,t){var g=d.createElement(t),s=d.getElementsByTagName(t)[0];g.async = true;g.src = '//www.google-analytics.com/ga.js';s.parentNode.insertBefore(g, s);})(document, 'script');

