﻿// JScript File

function ReceiveServerData(arg, context) {
    var R = arg.split('^|^');
    var control;
    
    switch (R[0]) {           
        case "Envia-Suscripcion-email":
            control = ObjetoporId('QN_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 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_suscribe_nombre');
    var apellido_val = ObjetoporId('frm_suscribe_apellidos');
    var correo_val = ObjetoporId('frm_suscribe_mail');
    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 (!stop) {
        muestra_en_espera('QN_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_contacto_nombre');
		var fapellido = ObjetoporId('frm_contacto_apellidos');
		var fmail = ObjetoporId('frm_contacto_mail');
		var ftipo = ObjetoporId('frm_contacto_asunto');
		var ftipo_valor = ftipo[ftipo.selectedIndex].value;
		var fmsg = ObjetoporId('frm_contacto_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, '');
		}
	}