//<script>
	

var aEquipos = new Array("Ancora","EnologicoCPG","LateralLM","ME6100","LateralLR"
						,"ME4100","VerticalconMotorDirecto","ME5100","Blender","VerticalconReductor"
						,"ME1100SLIM","JetMix","Portatil","ME1100","MasAdecuado");

// Rep un array de caracteristiques i desactiva totes les Bombes que tenen zeros
function apagarEquips(aChar) {
		for (i in aChar) {
			if (aChar[i]==0) {
				sInput = eval("document.all." + aEquipos[i]);
				if (sInput!=undefined) {
						sInput.className = "OpcionInactiva";
						sInput = eval("document.all.Equipo" + aEquipos[i]);
						sInput.disabled = true;
				}
			}
		}			
}


function activarEquipo(Equip) {
	if (1==1) {
	todasActivas();
	sInputIni = eval("document.all.Equipo" + Equip);
	if (sInputIni!=undefined) {
		for (i in aEquipos) {
			if (aEquipos[i]!=Equip) {
				sInput = eval("document.all.Equipo" + aEquipos[i]);
				if (sInput!=undefined) {
					sInput.checked = false;
					sInput.disabled = sInputIni.checked;
				}			
			}
		}
	}
	}
}

function activarEquips() {

	todasActivas();
	
}





function todasActivas() {
	var i;
	var sInput = "";
	
	for (i in aEquipos) {
		sInput = eval("document.all." + aEquipos[i]);
		if (sInput != undefined) {
			sInput.className = "OpcionActiva";
			sInput = eval("document.all.Equipo" + aEquipos[i]);
			sInput.disabled = false;
		}
	}
	
}

function todasInactivas() {
	var i;
	var sInput = "";
	
	for (i in aEquipos) {
		sInput = eval("document.all." + aEquipos[i]);
		if (sInput!=undefined) sInput.className = "OpcionInactiva";
		//sInput = eval("document.all.Equip" + aEquipos[i]);
		//sInput.disabled = true;
		//sInput.checked = false;
	}
	
}

function EquipSeleccionat () {
	var bSelecciones = 0;
	var sInput = "";
	var i;
	
	for (i in aEquipos) {
		sInput = eval("document.all.Equipo" + aEquipos[i]);
		if (sInput!=undefined) {
			if (sInput.checked == true)
				bSelecciones++;
		} else alert(aEquipos[i] + ': no definida !');
	}

	//caso especial de seleccion de la mas adecuada
	sInput = eval("document.all.EquipoMasAdecuado");
		if (sInput.checked == true)
			bSelecciones++;
	//si no hay ninguna Equip seleccionada se devuelve false 
	//para que se muestre un mensaje de que no se ha seleccionado
	//ninguna Equip.
	if (bSelecciones == 0) return false;
	else return true;
}
function validaLlarg(){
	if (form1.ObservacionesDAT.value.length>1000) {
		alert(aTextos[450]);
		form1.ObservacionesDAT.focus();
		return false;
	}
	return true;
}
function IsNumeric(strString)
   //  check for valid numeric strings	
   {
   var strValidChars = "0123456789.-";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
   }
   
function EsEnter(strString)
   //  check for valid numeric strings	
   {
   var strValidChars = "0123456789";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
   }   
   
function valida(form,vEmpresa) {

	var wCliente = form.Empresa.value;
	var wIdCliente = form.Cliente.value;
	var wContacto = form.Contacto.value;
	var wEmail = form.mail.value;
	var wProducto = form.ProductoDAT.value;
	var vfrase = /^\w+(.+)+$/;
	//var vEmail = /^(.+)+@(.+)+(\.(.+)+)+$/;
	
	if (!EquipSeleccionat()) {
		alert(aTextos[430]);
		return false;	
	}

/*	if (wIdCliente != "") {
		if (!EsEnter(wIdCliente)) {
			alert(aTextos[170]);
			form.Cliente.focus();
			return false;
		}
	}
*/	
	//alert('Validant');
	if (wCliente == ""){		
		alert(aTextos[170]);
		form.Empresa.focus();
		return false;	
	}	
	/*if (!vfrase.test(wCliente))	{		
		alert(wCliente + " ¡ Cliente NO VALIDO !\nPor favor, introduzca Id. y nombre del cliente.");
		form.Cliente.select();		
		form.Cliente.focus();		
		return false;			
	}	*/

	/*if (wContacto == ""){		
		alert("Por favor, introduzca el Nombre de contacto.");
		form.Contacto.focus();		
		return false;	
	}*/	
	/*if (!vfrase.test(wContacto))	{		
		alert(wContacto + " ¡ Nombre NO VALIDO !\nPor favor, introduzca su Nombre.");
		form.Contacto.select();		
		form.Contacto.focus();		
		return false;			
	}*/	
	if (wEmail == ""){
		alert(aTextos[171]);		
		form.mail.focus();		
		return false;	
	}	
	/*if (!vemail.test(wEmail))	{		
		alert(wEmail + " ¡ Email NO VALIDO !\nPor favor, introduzca su dirección Email.");		
		form.Email.select();		
		form.Email.focus();		
		return false;			
	} 
	*/
	
	if (wProducto == ""){
		alert(aTextos[172]);		
		form.ProductoDAT.focus();		
		return false;	
	}
	
	TanqueValidar();

	//comprobacion  que el cliente y el producto existe
	//parametro que se pasa a todos los asp para que cargue la pagina del servidor.
	form1.NuevaAplicacionDAT.disabled=false;
	form1.DatosViejaDAT.disabled=false;

	var d = new Date()
	var dFecha = d.getTime()		
	top.generador.location.href="comprobarDatos.asp?idcliente="+ wCliente  + "&idempresa="+ vEmpresa + "&modo=S&fecha=" + dFecha +"&producto="+ wProducto;	
	return false;		
	
}



