// discriminador de browser (ns == 1 --> Netscape)
ns4	=	(document.layers)?1:0;
ie	=	(document.all)?1:0;
ns6	=	(document.getElementById && (!document.all))?1:0;



/*  +	+	+	+	+	+	+	+	+	+	+	+	+	+	+
+
+	function defDIV(theDivName,theX,theY)
+		Define un objeto div de nombre "divtheDivName" a partir 
+		de la div HTML de nombre "theDivName" y situa la capa	
+		correspondiente en las coordenadas X e Y pasadas.
+		Nomenclatura recomendada: nombreDIV para la div HTML. La 
+		función genera automáticamente el objeto JS con nombre 
+		"divnombreDIV".(Una versión posterior deberá eliminar el 
+		"DIV" del nombre del objeto JS para mantener la nomenclatura usual)
+
+		theDivName	--> string con el nombre de la div destino
+		theX		--> Posicion horizontal indicada en pixels
+		theY		--> Posicion vertical indicada en pixels
+
+	(ns6 compliant)
+
+	+	+	+	+	+	+	+	+	+	+	+	+	+	+	+ */

function defDIV(theDivName,theX,theY){
				
		if (ns4)
			eval('div'+ theDivName +'	=	document.layers[\''+ theDivName +'\']');
						
		else if (ie)
			eval('div'+ theDivName +'	=	document.all[\''+ theDivName +'\'].style'); 
						
		else if ((ns6)&&(!ie))
			eval('div'+theDivName+'=document.getElementById(\''+theDivName+'\').style');

					
		eval('moveDIVTo\(div'+ theDivName +',theX,theY\)');
		//eval('showDIV\(div'+ theDivName +'\)');
	}
			
//	+	+	+	+	+	+	+	+	+	+	+	+	+	+	+		




/*  +	+	+	+	+	+	+	+	+	+	+	+	+	+	+
+
+	function defDIV2(theDivName)
+		Define un objeto div de nombre "divtheDivName" a partir 
+		de la div HTML de nombre "theDivName" sin situar la capa	
+		correspondiente en las coordenadas X e Y pasadas.
+		Nomenclatura recomendada: nombreDIV para la div HTML. La 
+		función genera automáticamente el objeto JS con nombre 
+		"divnombreDIV".(Una versión posterior deberá eliminar el 
+		"DIV" del nombre del objeto JS para mantener la nomenclatura usual)
+
+		theDivName	--> string con el nombre de la div destino
+		
+
+	(ns6 compliant)
+
+	+	+	+	+	+	+	+	+	+	+	+	+	+	+	+ */

function defDIV2(theDivName){
				
		if (ns4)
			eval('div'+ theDivName +'	=	document.layers[\''+ theDivName +'\']');
						
		else if (ie)
			eval('div'+ theDivName +'	=	document.all[\''+ theDivName +'\'].style'); 
						
		else if ((ns6)&&(!ie))
			eval('div'+theDivName+'=document.getElementById(\''+theDivName+'\').style');

					
		//eval('moveDIVTo\(div'+ theDivName +',theX,theY\)');
		eval('showDIV\(div'+ theDivName +'\)');
	}
			
//	+	+	+	+	+	+	+	+	+	+	+	+	+	+	+		



/*  +	+	+	+	+	+	+	+	+	+	+	+	+	+	+
+
+	function dimDIV(theDiv,theWidth)
+		Modifica la anchura de una layer accediendo a su propiedad width.
+
+		theDiv		--> objeto div a redimensionar
+		theWidth	--> Nueva anchura en pixels
+
+	+	+	+	+	+	+	+	+	+	+	+	+	+	+	+ */

function dimDIV(theDiv,theWidth){

		if (ns4)
			return;
					
		else if (ie)
			theDiv.width	=	theWidth;
					
		else if ((ns6)&&(!ie))
			theDiv.width	=	theWidth;
	}
			
//	+	+	+	+	+	+	+	+	+	+	+	+	+	+	+		

function dimHeightDIV(theDiv,theHeight){

		if (ns4)
			return;
					
		else if (ie)
			theDiv.height	=	theHeight;
					
		else if ((ns6)&&(!ie))
			theDiv.height	=	theHeight;
	}
			
