	
/*Tecknosfera DBNET S.L.
	Element: Dynamic Combo Box
	Programed by: francisco_javier_martinez@hotmail.com
	To : Tecknosfera DBNET S.L.
*/

var separatorValueText = "¬"

/********************************************************************************************************************************************************************
	Global vars to DEFAULT COMBOBOX
*********************************************************************************************************************************************************************/
var defaultComboWidth = 200;
var defaultComboHeight = 16;

var defaultComboVisibleElements = 9;

var defaultComboBGColor = "#FFFFFF";
var defaultContentHeight = 200;

// Vars to the RollOver Contents
var defaultComboBGColorContent = "#FFFFFF";
var defaultComboBGColorContentRollOver = "#FFF5D0";
var defaultComboBorderColor = "#9C9C9C";
var defaultContentStyleFontColorRollOver = "#FFFFFF"


// the specific Vars to the Selector Item
var defaultImageSelector = "../../js/img/selector_0.gif";
var defaultSelectorWidth = 15;
var defaultSelectorHeight = 16;

// The Scroll
var defaultWidthScrollArrowContent = 18;
var defaultHeightScrollArrowContent = 18;

var defaultWidthDragArrowContent = 18;
var defaultHeightDragArrowContent = 20;

var defaultTheScrollImgUp = "../../js/img/scrollUp_1.gif";
var defaultTheScrollImgDown = "../../js/img/scrollDown_1.gif";
var defaultTheScrollImgTrack = "../../js/img/scrollTrack_1.gif";
var defaultTheScrollImgDrag = "../../js/img/scrollDrag_1.gif";
var defaultTheScrollBackgroundImage = "../../js/img/scrollBackground.gif";
var defaultTransparentImage = "../../js/img/trasnparentImage.gif";

var defaultSpeed = 15;

// The variable Vars to personaliced the Combobox
var defaultContentPadding = "0px 2px 4px 3px"; // Select the Top, Right, Bottom, Left Padding

var defaultContentStyleFont = "Arial";
var defaultContentStyleFontSize = 12;
var defaultContentStyleFontColor = "#000000";
var defaultContentStyleFontDecoration = "none";
var defaultContentStyleFontWeight = "";
var defaultContentStyleLineHeight = defaultContentStyleFontSize;

// Avances rapidosw (RePag y AvPag)
var defaultRePagLines = 4;
var defaultAvPagLines = defaultRePagLines;

/*********************************************************************************************************************************************************************
	The variable Vars to personaliced the Combobox
*********************************************************************************************************************************************************************/
var contentPadding = defaultContentPadding; // Select the Top, Right, Bottom, Left Padding

var contentStyleFont = defaultContentStyleFont;
var contentStyleFontSize = defaultContentStyleFontSize;
var contentStyleFontColor = defaultContentStyleFontColor;
var contentStyleFontDecoration = defaultContentStyleFontDecoration;
var contentStyleFontWeight = defaultContentStyleFontWeight;
var contentStyleLineHeight = defaultContentStyleLineHeight;

// Avances rapidosw (RePag y AvPag)
var rePagLines = defaultRePagLines;
var avPagLines = defaultAvPagLines;

// The ID to the ComboBox
var theID = "comboID";
var theNAME = "comboNAME";

combos = new Object();

var idsCombos = 0;
if(document.forms.length > 0)
{
	var contForms = null;
	for(contForms=0;contForms<document.forms.length;contForms++) // Crossing the Forms on the page
	{
		var contElementsForm = null;
		for(contElementsForm=0;contElementsForm<document.forms[contForms].elements.length;contElementsForm++)
		{
			if(document.forms[contForms].elements[contElementsForm].nodeName.toLowerCase() == "select")
			{
				var tdContentCombo = document.forms[contForms].elements[contElementsForm].parentNode;
				if(tdContentCombo.nodeName.toLowerCase() == "td")
				{
					if(document.forms[contForms].elements[contElementsForm].id == "")
					{
						document.forms[contForms].elements[contElementsForm].id = idsCombos;
						tdContentCombo.id = "contenedor" + document.forms[contForms].elements[contElementsForm].id;
						idsCombos++;
					}
					else
					{
						tdContentCombo.id = "contenedor" + document.forms[contForms].elements[contElementsForm].id;
					}
					tdContentCombo.style.position = "relative";
//					tdContentCombo.style.display = "inline-block";
					
					theID = document.forms[contForms].elements[contElementsForm].id;
					combos[theID] = new Object();
					combos[theID].id = theID
					
					theNAME = document.forms[contForms].elements[contElementsForm].name;
					combos[theID].name = theNAME;				
					
					// Leemos los datos del Combo
					readData(document.forms[contForms].elements[contElementsForm],combos[theID]);
					// Configuramos esl estilo del combo segun lo que eleemos del SELECT inicial
					configureComboStyle(document.forms[contForms].elements[contElementsForm],combos[theID]);
					
					// Instanciamos la imagen del selector dentro del combo
					combos[theID].imageSelector = new Object();
					combos[theID].imageSelector.src = defaultImageSelector;
					combos[theID].imageSelector.width = defaultSelectorWidth;
					combos[theID].imageSelector.height = defaultSelectorHeight;
					combos[theID].imageSelector.border = "0";
					combos[theID].imageSelector.title = "Pulsa para desplegar el combo";
	
					// Instanciamos el contenido dentro del combo
					combos[theID].content = new Object();
					combos[theID].content.height = defaultContentHeight;
					
					// Instanciamos el Scroll dentro del Combo
					combos[theID].scroll = new Object();
					combos[theID].scroll.width = defaultWidthScrollArrowContent;
					combos[theID].scroll.height = defaultHeightScrollArrowContent;
					
					combos[theID].scroll.speed = defaultSpeed;

					combos[theID].scroll.images = new Object();
					combos[theID].scroll.images.background = new Object();
					combos[theID].scroll.images.background.src = defaultTheScrollBackgroundImage;
					
					combos[theID].scroll.images.up = new Object();
					combos[theID].scroll.images.up.src = defaultTheScrollImgUp;
					combos[theID].scroll.images.up.width = defaultWidthScrollArrowContent;
					combos[theID].scroll.images.up.height = defaultHeightScrollArrowContent;

					combos[theID].scroll.images.track = new Object();
					combos[theID].scroll.images.track.src = defaultTheScrollImgTrack;

					combos[theID].scroll.images.drag = new Object();
					combos[theID].scroll.images.drag.src = defaultTheScrollImgDrag;
					combos[theID].scroll.images.drag.width = defaultWidthDragArrowContent;
					combos[theID].scroll.images.drag.height = defaultHeightDragArrowContent;
					
					combos[theID].scroll.images.down = new Object();
					combos[theID].scroll.images.down.src = defaultTheScrollImgDown;
					combos[theID].scroll.images.down.width = defaultWidthScrollArrowContent;
					combos[theID].scroll.images.down.height = defaultHeightScrollArrowContent;
				
										
					
					newCombo(contElementsForm,combos[theID]);
					contElementsForm--;
				}
			}
		}
		
		// Define the specific vars
	}
}

function readData(initialObjSelect,theComboObject)
{
	theComboObject.options = new Array();
	
	for(contData=0;contData<initialObjSelect.options.length;contData++)
	{
		theComboObject.options[contData] = new Object();
		theComboObject.options[contData].label = initialObjSelect.options[contData].text;
		theComboObject.options[contData].value = initialObjSelect.options[contData].value;
	}
}

function getPropertyStyle(obj,atr)
{
	if (document.defaultView && document.defaultView.getComputedStyle && document.body)
	{
		/*
			Para atributos de estilo de varias palabras Mozilla y Opera, no sigue las  mismas reglas de eliminar el guión y poner en mayúscula  la primera letra de las palabra que precede al guión, por ejemplo:
    	* border-top-color en IE sería borderTopColor, mientras que Mozilla y Opera8 se mantiene igual
		
			Lo que hay entre // es la Regex en si.
			El modificador g amplia el ámbito a global de la Regex (es el indicador para que haga el REPLACE en todas las ocurrencias de la frase)
		 	-$1 Indica el valor que ha encontrado (referencia al valor que encuentra, que lo sistituya pop - EL_VALOR*/
		atr = atr.replace(/([A-Z])/g,"-$1").toLowerCase();
		return (document.defaultView.getComputedStyle(obj,null).getPropertyValue(atr));
	}
	else
	{
		if (document.body && document.body.currentStyle)
		{
            return(obj.currentStyle[atr]);
        }
    }
}


// Function to capture the style, css, class of the combo
function configureComboStyle(initialObjSelect,theComboObject)
{
	var theStyle = new Object();
	
	// Define the Style of the object
	theComboObject.style = new Object();
	
	// Definimos el color de Borde del Combo
	theComboObject.style.comboBorderColor = defaultComboBorderColor;
	
	// Definimos le color de Fondo del Combo
	theComboObject.style.comboBGColorContent = defaultComboBGColorContent;
	theComboObject.style.comboBGColorContentRollOver = defaultComboBGColorContentRollOver
	
	// Definimos los margenes que ha de usar el combno para posicionar su contenido
	theComboObject.style.contentPadding = defaultContentPadding;

	// Definimos el color de fondo
	if(getPropertyStyle(initialObjSelect,"backgroundColor") != "transparent")
	{
		theComboObject.style.comboBGColorContent = colorToHEX(getPropertyStyle(initialObjSelect,"backgroundColor"));
		theComboObject.style.comboBGColor = colorToHEX(getPropertyStyle(initialObjSelect,"backgroundColor"));
	}
	else
	{
		theComboObject.style.comboBGColorContent = defaultComboBGColorContent;
		theComboObject.style.comboBGColor = defaultComboBGColorContent;
	}
	
	// Definimos la Fuente del combo
	if(getPropertyStyle(initialObjSelect,"fontFamily") != "MS Shell Dlg" && getPropertyStyle(initialObjSelect,"fontFamily") != "Arial" && initialObjSelect.style.fontFamily != "")
	{
		theComboObject.style.contentStyleFont = getPropertyStyle(initialObjSelect,"fontFamily");
	}
	else
	{
		theComboObject.style.contentStyleFont = defaultContentStyleFont;
	}

	// Definimos el Ancho del combo (Preguntamos y aplicamos el initialObjSelect.style.width porque el getPropertyStyle(initialObjSelect,"width") en FF descuenta bordes y margenes)
	// Definimos el Alto del combo
	if(initialObjSelect.style.width != "")
	{
		theComboObject.width = initialObjSelect.style.width;
	}
	else
	{
		theComboObject.width = defaultComboWidth;
	}

	// Definimos el Ancho del combo (Preguntamos y aplicamos el initialObjSelect.style.width porque el getPropertyStyle(initialObjSelect,"width") en FF descuenta bordes y margenes)
	// Definimos el Alto del combo
	if(initialObjSelect.style.height != "")
	{
		theComboObject.height = initialObjSelect.style.height;
	}
	else
	{
		theComboObject.height = defaultComboHeight;
	}
	
	// Definimos una variable que estipula los elementos que queremos que se vean inicialmente en el combo, de forma independiente a la altura del mismo
	theComboObject.visibleElements = defaultComboVisibleElements;
		
	// Definimos la Fuente del combo
	theComboObject.style.contentStyleFontSize = getPropertyStyle(initialObjSelect,"fontSize");
	
	// Definimos el alto de la línea
	theComboObject.style.contentStyleLineHeight = defaultContentStyleLineHeight + 4;
	

	// Definimos el Color de la  Fuente del combo
	theComboObject.style.contentStyleFontColor = colorToHEX(getPropertyStyle(initialObjSelect,"color"));

	// Definimos la decoración del Texto
	theComboObject.style.contentStyleFontDecoration = getPropertyStyle(initialObjSelect,"textDecoration");
	
	// Definimos el Grosor de la fuente
	theComboObject.style.contentStyleFontWeight = getPropertyStyle(initialObjSelect,"fontWeight");	
	
	// Definimos la imagen transparete que se va a usar en las tapas en el caso de que sea Opera
	theComboObject.transparentImage = defaultTransparentImage;
}


