(function(a){jQuery.fn.pngFix=function(b){b=jQuery.extend({blankgif:"/images/blank.gif"},b);var c=(navigator.appName=="Microsoft Internet Explorer"&&parseInt(navigator.appVersion)==4&&navigator.appVersion.indexOf("MSIE 5.5")!=-1);var d=(navigator.appName=="Microsoft Internet Explorer"&&parseInt(navigator.appVersion)==4&&navigator.appVersion.indexOf("MSIE 6.0")!=-1);if(jQuery.browser.msie&&(c||d)){jQuery(this).find("img[src$=.png]").each(function(){jQuery(this).attr("width",jQuery(this).width());jQuery(this).attr("height",jQuery(this).height());var k="";var f="";var g=(jQuery(this).attr("id"))?'id="'+jQuery(this).attr("id")+'" ':"";var h=(jQuery(this).attr("class"))?'class="'+jQuery(this).attr("class")+'" ':"";var m=(jQuery(this).attr("title"))?'title="'+jQuery(this).attr("title")+'" ':"";var e=(jQuery(this).attr("alt"))?'alt="'+jQuery(this).attr("alt")+'" ':"";var j=(jQuery(this).attr("align"))?"float:"+jQuery(this).attr("align")+";":"";var l=(jQuery(this).parent().attr("href"))?"cursor:hand;":"";if(this.style.border){k+="border:"+this.style.border+";";this.style.border=""}if(this.style.padding){k+="padding:"+this.style.padding+";";this.style.padding=""}if(this.style.margin){k+="margin:"+this.style.margin+";";this.style.margin=""}var i=(this.style.cssText);f+="<span "+g+h+m+e;f+='style="position:relative;white-space:pre-line;display:inline-block;background:transparent;'+j+l;f+="width:"+jQuery(this).width()+"px;height:"+jQuery(this).height()+"px;";f+="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+jQuery(this).attr("src")+"', sizingMethod='scale');";f+=i+'"></span>';if(k!=""){f='<span style="position:relative;display:inline-block;'+k+l+"width:"+jQuery(this).width()+"px;height:"+jQuery(this).height()+'px;">'+f+"</span>"}jQuery(this).hide();jQuery(this).after(f)});jQuery(this).find("*").each(function(){var f=jQuery(this).css("background-image");if(f.indexOf(".png")!=-1){var e=f.split('url("')[1].split('")')[0];jQuery(this).css("background-image","none");jQuery(this).get(0).runtimeStyle.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+e+"',sizingMethod='scale')"}});jQuery(this).find("input[src$=.png]").each(function(){var e=jQuery(this).attr("src");jQuery(this).get(0).runtimeStyle.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+e+"', sizingMethod='scale');";jQuery(this).attr("src",b.blankgif)})}return jQuery}})(jQuery);var map;var overlay;var latlng;var geocoder;var markerimage="/images/marker_default.png";$(document).ready(function(){$.localScroll();$(document).pngFix();$(".date_field").datepicker({dateFormat:"mm/yy"});$(".int_validation").keypress(function(a){var b=a.charCode?a.charCode:a.keyCode;if(b!=8){if(b<48||b>57){return false}}});$(".card_validation").keypress(function(a){var b=a.charCode?a.charCode:a.keyCode;if(b!=8&&b!=32){if(b<48||b>57){return false}}})});try{USGSOverlay.prototype=new google.maps.OverlayView()}catch(err){}function USGSOverlay(b){this.bounds_=b;this.map_=map;var a=document.createElement("DIV");a.className="overlay";var c=document.createElement("DIV");c.className="top_bg";c.innterHTML="Top";var d=document.createElement("DIV");d.className="bottom_bg";d.innerHTML+='<div class="hook">hook</div><a href="javascript:void(0);" onclick="overlay.toggle();"  class="close">Close</a><strong class=\'name\'></strong>';d.innerHTML+='<p id="overlaytext"></p>';d.innerHTML+='<a href="javascript:void(0);" class="showhide" onclick="$(this).next().toggle();" title="Show/Hide more information">Show/Hide more information</a>';d.innerHTML+='<p id="overlaymoretext"></p>';a.appendChild(c);a.appendChild(d);this.div_=a;this.setMap(map)}USGSOverlay.prototype.update=function(a){this.bounds_=new google.maps.LatLngBounds(a.position,a.position);$(".name",this.div_).html(a.title);$("#overlaymoretext").hide();if(a.data==null){$(".overlay #overlaytext").html('<img src="/images/ajax-loader.gif" />');$("#overlaytext",this.div_).show(0,function(){$.post("/layouts/service.asmx/GetPledgeDetail",{pledgeid:a.id},function(b){if(b.detail.length>0){pledge.register(b.pledges);a.data="<strong>Why was this spot chosen?</strong>"+b.detail}if(b.facebookurl.length>0){a.data+="<br /><a href='"+b.facebookurl+"' target='__blank' title='click to view my facebook page'>View my facebook page</a>"}if(b.reason.length>0){$(".overlay .showhide").css("display","block");a.moretext="<strong>Why do you support PLACE?</strong>"+b.reason}$(".overlay #overlaytext").html(a.data);$(".overlay #overlaymoretext").html(a.moretext)},"json")})}else{$("#overlaytext",this.div_).html(a.data);$("#overlaymoretext",this.div_).html(a.moretext)}this.draw();this.show()};USGSOverlay.prototype.onAdd=function(){var a=this.getPanes();a.overlayImage.appendChild(this.div_)};USGSOverlay.prototype.draw=function(){var b=this.getProjection();var c=b.fromLatLngToDivPixel(this.bounds_.getSouthWest());var a=b.fromLatLngToDivPixel(this.bounds_.getNorthEast());this.div_.style.left=(c.x)+28+"px";this.div_.style.top=(a.y)-40+"px"};USGSOverlay.prototype.onRemove=function(){this.div_.parentNode.removeChild(this.div_);this.div_=null};USGSOverlay.prototype.toggle=function(){if(this.div_){if(this.div_.style.visibility=="hidden"){this.show()}else{this.hide()}}};USGSOverlay.prototype.hide=function(){if(this.div_){this.div_.style.visibility="hidden"}};USGSOverlay.prototype.show=function(){if(this.div_){this.div_.style.visibility="visible"}};function codeLatLng(a){var b=a;if(geocoder){geocoder.geocode({latLng:b},function(f,d){if(d==google.maps.GeocoderStatus.OK){if(f.length==0){pledge.countrycode="";pledge.locationname="";pledge.locationlat="";pledge.locationlon="";$(".place_details").html("")}else{var c=f.length>1?f[1]:f[0];if(c){for(var e=c.address_components.length-1;e>=0;e--){if(c.address_components[e].short_name.length==2){pledge.countrycode=c.address_components[e].short_name+" - "+c.address_components[e].long_name;break}else{pledge.countrycode="unknown"}}pledge.locationname=c.formatted_address;pledge.locationlat=c.geometry.location.lat();pledge.locationlon=c.geometry.location.lng();$(".place_details").html(c.formatted_address+"<br />lat: "+pledge.locationlat.toFixed(2)+"<br />lon: "+pledge.locationlon.toFixed(2)).show()}}}else{pledge.countrycode="";pledge.locationname="";pledge.locationlat="";pledge.locationlon="";$(".place_details").html("")}})}else{}}function OnMarkerDragged(a){var b=this.getPosition();map.panTo(b);codeLatLng(b)}function showTerms(){popup("terms.aspx")}function onSubmit(a,b,c){if(b.keyCode==13){b.cancelBubble=true;b.returnValue=false;if(b.preventDefault){b.preventDefault()}if(typeof(c)=="function"){c.call()}}}function closeStep(a){$(".map_wrapper .panel .step").hide();$(".map_wrapper .panel .step_1").show();$(".map_wrapper .panel").hide();$(".map_wrapper #map").css("width","948px");google.maps.event.trigger(map,"resize")}var $dialog;var searchmarker;var searchInfoWindow;function closedialog(){if($dialog){$dialog.dialog("close")}}function plotResult(d,c,b){var a=new google.maps.LatLng(d,c);map.panTo(a);if(searchmarker==null){searchmarker=new google.maps.Marker({map:map,position:a,title:b,icon:"/images/marker_search.png"});searchInfoWindow=new google.maps.InfoWindow()}else{searchmarker.setMap(map);searchmarker.setPosition(a);searchmarker.setTitle(b)}searchInfoWindow.setContent(b);searchInfoWindow.setPosition(a);searchInfoWindow.open(map)}function searchMap(){closedialog();if(searchInfoWindow){searchInfoWindow.close()}if(searchmarker){searchmarker.setMap(null)}var a=$(".searchQuery").val();if(a==""){$dialog=$("<div></div>").html("Location could not be found. <br /><a href='javascript:void(0);' onclick='closedialog()'>Please</a> try searching with different keywords.").dialog({modal:true,height:150,title:"Error"});return false}if(geocoder){geocoder.geocode({address:a},function(e,c){if(c==google.maps.GeocoderStatus.OK&&e.length>0){if(e.length==1){plotResult(e[0].geometry.location.lat(),e[0].geometry.location.lng(),e[0].formatted_address)}else{var b;if(e.length==8){b="<strong>Please try more specific keywords</strong><br/>"}else{b="<strong>Please select a result from below.</strong><br/>"}for(var d=0;d<e.length;d++){b+='<a href="javascript:void(0);" onclick="plotResult(\''+e[d].geometry.location.lat()+"','"+e[d].geometry.location.lng()+"','"+e[d].formatted_address+"');\">"+e[d].formatted_address+"</a><br/>"}$dialog=$("<div></div>").html(b).dialog({modal:false,height:(150+(e.length*9)),title:"Multiple locations found"})}}else{$dialog=$("<div></div>").html('Location could not be found. <br /><a href="javascript:void(0);" onclick="closedialog()">Please</a> try searching with different keywords.').dialog({modal:true,height:150,title:"Location not found",buttons:{Ok:function(){$(this).dialog("close")}}})}})}return false}function limitText(b,a,c,d){if($("#"+a).val().length>d){$("#"+a).val($("#"+a).val().substring(0,d))}$("#"+c).html(d-$("#"+a).val().length)}function IsNumeric(a){return(a-0)==a&&a.length>0}var pledge={countrycode:"",locationname:"",locationlat:"",locationlon:"",locationreason:"",firstname:"",surname:"",pledgereason:"",email:"",facebookpage:"",amount:"",cname:"",cardno:"",csec:"",expirymon:"",expiryyear:"",pledgemarker:null,markersArray:[],pledgescount:0,initialize:function(){geocoder=new google.maps.Geocoder();latlng=new google.maps.LatLng(39.5040407055842,-92.61328125);var a={zoom:3,center:latlng,mapTypeId:google.maps.MapTypeId.HYBRID,navigationControl:true,scrollwheel:false};map=new google.maps.Map(document.getElementById("map"),a);$.post("/layouts/service.asmx/GetPledges",{},function(b){pledge.counter(b.count);if(b.count>0){pledge.register(b.pledges)}},"json");overlay=new USGSOverlay(new google.maps.LatLngBounds(latlng,latlng))},register:function(pointsStr){var points=eval(pointsStr);var jid=null;for(var p in points){var point=points[p];if(IsNumeric(point[1])&&IsNumeric(point[2])){var marker=new google.maps.Marker({position:new google.maps.LatLng(point[1],point[2]),map:map,id:point[0],zIndex:0,title:point[3],icon:markerimage,data:null});marker.listener=google.maps.event.addListener(marker,"click",function(){map.setCenter(this.position);overlay.update(this)});if(point[5]&&point[5]==1){map.setCenter(marker.position);overlay.update(marker)}this.markersArray.push(marker)}}},validatestep:function(a){switch(a){case 0:this.dropMarkerLock(false);break;case 1:this.dropMarkerLock(false);break;case 2:if(!this.locationname||this.locationname.length==""){$(".map_wrapper .panel .error").show();$(".map_wrapper .panel .error .text").html("<p><strong>Sorry but you cannot continue until you have chosen where to place your hand.</strong></p><p>Click the hand icon to place it on the map, then drag it to anywhere in the world you would like. For example, where in the world is your sanctuary, or your most favourite or memorable place? Where were you moved or inspired?</p>");return false}this.dropMarkerLock(true);break;case 3:if($("#locreason").val().length==0){$(".map_wrapper .panel .error").show();$(".map_wrapper .panel .error .text").html("<p><strong>Some required information is missing</strong>.</p><p>Please enter a reason why you have chosen to place your hand here.</p>");return false}break;case 4:var b="";if($("#fname").val().length==0){b+=(b.length>0?"":"")+"<li>First name</li>"}if($("#sname").val().length==0){b+=(b.length>0?"":"")+"<li>Surname</li>"}if($("#email").val().length==0){b+=(b.length>0?"":"")+"<li>Email address</li>"}if(b.length>0){$(".map_wrapper .panel .error").show();$(".map_wrapper .panel .error .text").html("<p><strong>Some required information is missing</strong>.</p><p>Please provide the following to continue:</p><ul>"+b+"</ul>");return false}break;case 5:var b="";if($(".rblWhy10k input:checked").length==0||$(".rblWhy10k input:checked").val()=="4"){this.pledgereason=$("#reason").val()}else{if($(".rblWhy10k input:checked").length>0){this.pledgereason=$(".rblWhy10k input:checked").next().html()}}if(this.pledgereason.length==0){b+=(b.length>0?", ":"")+"Reason to support us";if(b.length>0){$(".map_wrapper .panel .error").show();$(".map_wrapper .panel .error .text").html("<p>Please fill in all the fields and try again:</p> <ul><li>"+b+"</li></ul>");return false}}break;case 6:var b="";if($("#amount").val().length==0){b+=(b.length>0?"":"")+"<li>Amount per month</li>"}if($("#cname").val().length==0){b+=(b.length>0?"":"")+"<li>Name on card</li>"}if($("#cardno").val().length==0){b+=(b.length>0?"":"")+"<li>Card number</li>"}if($("#csec").val().length==0){b+=(b.length>0?"":"")+"<li>Card security code</li>"}if(!$("#terms").is(":checked")){b+=(b.length>0?"":"")+"<li>Accept our terms and conditions</li>"}if(b.length>0){$(".panel .error").show();$(".panel .error .text").html("<p><strong>Some required information is missing</strong>.</p><p>Please provide the following to continue:</p><ul>"+b+"</ul>");return false}break;case 0:case 1:default:break}return true},showStep:function(a){if(this.validatestep(a)){switch(a){case 4:$.post("/layouts/service.asmx/ValidateEmail",{email:$("#email").val()},function(b){if(b.valid){$(".map_wrapper .panel .step").hide();$(".map_wrapper .panel .step_"+a).show()}else{$(".map_wrapper .panel .error").show();$(".map_wrapper .panel .error .text").html("<p><ul><li>Incorrect email address format</li></ul></p>")}},"json");break;case 5:pledge.prepledge();break;default:$(".map_wrapper .panel .step").hide();$(".map_wrapper .panel .step_"+a).show();break}}},prepledge:function(){this.locationreason=$("#locreason").val();this.firstname=$("#fname").val();this.surname=$("#sname").val();this.email=$("#email").val();this.facebookpage=$("#facebookpage").val();if($(".rblWhy10k input:checked").length==0||$(".rblWhy10k input:checked").val()=="4"){this.pledgereason=$("#reason").val()}else{if($(".rblWhy10k input:checked").length>0){this.pledgereason=$(".rblWhy10k input:checked").next().html()}}this.amount=$("#amount").val();this.cname=$("#cname").val();this.cardno=$("#cardno").val();this.expirymon=$(".ex-day").val();this.expiryyear=$(".ex-year").val();this.csec=$("#csec").val();$(".loading").show(0,function(){$.post("/layouts/service.asmx/PrePledge",{firstname:pledge.firstname,surname:pledge.surname,reason:pledge.pledgereason,email:pledge.email,facebookpage:pledge.facebookpage,countrycode:pledge.countrycode,locationname:pledge.locationname,locationlat:pledge.locationlat,locationlon:pledge.locationlon,locationreason:pledge.locationreason},function(a){$(".loading").hide();if(a.success){$.fancybox({type:"iframe",href:"/secure.aspx?sess="+a.key,transitionIn:"elastic",transitionOut:"elastic",overlayOpacity:0.9,overlayColor:"#000",scrolling:"no",width:314,height:512,modal:false,onCleanup:function(){$.fancybox.showActivity();var b=false;jQuery.ajax({url:"/layouts/service.asmx/CheckIfPaymentComplete",datatype:"json",data:{key:a.key},contentType:"application/json; charset=utf-8",success:function(c){$.fancybox.hideActivity();b=JSON.parse(c).complete},async:false});if(b){return true}else{return confirm("Are you sure you want to close the payment screen?")}},onClosed:function(){$(".loading").show(0,function(){$.post("/layouts/service.asmx/CheckIfPaymentSuccessful",{key:a.key},function(b){if(b.success){$(".panel .step").hide();$(".panel .step_6").show();pledge.pledgemarker.setIcon(markerimage);pledge.pledgemarker.setMap(null);pledge.register("["+b.pledge+"]");pledge.incrementCounter();pledge.showPledgeMarkers()}$(".loading").hide()},"json")})}})}else{$(".panel .error").show();$(".panel .error .text").html("<p><strong>Sorry we have experienced a problem processing your card payment.</strong></p><p>Please check your details and try again.</p><p>"+a.message+"</p>")}},"json")})},pledge:function(a){if(this.validatestep(6)){this.amount=$("#amount").val();this.cname=$("#cname").val();this.cardno=$("#cardno").val();this.expirymon=$(".ex-day").val();this.expiryyear=$(".ex-year").val();this.csec=$("#csec").val();$(".loading").show(0,function(){$.post("/layouts/service.asmx/Pledge",{key:a,amount:pledge.amount,cname:pledge.cname,cardno:pledge.cardno,expirymon:pledge.expirymon,expiryyear:pledge.expiryyear,csec:pledge.csec},function(b){$(".loading").hide();if(b.success){$(".panel .step").hide();$(".panel .step_6").show()}else{if(b.message=="keyerr"){$(".formelements").hide();$(".panel .pserror").show()}else{$(".panel .error").show();$(".panel .error .text").html("<p><strong>Sorry we have experienced a problem processing your card payment.</strong></p><p>Please check your details and try again.</p><p>"+b.message+"</p>")}}},"json")})}},dropMarkerLock:function(a){if(this.pledgemarker){this.pledgemarker.setDraggable(!a)}},dropMarker:function(){this.hidePledgeMarkers();overlay.hide();var a=map.getCenter();if(!this.pledgemarker){this.pledgemarker=new google.maps.Marker({position:a,map:map,title:"Your pledge location",draggable:true,icon:"/images/marker_special.png"})}else{this.pledgemarker.setMap(map);pledge.pledgemarker.setPosition(a)}$(".place").hide();$(".place_confirm").show();codeLatLng(a);google.maps.event.addListener(this.pledgemarker,"dragend",OnMarkerDragged)},dropMarkerReset:function(){this.pledgemarker.setMap(null);this.pledgemarker.setIcon("/images/marker_special.png");this.hidePledgeMarkers();pledge.countrycode="";pledge.locationname="";pledge.locationlat="";pledge.locationlon="";$(".place").show();$(".place_confirm").hide();$(".place_details").hide()},hidePledgeMarkers:function(){if(pledge.markersArray){for(i in this.markersArray){this.markersArray[i].setMap(null)}}},showPledgeMarkers:function(){if(pledge.markersArray){for(i in this.markersArray){this.markersArray[i].setMap(map)}}},incrementCounter:function(){this.counter(this.pledgescount+1)},counter:function(a){this.pledgescount=a;var c="00000";var d=a.toString();if(c.length>a.toString().length){d=c.substring(0,c.length-d.length)+d}$("#counter").html("");for(var b=0;b<d.length;b++){$("#counter").append($("<img/>").attr({alt:d.substring(b,b+1)}).attr({src:"/images/number_"+d.substring(b,b+1)+".gif"}))}}};function popup(x){day=new Date();id=day.getTime();eval("page"+id+" = window.open(x, '"+id+"', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=400,height=400,left = 440,top = 312');")}function intValidation(a){if(!parseInt(a.value)){a.value=""}}var $contactusdialog;function ContactUs(){if($contactusdialog){$contactusdialog.dialog("close")}if($("#ContactName").val().length==0||$("#ContactEmail").val().length==0||$("#ContactMessage").val().length==0){$contactusdialog=$("<div></div>").html("Sorry we need some more information, please complete your name, email address and message.").dialog({modal:true,height:150,title:"Required fields missing",buttons:{Close:function(){$(this).dialog("close")}}});return false}else{$contactusdialog=$("<div></div>").html("Please wait, your email is being sent.").dialog({modal:true,height:150,title:"Sending...",buttons:{Close:function(){$(this).dialog("close")}}});$.post("/layouts/service.asmx/ContactUs",{name:$("#ContactName").val(),email:$("#ContactEmail").val(),message:$("#ContactMessage").val()},function(a){if($contactusdialog){$contactusdialog.dialog("close")}if(a.result.length>0){$contactusdialog=$("<div></div>").html(a.result).dialog({modal:true,height:150,title:"Sorry, an errror has occured sending your message",buttons:{Close:function(){$(this).dialog("close")}}})}else{$("#ContactName").val("");$("#ContactEmail").val("");$("#ContactMessage").val("");$contactusdialog=$("<div></div>").html("Thank you your message has been sent.").dialog({modal:true,height:150,title:"Thank you",buttons:{Close:function(){$(this).dialog("close")}}})}},"json")}};
