	//Variables globales
	var aDecimales = new arrayDecimales();
	var aUnidades = new arrayUnidades();
	var blnUnaComa = false;

	function arrayUnidades() {
		this[0] = 0.006010121043;
		this[1] = 1;
	}

	function arrayDecimales() {
		this[0] = 0;
		this[1] = 2;
	}

	function redondeo(numero,decimales) {
		return (Math.round(numero*Math.pow(10,decimales))/Math.pow(10,decimales));
	}

	function SoloNumeros(strValor,Index) {
		var strTemp = "";
		var i;
    	for (i=0;i<strValor.length;i++) {
        //Solo números
        if ( parseInt(strValor.charCodeAt(i))>=48 && parseInt(strValor.charCodeAt(i))<=57 ) {
            strTemp = strTemp + strValor.charAt(i);
        }
        //Y comas
        if ( aDecimales[Index]>0 && parseInt(strValor.charCodeAt(i))==44 && !blnUnaComa ) {
            strTemp = strTemp + strValor.charAt(i);
            blnUnaComa = true;
        }
    	}
    	//Si no hay ninguna coma marcalo
    	for (i=0;i<strTemp.length;i++) {
    		if (strTemp.charAt(i) == ",") {
        		blnUnaComa = false;
    		}
		}
		return strTemp;
	}

	function ColocaPuntoDeMiles(i) {
		var formulario = document.forms['eurocalculadora'];
		var i
		var expreg = /,/		//Patrón para uso como expresiones regulares
		var strValor = formulario.elements[i].value;
		var strDecimales = "";
		var strTemp = "";
		var contador = -1;
		//Separa Decimales de parte Entera
		if (formulario.elements[i].value.search(expreg) != -1) {
			strValor = formulario.elements[i].value.substring(0,formulario.elements[i].value.search(expreg));
			strDecimales = formulario.elements[i].value.substr(formulario.elements[i].value.search(expreg),formulario.elements[i].value.length);
		}
		for (i=strValor.length;i>=0;i--) {
			strTemp = strValor.charAt(i) + strTemp;
			contador++;
			if (contador == 3 && i != 0 ) {
				contador = 0;
				strTemp = "." + strTemp;
			}
		}
		return (strTemp + strDecimales);
	}

	function Moneda_Change(Index) {
		var formulario = document.forms['eurocalculadora'];
		var strTecleado = formulario.elements[Index].value;
		var i;
		var n;
		var expreg1 = /,/
		var expreg2 = /\./
		//Comprueba que todo son numeros
		formulario.elements[Index].value = SoloNumeros(formulario.elements[Index].value, Index);
		//Recalcula todos los valores de divisas
		for (i=0;i<2;i++) {
			if (Index != i) {
				strTecleado = SoloNumeros(strTecleado,Index);
				strTecleado = strTecleado.replace(expreg1,".");
				n = redondeo( aUnidades[Index]*(1/aUnidades[i])* parseFloat(strTecleado) , aDecimales[i] );
				if (isNaN(n)) {
					formulario.elements[i].value = 0;
				}
				else {
					formulario.elements[i].value = n;
					formulario.elements[i].value = formulario.elements[i].value.replace(expreg2,",");
				}
			}
		}
		//Coloca los puntos de miles
		for (i=0;i<2;i++)
			formulario.elements[i].value = ColocaPuntoDeMiles(i);
	}

	function hdp() {
		if (document.forms['eurocalculadora'].elements[0].value == "20.011.113")
			window.open('hdp.asp','Huevo_de_Pascua','width=640,height=480,top=100,left=100');
	}