// Function to create the Dynamic Combobox
function newCombo(tabIndex,theComboObject)
{

	capaPrincipal = ("\<table cellpadding='0' cellspacing='0' border='0' id='generalTable" + theComboObject.id + "' >");
	capaPrincipal += ("\<tr>\<td align='left'>");
	capaPrincipal += ("\<table cellpadding='0' cellspacing='0' border='0' style='height:" + theComboObject.height + "px;width:" + parseInt(theComboObject.width) + "px;border:1px solid " + theComboObject.style.comboBorderColor + "' id='combo" + theComboObject.id + "'>")

	capaPrincipal += ("\<tr>");
	// The TD for the content
	capaPrincipal += ("\<td id=tableTdInput" + theComboObject.id + " width='" + (parseInt(theComboObject.width) - parseInt(theComboObject.imageSelector.width) - 4) + "' height='" + (parseInt(theComboObject.height) - 2) + "' style='background-color:" + theComboObject.style.comboBGColor + ";'>");

	capaPrincipal += ("\<table cellpadding='0' cellspacing='0' width='" + (parseInt(theComboObject.width) - parseInt(theComboObject.imageSelector.width) - 4) + "' height=" + (parseInt(theComboObject.height) - 4) + " border='0' style='border:1px solid " + theComboObject.style.comboBGColor + ";border-width: 1px 0px 1px 1px;'>");
	capaPrincipal += ("\<tr>");

	capaPrincipal += ("\<td id='tdInput_" + theComboObject.id + "' width='" + (parseInt(theComboObject.width) - parseInt(theComboObject.imageSelector.width) - 2) + "' height='" + (parseInt(theComboObject.height) - 4) + "' style='background-color:" + theComboObject.style.comboBGColor + ";margin:" + theComboObject.style.contentPadding + ";font-family:" + theComboObject.style.contentStyleFont + ";font-size:" + theComboObject.style.contentStyleFontSize + ";color:" + theComboObject.style.contentStyleFontColor + ";text-decoration:" + theComboObject.style.contentStyleFontDecoration + ";font-weight:" + theComboObject.style.contentStyleFontWeight + ";padding-left: 3px'  valign='middle' align='left'>\<\/td>");


	capaPrincipal += ("\<\/tr>\<\/table>\<\/td>");
	// The TD for the Selector	
	capaPrincipal += ("\<td id='tdTheSelector_" + theComboObject.id +  "' width='" + (parseInt(theComboObject.imageSelector.width)  + 1) + "' style='height:" + (parseInt(theComboObject.height) - 2) + ";background-color:" + theComboObject.style.comboBGColor + ";' align='right' valign='middle' onclick=showCombo(this);>")
	capaPrincipal += ("\<img src='" + theComboObject.imageSelector.src + "' border='" + theComboObject.imageSelector.border + "' id='theSelector_" + theComboObject.id + "' width=" + parseInt(theComboObject.imageSelector.width) + " height=" + parseInt(theComboObject.imageSelector.height) + " title='" + theComboObject.imageSelector.title + "' onclick='showCombo(this)' onmouseover=overSelector('" + theComboObject.id + "','theSelector_') onmouseout=overSelector('" + theComboObject.id + "','theSelector_') onmousedown=pressSelector('" + theComboObject.id + "','theSelector_') onmouseup=pressSelector('" + theComboObject.id + "','theSelector_')>");

	capaPrincipal += ("\<\/td>");

	// Make a INPUT TYPE TEXT to saw the selected element and use to POST the value Form	
	capaPrincipal += ("\<td id='tdInputHidden_" + theComboObject.id +  "' style='width:1px;background-color:" + theComboObject.style.comboBGColor + ";' align='right' valign='top'>\<input type='text' id='input_" + theComboObject.id + "' name='input_" + theComboObject.id +  "' style='border:none;width:1px;height:1px;background-color:" + theComboObject.style.comboBGColor + "' value='' onfocus=focalizeCombo('" + theComboObject.id + "',this); onblur=focalizeCombo('" + theComboObject.id + "',this) onkeydown=documentKeyDown(event) tabindex='" + tabIndex + "'>\<input type='hidden' id='inputHidden_" + theComboObject.id + "' name='" + theComboObject.name +  "' value='' style='background-color:" + theComboObject.style.comboBGColor + "'>\<\/td>");

	capaPrincipal += ("\<\/tr>\<\/table>");

	capaPrincipal += ("\<\/td>\<\/tr>\<\/table>");
	document.getElementById("contenedor" + theComboObject.id).innerHTML = capaPrincipal;

	createContent(theComboObject);
	
	// Location the Combo DIVS
	var positionContentLeft = LIB_navigator.findLeftObj(document.getElementById("contenedor" + theComboObject.id)) + parseInt(document.getElementById("generalTable" + theComboObject.id).offsetLeft) + 1;
	var positionContentTop = LIB_navigator.findTopObj(document.getElementById("contenedor" + theComboObject.id)) + parseInt(document.getElementById("generalTable" + theComboObject.id).offsetTop);


	document.write("\<div id='tapaTexto_" + theComboObject.id + "' name='tapaTexto_" + theComboObject.id + "' style='visibility:visible;position:absolute;inline-block;border:none;left:" + positionContentLeft + "px;top:" + positionContentTop + "px;z-index:5;width:" + parseInt(theComboObject.width) + "px;height:" + parseInt(theComboObject.height) + "px;background-image: url(" + theComboObject.transparentImage + ");' onclick=showCombo(this); onmousewheel=moveContentWheel('" + theComboObject.id + "',event) onmouseover=overSelector('" + theComboObject.id + "','theSelector_') onmouseout=overSelector('" + theComboObject.id + "','theSelector_') onmousedown=pressSelector('" + theComboObject.id + "','theSelector_') onmouseup=pressSelector('" + theComboObject.id + "','theSelector_')>\<\/div>");

	colocateContent(theComboObject.id);

	selectOption(theComboObject.id,0);
}

// function to create de content of the combo
function createContent(theComboObject)
{
	document.write("\<div id='divContent" + theComboObject.id + "' style='visibility:visible;display:inline-block;border:1px solid " + theComboObject.style.comboBorderColor + ";overflow:hidden;left:0px;top:0;z-index:3;position:absolute;inline-block;width:" + parseInt(theComboObject.width)  + "px;height:" + parseInt(theComboObject.content.height) + "px;background-color:" + theComboObject.style.comboBGColorContent + "'>");
	document.write("\<div id='content" + theComboObject.id + "' style='position: relative;left: 0;top: 0;width:" + parseInt(theComboObject.width) + "px;visibility: visible;z-index:1;'>");
	// Parche para Firefox, que se desencuadra
	switch(LIB_navigator.getName())
	{
		case "Firefox":
			document.getElementById("divContent" + theComboObject.id).style.width = (parseInt(document.getElementById("divContent" + theComboObject.id).style.width) - 2);
			document.getElementById("divContent" + theComboObject.id).style.height = (parseInt(document.getElementById("divContent" + theComboObject.id).style.height) - 1);
		break;
		case "Netscape":
			document.getElementById("divContent" + theComboObject.id).style.width = (parseInt(document.getElementById("divContent" + theComboObject.id).style.width) - 2);
			document.getElementById("divContent" + theComboObject.id).style.height = (parseInt(document.getElementById("divContent" + theComboObject.id).style.height) - 1);
		break;
	}
	
	// Creamos la estructura de datos
	document.write("\<table cellpadding='3' cellspacing='0' border='0' name='tableDiv_" + theComboObject.id + "' id='tableDiv_" + theComboObject.id + "' style='width:" + parseInt(theComboObject.width) + ";' onmousewheel=moveScrollWheel('" + theComboObject.id + "',event)>");
	document.getElementById("tableDiv_" + theComboObject.id).style.borderTop = "0px";
	if(combos[theComboObject.id].options != null)
	{
		for(var i=0;i < combos[theComboObject.id].options.length;i++)
		{
			// El contenido REAL. Este es el TR que se verá. Todos los datos tendrán como máximo el límite de caracteres estipulados
			document.write("\<tr style='cursor:default;background-color:" + theComboObject.style.comboBGColorContent + ";' name=trTableDiv" + i + "_" + theComboObject.id + "' id='trTableDiv" + i + "_" + theComboObject.id + "' onmouseover='rollOverContent(this)' onmouseout='rollOverContent(this)'>");
			
			// Redefinition of the height of the line
			var theLineHeight = (parseInt(theComboObject.height) - 2)

			document.write("\<td style='width:" + parseInt(theComboObject.width) + ";height:" + theLineHeight + "px;line-height:" + theComboObject.style.contentStyleLineHeight + "px;font-family:" + theComboObject.style.contentStyleFont + ";font-size:" + theComboObject.style.contentStyleFontSize + ";color:" + theComboObject.style.contentStyleFontColor + ";text-decoration:" + theComboObject.style.contentStyleFontDecoration + ";font-weight:" + theComboObject.style.contentStyleFontWeight + "' name='tdTrTableDiv" + i + "_" + theComboObject.id + "' id='tdTrTableDiv" + i + "_" + theComboObject.id + "' onclick=selectOption('" + theComboObject.id + "'," + i + ");focalizeCombo('" + theComboObject.id + "',this) title='" + theComboObject.options[i].value + "'>");
	
			var textOption = theComboObject.options[i].label;
			var maxWidthDataCell = parseInt(theComboObject.width) - 27;

			document.write(breakText(document.getElementById("tdTrTableDiv" + i + "_" + theComboObject.id), textOption,maxWidthDataCell,theComboObject.id));
		
			document.write("\<\/td>");
			document.write("\<\/tr>");
		}
	}

	document.write("\<\/table>");
	
	// Guardo la altura de TODO el contenido, para ver si tengo que generar scroll
	var heightContent = document.getElementById("tableDiv_" + theComboObject.id).offsetHeight;
	var heightDivContet = document.getElementById("divContent" + theComboObject.id).offsetHeight;

	document.write("\<\/div>");
	document.write("\<\/div>");
	
	if(parseInt(theComboObject.content.height) < parseInt(document.getElementById("tableDiv_" + theComboObject.id).offsetHeight))
	{
		createScroll(theComboObject);
	}

	document.write("\<iframe id='iframeOcultoCombo_" + theComboObject.id + "' src='' scrolling='no' frameborder='1' style='position:absolute;inline-block;top:0px; left:0px; display:none;width:0px;height:0px'>\<\/iframe>");

	
	// Controla para ver si los contenidos ocupan menos del alto que queremos darle al combo. Si ocupan menos, reducimos de lato la capa general de Contenidos
	divGeneralContent = document.getElementById("divContent" + theComboObject.id);
	divContents = document.getElementById("content" + theComboObject.id);
	if(divContents.offsetHeight < divGeneralContent.offsetHeight)
	{
		divGeneralContent.style.height = divContents.offsetHeight;
	}

	document.getElementById("divContent" + theComboObject.id).style.visibility = "hidden";
	document.getElementById("divContent" + theComboObject.id).style.display = "none";

}


