<!-- changeObjectVisibility *************************************** -->
<!-- ************************************************************** -->
<!-- Cambia la visibilidad de un objeto                             -->
<!-- ************************************************************** -->

function changeObjectVisibility(objectId, newVisibility) 
{
	// Lo primero es coger la referencia a partir del estilo del navegador y
	// asegurarse que el objeto existe
	
    var styleObject = getStyleObject(objectId);
    
    if(styleObject)
    {
		styleObject.visibility = newVisibility;
		return true;
    }
    else
    {
	    // Si no podemos encontrar el objeto, no podemos cambiar su visibilidad
		return false;
    }
}


<!-- getStyleObject *********************************************** -->
<!-- ************************************************************** -->
<!-- Devuelve el estilo de un objecto.                              -->
<!-- ************************************************************** -->

function getStyleObject(objectId) 
{

	// check W3C DOM, luego MSIE 4, luego NN 4.
  
  	if(document.getElementById && document.getElementById(objectId)) 
  	{
		return document.getElementById(objectId).style;
   	}
   	else if (document.all && document.all(objectId)) 
   	{
		return document.all(objectId).style;
   	} 
   	else if (document.layers && document.layers[objectId])
   	{ 
		return document.layers[objectId];
   	}
   	else
   	{
		return false;
   	}
}



<!-- *********************************************************************************** -->
<!-- TOOLTIP *************************************************************************** -->



<!-- Enlaza: ****************************************************** -->
<!-- ************************************************************** -->
<!-- Asigna todos los controles de un formulario eventos comunes    -->
<!-- ************************************************************** -->
		 	
function enlaza (index)
{
	
	<!-- Definición de variables privadas ***************************** -->
	var bucle;
	p_formid = index;
	
			  
	<!-- Bucle principal ********************************************** -->
	<!-- ************************************************************** -->
	<!-- Recorre un bucle a través de todos los objetos del formulario  -->
	<!-- y activa sus eventos 								   -->
	<!-- ************************************************************** -->
	
	for (bucle=0; bucle < document.forms[index].elements.length; bucle++)
	{
		
		<!-- Cajas de texto ****************************************** -->

		if (document.forms[index].elements[bucle].type == 'text')
		{
			document.forms[index].elements[bucle].onblur = lostfocus;
			document.forms[index].elements[bucle].onfocus = gotfocus;
		}
	}
}

		  		
<!-- Asigna todos los controles de un formulario eventos comunes ** -->
<!-- ************************************************************** -->
<!-- Click del botón ********************************************** -->
<!-- ************************************************************** -->

function submitclick()
{

	<!-- Declaración privada de variables ************************ --> 
	<!-- ********************************************************* -->
	
	var bucle;
	var resultado;
	var returnval;
		
	<!-- Determina la acción a tomar por el botón **************** --> 
	<!-- ********************************************************* -->
	
	for (bucle=0; bucle < document.forms[0].elements.length; bucle++)
	{
		if (document.forms[0].elements[bucle].type == 'text')
		{
			if (comprobar (document.forms[0].elements[bucle]) == 0)
			{
				resultado = "error";
			}
		}
	}
	
	if (resultado == "error")
	{
		alert ("Compruebe los campos.");
		returnval = false;
	}
	else
	{
		returnval = true;
	}
	
	return returnval;
	
}



<!-- On Blur ****************************************************** -->
<!-- ************************************************************** -->
		
function lostfocus()
{
	
	if (window.event.srcElement.name.split("___")[3] == '1')
	{
		if (window.event.srcElement.value == '')
		{
			window.event.srcElement.className='boton3';
		}
		else
		{
			window.event.srcElement.className='boton2';
		}
	}
	else
	{
		window.event.srcElement.className='boton2';		
	}
}
		

<!-- ************************************************************** -->
<!-- On Focus ***************************************************** -->
<!-- ************************************************************** -->

var highlightcolor="lightgrey";
var ns6=document.getElementById&&!document.all;
var previous='';
var eventobj;
var intended=/INPUT|TEXTAREA/