//	+	+	+	+	+	+	+	+	+	+	+	+	+	+	+
			
/*  +	+	+	+	+	+	+	+	+	+	+	+	+	+	+
+
+	function writeDIV(div,text)
+		Escribe contenido HTML en una div
+		div		--> string con el nombre de la div destino
+		text	--> string con el contenido HTML a escribir
+
+	(ns6 compliant)
+
+	+	+	+	+	+	+	+	+	+	+	+	+	+	+	+ */

function writeDIV(div,text)
{
 if (ns4)
 {	
  var lyr = document.layers[div].document;
  lyr.open();
  lyr.write(text);
  lyr.close();
 }
 else if (ns6){
  var lyr = document.getElementById(div);
  lyr.innerHTML = text;
 }
 else
  document.all[div].innerHTML = text+'\n';
 }

//	+	+	+	+	+	+	+	+	+	+	+	+	+	+	+		

/*  +	+	+	+	+	+	+	+	+	+	+	+	+	+	+
+
+	function writeDIV2(nested,div,text)
+		Escribe contenido HTML en una div
+		div		--> string con el nombre de la div destino
+		text	--> string con el contenido HTML a escribir
+
+	(ns6 compliant)
+
+	+	+	+	+	+	+	+	+	+	+	+	+	+	+	+ */

function writeDIV2(nested,div,text)
{
 if (ns4)
 {
  var lyr;	
  if (nested!=null) 
    lyr = document.layers[nested].document.layers[div].document;
  else
    lyr = document.layers[div].document;
  
  lyr.open();
  lyr.write(text);
  lyr.close();
 }
 else if (ns6){
  var lyr = document.getElementById(div);
  lyr.innerHTML = text;
 }
 else 
  document.all[div].innerHTML = text;
 
 }

//	+	+	+	+	+	+	+	+	+	+	+	+	+	+	+		



/*  +	+	+	+	+	+	+	+	+	+	+	+	+	+	+
+
+	function writeDIVobj(div,text)
+		Escribe contenido HTML en una div. Es una variante de
+		la function anterior. En esta, pasamos directamente el 
+		objeto div, de esta manera podemos pasar div's anidadas 
+		con más de un nivel de profundidad como es el caso de 
+		la div donde se vuelca el contenido en un objeto scroll2
+		div		--> Objeto div destino
+		text	--> string con el contenido HTML a escribir
+
+	------------------------------------------------------------ */

function writeDIVobj(div,text)
{
 if (ns4)
 {	
  div.document.open();
  div.document.write(text);
  div.document.close();
 }
 else div.innerHTML = text;
}

//	+	+	+	+	+	+	+	+	+	+	+	+	+	+	+		


/*  +	+	+	+	+	+	+	+	+	+	+	+	+	+	+
+
+	function moveDIVTo(div,x,y)
+		Mueve una div. a la posición x,y 
+		div		--> objeto div a mover. Previamente debe estar 
+					definido en la funcion init();
+		x		--> Posicion horizontal en pixels
+		y		--> Posición vertical en pixels
+
+	(ns6 compliant)
+
+	+	+	+	+	+	+	+	+	+	+	+	+	+	+	+ */

function moveDIVTo(div,x,y) {
                div.xpos = x
                div.left = div.xpos
                div.ypos = y
                div.top = div.ypos
        }

//	+	+	+	+	+	+	+	+	+	+	+	+	+	+	+



/*  +	+	+	+	+	+	+	+	+	+	+	+	+	+	+
+
+	function moveDIVBy(div,x,y) {
+		Desplaza una div. el número de pixels indicado en x,y 
+		div		--> objeto div a mover. Previamente debe estar 
+					definido en la funcion init();
+		x		--> Offset horizontal en pixels
+		y		--> Offset vertical en pixels
+
+	(ns6 compliant)
+
+	+	+	+	+	+	+	+	+	+	+	+	+	+	+	+ */

function moveDIVBy(div,x,y) {
		div.xpos += x
		div.left = div.xpos
		div.ypos += y
		div.top = div.ypos
	}

//	+	+	+	+	+	+	+	+	+	+	+	+	+	+	+