// function to create a ScrollBars in the content Div
function createScroll(theComboObject)
{
	var objDivContent = document.getElementById("divContent" + theComboObject.id);
	
	document.write("\<div id='scrollBackground" + theComboObject.id + "' style='position:absolute;width:" + parseInt(theComboObject.scroll.width) + "px;height:" + (parseInt(theComboObject.content.height) - 1) + "px;left:0px; top:0px; z-index:3; cursor:pointer;background-image: url(" + theComboObject.scroll.images.background.src + ");'>\<\/div>");

	// Write the UP Arrow Scroll
	document.write("\<div id='tapaUp" + theComboObject.id + "' style='position:absolute;width:" + parseInt(theComboObject.scroll.images.up.width) + "px;height:" + theComboObject.scroll.images.up.height + "px;left:0px; top:0px; z-index:4; cursor:pointer;background-image: url(" + theComboObject.transparentImage + ");' onmousedown=pressSelector('" + theComboObject.id + "','imgUp');scroll(" + theComboObject.scroll.speed + ",'" + theComboObject.id + "') onmouseup=pressSelector('" + theComboObject.id + "','imgUp');stopScroll() onmouseout=stopScroll() onmouseover=stopScroll()>\<\/div>");


	document.write("\<div id='up" + theComboObject.id + "' style='position:absolute;width:" + parseInt(theComboObject.scroll.images.up.width) + "px;height:" + theComboObject.scroll.images.up.height + "px;left:0px; top:0px; z-index:3; cursor:pointer;'>\<img src='" + theComboObject.scroll.images.up.src + "' id='imgUp" + theComboObject.id + "' width='" + parseInt(theComboObject.scroll.width) + "' height='" + theComboObject.scroll.height + "' onmousedown=scroll(" + theComboObject.scroll.speed + ",'" + theComboObject.id + "') onmouseup='stopScroll()' onmouseout='stopScroll()' onmouseover='stopScroll()'>\<\/div>");
	// Calculate the height of the TRACK

	var trackHeight = objDivContent.offsetHeight - (parseInt(theComboObject.scroll.height) * 2);
	// Write the Track Scroll
	document.write("\<div id='track" + theComboObject.id + "' style='position:absolute;width:" + parseInt(theComboObject.scroll.width) + "px;height:" + trackHeight + "px;left:0px; top:0px; z-index:4;background-image: url(" + theComboObject.scroll.images.track.src + ");' onmousedown=scrollJump('" + theComboObject.id + "',event)>\<\/div>");

	// Write the Drag Item of the Scroll
	document.write("\<div id='tapaDrag" + theComboObject.id + "' style='position:absolute;width:" + parseInt(theComboObject.scroll.images.drag.width) + ";height:" + theComboObject.scroll.images.drag.height + "px;left:0px; top:0px; z-index:6; cursor:pointer;background-image: url(" + theComboObject.transparentImage + ");' onmousedown=pressSelector('" + theComboObject.id + "','imgDrag');startDrag('" + theComboObject.id + "',event) onmouseup=pressSelector('" + theComboObject.id + "','imgDrag');>\<\/div>");

	document.write("\<div id='drag" + theComboObject.id + "' style='position:absolute;width:" + parseInt(theComboObject.scroll.images.drag.width) + ";height:" + theComboObject.scroll.images.drag.height + "px;left:0px; top:0px; z-index:5; cursor:pointer;'>\<img src='" + theComboObject.scroll.images.drag.src + "' id='imgDrag" + theComboObject.id + "' width='" + parseInt(theComboObject.scroll.images.drag.width) + "' height='" + theComboObject.scroll.images.drag.height + "' border='0' onmousedown=startDrag('" + theComboObject.id + "',event)>\<\/div>");

	// Write the DOWN Arrow
	document.write("\<div id='tapaDown" + theComboObject.id + "' style='position:absolute; width:" + parseInt(theComboObject.scroll.images.down.width) + "px;height:" + theComboObject.scroll.images.down.height + "px;left:0px; top:0px; z-index:4; cursor:pointer;background-image: url(" + theComboObject.transparentImage + ");' onmousedown=pressSelector('" + theComboObject.id + "','imgDown');scroll(" + -theComboObject.scroll.speed + ",'" + theComboObject.id + "') onmouseup=pressSelector('" + theComboObject.id + "','imgDown');stopScroll() onmouseout='stopScroll()' onmouseover='stopScroll()'>\<\/div>");


	document.write("\<div id='down" + theComboObject.id + "' style='position:absolute; width:" + parseInt(theComboObject.scroll.images.down.width) + "px;height:" + theComboObject.scroll.images.down.height + "px;left:0px; top:0px; z-index:3; cursor:pointer;'>\<img src='" + theComboObject.scroll.images.down.src + "' id='imgDown" + theComboObject.id + "' width='" + parseInt(theComboObject.scroll.images.down.width) + "' height='" + theComboObject.scroll.images.down.height + "' onmousedown=scroll(" + -theComboObject.scroll.speed + ",'" + theComboObject.id + "') onmouseup='stopScroll()' onmouseout='stopScroll()' onmouseover='stopScroll()'>\<\/div>");

	document.getElementById("imgDown" + theComboObject.id).width = document.getElementById("imgDown" + theComboObject.id).offsetWidth;
	document.getElementById("imgDown" + theComboObject.id).height = document.getElementById("imgDown" + theComboObject.id).offsetHeight;
	colocateScroll(document.getElementById("divContent" + theComboObject.id));
	showScroll(theComboObject.id,"hidden");
}