function checkel(which)
{
	if (which.style&&intended.test(which.tagName))
	{
		if (ns6&&eventobj.nodeType==3) eventobj=eventobj.parentNode.parentNode;
		
		if (eventobj.type == 'button')
		{
			return false;
		}
		else
		{
			return true;
		}
	}
	else
	{
		return false
	}
}

//Function to highlight form element
function highlight(e)
{
	eventobj=ns6? e.target : event.srcElement
	
	if (previous!='')
	{
		if (checkel(previous))
		previous.style.backgroundColor='';
		previous=eventobj;
		
		if (checkel(eventobj)) eventobj.style.backgroundColor=highlightcolor;
	}
	else
	{
		previousclassName=eventobj.className;
		if (checkel(eventobj)) eventobj.style.backgroundColor=highlightcolor;
		previous=eventobj;
	}
}




function seleccion()
{
	window.event.srcElement.focus();
}




<!-- ********************************************************************** -->
<!-- Funciones privadas *************************************************** -->
<!-- ********************************************************************** -->

<!-- DNILetra ************************************************************* -->
<!-- ********************************************************************** -->
	
function letranif(cadena)
{
	
	<!-- Declaración privada de variables            -->
	
	var tmpletra;
	var posicion;
	
	
	<!-- Prueba                                      -->
	
	posicion = 0 + (cadena % 23);
	tmpletra = "TRWAGMYFPDXBNJZSQVHLCKE".substring (posicion, posicion + 1);
	return tmpletra;
	
}

 	

<!--tFormato: Aplica a una cantidad formato monetario                                                        -->
<!--******************************************************************************************************** -->

function tFormato(importe)
{
	
	var resultado;
	
	
	resultado = "";
	
	if (importe == 0)
	{
		return "Vista previa. Introduzca los decimales con el símbolo del punto.";
	}
	else
	{	
		
		miFloat = parseFloat(importe)
		if (isNaN(miFloat) == false)
		{
			miFloat = parseFloat(importe).toFixed(2).toString();
			longitud = miFloat.substring(1, miFloat.length - 2).length;
			cantidadceros = parseInt(longitud / 3).toFixed(0);
			primerpunto = longitud % 3;

			for (bucle=0; bucle < miFloat.substring(1, miFloat.length - 2).length; bucle++)
			{
				if (cantidadceros > 0)
				{
					if ((bucle == primerpunto) && bucle != 0)
					{
						resultado = resultado + ".";
					}

					if (bucle != 0 && bucle != 1 && bucle != 2)
					{					
						indice = (Math.floor(bucle / 3) * 3);
						if (bucle == primerpunto + indice) {resultado = resultado + ".";}
					}

					
				}
				resultado = resultado + miFloat.substring(bucle, bucle + 1);
			}
			
			return resultado + "," + miFloat.substring(miFloat.length - 2, miFloat.length) + " €";
		}
		else
		{
			return "Vista previa. Introduzca los decimales con el símbolo del punto .";
		}
	}
}



<!--CONFIRMAR: Cancela un evento sumbit a peitición del usuario									             -->
<!--******************************************************************************************************** -->

function confirmar(mensaje)
{
	if (mensaje == "") {mensaje="¿Esta seguro que desea eliminar esta ficha?";}
	if (mensaje == null) {mensaje="¿Esta seguro que desea eliminar esta ficha?";}
	
	
	vconfirmar=confirm(mensaje);
	if (vconfirmar) {return true;} else {return false;}
}


<!--MAXIMALONGITUD: Limita un TextArea				  										    			 -->
<!--******************************************************************************************************** -->


function maximaLongitud(texto,maxlong)
{

	var tecla, in_value, out_value;

 	if (texto.value.length > maxlong)
 	{
			in_value = texto.value;
			out_value = in_value.substring(0,maxlong);
			texto.value = out_value;
			return false;
		}
		return true;
}
	
	

