﻿// JScript File

function ReceiveServerData(arg, context) {
    var R = arg.split('^|^');
    var control;
    
    switch (R[0]) {           
        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 contactus_envia_mensaje(idioma) {
		var fnombre = ObjetoporId('frm_nombre');
		var fapellido = ObjetoporId('frm_apellidos');
		var fmail = ObjetoporId('frm_mail');
		var ftel = ObjetoporId('frm_tel');
		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 (ftel.value == '' && !stop) {
			if (idioma == 'esp') alert('Por favor introduzca su Tel\éfono.');
			else                 alert('Your Phone Number cannot be blank.');
			ftel.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 + ftel.value + sep + ftipo_valor + sep + fmsg.value;
			CallServerContactus(inst, '');
		}
	}