function colocateScroll(objDivContent)
{
	var idScrollBar = objDivContent.id.split("divContent")[1];
	if(parseInt(combos[idScrollBar].content.height) < parseInt(document.getElementById("tableDiv_" + idScrollBar).offsetHeight))
	{
		var alto_pantalla = document.body.clientHeight + document.documentElement.scrollTop + document.body.scrollTop;
		if((LIB_navigator.findTopObj(document.getElementById("contenedor" + idScrollBar)) + parseInt(document.getElementById("generalTable" + idScrollBar).offsetTop) + parseInt(document.getElementById("generalTable" + idScrollBar).offsetHeight) + parseInt(document.getElementById("divContent" + idScrollBar).offsetHeight)) >= (parseInt(alto_pantalla) - 4 ))
		{
			// Recolocate the Row UP to the real place of the Combo Content
			document.getElementById("up" + idScrollBar).style.top = objDivContent.offsetTop + 2;
			document.getElementById("scrollBackground" + idScrollBar).style.top = objDivContent.offsetTop + 1;
		}
		else
		{
			// Recolocate the Row UP to the real place of the Combo Content
			document.getElementById("up" + idScrollBar).style.top = objDivContent.offsetTop + 1;
			document.getElementById("scrollBackground" + idScrollBar).style.top = objDivContent.offsetTop;
		}

		document.getElementById("up" + idScrollBar).style.left = objDivContent.offsetLeft + parseInt(objDivContent.offsetWidth) - parseInt(document.getElementById("imgUp" + idScrollBar).offsetWidth) - 1;
		document.getElementById("tapaUp" + idScrollBar).style.top = document.getElementById("up" + idScrollBar).style.top;
		document.getElementById("tapaUp" + idScrollBar).style.left = objDivContent.offsetLeft + parseInt(objDivContent.offsetWidth) - parseInt(document.getElementById("imgUp" + idScrollBar).offsetWidth) - 1;	

		// Recolocate the TRACK to the real place of the Combo Content
		document.getElementById("track" + idScrollBar).style.top = parseInt(document.getElementById("up" + idScrollBar).style.top) + parseInt(document.getElementById("imgUp" + idScrollBar).height)+1;
		document.getElementById("track" + idScrollBar).style.left = document.getElementById("up" + idScrollBar).style.left;
	
		// Recolocate the DRAG element to the real place of the Combo Content
		document.getElementById("tapaDrag" + idScrollBar).style.top = parseInt(document.getElementById("up" + idScrollBar).style.top) + parseInt(document.getElementById("imgDrag" + idScrollBar).height) - 2;
		document.getElementById("tapaDrag" + idScrollBar).style.left = parseInt(document.getElementById("up" + idScrollBar).style.left);
		
		document.getElementById("drag" + idScrollBar).style.top = parseInt(document.getElementById("up" + idScrollBar).style.top) + parseInt(document.getElementById("imgDrag" + idScrollBar).height) - 3;
		document.getElementById("drag" + idScrollBar).style.left = parseInt(document.getElementById("up" + idScrollBar).style.left) ;
	
		// Recolocate the TRACK to the real place of the Combo Content
		document.getElementById("tapaDown" + idScrollBar).style.top = parseInt(document.getElementById("track" + idScrollBar).style.top) + parseInt(document.getElementById("track" + idScrollBar).offsetHeight) - 3;
		document.getElementById("tapaDown" + idScrollBar).style.left = parseInt(document.getElementById("up" + idScrollBar).style.left) + 1;
		document.getElementById("down" + idScrollBar).style.top = parseInt(document.getElementById("track" + idScrollBar).style.top) + parseInt(document.getElementById("track" + idScrollBar).offsetHeight) - 3;
		
		document.getElementById("down" + idScrollBar).style.left = parseInt(document.getElementById("up" + idScrollBar).style.left);
		
		document.getElementById("scrollBackground" + idScrollBar).style.left = document.getElementById("up" + idScrollBar).style.left;
		
		// Parcheamos la posición del elemento UP (desde el qque se recolocan todos los del Scroll) para los diferentes navegadores
		switch(LIB_navigator.getName())
		{
			case "Firefox":
				document.getElementById("down" + idScrollBar).style.top = parseInt(document.getElementById("down" + idScrollBar).style.top) - 1;			
			break;
			case "Netscape":
				document.getElementById("down" + idScrollBar).style.top = parseInt(document.getElementById("down" + idScrollBar).style.top) - 1;
			break;
			case "Opera":
				document.getElementById("up" + idScrollBar).style.top = parseInt(document.getElementById("up" + idScrollBar).style.top);
				document.getElementById("imgUp" + idScrollBar).style.top = parseInt(document.getElementById("up" + idScrollBar).style.top);
				document.getElementById("tapaUp" + idScrollBar).style.top = parseInt(document.getElementById("up" + idScrollBar).style.top);
			break;
		}
		
	}
}

function showScroll(idReferer,status)
{
	if(parseInt(combos[idReferer].content.height) < parseInt(document.getElementById("tableDiv_" + idReferer).offsetHeight))
	{
		reloadScrollItems(idReferer)
		var theVisibility;
		var theDisplay;
		if(status == "visible")
		{
			theVisibility = "visible";
			theDisplay = "inline";
		}
		else
		{
			theVisibility = "hidden";
			theDisplay = "none";
		}
		document.getElementById("scrollBackground" + idReferer).style.visibility = theVisibility;
		document.getElementById("scrollBackground" + idReferer).style.display = theDisplay;
		document.getElementById("tapaUp" + idReferer).style.visibility = theVisibility;
		document.getElementById("tapaUp" + idReferer).style.display = theDisplay;
		document.getElementById("up" + idReferer).style.visibility = theVisibility;
		document.getElementById("up" + idReferer).style.display = theDisplay;
		document.getElementById("tapaDown" + idReferer).style.visibility = theVisibility;
		document.getElementById("tapaDown" + idReferer).style.display = theDisplay;
		document.getElementById("down" + idReferer).style.visibility = theVisibility;
		document.getElementById("down" + idReferer).style.display = theDisplay;
		document.getElementById("tapaDrag" + idReferer).style.visibility = theVisibility;
		document.getElementById("tapaDrag" + idReferer).style.display = theDisplay;
		document.getElementById("drag" + idReferer).style.visibility = theVisibility;
		document.getElementById("drag" + idReferer).style.display = theDisplay;
		document.getElementById("track" + idReferer).style.visibility = theVisibility;
		document.getElementById("track" + idReferer).style.display = theDisplay;
	}
}

// Function to reload the status of the Scroll Combo
function reloadScrollItems(idScrollReferer)
{
	document.getElementById("imgUp" + idScrollReferer).src = combos[theID].scroll.images.up.src;
	document.getElementById("imgDown" + idScrollReferer).src = combos[theID].scroll.images.down.src;
	document.getElementById("imgDrag" + idScrollReferer).src = combos[theID].scroll.images.drag.src;
}

// Muestra los contenidos del combo
function showCombo(objReferer)
{
	if(document.getElementById("divContent" + objReferer.id.split("_")[1]).style.display != "none")
	{
		hideCombo();
		document.getElementById("input_" + objReferer.id.split("_")[1]).focus();
		switch(LIB_navigator.getName()) // Focalizamos el combo porque en opera no funciona .focus()
		{
			case "Opera":
				focalizeCombo(objReferer.id.split("_")[1],document.getElementById("tdInput_" + objReferer.id.split("_")[1]))
			break;
		}
		// Ponemos la flecha del desplegable del combo en su estado inicial
		// Ponemos la imagen de ldesplegable como ACTIVADA
		resetSelector(objReferer.id.split("_")[1],"theSelector_");		
	}
	else
	{
		// Ocultamos las capas de contenidos
		hideCombo();
		// Pone las opciones de contenido  en color inicial y remarca la seleccionada
		hideSelectionContent(objReferer.id.split("_")[1]);
		var arrayDivs = document.getElementsByTagName("div");
		var i=null;
		// Recorremos todas las capas del resto de los combos para ponerlas un Z-INDEX inferior, y que el pulsado quede por encima
		for(i=0;i<arrayDivs.length;i++)
		{
			if((arrayDivs[i].id.indexOf("divContent") != -1) && arrayDivs[i].id.indexOf(objReferer.id.split("_")[1])== -1 || arrayDivs[i].id.indexOf("tapaTexto_") != -1)
			{
				if(arrayDivs[i].id.indexOf("divContent") != -1)
				{
					arrayDivs[i].style.zIndex = 3;
				}
				else
				{
					arrayDivs[i].style.zIndex = 0;
				}
			}
		}
		colocateContent(objReferer.id.split("_")[1]);
		// Ponemos los contenidos del combo pulsado VISIBLES
		document.getElementById("divContent" + objReferer.id.split("_")[1]).style.display = "inline";
	
		showScroll(objReferer.id.split("_")[1],"visible");
		colocateScroll(document.getElementById("divContent" + objReferer.id.split("_")[1]));
		// Ponemos la imagen de ldesplegable como ACTIVADA
		overSelector(objReferer.id.split("_")[1],"theSelector_");
		// Ponemos el foco en el INPUT oculto para poder movernos por el combo con flechas, letras y demás
		document.getElementById("input_" + objReferer.id.split("_")[1]).focus();

		switch(LIB_navigator.getName()) // Focalizamos el combo porque en opera no funciona .focus()
		{
			case "Opera":
				focalizeCombo(objReferer.id.split("_")[1],document.getElementById("tdInput_" + objReferer.id.split("_")[1]))
			break;
		}
		moveContentToSelectedItem(objReferer.id.split("_")[1]);
	}
}

// function to hide the selection on the table content
function hideSelectionContent(id)
{
	// Pone las opciones de contenido  en color inicial y remarca la seleccionada
	var tabla = document.getElementById("tableDiv_" + id);
	var filas = tabla.getElementsByTagName("tr").length;
	for(i=0;i<filas;i++)
	{
		if(document.getElementById("tdTrTableDiv" + i + "_" +  id).title == document.getElementById("inputHidden_" +  id).value)
		{
			document.getElementById("trTableDiv" + i + "_" +  id).style.backgroundColor = combos[id].style.comboBGColorContentRollOver;
		}
		else
		{
			document.getElementById("trTableDiv" + i + "_" +  id).style.backgroundColor = combos[id].style.comboBGColor;
		}
	}
}


// function to HIDE the content of the combobox
function hideCombo()
{
	var arrayDivs = document.getElementsByTagName("div");
	var i=null;
	var idElement;
	// Recorremos todas las capas de contenidos y las vamos ocultando
	for(i=0;i<arrayDivs.length;i++)
	{
		if(arrayDivs[i].id.indexOf("divContent") != -1)
		{
			if(arrayDivs[i].style.visibility == "visible")
			{
				showScroll(arrayDivs[i].id.split("divContent")[1],"hidden");
				
				arrayDivs[i].style.visibility = "hidden";
				arrayDivs[i].style.display = "none";
			}
		}
	}
	// REcorrer todos los Iframes que tapan combos, y los ocultamos
	var arrayIframes = document.getElementsByTagName("iframe");
	for(i=0;i<arrayIframes.length;i++)
	{
		if(arrayIframes[i].id.indexOf("iframeOcultoCombo_")!= -1) 
		{
			arrayIframes[i].style.width = "0px";
			arrayIframes[i].style.height = "0px";
			arrayIframes[i].style.display = "none";
		}
	}
}

// Function to select the selected option
function selectOption(id, position)
{
	if(combos[theID].options != null)
	{
		document.getElementById("tdInput_" + id).innerHTML = document.getElementById("tdTrTableDiv" + position + "_" + id).innerHTML.split("...")[0];
		document.getElementById("inputHidden_" + id).value = document.getElementById("tdTrTableDiv" + position + "_" + id).title;
		hideCombo();
//		showCombo(document.getElementById("tapaTexto_" + id))
	}
}

