// JavaScript Document
	function rollover(imagen)
	{
		//alert(imagen.src);
		var trz;
		trz = imagen.src.split("/");
		ruta = imagen.src;
		nomimage1 = trz[trz.length-1];
		nomimage = nomimage1.replace("1", "2");
		
		imagen.src = ruta.replace(nomimage1, nomimage);
	}
	
	function rollout(imagen)
	{
		var trz;
		trz = imagen.src.split("/");
		ruta = imagen.src;
		nomimage1 = trz[trz.length-1];
		nomimage = nomimage1.replace("2", "1");
		
		imagen.src = ruta.replace(nomimage1, nomimage);
	}

	function cambia(id)
	{
		
		var foto1 = document.getElementById("foto1");
		var miurl = foto1.src;
		var foto2 = document.getElementById(id);
		
		foto1.src = foto2.src;
		foto2.src = miurl;		
	}

	function IsNumeric(sText) 
	{
		var ValidChars = "0123456789.";
		var IsNumber = true;
		var Char;
		
		for (i = 0; i < sText.length && IsNumber == true; i++) 
		{
			Char = sText.charAt(i);
			if (ValidChars.indexOf(Char) == -1) 
			{
				IsNumber = false;
			}
		}
		
		return IsNumber;
	}

	
	function validaPuja(form, creditos, creditosPorPuja)
	{	
		mif = document.getElementById(form);
		if( parseFloat(creditos) >= parseFloat(creditosPorPuja))
		{
			if(mif.entero.value != "" && mif.decimal.value != "" && mif.entero.value != "€" && mif.decimal.value != "c/€")
			{
				if( IsNumeric(mif.entero.value) && IsNumeric(mif.decimal.value) )
				{
					if(confirm("La puja que vas a realizar es por " + mif.entero.value + "." + mif.decimal.value + " €, ¿Estas seguro?"))
					{
						mif.action = "insertarp.asp"
						return true;
					}
					else
					{
						document.getElementById("entero").select();
						return false;
					}
				}
				else
				{
					alert("Tu puja debe contener valores numéricos.");
					document.getElementById("entero").focus();
					return false;
				}
			}
			else
			{
				alert("Debes rellenar los valores de tu puja");
				document.getElementById("entero").focus();
				return false;
			}
		}
		else
		{
			alert("Esta operación requiere " + parseFloat(creditosPorPuja) + " Cr. y tu saldo (" + parseFloat(creditos) + " Cr.) no permite realizarla")
			return false;
		}
	}
	
	function validaMultiPuja(form, creditos, creditosPorPuja)
	{	
		mif = document.getElementById(form);
		linf = Math.round(100*(parseFloat("0"+mif.li_entero.value)+ parseFloat("0."+mif.li_decimal.value)));
		lsup = Math.round(100*(parseFloat("0"+mif.ls_entero.value)+ parseFloat("0."+mif.ls_decimal.value)));
		
		if(linf < lsup) 
		{
			
			total = (lsup - linf) + 1;
			cuantos = total;
			
			//alert(parseFloat(total) + " " + parseFloat(creditosPorPuja));
			total = parseFloat(total) * parseFloat(creditosPorPuja);
			total = total.toFixed(2);
			//alert(cuantos + " " + creditosPorPuja + " " + total + " " + creditos);
			if(parseFloat(total) <= parseFloat(creditos))
			{					
				if(confirm('Está operación requiere ' + total + ' €Créditos\n¿Deseas realizar la multipuja?'))
				{
					mif.action = "insertarpMulti.asp";
					return true;
				}
				else
				{
					return false;
				}
			}
			else
			{
				alert("Esta operación requiere " + parseFloat(total) + " €Créditos. Tu saldo (" + parseFloat(creditos) + " €Créditos) no permite realizarla.")
				return false;
			}
		}
		else
		{
			alert("Límite inferior debe ser menor que límite superior")
			return false;
		}		
	}

	
	
	function aceptamodificar(form)
	{
		if(confirm("¿Está seguro que desea modificar sus datos?"))
		{
			if(validateOnSubmit(form))
			{
				return true;
			}
			else
			{
				return false;
			}
		}
		else
		{
			return false;
		}
	}

	