/*  +	+	+	+	+	+	+	+	+	+	+	+	+	+	+
+
+	function hideDIV(div)
+		Oculta una div. (Tocando su atributo visibility)
+		div		--> objeto div a ocultar. Previamente debe estar 
+					definido en la funcion init();
+
+	(ns6 compliant)
+
+	+	+	+	+	+	+	+	+	+	+	+	+	+	+	+ */

function hideDIV(div)
{
 if (ns4) div.visibility = "hide";
 else div.visibility = "hidden";
}

//	+	+	+	+	+	+	+	+	+	+	+	+	+	+	+


/*  +	+	+	+	+	+	+	+	+	+	+	+	+	+	+
+
+	function showDIV(div)
+		Muestra una div. (Tocando su atributo visibility)
+		div		--> objeto div a mostrar. Previamente debe estar 
+					definido en la funcion init();
+
+	(ns6 compliant)
+	
+	+	+	+	+	+	+	+	+	+	+	+	+	+	+	+ */

function showDIV(div){
 if (ns4) div.visibility = "show";
 else div.visibility = "visible";
}

//	+	+	+	+	+	+	+	+	+	+	+	+	+	+	+


/*  +	+	+	+	+	+	+	+	+	+	+	+	+	+	+
+
+	function preload(imgObj,imgSrc)
+		Precarga una imagen creando un objeto image de 
+		javascript con la imagen que se indica en imgSrc
+		imgObj		--> Cadena de texto con el nombre que queremos
+						dar al nuevo objeto image creado. La nomenclatura
+						recomendada es 'nombreIO'
+		imgSrc		--> Cadena de texto con el path de la imagen
+
+	+	+	+	+	+	+	+	+	+	+	+	+	+	+	+ */

function preload(imgObj,imgSrc) {
    if (document.images) {
            eval(imgObj+' = new Image()')
            eval(imgObj+'.src = "'+imgSrc+'"')
    }
}

//	+	+	+	+	+	+	+	+	+	+	+	+	+	+	+



/*  +	+	+	+	+	+	+	+	+	+	+	+	+	+	+
+
+	function changeImage(layer,imgName,imgObj) 
+		Sustituye la imagen que aparece en el nido HTML indicado en imgName
+		por imagen almacenda en la propiedad .src del objeto imagen JS 
+		indicado en imgObj. 
+
+		layer		--> cadena con el nombre de la DIV que contiene el nido HTML. En caso 
+						que el nido no esté dentro de ninguna layer pasaremos 
+						un valor de null.
+		imgName		--> Cadena con el nombre del nido HTML de la imagen que 
+						queremos reemplazar
+		imgObj		--> Cadena con el nombre del objeto imagen JS. La nomenclatura
+						recomendada es 'nombreIO'
+
+	+	+	+	+	+	+	+	+	+	+	+	+	+	+	+ */

function changeImage(layer,imgName,imgObj) {
	if (document.images) {
		if (document.layers && layer!=null) eval('document.'+layer+'.document.images["'+imgName+'"].src = '+imgObj+'.src')
		else document.images[imgName].src = eval(imgObj+".src")
	}
}

//	+	+	+	+	+	+	+	+	+	+	+	+	+	+	+



/*  +	+	+	+	+	+	+	+	+	+	+	+	+	+	+
+
+	function isFecha(theFecha)
+		Validación de una fecha introducida por el usuario.
+		Valida que la fecha esté introducida en formato dd/mm/yyyy.
+		La primere linea supone la aceptación de valores nulos para el campo fecha.
+
+		theFecha	--> Cadena introducida por el usuario con la fecha que deseamos validar
+
+	+	+	+	+	+	+	+	+	+	+	+	+	+	+	+ */

	function isFecha(theFecha) {
		if (theFecha=='') return(true); //Permitimos valor nulo para el campo de fecha
		var DatosFecha = theFecha.split('/');
		var Fecha = new Date();
		Fecha.setFullYear(DatosFecha[2],DatosFecha[1]-1,DatosFecha[0]);		
		return ((Fecha.getMonth()==DatosFecha[1]-1)&&(DatosFecha[2].length==4));
	}

//	+	+	+	+	+	+	+	+	+	+	+	+	+	+	+