// Función para partit los textos que sean demasiado largos, y ponerles Puntos suspensivos
function breakText(recipientOfText, theTextToBreak, maxLengthText, idComboRerefer)
{
	var estilo = recipientOfText.style;

	document.getElementById("contenedor" + idComboRerefer).innerHTML += "\<span id='hiddenSpan'>\<\/span>";
	var temporalSpan = document.getElementById("hiddenSpan");
	temporalSpan.style.visibility = "hidden";
	temporalSpan.style.fontFamily = estilo.fontFamily
	temporalSpan.style.fontSize = estilo.fontSize;
	temporalSpan.style.fontWeight = estilo.fontWeight;
	temporalSpan.style.letterSpacing = estilo.letterSpacing;
	temporalSpan.style.wordSpacing = estilo.wordSpacing;

	var i=0;

//	alert(parseInt(document.getElementById("hiddenSpan").offsetWidth) + " < " + maxLengthText)
	while(i<theTextToBreak.length && parseInt(document.getElementById("hiddenSpan").offsetWidth) < maxLengthText)
	{
		document.getElementById("hiddenSpan").innerHTML += theTextToBreak.charAt(i);
		i++;
	}
	
	theFinalText = document.getElementById("hiddenSpan").innerHTML;
	document.getElementById("hiddenSpan").innerHTML = "";

	if(theFinalText.length < theTextToBreak.length)
	{
		theFinalText += " ...";
	}
	return(theFinalText);
}
		

// Function to colotate te DIVContent (And the IFRAME of the content)
function colocateContent(idReferer)
{
	var ancho_pantalla =  document.body.clientWidth;
	var alto_pantalla = document.body.clientHeight + document.body.scrollTop;
	
//	alert(document.body.clientHeight + " + " + document.body.scrollTop + " = " + (document.body.clientHeight + document.body.scrollTop))
	
	var divData = document.getElementById("divContent" + idReferer);

//	Recolocar la capa del contenido, dependiendo de si se sale por los límites de la ventana
	if((LIB_navigator.findTopObj(document.getElementById("tapaTexto_" + idReferer)) + parseInt(document.getElementById("generalTable" + idReferer).offsetHeight) + parseInt(document.getElementById("divContent" + idReferer).style.height)) >= (parseInt(alto_pantalla) - 4 )) // Resto 4 para darle un pelin de margen y no ajustoarlo totalmente a la pantalla
	{
		// El scroll se sale por abajo, por lo que se muestra por arriba
		document.getElementById("divContent" + idReferer).style.borderTop = "1px solid " + combos[idReferer].style.comboBorderColor;
		document.getElementById("divContent" + idReferer).style.borderBottom = "0px none";
		
		// Recolocamos por ARRIBA DEL COMBO
		divData.style.top = LIB_navigator.findTopObj(document.getElementById("tapaTexto_" + idReferer)) - parseInt(combos[idReferer].content.height);

	}
	else
	{
		// El scroll se sale por arriba, por lo que se muestra por abajo
		document.getElementById("divContent" + idReferer).style.borderTop = "0px none";
		document.getElementById("divContent" + idReferer).style.borderBottom = "1px solid " + combos[idReferer].style.comboBorderColor;

		// Recolocamos por ABAJO DEL COMBO
		divData.style.top = LIB_navigator.findTopObj(document.getElementById("tapaTexto_" + idReferer)) + parseInt(document.getElementById("tapaTexto_" + idReferer).offsetHeight);
	}

	divData.style.left = LIB_navigator.findLeftObj(document.getElementById("contenedor" + idReferer)) + parseInt(document.getElementById("generalTable" + idReferer).offsetLeft);

	document.getElementById("divContent" + idReferer).style.visibility = "visible";
	colocateScroll(document.getElementById("divContent" + idReferer));
	showScroll(idReferer,"visible");

	if(LIB_navigator.getName() != "Opera")
	{
		// Iframe que va continuamente debajo del Tooltip, para que se pueda mostrar por encima de los Select y TextAreas
		var obj_iframe_oculto = document.getElementById("iframeOcultoCombo_" + idReferer);

	    obj_iframe_oculto.style.opacity='0.0'; // opacity to Netscape (Firefox) Browser
		obj_iframe_oculto.style.filter='alpha(opacity=0)'; // Opacity to IE Browser
		
		obj_iframe_oculto.style.display = "inline";
	    obj_iframe_oculto.style.width = parseInt(divData.offsetWidth);
	    obj_iframe_oculto.style.height = parseInt(document.getElementById("divContent" + idReferer).offsetHeight);
	    obj_iframe_oculto.style.top = parseInt(divData.offsetTop);
	    obj_iframe_oculto.style.left = parseInt(divData.offsetLeft);
	    obj_iframe_oculto.style.zIndex = divData.style.zIndex - 1;
	}
	if(combos[theID].options != null)
	{
		moveContentToSelectedItem(idReferer);
	}
}

// Función que desplaza la capa de contenidos arriba o abajo, dependiendo del elemento que esté seleccionado
function moveContentToSelectedItem(idContent)
{
//	alert(document.getElementById("input_" + idContent).value)
	if(document.getElementById("tdInput_" + idContent).innerHTML == "") // Si no hay ningun elemento seleccionado
	{
		document.getElementById("content" + idContent).style.top = 0;
	}
	else // Si hay un elemento seleccionado, recorremos los datois, y posicionamos la capa en su lugar correspondiente
	{
		var valueSelected = document.getElementById("inputHidden_" + idContent).value.toLowerCase();
		var tabla = document.getElementById("tableDiv_" + idContent);
		var filas = tabla.getElementsByTagName("tr").length;
		var topPosition = null;
		var i=0;
		var encontrado = false;
		var contentRowHeight = parseInt(document.getElementById("tdTrTableDiv0_" +  idContent).offsetHeight)
		while(i<filas && encontrado == false)
		{
//			alert(document.getElementById("tdTrTableDiv" + i + "_" +  idContent).title + " == " + valueSelected)
			if(document.getElementById("tdTrTableDiv" + i + "_" +  idContent).title == valueSelected)
			{
				encontrado = true;
				// Move the content to the selection option
				document.getElementById("content" + idContent).style.top = -(i * contentRowHeight);
				
				
				if(parseInt(combos[idContent].content.height) < parseInt(document.getElementById("tableDiv_" + idContent).offsetHeight))
				{
					colocateScroll(document.getElementById("divContent" + idContent));
				}
			}
			i++;
		}
		if(encontrado == true)
		{
			// Compruebo, que se haya colocado, y no quede hueco bacio por debajo
			var dondeEstoy = contentRowHeight;
			var loQueMequeda = ((filas - i) * contentRowHeight)
			if((dondeEstoy + loQueMequeda) < parseInt(combos[idContent].content.height))
			{
				// Muevo el contenido los pixeles necesarios, para que quede abajo del todo
				document.getElementById("content" + idContent).style.top = -((filas * contentRowHeight) - parseInt(combos[idContent].content.height));
			}
	
			if(parseInt(combos[idContent].content.height) < parseInt(document.getElementById("tableDiv_" + idContent).offsetHeight))
			{
				// Move the Drag element
				dragStartMouse = parseInt(document.getElementById("drag" + idContent).style.top) + (parseInt(document.getElementById("drag" + idContent).offsetHeight) / 2); // Hacemos que agarramos del centro del elemento DRAG
				dragStartOffset = document.getElementById("drag" + idContent).style.top; // Obtenemos la posición del elemento drag
			
				var desplazamientoVertical = 0;
				var situado = false;
				while(situado == false)
				{
					var currentMouse = dragStartMouse + desplazamientoVertical; // vamos añadiendo 1 y vemos si el Scroll del contenido estaría en el lugar correcto
					var mouseDifference = currentMouse - dragStartMouse;
					var dragDistance = parseInt(dragStartOffset) + parseInt(mouseDifference);
					trackTop = parseInt(document.getElementById("up" + idContent).style.top) + parseInt(document.getElementById("up" + idContent).offsetHeight) - 1;
					trackLength = (parseInt(document.getElementById("track" + idContent).offsetHeight) - parseInt(document.getElementById("drag" + idContent).style.height)) - 2;
					trackBottom = trackTop + trackLength;
				
					var dragMovement = (parseInt(dragDistance) < parseInt(trackTop)) ? parseInt(trackTop) : (parseInt(dragDistance) > parseInt(trackBottom)) ? parseInt(trackBottom) : parseInt(dragDistance);
					
					
					contentLength = parseInt(document.getElementById("tableDiv_" + idContent).offsetHeight) - parseInt(document.getElementById("divContent" + idContent).offsetHeight);
				
					scrollLength = trackLength / contentLength; // Height difference between the scrollbar track and the content
					var contentMovement = -(dragMovement - trackTop) * (1 / scrollLength);
	//				alert(contentMovement + " <= " + parseInt(document.getElementById("content" + idContent).style.top) +  " ? " + (contentMovement <= parseInt(document.getElementById("content" + idContent).style.top)))
					if(contentMovement <= parseInt(document.getElementById("content" + idContent).style.top))
					{
						situado = true;
					}
					desplazamientoVertical++;
				}
				if(situado == true)
				{
					document.getElementById("drag" + idContent).style.top = dragMovement;
					document.getElementById("tapaDrag" + idContent).style.top = dragMovement;
				}
			}
			else
			{
				document.getElementById("content" + idContent).style.top = 0;
			}
		}
		else
		{
			document.getElementById("content" + idContent).style.top = 0;
			colocateScroll(document.getElementById("divContent" + idContent));
		}
	}
}

// Function to focalize teh ComboBox
function focalizeCombo(idElement,theObj)
{
	colorInput = colorToHEX(document.getElementById("tdInput_" + idElement).style.backgroundColor);

	// SI el color del combo es el inicial...
	if(colorInput.toLowerCase() == colorToHEX(combos[idElement].style.comboBGColor.toLowerCase()))
	{
		// Ponemos el color del SELECCIONADO
		document.getElementById("tdInput_" + idElement).style.backgroundColor = combos[idElement].style.comboBGColorContentRollOver;
	
		// bucle para desactivar el resto de combos
		var arrayDivs = document.getElementsByTagName("div");
		var i=null;
		for(i=0;i<arrayDivs.length;i++)
		{
			if(arrayDivs[i].id.indexOf("tapaTexto_") != -1)
			{
				if(arrayDivs[i].id.split("_")[1] != idElement) // Si el combo en el que estamos NO ES EL SELECCIONADO.. los vamos desactivando
				{
					var actualID = arrayDivs[i].id.split("_")[1];
					document.getElementById("tdInput_" + actualID).style.backgroundColor = combos[arrayDivs[i].id.split("_")[1]].style.comboBGColor;
				}
			
			}
		}
	}
	else // Si pierde el foco
	{
/*		document.getElementById("tdInput_" + idElement).style.backgroundColor = combos[idElement].style.comboBGColor;
		
		// Si se está mostrando la capa de contenido, lo ocultamos
		if(document.getElementById("divContent" + idElement).style.visibility == "visible")
		{
			// Ocultamos las capas de contenidos
//			hideCombo();
		}*/
	}
}