<!--ADDOPT: Añade opciones a un control OPTION                                                               -->
<!--******************************************************************************************************** -->

function addOpt(oControl, iPos, sTxt, sVal, selected)
{
 	var selOpcion=new Option(sTxt, sVal);
 	
 	eval(oControl.options[iPos]=selOpcion);
 	eval(oControl.options[iPos].selected = selected);
}



<!--Pop_UP 																									-->
<!--******************************************************************************************************* -->

var ventana_pop=false;

function Pop_UP(url, ancho, alto, titulo)
{
	
	if (typeof ventana_pop.document == "object") {ventana_pop.close()}	
	LeftPosition = (screen.width) ? (screen.width-ancho)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-alto)/2 : 0;
	
	destino = "imagen.php?url=" + url + "&titulo=" + titulo;
	ventana_pop = window.open(destino, "Imagen", "status = 1, left = " + LeftPosition + ", top = " + TopPosition + ", height = " + alto + ", width = " + ancho + ", resizable = 0" )
	
}


<!--Pop_UP_Galeria 																									-->
<!--******************************************************************************************************* -->

var ventana_pop=false;

function Pop_UP_Galeria(url, ancho, alto, titulo, pie, imagen)
{
	
	if (typeof ventana_pop.document == "object") {ventana_pop.close()}	
	LeftPosition = (screen.width) ? (screen.width-ancho)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-alto)/2 : 0;
	
	destino = "galeria_imagen.php?url=" + url + "&titulo=" + titulo + "&pie=" + pie + "&imagen=" + imagen;
	ventana_pop = window.open(destino, "Imagen", "status = 1, left = " + LeftPosition + ", top = " + TopPosition + ", height = " + alto + ", width = " + ancho + ", resizable = 0" )
	
}


<!--tImprimir																								-->
<!--******************************************************************************************************* -->

var ventana_imprimir=false;

function tImprimir(url, ancho, alto, titulo)
{
		
	if (typeof ventana_imprimir.document == "object") {ventana_imprimir.close()}	
	LeftPosition = (screen.width) ? (screen.width-ancho)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-alto)/2 : 0;
	
	destino = "imprimir.php?url=" + url + "&titulo=" + titulo;
	ventana_imprimir = window.open(url, "Imagen", "status = 1, left = " + LeftPosition + ", top = " + TopPosition + ", height = " + alto + ", width = " + ancho + ", resizable = 0, scrollbars = yes" )

}



<!--tFicha     																							    -->
<!--******************************************************************************************************* -->

var ventana_ficha=false;

function tFicha(url, ancho, alto)
{
	
	if (typeof ventana_ficha.document == "object") {ventana_ficha.close()}	
	LeftPosition = (screen.width) ? (screen.width-ancho)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-alto)/2 : 0;
	
	destino = url;
	ventana_ficha = window.open(destino, "Imagen", "status = 1, left = " + LeftPosition + ", top = " + TopPosition + ", height = " + alto + ", width = " + ancho + ", resizable = 0, scrollbars=yes" )
}



<!--Ayuda     																							    -->
<!--******************************************************************************************************* -->

var ventana_ayuda=false;

function tAyuda(url, ancho, alto)
{
	
	if (typeof ventana_ayuda.document == "object") {ventana_ayuda.close()}	
	LeftPosition = (screen.width) ? (screen.width-ancho)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-alto)/2 : 0;
	
	destino = url;
	ventana_ayuda = window.open(destino, "Imagen", "status = 1, left = " + LeftPosition + ", top = " + TopPosition + ", height = " + alto + ", width = " + ancho + ", resizable = 0, scrollbars=yes" )
}




<!-- Solo Numeris ************************************************************************************************ -->
function solonumeros()
{
	if (navigator.appName == "Microsoft Internet Explorer")
	{
		var key=window.event.keyCode;
		
		if (key < 48 || key > 57) 
		{
			if (key != 46 && key != 44) {window.event.keyCode=0;}
		}
	}
}


