var ACCOUNT=(function(B,A){var C={init:function(){B.validator.addMethod("confirm",function(F,E){var D=B(E).attr("id")+"_confirm";if(F!=B("#"+D).val()){return false;}else{return true;}},__("register_invalid_email_confirm"));B("#vs_account_change_password").validate({rules:{new_pass_account:{required:true,minlength:6,maxlength:255,confirm:true},retype_pass_account:{required:true,minlength:6,maxlength:255}},submitHandler:function(D){LIGHTBOX.showLogger();LIGHTBOX.addLogMessage(__("reset_password_validating"),"loading");
B.post("/ajax/account.php",{code:D.elements["code"].value,email:D.elements["email"].value,new_pass_account:D.elements["new_pass_account"].value,retype_pass_account:D.elements["retype_pass_account"].value,reset_password:D.elements["reset_password"].value,saved:D.elements["saved"].value,user_id:D.elements["user_id"].value},function(E,F,G){if(window.console){console.log("Received reset password response:",E,F);}if(E.length>0){E=E[0];switch(E.code){case"invalid_password":case"invalid_new_password":case"password_mismatch":LIGHTBOX.updateLogMessage(__("reset_password_validating"),"error");
LIGHTBOX.addLogMessage(E.message,"error");LIGHTBOX.hideLogger(3000);D.elements["new_pass_account"].value="";D.elements["retype_pass_account"].value="";break;case"no_changes":case"success":LIGHTBOX.updateLogMessage(__("reset_password_validating"),"success");LIGHTBOX.addLogMessage(__("reset_password_success"),"success");LIGHTBOX.addLogMessage(__("postform_login"),"loading");A.authorize({action:"login",email:D.elements["email"].value,password:D.elements["new_pass_account"].value,onComplete:function(J){var H=J;
var I="";for(i=0;i<H.length;i++){I=H[i];switch(I.code){case"blocked_user":case"disabled_user":case"invalid_email":case"incorrect_email_password":LIGHTBOX.updateLogMessage(__("postform_login"),"error");LIGHTBOX.addLogMessage(I.message,"error");setTimeout(function(){LIGHTBOX.hideLogger();},3000);B("#login_error").html(__("postform_login_error"));B("#login_error").show();break;case"invalid_captcha":case"login_successful":LIGHTBOX.updateLogMessage(__("postform_logged_in"),"success");B("input[name=logged_in]").val(1);
A.updateGFVivaCookie(B.toJSON(J));A.login();A.loginRefresh("http://www."+A._gpc_domain+"/account_classifieds.php");break;}}}});break;}}},"json");}});B("#vs_account_modify").validate({rules:{email:{required:true,email:true},username:{required:true,minlength:3,maxlength:32},new_pass_account:{minlength:3},retype_pass_account:{minlength:3},civility:{required:function(){return("FR"==A._country_geo[1]);}}},submitHandler:function(D){LIGHTBOX.showLogger();LIGHTBOX.addLogMessage(__("account_info_validating"),"loading");
if(D.elements["new_pass_account"].value.length>0){if(D.elements["new_pass_account"].value!=D.elements["retype_pass_account"].value){LIGHTBOX.updateLogMessage(__("Passwords Do Not Match"),"error");setTimeout(function(){LIGHTBOX.hideLogger();},3000);return false;}}LIGHTBOX.updateLogMessage(__("account_info_validating"),"success");B.post("/ajax/account.php",{validate:1,email:D.elements["email"].value,username:D.elements["username"].value,new_pass_account:D.elements["new_pass_account"].value,retype_pass_account:D.elements["retype_pass_account"].value,civility:(D.elements["civility"]?D.elements["civility"].value:""),year:(D.elements["year"]?D.elements["year"].value:""),from_partners:D.elements["from_partners"].checked?"partners":""},function(E,F,G){console.log("Received account update response:",E,F);
E=E[0];if(E.code=="success"||E.code=="no_changes"){LIGHTBOX.addLogMessage(__("account_info_saved"),"success");B(D.elements["new_pass_account"]).val("").parent().parent().hide();B(D.elements["retype_pass_account"]).val("").parent().parent().hide();}else{LIGHTBOX.addLogMessage(__("account_info_not_saved"),"error");}setTimeout(function(){LIGHTBOX.hideLogger();},3000);},"json");return false;}});B(".vs-account-featured-button").click(function(){LIGHTBOX.open("featured_ad_explanation","/ajax/lightbox/featured_ad_explanation.php",{},{modal:true,width:675,resizable:false,title:__("featured_ad_explanation")});
});B("#login_forgot_password_link").click(function(){LIGHTBOX.open("forgot_password","/ajax/lightbox/forgot_password.php",{},{width:500,modal:true});});B("#login_create_account_link").click(function(){LIGHTBOX.open("register","/ajax/lightbox/register.php",{},{width:650,modal:true,title:__("lightbox_register"),open:function(D,E){B("#registerForm").validate({rules:{mail_posting:{required:true,email:true,minlength:6,maxlength:255,confirm:true},mail_posting_confirm:{required:true,email:true,minlength:6,maxlength:255},pass_posting:{required:true,minlength:3},pseudo_posting:{required:true,minlength:3},captcha:{required:true,minlength:5,maxlength:5}},errorPlacement:function(F,G){F.appendTo(G.parent().parent().find("th"));
},highlight:function(H,F,G){B(H).parent().parent("tr").addClass(F).removeClass(G);},unhighlight:function(H,F,G){B(H).parent().parent("tr").removeClass(F).addClass(G);},submitHandler:function(F){LIGHTBOX.showLogger();LIGHTBOX.addLogMessage(__("register_registering_msg"),"loading");A.authorize({action:"register",email:F.elements["mail_posting"].value,password:F.elements["pass_posting"].value,username:F.elements["pseudo_posting"].value,phone:"",vivastreet_optin:F.elements["vivastreet_optin"].checked?"yes":"no",partners_optin:F.elements["partners_optin"].checked?"yes":"no",captcha:F.elements["captcha"].value,country:A.country_geo["code"].toLowerCase(),checkDupe:true,onComplete:function(G){var H=G[0];
switch(H.code){case"blocked_user":case"disabled_user":case"invalid_email":case"duplicate_email":case"register_failed":case"invalid_captcha":if(H.code=="invalid_email"){LIGHTBOX.updateLogMessage(__("register_registering_msg"),"error");LIGHTBOX.addLogMessage(__("postform_register_mail_posting"),"error");A.resetCaptcha("register","#captcha_image_register","captcha");LIGHTBOX.hideLogger(3000);}else{if(H.code=="duplicate_email"){LIGHTBOX.updateLogMessage(__("register_registering_msg"),"error");LIGHTBOX.addLogMessage(__("postform_register_dupe_email"),"error");
A.resetCaptcha("register","#captcha_image_register","captcha");LIGHTBOX.hideLogger(3000);}else{LIGHTBOX.updateLogMessage(__("register_registering_msg"),"error");LIGHTBOX.addLogMessage(__("postform_register"),"error");A.resetCaptcha("register","#captcha_image_register","captcha");LIGHTBOX.hideLogger(3000);}}return false;case"register_successful":case"login_successful":LIGHTBOX.close("register");LIGHTBOX.updateLogMessage(__("register_registering_msg"),"success");LIGHTBOX.addLogMessage(__("postform_login"),"loading");
A.authorize({action:"login",email:F.elements["mail_posting"].value,password:F.elements["pass_posting"].value,onComplete:function(K){var I=K;var J="";for(i=0;i<I.length;i++){J=I[i];switch(J.code){case"blocked_user":case"disabled_user":case"invalid_email":case"incorrect_email_password":LIGHTBOX.updateLogMessage(__("postform_login"),"error");LIGHTBOX.addLogMessage(J.message,"error");setTimeout(function(){LIGHTBOX.hideLogger();},3000);break;case"invalid_captcha":case"login_successful":LIGHTBOX.updateLogMessage(__("postform_logged_in"),"success");
B("input[name=logged_in]").val(1);A.updateGFVivaCookie(B.toJSON(K));A.login();A.loginRefresh("http://www."+A._gpc_domain+"/account.php?account_notify=account_not_confirmed");break;}}}});return false;}}});return false;}});A.resetCaptcha("register","#captcha_image_register","captcha");}});});},reload_captcha:function(F,E,D,G){F.attr("src",A.captcha(E,D));if(G){G.val("");}},sendReply:function(D){LIGHTBOX.open("send_reply","/ajax/lightbox/account_send_reply.php",{mid:D},{modal:true,width:650,height:475,open:function(E,F){B("#vs_lb_send_reply_form").validate({errorClass:"error",rules:{posting_user_email:{required:A.isLogged,email:true},message:{required:true,minlength:15,maxlength:5000},captcha:{required:true,minlength:5,maxlength:5}},messages:{message:{minlength:__("vivamail_message_too_short"),maxlength:__("add_comment_message_long")}},highlight:function(H,G){var I=B(H).parent().parent();
if(I.is("tr")){I.addClass(G);}else{I.parent().addClass(G);}},unhighlight:function(H,G){var I=B(H).parent().parent();if(I.is("tr")){I.removeClass(G);}else{I.parent().removeClass(G);}},submitHandler:function(G){LIGHTBOX.showLogger();LIGHTBOX.addLogMessage(__("send_reply_validation"),"loading");G.submit();}});B("#captcha_image_vivamail").attr("src",A.captcha("vivamail","small"));}});},sendReplyResponse:function(D){console.log("Send reply response:",D);if(D.success==true){LIGHTBOX.updateLogMessage(__("send_reply_validation"),"success");
LIGHTBOX.addLogMessage(D.message,"success");}else{LIGHTBOX.updateLogMessage(__("send_reply_validation"),"error");LIGHTBOX.addLogMessage(D.message,"error");}LIGHTBOX.close("send_reply");setTimeout(function(){LIGHTBOX.hideLogger();},3000);},vivamailAction:function(D,E){B("#extra_action").val(E);D.submit();},forgotPasswordSend:function(D){LIGHTBOX.showLogger();LIGHTBOX.addLogMessage(__("forgot_password_sending"),"loading");B.get("/ajax/forgot_password.php",{process:1,forgot_password_email:D,domain:A._gpc_domain,type:A._gpc_page_type,rand:Math.random()},function(E,F,G){if(E.code=="failed"||E.code=="failed_temporary"){LIGHTBOX.updateLogMessage(__("forgot_password_error"),"error");
LIGHTBOX.addLogMessage(E.message,"error");LIGHTBOX.hideLogger(3000);}else{LIGHTBOX.close("forgot_password");LIGHTBOX.addLogMessage(__("forgot_password_success"),"success");LIGHTBOX.hideLogger(3000);}},"json");},toggleAutoRenew:function(H,G,D){var F=B(H);F.removeClass("saved");if(G=="featured"){if(H.checked==true){var I=1;}else{var I=2;}}else{if(G=="premium"){if(H.checked==true){var I=3;}else{var I=4;}}else{if(G=="repost"){if(H.checked==true){var I=5;}else{var I=6;}}else{if(G=="highlight"){if(H.checked==true){var I=7;
}else{var I=8;}}}}}var E=A._ajax_dir+"set_auto_renew.php?classified_id="+D+"&action="+I;LIGHTBOX.open("posting_auto_renew","/ajax/lightbox/posting_auto_renew.php",{request_url:E,checkbox_id:B(H).attr("id"),disclaimer:(B(H).is(":checked")?"disclaimer_auto_renewal":"disclaimer_auto_renewal_cancel")},{modal:true,width:500,close:function(J,K){if(false==F.hasClass("saved")){if(F.is(":checked")){F.removeAttr("checked");}else{F.attr("checked","checked");}}if(typeof (CONFIRM)!="undefined"){CONFIRM.checkSaveCard();
}}});},saveAutoRenew:function(D){B.get(D,function(E,F,G){LIGHTBOX.close("posting_auto_renew");});},sendConfirmation:function(D){if("undefined"==typeof (D)){D="";}B.get(A._ajax_dir+"/send_confirmation.php",{domain:A._gpc_domain,country:A._country_geo[1],refer:D},function(E){if(E.code=="success"){LIGHTBOX.addLogMessage(E.message,"success");LIGHTBOX.hideLogger(3000);}else{LIGHTBOX.addLogMessage(E.message,"error");LIGHTBOX.hideLogger(3000);}},"json");},resetPassword:function(){B(".vs-account-new-password input[type=password]").attr("disabled",false);
B(".vs-account-new-password").show();B("#vs-accont-reset-password").remove();return false;}};return C;})($J,VIVASTREET);var DATAGRID={initButtonCheck:function(){$J(".vs-table-checkbox").click(function(){DATAGRID.checkButtonStatus();});DATAGRID.checkButtonStatus();},checkButtonStatus:function(){var F=$J("input.vs-table-checkbox");var I=true;var D=true;var H=false;var A=true;var C=0;for(var E=0;E<F.length;E++){var G=F[E];var B=$J(F[E]);if(G.checked==true){H=true;if(window.query["tab"]&&window.query["tab"]=="disabled"){if(!B.parent().parent().hasClass("vs-classified-row-can-republish")){D=false;
}}else{if(!B.parent().parent().hasClass("vs-classified-row-can-repost")){I=false;}}if(!B.parent().parent().hasClass("vs-classified-row-can-deactivate")){A=false;}C++;}}if(C==0){I=false;D=false;A=false;}if(H==false){DATAGRID.setDisabled(".vs-delete-button");}else{DATAGRID.setEnabled(".vs-delete-button");}if(A==false){DATAGRID.setDisabled(".vs-deactivate-button");}else{DATAGRID.setEnabled(".vs-deactivate-button");}if(I==false){DATAGRID.setDisabled(".vs-repost-button");}else{DATAGRID.setEnabled(".vs-repost-button");
}if(D==false){DATAGRID.setDisabled(".vs-republish-button");}else{DATAGRID.setEnabled(".vs-republish-button");}return true;},setDisabled:function(A){A=$J(A);A.attr("disabled","disabled");A.addClass("vs-input-button-disabled");A.button("disable");},setEnabled:function(A){A=$J(A);A.attr("disabled","");A.removeClass("vs-input-button-disabled");A.button("enable");},checkAll:function(B){var C=$J(".vs-table-checkbox");for(var A=0;A<C.length;A++){C[A].checked=B;}return true;}};