$(function(){$("#helpHostAnEventDialog").dialog({autoOpen:false,height:260,minWidth:240,width:240,modal:true,title:"Host a Cleanup Event"});$("#helpHostAnEventLink").click(function(){$("#helpHostAnEventDialog").dialog("open");return false});var a=[];var h=null;var i=[];function f(){var x=new google.maps.LatLng(44.980342,-84.177246);var y={zoom:6,center:x,mapTypeId:google.maps.MapTypeId.ROADMAP,maxZoom:16,minZoom:5,panControl:false,streetViewControl:false};h=new google.maps.Map(document.getElementById("map_canvas"),y)}function v(){var A=parseInt($("html").height()),F=parseInt($("nav").height()),z=parseInt($("header").height()),y=parseInt($("footer").height()),H=parseInt($(window).height()),E=465,D=H-F-z-y-20,G=$("#map_splash img").height(),x=D;var B=$("html").width(),C=$("td.homeBeachList").width(),I=$(window).width();if($("#map_canvas").hasClass("hidden")){D=G;x=G-192}else{D=(D<E)?E:D;x=D-194}$("#map_canvas").height(D).width(I-C-1);$("#map").height(D);$("#beachList").height(x)}v();function u(){b();var A=65;for(var y in a){var x=a[y];if(x!="undefined"){var z="";if((x.LatitudeCenter)&&(x.LatitudeCenter!==0)){z="http://www.google.com/mapfiles/marker"+String.fromCharCode(A++)+".png";c(h,new google.maps.LatLng(x.LatitudeCenter,x.LongitudeCenter),x.SiteName,z)}}}e(h)}function t(D){$("ul.homeBeachList").empty();$(".eventDetailDialog").remove();if(a.length==0){if(!D){$.tmpl($("#beachListEmptyRowTmpl")).appendTo("ul.homeBeachList")}return false}var C=65;for(var y in a){var x=a[y];if(x!="undefined"){var B="";if((x.LatitudeCenter)&&(x.LatitudeCenter!==0)){B="http://www.google.com/mapfiles/marker"+String.fromCharCode(C++)+".png"}var z="";if((x.City!=null)&&(x.City.CityName.length>0)){z+=x.City.CityName}if((x.County!=null)&&(x.County.CountyName.length>0)){if(z.length>0){z+=", "}z+=x.County.CountyName+" County"}if((x.State!=null)&&(x.State.StateName.length>0)){if(z.length>0){z+=", "}z+=x.State.StateName}$("ul.homeBeachList").append($("#beachListRowTmpl").tmpl({Beach:x,Icon:B,BeachLocale:z}));for(var A in x.Events){$(".eventDetailDialog[data-id='"+x.Events[A].Id+"']").dialog({autoOpen:false,title:"Event Details",modal:true,draggable:true,resizable:false,minWidth:340,width:340});$(".eventDate[data-id='"+x.Events[A].Id+"']").unbind("click").bind("click",function(){$(".eventDetailDialog").dialog("close");var E=$(".eventDetailDialog[data-id='"+$(this).attr("data-id")+"']");var F=$(this).position();E.dialog("option","position",[F.left+300,F.top-100]);E.dialog("open");$("a.eventRegisterButton",E).unbind("click").bind("click",j)})}}}}t(true);function e(z){var x=new google.maps.LatLngBounds();if(i.length>0){for(var y=0;y<i.length;y++){x.extend(i[y].position)}z.fitBounds(x)}}function c(z,y,B,x){var A=new google.maps.Marker({position:y,map:z,title:B});if(x!=null){A.setIcon(x)}i.push(A)}function b(){for(var x=0;x<i.length;x++){i[x].setMap(null)}i=[]}var w=function(){var z=$("#mapCriteria").serialize();var x=$("#beach",$("#mapCriteria")).val();var y=$("#date",$("#mapCriteria")).val();if(x=="county, city, or beach name"){x=""}if(y=="event date"){y=""}if((x!="")||(y!="")){$.blockUI({message:'<img src="'+Wndsr.vroot+'Content/images/waitSave.gif" />  Searching...'});$.post(Wndsr.vroot+"Callback/BeachAndEventSearch",{beach:x,city:x,county:x,date:y},function(A){$("#map_canvas").removeClass("hidden");$("#map_splash").addClass("hidden");if(h==null){f()}$.unblockUI();a=jQuery.parseJSON(A);t();u();v()},"html").error(function(B,C,A){alert(C)})}};$(window).resize(function(){v()});var g=false;var k=null;var j=function(){$(".eventDetailDialog").dialog("close");k=$("#registerDialog");k.dialog({modal:true,width:750});k.dialog("open");$("#registerEventId",k).val($(this).attr("data-id"));$("#registerEventSiteName",k).val($(this).attr("data-sitename"));$("#registerEventDate",k).val($(this).attr("data-date"));$("#registerEventIsPublic",k).val($(this).attr("data-ispublic"));$("#registerEventTeamType",k).val("");$("#loginOrRegister").val("register");$("#waiver").removeAttr("checked");$("#photo").removeAttr("checked");$("#newsletter").attr("checked",true);$("#child").removeAttr("checked");$("#dob").val("");$("#ParentFirstName").val("");$("#ParentLastName").val("");$("#ParentEmail").val("");$("#authorize").removeAttr("checked");$("select#referral").attr("selectedIndex",0);$("#referralOther").val("");$("#registerAsIndividual").removeAttr("checked");$("#registerAsTeam").removeAttr("checked");$("#numParticipants").val("");$("#numMinors").val("");$("#teamId").val("");$("#autocompleteTeamName").val("");$("#autocompleteTeamID").val("");$("#teamDetails").addClass("hidden").hide();$("#individualDetails").addClass("hidden").hide();if(isAuthenticated){p()}else{n()}};var n=function(){$("#register-step-1").removeClass("hidden");$("#register-step-2").addClass("hidden");$("#register-step-3").addClass("hidden");$("#register-step-4").addClass("hidden");$("#emailRegister").val("");$("#passwordCreate").val("");$("#passwordConfirm").val("");$("#passwordLogin").val("");g=false;var x=function(){if($("#loginOrRegister").val()=="login"){$("#loginOrRegisterLogin").attr("checked",true);$("#passwordCreate").val("").attr("disabled",true);$("#passwordConfirm").val("").attr("disabled",true);$("#passwordLogin").val("").removeAttr("disabled")}else{if($("#loginOrRegister").val()=="register"){$("#loginOrRegisterRegister").attr("checked",true);$("#passwordCreate").val("").removeAttr("disabled");$("#passwordConfirm").val("").removeAttr("disabled");$("#passwordLogin").val("").attr("disabled",true)}}};x();$("input[name='loginOrRegister']").unbind("click").bind("click",function(){$("#loginOrRegister").val($("input[name='loginOrRegister']:checked").val());x()});k.dialog("option","title","Event Registration: Sign In or Create An Account");$("button.continue").unbind("click").bind("click",o)};var r=function(){$("#register-step-1").addClass("hidden");$("#register-step-2").removeClass("hidden");$("#register-step-3").addClass("hidden");$("#register-step-4").addClass("hidden");k.dialog("option","title","Event Registration: Waiver and Liability Release");$("#registrationWaiverFailurePlaceholder",k).addClass("hidden");var x=function(){if($("input#child").attr("checked")){$("#dob").removeAttr("disabled");$("#ParentFirstName").removeAttr("disabled");$("#ParentLastName").removeAttr("disabled");$("#ParentEmail").removeAttr("disabled");$("#authorize").removeAttr("disabled")}else{$("#dob").val("").attr("disabled",true);$("#ParentFirstName").val("").attr("disabled",true);$("#ParentLastName").val("").attr("disabled",true);$("#ParentEmail").val("").attr("disabled",true);$("#authorize").removeAttr("checked").attr("disabled",true)}if($("select#referral").val()=="23"){$("#referralOther").removeAttr("disabled")}else{$("#referralOther").val("").attr("disabled",true)}};x();$("input#child").unbind("click").bind("click",function(){x()});$("select#referral").unbind("change").bind("change",function(){x()});$("button.continue").unbind("click").bind("click",s)};var p=function(){$("#register-step-1").addClass("hidden");$("#register-step-2").addClass("hidden");$("#register-step-3").removeClass("hidden");$("#register-step-4").addClass("hidden");k.dialog("option","title","Event Registration: Team Information");$("#registrationTeamFailurePlaceholder",k).addClass("hidden");$("#adminPersonSelectDiv").addClass("hidden");$("#registerButton").parent().remove();Wndsr.setupValidation($("#registerForm"),d);if((isAuthenticated)||(g)){$("button.back").addClass("hidden")}else{$("button.back").unbind("click").bind("click",r).removeClass("hidden")}$("button.continue").unbind("click").bind("click",q)};var l=function(){$("#register-step-1").addClass("hidden");$("#register-step-2").addClass("hidden");$("#register-step-3").addClass("hidden");$("#register-step-4").removeClass("hidden");k.dialog("option","title","Event Registration: Confirmation");$("#registrationConfirmFailurePlaceholder",k).addClass("hidden");$("#confirmEventSiteName").html($("#registerEventSiteName").val());$("#confirmEventIsPublic").html(($("#registerEventIsPublic").val()=="true")?"Yes":"No");$("#confirmEventDate").html(Wndsr.formatDateMMDDYYYY(Wndsr.parseJsonDateString($("#registerEventDate").val())));$("#confirmEventTeamType").html($("#registerEventTeamType").val());$("button.back").unbind("click").bind("click",p).removeClass("hidden");$("button.continue").unbind("click").bind("click",m)};var o=function(){$("#loginOrRegister").val($("input[name='loginOrRegister']:checked").val());$("#registrationLoginFailurePlaceholder",k).addClass("hidden");var x=$("#emailRegister").val();var y="";var z=$("#thirdPartyType").val();if($("#loginOrRegister").val()=="register"){y=$("#passwordCreate").val();if((x==null)||(x=="")||(y==null)||(y=="")){$("#registrationLoginFailurePlaceholder",k).removeClass("hidden").html('<span class="validation-summary-errors">E-mail and password required to login</span>');return}if(y!=$("#passwordConfirm").val()){$("#registrationLoginFailurePlaceholder",k).removeClass("hidden").html('<span class="validation-summary-errors">Password and confirmation password must be the same</span>');return}$.blockUI({message:'<img src="'+Wndsr.vroot+'Content/images/waitSave.gif" />  Attempting to create new account...'});$.post(Wndsr.vroot+"Home/CreateAccountJson",{user:x,password:y,thirdPartyType:z},function(A){$.unblockUI();if((A==="true")||(A===true)){r()}else{$("#registrationLoginFailurePlaceholder",k).removeClass("hidden").html('<span class="validation-summary-errors">Account could not be created</span>')}},"json").error(function(B,C,A){$.unblockUI();alert(C)})}else{if($("#loginOrRegister").val()=="login"){y=$("#passwordLogin").val();if((x==null)||(x=="")||(y==null)||(y=="")){$("#registrationLoginFailurePlaceholder",k).removeClass("hidden").html('<span class="validation-summary-errors">E-mail and password required to login</span>');return}$.blockUI({message:'<img src="'+Wndsr.vroot+'Content/images/waitSave.gif" />  Attempting Login...'});$.post(Wndsr.vroot+"Secure/Login",{email:x,password:y},function(A){$.unblockUI();if((A==="true")||(A===true)){g=true;p()}else{$("#registrationLoginFailurePlaceholder",k).removeClass("hidden").html('<span class="validation-summary-errors">Login failed for user '+x+"</span>")}},"json").error(function(B,C,A){$.unblockUI();alert(C)})}}};var s=function(){$("#registrationWaiverFailurePlaceholder",k).addClass("hidden");if(!$("#waiver").is(":checked")){$("#registrationWaiverFailurePlaceholder",k).removeClass("hidden").html('<span class="validation-summary-errors">You must agree to the waiver and liability release before proceeding</span>');return}if(!$("#photo").is(":checked")){$("#registrationWaiverFailurePlaceholder",k).removeClass("hidden").html('<span class="validation-summary-errors">Please agree to the "photo and name use waiver"</span>');return}if($("#child").is(":checked")){if($("#dob").val()===""||$("#ParentFirstName").val()===""||$("#ParentLastName").val()===""||$("#ParentEmail").val()===""){$("#registrationWaiverFailurePlaceholder",k).removeClass("hidden").html('<span class="validation-summary-errors">If Under 18 is checked, the parent/guardian information must also be completed</span>');return}if($("#authorize").filter(":checked").length!==1){$("#registrationWaiverFailurePlaceholder",k).removeClass("hidden").html('<span class="validation-summary-errors">Parent or guardian must check the box authorizing participation</span>');return}}$.blockUI({message:'<img src="'+Wndsr.vroot+'Content/images/waitSave.gif" />  Saving...'});$.post(Wndsr.vroot+"Home/SelfUpdateReferralJson",$("#updateUserReferralForm").serialize(),function(x){$.unblockUI();if((x==="true")||(x===true)){p()}else{$("#registrationWaiverFailurePlaceholder",k).removeClass("hidden").html('<span class="validation-summary-errors">Attempt to save waivers failed</span>')}},"json").error(function(y,z,x){$.unblockUI();alert(z)})};var q=function(){$("#eventId").val($("#registerEventId").val());$("#registrationTeamFailurePlaceholder",k).addClass("hidden");if(!(($("#registerAsIndividual:checked").length==1)||($("#registerAsTeam:checked").length==1))){$("#registrationTeamFailurePlaceholder",k).removeClass("hidden").html('<span class="validation-summary-errors">Please select the type of team that you will be part of.</span>');return}if(!($("#registerForm").valid())){$("#registrationTeamFailurePlaceholder",k).removeClass("hidden").html('<span class="validation-summary-errors">Please complete your team information.</span>');return}$("#registerEventTeamType").val(($("#registerAsIndividual:checked").length==1)?"Individual":"Team");l()};var m=function(){$.blockUI({message:'<img src="'+Wndsr.vroot+'Content/images/waitSave.gif" />  Saving Registration...'});$.post(Wndsr.vroot+"Home/SelfRegisterJson",$("#registerForm").serialize(),function(x){$.unblockUI();if((x==="true")||(x===true)){alert("Your registration is complete!  You should receive a confirmation e-mail shortly.");k.dialog("close");if((isAuthenticated)||(g)){$.blockUI({message:'<img src="'+Wndsr.vroot+'Content/images/waitSave.gif" />  Redirecting to dashboard...'});location.href=Wndsr.vroot+"Secure/Dashboard"}else{$.blockUI({message:'<img src="'+Wndsr.vroot+'Content/images/waitSave.gif" />  Redirecting to home page...'});location.href=Wndsr.vroot}}else{if((x==="false")||(x===false)){$("#registrationConfirmFailurePlaceholder",k).removeClass("hidden").html('<span class="validation-summary-errors">Registration failed.  You are already registered for this event.</span>')}else{$("#registrationConfirmFailurePlaceholder",k).removeClass("hidden").html('<span class="validation-summary-errors">Attempt to complete registration has failed.</span>')}}},"json").error(function(y,z,x){$.unblockUI();alert(z)})};var d={validateNumParticipants:{method:function(y,x){return($("#registerAsIndividual:checked").length==1||($("#registerAsTeam:checked").length==1&&$("#numParticipants").val()!==""))},message:"Number of Participants Required"},validateNumMinors:{method:function(y,x){return($("#registerAsIndividual:checked").length==1||($("#registerAsTeam:checked").length==1&&$("#numMinors").val()!==""))},message:"Number Under 18 Required"},validateMinorsLessTotal:{method:function(A,x){var z=parseInt($("#numParticipants").val());var y=parseInt($("#numMinors").val());return($("#registerAsIndividual:checked").length==1||(y<=z))},message:"Number of Minors must be less than or equal to the Total"},validateNewTeamName:{method:function(y,x){return($("#createNewTeam").val()=="false"||($("#newTeamName").val()!=""))},message:"New Team Name is required"},validateRoleType:{method:function(y,x){return($("#PersonRoleType")==undefined||$("#PersonRoleType").val()!=0)},message:"Role is required"}};$("button").button();$("#searchBeaches").click(w);$("#mapCriteria").submit(function(x){x.preventDefault()});$("#taskSearch input").hint()});
