<!-- Debe contener una funcion *valida* para comprovar el formulario -->
function esTelefono(campo){
if (campo.value.toUpperCase()!=campo.value.toLowerCase()){
alert("El camp de telčfon no es vālid");
return false;}
return true;
}

function esFax(campo){
if (campo.value.toUpperCase()!=campo.value.toLowerCase()){
alert("El camp de Fax no es vālid");
return false;}
return true;
}

function esEmail(campo){
str = campo.value;
  if (str==null || str.length==0)
  	return true;
  if (!(str.indexOf(".") > 0) || !(str.indexOf("@") > 0)){
	alert("El camp e-mail no es vālid");
	return false;
	}
return true;
 
  }

function esNumerico(campo,texto){
	if (isNaN(Number(campo.value))){
		alert("El valor de "+texto+" ha de ser un nombre");
		return false;
	}
	return true;
}

function esNumericoPositivo(campo){
	if (isNaN(Number(campo.value))){
		alert("El valor ha de ser numéric");
		campo.focus();
		return false;
	}

	if (Number(campo.value) < 0) {
		alert("El valor de "+texto+" ha de ser positiu");
	}
	return true;
}

function esEntero(campo,texto){
	if (Math.round(campo.value) != campo.value){
		alert("El valor de "+texto+" ha de ser un enter");
		return false;
	}else{
		return true;
	}
}

function esTextoNormal(txt,campo_error){
	for(n=65;n<125;n++)	{
		a = String.fromCharCode(n);
		if (txt.indexOf(a+a+a)>=0) {
		alert('El valor de:'+campo_error+' no és vālid');
		return false;}
	}
return true;
}

function sizeMax(campo,maxsize,texto){
 if (campo.value.length>maxsize)
   {  
   alert("El camp: "+texto+" no pot ser excedir de "+maxsize+" carācters");
   return false;
   }
   return true;
}

function Nulo(campo,texto) {

 if (campo.value.length==0){
  alert("El camp: "+texto+" no pot ser buid");
  return false;
 }
 return true;
}

function selectObligatorio(campo,texto) {
 if (campo.selectedIndex==0){
  alert("ha de seleccionar un valor per el camp "+texto+" ");
  campo.focus();
  return false;
 }
 return true;
}

function esMayor(campo1, campo2)
{
	if(Number(campo1.value) > Number(campo2.value))
	{
		alert("La quantitat no pot ser major que "+campo2.value);
		campo1.focus();
		return false;
	}
	return true;
}

function validarTamanoTextarea(campo, maximo) 
{
	if (campo.value.length > maximo)
	{
		campo.value = campo.value.substring(0, maximo);
	}
}

function CaracterVal(e) {
	var charCode
	
	if (navigator.appName == "Netscape") 
		charCode = e.which // leo la tecla en ASCII que ingreso
	else
		charCode = e.keyCode // leo la tecla en ASCII que ingreso
		
	// control keys 0=null,9=tabulador, 13=intro, 27=escape
	if ((charCode==null) || (charCode==0) || (charCode==8) || 
	(charCode==9) || (charCode==27) )		
		return true;
		
	if ((charCode==61) || (charCode==34) || (charCode==13)){ //si es (=) o si (")
		return false;
	}

	return true;
}