<!-- Solo Precio ************************************************************************************************ -->
function soloprecio()
{
	if (navigator.appName == "Microsoft Internet Explorer")
	{
		var key=window.event.keyCode;
		
		if (key < 48 || key > 57)
		{
			if (key != 46) {window.event.keyCode=0;}
		}
	}
}



<!--Muestra Calendario 																         					    -->
<!--*************************************************************************************************************** -->

var ventanaCalendario=false
var ventanaCatalogo=false

function muestraCalendario(ruta, formulario_destino, campo_destino, fecha_ini, fecha_fin, defecto)
{
	if (typeof ventanaCalendario.document == "object")
	{
		ventanaCalendario.close()
	}
	
	ventanaCalendario = window.open(ruta + "modulo_calendario.php?formulario=" + formulario_destino + "&nomcampo=" + campo_destino + "&fecha_min="+fecha_ini+"&fecha_max="+fecha_fin+"&defecto="+defecto,"calendario","width=300,height=300,left=100,top=100,scrollbars=no,menubars=no,statusbar=NO,status=NO,resizable=YES,location=NO")
}



<!--tGaleria     																							-->
<!--******************************************************************************************************* -->

var ventana_galeria=false;
function tGaleria(url, ancho, alto)
{
	
	if (typeof ventana_galeria.document == "object") {ventana_galeria.close()}	
	LeftPosition = (screen.width) ? (screen.width-ancho)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-alto)/2 : 0;
	
	destino = url;
	ventana_galeria = window.open(destino, "Imagen", "status = 1, left = " + LeftPosition + ", top = " + TopPosition + ", height = " + alto + ", width = " + ancho + ", resizable = 0, scrollbars=no" )
}



<!--eFlash																									-->
<!--******************************************************************************************************* -->

function eFlash(pelicula,variables,ancho,alto,id,wmode)
{
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="'+ancho+'" height="'+alto+'" title="">');
	document.write('<param name="movie" value="'+pelicula+'?'+variables+'" />');
	document.write('<param name="quality" value="high" />');
	
	
	if (wmode==true)
	{
		document.write('<param name="wmode" value="transparent" />');
		document.write('<embed src="'+pelicula+'?'+variables+'" wmode="transparent" width="'+ancho+'" height="'+alto+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"></embed>');
	}
	else
	{
		document.write('<embed src="'+pelicula+'?'+variables+'" width="'+ancho+'" height="'+alto+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"></embed>');
	}
	document.write('</object>');
}


<!--Redireccionar																									-->
<!--******************************************************************************************************* -->

function redireccionar(direccion, tiempo) 
{
	setTimeout("location.href=direccion", tiempo);
}




<!--Muestra Callejero													         					    		  	-->
<!--*************************************************************************************************************** -->

var ventanaCallejero=false

function muestraLocalidad(IDZona, posx, posy)
{
	if (typeof ventanaCallejero.document == "object")
	{
		ventanaCallejero.close()
	}
	
	if (IDZona != "" )
	{
		
		
		if ( posx != "" && posy != "" )
		{
		
		ventanaCallejero = window.open("modulos/modulo_callejero.php?IDZona=" + IDZona + "&posx=" + posx + "&posy=" + posy ,"Callejero","width=500,height=700,left=100,top=100,scrollbars=no,menubars=no,statusbar=NO,status=NO,resizable=YES,location=NO")
		
		}else{
			
		ventanaCallejero = window.open("modulos/modulo_callejero.php?IDZona=" + IDZona,"Callejero","width=500,height=700,left=100,top=100,scrollbars=no,menubars=no,statusbar=NO,status=NO,resizable=YES,location=NO")
				
		}	
	
	
		
	}else{
		
	ventanaCallejero = window.open("modulos/modulo_callejero.php","Callejero","width=500,height=700,left=100,top=100,scrollbars=no,menubars=no,statusbar=NO,status=NO,resizable=YES,location=NO")			
	
	}
	
	
}
