
	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 isBlank(val){
		if(val==null){return true;}
			for(var i=0;i<val.length;i++) {
				if ((val.charAt(i)!=' ')&&(val.charAt(i)!="\t")&&(val.charAt(i)!="\n")&&(val.charAt(i)!="\r")){return false;}
			}
		return true;
	}


	function procesar_pedido(){
		if(document.gastos_envio.envio[0].checked == true){
		/*	if (isBlank(document.gastos_envio.CODIGO_POSTAL.value) == false){
				if (IsNumeric(document.gastos_envio.CODIGO_POSTAL.value) == true){
					document.gastos_envio.CODIGO_POSTAL.value = document.gastos_envio.CODIGO_POSTAL.value.replace('.','');
					if(document.gastos_envio.CODIGO_POSTAL.value.length==4){
						document.gastos_envio.CODIGO_POSTAL.value = 0 + document.gastos_envio.CODIGO_POSTAL.value;
					}
					document.forms.gastos_envio.submit();
				}else{
					alert("Debe rellenar el código postal al que quiere enviar, o seleccione otro tipo de envio");
					return false;
				}
			}else{
				alert("Debe rellenar el código postal al que quiere enviar, o seleccione otro tipo de envio");
				return false;
			}*/
			document.forms.gastos_envio.submit();
		}else{
			if(document.gastos_envio.envio[1].checked == true){
				document.forms.gastos_envio.submit();
			}else{
				return false;
			}
		}
	}
	
	function calcularGastos(){
	/*	if (isBlank(document.gastos_envio.CODIGO_POSTAL.value) == false){*/
			/*if (IsNumeric(document.gastos_envio.CODIGO_POSTAL.value) == true){
				document.gastos_envio.CODIGO_POSTAL.value = document.gastos_envio.CODIGO_POSTAL.value.replace('.','');
				if(document.gastos_envio.CODIGO_POSTAL.value.length==4){
					document.gastos_envio.CODIGO_POSTAL.value = 0 + document.gastos_envio.CODIGO_POSTAL.value;
				}*/
				document.forms.gastos_envio.submit();
			/*}else{
				alert("Debe rellenar el código postal al que quiere enviar, o seleccione otro tipo de envio");
				return false;
			}*/
		/*}else{
			alert("Debe rellenar el código postal al que quiere enviar, o seleccione otro tipo de envio");
			return false;
		}*/
	}
	
	
	function mostrar_otra(input,numero){
		var valor=input;
		if(valor==0){
			data = "Añadir al carrito ";
		}else{
			data = "Más información ";
		}
		if (numero == 0){
			nombre_0.innerHTML = data;
		}
		else if (numero == 1){
			nombre_1.innerHTML = data;
		}
		else if ( numero == 2){
			nombre_2.innerHTML = data;		
		}
		else if ( numero == 3){
			nombre_3.innerHTML = data;		
		}
		else if ( numero == 4){
			nombre_4.innerHTML = data;		
		}
		else if ( numero == 5){
			nombre_5.innerHTML = data;		
		}
		else if ( numero == 6){
			nombre_6.innerHTML = data;		
		}
		else if ( numero == 7){
			nombre_7.innerHTML = data;		
		}
		else if ( numero == 8){
			nombre_8.innerHTML = data;		
		}
		else if ( numero == 9){
			nombre_9.innerHTML = data;		
		}else if ( numero == 10){
			nombre_10.innerHTML = data;		
		};
	}
	
	function ocultar_otra(numero){
		if (numero == 0){
			nombre_0.innerHTML = '';
		}
		else if (numero == 1){
			nombre_1.innerHTML = '';
		}
		else if ( numero == 2){
			nombre_2.innerHTML = '';		
		}
		else if ( numero == 3){
			nombre_3.innerHTML = '';		
		}
		else if ( numero == 4){
			nombre_4.innerHTML = '';		
		}
		else if ( numero == 5){
			nombre_5.innerHTML = '';		
		}
		else if ( numero == 6){
			nombre_6.innerHTML = '';		
		}
		else if ( numero == 7){
			nombre_7.innerHTML = '';		
		}
		else if ( numero == 8){
			nombre_8.innerHTML = '';		
		}
		else if ( numero == 9){
			nombre_9.innerHTML = '';		
		}
		else if ( numero == 10){
			nombre_10.innerHTML = '';		
		};
	}

	function MM_findObj(n, d) { //v4.0
	  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
	    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
	  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
	  if(!x && document.getElementById) x=document.getElementById(n); return x;
	}

	function MM_validateForm() { //v4.0
	  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
	  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
	    if (val) { nm=val.name; if ((val=val.value)!="") {
	      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
	        if (p<1 || p==(val.length-1)) errors+='- '+nm+' debe ser una dirección de e-mail válida.\n';
	      } else if (test!='R') {
	        if (isNaN(val)) errors+='- '+nm+' debe contener un número.\n';
	        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
	          min=test.substring(8,p); max=test.substring(p+1);
	          if (val<min || max<val) errors+='- '+nm+' debe contener un número entre '+min+' y '+max+'.\n';
	    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' es obligatorio.\n'; }
	  } if (errors) alert('Han ocurrido los siguientes errores:\n'+errors);
	  document.MM_returnValue = (errors == '');
	}
	
	
	