/*  +	+	+	+	+	+	+	+	+	+	+	+	+	+	+
+
+	function perfectOpen(theURL,theWinName,theWidth,theHeight,hasScrollBars)
+		Abre un popup centrado en la pantalla.
+
+		theURL			--> URL de la página que queremos mostrar en el pop up
+		theWinName		--> Nombre que daremos a la nueva ventana
+		theWidth		--> Anchura de la ventana
+		theHeight		--> Altura de la ventana
+		hasScrollBars	--> Flag que indica si queremos que aparezca barra de desplazimiento
+
+	+	+	+	+	+	+	+	+	+	+	+	+	+	+	+ */

	function perfectOpen(theURL,theWinName,theWidth,theHeight,hasScrollBars){
		jsWinFormat	=	'width='+theWidth+', height='+theHeight;
		/*
		if (hasScrollBars!=0) {
			jsWinFormat = jsWinFormat + ',scrollbars=yes';			
		}
		else
			jsWinFormat	+= ',scrollbars=no';
		*/
		
		if (hasScrollBars==0){
			jsWinFormat += ',scrollbars=0';
		}
		else
			jsWinFormat += ',scrollbars=1';
			 
		theNewWin=window.open(theURL,theWinName,jsWinFormat);
		winCenter(theNewWin,theWidth,theHeight);
		theNewWin.focus();
	}

//	+	+	+	+	+	+	+	+	+	+	+	+	+	+	+



/*  +	+	+	+	+	+	+	+	+	+	+	+	+	+	+
+
+	function winCenter(theWinObject,theWinWidth,theWinHeight)
+		Centra en pantalla la ventana pasada como primer parámetro
+
+		theWinObject	--> Objeto ventana que vamos a centrar
+		theWinWidth		--> Anchura de la ventana
+		theWinHeight	--> Altura de la ventana
+
+	+	+	+	+	+	+	+	+	+	+	+	+	+	+	+ */

	function winCenter(theWinObject,theWinWidth,theWinHeight){
			xW= (screen.width - theWinWidth)/2;
			yW= (screen.height - theWinHeight)/2;
			theWinObject.moveTo(xW,yW);
	}
	
//	+	+	+	+	+	+	+	+	+	+	+	+	+	+	+



/*  +	+	+	+	+	+	+	+	+	+	+	+	+	+	+
+
+	function winCenter(theWinObject,theWinWidth,theWinHeight)
+		Centra en pantalla la ventana pasada como primer parámetro
+
+		theWinObject	--> Objeto ventana que vamos a centrar
+		theWinWidth		--> Anchura de la ventana
+		theWinHeight	--> Altura de la ventana
+
+	+	+	+	+	+	+	+	+	+	+	+	+	+	+	+ */

	function winCenter(theWinObject,theWinWidth,theWinHeight){
			xW= (screen.width - theWinWidth)/2;
			yW= (screen.height - theWinHeight)/2;
			theWinObject.moveTo(xW,yW);
	}
	
//	+	+	+	+	+	+	+	+	+	+	+	+	+	+	+



/*  +	+	+	+	+	+	+	+	+	+	+	+	+	+	+
+
+	function openCenteredWindow(theURL,theWidth,theHeight)
+		Abre una ventana centrada en la pantalla.
+
+		theURL		--> URL que queremos abrir
+		theWinName	--> Nombre de la nueva ventana
+		theWidth	--> Anchura de la ventana
+		theHeight	--> Altura de la ventana
+
+	+	+	+	+	+	+	+	+	+	+	+	+	+	+	+ */

	
	function openCenteredWindow(theURL,theWinName,theWidth,theHeight) {
		var myWindow;
	    
	    var left = parseInt((screen.availWidth/2) - (theWidth/2));
	    var top = parseInt((screen.availHeight/2) - (theHeight/2));
	    var windowFeatures = "width=" + theWidth + ",height=" + theHeight + 
	        ",status,resizable=no,scrollbars=yes,left=" + left + ",top=" + top + 
	        ",screenX=" + left + ",screenY=" + top;
	    myWindow = window.open(theURL, theWinName, windowFeatures);
		myWindow.focus();
	}
	
//	+	+	+	+	+	+	+	+	+	+	+	+	+	+	+

