$("a.fb_link").live("click",function(){window.location="/members/profile/";return false});(function(a){var b={};(function(){if(!a.support.opacity){a.fn.clearType=function(){return a(this).each(function(){this.style.removeAttribute("filter")})}}else{a.fn.clearType=function(){return this}}})();b.registerFormFocus=function(){a(".col .field").focus(function(){a(".col").removeClass("current");a(this).closest(".col").addClass("current")})};b.Nav=function(){var b=a("#mainMenu");b.find("li").each(function(){if(a(this).find("ul").length>0){a("<span>").appendTo(a(this).find("a").eq(0));a(this).mouseenter(function(){a(this).find("ul").stop(true,true).slideDown()});a(this).mouseleave(function(){a(this).find("ul").stop(true,true).slideUp()})}})};b.filterSelect=function(){var b;a("a.filterSelect").mouseenter(function(){clearTimeout(b);a("#filterOptions").stop(true,true).slideDown();a("a.filterSelect").addClass("selected")}).mouseleave(function(){b=setTimeout(function(){a("#filterOptions").stop(true,true).slideUp();a("a.filterSelect").removeClass("selected")},300)});a("#filterOptions").mouseenter(function(){clearTimeout(b)}).mouseleave(function(){clearTimeout(b);b=setTimeout(function(){a("#filterOptions").stop(true,true).slideUp();a("a.filterSelect").removeClass("selected")},300)});a("#filterOptions nav a").click(function(b){b.preventDefault(b);a("#filterOptions").find("a.selected").removeClass("selected");var c=a(this).text();if(c.toLowerCase()=="all projects"){a("#filterBar h1, a.filterSelect span").text("All Projects")}else{a("#filterBar h1, a.filterSelect span").text(c+" Projects")}a("#filterBar h1").append('<span class="filter-loader"></span>');searchResults.filterByCat(c)})};b.tabs=function(){a(".tabs").each(function(){var b=a(this).find("li"),c=a(this).siblings("section"),d,e=350;a(this).parent().css({position:"relative",overflow:"visible"});d=c.eq(0).position();b.find("a").each(function(){if(a(this).prop("id")!="project-embed"){var f=a(this),g=f.parent(),h=c.filter("."+f.attr("id"));if(!g.is(".active")){h.hide().css({opacity:0})}if(g.is(".tab")){f.click(function(f){f.preventDefault();if(!g.is(".active")){b.removeClass("active");g.addClass("active");c.stop().css({position:"absolute",top:d.top,left:d.left}).animate({opacity:0},e,function(){a(this).hide()});h.stop().css({opacity:0,position:"relative",top:0,left:0}).show().animate({opacity:1},e,h.clearType)}})}}})})};b.scroll=function(b){var c=a("#popular ul"),d,e,f,g=290,h=g*c.find("li").length,i=0;c.wrap('<div style="overflow:hidden"></div>').append(d=a('<div class="scrollLeft"/>'),e=a('<div class="scrollRight"/>'));f=c.parent().width();e.click(function(){if(i+f+g<=h){i+=g;c.stop().animate({"margin-left":-i})}});i+f>=h;d.click(function(){if(i-g>=0){i-=g;c.stop().animate({"margin-left":-i})}})};b.hover=function(b,c){if(a.support.opacity){a(b).each(function(){var b=a('<div class="bgRollover" />').css({opacity:0,position:"absolute",top:0,left:0,"z-index":0,width:"100%",height:"100%"});a(this).wrapInner('<div style="position:relative;"></div>').css({position:"relative"}).prepend(b).hover(function(){b.stop().animate({opacity:c},350)},function(){b.stop().animate({opacity:0},350)})})}};b.contributors=function(){function m(){if(--h==0){h=1;setTimeout(l,e)}}function l(){if(--h==0){h=c;for(i=0;i<c;i++){b.eq(g).animate({opacity:0},d,function(){a(this).hide();k()});g=g+1>f?0:g+1}}}function k(){var a=g;if(--h==0){h=c;for(i=0;i<c;i++){b.eq(a).css({display:"block",opacity:0}).animate({opacity:1},d,function(){m()});a=a+1>f?0:a+1}}}var b=a("#contributors li"),c=4,d=500,e=4500,f=b.length-1,g=0,h=1,i,j;m()};b.project=function(){var b=a("#featuredProject").css({overflow:"hidden"}),c=b.find("ul"),d=b.find("li"),e=d.eq(0).outerWidth(true),f=b.width(),g="",h=d.length,i,j,k,l=0,m=500,n=2e3;a(".ssvideo").each(function(b){var c,d=a(this).data("host"),e={allowScriptAccess:"always",wmode:"transparent"},f={id:"player"+b};if(d.match(/youtube/i)){c="http://www.youtube.com/e/"+a(this).data("video")+"?enablejsapi=1"}else if(d.match(/vimeo/i)){c="http://vimeo.com/moogaloop.swf?clip_id="+a(this).data("video")+"&api=1"}if(c){a(this).attr({id:"video"+b});swfobject.embedSWF(c,"video"+b,"450","280","8",null,null,e,f)}});while(h--){g+='<div class="slideButton"></div>'}i=a('<div id="slideNav" style="position:relative; overflow:hidden;"><div style="float:left; position:relative; left:50%"><div style="float:left; position:relative; left:-50%">'+g+"</div></div>");j=i.find(".slideButton");i.appendTo(b).delegate(".slideButton","click",function(){var b,d;if(!a(this).is(".active")){d=j.index(j.filter(".active"));b=a("#player"+d)[0];if(b&&"pauseVideo"in b){b.pauseVideo()}else if(b&&"api_pause"in b){b.api_pause()}else{console.log("player not found")}l=j.index(this);j.removeClass("active");a(this).addClass("active");c.stop().animate({"margin-left":-l*e},m)}});j.eq(0).addClass("active");var o=null;a(".slideButton").click(function(a){if("originalEvent"in a){clearInterval(o)}});o=setInterval(function(){var b=0;var c=a(".slideButton");return function(){c.eq(++b%c.length).click()}}(),1e4)};b.featuredAngel=function(){var b=a("#featuredAngel").css({overflow:"hidden"}),c=b.find("ul.angelList"),d=b.find("ul.angelList > li"),e=d.eq(0).outerWidth(true),f=b.width(),g="",h=d.length,i,j,k,l=0,m=500,n=2e3;while(h--){g+='<div class="boxSlideButton"></div>'}i=a('<div id="boxSlideNav">'+g+"</div>");j=i.find(".boxSlideButton");i.appendTo(b).delegate(".boxSlideButton","click",function(){if(!a(this).is(".active")){l=j.index(this);j.removeClass("active");a(this).addClass("active");c.stop().animate({"margin-left":-l*e},m)}});j.eq(0).addClass("active");var o=null;a(".boxSlideButton").click(function(a){if("originalEvent"in a){clearInterval(o)}});o=setInterval(function(){var b=0;var c=a(".boxSlideButton");return function(){c.eq(++b%c.length).click()}}(),1e4)};b.signup=function(){a(".query").focus(function(){if(a(this).val()==="Search for projects..."){a(this).val("")}}).blur(function(){if(a(this).val()===""){a(this).val("Search for projects...")}});a(".start_screen_name, .name").live("focus",function(){if(a(this).val()=="Name...")a(this).val("")}).live("blur",function(){if(a(this).val()=="")a(this).val("Name...")});a(".start_email,.forgotPass, .email").live("focus",function(){if(a(this).val()=="Email Address...")a(this).val("")}).live("blur",function(){if(a(this).val()=="")a(this).val("Email Address...")});a(".start_username").live("focus",function(){if(a(this).val()=="Username...")a(this).val("")}).live("blur",function(){if(a(this).val()=="")a(this).val("Username...")});a(".start_password").live("focus",function(){if(a(this).val()=="Password...")a(this).val("")}).live("blur",function(){if(a(this).val()=="")a(this).val("Password...")});if(a(".targetfunding").val()==""){a(".targetfunding").val("Please enter amount in GBP")}a(".targetfunding").live("focus",function(){if(a(this).val()=="Please enter amount in GBP")a(this).val("")}).live("blur",function(){if(a(this).val()=="")a(this).val("Please enter amount in GBP")});if(a(".closedate").val()==""){a(".closedate").val("The date your campaign will complete funding by")}a(".closedate").live("focus",function(){if(a(this).val()=="The date your campaign will complete funding by")a(this).val("")}).live("blur",function(){if(a(this).val()=="")a(this).val("The date your campaign will complete funding by")});if(a(".projecttitle").val()=="")a(".projecttitle").val("Project Title...");a(".projecttitle").focus(function(){if(a(this).val()=="Project Title...")a(this).val("")}).blur(function(){if(a(this).val()=="")a(this).val("Project Title...")});a(".yourname").focus(function(){if(a(this).val()=="Your Name...")a(this).val("")}).blur(function(){if(a(this).val()=="")a(this).val("Your Name...")});a(".youremail").focus(function(){if(a(this).val()=="Your Email...")a(this).val("")}).blur(function(){if(a(this).val()=="")a(this).val("Your Email...")});a(".friendsemail").focus(function(){if(a(this).val()=="Friends Email...")a(this).val("")}).blur(function(){if(a(this).val()=="")a(this).val("Friends Email...")});a(".friendsname").focus(function(){if(a(this).val()=="Friends Name...")a(this).val("")}).blur(function(){if(a(this).val()=="")a(this).val("Friends Name...")});a(".field.username").bind("keypress blur",function(){a(".field.screenname").val(a(this).val())});a("#start_2_agreeterms").click(function(){if(a(this).attr("checked"))a("#start_2_continue").fadeIn("slow");else a("#start_2_continue").fadeOut("slow")});a("#agree").click(function(){if(a(this).attr("checked"))a("#btn-agree").fadeIn("slow");else a("#btn-agree").fadeOut("slow")});a("#project_country_list").change(function(){if(a(this).val()=="United Kingdom")a("#project_city_list").slideDown("fast");else a("#project_city_list").slideUp("fast")});if(a("#add_pledge").length>0){if(a("#pledge_container > table").size()=="1"){var b=a(".pledge_tbl_master").clone("false");var c="row_new_"+a("#pledge_container > table").size();b.attr({"class":"pledge_tbl_slave"}).removeAttr("style");b.find(".row_order").val(c);b.find(".pledgedesc").removeAttr("readonly").attr({name:"project_pledges["+c+"][col_id_1]"}).val("").html("");b.find(".pledgeval").removeAttr("readonly").attr({name:"project_pledges["+c+"][col_id_2]"}).val("");b.find(".pledgeqty").removeAttr("readonly").attr({name:"project_pledges["+c+"][col_id_3]"}).val("0");b.find(".pledgeqtymatch").attr({name:"project_pledges["+c+"][col_id_6]"}).val("0");b.find(".btn-rem").removeAttr("style");b.find(".row_order").prop("name","project_pledges[row_order][]");b.appendTo("#pledge_container")}}a("#add_pledge").live("click",function(){var b=a(".pledge_tbl_master").clone("false");var c="row_new_"+a("#pledge_container > table").size();b.prop("class","pledge_tbl_slave").removeAttr("style");b.find(".row_order").val(c).prop("name","project_pledges[row_order][]");b.find(".pledgedesc").removeProp("readonly").prop("name","project_pledges["+c+"][col_id_1]").val("").html("");b.find(".pledgeval").removeProp("readonly").prop("name","project_pledges["+c+"][col_id_2]").val("");b.find(".pledgeqty").removeProp("readonly").prop("name","project_pledges["+c+"][col_id_3]").val("0");b.find(".pledgeqtymatch").prop("name","project_pledges["+c+"][col_id_6]").val("0");b.find(".btn-rem").removeAttr("style");b.find(".row_order").prop("name","project_pledges[row_order][]");b.appendTo("#pledge_container");return false});a(".pledgeqty").blur(function(){a(this).next("input").val(a(this).val())});a("#add_pledge_btn").click(function(b){b.preventDefault();a("#pledges").append(a("#pledge_clone").html())});a(".btn-rem").live("click",function(b){b.preventDefault();a(this).parent().parent().remove();a("#deleted_rows").append('<input type="hidden" value="'+a(this).attr("rel")+'" name="project_pledges[deleted_rows][]">')});if(a(".datepicker").length>0){a(".datepicker").datepicker({dateFormat:"yy-mm-dd",nextText:">",prevText:"<",showAnim:"slide"})}if(a(".datepicker_editform").length>0){a(".datepicker_editform").datepicker({dateFormat:"yy-mm-dd 23:00",nextText:">",prevText:"<",showAnim:"slide"})}a(".update_addform").click(function(b){b.preventDefault();a("#project_summary").val(a("#cke_contents_project_summary_copy iframe").contents().find(".cke_show_borders").html());a("#nextstep").val(a(this).attr("rel"));a("#project_submit_add").click()});a(".update_addmediaform").click(function(b){b.preventDefault();a("#nextstep").val(a(this).attr("rel"));a("#project_submit_addmedia").click()});a(".update_editform").click(function(b){b.preventDefault();a("#project_summary").val(a("#cke_contents_project_summary_copy iframe").contents().find(".cke_show_borders").html());a("#nextstep").val(a(this).attr("rel"));a("#project_submit_edit").click()});a("#project_submit_add").click(function(b){var c=a(this).closest("form");a(".message_box").slideUp("fast");a.post(siteUrl+"members/add_project",c.serialize(),function(b){if(!b.success){var c="";for(var d in b.field_errors){c+=b.field_errors[d]+"<br />"}for(var d in b.errors){c+=b.errors[d]+"<br />"}a(".errors_wrap").html("");a(".errors_wrap").html(c);a("#error_msg").slideDown("fast");jQuery("html, body").animate({scrollTop:0},"slow")}else{var e="";if(a("#nextstep").val()=="savecontinue")e=siteUrl+"members/add_project_media/"+b.entry_id;else e=siteUrl+"members/add_project/"+b.entry_id;window.location=e}},"json");return false});a("#project_submit_addmedia").click(function(b){var c=a(this).closest("form");a(".message_box").slideUp("fast");a.post("/members/add_project",c.serialize(),function(b){if(!b.success){var c="";for(var d in b.field_errors){c+=b.field_errors[d]+"<br />"}for(var d in b.errors){c+=b.errors[d]+"<br />"}a(".errors_wrap").html("");a(".errors_wrap").html(c);a("#error_msg").slideDown("fast");jQuery("html, body").animate({scrollTop:0},"slow")}else{var e="";if(a("#nextstep").val()=="savecontinue")e="/members/my_projects";else if(a("#nextstep").val()=="savecontinue_review")e="/members/tell-your-friends/feedback/"+b.entry_id;else if(a("#nextstep").val()=="savecontinue_golive")e="/members/tell-your-friends/golive/"+b.entry_id;else e="/members/add_project_media/"+b.entry_id;window.location=e}},"json");return false});a("#project_submit_edit").click(function(b){var c=a(this).closest("form");a(".message_box").slideUp("fast");a.post("/members/edit_project",c.serialize(),function(b){if(!b.success){var c="";for(var d in b.field_errors){c+=b.field_errors[d]+"<br />"}for(var d in b.errors){c+=b.errors[d]+"<br />"}a(".errors_wrap").html("");a(".errors_wrap").html(c);a("#error_msg").slideDown("fast");jQuery("html, body").animate({scrollTop:0},"slow")}else{var e="";if(a("#nextstep").val()=="savecontinue")e="/members/my_projects";else if(a("#nextstep").val()=="savecontinue_review")e="/members/tell-your-friends/feedback/"+b.entry_id;else if(a("#nextstep").val()=="savecontinue_golive")e="/members/tell-your-friends/golive/"+b.entry_id;else e="/members/edit_project/"+b.entry_id;window.location=e}},"json");return false});a("#save_project_alert").click(function(a){a.preventDefault();alert("You must save your project before you can preview it.")});a(".media_check").click(function(b){b.preventDefault();if(confirm("Please confirm that you have saved your media before leaving this page.\nClick cancel to go back and save your project or click OK to continue."))window.location=a(this).attr("rel")})};b.member_project_manager=function(){a(".update_form").click(function(b){b.preventDefault();a("#project_summary").val(a("#cke_contents_project_summary_copy iframe").contents().find(".cke_show_borders").html());a("#project_submit").click()})};b.createproject=function(){a(".update_nextstep").click(function(b){b.preventDefault();a("#nextstep").val(a(this).attr("rel"));a("#project_summary_copy").val(a("#cke_contents_project_summary iframe").contents().find(".cke_show_borders").html());a("#submit").click()});a("#submit").click(function(b){b.preventDefault();var c=a(this).closest("form");if(c.validate().form()){var d="";c.find(":input").each(function(a){d+=this.name+"="+this.value+"&"});if(a("#channel_entry_id").val()){a.post("/projects/start/edit",{postdata:d},function(b){if(b.status=="true"&&b.channel_entry_id){if(a("#nextstep").val()=="preview")window.open("/projects/draft/"+b.channel_entry_id,"_blank","left=0,top=0,scrollbars=yes");else if(a("#nextstep").val()=="savecontinue")window.location="/projects/media/"+b.channel_entry_id;else alert(b.message)}else alert(b.message)},"json")}else{a.post("/projects/start/create",{postdata:d},function(b){if(b.status=="true"&&b.channel_entry_id){if(a("#nextstep").val()=="preview")window.open("/projects/draft/"+b.channel_entry_id,"_blank","left=0,top=0,scrollbars=yes");else if(a("#nextstep").val()=="savecontinue")window.location="/projects/media/"+b.channel_entry_id;else{a("#channel_entry_id").val(b.channel_entry_id);alert(b.message)}}else alert(b.message)},"json")}}});a(".update_nextstep_media").click(function(b){b.preventDefault();a("input[name=return_url]").val(a(this).attr("rel"));a("input[name=return]").val(a(this).attr("rel"));a("#submit_media").click()})};b.accordion=function(){heightArray=new Array;a("dl.v_show_hide dd").each(function(b){theHeight=a(this).height();heightArray[b]=theHeight});a("dl.v_show_hide dd").hide();a("dl.v_show_hide dt").click(function(){a(this).next("dd").css({height:heightArray[a("dl.v_show_hide dt").index(this)]});a(this).next("dd").slideToggle("slow").siblings("dd").slideUp("slow")})};b.addFollow=function(){a(".favorited.not_saved").append('<a class="Favorites_Save Favorites_Trigger" style="display:none;" href="{permalink="projects/add_follow/"}">save</a>');a(".favorited.not_saved").append('<a class="Favorites_Delete Favorites_Trigger" style="display:none;" href="{permalink="projects/add_follow/delete/"}">delete</a>');a(".favorited.saved").append('<a class="Favorites_Save Favorites_Trigger" style="display:none;" href="{permalink="projects/add_follow/"}">save</a>');a("a.Favorites_Save").click(function(){var b=a(this).attr("href");a(".Favorites_Status").load(b,function(){a(".Favorites_Delete").show()});a(this).hide();return false});a("a.Favorites_Save_Full").click(function(){var b=a(this).attr("href");a(".Favorites_Status").load(b,function(){a(".Favorites_Delete").show()});a(this).hide();return false});a("a.Favorites_Delete").click(function(){var b=a(this).attr("href");a(".Favorites_Status").load(b,function(){a(".Favorites_Save").show()});a(this).hide();return false})};b.pledge=function(){a(".radioButton.active").each(function(b){$amount=a(this).next().children(".amount").text();$pledge_id=a(this).attr("rel");$details=a(this).next().next(".pledgeDesc").text();a("#pledgeAmount").val($amount);a("#pledgeReward").html($details).slideDown("fast");a("#pledge_amount_identifier").val($amount);a("#pledge_id_identifier").val($pledge_id)});a(".fund_update").click(function(b){b.preventDefault();a("#pledgeReward").slideUp("fast");a(".radioButton").removeClass("active");a(".fund").removeClass("selected");$amount=a(this).parent().prev().prev().prev().children(".amount").text();$pledge_id=a(this).attr("rel");$details=a(this).parent().prev().prev(".pledgeDesc").text();$radio=a(this).parent().prev().prev().prev().prev(".radioButton");a(this).addClass("selected");$radio.addClass("active");a("#pledgeAmount").val($amount);a("#pledgeReward").html($details).slideDown("fast");a("#pledge_amount_identifier").val($amount);a("#pledge_id_identifier").val($pledge_id)});a(".radioButton").click(function(b){b.preventDefault();a(this).next().next().next().next().children(".fund_update").click()});a("#btn-pledge").click(function(b){b.preventDefault();var c=parseInt(a("#pledgeAmount").val());var d=parseInt(a("#pledge_amount_identifier").val());var e=c-d;if(e>=0)a("#pledge").submit();else alert("To make this pledge the amount paid must be equal to or greater than the pledge amount!")})};b.showHide=function(){var b="View Pledges";var c="Hide Pledges";var d=false;a(".pledgeList").prev().append('<a href="#" class="toggleLink viewProj">'+b+"</a>");a(".pledgeList").hide();a("a.toggleLink").click(function(){d=!d;a(this).html(!d?b:c);a(this).parent().next(".pledgeList").toggle("slow");return false})};a(document).ready(function(){b.Nav();b.filterSelect();b.addFollow();b.accordion();b.tabs();b.scroll();b.contributors();b.project();b.signup();b.pledge();b.hover("section.projects > section, section.posts > section",1);b.showHide();b.createproject();b.member_project_manager();b.featuredAngel();b.registerFormFocus();jQuery.validator.addClassRules({targetfunding:{required:true,range:[1,9999999],digits:true},closedate:{required:true,date:true},projecttitle:{required:true,minlength:5,maxlength:40},projectsummarycopy:{required:true,minlength:40,maxlength:5e3},pledgedesc:{required:true,minlength:5,maxlength:255},pledgeval:{required:true,number:true},pledgeqty:{required:true,digits:true},pledgeAmount:{required:true,number:true}})})})(jQuery)