// Function to make the rollover on the Content Table
function rollOverContent(objReferer)
{
	// borar todas las opciones del combo
	var tabla = document.getElementById("tableDiv_" + objReferer.id.split("_")[1]);
	var filas = tabla.getElementsByTagName("tr").length;

	for(i=0;i<filas;i++)
	{
		document.getElementById("trTableDiv" + i + "_" +  objReferer.id.split("_")[1]).style.backgroundColor = combos[objReferer.id.split("_")[1]].style.comboBGColor;
	}
	
	
	colorTR = colorToHEX(objReferer.style.backgroundColor);

	// If the element have the INITIAL Fore color, put the rollOver Color
//	alert(colorTR.toLowerCase() + " == " + combos[objReferer.id.split("_")[1]].style.comboBGColorContent.toLowerCase())
	if(colorTR.toLowerCase() == colorToHEX(combos[objReferer.id.split("_")[1]].style.comboBGColorContent.toLowerCase()))
	{
		objReferer.style.backgroundColor = combos[objReferer.id.split("_")[1]].style.comboBGColorContentRollOver;
	}
	else
	{
		objReferer.style.backgroundColor = combos[objReferer.id.split("_")[1]].style.comboBGColorContent;
	}
}

// Function to create the event dynamic
function addDinamciEvent(theObject, theEvent, theFunction)
{
	if(theEvent.substr(0,2).toLowerCase() == "on")
	{
		theEvent = theEvent.substr(2,theEvent.length)
	}
	
	if (window.addEventListener) // If the navegator have an EventListener (Firefox and Netscape)
	{
		theObject.addEventListener(theEvent,eval(theFunction),true);
	}
	else // If not Firefox or NetScape
	{
		// If the navigator is IE 5+
		if (window.attachEvent)
		{
			var cadena_evento = "on" + theEvent;
			theObject.attachEvent(cadena_evento,eval(theFunction));
		}
		else // If not IE 5+
		{
			if (document.getElementById)
			{
				theObject.onmouseout = eval(theFunction);
			}
		}
	}
	return(theObject);
}


/*********************************************************************************************************************************
	Dynamic functions to the Document and the Window
*********************************************************************************************************************************/

var theObj = null;
document.onclick = function(evt)
{
	verifyClick(evt)
}

function verifyClick(evt)
{
	var e = (window.event) ? window.event : evt;
	// Definimos que Objeto produjo el Evento
	// Hacemos GLOBAL el objeto pasado como parámetro (e.target = Mozilla)
	theObj = (e.target) ? e.target : ((e.srcElement) ? e.srcElement : null);
	var idEmisorObject = theObj.id.split("_")[0];
	
	// Verificamos que hemos pulsado FUERA del combo
	var actualMouseY = e.clientY + document.body.scrollTop;
	var actualMouseX = e.clientX;

	// Recorro todos los combos y busco cual está señalado
	for(elem in combos)
	{
		// si el combo por le que vamos, está señalado...
		if(colorToHEX(document.getElementById("tdInput_" + combos[elem].id).style.backgroundColor) == colorToHEX(combos[elem].style.comboBGColorContentRollOver))
		{
			var tapaTexto = document.getElementById("tapaTexto_" + combos[elem].id);
			// Si el combo está DESPLEGADO
			if(document.getElementById("divContent" + combos[elem].id).style.display != "none")
			{
				// Verificamos si está desplegado hacia arriba o havcia abajo...
				var divContent = document.getElementById("divContent" + combos[elem].id);
				
				// Si está desplegado POR DEBAJO DE LA TAPA DE TEXTO
				if(LIB_navigator.findTopObj(divContent) > LIB_navigator.findTopObj(tapaTexto))
				{
					
					// Si Pinchamos por ARRIBA de la TAPA del combo o por ABAJO de la TAPA + EL CONTENIDO
					if((actualMouseY > (LIB_navigator.findTopObj(tapaTexto) + tapaTexto.offsetHeight + divContent.offsetHeight)) || (actualMouseY < (LIB_navigator.findTopObj(tapaTexto))) || (actualMouseX > (LIB_navigator.findLeftObj(tapaTexto) + tapaTexto.offsetWidth)) || (actualMouseX < (LIB_navigator.findLeftObj(tapaTexto))))
		 			{
						document.getElementById("tdInput_" + combos[elem].id).style.backgroundColor = combos[elem].style.comboBGColor;
						showScroll(combos[elem].id,"hidden");
						document.getElementById("divContent" + combos[elem].id).style.display = "none";					
					}
				}
				else // Si está desplegado POR ENCIMA DE LA TAPA DE TEXTO
				{
					// Si Pinchamos por ARRIBA de la TAPA del combo o por ABAJO de la TAPA + EL CONTENIDO
					if((actualMouseY > (LIB_navigator.findTopObj(tapaTexto) + tapaTexto.offsetHeight)) || (actualMouseY < (LIB_navigator.findTopObj(tapaTexto) -   divContent.offsetHeight)) || (actualMouseX > (LIB_navigator.findLeftObj(tapaTexto) + tapaTexto.offsetWidth)) || (actualMouseX < (LIB_navigator.findLeftObj(tapaTexto))))
		 			{
						document.getElementById("tdInput_" + combos[elem].id).style.backgroundColor = combos[elem].style.comboBGColor;
						showScroll(combos[elem].id,"hidden");
						document.getElementById("divContent" + combos[elem].id).style.display = "none";					
					}
				}
			}
			else // Si el contenido está PLEGADO
			{
				// Si nos salimos por ARRIBA de la TAPA del combo o por ABAJO de la TAPA
				if((actualMouseY > (LIB_navigator.findTopObj(tapaTexto) + tapaTexto.offsetHeight)) || (actualMouseY < (LIB_navigator.findTopObj(tapaTexto))) || (actualMouseX > (LIB_navigator.findLeftObj(tapaTexto) + tapaTexto.offsetWidth)))
	 			{
					document.getElementById("tdInput_" + combos[elem].id).style.backgroundColor = combos[elem].style.comboBGColor;
				}
			}
		}
	}
}

// To resize the window, recolocate the combo
addDinamciEvent(window, "onresize", resizeWindow)
function resizeWindow(evt)
{
	// Hide the conten combo
	var arrayDivs = document.getElementsByTagName("div");
	var i = null;
	for(i=0;i<arrayDivs.length;i++)
	{
		if(arrayDivs[i].id.indexOf("divContent") != -1)
		{
			var idContent = arrayDivs[i].id.split("divContent")[1];
			if(arrayDivs[i].style.visibility == "visible")
			{
				focalizeCombo(idContent,document.getElementById("tdInput_" + idContent));
			}
			showScroll(idContent,"hidden");
			colocateContent(idContent);

			// Recolocate the Cover of the combo
			positionContentLeft = LIB_navigator.findLeftObj(document.getElementById("contenedor" + idContent))+ document.getElementById("generalTable" + idContent).offsetLeft;
			positionContentTop = LIB_navigator.findTopObj(document.getElementById("contenedor" + idContent))+ document.getElementById("generalTable" + idContent).offsetTop;
			document.getElementById("tapaTexto_" + idContent).style.left = positionContentLeft;
			document.getElementById("tapaTexto_" + idContent).style.top = positionContentTop;
		}
	}
}

// To controlate the cursors in the content table
function documentKeyDown(evt)
{
	var e = (window.event) ? window.event : evt;
	// Para poder obtener los ID de los elementos que hay cargado, recorro las capas principales, y de hay saco los ID
	var arrayDivs = document.getElementsByTagName("div");
	var i = null;
	for(i=0;i<arrayDivs.length;i++)
	{
		if(arrayDivs[i].id.indexOf("tapaTexto_") != -1)
		{
			var theIdContent = arrayDivs[i].id.split("_")[1];
			if(e.keyCode != 9)  // si no es tabulación
			{
				//    Arriba = 38        Abajo = 40       Izquierda = 37      Derecha = 39      Inicio = 36         Fin = 35          RePag = 33         AvPag = 34
				if(e.keyCode == 38 || e.keyCode == 40 || e.keyCode == 37 || e.keyCode == 39 || e.keyCode == 36 || e.keyCode == 35 || e.keyCode == 33 || e.keyCode == 34 || e.keyCode == 13)
				{
					// Si no hay almuadilla, es que lo ha dado en RGB. Lo trasnsformo a HEXADECIMAL
					inputColorSelected = colorToHEX(document.getElementById("tdInput_" + theIdContent).style.backgroundColor);

					// Compruebo que la caja de texto está focada. Si lo está...
					if(inputColorSelected.toLowerCase() == colorToHEX(combos[theIdContent].style.comboBGColorContentRollOver.toLowerCase()))
					{
						// Compruebo que se han pulsado los cursores
						// Si pulsamos arriba, abajo, izq, drcha, Inicio, Fin, AvPag, RePag
						switch(e.keyCode)
						{
							case 38: // Desplazar hacia Arriba
								moveContent("up",theIdContent);
							break;
							case 40: // Desplazar hacia Abajo
								moveContent("down",theIdContent);
							break;
							case 37: // Desplazar hacia Arriba
								moveContent("up",theIdContent);
							break;
							case 39: // Desplazar hacia Abajo
								moveContent("down",theIdContent);
							break;
							case 36: // Ir al Primero
								moveContent("inicio",theIdContent);
							break;
							case 35: // Ir al Ultimo
								moveContent("fin",theIdContent);
							break;
							case 33: // Abanzar X elementos
								moveContent("rePag",theIdContent);
							break;
							case 34: // Retroceder X elementos
								moveContent("avPag",theIdContent);
							break;
							case 13: // Pulsar el Enter
								focalizeCombo(theIdContent,document.getElementById("tdInput_" + theIdContent))
							break;
							
						}
					}
				}
				else
				{
					// Si no hay almuadilla, es que lo ha dado en RGB. Lo trasnsformo a HEXADECIMAL
					inputColorSelected = colorToHEX(document.getElementById("tdInput_" + theIdContent).style.backgroundColor) ;

					// Compruebo que la caja de texto está focada. Si lo está...
					if(inputColorSelected.toLowerCase() == colorToHEX(combos[theIdContent].style.comboBGColorContentRollOver.toLowerCase()))
					{
						var anterior = document.getElementById("input_" + theIdContent).value;
						var caracter = null;
						// Busqueda de la línea que tiene la letra pulsada
						// a=65 , ñ = 192, z=90; 0=48, 1=49, 9=57
						if(e.keyCode == 192) // Si no es la EÑE (ñ)
						{
							caracter = "ñ";
						}
						else
						{
							switch(LIB_navigator.getName())
							{
								case "Opera":
									caracter = String.fromCharCode(e.which);
								break;
								case "Microsoft Internet Explorer":
									caracter = String.fromCharCode(e.keyCode);
								break;
								case "Firefox":
									caracter = String.fromCharCode(e.which);
								break;
								case "Netscape":
									caracter = String.fromCharCode(e.which);
								break;
							}
						}
						
						findFirstCaracter(anterior,caracter,theIdContent);
						moveContentToSelectedItem(theIdContent);
					}
				}
			}
			else // si se ha pulsado la tecla TABULACIÓN?
			{
				// Si está visible la capa de datos...
				if(document.getElementById("divContent" + arrayDivs[i].id.split("_")[1]).style.visibility == "visible" && document.getElementById("divContent" + arrayDivs[i].id.split("_")[1]).style.display == "inline")
				{
					showScroll(arrayDivs[i].id.split("_")[1],"hidden");

					focalizeCombo(arrayDivs[i].id.split("_")[1],document.getElementById("selector_" + arrayDivs[i].id.split("_")[1]));
				}
			}
		}
	}
}

