<!-- CORTAR TEXTO EN TEXTAREAS -- >
function cortar(id,num)
	{
	if (document.getElementById(id).value.length>num) document.getElementById(id).value=document.getElementById(id).value.substr(0,num);
	}


<!-- REDONDEAR NUMERO CON DECIMALES -->
function decimales(numero,decimales,separador_decimal)
	{
		numero=parseFloat(numero);
		decimales=parseInt(decimales);
		
		var valor=numero;

		for (i=0;i<decimales;i++) //sacamos los decimales que necesitamos a la parte entera multiplicando por 10
			{
				valor=valor*10;
			}//del for

		valor=parseInt(valor); //pasamos a entero y desechamos la parte decimal
		var valorcadena=String(valor); //convertimos a cadena el valor
		
		var parte_decimal=valorcadena.substr(valorcadena.length-decimales); //sacamos la parte decimal de la cadena
		if (parte_decimal=='0')//en el caso de que el numero sea 0 la parte decimal también es 0
			{
			parte_decimal='';
			for (i=0;i<decimales;i++)//creamos las posiciones decimales
				{
				parte_decimal=parte_decimal+'0';
				}//del for
			}//del if

		for (i=0;i<decimales;i++) //hacemos la operacion inversa a la primera para volver a tener el valor entero igual
			{
				valor=valor/10;
			}//del for
			
		valor=parseInt(valor); //deshechamos de nuevo la parte decimal
		valor=String(valor)+separador_decimal+parte_decimal; //reconstruimos el numero
		
		if (isNaN(valor)==true)
			{
				valor='error';
			}//del if
		
		return valor;
		
	}//de function
<!-- -->

<!-- PREGUNTA ANTES DE EJECUTAR -->
function confirmacion_ejecutar(pregunta,accion)
{
confirmar=confirm(pregunta);
	if (confirmar)
	{
    accion;
  	}
}
<!-- -->

<!-- NUEVA VENTANA CON ANCHO, ALTO Y SIN BARRAS NI BOTONES -->
function abrir_ventana(theURL,title,w,h)
	{
	var windowprops ="top=0,left=0,toolbar=no,location=no,status=no, menubar=no,scrollbars=no, resizable=no,width=" + w + ",height=" + h;

	window.open(theURL,title,windowprops);
	}
<!-- -->

<!-- PREGUNTA ANTES DE IR A URL -->
function borrarconfirmacion(pregunta,URL)
{
confirmar=confirm(pregunta);
	if (confirmar)
	{
    location.href=URL;
  	}
}
<!-- -->


<!-- cambia EL SRC de la imagen -->
function ampliar(dato,titulo)
{  
		document.getElementById('galeria').src="";
		document.getElementById('galeria').src=dato+"-grande.jpg";
		document.getElementById('galeria').title=titulo;
}
<!-- -->


<!-- MOSTRAR/OCULTAR CAPA -->
function flip(rid)
  		{
    		current=(document.getElementById(rid).style.display == 'none') ? 'block' : 'none';
    		document.getElementById(rid).style.display = current;
  		}
<!-- -->


<!-- SOLO MOSTRAR CAPA -->
function mostrar_capa(rid)
  		{
			document.getElementById(rid).style.display='block';
  		}
<!-- -->
		
		
//Funcion Favoritos---------------
function favoritos(pagina,descripcion){
if ((navigator.appName=="Microsoft Internet Explorer") && (parseInt(navigator.appVersion)>=4)) {
var url=pagina;
var titulo=descripcion;
window.external.AddFavorite(url,titulo);
}
else {
if(navigator.appName == "Netscape") 
alert ("Presione Crtl+D para añadir esta direccion a Favoritos");
}
}
//---------------------


<!-- RESALTAR CASILLA -->
function resaltar_casilla(objeto)
{
	document.getElementById(objeto).style.backgroundColor='#CCCCCC';
	document.getElementById(objeto).style.borderColor='#FF0000';
	document.getElementById(objeto).style.color='#FF0000';
}
<!-- COMPROBAR LOS CAMPOS DE UN FORMULARIO -->
function Email_Valido(email){ 
var exp_email1 = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/;
var exp_email2 = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/;
return !exp_email1.test(email) && exp_email2.test(email);
}


