﻿// JScript File

var txt_cap_correo_es = 'escriba aqui su e-mail';
var txt_cap_correo_en = 'enter your e-mail here';

function ReceiveServerData(arg, context) {
    var R = arg.split('^|^');
    var control;
    
    switch (R[0]) {           
        case "Envia-Suscripcion-email":
            control = ObjetoporId('BtnSub');
            control.innerHTML = R[2];
            alert(R[1]);
            break;
            
        case "Contactus-Envia-Msg":
            control = ObjetoporId('BtnSub');
            control.innerHTML = R[2];
            alert(R[1]);
            break;
    }
    
}
            
function ReceiveServerDataError(msg_error, context) {
    alert('Error. ' + msg_error);
    //$find('pup_espera').hide();
}

function dcontenido(obj,idioma) {
    if (idioma == 'esp') {
        if (obj.value == txt_cap_correo_es)      obj.value = '';
    } else {
        if (obj.value == txt_cap_correo_en)      obj.value = '';
    }   
}

function rcontenido(obj,idioma) {
    if (idioma == 'esp') {
        if (obj.value == '')      obj.value = txt_cap_correo_es;
    } else {
        if (obj.value == '')      obj.value = txt_cap_correo_en;
    }   
}

function suscribe_qcorreo(ctrl,idioma) {
    var ref = '';
    var obj = ObjetoporId(ctrl);
    
    if (obj.value == '' || obj.value == '.' || obj.value == txt_cap_correo_es || obj.value == txt_cap_correo_en) {
        if (idioma == 'esp')    alert('Por favor introduzca su correo electr\ónico.');
        else                    alert('Please enter your e-mail addess.');
    } else {
        if (idioma == 'esp')    ref = 'e-Boletin.html';
        else                    ref = 'e-Newsletter.html';
        window.location = './' + ref + '?ref=' + obj.value;
    }
}

function ObjetoporId( id ) 
{ 
    if (document.getElementById) 
        var returnVar = document.getElementById(id); 
    else if (document.all) 
        var returnVar = document.all[id]; 
    else if (document.layers) 
        var returnVar = document.layers[id]; 
    return returnVar; 
}

function suscribe_email(idioma) {
    var nombre_val = ObjetoporId('frm_nombre');
    var apellido_val = ObjetoporId('frm_apellido');
    var correo_val = ObjetoporId('frm_correo');
    var correo2_val = ObjetoporId('frm_correo2');
    var inst = '';
    var sep = '^|^';    
    var stop = false;
    
    if (nombre_val.value == '' && !stop){
        stop = true; 
        if (idioma == "esp")    alert('Por favor especifique su nombre. Gracias!');
        else                    alert('Please enter your first name. Thank you!');
        nombre_val.focus();
    }
    if (apellido_val.value == '' && !stop){
        stop = true; 
        if (idioma == "esp")    alert('Por favor especifique su apellido. Gracias!');
        else                    alert('Please enter your last name. Thank you!');
        apellido_val.focus();
    }
    if (correo_val.value == '' && !stop){
        stop = true; 
        if (idioma == "esp")    alert('Por favor especifique su correo electr\ónico. Gracias!');
        else                    alert('Please enter your e-mail address. Thank you!');
        correo_val.focus();
    }
    if (correo2_val.value == '' && !stop){
        stop = true; 
        if (idioma == "esp")    alert('Por favor confirme su correo electr\ónico. Gracias!');
        else                    alert('Please confirm your e-mail address. Thank you!');
        correo2_val.focus();
    }
    if (correo_val.value != '' && correo2_val.value != '' && correo_val.value != correo2_val.value && !stop){
        stop = true; 
        if (idioma == "esp")    alert('Por favor verifique su correo electr\ónico, \ndebe escribirlo igual en el campo de correo y \nen la confirmaci\ón. Gracias!');
        else                    alert('The confirmation e-mail must match your e-mail address. \nPlease verify your e-mails. Thank you!');
        correo2_val.focus();
    }
    
    if (!stop) {
        muestra_en_espera('BtnSub');
        
        inst += 'Envia-Suscripcion-email' + sep + idioma + sep + nombre_val.value + sep + apellido_val.value + sep + correo_val.value;
        CallServerEmailSuscribe(inst, '');
    }
}

function contactus_envia_mensaje(idioma) {
		var fnombre = ObjetoporId('frm_nombre');
		var fapellido = ObjetoporId('frm_apellidos');
		var fmail = ObjetoporId('frm_mail');
		var ftipo = ObjetoporId('frm_asunto');
		var ftipo_valor = ftipo[ftipo.selectedIndex].value;
		var fmsg = ObjetoporId('frm_message');
		var sep = '^|^';
		var inst = '';
		var stop = false;
	    
		if (fnombre.value == '' && !stop) {
			if (idioma == 'esp') alert('Por favor introduzca su Nombre.');
			else                 alert('Your First Name cannot be blank.');
			fnombre.focus();
			stop = true;
		}
		if (fapellido.value == '' && !stop) {
			if (idioma == 'esp') alert('Por favor introduzca sus Apellidos.');
			else                 alert('Your Last Name cannot be blank.');
			fapellido.focus();
			stop = true;
		}
		if (fmail.value == '' && !stop) {
			if (idioma == 'esp') alert('Por favor introduzca su e-mail.');
			else                 alert('Your e-mail cannot be blank.');
			fmail.focus();
			stop = true;
		}
		if (ftipo_valor == '' && !stop) {
			if (idioma == 'esp') alert('Por favor seleccione el tipo de solicitud.');
			else                 alert('The Inquiry Type cannot be blank.');
			ftipo.focus();
			stop = true;
		}
		if (fmsg.value == '' && !stop) {
			if (idioma == 'esp') alert('Por favor introduzca su mensaje.');
			else                 alert('The message content cannot be blank.');
			fmsg.focus();
			stop = true;
		}
	    
		if (!stop) {
			muestra_en_espera('BtnSub');   
			inst = 'Contactus-Envia-Msg' + sep + idioma + sep + fnombre.value + sep + fapellido.value + sep + fmail.value + sep + ftipo_valor + sep + fmsg.value;
			CallServerContactus(inst, '');
		}
	}