window.onload = function() {
	//alert("Inicio de tipo de cambio");
}


function checkTCForm () {
	if (document.frmTC.origen.value=="") {
		alert('Por favor, introduzca la moneda que quiere cambiar para continuar.');
		document.frmTC.origen.focus();
		return false;
	}
	else if (document.frmTC.destino.value=="") {
		alert('Por favor, introduzca la moneda a la que quiere realizar el tipo de cambio para continuar.');
		document.frmTC.destino.focus();
		return false;
	}
	else if (document.frmTC.monto.value!="") {
		v=document.frmTC.monto.value;
		regexp = /^[0-9]*.[0-9]*$/;
		res= regexp.test(v);
		
		if (res) {
			if ( isNaN(v) ) {
				alert('Use el punto "." como separador decimal.');
				document.frmTC.monto.focus();
				return false;
			}
			else {
				if (v>0) {
					document.getElementById('frmTC_c_loading').style.visibility = 'visible';
				}
				else {
					alert('El monto introducido debe ser mayor que 0.');
					document.frmTC.monto.focus();
					return false;
				}
			}
		}
		else  {
			alert('El monto introducido contiene un valor que no es v�lido.\nUtilice s�lamente n�meros, no use signos.');
			document.frmTC.monto.focus();
			return false;
		}
	}
	document.getElementById('frmTC_c_loading').style.visibility = 'visible';
	DisplayWaitingTC();
	return true;
	
}

function paBajo(elID)
    {
      var el = document.getElementById(elID);
      el.scrollIntoView(true);
      alert ('Si entro paBajo');
    }

function showLoading(){
	//alert ('Aqui ando');
	document.getElementById('frmTC_c_loading').style.visibility = 'visible';
	DisplayWaitingTC();
}    


function DisplayWaitingTC(){
document.getElementById("frmTC_c_loading").innerHTML ="<center><span class='bold peque'><br /><br /><br />Estamos consultando el Tipo de cambio en:<br /></span><div id=\"divLoading2\">Bancomer</div><img src=\"/images/barra-load.gif\"><br /></center>";
		setTimeout("document.getElementById('divLoading2').innerHTML='Banco del Bajio'",10500);
		setTimeout("document.getElementById('divLoading2').innerHTML='Scotiabank'",9000);
		setTimeout("document.getElementById('divLoading2').innerHTML='Banca Mifel'",7500);
		setTimeout("document.getElementById('divLoading2').innerHTML='Inbursa'",6000);
		setTimeout("document.getElementById('divLoading2').innerHTML='HSBC'",4500);
		setTimeout("document.getElementById('divLoading2').innerHTML='Banorte'",3000);
		setTimeout("document.getElementById('divLoading2').innerHTML='Banco  Azteca'",1500);
}
function ChangeFormTC(){
    var origenTC = document.frmTC.origen.value;
    var destinoTC = document.frmTC.destino.value;

    if (origenTC=="PES") origenTC="pesos";
    else if (origenTC=="USD") origenTC="dolares";
    else origenTC="euros";

    if (destinoTC=="PES") destinoTC="pesos";
    else if (destinoTC=="USD") destinoTC="dolares";
    else destinoTC="euros";
    
    document.getElementById("FormaIniTC").action="/tipo-de-cambio-resultados/"+origenTC+"-"+destinoTC+"/";
}

function sendvaluestc(opt){
	if (opt==1){
		document.frmTC.origen.value="PES";
		document.frmTC.destino.value="USD";
	}else if (opt==2){
		document.frmTC.origen.value="PES";
		document.frmTC.destino.value="EUR";
	}else if (opt==3){
		document.frmTC.origen.value="USD";
		document.frmTC.destino.value="PES";
	}else if (opt==4){
		document.frmTC.origen.value="USD";
		document.frmTC.destino.value="EUR";
	}else if (opt==5){
		document.frmTC.origen.value="EUR";
		document.frmTC.destino.value="PES";
	}else{
		document.frmTC.origen.value="EUR";
		document.frmTC.destino.value="USD";
	}
        ChangeFormTC();
	document.frmTC.submit();
}