function comprobarCampos(form,campos,email) {
	var ok=true;
	var formObj=document.getElementById(form);
	var camposArr= campos.split("|");
	for (i=0;i<camposArr.length;i++) { 
		campoObj=document.getElementById(camposArr[i]);
		campoObj.style.backgroundColor="#5ad9ff";
		if(campoObj.value=="" ||campoObj.value==0) { 
			campoObj.style.backgroundColor="#0089c9";
			campoObj.style.color="#ffffff";
			ok=false;
			break;
		}
	}
	if(ok) { 
		if (document.getElementById(email) && document.getElementById(email).value!="" && document.getElementById(email).value!=null) {
			if (Email_Valido(document.getElementById(email).value)) formObj.submit(); else alert("Parece que el email no es válido. Por favor, revise los datos");
			
		} else formObj.submit();
	} else alert("Hay campos obligatorios en el formulario sin rellenar.\n\n Por favor, revise los datos.");
}

function camposIguales(c1,c2) {
	var campo1=	document.getElementById(c1);
	var campo2=	document.getElementById(c2);
	campo1.style.backgroundColor="#5ad9ff";
	campo2.style.backgroundColor="#5ad9ff";
	if ((campo1.value!="" && campo2.value !="" && campo1.value!=null && campo2.value !=null) && campo1.value!=campo2.value) {
			alert ("Los valores introducidos en ambos campos deben ser iguales");
			campo1.style.backgroundColor="#0089c9";
			campo2.style.backgroundColor="#0089c9";
			campo1.style.color="#ffffff";
			campo2.style.color="#ffffff";
			return false;
	} else return true;
}

function Comp_Digito(e)
 {
  //Comprueba que la tecla pulsada es un número. Sino lo es, no devuelve nada
  var keycode;
  if (window.event) keycode = window.event.keyCode;
    else if (e) keycode = e.which;
    else return true;
  if (keycode!=44 && keycode!=46 && keycode !=8 && keycode !=0 && (keycode < 48 || keycode >57)) return false;
     else if (keycode==46 ){
		  if (window.event) window.event.keyCode=44;
			else if (e) e.which=44;
			else return true;
		 } else return true;
 }
// Ajax para el correo
function creaAjax(){
         var objetoAjax=false;
         try {
          /*Para navegadores distintos a internet explorer*/
          objetoAjax = new ActiveXObject("Msxml2.XMLHTTP");
         } catch (e) {
          try {
                   /*Para explorer*/
                   objetoAjax = new ActiveXObject("Microsoft.XMLHTTP");
                   }
                   catch (E) {
                   objetoAjax = false;
          }
         }

         if (!objetoAjax && typeof XMLHttpRequest!='undefined') {
          objetoAjax = new XMLHttpRequest();
         }
         return objetoAjax;
}                 

function FAjax (url,capa,valores,metodo)
{
          var ajax=creaAjax();
          var capaContenedora = document.getElementById(capa);

/*Creamos y ejecutamos la instancia si el metodo elegido es POST*/
if(metodo.toUpperCase()=='POST'){
         ajax.open ('POST', url, true);
         ajax.onreadystatechange = function() {
         if (ajax.readyState==1) {
                          capaContenedora.innerHTML="Cargando...";
         }
         else if (ajax.readyState==4){
                   if(ajax.status==200)
                   {
                        document.getElementById(capa).innerHTML=ajax.responseText;
                   }
                   else if(ajax.status==404)
                                             {

                            capaContenedora.innerHTML = "La direccion no existe";
                                             }
                           else
                                             {
                            capaContenedora.innerHTML = "Error: ".ajax.status;
                                             }
                                    }
                  }
         ajax.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
         ajax.send(valores);
         return;
}
/*Creamos y ejecutamos la instancia si el metodo elegido es GET*/
if (metodo.toUpperCase()=='GET'){

         ajax.open ('GET', url, true);
         ajax.onreadystatechange = function() {
         if (ajax.readyState==1) {
                                      capaContenedora.innerHTML="Cargando...";
         }
         else if (ajax.readyState==4){
                   if(ajax.status==200){
                                             document.getElementById(capa).innerHTML=ajax.responseText;
                   }
                   else if(ajax.status==404)
                                             {

                         alert("LA direccion no existe");
						 //   capaContenedora.innerHTML = "La direccion no existe";
                                             }
                                             else
                                             {
												 alert(" Error ".ajax.status);
                           // capaContenedora.innerHTML = "Error: ".ajax.status;
                                             }
                                    }
                  }
         ajax.setRequestHeader('Content-Type','application/x-www-form-urlencoded'); 
         ajax.send(null);
         return
}
} 
/*function cargaContenido()
{
	//var valor=document.getElementById("categoria").options[document.getElementById("categoria").selectedIndex].value;
	var valor = document.form1.categoria.value;
	if(valor==0)
	{
		// Si el usuario eligio la opcion "Elige", no voy al servidor y pongo todo por defecto
		alert("Seleccione una Opcion" + valor);
	}
	else
	{
		FAjax('ajax_subcategorias.php?cat='+valor,'divSub','','get');
		
	}
}*/