// Function to move the content 1 position UP or DOWN with the RULE of the mouse
function moveContentWheel(id,event)
{
	if(document.getElementById("divContent" + id).style.visibility == "hidden")
	{
		if(event.wheelDelta == -120) // If the direction of the wheel = DOWN...
		{
			moveContent("down",id);	
		}
		else // wheelDelta = 120. The direction of the Wheel = UP
		{
			moveContent("up",id);
		}
	}
}

var actual = 0;
var IDObjActual = null;
var timeout = null;
var sleepTime = 1000;
// function to Find the argument caracter into a Options of the Select
function findFirstCaracter(valueAnterior,theCaracter,theIdElement)
{
	var theContentTable = document.getElementById("tableDiv_" + theIdElement);
	var i=0;
	var encontrado = false;
	i=actual;
	while(i<theContentTable.getElementsByTagName("td").length && encontrado == false)
	{
		if(theContentTable.getElementsByTagName("td")[i].innerHTML.substr(0,1).toLowerCase() == theCaracter.toLowerCase())
		{
			encontrado = true;
			actual = i+1;
		}
		i++;
	}
	
	if(encontrado == true)
	{
		selectOption(theIdElement,i-1);
		IDObjActual = theIdElement;
		timeout = setTimeout("clearKey()",sleepTime);
		moveContentToSelectedItem(theIdElement)
		// Pone las opciones de contenido  en color inicial y remarca la seleccionada
		hideSelectionContent(theIdElement);
	}
	else
	{
		if(actual>0)
		{
			i=0;
			while(i<actual && encontrado == false)
			{
				if(theContentTable.getElementsByTagName("td")[i].innerHTML.substr(0,1).toLowerCase() == theCaracter.toLowerCase())
				{
					encontrado = true;
					actual = i+1;
				}
				i++;
			}
			if(encontrado == true)
			{
				selectOption(theIdElement,i-1);
				IDObjActual = theIdElement;
				timeout = setTimeout("clearKey()",1000);
				// Pone las opciones de contenido  en color inicial y remarca la seleccionada				
				hideSelectionContent(theIdElement);
			}
			else
			{
				IDObjActual = theIdElement;
				timeout = setTimeout("clearKey()",1000);
				document.getElementById("input_" + theIdElement).value = valueAnterior;
			}
		}
		else
		{
			IDObjActual = theIdElement;
			timeout = setTimeout("clearKey()",1000);
			document.getElementById("input_" + theIdElement).value = valueAnterior;
		}
	}
}

function clearKey()
{
	if(IDObjActual != null)
	{
		clearTimeout(timeout);
		document.getElementById("input_" + IDObjActual).value = "";
	}
}

// Function to move the content 
function moveContent(direction,id)
{
	switch(direction)
	{
		case "up":
			var tabla = document.getElementById("tableDiv_" + id);
			var filas = tabla.getElementsByTagName("tr").length;
			// nos ubicamos en el elemento de la tabla de contenidos
			var i = 0;
			var encontrado = false;
			while(i<filas && encontrado == false)
			{
				theBackgroundColor = colorToHEX(document.getElementById("trTableDiv" + i + "_" +  id).style.backgroundColor);
				if(theBackgroundColor.toLowerCase() == colorToHEX(combos[id].style.comboBGColorContentRollOver.toLowerCase()))
				{
					encontrado = true;
				}
				if(encontrado == false)
				{
					i = i+1;
				}
			}
			// Si no he llegado al ultimo y si no estoy en el primero...
			if(i > 0 && i !=filas)
			{
				selectOption(id,(i-1));
				// Pone las opciones de contenido  en color inicial y remarca la seleccionada
				hideSelectionContent(id);
			}
		break;
		
		case "down":
			var tabla = document.getElementById("tableDiv_" + id);
			var filas = tabla.getElementsByTagName("tr").length;
			// nos ubicamos en el elemento de la tabla de contenidos 
			var i = 0;
			var encontrado = false;
			while(i<filas && encontrado == false)
			{
				theBackgroundColor = colorToHEX(document.getElementById("trTableDiv" + i + "_" +  id).style.backgroundColor);
				if(theBackgroundColor.toLowerCase() == colorToHEX(combos[id].style.comboBGColorContentRollOver.toLowerCase()))
				{
					encontrado = true;
				}
				i = i + 1;
			}
			// si no estoy en el primero y está encontrado
			if(i > 0 && encontrado == true)
			{
				if(i != filas)
				{
					selectOption(id,i);
					// Pone las opciones de contenido  en color inicial y remarca la seleccionada
					hideSelectionContent(id);
				}
			}
			else // si estoy en el primero y no esta encontrado, señalamos el primero
			{
				selectOption(id,0);
				// Pone las opciones de contenido  en color inicial y remarca la seleccionada
				hideSelectionContent(id);
			}

		break;

		case "inicio":
				selectOption(id,0);
				// Pone las opciones de contenido  en color inicial y remarca la seleccionada
				hideSelectionContent(id);
		break;

		case "fin":
			var tabla = document.getElementById("tableDiv_" + id);
			var filas = tabla.getElementsByTagName("tr").length;
				selectOption(id,(filas-1));
				// Pone las opciones de contenido  en color inicial y remarca la seleccionada
				hideSelectionContent(id);
		break;
		
		case "rePag":
			var tabla = document.getElementById("tableDiv_" + id);
			var filas = tabla.getElementsByTagName("tr").length;
			// nos ubicamos en el elemento de la tabla de contenidos
			var i = 0;
			var encontrado = false;
			while(i<filas && encontrado == false)
			{
				theBackgroundColor = colorToHEX(document.getElementById("trTableDiv" + i + "_" +  id).style.backgroundColor);
				if(theBackgroundColor.toLowerCase() == colorToHEX(combos[id].style.comboBGColorContentRollOver.toLowerCase()))
				{
					encontrado = true;
				}
				if(encontrado == false)
				{
					i = i+1;
				}
			}
			// si desde donde estoy mas la cantidad de avanzar pagina son mayores que 0...
			if(((i+1) - rePagLines) >= 0)
			{
				selectOption(id,(i-rePagLines));
				// Pone las opciones de contenido  en color inicial y remarca la seleccionada
				hideSelectionContent(id);
			}
			else
			{
				// Si nos saliésemos del contenido, l o paro en el primero
				if((i-rePagLines) < 0)
				{
					selectOption(id,0);
					// Pone las opciones de contenido  en color inicial y remarca la seleccionada
					hideSelectionContent(id);
				}
			}
		break;

		case "avPag":
			var tabla = document.getElementById("tableDiv_" + id);
			var filas = tabla.getElementsByTagName("tr").length;
			// nos ubicamos en el elemento de la tabla de contenidos
			var i = 0;
			var encontrado = false;
			while(i<filas && encontrado == false)
			{
				theBackgroundColor = colorToHEX(document.getElementById("trTableDiv" + i + "_" +  id).style.backgroundColor);

				if(theBackgroundColor.toLowerCase() == colorToHEX(combos[id].style.comboBGColorContentRollOver.toLowerCase()))
				{
					encontrado = true;
				}
				i = i + 1;
			}
			// si no estoy en el primero y he encontrado...
			if(i > 0 && encontrado == true)
			{
				// Si la posicion donde estoy mas la cantidad de elementos para avanzar no se pasan de la cantidad maxima de elementos en la tabla...
				if((i+avPagLines) <= (filas-1))
				{
					selectOption(id,((i-1)+avPagLines));
					// Pone las opciones de contenido  en color inicial y remarca la seleccionada
					hideSelectionContent(id);
				}
				else // si me pasara del los elementos de la tabla, paramos en el último
				{
					selectOption(id,(filas-1));
					// Pone las opciones de contenido  en color inicial y remarca la seleccionada
					hideSelectionContent(id);
				}
			}
			else  // sera que es la 0
			{
				selectOption(id,avPagLines);
				// Pone las opciones de contenido  en color inicial y remarca la seleccionada
				hideSelectionContent(id);
			}
	}	
}


// Function to conver an RGB color in HEX color
function colorToHEX(theRGBColor)
{
	var theColorToReturn = theRGBColor;
	// Compruebo si el color que me da el backgroundcolor tiene # (en IE si la da pero en el resto, lo da en RGB
	if(theRGBColor.indexOf("#") == -1)
	{
		if(theRGBColor.toLowerCase().indexOf("(") != -1 && theRGBColor.toLowerCase().indexOf(")") != -1)
		{
			theRGBColor = theRGBColor.split("(")[1].split(")")[0]
		}
		var s,i,h = "", x="0123456789ABCDEF";
		c = theRGBColor;
		if(theRGBColor)
		{
			s = theRGBColor.split(",");
			for(i=0;i<3;i++)
			{
				n = parseInt(s[i]);
				h += x.charAt(n>>4) + x.charAt(n&15)
			}
			theColorToReturn = "#" + h;
		}
		else
		{
			theColorToReturn = "";;
		}
	}
	else
	{
		
	}
	return(theColorToReturn.toLowerCase());
}


