	//funcion que devuelve el valor seleccionado de un radiobutton
	function getRadioButtonSelectedValue(ctrl)
			{
    		for(i=0;i<ctrl.length;i++)
        		{if(ctrl[i].checked) 
        			{return ctrl[i].value;}
        		}
			}	
 		
 		
 		//funcion que devuelve true si se ha seleccionado algun radiobutton
 		function getRadioButtonSelected(ctrl)
			{
    		for(i=0;i<ctrl.length;i++)
        		{if(ctrl[i].checked) 
        			{return true;}
        	}
	}



	///Validacion de fecha
	function isDate(s)
		{	var day,month,year,mod,chr
	    	if (s==null || s.length==0)
	       	 return true
	   	 if (s.length!=10)
	      	  return false
	
	   	 for (var ij=0;ij<10;ij++)
	   	 {	chr=s.charAt(ij)
	       	 if (ij!=2 && ij!=5)
	      	  {	if (chr<"0"||chr>"9") return false
	      	  }
	      	  else
	      	  {	if (chr!="/") return false
	      	  }
	  	  }
			tempoDate=s.split("/");
			day=parseInt(tempoDate[0],10);
	   	 month=parseInt(tempoDate[1],10);
	   	 year=parseInt(tempoDate[2],10);
	
	   	 if (1>day || day>31)
	   	     return false
	     if (1>month || month>12)
	       	 return false
	     if ((1>year)&&(year.length!=4))
	        return false
	     if ((month==4 || month==6 || month==9 || month==11) && day==31)
	        return false
	     if (month==2)
	     {	mod=year%4
	    	if (mod==0)
	    	{	mod=year%100
		    if(mod==0)
		    {	var mod2=year%400
				if(mod2==0 &&  day>29)
					return false
				else if(mod2!=0 && day>28)
					return false
			}
		    else if(day>29)
		        return false
	        }
	        else if (day>28)
	            return false
	    }
	    return true 		
	}
	
	
	// Validación del NIF
	function validaNIF(nif){
		var letras = 'TRWAGMYFPDXBNJZSQVHLCKE';
		var n = nif.substring(0,8);
		var numero = n%23;
		var l = nif.substring(8,9);
		var ll = letras.substring(numero, numero+1);
		if (l != ll) {
			alert('Letra de NIF no válida.');
			return false;
		}
		var exp = new RegExp ('^[0-9]{8}[A-Z]{1}$');
		if (!exp.test(nif)) {
			alert('NIF no válido');
			return false;
		}
	
		return true;
	}

	// Validacion del CIF
	function validarCIF(texto){ 
         
	        var pares = 0; 
        	var impares = 0; 
	        var suma; 
        	var ultima; 
	        var unumero; 
        	var uletra = new Array("J", "A", "B", "C", "D", "E", "F", "G", "H", "I"); 
	        var xxx; 
         
	        texto = texto.toUpperCase(); 
         
        	var regular =/^[ABCDEFGHKLMNPQS]\d\d\d\d\d\d\d[0-9,A-J]$/g; 
         if (!regular.exec(texto)) return false; 
              
         ultima = texto.substr(8,1); 

         for (var cont = 1 ; cont < 7 ; cont ++){ 
             xxx = (2 * parseInt(texto.substr(cont++,1))).toString() + "0"; 
             impares += parseInt(xxx.substr(0,1)) + parseInt(xxx.substr(1,1)); 
             pares += parseInt(texto.substr(cont,1)); 
         } 
         xxx = (2 * parseInt(texto.substr(cont,1))).toString() + "0"; 
         impares += parseInt(xxx.substr(0,1)) + parseInt(xxx.substr(1,1)); 
          
         suma = (pares + impares).toString(); 
         unumero = parseInt(suma.substr(suma.length - 1, 1)); 
         unumero = (10 - unumero).toString(); 
         if(unumero == 10) unumero = 0; 
          
         if ((ultima == unumero) || (ultima == uletra[unumero])) 
             return true; 
         else 
             return false; 

	} 

	function arreglaCIF(campo){
		var nifB = campo;
		nifB.value = nifB.value.toUpperCase();

		if (nifB.value!=''){
			if (!isNaN(nifB.value.substring(0,1))){
				while (nifB.value.length<9){
					nifB.value = '0'+nifB.value;
				}
			}
		}
	}
	
	function formatText(campo){
		campo.value = campo.value.toUpperCase();
	}
	
		
	function maxTextArea(textArea, max){
			if (textArea.value.length > max) {
				textArea.value = textArea.value.substring(0, max);
				alert('El texto introducido es demasiado largo.\n\nSe han eliminado los últimos caracteres.')
				textArea.focus();
				return false;
			}
		
	}
	
	function buscarTexto() {
		if (document.BusquedaForm.contiene.value=="") {
			alert('Debe especificar un valor de búsqueda');
			return;
		}
		document.BusquedaForm.opcion.value="buscar";
		document.BusquedaForm.submit();
	}
		
	function buscarAvanzada() {
		checkeados=0;
		
		if (document.BusquedaForm.tagsContenidos!=null) {
			for (i=0; i<document.BusquedaForm.tagsContenidos.length; i++) {
				if (document.BusquedaForm.tagsContenidos[i].checked) {
					checkeados++;
				}
			}
		}
		
		if (document.BusquedaForm.tagsNoticias != null) {
			for (i=0; i<document.BusquedaForm.tagsNoticias.length; i++) {
				if (document.BusquedaForm.tagsNoticias[i].checked) {
					checkeados++;
				}
			}
		}
		
		if (document.BusquedaForm.tagsEventos != null) {
			for (i=0; i<document.BusquedaForm.tagsEventos.length; i++) {
				if (document.BusquedaForm.tagsEventos[i].checked) {
					checkeados++;
				}
			}
		}
		
		if (document.BusquedaForm.tagsBlogs != null) {
			for (i=0; i<document.BusquedaForm.tagsBlogs.length; i++) {
				if (document.BusquedaForm.tagsBlogs[i].checked) {
					checkeados++;
				}
			}
		}

		if (document.BusquedaForm.contiene.value=="" && checkeados==0) {
			alert('Debe especificar un valor de búsqueda o marcar al menos una etiqueta');
			return;
		}
		document.BusquedaForm.opcion.value="buscar";
		document.BusquedaForm.submit();
	}
	
	function busquedaAvanzada() {
		document.BusquedaForm.opcion.value="busquedaAvanzada";
		document.BusquedaForm.submit();
	}
	
	function abrir(url,target,w,h,l,t,s,tb,mb) {
		ventana = window.open (url,target,"width="+w+",height="+h+",left="+l+",top="+t+",scrollbars="+s+",toolbar="+tb+", resizable=1,menubar="+mb);
		ventana.focus();
	}

	
		