//VALIDATES
function sc_validateEmail(value) {
var regExp = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-]{2,4}$/;
return (regExp.test(value));
}
function sc_validateNombre(value) {
return (isNaN(value));
}
function sc_validateApellido(value) {
return (isNaN(value));
}
function sc_validateCodigoPostal(value) {
if (sc_valuePaisGeo == 'ESP') {
regExp =/^(0[1-9]|1[0-9]|2[0-9]|3[0-9]|4[0-9]|5[0-2])(\d{3})\b/
return (regExp.test(value));
}
else {
return true;
}
}
function sc_validateFechaNacimiento(value) {
var oDate = new Date();
var actualYear = oDate.getFullYear();
return (value >= 1900 && value <= actualYear);
}
function sc_validateSexo(value) {
return (value == 0 || value == 1);
}
function sc_isValidateAll() {
if (typeof(sc_errorOtherValidations)=="undefined") {
sc_errorOtherValidations = false;
}
if (sc_errorOtherValidations) {
return false;
}
sc_resultValidate = true;
//Email
sc_hasToValidate = (sc_hasToValidateEmail == 'true');
if (sc_resultValidate && sc_hasToValidate) {
sc_resultValidate = sc_resultValidate && sc_validateEmail(sc_valueEmail);
if (!sc_resultValidate) {
alert('Ingrese un Email V\341lido');
document.getElementById(sc_domIdEmail).focus();
}
}
//Nombre
sc_hasToValidate = (sc_hasToValidateNombre == 'true');
if (sc_resultValidate && sc_hasToValidate) {
sc_resultValidate = sc_resultValidate && sc_validateNombre(sc_valueNombre);
if (!sc_resultValidate) {
alert('Ingrese un Nombre');
document.getElementById(sc_domIdNombre).focus();
}
}
//Apellido
sc_hasToValidate = (sc_hasToValidateApellido == 'true');
if (sc_resultValidate && sc_hasToValidate) {
sc_resultValidate = sc_resultValidate && sc_validateApellido(sc_valueApellido);
if (!sc_resultValidate) {
alert('Ingrese un Apellido');
document.getElementById(sc_domIdApellido).focus();
}
}
//CodigoPostal
sc_hasToValidate = (sc_hasToValidateCodigoPostal == 'true');
if (sc_resultValidate && sc_hasToValidate) {
sc_resultValidate = sc_resultValidate && sc_validateCodigoPostal(sc_valueCodigoPostal);
if (!sc_resultValidate) {
alert('Ingrese un C\363digo Postal de Espa\361a V\341lido');
document.getElementById(sc_domIdCodigoPostal).focus();
}
}
//FechaNacimiento
sc_hasToValidate = (sc_hasToValidateFechaNacimiento == 'true');
if (sc_resultValidate && sc_hasToValidate) {
sc_resultValidate = sc_resultValidate && sc_validateFechaNacimiento(sc_valueFechaNacimiento);
if (!sc_resultValidate) {
alert('Seleccione una Fecha de Nacimiento');
document.getElementById(sc_domIdFechaNacimiento).focus();
}
}
//Sexo
sc_hasToValidate = (sc_hasToValidateSexo == 'true');
if (sc_resultValidate && sc_hasToValidate) {
sc_resultValidate = sc_resultValidate && sc_validateSexo(sc_valueSexo);
if (!sc_resultValidate) {
alert('Seleccione su Sexo');
document.getElementById(sc_domIdSexo).focus();
}
}
if (sc_contarPais && sc_coregistroActive && sc_resultValidate) {
switch (sc_valuePaisGeo) {
case '' :
sc_contadores(sc_valueIdAfiliado, sc_valueIdWeb, ''); break;
case 'ESP' :
sc_contadores(sc_valueIdAfiliado, sc_valueIdWeb, 'ESP'); break;
default :
sc_contadores(sc_valueIdAfiliado, sc_valueIdWeb, 'no_espaniol'); break;
}
sc_contarPais = false;
}
if (sc_coregistroActive && sc_resultValidate) {
//sc_valuePaisGeo = 'ESP';
if(sc_valuePaisGeo == 'ESP') {
if(!sc_crDivDisplayed) {
if (sc_valueIdAfiliado != "16") {
alert('A continuaci\363n le mostraremos unas promociones que pueden ser de su inter\351s.\nElija SI o NO, seg\372n su inter\351s y finalice su registro.');
}
sc_crDivDisplayed = 1;
sc_code_html = "";
for(var pos in sc_load_cr) {
//alert(sc_load_cr[pos]['condicion']);
//if (sc_load_cr[pos]['condicion'] == '') {
if (false) {
sc_code_html += sc_load_cr[pos]['html'];
}
else {
sc_condition_show = true;
eval(sc_load_cr[pos]['condicion']); //sc_condition_show;
if (sc_condition_show) {
sc_code_html += sc_load_cr[pos]['html'];
}
}
}
sc_powered = '
 |
';
sc_form_coregistros = '' + sc_code_html + sc_powered + '
';
document.getElementById('previewLayer').innerHTML = '';
document.getElementById('previewLayer').style.display = "block";
sc_contadores(sc_valueIdAfiliado, sc_valueIdWeb, 'lead');
if(typeof window.sc_beforeSubmit == 'function') {
sc_beforeSubmit();
}
return false;
}
else {
crsubmit = 1;
return true;
}
}
}
return sc_resultValidate;
}
function sc_parseVariables () {
tmp = scFieldEmail.split(',');
sc_domIdEmail = tmp[0]; sc_hasToValidateEmail = tmp[1];
tmp = scFieldNombre.split(',');
sc_domIdNombre = tmp[0]; sc_hasToValidateNombre = tmp[1];
tmp = scFieldApellido.split(',');
sc_domIdApellido = tmp[0]; sc_hasToValidateApellido = tmp[1];
tmp = scFieldCodigoPostal.split(',');
sc_domIdCodigoPostal = tmp[0]; sc_hasToValidateCodigoPostal = tmp[1];
tmp = scFieldFechaNacimiento.split(',');
sc_domIdFechaNacimiento = tmp[0]; sc_hasToValidateFechaNacimiento = tmp[1];
tmp = scFieldSexo.split(',');
sc_domIdSexo = tmp[0]; sc_hasToValidateSexo = tmp[1];
}
function sc_getData () {
params = 'id_afiliado=' + sc_valueIdAfiliado
+ '&id_web=' + sc_valueIdWeb
+ '&email=' + sc_valueEmail
+ '&nombre=' + sc_valueNombre
+ '&apellido=' + sc_valueApellido
+ '&codigo_postal=' + sc_valueCodigoPostal
+ '&fecha_nacimiento=' + sc_valueFechaNacimiento
+ '&sexo=' + sc_valueSexo
return params;
}
function SetSubmitFunction(sc_pForm, sc_pSubmitButton) {
if (sc_pForm && sc_pSubmitButton) {
if(typeof sc_pForm.submit.name == "undefined"){
sc_pForm.submit=function(){
return(true);
};
}
sc_pForm.onsubmit=function(){
validFields = sc_isValidateAll()
if (validFields) {
/* Chequeamos si tenemos que realizar los submits por los coregistros */
if(sc_coregistroActive) {
for(var pos in sc_extras) {
var oRadioSI = document.getElementById("radio_sc_list_" + sc_extras[pos]['id'] + "_1");
var oRadioNO = document.getElementById("radio_sc_list_" + sc_extras[pos]['id'] + "_2");
if (oRadioSI != null && oRadioSI != undefined && oRadioNO != null && oRadioNO != undefined) {
if(oRadioSI.checked) {
//##################################### CUSTOM MATCH-VAR COREGISTROS #######################################
//Sorteomania
if (typeof(sc_shootPixel)=="undefined") {
sc_shootPixel = false;
}
if (sc_extras[pos]['id'] == "10" && !sc_shootPixel) {
str = "http://smx.sorteomania.com/coreg/pixelemailing.php?origen=CI&premio=no&sorteomania=1&anunciante=SM&email=" + sc_valueEmail + "&edad=" + sc_valueFechaNacimiento + "&user_ip=" + sc_valueIp + "&ip=" + sc_valueIp;
var myImg = new Image();
myImg.src = str;
pausecomp(2000);
sc_shootPixel = true;
}
//Photobox
if (sc_extras[pos]['id'] == "14") {
sc_valuePass = document.getElementById("sc_password").value;
if (sc_valuePass == "") {
alert('Ingrese un Password para la campa\361a PhotoBox');
document.getElementById("sc_password").focus();
return false;
}
if (sc_valueFechaNacimiento <= 1991) {
sc_crVariables += '&password=' + sc_valuePass;
}
}
//Clubconcursos y Bonoweb
if ((sc_extras[pos]['id'] == "16") || (sc_extras[pos]['id'] == "17")) {
sc_valueTelefono = document.getElementById("sc_telefono").value;
sc_valueTelefonoMovil = document.getElementById("sc_telefono_movil").value;
// Validación número de teléfono fijo
telefono_fijo = !empty(sc_valueTelefono) && !isNaN(sc_valueTelefono);
if (!telefono_fijo) {
alert('Ingrese un n\372mero de tel\351fono fijo v\341lido.');
document.getElementById("sc_telefono").focus();
return false;
}else{
primer_numero = sc_valueTelefono.substr(0,1);
if ((sc_valueTelefono.length != 9) || (primer_numero != 9)){
alert('Un n\372mero de tel\351fono fijo v\341lido debe tener 9 d\355gitos y comenzar con el n\372mero 9.');
document.getElementById("sc_telefono").focus();
return false;
}
}
// Validación número de teléfono móvil
telefono_movil = !empty(sc_valueTelefonoMovil) && !isNaN(sc_valueTelefonoMovil);
if (!telefono_movil) {
alert('Ingrese un n\372mero de tel\351fono m\363vil v\341lido.');
document.getElementById("sc_telefono_movil").focus();
return false;
}else{
primer_numero = sc_valueTelefonoMovil.substr(0,1);
if ((sc_valueTelefonoMovil.length != 9) || (primer_numero != 6)){
alert('Un n\372mero de tel\351fono m\363vil v\341lido debe tener 9 d\355gitos y comenzar con el n\372mero 6.');
document.getElementById("sc_telefono_movil").focus();
return false;
}
}
sc_crVariables += '&telefono=' + sc_valueTelefono + '&telefono_movil=' + sc_valueTelefonoMovil;
}
//Clubconcursos
if (sc_extras[pos]['id'] == "16") {
sc_valueDireccion = document.getElementById("sc_direccion").value;
if (sc_valueDireccion == "") {
alert('Ingrese su Direcci\363n para la campa\361a Clubconcursos');
document.getElementById("sc_direccion").focus();
return false;
}
sc_crVariables += '&direccion=' + sc_valueDireccion;
}
//Jobs&Travel
if (sc_extras[pos]['id'] == "20") {
sc_valuePass = document.getElementById("sc_password_id_20").value;
if (sc_valuePass == "") {
alert('Ingrese un Password para la campa\361a Jobs&Travel');
document.getElementById("sc_password_id_20").focus();
return false;
}
if (sc_valueFechaNacimiento <= 1991) {
sc_crVariables += '&password_id_20=' + sc_valuePass;
}
}
//BlackBerry
if ((sc_extras[pos]['id'] == "32") || (sc_extras[pos]['id'] == "39")) {
blackBerrySI = document.getElementById("sc_valueBlackberry_y");
blackBerryNO = document.getElementById("sc_valueBlackberry_n");
if (!blackBerrySI.checked && !blackBerryNO.checked) {
alert('Seleccione si posee o no un BlackBerry Inteligente.');
return false;
}
sc_valueBlackberry = (blackBerrySI.checked)? blackBerrySI.value : blackBerryNO.value;
sc_crVariables += '&valueBlackberry=' + sc_valueBlackberry;
}
//MundialChess
if (sc_extras[pos]['id'] == "36") {
sc_username_mundialchess = document.getElementById("sc_username_mundialchess").value;
if (sc_username_mundialchess == "") {
alert('Ingrese un Nombre de Usuario para la campa\361a MundialChess');
document.getElementById("sc_username_mundialchess").focus();
return false;
}
sc_crVariables += '&username_mundialchess=' + sc_username_mundialchess;
}
//#################################### END CUSTOM MATCH-VAR COREGISTROS ####################################
sc_crVariables += '&CR[' + sc_extras[pos]['id'] + ']=' + sc_extras[pos]['id'];
}
if(oRadioNO.checked) {
sc_crVariables += '&CR[' + sc_extras[pos]['id'] + ']=0';
}
if(!oRadioSI.checked && !oRadioNO.checked) {
alert('- Debe seleccionar si desea o no, recibir nuestras ofertas.');
oRadioSI.focus();
return false;
}
}
}
sc_pSubmitButton.value="Enviando...";
sc_pSubmitButton.disabled = true;
sendData = sc_getData();
var myImg = new Image();
//return false;
myImg.src = sc_js_decode('aHR0cDovL3NvbG9jb3JlZ2lzdHJvcy5jb20vaW50ZWdyYXRpb24vZ2V0LnBocD8=') + sendData + sc_crVariables;
pausecomp(2000);
if(sc_pForm) {
sc_pForm.target = '';
myImg.onload = function() {
sc_pForm.submit();
};
pausecomp(1000);
if(typeof window.sc_afterSubmit == 'function') {
sc_afterSubmit();
}
}
else {
sc_pForm.target = '';
sc_pForm.submit();
}
}
}
return(validFields);
}
//HandleSubmitsOnclick(Form);
}
}
function pausecomp(millis){
date = new Date();
var curDate = null;
do { var curDate = new Date();
}while(curDate-date < millis);
}
function sc_main() {
sc_parseVariables();
form = document.getElementById(document.sc_form_configuracion.sc_formClient.value);
button = document.getElementById(document.sc_form_configuracion.sc_buttonSubmitClient.value);
sc_crDivDisplayed = 0;
SetSubmitFunction(form, button);
}
sc_main();