JsZetaUser={};I18n.es.user_welcome="Bienvenido ";I18n.es.user_view_data="Ver datos";I18n.es.user_close_session="Cerrar sesión";I18n.ca.user_welcome="Benvingut ";I18n.ca.user_view_data="Veure dades";I18n.ca.user_close_session="Tancar sessió";JsZetaUser.SULastURL=function(){this.actual_pathname=document.location.pathname;};JsZetaUser.SULastURL.prototype.startsWith=function(s){return this.actual_pathname.indexOf(s)==0;};JsZetaUser.SULastURL.prototype.getLastURL=function(){return this.actual_pathname;};JsZetaUser.SULastURL.SUSetLastURL=function(locale){var lastURL=new JsZetaUser.SULastURL();var load_pf_login=function(){document.location.href=JsZetaUtils.SuPath+"registro/registro_login.jsp?lang="+locale+"&ts="+JsZetaUtils.timestamp();};if(!lastURL.startsWith(JsZetaUtils.SuPath)){$.get(JsZetaUtils.SuPath+"setLastUrl.jsp",{beforeLoginPathName:lastURL.getLastURL()},load_pf_login);}else{load_pf_login();}};JsZetaUser.Profile={New:function(locale){document.location.href=JsZetaUtils.SuPath+"commands/addUserPart0?lang="+locale;},Edit:function(locale){document.location.href=JsZetaUtils.SuPath+"commands/modifyUserPart0?lang="+locale;},Login:function(locale){JsZetaUser.SULastURL.SUSetLastURL(locale);},RecPwd:function(locale){document.location.href=JsZetaUtils.SuPath+"registro/registro_rec_pwd.jsp?lang="+locale;},UserDown:function(locale){document.location.href=JsZetaUtils.SuPath+"registro/registro_baja.jsp?lang="+locale;},UserRecUser:function(locale){document.location.href=JsZetaUtils.SuPath+"registro/registro_rec_user.jsp?lang="+locale;},UserRecUserOpc:function(locale){if($("input:radio[name=RECUSEROPTIONID]:checked").val()=="recuser_si"){document.location.href=JsZetaUtils.SuPath+"registro/registro_rec_user_confirm.jsp?lang="+locale;}else{JsZetaUser.Profile.New(locale);}},GetUser:function(locale){if(!JsZetaUtils.Cookies.areEnabled()){JsZetaUser.Profile.getUserSU(locale);}else{var userEncCookie=JsZetaUtils.getCookie("userInfo");if(userEncCookie.length>2){if(userEncCookie.charAt(0)=='"'){userEncCookie=userEncCookie.substring(1,userEncCookie.length-1);}dojo.require("dojox.encoding.crypto.Blowfish");var userCookie=dojox.encoding.crypto.Blowfish.decrypt(userEncCookie,"abcdefg");var userCookieObj=eval("["+userCookie+"]");var userLogged=$("<span>");userLogged.attr("id","user");userLogged.text(I18n[locale].user_welcome+userCookieObj[0].name);$("#registro").prepend(userLogged);$("#register").attr("href","javascript:JsZetaUser.Profile.Login('"+locale+"')");$("#register > span").text(I18n[locale].user_view_data);$("#login").attr("href","javascript:JsZetaUser.Profile.Logout()");$("#login > span").text(I18n[locale].user_close_session);}}},getUserSU:function(locale){$.ajax({type:"GET",url:JsZetaUtils.urlNoCache(JsZetaUtils.SuPath+"services/getUser"),dataType:"xml",success:function(xml){$(xml).find("nombre").each(function(){var userLogged=$("<span>");userLogged.attr("id","user");userLogged.text(I18n[locale].user_welcome+$(this).text());$("#registro").prepend(userLogged);});$("#register").attr("href","javascript:JsZetaUser.Profile.Login('"+locale+"')");$("#register > span").text(I18n[locale].user_view_data);$("#login").attr("href","javascript:JsZetaUser.Profile.Logout()");$("#login > span").text(I18n[locale].user_close_session);}});},Logout:function(){$.ajax({type:"GET",url:JsZetaUtils.urlNoCache(JsZetaUtils.SuPath+"services/logout"),success:function(){var actual_pathname=document.location.pathname;var index_su=actual_pathname.indexOf(JsZetaUtils.SuPath);if(index_su==0){var lang=JsZetaUtils.getParameterUrl("lang");lang=lang!=0?lang:"es";document.location.href=document.location.href.substring(0,document.location.href.length-(actual_pathname.length+document.location.search.length-1))+lang+"/";}else{window.location.reload();}}});}};I18n.es.register_form_nick_oblig="El campo Usuario es obligatorio";I18n.es.register_form_name_oblig="El campo Nombre es obligatorio";I18n.es.register_form_surname_oblig="El campo Apellidos es obligatorio";I18n.es.register_form_secansw_oblig="El campo Respuesta es obligatorio";I18n.es.register_form_mail_no_valido="e-Mail no válido";I18n.es.register_form_password_length="La contraseña debe tener un mínimo de 6 caracteres y un máximo de 20";I18n.es.register_form_nick_length="El campo Usuario debe tener un mínimo de 4 caracteres y un máximo de 50";I18n.es.register_form_password_match="La contraseña no coincide";I18n.es.register_form_captcha_oblig="Debe introducir el código de seguridad";I18n.es.register_form_captcha_number="El código de seguridad debe ser numérico";I18n.es.register_form_captcha_length="El código de seguridad debe tener 7 caracteres";I18n.es.register_form_accept_cond="Debes aceptar las condiciones";I18n.es.register_form_avatar_cond="El formato de la imagen debe ser jpg, gif o png";I18n.ca.register_form_nick_oblig="El camp Usuari és obligatori";I18n.ca.register_form_name_oblig="El camp Nom és obligatori";I18n.ca.register_form_surname_oblig="El camp Cognoms és obligatori";I18n.ca.register_form_secansw_oblig="El camp Resposta és obligatori";I18n.ca.register_form_mail_no_valido="e-mail no vàlid";I18n.ca.register_form_password_length="La contrasenya ha de tenir un mínim de 6 caràcters i un màxim de 20";I18n.ca.register_form_nick_length="El camp Usuari ha de tenir un mínim de 4 caràcters i un màxim de 50";I18n.ca.register_form_password_match="La contrasenya no coincideix";I18n.ca.register_form_captcha_oblig="Cal introduir el codi de seguretat";I18n.ca.register_form_captcha_number="El codi de seguretat ha de ser numèric";I18n.ca.register_form_captcha_length="El codi de seguretat ha de tenir 7 caràcters";I18n.ca.register_form_accept_cond="Heu d'acceptar les condicions";I18n.ca.register_form_avatar_cond="El format de la imatge ha de ser jpg, gif o png";JsZetaUser.validators={validaCmpOblig:function(cmp){if(cmp.length<1){return false;}return true;},validaCmpNumber:function(cmp){if(!/^([0-9])*$/.test(cmp)){return false;}return true;},validaNick:function(nick,locale){if(!JsZetaUser.validators.validaCmpOblig(nick)){JsZetaUtils.Errors.showError(I18n[locale].register_form_nick_oblig);return false;}if(!(nick.length>=4&&nick.length<=50)){JsZetaUtils.Errors.showError(I18n[locale].register_form_nick_length);return false;}return true;},validaName:function(name,locale){if(!JsZetaUser.validators.validaCmpOblig(name)){JsZetaUtils.Errors.showError(I18n[locale].register_form_name_oblig);return false;}return true;},validaSurname:function(surname,locale){if(!JsZetaUser.validators.validaCmpOblig(surname)){JsZetaUtils.Errors.showError(I18n[locale].register_form_surname_oblig);return false;}return true;},validaMail:function(mail,locale){if(mail.lastIndexOf(".")<=2||mail.indexOf("@")<=0){JsZetaUtils.Errors.showError(I18n[locale].register_form_mail_no_valido);return false;}return true;},validaPwd:function(locale,pwd,pwd2){if(!(pwd.length>=6&&pwd.length<=20)){JsZetaUtils.Errors.showError(I18n[locale].register_form_password_length);return false;}if(arguments.length>2){if(pwd!=pwd2){JsZetaUtils.Errors.showError(I18n[locale].register_form_password_match);return false;}}return true;},validaCaptcha:function(code,locale){if(!JsZetaUser.validators.validaCmpOblig(code)){JsZetaUtils.Errors.showError(I18n[locale].register_form_captcha_oblig);return false;}if(!JsZetaUser.validators.validaCmpNumber(code)){JsZetaUtils.Errors.showError(I18n[locale].register_form_captcha_number);return false;}if(code.length!=7){JsZetaUtils.Errors.showError(I18n[locale].register_form_captcha_length);return false;}return true;},validaCond:function(cond,locale){if(!cond){JsZetaUtils.Errors.showError(I18n[locale].register_form_accept_cond);return false;}return true;},validaAvatar:function(avatar,locale){if(avatar!=""){var ext=avatar.substring(avatar.length-3).toLowerCase();if(ext!="jpg"&&ext!="gif"&&ext!="png"){JsZetaUtils.Errors.showError(I18n[locale].register_form_avatar_cond);return false;}}return true;},validaSecAnsw:function(secansw,locale){if(!JsZetaUser.validators.validaCmpOblig(secansw)){JsZetaUtils.Errors.showError(I18n[locale].register_form_secansw_oblig);return false;}return true;},registerForm1:function(locale,form){var vO=JsZetaUser.validators;var valid=vO.validaNick($("#NICK").val(),locale)&&vO.validaMail($("#EMAIL").val(),locale)&&vO.validaName($("#NOMBRE").val(),locale)&&vO.validaSurname($("#APELLIDOS").val(),locale)&&vO.validaPwd(locale,$("#PWD").val(),$("#PWD2").val())&&vO.validaAvatar($("#AVATAR").val(),locale)&&vO.validaSecAnsw($("#SECURITYANSWER").val(),locale);if(valid){$.ajax({type:"GET",url:JsZetaUtils.urlNoCache(JsZetaUtils.SuPath+"services/getPortalUser"),data:{MAIL:$("#EMAIL").val()},success:function(xml){$(xml).find("boolean").each(function(){var isUserOnlySP=false;isUserOnlySP=$(this).text()=="true";if(isUserOnlySP){JsZetaUser.Profile.UserRecUser(locale);}else{form.submit();}});},error:function(xml){form.submit();}});}},registerForm2:function(locale,form){var vO=JsZetaUser.validators;var valid=vO.validaCaptcha($("#CAPTCHA_RESPONSE").val(),locale)&&vO.validaCond($("#CONDLEG").is(":checked"),locale);if(valid){$.ajax({type:"GET",url:JsZetaUtils.urlNoCache(JsZetaUtils.SuPath+"services/validateCaptcha"),data:{CAPTCHA_RESPONSE:$("#CAPTCHA_RESPONSE").val()},success:function(){form.submit();},error:function(xml){$(xml.responseXML).find("message").each(function(){JsZetaUtils.Messages.showMsg($(this).text());});}});}},registerFormMod:function(locale,form){var vO=JsZetaUser.validators;var valid=vO.validaNick($("#NICK").val(),locale)&&vO.validaMail($("#EMAIL").val(),locale)&&vO.validaName($("#NOMBRE").val(),locale)&&vO.validaSurname($("#APELLIDOS").val(),locale)&&vO.validaPwd(locale,$("#PWD").val(),$("#PWD2").val())&&vO.validaAvatar($("#AVATAR").val(),locale)&&vO.validaSecAnsw($("#SECURITYANSWER").val(),locale);if(valid){form.submit();}},loginForm:function(locale,form){var vO=JsZetaUser.validators;var valid=vO.validaMail($("#LOGIN").val(),locale)&&vO.validaPwd(locale,$("#PWD").val());if(valid){$.ajax({type:"GET",url:JsZetaUtils.urlNoCache(JsZetaUtils.SuPath+"services/getPortalUser"),data:{MAIL:$("#LOGIN").val()},success:function(xml){$(xml).find("boolean").each(function(){var isUserOnlySP=false;isUserOnlySP=$(this).text()=="true";if(isUserOnlySP){JsZetaUser.Profile.UserRecUser(locale);}else{form.submit();}});},error:function(xml){form.submit();}});}},recUserForm:function(locale,form){var vO=JsZetaUser.validators;var valid=vO.validaMail($("#LOGIN").val(),locale)&&vO.validaPwd(locale,$("#PWD").val());if(valid){form.submit();}},recPwdForm:function(locale,form){var vO=JsZetaUser.validators;var valid=vO.validaMail($("#LOGIN").val(),locale);if(valid){form.submit();}}};JsZetaUser.SpainSwitcher={switcher:function(){var countryBox=document.getElementById("reg_11");var country=countryBox.options[countryBox.selectedIndex].value;if(country=="PAIS_67"){document.getElementById("hideShowCountry").style.display="block";}else{document.getElementById("hideShowCountry").style.display="none";}}};
