(function(f){var i=60000;var b=30000;var a=null;var h=gettext(" more messages...");function g(){var j=new Date().getTime()-e;clearTimeout(a);a=setTimeout(g,b);if(j<=i){var k=new Array();f(".wall_item.wantto").each(function(l){if(l<5){k.push(this.id)}});f.comet.call({method:"keepalive_comments",data:{ids:k}})}}var e=new Date().getTime();function d(){newTimestamp=new Date().getTime();var j=newTimestamp-e;e=newTimestamp;if(j>j){g()}}if(f("body.index").size()==0){f(function(){f(document).mousemove(d).mouseenter(d).scroll(d).keydown(d).click(d).dblclick(d);a=setTimeout(g,b)})}var c={init:function(j){this.each(function(){var m=f(this);m.cancel_btn=m.find(".wantto_cancel");m.find(".wantto_placeholder_textarea").click(function(){f(".wantto_placeholder",m).hide();f(".wantto_form",m).show()});m.find(".id_time_identifier").change(function(){if(f(this).val()=="specific"){f(".id_expiry",m).show()}else{f(".id_expiry",m).hide()}});m.find(".specify_place").click(function(o){o.preventDefault();o.stopPropagation();var n=f(this).siblings(".location_list");n.addClass("on");f(this).hide();n.find(".input_place").focus();n.find(".input_place").attr("size",34);return false});m.find(".input_place").focus(function(o){o.stopPropagation();var n=f(this).parents(".location_list");n.addClass("on");n.siblings(".specify_place").hide()}).focusout(function(o){if(m.find(".place_select_results").size()==0){var n=f(this).parents(".location_list");n.removeClass("on");n.siblings(".specify_place").show()}}).guluAutoComplete({max:10,width:210,stop_submit:true,cacheLength:0,footer:function(o,n){if(o.length){return false}footer_data={html:'<div class="add_new">Add Place : '+n+"</div>",data:[n],value:false,result:""};return footer_data},beforeAjax:function(n){n.trigger("reset_inputs_params",[c.get_latlon(m)])}},{list_contain:m.find(".location_list"),url:"/search/ajax/auto_complete_place/",remove_item:function(){},result:function(q,o,n){var p=m.find(".location_list");var r=m.find(".input_place");if(n){c.addPlace(q,o,n,p)}else{autoShowDialogAjax({url:"/place/ajax/popup_add_place/",callback:function(){f("#id_form_add_place").data("restore",r);f("#id_form_add_place").find("#id_name").val(o[0]).attr("readonly","readonly")},callback_close:function(){return_data=r.data("place");if(return_data){c.addPlace("",return_data,"",p)}}})}}});m.find(".email_my_friends").click(function(o){o.preventDefault();o.stopPropagation();var n=f(this).siblings(".add_friends");n.addClass("on");f(this).hide();n.find(".input_invite_friends").focus();return false});m.find(".input_invite_friends").focus(function(){var n=f(this).parents(".add_friends");n.addClass("on");n.siblings(".email_my_friends").hide()}).focusout(function(){});m.find(".input_invite_friends").guluAutoComplete({max:5,width:210,content_width:210,loadingClass:"",stop_submit:true,liClass:"people",cacheLength:0,footer:function(o,n){if(o.length){return false}valid=Gulu.validateEmail(n);footer_data={html:'<div class="add_new"> Email: '+n+"</div>",data:[n,valid],value:false,result:""};return footer_data}},{list_contain:m.find(".contact_list"),url:"/search/ajax/auto_complete_people/",remove_item:function(){if(m.find(".contact_list input[type=hidden]").size()==0){var n=m.find(".contact_list .input_wrapper input");n.attr("placeholder",n.attr("noplaceholder"));n.removeAttr("noplaceholder")}},result:function(p,r,q){var n=m.find(".contact_list");var o=n.find(".input_wrapper input");if(q){c.addFriend(r,n)}else{if(r[1]){Invite.AddNewContact(r[0],function(s){c.addFriend(s.data,n)})}else{console.log("invalid email.");o.val("");o.attr("size","1");o.trigger("reset_inputs_params")}}o.val("");o.attr("noplaceholder",o.attr("placeholder"));o.removeAttr("placeholder")},only_one:false,no_duplicate:true,prefill:m.find(".input_invite_friends").attr("placeholder")});var l=m.find(".want_to_photo_uploader");var k=new Photos.NewAjaxUploader({uploader_root:l,max_photos:1,btn_container:f(".op_bg_box",l),button:f(".btn_add_photo",l),delete_button:f(".btn_delete_photo",l),initial_photo_class:"initial_photo",initial_photo:f(".no_photo",l),preview:f(".show_photo",l),input:f(".current_photo_id",l),tagged_photo_list:f(".tagged_photo_list",l),default_photos:{photo_id_list:[],photo_url_list:[]},url_input:f(".photo_url",l),imagespec:"image105x105",thumbnail_pagination:false,prev_photo_btn:f(".prev_wall_post_photo",l),next_photo_btn:f(".next_wall_post_photo",l),current_page:f(".wall_post_photo_page",l),total_pages:f(".wall_post_total_photos",l),errors:f(".photo_error_msg",l)});m.find(".add_photo_txt a").click(function(q){q.preventDefault();q.stopPropagation();var o=f(this).parent();var p=o.siblings(".want_to_photo_uploader");var n=o.siblings(".cancel_photo_txt");p.addClass("on");o.hide();n.show();return false});m.find(".cancel_photo_txt a").click(function(q){q.preventDefault();q.stopPropagation();var n=f(this).parent();var p=n.siblings(".want_to_photo_uploader");var o=n.siblings(".add_photo_txt");p.removeClass("on");n.hide();o.show();k.clear_photos();return false});m.find("input[type='checkbox']").autoConvertUI({type:"checkbox",hook_event_1:function(n){}});m.find(".select.id_time_identifier").autoConvertUI({css_class:"ui_select s select_id_time_identifier",type:"select",hook_event_1:function(n){if(this.$obj.val()=="specific"){m.find(".date_group").show()}else{m.find(".date_group").hide()}},hook_convert_after:function(n){f(f("ul li",n.$ui)[0]).hide();f(f("ul li",n.$ui)[1]).click()}});m.find(".select.id_category").autoConvertUI({css_class:"ui_select s select_id_category",type:"select",hook_event_1:function(o){var p=this.$obj.val();if(p=="session"){m.find(".content_input").hide();m.find(".when_group").hide();m.find(".at_group").hide();m.find(".add_place").hide();m.find(".select_tc_session").show();m.find(".content_input").val(m.find(".select.tc_session").val())}else{m.find(".when_group").show();m.find(".at_group").show();m.find(".add_place").show();m.find(".select_tc_session").hide();m.find(".content_input").val("")}if(p=="show"||p=="sports"||p=="hangout"||p=="meetup"){var r=m.find(".content_input");var q="";r.show();r.val("");if(p=="show"){q=gettext("Show title")}else{if(p=="sports"){q="Activity"}else{if(p=="hangout"){q=gettext("Doing what")}else{if(p=="meetup"){q=gettext("About what")}}}}r.attr("placeholder",q)}else{m.find(".content_input").hide()}if(p=="eat"||p=="show"){var n=m.find(".select_id_time_identifier").find("ul");f(f("li",n)[0]).hide();if(m.find(".select.id_time_identifier").val()=="any_time"){f(f("li",n)[1]).click()}}else{var n=m.find(".select_id_time_identifier").find("ul");console.log(n);f(f("li",n)[0]).show()}}});m.find(".select.tc_session").autoConvertUI({css_class:"ui_select s select_tc_session",type:"select",hook_event_1:function(n){var o=this.$obj.val();m.find(".content_input").val(o)}});m.find(".datepicker").datepicker({showOn:"both",buttonImage:"/static/images/calendar.gif",buttonImageOnly:true});m.find(".txt_check").checkValue({hook_focus:function(){}});m.find(".wall_post_private_setting").autoConvertUI({type:"select",hook_event_1:function(n){},hook_convert_after:function(){var o=this.$ui;var n=this.$ul;o.addClass("post_lock");o.css({height:8});n.css({width:50,top:18});o.find(".select_arrow").css({top:5})},option_icon:["/static/images/icon_unlock2.gif","/static/images/icon_lock2.gif"]});m.cancel_btn.click(function(n){n.preventDefault();n.stopPropagation();f(".wantto_form",m).hide();f(".wantto_placeholder",m).show();k.clear_photos();m.find(".cancel_photo_txt a").click();c.clean_place(m);c.clean_contact(m);if(m.find(".only_check input").attr("checked")){m.find(".only_check").click()}m.find(".content_input").val("");m.find(".content_input").attr("placeholder","");m.find(".ui_select").each(function(){f(f(this).find("ul li")[0]).click()});return false});m.find(".wantto_post_btn").click(function(n){n.preventDefault();var o=m.find(".wantto_form_container").serializeObject();c.submit(o,m);return false})});return this},get_latlon:function(j){var k=j.find(".city_lat").val();var l=j.find(".city_lon").val();return{lat:k,lon:l}},addPlace:function(m,k,j,l){l.find(".input_wrapper input").focus();l.append(f('<input type="hidden" class="place_select_results" name="place" id="'+k[0]+'" value="'+k[0]+'"/>'));l.find("ul").append(f('<li style="max-width:105px;" class="'+k[0]+'"><span class="name">'+k[1]+'</span><span class="cancel">x</span></li>'));l.find(".input_wrapper input").val("");l.find(".input_wrapper input").attr("size","1")},addFriend:function(j,l){var k=l.find(".input_wrapper input");k.focus();l.append(f('<input type="hidden" name="contact_list[]" id="'+j[0]+'" value="'+j[0]+'"/>'));l.find("ul").append(f('<li style="max-width:180px;" class="'+j[0]+'"><span class="name">'+j[1]+'</span><span class="cancel">x</span></li>'));k.val("");k.attr("size","1");k.trigger("reset_inputs_params")},submit:function(l,k){if(!c.validate(l,k)){return false}if(l.category=="session"&&l.content==""){l.content=0}var j=f(".wall_post.form_style_1");j.css("position","relative");j.append(f('<div id="posting_now" class="ui_dialog_bg brown" style="position:absolute; z-index:199; top:0px; left:0px; width:'+j.width()+"px; height:"+j.height()+'px; "><img style="display:block; margin:80px auto 0; width:32px; height:32px; " src="/static/images/icon_loading.gif"></div>'));f.ajax({type:"POST",url:"/wantto/post/",data:l,dataType:"json",success:function(m){f("#posting_now").remove();if(m.ok==1){if(m.old==1){f("."+m.action_id+"."+m.actor_id).fadeOut(1000)}k.cancel_btn.click();f(".bind_close.close").click();if(f("#wantto_id_holder").length>0){window.location="/wantto/p/"+m.wantto_id+"?iid="+m.sender_iid}f(m.html).hide().prependTo("#activity_container").fadeIn(1000);f.fn.globjectnotify.subscribe_object(m.wantto_id);Gulu.first_feed_post()}else{f.each(m.fields,function(n,p){if(m.errors[p]){var o=k.find("."+p+"_errors");o.html(m.errors[p][0]);o.show()}else{var o=k.find("."+p+"_errors");o.html("");o.show()}})}}})},clean_place:function(j){var k=j.find(".location_list");k.removeClass("on");k.siblings(".specify_place").show();k.find("input[name=place]").remove();k.find("ul li").remove();k.find(".input_wrapper input").val("")},clean_contact:function(j){var k=j.find(".contact_list");k.parents(".add_friends").removeClass("on");k.parents(".add_friends").siblings(".email_my_friends").show();k.find("input[type=hidden]").remove();k.find("ul li").remove();k.find(".input_wrapper input").val("")},validate:function(l,j){j.find(".error_msg").text("").hide();var k=true;if(l.time_identifier=="specific"){if(l.expiry==""){j.find(".expiry_error_msg").text(gettext("Pick a date for specific time is required.")).show();k=false}}return k},destroy:function(){return this.each(function(){})}};f.fn.WantTo=function(j){if(c[j]){return c[j].apply(this,Array.prototype.slice.call(arguments,1))}else{if(typeof j==="object"||!j){return c.init.apply(this,arguments)}else{f.error("Method "+j+" does not exist on jQuery.WantTo")}}return this}})(jQuery);
