$.fn.image=function(b,a){return this.each(function(){var c=new Image();c.src=b;c.onload=a;this.src=c.src})};var showwarning=false;$(document).ready(function(){resetForm();window.onbeforeunload=confirmExit;$("#tool").hide();$("#display_errors").hide();$("#download_guide").hide();$("#tool").fadeIn(1500);$("#tool_inner_wrapper input, #tool_inner_wrapper select").attr("disabled","disabled");$("#information").formwizard({historyEnabled:false,formPluginEnabled:true,validationEnabled:true,textSubmit:"",textNext:"",textBack:""},{errorLabelContainer:$("#display_errors"),rules:{contact_information:{minlength:3}},messages:{"guidetype[]":"Please select a guide type.",state:"Please select a state.",community:"Please select a community.","dev_messages[]":"Please select development messages you'd like to include. ","water_messages[]":"Please select water budget messages you'd like to include. ","steward_messages[]":"Please select stewardship messages you'd like to include. ",name_of_link:"Please include a name of the link for your resource.<br />",web_address:"Please include a web address for your resource (include http://).",logo_check:"Please either upload a logo or check the box to enter your organization's name",contact_information:"Please include your organization's contact information",resource_link_1:"Please add at least 1 resource<br />",resource_address_1:"Please enter a valid URL beginning with http://<br />",resource_link_2:"",resource_address_2:"Please enter a valid URL beginning with http://<br />",resource_link_3:"",resource_address_3:"Please enter a valid URL beginning with http://<br />",resource_link_4:"",resource_address_4:"Please enter a valid URL beginning with http://<br />",resource_link_5:"",resource_address_5:"Please enter a valid URL beginning with http://<br />"}},{success:function(a){alert(a)},beforeSubmit:function(a){alert("about to send the following data: \n\n"+$.param(a))},resetForm:false});init_checkboxes();$("a[rel='sample_1']").colorbox();$("a[rel='sample_2']").colorbox();$("a[rel='sample_3']").colorbox();$("#guide_dev").toggle(function(){$(this).attr("checked",true);$("#resources_dev").show();$("#links_dev").show();showwarning=true},function(){$(this).attr("checked",false);$("#resources_dev").hide();$("#resources_dev input").attr("disabled","disabled");$("#resources_dev input").attr("checked",false);$("#links_dev").hide();$("#links_dev input").attr("disabled","disabled");$("#links_dev input").attr("checked",false)});$("#guide_water").toggle(function(){$(this).attr("checked",true);$("#resources_water").show();$("#links_water").show();showwarning=true},function(){$(this).attr("checked",false);$("#resources_water").hide();$("#resources_water input").attr("disabled","disabled");$("#resources_water input").attr("checked",false);$("#links_water").hide();$("#links_water input").attr("disabled","disabled");$("#links_water input").attr("checked",false)});$("#guide_steward").toggle(function(){$(this).attr("checked",true);$("#resources_steward").show();$("#links_steward").show();showwarning=true},function(){$(this).attr("checked",false);$("#resources_steward").hide();$("#resources_steward input").attr("disabled","disabled");$("#resources_steward input").attr("checked",false);$("#links_steward").hide();$("#links_steward input").attr("disabled","disabled");$("#links_steward input").attr("checked",false)});$("a[rel='sample_1a']").colorbox();$("a[rel='sample_2a']").colorbox();$("a[rel='sample_3a']").colorbox();$("#community_wrapper").hide();$("#guardians").hide();$("#state").change(function(){$("#guardians").fadeOut();$.post("a/select_state",{state:$("#state").val()},function(a){if(a){$("#community").html(a);$("#community_status").text("");$("#community_wrapper").fadeIn()}else{$("#community_wrapper").fadeOut()}})});$("#community").change(function(){if($("#community").val()!==""){$.post("a/select_community",{state:$("#state").val(),community:$("#community").val()},function(a){if(a){$("#guardians").html(a);$("#guardians").fadeIn()}else{$("#guardians").fadeOut()}})}else{$("#guardians").fadeOut()}});init_step3();$("#resources_dev").hide();$("#resources_water").hide();$("#resources_steward").hide();$(".more_info").click(function(){$.fn.colorbox({href:$(this).attr("href"),inline:true,open:true,width:"50%"});return false});$("#links_dev").hide();$("#links_water").hide();$("#links_steward").hide();$("#add_own_resource").toggle(function(){$(this).attr("checked",true);$("#name_of_link").removeAttr("disabled");$("#web_address").removeAttr("disabled")},function(){$("#name_of_link").attr("disabled","disabled");$("#web_address").attr("disabled","disabled");$(this).attr("checked",false)});init_step6_logo();$("#try_logo_upload_again").click(function(){$("#organization_logo").load("a/logo_try_again",function(){init_step6_logo()});return false});$(".sample_preview").click(function(){$.fn.colorbox({href:$(this).attr("href"),open:true,width:"700px"});return false});$("#preview_contact_info").colorbox();$("#preview_version").colorbox();$("#user_info_error").hide();$("#download_guide").click(function(){if($("#submitted_email").length==0){if($("#your_name").val()!=""&&$("#your_email").val()!=""&&$("#your_email").valid()){$("#user_information").fadeOut();$("#user_information").load("a/submit_user_info",{your_name:$("#your_name").val(),your_email:$("#your_email").val()},function(){$("#user_information").fadeIn()})}else{$("#user_info_error").show();return false}}$.post("a/submit_values",$("#information").serializeArray())});$("#button_next, #button_back").click(function(){$(this).blur()})});function init_step3(){$("#thumb_loader").hide();$("#image_gallery img").click(function(){$(this).fadeTo(100,0.4,function(){$(this).fadeTo(300,1)});var a=$(this).attr("src").replace(".png","_large.png");$("#pic").attr("value",a);$("#thumb_final").hide();$("#thumb_loader").show();$("#thumb_final").image(a,function(){$("#thumb_loader").hide();$("#thumb_final").fadeIn()})});$("#image_gallery img").hover(function(){$(this).fadeTo(10,0.8)},function(){$(this).stop();$(this).fadeTo(200,1)});$("#upload_cover_disabled").hide();new AjaxUpload("#upload_cover",{action:"a/upload_cover_image",name:"userfile",data:{key1:"This data won't",key2:"be send because",key3:"we will overwrite it"},onSubmit:function(a,b){if(b&&/^(jpg|png|jpeg|gif)$/.test(b)){this.setData({key:"This string will be send with the file",key2:a});$("#upload_cover_wrapper .status_text").html('<img src="css/img/thumb_loader.gif" style="float:left;" /><p style="float:left;">Uploading '+a+"</p>")}else{$("#upload_cover_wrapper .status_text").text("Error: only images are allowed");return false}$("#upload_cover").fadeOut();$("#oops_no_logo").fadeOut()},onComplete:function(b,a){$("#system_images").slideUp(function(){$("#upload_cover_wrapper #cover_status").html(a);kickoff()})}})}function init_step6_logo(){$("#try_logo_again").hide();$("#no_logo_text").hide();$("#upload_logo_disabled").hide();$("#yes_organization_logo").attr("checked",true);$("#no_organization_logo").click(function(){$(this).attr("checked",true);$("#logo_upload_wrapper").hide();$("#no_logo_text").show();$("#organization_logo").addClass("disabled");$("#logo_check").removeClass("required");$("#no_logo_text").removeAttr("disabled");if($("#uploaded_logo").length==0){$("#upload_logo").hide();$("#upload_logo_disabled").show()}});$("#yes_organization_logo").click(function(){$(this).attr("checked",true);$("#no_logo_text").hide();$("#logo_upload_wrapper").show();$("#organization_logo").removeClass("disabled");$("#logo_check").addClass("required");$("#no_logo_text").attr("disabled","disabled");if($("#uploaded_logo").length==0){$("#upload_logo").show();$("#upload_logo_disabled").hide()}});$("#no_logo_text").click(function(){if($(this).val()=="Enter Organization's Name"){$(this).val("")}});new AjaxUpload("#upload_logo",{action:"a/upload",name:"userfile",data:{key1:"This data won't",key2:"be send because",key3:"we will overwrite it"},onSubmit:function(a,b){if(b&&/^(jpg|png|jpeg|gif)$/.test(b)){this.setData({key:"This string will be send with the file",key2:a});$("#logo_upload_wrapper .status_text").text("Uploading "+a)}else{$("#logo_upload_wrapper .status_text").text("Error: only images are allowed");return false}$("#upload_logo").hide();$("#oops_no_logo").hide()},onComplete:function(b,a){$("#logo_upload_wrapper #logo_status").html("<p>"+a+"</p>");$("#determine_organization").hide();$("#try_logo_again").show()}})}function resetForm(){for(i=0;i<document.forms.length;i++){document.forms[i].reset()}}function confirmExit(){if(showwarning){return"You have attempted to leave or refresh this page.  Any changes to the fields will be lost.  Are you sure you want to exit this page?"}}jQuery.validator.addMethod("require_from_group",function(d,c,b){numberRequired=b[0];selector=b[1];var e=$(c).parents("form");var f=0;e.find(selector).each(function(){if($(this).val()){f++}});if(f>=numberRequired){e.find(selector).removeClass("error");var a=e.find(selector).next("label.error").not(".checked");a.text("").addClass("checked");return true}},jQuery.format(""));jQuery.validator.addClassRules("fillone",{require_from_group:[1,".fillone"]});
