	function dateVal (input) { 
   		if (input.length != 10) { 
   			return false; 
   			}		 
   			for (j=0; j<input.length; j++) { 
   			//all figures and spacers in place? 
     		if ((j == 2) || (j == 5)) { 

       		if (input.charAt(j) != "/") { 
         		return false; 
       		} 
     		} else if ((input.charAt(j)<"0") || (input.charAt(j)>"9")) { 
       		return false; 
     		} 
   		} 
		// 
		//using right format dd/mm/yyyy and year 2002 or more? Change this for diff formats... 

		bits = input.split("/"); 
		days = Number(bits[0]); 
		month = Number(bits[1]); 
		year=Number(bits[2]); 
		if (days > 31) { return false;} 
		else if (month > 12) { return false;} 
		else if (year < 2002) { return false;} 
		return true; 
		} 


	//....................................................... insercio data(fecha)
	function IsNumeric(valor) 
	{ 
	var log=valor.length; var sw="S"; 
	for (x=0; x<log; x++) 
		{ v1=valor.substr(x,1); 
		v2 = parseInt(v1); 
		//Es un valor numeric? 
		if (isNaN(v2)) { sw= "N";} 
		} 
	if (sw=="S") {return true;} else {return false; } 
	} 

	var primerslap=false; 
	var segonsllap=false; 
	
	function farmataData(fecha) 
	{ 
	var long = fecha.length; 
	var dia; 
	var mes; 
	var ano; 

	if ((long>=2) && (primerslap==false)) { dia=fecha.substr(0,2); 
	if ((IsNumeric(dia)==true) && (dia<=31) && (dia!="00")) { fecha=fecha.substr(0,2)+"/"+fecha.substr(3,7); primerslap=true; } 
		else { fecha=""; primerslap=false;} 
		} 
	else 
		{ dia=fecha.substr(0,1); 
		if (IsNumeric(dia)==false) 
		{fecha="";} 
		if ((long<=2) && (primerslap=true)) {fecha=fecha.substr(0,1); primerslap=false; } 
	} 
	if ((long>=5) && (segonsllap==false)) 
		{ mes=fecha.substr(3,2); 
		if ((IsNumeric(mes)==true) &&(mes<=12) && (mes!="00")) { fecha=fecha.substr(0,5)+"/"+fecha.substr(6,4); segonsllap=true; } 
		else { fecha=fecha.substr(0,3);; segonsllap=false;} 
	} 
	else { if ((long<=5) && (segonsllap=true)) { fecha=fecha.substr(0,4); segonsllap=false; } } 
	if (long>=7) 
	{ ano=fecha.substr(6,4); 
	if (IsNumeric(ano)==false) { fecha=fecha.substr(0,6); } 
	else { if (long==10){ if ((ano==0) || (ano<1900) || (ano>2100)) { fecha=fecha.substr(0,6); } } } 
	} 

	if (long>=10) 
	{ 
	fecha=fecha.substr(0,10); 
	dia=fecha.substr(0,2); 
	mes=fecha.substr(3,2); 
	ano=fecha.substr(6,4); 
	// Any no bi i es febrer i dia es>28 
	if ( (ano%4 != 0) && (mes ==02) && (dia > 28) ) { fecha=fecha.substr(0,2)+"/"; } 
	} 
	return (fecha); 
	} 


	function koko(){
		var fechaActual = new Date();
  		
  		var fecha2000 = new Date(document.frmSolicitaTP.neix.value);
  		
  		
  		var tiempoRestante =  fechaActual.getTime()-fecha2000.getTime();
  		
  		
  		
  		var dias = Math.floor(tiempoRestante / (1000 * 60 * 60 * 24*365));
			
		if (dias<18)
		{
		document.getElementById ("tutor").style.display="block"
		document.getElementById ("tutor").style.opacity="1"
		document.getElementById ("tutor").style.filter ="alpha(opacity=100)"

		
		document.frmSolicitaTP.tnom.disabled=false;
		document.frmSolicitaTP.tcognom1.disabled=false;
		document.frmSolicitaTP.tcognom2.disabled=false;
		document.frmSolicitaTP.tadreca.disabled=false;
		document.frmSolicitaTP.tpoblacion.disabled=false;
		document.frmSolicitaTP.tprovincia.disabled=false;
		document.frmSolicitaTP.tCP.disabled=false;
		document.frmSolicitaTP.tDNI.disabled=false;
		document.frmSolicitaTP.ttelefon.disabled=false;
		document.frmSolicitaTP.temail.disabled=false;
		document.frmSolicitaTP.menor.value="SI"
		}  		
  		else
  		{
		document.getElementById ("tutor").style.display="none"
		document.getElementById ("tutor").style.opacity=".3"
		document.getElementById ("tutor").style.filter ="alpha(opacity=30)"
		document.frmSolicitaTP.tnom.disabled=true;
		document.frmSolicitaTP.tcognom1.disabled=true;
		document.frmSolicitaTP.tcognom2.disabled=true;
		document.frmSolicitaTP.tadreca.disabled=true;
		document.frmSolicitaTP.tpoblacion.disabled=true;
		document.frmSolicitaTP.tprovincia.disabled=true;
		document.frmSolicitaTP.tCP.disabled=true;
		document.frmSolicitaTP.tDNI.disabled=true;
		document.frmSolicitaTP.ttelefon.disabled=true;
		document.frmSolicitaTP.temail.disabled=true;
		document.frmSolicitaTP.menor.value="NO"
  		}
  		
  		

	
	}


	function procesaF(){


	
	if (document.frmSolicitaTP.nom.value=="") {
		posaError('nom',0)
		return false
		} 
	

	if (document.frmSolicitaTP.cognom1.value=="") {
		posaError('cognom1',0)
		return false
		} 
	
	if (document.frmSolicitaTP.cognom2.value=="") {
		posaError('cognom2',0)
		return false
		} 
	

	if (document.frmSolicitaTP.adreca.value=="") {
		posaError('adreca',0)
		return false
		} 

	if (document.frmSolicitaTP.poblacion.value=="") {
		posaError('poblacion',0)
		return false
		} 

	if (document.frmSolicitaTP.provincia.value=="") {
		posaError('provincia',0)
		return false
		} 

	if (document.frmSolicitaTP.CP.value=="") {
		posaError('CP',0)
		return false
		} 

	if (document.frmSolicitaTP.DNI.value=="") {
		posaError('DNI',0)
		return false
		} 



	if (document.frmSolicitaTP.telefon.value=="") {
		posaError('telefon',0)
		return false
		} 





	if (document.frmSolicitaTP.neix.value=="") {
		posaError('neix',0)
		return false
		} 


	if (document.frmSolicitaTP.menor.value=="SI") 
		{
		if (document.frmSolicitaTP.tnom.value=="") {
			posaError('tnom',385)
			return false
			} 
	

		if (document.frmSolicitaTP.tcognom1.value=="") {
			posaError('tcognom1',385)
			return false
			} 
	
		if (document.frmSolicitaTP.tcognom2.value=="") {
			posaError('tcognom2',385)
			return false
			} 
	

		if (document.frmSolicitaTP.tadreca.value=="") {
			posaError('tadreca',385)
			return false
			} 

		if (document.frmSolicitaTP.tpoblacion.value=="") {
			posaError('tpoblacion',385)
			return false
			} 

		if (document.frmSolicitaTP.tprovincia.value=="") {
			posaError('tprovincia',385)
			return false
			} 

		if (document.frmSolicitaTP.tCP.value=="") {
			posaError('tCP',385)
			return false
			} 

		if (document.frmSolicitaTP.tDNI.value=="") {
			posaError('tDNI',385)
			return false
			} 


		if (document.frmSolicitaTP.ttelefon.value=="") {
			posaError('ttelefon',385)
			return false
			} 





		if (document.frmSolicitaTP.tneix.value=="") {
			posaError('tneix',385)
			return false
			} 
		}		


		if (document.frmSolicitaTP.pAEPKA.value=="Ninguno de esta lista" && document.frmSolicitaTP.asACKE.value=="Ninguno de esta lista" && document.frmSolicitaTP.capCombo.value=="Por favor, escriba aqui quien le ha propuesto la solicitud:")
			{
			document.frmSolicitaTP.capCombo.value="Por favor, escriba aqui quien le ha propuesto la solicitud:"
			document.frmSolicitaTP.capCombo.focus()
			document.frmSolicitaTP.capCombo.select()
			return false
			}		
		
          						                                  			
			document.frmSolicitaTP.submit ()
		
	}	
	
	function treuError() {
		
				
		if (document.frmSolicitaTP.neix.value=="ejemplo: 01/10/1985") {
		document.frmSolicitaTP.neix.value=""
		}


		document.getElementById ("navega").style.display ="none"
		return false;
	}



	function posaError(obj,tS){
		

		document.location ="#contingut"
		document.getElementById ("navega").style.display ="block"
		kk=document.getElementById (obj).offsetLeft 
		kk2=document.getElementById (obj).offsetTop 

		if (window.innerHeight)
			{/*navegadors basats en mozilla*/;h = window.innerHeight-160;kk2=kk2-80;kk=kk+30}
		else
		{ 
		
			if (document.body.clientHeight)
			{/*Navegadors basats en IExplorer; h = document.body.clientHeight*/;kk2=kk2+0+tS;kk=kk+0}
			else
			{/*altres navegadors*/;h = 600} 
		} 

	
		document.getElementById ("navega").style.left = kk +"px"
		document.getElementById ("navega").style.top = kk2 +"px"
		document.getElementById ("navega").style.paddingBottom ="19px"
		document.getElementById ("navega").style.paddingTop ="22px"
		document.getElementById ("navega").style.fontSize ="0.85em"
		document.getElementById ("navega").innerHTML ="Campo<br />obligatorio!"
	
		return false

	}




	function exclouPista(tS){
	
	if (tS==1){
		//document.frmSolicitaTP.asACKE.disabled =false;
		//document.frmSolicitaTP.pAEPKA.disabled =true;
		document.frmSolicitaTP.pAEPKA.options [0].selected=true;
		}

	if (tS==2){
		document.frmSolicitaTP.asACKE.options [0].selected=true;
		//document.frmSolicitaTP.asACKE.disabled =true;
		//document.frmSolicitaTP.pAEPKA.disabled =false;
		}
	
	lletra=document.frmSolicitaTP.asACKE.value
	posicio=document.frmSolicitaTP.pAEPKA.value
	
	if (lletra=='Ninguno de esta lista' & posicio=='Ninguno de esta lista')
		{
		document.getElementById ("capCombo").style.visibility="visible"
		document.frmSolicitaTP.capCombo.value="Por favor, escriba aqui quien le ha propuesto la solicitud:"
		document.frmSolicitaTP.capCombo.focus()
		document.frmSolicitaTP.capCombo.select()
		}

		else 
		{document.getElementById ("capCombo").style.visibility="hidden"}

	}






	function posaCapCombo(){
		document.frmSolicitaTP.capCombo.focus()
		document.frmSolicitaTP.capCombo.value=""
	}


//................................................. comproba que nomes siguin nums


      //................ aquest si que va amb tots els browsers	
	function esNumero(evt)
      {
         var charCode = (evt.which) ? evt.which : event.keyCode
         if (charCode > 31 && (charCode < 48 || charCode > 57))
            return false;

         return true;
      }





	function posaDNI(tS) { 
	
		strDNI="TRWAGMYFPDXBNJZSQVHLCKET" 
		
		if (tS==1)
			{
			posicio = document.frmSolicitaTP.DNI.value % 23 
			lletra = strDNI.substring(posicio,posicio+1) 
			
			if (document.frmSolicitaTP.DNI.value !="")
				{ 
				document.frmSolicitaTP.DNI.value=document.frmSolicitaTP.DNI.value+"-"+lletra
				}
			}
			
		if (tS==2)
			{
			posicio = document.frmSolicitaTP.tDNI.value % 23 
			lletra = strDNI.substring(posicio,posicio+1) 
			
			if (document.frmSolicitaTP.tDNI.value !="")
				{
				document.frmSolicitaTP.tDNI.value=document.frmSolicitaTP.tDNI.value+"-"+lletra
				}
			}

	
		}	 