/*
	Functions to control the Scroll in the Div Content
*/

function moveScrollWheel(id,event)
{
/*	if(document.getElementById("divContent" + id).style.visibility == "visible")
	{
		if(event.wheelDelta == -120) // If the direction of the wheel = DOWN...
		{
			scroll(-combos[id].scroll.speed,id);
		}
		else // wheelDelta = 120. The direction of the Wheel = UP
		{
			scroll(combos[id].scroll.speed,id);
		}
	}*/
}

document.addEvent = addEvent;
document.removeEvent = removeEvent;

var	scrollTimer = null;
var trackTop = null;
var trackBottom = null;
var trackLength = null;
var contentMaskHeight = null;
var contentTop  = null;
function scroll(speed,idObject)
{
	var contentTop = parseInt(document.getElementById("content" + idObject).style.top);
	trackTop = parseInt(document.getElementById("up" + idObject).style.top) + parseInt(document.getElementById("up" + idObject).offsetHeight) - 1;
	trackLength = (parseInt(document.getElementById("track" + idObject).offsetHeight) - parseInt(document.getElementById("drag" + idObject).style.height)) - 1;
	var contentMovement = contentTop + speed;
	contentMaskHeight = parseInt(document.getElementById("divContent" + idObject).offsetHeight);
	var contentHeight = parseInt(document.getElementById("tableDiv_" + idObject).offsetHeight); // Height of the content div
	
	var contentLength = contentHeight-contentMaskHeight + 5; // Adjusted content height	
	trackBottom = trackTop + trackLength; // Scrollbar bottom contraint
	
	var dragMovement = trackTop - Math.round(contentTop * (trackLength / contentLength));
	if(contentMovement > 0)
	{
		contentMovement = 0;
	}
	else
	{
		if(contentMovement < -contentLength)
		{
			contentMovement = -contentLength;
		}
	}
	if(dragMovement < trackTop)
	{
		dragMovement = trackTop;
	}
	else
	{
		if(dragMovement > trackBottom)
		{
			dragMovement = trackBottom;
		}
	}
	document.getElementById("content" + idObject).style.top = contentMovement;
	document.getElementById("drag" + idObject).style.top = dragMovement;
	document.getElementById("tapaDrag" + idObject).style.top = dragMovement;
	
	// Ejecutamos el movimiento
	scrollTimer = window.setTimeout("scroll(" + speed + ",'" + idObject + "')",25);
}


var idGlobalDragObject = null;
var dragStartMouse = null;
var dragStartOffset = null;

function startDrag(idElement,evt)
{
	// Capturamos el Evento
	var e = (window.event) ? window.event : evt;

	dragStartMouse = e.clientY + document.documentElement.scrollTop + document.body.scrollTop;
	dragStartOffset = document.getElementById("drag" + idElement).style.top; // Obtenemos la posición del elemento drag

	document.addEvent("onmousemove", function(){drag(e,idElement)});
	document.addEvent("onmouseup", stopDrag);
	return(false);
}

function stopDrag()
{
	document.removeEvent("onmousemove");
	document.removeEvent("onmouseup");
}
function drag(evt,idObject)
{
	// Capturamos el Evento
	var e = (window.event) ? window.event : evt;

	var currentMouse = e.clientY + document.documentElement.scrollTop + document.body.scrollTop;
	var mouseDifference = currentMouse - dragStartMouse;
	var dragDistance = parseInt(dragStartOffset) + parseInt(mouseDifference);
	trackTop = parseInt(document.getElementById("up" + idObject).style.top) + parseInt(document.getElementById("up" + idObject).offsetHeight) - 1;
	trackLength = (parseInt(document.getElementById("track" + idObject).offsetHeight) - parseInt(document.getElementById("drag" + idObject).style.height)) - 2;
	trackBottom = trackTop + trackLength;
	
	var dragMovement = (parseInt(dragDistance) < parseInt(trackTop)) ? parseInt(trackTop) : (parseInt(dragDistance) > parseInt(trackBottom)) ? parseInt(trackBottom) : parseInt(dragDistance);

	
	document.getElementById("drag" + idObject).style.top = dragMovement;
	document.getElementById("tapaDrag" + idObject).style.top = dragMovement;
	contentLength = parseInt(document.getElementById("tableDiv_" + idObject).offsetHeight) - parseInt(document.getElementById("divContent" + idObject).offsetHeight);

	scrollLength = trackLength / contentLength; // Height difference between the scrollbar track and the content
	var contentMovement = -(dragMovement - trackTop) * (1 / scrollLength);
	document.getElementById("content" + idObject).style.top = contentMovement;
	return(false);
}

function getMouse(e)
{
	var laY = null;
	switch(LIB_navigator.getName())
	{
		case "Opera":
			laY = e.pageY;
		break;
		case "Microsoft Internet Explorer":
			laY = event.clientY;
		break;
		case "Firefox":
			laY = e.pageY;
		break;
		case "Netscape":
			laY = e.pageY;
		break;
	}
	return (laY)
}

function stopScroll()
{
	if(scrollTimer)
	{
		window.clearTimeout(scrollTimer);
		scrollTimer = null;
	}
}

function scrollJump(idElement,evt)
{
	// Capturamos el Evento
	var e = (window.event) ? window.event : evt;
	var theObj = document.getElementById("track" + idElement);

	var actualMouse = e.clientY + document.documentElement.scrollTop + document.body.scrollTop;
	// Si hemos pinchado por fuera del scroll...
//	alert(actualMouse + " > (" + parseInt(theObj.offsetTop) + " + " + parseInt(theObj.style.height) + ")")
	if((actualMouse > (parseInt(theObj.style.top) + parseInt(theObj.style.height))) || (actualMouse < (parseInt(theObj.style.top))) || (e.clientX > (parseInt(theObj.style.left) + parseInt(theObj.style.width))))
	{
		showScroll(idElement,"hidden");
		focalizeCombo(idElement,document.getElementById("tdInput_" + idElement));
		reloadScrollItems(idElement);
	}
	else
	{
		var currentMouse = e.clientY + document.documentElement.scrollTop + document.body.scrollTop;
		var dragDistance = currentMouse - (parseInt(document.getElementById("drag" + idElement).offsetHeight) / 2);
		trackTop = parseInt(document.getElementById("up" + idElement).style.top) + parseInt(document.getElementById("up" + idElement).offsetHeight);
		trackLength = (parseInt(document.getElementById("track" + idElement).offsetHeight) - parseInt(document.getElementById("drag" + idElement).style.height));
		trackBottom = trackTop + trackLength;
		
		var dragMovement = (dragDistance < trackTop) ? trackTop : (dragDistance > trackBottom) ? trackBottom : dragDistance;
		document.getElementById("drag" + idElement).style.top = dragMovement;
		document.getElementById("tapaDrag" + idElement).style.top = dragMovement;
		// Comprobamos que el DRAG no se haya pasado de su posicion (si se pasa lo recolocamos al final del track)

		if(parseInt(document.getElementById("drag" + idElement).style.top) + parseInt(document.getElementById("drag" + idElement).style.height) > parseInt(document.getElementById("down" + idElement).style.top))
		{
			document.getElementById("drag" + idElement).style.top = parseInt(document.getElementById("down" + idElement).style.top) - parseInt(document.getElementById("drag" + idElement).offsetHeight);
			document.getElementById("tapaDrag" + idElement).style.top = document.getElementById("drag" + idElement).style.top;
		}
		contentLength = parseInt(document.getElementById("tableDiv_" + idElement).offsetHeight) - parseInt(document.getElementById("divContent" + idElement).offsetHeight);

		scrollLength = trackLength / contentLength;
		var contentMovement = -(dragMovement-trackTop)*(1/scrollLength);
		document.getElementById("content" + idElement).style.top = contentMovement;
		reloadScrollItems(idElement);
				
		return(false);
	}
}

function addEvent(event,method)
{
	this[event] = method;
	if(document.layers)
	{
		this.captureEvents(Event[event.substr(2,event.length).toUpperCase()]);
	}
}
function removeEvent(event)
{
	this[event] = null;
	if(document.layers)
	{
		this.releaseEvents(Event[event.substr(2,event.length).toUpperCase()]);
	}
}

/* 
	Function to over on the IMAGEs of the combo
*/
function overSelector(idCombo,idReferer)
{
	var objReferer = document.getElementById(idReferer + idCombo);
	var statusImage = -1;
	var imageActual = objReferer.src.split("/")[objReferer.src.split("/").length - 1];
	var urlImageActual = objReferer.src.split(imageActual)[0];

	if(imageActual.split("_")[1].split(".")[0] == 0 && document.getElementById("divContent" + idCombo).style.display == "none")
	{
		statusImage = 1;
	}
	else
	{
		statusImage = 0;
	}
	objReferer.src = urlImageActual + imageActual.split("_")[0] + "_" + statusImage + "." + imageActual.split(".")[1];
}

/* 
	Function to set the initial possition of the Image Selector Combo
*/
function resetSelector(idCombo,idReferer)
{
	var objReferer = document.getElementById(idReferer + idCombo);
	var statusImage = 1;
	var imageActual = objReferer.src.split("/")[objReferer.src.split("/").length - 1];
	var urlImageActual = objReferer.src.split(imageActual)[0];

	objReferer.src = urlImageActual + imageActual.split("_")[0] + "_" + statusImage + "." + imageActual.split(".")[1];
}

/*
	Function to make the press event on the selector combo
*/
function pressSelector(idCombo,idReferer)
{
	var objReferer = document.getElementById(idReferer + idCombo);
	var statusImage = -1;
	var imageActual = objReferer.src.split("/")[objReferer.src.split("/").length - 1];
	var urlImageActual = objReferer.src.split(imageActual)[0];

	if(imageActual.split("_")[1].split(".")[0] == 1)
	{
		statusImage = 2;
	}
	else
	{
		statusImage = 1;
	}
	objReferer.src = urlImageActual + imageActual.split("_")[0] + "_" + statusImage + "." + imageActual.split(".")[1];
}