<!-- 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="transparent";
		if(campoObj.value=="" ||campoObj.value==0) { 
			campoObj.style.backgroundColor="#fa6e20";
			//campoObj.style.color="#323424";
			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="transparent";
	campo2.style.backgroundColor="transparent";
	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="#fa6e20";
			campo2.style.backgroundColor="#fa6e20";
			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;
 }

