var uHash = "";
function login() {
var params="idPartner=ALMEIDA";
params += "&lang=en";
params += "&email=" + $i("#login-email").val();
params += "&password=" + $i("#login-password").val();
params += "&rand=" + Math.random();
$i.ajax({
type: 'POST',
url: "../../nUser/jsp/E_LogIn.jsp",
data: encodeURI(params),
dataType: "xml",
async: false,
success: function(response) {
$i('.pclient.popup').slideToggle('fast');
if (response != null) {
var idError = recuperarElementoXML(response, "RQ_com_desktop_logIn_status");
switch (idError) {
case "USER_DONT_EXIST":
var title = "Check login details";
var txt = "The email and password combination you have introduced is not valid.";
$i('#login-password').val("");
showGenericPopup(title,txt);
break;
default:
createLoginHash();
var params2="idPartner=ALMEIDA";
params2 += "&lang=en";
params2 += "&domain=";
params2 += "&h="+uHash;
$i('.header-loginsignin').load("../../nPortlets/jsp/E_Top_LoggedUser.jsp?"+params2, function() {
menu.init();
});
break;
}
} else {
showGenericPopup("Oooooops! ","There has been an error, please try again later");
}
},
error: function (xhr, textStatus, thrownError){
alert("Error");
return;
}
});
}
function createLoginHash() {
var params="idPartner=ALMEIDA";
params += "&lang=en";
params += "&email=" + $i("#login-email").val();
params += "&rand=" + Math.random();
$i.ajax({
type: 'POST',
url: "../../nUser/jsp/E_CreateLoginHash.jsp",
data: encodeURI(params),
dataType: "xml",
async: false,
success: function(response) {
if (response != null) {
var r = recuperarElementoXML(response, "RQ_com_desktop_widget_user_hash");
if (r!="") {
widgetCreateCookie("idiso-be-user-hash",r,1/24/2);
uHash = r;
return r;
} else {
return "";
}
}
},
error: function (xhr, textStatus, thrownError){
alert("Error");
return "";
}
});
}
function signin() {
hideLoginErrorText("signin");
if ($i("#signin-acceptConditions").is(':checked')) {
if (signInFormOK()) {
var params = "idPartner=ALMEIDA";
params += "&lang=en";
params += "&email=" + $i("#signin-email").val();
params += "&name=" + $i("#signin-name").val();
params += "&lastname1=" + $i("#signin-lastname1").val();
params += "&p=" + $i("#signin-password").val();
params += "&rand=" + Math.random();
$i.ajax({
type: 'POST',
url: "../../nUser/jsp/E_SignIn.jsp",
data: encodeURI(params),
dataType: "xml",
async: false,
success: function(response){
$i('.pclient.popup').slideToggle('fast');
if (response != null) {
var idError = recuperarElementoXML(response, "RQ_com_desktop_signIn_status");
var title = "";
var txt = "";
switch (idError) {
case "USER_EXISTS":
title = "Account active";
txt = "You already have an account with {1}. Enter your password in the login field.".replace("{1}",$i('#signin-email').val());
break;
case "USER_EXISTS_PENDING":
title = "Email not active";
txt = "This email {1} already exists. To benefit from all the features, please verify the email address in your email account.".replace("{1}",$i('#signin-email').val());
txt += "
If you have not received the email please click Here.";
break;
case "EMPTY_FIELDS":
title = "Check the fields";
txt = "Fill in all essential fields";
break;
case "PASSWORD_TOOEASY":
title = "Invalid password";
txt = "The password must contain a minimum of 6 characters and must be at least one letter and one number.";
break;
case "EMAIL_INCORRECT":
title = "Incorrect e-mail";
txt = "The email entered is not valid.";
break;
case "ERROR":
title = "Oooooops! ";
txt = "There has been an error, please try again later";
break;
default: // OK
title = "REGISTER- SEND EMAIL";
txt = "Email sent to {1}! You will receive an email to validate your account shortly. If you do not receive the email please check your junk folder.".replace("{1}",$i('#signin-email').val());
singnInFormClear();
break;
}
showGenericPopup(title,txt);
} else {
showGenericPopup("Oooooops! ","There has been an error, please try again later");
}
},
error: function (xhr, textStatus, thrownError){
showGenericPopup("Oooooops! ","There has been an error, please try again later");
return;
}
});
}
} else {
showLoginErrorText("signin","You must accept the conditions");
}
}
function socialSignIn(params) {
$i.ajax({
type: 'POST',
url: "../../nUser/jsp/E_SocialLogin.jsp",
data: encodeURI(params),
dataType: "xml",
async: false,
success: function(response){
$i('.pclient.popup').slideToggle('fast');
if (response != null) {
var idError = recuperarElementoXML(response, "RQ_com_desktop_socialLogIn_status");
var title = "";
var txt = "";
switch (idError) {
case "USER_EXISTS":
title = "Account active";
txt = "You already have an account with {1}. Enter your password in the login field.".replace("{1}",$i('#signin-email').val());
break;
case "USER_EXISTS_PENDING":
title = "Email not active";
txt = "This email {1} already exists. To benefit from all the features, please verify the email address in your email account.".replace("{1}",$i('#signin-email').val());
break;
case "EMPTY_FIELDS":
title = "Check the fields";
txt = "Fill in all essential fields";
break;
case "ERROR":
title = "Oooooops! ";
txt = "There has been an error, please try again later";
break;
default: // OK
title = "REGISTER- SEND EMAIL";
txt = "Email sent to {1}! You will receive an email to validate your account shortly. If you do not receive the email please check your junk folder.".replace("{1}",$i('#signin-email').val());
break;
}
showGenericPopup(title,txt);
} else {
showGenericPopup("Oooooops! ","There has been an error, please try again later");
}
},
error: function (xhr, textStatus, thrownError){
alert("Error");
return;
}
});
}
function forgotPassword() {
var params = "idPartner=ALMEIDA";
params += "&lang=en";
params += "&email=" + $i('#forgotPassword-email').val();
params += "&rand=" + Math.random();
$i.ajax({
type: 'POST',
url: "../../nUser/jsp/E_ForgotPassword.jsp",
data: encodeURI(params),
dataType: "text",
async: false,
success: function(response) {
var title = "Password sent";
var txt = "A new password has been sent to {1}".replace("{1}",$i('#forgotPassword-email').val());
showGenericPopup(title, txt);
showSignInForm();
$i('#login-password').val();
},
error: function (xhr, textStatus, thrownError){
showGenericPopup("Oooooops! ","There has been an error, please try again later");
return;
}
});
}
function logout(h) {
var params = "idPartner=ALMEIDA";
params += "&lang=en";
if (h) params += "&h="+h;
params += "&rand=" + Math.random();
idisoWidget_logout();
$i.ajax({
type: 'POST',
url: "../../nUser/jsp/E_LogOut.jsp",
data: encodeURI(params),
dataType: "text",
async: false,
success: function(response) {
section = $i('body').attr("id");
var params2="idPartner=ALMEIDA";
params2 += "&lang=en";
$i('.header-loginsignin').load("../../nPortlets/jsp/E_Top_LoggedUser.jsp?"+params2);
},
error: function (xhr, textStatus, thrownError){
alert("Error");
return;
}
});
}
function idisoWidget_logout() {
widgetDeleteCookie("idiso-be-user-hash");
}
function sendValidationEmail() {
var params = "idPartner=ALMEIDA";
params += "&lang=en";
params += "&email=" + $i('#signin-email').val();
params += "&name=" + $i('#signin-name').val();
params += "&rand=" + Math.random();
$i.ajax({
type: 'POST',
url: "../../nUser/jsp/E_SendValidationEmail.jsp",
data: encodeURI(params),
dataType: "text",
async: false,
success: function(response) {
var title = "REGISTER- SEND EMAIL";
var txt = "Email sent to {1}! You will receive an email to validate your account shortly. If you do not receive the email please check your junk folder.".replace("{1}",$i('#signin-email').val());
showGenericPopup(title,txt);
},
error: function (xhr, textStatus, thrownError){
alert("Error");
return;
}
});
}
function showLoginErrorText(section,txt) {
$i('#'+section+'-errorform .text').html(txt);
$i('#'+section+'-errorform').slideDown();
}
function hideLoginErrorText(section) {
$i('#'+section+'-errorform').slideUp(1);
$i('#'+section+'-errorform .text').html("");
$i('.error').removeClass("error");
}
function showSignInForm() {
$i('.pclient').find('.content3').hide();
$i('.pclient').find('.content1').show();
$i('#login-password').val("");
}
function showForgotPasswordForm() {
$i('.pclient').find('.content3').show();
$i('.pclient').find('.content1').hide();
if ($i('#login-email').val()!="") $i('#forgotPassword-email').val($i('#login-email').val());
}
function signInFormOK() {
var ok=true;
var fields = new Array("signin-name", "signin-lastname1", "signin-email", "signin-password");
for (var i=0; i