// JavaScript Document 
window.onload = function () {
	if (document.getElementById('productos')) {
		var productos=document.getElementById('productos');
		var campos=productos.getElementsByTagName('input');
		for (i=0; i<campos.length; i++) {
			campos[i].onclick=function() {
				if (this.checked) {
					this.parentNode.parentNode.className="seleccionada";
				}
				else {
					this.parentNode.parentNode.className="";
				}
			}
		}
		var todos=document.getElementById('todos');
		todos.onclick=function() {
			var todos=1;
			for (i=0; i<campos.length; i++) {
			
			if (!campos[i].checked) {
					todos=0;
					break;
				}
			}
			for (i=0; i<campos.length; i++) {
			
			if (todos) {
					campos[i].checked=false;
					campos[i].parentNode.parentNode.className="";
				}
				else  {
					campos[i].checked=true;
					campos[i].parentNode.parentNode.className="seleccionada";
				}
			}
		}
	}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0  
  	window.open(theURL,winName,features);  
 }

function chequeo(formu) {
 var i = 0;
 for (i=0; i<formu.elements.length; i++){
    if (formu.elements[i].name=="terms_conditions" && formu.elements[i].checked==false) {
       alert ("Debe aceptar los terminos y condiciones")
       return false;
    }
    if(formu.elements[i].value==""){
      alert ("Por favor, debe rellenar todos los campos.")
      return false;
    }	
 }
 return true;
}

function chequeo_fin(formu) {//Para financredit ec-2007-08-29
 var i = 0;
 for (i=0; i<formu.elements.length; i++){
    if (formu.elements[i].name=="terms_conditions" && formu.elements[i].checked==false) {
       alert ("Debe aceptar los terminos y condiciones")
       return false;
    }
    if(formu.elements[i].value==""){
      alert ("Por favor, debe rellenar todos los campos.")
      return false;
    }	
    if(formu.elements[i].name=='importe' && !comprueba_numero(formu.elements[i],'15000','Importe')){
    	return false;
    }
      
 }
 return true;
}

function comprueba_numero(element,importe,texto){
   var checkStr = element.value;   
   var checkOK = "0123456789";   
   var allValid = true;
   var decPoints = 0;
   var allNum = "";  
   for (i = 0; i < checkStr.length; i++) {
     ch = checkStr.charAt(i);
     for (j = 0; j < checkOK.length; j++)
       if (ch == checkOK.charAt(j))
	 break;
     if (j == checkOK.length) {
       allValid = false;
       break;
     }
     allNum += ch;   
   }
   if (allValid && parseInt(checkStr)<'15000') {
     allValid = false;
   }
   if (!allValid) {     
     alert ("Por favor, el "+texto+" debe ser superior a "+importe+" euros.");     
     element.focus();
     return false;
   }   
   return true;
}