/*************************FUNCION DE PAGINACION************************/
var NumeroRegistros;
var NumeroRegPagina;
var HojaActual;
var PaginaActual;
var NumeroPagVisibles;
var ajaxentro;

//VARIABLES DE DETECCION DE POSICION DEL MOUSE EN LA PANTALLA
var xMousePos = 0; // Horizontal position of the mouse on the screen
var yMousePos = 0; // Vertical position of the mouse on the screen
var xMousePosMax = 0; // Width of the page
var yMousePosMax = 0; // Height of the page

//METODOS DE INICIALIZACION DE POSICION DEL MOUSE
if (document.layers) { // Netscape
    document.captureEvents(Event.MOUSEMOVE);
    document.onmousemove = captureMousePosition;
} else if (document.all) { // Internet Explorer
    document.onmousemove = captureMousePosition;
} else if (document.getElementById) { // Netcsape 6
    document.onmousemove = captureMousePosition;
}




function FuncionPaginador(NuevaPosicion,IdGeneralPagina,IdPaginador,IdHoja)
{
try {
    if(NuevaPosicion != null && IdGeneralPagina != null && IdPaginador != null && IdHoja !=null && NumeroRegPagina > 0 && NumeroPagVisibles > 0)
    {    
        var NuevaPagina;
        //var PaginaAnterior = PaginaActual;
        var i,j, ctrlpag,ctrlpagaux;
        //CAPTURA LA PAGINA A LA CUAL DIRIGIRSE
        if(NuevaPosicion == '+'){
            //INCREMENTA HOJA
            NuevaPagina = (HojaActual + 1) * NumeroPagVisibles;
        }
        else if(NuevaPosicion == '-'){
            //DECREMENTA HOJA
            NuevaPagina = (HojaActual - 1) * NumeroPagVisibles;
        }
        else{
            //ASIGNA UNA PAGINA
            NuevaPagina = new Number(NuevaPosicion);
        }
        //ASIGNA HOJA EN LA QUE SE ENCUENTRA
        if(NuevaPagina == NaN || NuevaPagina < 0)
            NuevaPagina = 0;
        if(NumeroRegistros < (NuevaPagina*NumeroRegPagina))
            NuevaPagina = PaginaActual;

        HojaActual = parseInt(NuevaPagina/NumeroPagVisibles);

        //ORGANIZA VISUALIZACION DE HOJAS DEL PAGINADOR
        for(i=0; i< NumeroRegistros/(NumeroRegPagina*NumeroPagVisibles); i++)
        {
            ctrlpag  = document.getElementById(IdHoja + i);
            if(ctrlpag != null)
            {
                if(i == HojaActual)
                {
                    ctrlpag.style.display='block';
                }
                else
                {
                    ctrlpag.style.display='none';
                }
            }
        }
        
        //GUARDA PAGINA EN LA QUE SE ENCUENTRA
        PaginaActual = NuevaPagina;
        
        for(i=0; i<NumeroRegistros/NumeroRegPagina; i++)
        {
            //BUSCA TODOS LOS CONTROLES DE PAGINACION
            ctrlpag = document.getElementById(IdGeneralPagina + i);
            if(ctrlpag != null)
            {
                if(i==PaginaActual)
                {
                    ctrlpag.style.display='block';
                }
                else
                {
                    ctrlpag.style.display='none';
                }
            }
            //ORGANIZA VISUALIZACION DEL PAGINADOR
            ctrlpag = document.getElementById(IdPaginador + i);
            if(ctrlpag != null)
            {
                //ASIGNA ESTILOS DE SELECCION
                if(i == PaginaActual)
                {
                    ctrlpag.attributes["class"].nodeValue = "tahoma_13_negra";
                    ctrlpag.style.textDecoration = 'none';
                }
                else
                {
                    ctrlpag.attributes["class"].nodeValue = "arial_11_azul_link";
                    ctrlpag.style.textDecoration = 'underline';
                }
            }
        }
    }
}
    catch (e) {
}
}
/*************************FIN FUNCION DE PAGINACION************************/

/************************************FUNCIONES BASICAS DE AJAX**********************************************/

var ClaseAjax = function()
{
    //CONSTRUCTOR
    function Ajax(onombreObjeto)
    {
    try {
        this.nombreObjeto = onombreObjeto;
        this.objXmlHttpPostBack = null;
        this.objRespuestaPostback = '';
    }
    catch (e) {
    }
    }
    //INICIALIZACION
    Ajax.prototype.inicia = function()
    {
    try {
        this.objXmlHttpPostBack = CreaObjetoAjax(); 
    }
    catch (e) {
    }   
    }
    //REALIZA LLAMADO ASINCRONICO
    Ajax.prototype.RealizaPostBackAsincronico = function(UrlLlamado, MetodoLlamado, FuncionFinalizacion, TipoRespuesta, Parametros)
    {
    try {
           /*window.alert("IniciodeLlamado");
            window.alert(UrlLlamado);
            window.alert(MetodoLlamado);
            window.alert(FuncionFinalizacion);
            window.alert(TipoRespuesta);
            window.alert(Parametros);*/
        if(this.objXmlHttpPostBack)
        {   //window.alert(1);
            if(this.objXmlHttpPostBack.readyState == 0 || this.objXmlHttpPostBack.readyState == 4)
            {//window.alert(2);
                this.objRespuestaPostback = '';

                //RELACIONA FUNCION DE FINALIZACION DE LLAMADO
                eval('this.objXmlHttpPostBack.onreadystatechange = function(ObjetoAjax, fnFinalizacion, TipoRespuesta) { '+
                    'return function() ' +
                    '{ ' +
                    '    if(ObjetoAjax.readyState == 4) ' +
                    '    { ' +
                    '        if(ObjetoAjax.status == 200) ' +
                    '        { ' +
                    '            if(TipoRespuesta == 0) ' +
                    '            { ' +
                    '              ' +  this.nombreObjeto + '.objRespuestaPostback = ObjetoAjax.responseXML; ' +
                    '            } ' +
                    '            else ' +
                    '            { ' +
                    '              ' +  this.nombreObjeto + '.objRespuestaPostback = ObjetoAjax.responseText; ' +
                    '            } ' +
                    '            eval(fnFinalizacion); ' +
                    '        } ' +
                    '        else ' +
                    '        { ' +
                    '            alert(\'Error de Servidor Respuesta de la peticion : \' + ObjetoAjax.status); ' +
                    '        } ' +
                    '    } ' +
                    '    else{} ' +
                    '}(ObjetoAjax = ' + this.nombreObjeto + '.objXmlHttpPostBack, fnFinalizacion = \'' + FuncionFinalizacion + '\', TipoRespuesta = ' + TipoRespuesta + '); '+
                '};');

                
                this.objXmlHttpPostBack.open(MetodoLlamado,UrlLlamado,true);
                if(MetodoLlamado == 'POST')
                {
                    this.objXmlHttpPostBack.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
                    this.objXmlHttpPostBack.setRequestHeader("Content-length", Parametros.length);
                    this.objXmlHttpPostBack.setRequestHeader("Connection", "close");            
                    this.objXmlHttpPostBack.send(Parametros);   
                             
                }
                else
                    this.objXmlHttpPostBack.send(null);
            }
            else
            {
                //alert('Procesando solicitud...');
            }
        }
        else
        {
            //alert('objeto de ajax no creado');
        }
    }
    catch (e) {
    }
    }
    //REALIZA LLAMADO SINCRONO
    Ajax.prototype.RealizaPostBackSincrono = function(UrlLlamado, MetodoLlamado, TipoRespuesta, Parametros)
    {
    try {
        var objAjaxTemporal = CreaObjetoAjax();
        if(objAjaxTemporal)
        {
            if(objAjaxTemporal.readyState == 0 || objAjaxTemporal.readyState == 4)
            {
                //RELACIONA FUNCION DE FINALIZACION DE LLAMADO
                objAjaxTemporal.open(MetodoLlamado,UrlLlamado,false);
                if(MetodoLlamado == 'POST')
                {
                    objAjaxTemporal.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
                    objAjaxTemporal.setRequestHeader("Content-length", Parametros.length);
                    objAjaxTemporal.setRequestHeader("Connection", "close");            
                    objAjaxTemporal.send(Parametros);                
                }
                else
                    objAjaxTemporal.send(null);
                    
                while(objAjaxTemporal.readyState != 4){}
                
                if(objAjaxTemporal.status == 200)
                {
                    if(TipoRespuesta == 0)
                    {
                        return objAjaxTemporal.responseXML;
                    }
                    else
                    {
                        return objAjaxTemporal.responseText;
                    }
                }
                else
                {
                    //ERROR EN LA PETICION
                    return 'Error de Servidor Respuesta de la peticion :' + objAjaxTemporal.status;
                }
            }
            else
            {
                return 'Procesando solicitud...';
            }
        }
        else
        {
            return 'Error de Explorador...';
        }
    }
    catch (e) {
    }
    }    
    
    //FUNCIONES DE USO GENERAL

    //FUNCION CREA EL OBJETO AJAX QUE REALIZA EL POSTBACK
    function CreaObjetoAjax() 
    {
    try { 
        var _xmlhttp;
        /*@cc_on @*//*@if (@_jscript_version >= 5)
        var idAX = ["Msxml2.XMLHTTP.5.0","Msxml2.XMLHTTP.4.0","Msxml2.XMLHTTP.3.0","Msxml2.XMLHTTP","Microsoft.XMLHTTP"];
        for(var i=0; !_xmlhttp && i<idAX.length; i++)
        {   try{_xmlhttp = new ActiveXObject(idAX[i]);}
            catch(ex) { _xmlhttp = false; }
        }@end @*/
        if (!_xmlhttp && typeof XMLHttpRequest!='undefined') 
        {
            _xmlhttp = new XMLHttpRequest();
        }
        return _xmlhttp;
    }
    catch (e) {
    }
    }     

    return{Ajax:Ajax}
}();

/************************************FIN FUNCIONES BASICAS DE AJAX**********************************************/

/***************************FUNCIONES DE DETECCION DE BROWSER*********************************/
var BrowserDetect = {
	init: function () {
	try {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
    }
    catch (e) {
    }
	},
	searchString: function (data) {
	try {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	}
    catch (e) {
    }
	},
	searchVersion: function (dataString) {
	try {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	}
    catch (e) {
    }
	},
	dataBrowser: [
		{
			string: navigator.userAgent,
			subString: "Chrome",
			identity: "Chrome"
		},
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]
};
/***************************FIN FUNCIONES DE DETECCION DE BROWSER*********************************/
/*************************FUNCION CALCULO DINAMICO DE PRESUPUESTO************************/
var ClasePresupuestarEnLineaDinamico = function()
{
    //CONSTRUCTOR
    function PresupuestarDinamico(onombreObjeto)
    {
    try {
        this.nombreObjeto = onombreObjeto;
        this.objAjax = null;
        
        //VARIABLES DE CALCULO DEL PRESUPUESTO
        this.ctrlValoresInicialesPres = null;
        this.objControlPresupuestoActual = null;
        this.valorAnteriorControlPresupuestoActual = 0;
        this.arrValoresPresupuesto = null;
        this.TotalPresupuesto = 0;
        this.TotalCapitulo = 0;
        this.SubCapituloRelacionado = 0;
        this.SeRealizaronCambios = false;
    }
    catch (e) {
    }
        
    }
    //INICIALIZACION
    PresupuestarDinamico.prototype.inicia = function(ostrItemIniciales)
    {
    try {
        //INICIA OBJETO DE MANIPULACION AJAX
        this.objAjax =  new ClaseAjax.Ajax(this.nombreObjeto + '.objAjax');
        this.objAjax.inicia();
    }
    catch (e) {
    }
    }
    //FUNCION DE PETICION POR METODO POST GENERAL
    PresupuestarDinamico.prototype.UpdatePanel = function(DivContenedor, UrlDestino, Parametros)
    {
    try {
        this.objAjax.RealizaPostBackAsincronico(UrlDestino, 'POST', this.nombreObjeto + '.FinUpdatePanel(\\\'' + DivContenedor + '\\\')', 1, Parametros);
    }
    catch (e) {
    }
    }
    PresupuestarDinamico.prototype.FinUpdatePanel = function(DivContenedor)
    {
    try {
        var objDivMostrar = document.getElementById(DivContenedor);
        if(objDivMostrar != null)
        {
            if(BrowserDetect.browser == 'Explorer')
            {
                objDivMostrar.outerHTML = '<div id="' + DivContenedor + '">' + this.objAjax.objRespuestaPostback + '</div>';
            }
            else
            {
                objDivMostrar.innerHTML = this.objAjax.objRespuestaPostback;
            }
            document.getElementById(DivContenedor).style['display'] = 'block';           
        }    
    }
    catch (e) {
    }
    }
    //MUESTRA OCULTA DETALLE DEL ANALISIS
    PresupuestarDinamico.prototype.MuestraOcultaDetalleAnalisis = function(idDivDetalle, posvector)
    {
    try {
        var objDivMostrar = document.getElementById(idDivDetalle);
        if(objDivMostrar != null)
        {
            if((BrowserDetect.browser != 'Explorer' && objDivMostrar.innerHTML.length < 150) || (BrowserDetect.browser == 'Explorer' && objDivMostrar.outerHTML.length < 150))
            {
                //EL CONTROL NO SE HA CARGADO DESDE EL SERVIDOR
                eval(this.nombreObjeto + '.UpdatePanel(\'' + idDivDetalle + '\', \'Programas/Presupuestar/DescripcionCapitulacion.asp\',  \'IsCallBack=1&posvector=' + posvector + '\')');
            }            
            else if(objDivMostrar.style['display'] == 'block')
            {
                objDivMostrar.style['display'] = 'none';
            }
            else
            {
                objDivMostrar.style['display'] = 'block';
            }
        }
    }
    catch (e) {
    }
    }    
    //CREA O COPIA PRESUPUESTO
    PresupuestarDinamico.prototype.FrmCrearCopiarPresupuesto = function(idContenedorItems, accion)
    {
    try {
        
        var objContenedor = document.getElementById(idContenedorItems);
        if(objContenedor != null)
        {
            var lstElementosPost = '', i, lstVariablesEnvio = objContenedor.getElementsByTagName('input');
            for(i = 0; i < lstVariablesEnvio.length; i++)
            {
                if(lstVariablesEnvio[i].value.length == 0 && lstVariablesEnvio[i].name != "codpres")
                {
                    alert('Todos los valores son necesarios.');
                    lstElementosPost = '';
                    break;
                }
                else
                {
                    lstElementosPost = lstElementosPost + lstVariablesEnvio[i].name + '=' + escape(lstVariablesEnvio[i].value) + '&';
                    
                }
            }


	    lstVariablesEnvio = objContenedor.getElementsByTagName('textarea');
            for(i = 0; i < lstVariablesEnvio.length; i++)
            {
                if(lstVariablesEnvio[i].value.length == 0)
                {
                    alert('Todos los valores son necesarios.');
                    lstElementosPost = '';
                    break;
                }
		        else if (lstVariablesEnvio[i].value.length >50 && lstVariablesEnvio[i].name =="txtDescripcionPresupuesto")
                {
		            alert('La descripción no puede tener mas de 50 carácteres');
                    break;
                }
                else
                {
                    lstElementosPost = lstElementosPost + lstVariablesEnvio[i].name + '=' + escape(lstVariablesEnvio[i].value) + '&';
                    
                }
            }

	



            lstVariablesEnvio = objContenedor.getElementsByTagName('select');
            for(i = 0; i < lstVariablesEnvio.length; i++)
            {
                if(lstVariablesEnvio[i].value.length == 0)
                {
                    alert('Todos los valores son necesarios.');
                    lstElementosPost = '';
                    break;
                }
                else
                {
                    lstElementosPost = lstElementosPost + lstVariablesEnvio[i].name + '=' + escape(lstVariablesEnvio[i].value) + '&';
                    
                }
            }

            if(lstElementosPost.length > 0)
            {
               // window.alert(lstElementosPost.toString());
                this.objAjax.RealizaPostBackAsincronico('Programas/Presupuestar/NuevoPresupuesto.asp', 'POST', this.nombreObjeto + '.FinCrearCopiarPresupuesto()', 1,'accion=' + accion + '&' + lstElementosPost);
            }
        }
    }
    catch (e) {
    }
    }    
    PresupuestarDinamico.prototype.FinCrearCopiarPresupuesto = function()    
    {
    try {
        if(!isNaN(this.objAjax.objRespuestaPostback) && this.objAjax.objRespuestaPostback.length < 10)
        {
            eval(this.nombreObjeto + '.UpdatePanel(\'DivContenedorTodoPresupuesto\', \'Programas/Presupuestar/ModificarPresupuesto.asp\', \'codpresupuesto=' + this.objAjax.objRespuestaPostback + '\');');
        }
        else
        {
            alert('Se genero un error creando el presupuesto.');
        }
    }
    catch (e) {
    }
    }
    //CAPTURA CONTROL DEL PRESUPUESTO
    PresupuestarDinamico.prototype.CapturaControlPresupuesto = function(objInput) 
    {
    try {
        if(objInput != null)
        {
            this.objControlPresupuestoActual = objInput;
            this.SeRealizaronCambios = true;
            this.valorAnteriorControlPresupuestoActual = this.objControlPresupuestoActual.value;
        }
    }
    catch (e) {
    }
    }
    //LIBERA CONTROL DEL PRESUPUESTO
    PresupuestarDinamico.prototype.LiberaControlPresupuesto = function(vlrUnidad) 
    {
    try {
      if(this.objControlPresupuestoActual != null)
      {
      	if(!isNaN(this.objControlPresupuestoActual.value))
      	{
      		if(this.objControlPresupuestoActual.value >= 0)
      		{
		        var i, cadbusqueda = '';
		
		        //INICIA VECTOR DEL PRESUPUESTO
		        if(document.getElementById('inputValoresInicialesPresupuesto') != null)
		        {
		            //OBTIENE LOS VALORES INICIALES DEL PRESUPUESTO ENVIADOS POR EL SERVIDOR        
		            if(this.ctrlValoresInicialesPres != document.getElementById('inputValoresInicialesPresupuesto').value)
		            {
		                eval(this.nombreObjeto + '.IniciaVectorPresupuesto()');
		            }
		        }
		        //ALMACENA MODIFICACION DEL PRESUPUESTO EN EL ARREGLO DEL PRESUPUESTO
		        cadbusqueda = this.objControlPresupuestoActual.id.replace('CntRelacionada$','');
		        for(i = 0; i < this.arrValoresPresupuesto.length; i++)
		        {
		            if(this.arrValoresPresupuesto[i][0] == cadbusqueda )
		            {
		                this.arrValoresPresupuesto[i][1] = this.objControlPresupuestoActual.value;
		                //LIBERA CONTROL DEL PRESUPUESTO
		                this.objControlPresupuestoActual = null;                    
		                break;
		            }
		        }
		        if(this.objControlPresupuestoActual != null)
		        {
		            this.arrValoresPresupuesto[this.arrValoresPresupuesto.length] = [cadbusqueda,this.objControlPresupuestoActual.value,vlrUnidad];
		            //LIBERA CONTROL DEL PRESUPUESTO
		            this.objControlPresupuestoActual = null;                  
		        } 
		    	}
		    	else
		    	{
		    		this.objControlPresupuestoActual.value = this.valorAnteriorControlPresupuestoActual;
		    		alert('Solo se admiten valores positivos.');	
		    	}
		   	}
		   	else
		   	{
		   		this.objControlPresupuestoActual.value = this.valorAnteriorControlPresupuestoActual;		   		
		   		alert('Solo se admiten valores numericos.');	
		   	}           
      }
    }
    catch (e) {
    }
    }
    //RECALCULA PRESUPUESTO
    PresupuestarDinamico.prototype.RecalculaPresupuesto = function() 
    {
    try {
        var i;
        if(document.getElementById('inputValoresInicialesPresupuesto') != null)
        {
            //OBTIENE LOS VALORES INICIALES DEL PRESUPUESTO ENVIADOS POR EL SERVIDOR        
            if(this.ctrlValoresInicialesPres != document.getElementById('inputValoresInicialesPresupuesto').value)
            {
                eval(this.nombreObjeto + '.IniciaVectorPresupuesto()');
                eval(this.nombreObjeto + '.MostrarValoresPresupuesto()');
            }
            //RECALCULA VALOR DEL PRESUPUESTO A PARTIR DEL ARREGLO DEL PRESUPUESTO
            else if(this.arrValoresPresupuesto != null)
            {
                var TotalAux = 0, TotalCapituloAux = 0;
                for(i = 0; i < this.arrValoresPresupuesto.length; i++)
                {
                    TotalAux = TotalAux + this.arrValoresPresupuesto[i][1] * this.arrValoresPresupuesto[i][2];
                    if(this.arrValoresPresupuesto[i][0].indexOf(this.SubCapituloRelacionado + '$') != -1 )
                    {
                        TotalCapituloAux = TotalCapituloAux + this.arrValoresPresupuesto[i][1] * this.arrValoresPresupuesto[i][2];
                    }
                }
                this.TotalPresupuesto = TotalAux;
                this.TotalCapitulo = TotalCapituloAux;
                eval(this.nombreObjeto + '.MostrarValoresPresupuesto()');
            }
        }
    }
    catch (e) {
    }
    }
    PresupuestarDinamico.prototype.IniciaVectorPresupuesto = function() 
    {
        var i;
    try {
        if(document.getElementById('inputValoresInicialesPresupuesto') != null)
        {
            //OBTIENE LOS VALORES INICIALES DEL PRESUPUESTO ENVIADOS POR EL SERVIDOR        
            if(this.ctrlValoresInicialesPres != document.getElementById('inputValoresInicialesPresupuesto').value)
            {
                this.ctrlValoresInicialesPres = document.getElementById('inputValoresInicialesPresupuesto').value;
                if(this.arrValoresPresupuesto == null)
                    this.arrValoresPresupuesto = [];
                    
                if(this.ctrlValoresInicialesPres.length > 3)
                {
                    //CAPTURA LA LISTA DE ITEMS INVIADOS POR EL SERVIDOR
                    if(this.ctrlValoresInicialesPres.split('#').length > 3)
                    {
                        //CAPTURA TOTAL DEL PRESUPUESTO
                        this.TotalPresupuesto = this.ctrlValoresInicialesPres.split('#')[0];
                        this.TotalCapitulo = this.ctrlValoresInicialesPres.split('#')[1];
                        this.SubCapituloRelacionado = this.ctrlValoresInicialesPres.split('#')[2];
                        var lstDescripcionItem = this.ctrlValoresInicialesPres.split('#')[3].split('|');
                        var cont = 0;
                        
                        for(i = 0; i < lstDescripcionItem.length; i++)
                        {
                            if(lstDescripcionItem[i].split(';').length > 2)
                            {
                                this.arrValoresPresupuesto[cont] = lstDescripcionItem[i].split(';');
                                cont++;
                            }
                        }
                    }
                }
            }
        }
    }
    catch (e) {
    }
    }    
    PresupuestarDinamico.prototype.MostrarValoresPresupuesto = function()
    {
    try {
        //MUESTRA TOTAL CALCULADO DEL PRESUPUESTO
        if(document.getElementById('txtTotalSubCapitulo') != null && document.getElementById('txtTotalPresupuesto') != null)
        {
        		var oTotalCapitulo = Math.ceil(this.TotalCapitulo);
        		var oTotalPresupuesto = Math.ceil(this.TotalPresupuesto);

            if(BrowserDetect.browser == 'Explorer')
            {
                document.getElementById('txtTotalSubCapitulo').outerHTML = '<span id="txtTotalSubCapitulo" class="tahoma_11_gris">' + oTotalCapitulo.toLocaleString() + '</span>';
                document.getElementById('txtTotalPresupuesto').outerHTML = '<span id="txtTotalPresupuesto" class="tahoma_13_gris">' + oTotalPresupuesto.toLocaleString() + '</span>';
            }
            else
            {
                document.getElementById('txtTotalSubCapitulo').innerHTML = oTotalCapitulo.toLocaleString();
                document.getElementById('txtTotalPresupuesto').innerHTML = oTotalPresupuesto.toLocaleString();
                document.getElementById('txtTotalPresupuesto').className = 'tahoma_13_gris';
            }
        }
    }
    catch (e) {
    }    
    }
    //GUARDA TODOS LOS CAMBIOS DEL PRESUPUESTO
    PresupuestarDinamico.prototype.GuardaTodosCambiosPresupuesto = function(CodPres,Cap) 
    {
    try {
        if(this.arrValoresPresupuesto != null)
        {
            if(document.getElementById('inputValoresInicialesPresupuesto') != null)
            {
                //OBTIENE LOS VALORES INICIALES DEL PRESUPUESTO ENVIADOS POR EL SERVIDOR        
                if(this.ctrlValoresInicialesPres == document.getElementById('inputValoresInicialesPresupuesto').value && this.SeRealizaronCambios == true)
                { 
                    //CONFIRMA EL POSTBACK
                    if(confirm('Desea guardar los cambios realizados?'))
                    {       
                        var i, lstPostBack = '';
                        for(i = 0; i < this.arrValoresPresupuesto.length; i++)
                        {
                            lstPostBack = lstPostBack + this.arrValoresPresupuesto[i][0].replace('$','#') + '#'+ this.arrValoresPresupuesto[i][1] + '|';
                        }
                        //ENVIA PARAMETROS PARA ACTUALIZACION EN LA BASE DE DATOS
                        if('True' == this.objAjax.RealizaPostBackSincrono('Programas/Presupuestar/DescripcionCapitulacion.asp', 'POST',1,'IsCallBack=1&CodPres=' + CodPres + '&Cap=' + Cap + '&accion=guardarcambios&SubCapSol=' + this.SubCapituloRelacionado + '&valores=' + lstPostBack))
                        {
                            if(document.getElementById('txtTotalPresupuesto') != null)
                            {
                                document.getElementById('txtTotalPresupuesto').className = 'tahoma_13_negra';
                                this.SeRealizaronCambios = false;
                            }
                        }
                        else
                        {
                            alert('Se ha cometido un error almacenando el presupuesto y es posible que los valores no se hallan almacenado en la base de datos.');
                        }
                    }
                }
            }
        }
    }
    catch (e) {
    }
    }
    //AJUSTA ESTILOS DE LOS PRESUPUESTOS SELECCIONADOS
    PresupuestarDinamico.prototype.AjustaEstilosCapitulos = function(IdObjContenedor,IdobjSeleccionado) 
    {
    try {
        var i;
        var objContenedor = document.getElementById(IdObjContenedor);
        var objSeleccionado = document.getElementById(IdobjSeleccionado);
        if(objContenedor != null && objSeleccionado != null)
        {
            var lstLinks = objContenedor.getElementsByTagName('a');
            for(i = 0; i < lstLinks.length; i++)
            {
                if(lstLinks[i].parentNode.className == 'arial_11_gris_link_seleccionado')
                    lstLinks[i].parentNode.className = 'arial_11_gris_link';
            }
            objSeleccionado.className = 'arial_11_gris_link_seleccionado';
        }
    }
    catch (e) {
    }
    }  
    //CAMBIA CAPITULO DEL PRESUPUESTO
    PresupuestarDinamico.prototype.CambiaCapituloPresupuesto = function(CodPresupuesto, CodSubCapitulo, NombreCapitulo, Contador) 
    {
    try {
        eval(this.nombreObjeto + '.GuardaTodosCambiosPresupuesto(' + CodPresupuesto + ',\'1\');');
        eval(this.nombreObjeto + '.UpdatePanel(\'DivDescripcionCapitulacion\', \'Programas/Presupuestar/DescripcionCapitulacion.asp\', \'IsPostBack=1&codsubcapitulo=' + CodSubCapitulo + '&capitulacion=1&codpres=' + CodPresupuesto + '&nomcapitulacion=' + escape(NombreCapitulo) + '\');');
        eval(this.nombreObjeto + '.AjustaEstilosCapitulos(\'DivContenedorCapitulos\',\'linkCapitulo_' + CodSubCapitulo + '_' + Contador + '\');');
        
        if(document.getElementById('txtSubCapitulo') != null)
        {
            if(BrowserDetect.browser == 'Explorer')
            {
                document.getElementById('txtSubCapitulo').outerHTML = '<span id="txtSubCapitulo">' + NombreCapitulo.charAt(0).toUpperCase() + NombreCapitulo.substr(1).toLowerCase(); + '</span>';
            }
            else
            {
                document.getElementById('txtSubCapitulo').innerHTML = NombreCapitulo.charAt(0).toUpperCase() + NombreCapitulo.substr(1).toLowerCase();
            }
        }
    }
    catch (e) {
    }
    }
    //CAMBIA MENU DEL PRESUPUESTO
    PresupuestarDinamico.prototype.CambiaMenuPresupuesto = function(CodPresupuesto,strEjecucionMenu) 
    {
    try {
        //GUARDA EL PRESUPUESTO
        if(CodPresupuesto.length > 0)
        {
            eval(this.nombreObjeto + '.GuardaTodosCambiosPresupuesto(' + CodPresupuesto + ',\'1\');');
        }
        if(strEjecucionMenu.length > 0)
        {
            eval(strEjecucionMenu);
        }
    }
    catch (e) {
    }
    }
    return{PresupuestarDinamico:PresupuestarDinamico}
}();

function FuncionCalculoDinamicoPresupuesto(objctrl, idControlPrincipal, idtxtTotalPresupuesto, idtxtTotalSubCapitulo, CostoUnidad)
{
    var ctrl;
    var ctrltxtTotalPresupuesto;
    var ctrltxtTotalSubCapitulo;
    var uidactualaux;
    var NuevoValor;
    var AntiguoValor = 0;
    var TotalPresupuesto;
    var TotalSubCapitulo;
    var ValCostoUnidad;
try {
    
    //CAPTURA CONTROL CON TODOS LOS VALORES REGISTRADOS POR EL USUARIO
    ctrl = document.getElementById(idControlPrincipal);
    //CAPTURA CONTROL DE TOTAL DE PRESUPUESTOS
    ctrltxtTotalPresupuesto = document.getElementById(idtxtTotalPresupuesto);
    //CAPTURA CONTROL DE TOTAL SUBCAPITULO
    ctrltxtTotalSubCapitulo = document.getElementById(idtxtTotalSubCapitulo);

    if(objctrl != null && objctrl.attributes['uidactual'] != null && ctrl != null && ctrl.attributes['value'].nodeValue != null && ctrltxtTotalPresupuesto != null && ctrltxtTotalPresupuesto.innerHTML != null && ctrltxtTotalSubCapitulo != null && ctrltxtTotalSubCapitulo.innerHTML != null)
    {
        //CAPTURA NUEVO VALOR DEL CONTROL
        
        //NuevoValor = new Number(objctrl.attributes['value'].nodeValue);
        NuevoValor = new Number(objctrl.value);
        if(isNaN(NuevoValor) || NuevoValor < 0)
        {
            NuevoValor = 0;
            objctrl.attributes['value'].nodeValue = NuevoValor;
            alert('Solo se permiten valores numericos mayores a cero.');
        }
        //CAPTURA EL TOTAL DE PRESUPUESTO
        TotalPresupuesto = (new Number(ctrltxtTotalPresupuesto.innerHTML.replace(/\./g,'').replace(/,/g,'')))/100;
        //CAPTURA EL TOTAL DEL SUBCAPITULO
        TotalSubCapitulo = (new Number(ctrltxtTotalSubCapitulo.innerHTML.replace(/\./g,'').replace(/,/g,'')))/100;
        //CAPTURA EL VALOR DE LA UNIDAD
        ValCostoUnidad = (new Number(CostoUnidad.replace(/\./g,'').replace(/,/g,'')))/100;
        
        if(!isNaN(TotalPresupuesto))
        {
            uidactualaux = objctrl.attributes['uidactual'].nodeValue.split('_');    
            //BUSCA SI EL VALOR HA SIDO REGISTRADO POR EL USUARIO

            if(ctrl.attributes['value'].nodeValue.indexOf(objctrl.attributes['uidactual'].nodeValue) != -1 && uidactualaux.length >= 3)
            {
                //ACTUALIZA EL LISTADO DE VALORES
                if(NuevoValor == 0)
                {
                    ctrl.attributes['value'].nodeValue = ctrl.attributes['value'].nodeValue.replace(objctrl.attributes['uidactual'].nodeValue,'');
                    //ACTUALIZA EL VALOR DE LA FUNCION JAVASCRIPT
                    objctrl.attributes['uidactual'].nodeValue = uidactualaux[0] + '_' + uidactualaux[1] + '_';
                }
                else
                {
                    ctrl.attributes['value'].nodeValue = ctrl.attributes['value'].nodeValue.replace(objctrl.attributes['uidactual'].nodeValue,uidactualaux[0] + '_' + uidactualaux[1] + '_' + NuevoValor);
                    //ACTUALIZA EL VALOR DE LA FUNCION JAVASCRIPT
                    objctrl.attributes['uidactual'].nodeValue = uidactualaux[0] + '_' + uidactualaux[1] + '_' + NuevoValor;
                }
                //CAPTURA EL VALOR ANTIGUO
                AntiguoValor = new Number(uidactualaux[2]);
                AntiguoValor = ValCostoUnidad * AntiguoValor;
                if(isNaN(AntiguoValor))
                    AntiguoValor = 0;
            }
            else if(uidactualaux.length >= 2)
            {
                if(NuevoValor == 0)
                {
                    ctrl.attributes['value'].nodeValue = ctrl.attributes['value'].nodeValue.replace(objctrl.attributes['uidactual'].nodeValue,'');
                    //ACTUALIZA EL VALOR DE LA FUNCION JAVASCRIPT
                    objctrl.attributes['uidactual'].nodeValue = uidactualaux[0] + '_' + uidactualaux[1] + '_';
                }
                else
                {
                    //REGISTRA NUEVO VALOR
                    ctrl.attributes['value'].nodeValue = ctrl.attributes['value'].nodeValue + ';' + uidactualaux[0] + '_' + uidactualaux[1] + '_' + NuevoValor;
                    //ACTUALIZA EL VALOR DEL JAVASCRIPT EN EJECUCION
                    objctrl.attributes['uidactual'].nodeValue = uidactualaux[0] + '_' + uidactualaux[1] + '_' + NuevoValor;
                }
            }
            //CALCULA NUEVO VALOR DEL PRESUPUESTO
            ctrltxtTotalPresupuesto.innerHTML =(new Number(TotalPresupuesto - AntiguoValor + (NuevoValor * ValCostoUnidad))).toLocaleString();
            ctrltxtTotalSubCapitulo.innerHTML =(new Number(TotalSubCapitulo - AntiguoValor + (NuevoValor * ValCostoUnidad))).toLocaleString(); 
            ctrltxtTotalPresupuesto.attributes["class"].nodeValue = 'tahoma_13_gris';
        }
    }
}
    catch (e) {
}
}
/*************************FIN CALCULO DINAMICO DE PRESUPUESTO************************/
/*************************FUNCION MUESTRA POPUP************************/
function Mostrar(UrlAbrir,AnchoVentana,AltoVentana)
{
    var iframeMostrar;
    var divImagenBig;
    var divImagenBigInner;
    var AltoPagina,AnchoPagina;
try {

    //CAPTURA IFRAME A MOSTRAR
    iframeMostrar = document.getElementById('imgCapa');
    //CAPTURA DIV DE EFECTOS
    divImagenBig = document.getElementById('ImagenBig');
    divImagenBigInner = document.getElementById('ImagenBigInner');
    if(iframeMostrar != null && divImagenBig != null && divImagenBigInner != null)
    {
        //CAPTURA DISTANCIA Y DE LA VENTANA
        var dsoctop = document.all? iecompattest().scrollTop : pageYOffset
	
        //ASIGNA PROPIEDADES AL IFRAME    
        iframeMostrar.style['width'] = AnchoVentana + 'px';
        iframeMostrar.src = UrlAbrir;

        //ASIGNA PROPIEDADES A DIV DE EFECTOS
        divImagenBig.style.visibility = "";
        divImagenBig.style.display='block';
        divImagenBig.style.overflow = 'auto';
        
				if(BrowserDetect.browser == "Firefox")
        {
            AltoPagina = window.scrollMaxY + window.innerHeight;
            AnchoPagina = window.scrollMaxX + window.innerWidth;
        }
        else
        {
            AltoPagina = window.document.body.scrollHeight;
            AnchoPagina = window.document.body.scrollWidth;            
        } 
        divImagenBig.style['height'] = AltoPagina + 'px';
        divImagenBig.style['width'] = AnchoPagina + 'px';
		
        
        divImagenBigInner.style.visibility = "";
	    	divImagenBigInner.style.display='block';
	    
		    //ASIGNA POSICION DEL IFRAME
		  	divImagenBigInner.style['left'] = ((document.body.clientWidth/2) - (AnchoVentana/2))+'px';	    
		    divImagenBigInner.style['top'] = (dsoctop + 50) + 'px';
    }
    var objects = document.getElementsByTagName('OBJECT');
    for(var index=0;index<objects.length;index++)
    objects.item(index).style.visibility = "hidden";

}
    catch (e) {
}
}

/*************************FIN FUNCION MUESTRA POPUP************************/

/*************************FUNCION PARA CAMBIAR EL TAMAÑO DEL POPUP ************************/
function redimFrame()
{
try {
		var alturaPagina;
		var iframeMostrar = document.getElementById('imgCapa');
		alturaPagina=iframeMostrar.contentWindow.document.body.scrollHeight;
		iframeMostrar.style.height=alturaPagina + 'px';
}
    catch (e) {
}
}
/*************************FIN FUNCION PARA CAMBIAR EL TAMAÑO DEL POPUP ************************/

/*************************FUNCION OCULTA POPUP************************/
function Ocultar()
{
try {
    var divImagenBig;
    var divImagenBigInner;

    //CAPTURA DIV DE EFECTOS
    divImagenBig = document.getElementById('ImagenBig');
    divImagenBigInner = document.getElementById('ImagenBigInner');
    var iframeMostrar = document.getElementById('imgCapa');

    if(divImagenBig != null && divImagenBigInner != null && iframeMostrar != null)
    {
        divImagenBig.style.display = 'none';
	    	divImagenBigInner.style.display = 'none';
	    	iframeMostrar.src = '';
    }
    var objects = document.getElementsByTagName('OBJECT');
    for(var index=0;index<objects.length;index++)
    objects.item(index).style.visibility = "visible";
}
    catch (e) {
}
}
/*************************FIN FUNCION OCULTA POPUP************************/

/*************************FUNCION CAPTURA ALTO DE VENTANA************************/
function iecompattest(){
try {
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}
    catch (e) {
}

}
/*************************FIN FUNCION CAPTURA ALTO DE VENTANA************************/


/*************************FUNCION DE CAMBIO PROPIEDAD DE CONTROL************************/

function FuncionCambioPropiedadControl(idControl, Propiedad, NuevoValor)
{
    var ctrl;
try {
    //CAPTURA CONTROL
    ctrl = document.getElementById(idControl);
    if(ctrl != null && ctrl.attributes[Propiedad] != null)
    {
        //ASIGNA NUEVO VALOR A LA PROPIEDAD
        ctrl.attributes[Propiedad].nodeValue = NuevoValor;
    }
}
    catch (e) {
}
}
/*************************FIN FUNCION DE CAMBIO PROPIEDAD DE CONTROL************************/

/*************************FUNCION DE CAMBIO ESTILO DE CONTROL************************/

function FuncionCambioEstiloControl(idControl, Estilo, NuevoValor)
{
try {
    var ctrl;
    //CAPTURA CONTROL
    ctrl = document.getElementById(idControl);
    if(ctrl != null)
    {
        //ASIGNA NUEVO VALOR AL ESTILO
        ctrl.style[Estilo] = NuevoValor;
    }
}
    catch (e) {
}
}
/*************************FIN FUNCION DE CAMBIO ESTILO DE CONTROL************************/

/*************************FUNCION DE POSTBACK SOBRE IFRAME HIJO************************/

function FuncionPostBackIframeHijo(strIdIframe , strIdForm, strNuevaUrl)
{
try {
    var ProcesoExitoso = false;
    if(navigator.appName == "Microsoft Internet Explorer")
    {
        //IE
        if(window.frames(strIdIframe) != null &&
            window.frames(strIdIframe).document.getElementById(strIdForm) != null)
        {
            var FormEnvio = window.frames(strIdIframe).document.getElementById(strIdForm);
            
            if(FormEnvio.attributes['action'] != null)
            {
                //ASIGNA NUEVO VALOR A LA PROPIEDAD
                FormEnvio.attributes['action'].nodeValue = strNuevaUrl;
                FormEnvio.submit();
                ProcesoExitoso = true;
            }
        }
    }
    else
    {
        if(window.frames[strIdIframe] != null &&
            window.frames[strIdIframe].document.getElementById(strIdForm) != null)
        {
            var FormEnvio = window.frames[strIdIframe].document.getElementById(strIdForm);
            FormEnvio.action = strNuevaUrl;
            FormEnvio.submit();
            ProcesoExitoso = true;
        }  
    }
    if(!ProcesoExitoso)
    {
       FuncionCambioPropiedadControl(strIdIframe, 'src', strNuevaUrl);  
    }
}
    catch (e) {
}    
}
/*************************FIN FUNCION DE POSTBACK SOBRE IFRAME HIJO************************/

/*************************FUNCION MUESTRA POPUP DE LA IMAGEN DE ESTADISTICA************************/
function FuncionPopUpEstadistica(idDiv, txtMostrar)
{
try {
    FuncionCambioEstiloControl(idDiv, 'left', xMousePos + 'px');
    FuncionCambioEstiloControl(idDiv, 'top', yMousePos + 'px');
    FuncionCambioEstiloControl(idDiv, 'display', 'block')
    
    if(document.getElementById(idDiv) != null)
    {
        document.getElementById(idDiv).innerHTML = txtMostrar;
    }
}
    catch (e) {
} 
}

function captureMousePosition(e) {
try {
    if (document.layers) {
        xMousePos = e.pageX;
        yMousePos = e.pageY;
        xMousePosMax = window.innerWidth + window.pageXOffset;
        yMousePosMax = window.innerHeight + window.pageYOffset;
    } else if (document.all) {
        if(document.readyState == 'complete'){    
            var dsocleft = document.all? iecompattest().scrollLeft : pageXOffset
            var dsoctop = document.all? iecompattest().scrollTop : pageYOffset
            xMousePos = window.event.x + dsocleft;//+ document.body.scrollLeft;
            yMousePos = window.event.y + dsoctop;//+ document.body.scrollTop;
            xMousePosMax = document.body.clientWidth + document.body.scrollLeft;
            yMousePosMax = document.body.clientHeight + document.body.scrollTop;
        }
    } else if (document.getElementById) {
        xMousePos = e.pageX;
        yMousePos = e.pageY;
        xMousePosMax = window.innerWidth + window.pageXOffset;
        yMousePosMax = window.innerHeight + window.pageYOffset;
    }
}
    catch (e) {
}
}

/*************************FIN FUNCION MUESTRA POPUP DE LA IMAGEN DE ESTADISTICA************************/







/*******Leonardo Guerreero************/


function fImprime()
{	
	window.print();
}

function muestra_imagen(archivo,ancho,alto,resumen,link1){ 
try {
 xInnerHtml('c1','' + archivo);
 xInnerHtml('Label3','' + link1+ancho+'</a>');
 xInnerHtml('Label4','' + alto);
 xInnerHtml('Label5','' + resumen);
 //xInnerHtml('Label6','' + link1);
 //init(ancho,alto,resumen)
}
    catch (e) {
}
} 

//function cerrar_ampliacion(){ 
//  xHide('ampliacion'); 
//} 

function init(valor,valor1,valor3) {
try {
//document.getElementById("Label3").innerText = valor;
document.getElementById("Label4").innerText = valor1;
document.getElementById("Label5").innerText = valor3;
}
    catch (e) {
}
} 
/*******Fin Leonardo Guerrero********/

function Mostrarnew(pImagen,pAncho,pAlto)
{	
try {	
	var nom = navigator.appName;	
	
	var lImagen = document.getElementById('imgCapa');

	
	
	if(nom== "Netscape")
	{
		pAlto= pAlto +50;
		pAncho= pAncho +10;
	}			
	
	lImagen.style.width = pAncho+'px';
	lImagen.style.height = pAlto+'px'

	if(pAlto > document.body.clientHeight)
		pAlto = document.body.clientHeight;

	lImagen.src = pImagen;
	
	var x = document.getElementById('ImagenBig');
	x.style.visibility = "visible";
	x.style.height=(window.document.body.scrollHeight)+'px';

	var x = document.getElementById('ImagenBigInner');
	x.style.visibility = "visible";
	
	
	//alert(nom);
	if (nom == "Netscape")
		{
			var lPosY = window.pageYOffset;
			x.style.top=((document.body.clientHeight / 2) + window.pageYOffset)-parseInt(pAlto*40/100)+'px'; 			
		}
	else
		x.style.top =(window.document.body.scrollTop)+((document.body.clientHeight/2)-(parseInt(pAlto*45/100)))+'px';
		
	x.style.left = ((document.body.clientWidth/2)-parseInt(pAncho*50/100))+'px';
}
    catch (e) {
}
}

function Mostrar32(pImagen,pAncho,pAlto)
{
try {	
	var nom = navigator.appName;
	var lImagen = document.getElementById('imgCapa');
	if(nom== "Netscape")
	{
		pAlto= pAlto +50;
		pAncho= pAncho +10;
	}
	lImagen.style.width = pAncho+'px';
	lImagen.style.height = pAlto+'px'
	
	if(pAlto > document.body.clientHeight)
		pAlto = document.body.clientHeight;
	
	lImagen.src = pImagen;
	
	var x = document.getElementById('ImagenBig');
	x.style.visibility = "visible";
	x.style.height=(window.document.body.scrollHeight)+'px';
	
	var x = document.getElementById('ImagenBigInner');
	x.style.visibility = "visible";
	
	
	if (nom == "Netscape"){
		x.style.top=((document.body.clientHeight / 2) + window.pageYOffset)-250-parseInt(pAlto*40/100)+'px';
	}
	else{
		x.style.top =(window.document.body.scrollTop)+((document.body.clientHeight/2)-180)+'px';
	}
	    x.style.left = ((document.body.clientWidth/2)-300)+'px';
}
    catch (e) {
}
}

function Mostrarold(pImagen,pAncho,pAlto)
{
try {
	var lImagen = document.getElementById('imgCapa');
	lImagen.src = pImagen;
	var x = document.getElementById('ImagenBig');
	x.style.visibility = "visible";
	x.style.height=(window.document.body.scrollHeight)+'px';
//	x.style.top =(window.document.body.scrollTop);

	
	var x = document.getElementById('ImagenBigInner');
	x.style.visibility = "visible";
	var nom = navigator.appName;
	
	if (nom == "Netscape")
		x.style.top =((document.body.clientHeight/2)-250)+'px';
	else
		x.style.top =(window.document.body.scrollTop)+((document.body.clientHeight/2)-200)+'px';
		
	    x.style.left = ((document.body.clientWidth/2)-300)+'px';
	
	
	//var lImagen = document.getElementById('imgCapa');
	//lImagen.src = pImagen;
}
    catch (e) {
}
}

function Mostrar1(pImagen)
{
try {
	var lImagen = document.getElementById('imgCapa1');
	lImagen.src = pImagen;
	var x = document.getElementById('ImagenBig1');
	x.style.visibility = "visible";
	x.style.height=(window.document.body.scrollHeight)+'px';
//	x.style.top =(window.document.body.scrollTop);

	
	var x = document.getElementById('ImagenBigInner1');
	x.style.visibility = "visible";
	var nom = navigator.appName;
	
	if (nom == "Netscape")
		x.style.top =((document.body.clientHeight/2)-250)+'px';
	else
		x.style.top =(window.document.body.scrollTop)+((document.body.clientHeight/2)-200)+'px';
		
	    x.style.left = ((document.body.clientWidth/2)-300)+'px';
	
	
	//var lImagen = document.getElementById('imgCapa');
	//lImagen.src = pImagen;
}
    catch (e) {
}
}

function Ocultar32()
{
try {
	var x = document.getElementById('ImagenBig')
	x.style.visibility = "hidden"
	
	var x = document.getElementById('ImagenBigInner');
	x.style.visibility = "hidden";
	//window.location.reload();
}
    catch (e) {
}	
}

function Ocultar1()
{
try {
	var x = document.getElementById('ImagenBig1')
	x.style.visibility = "hidden"
	
	var x = document.getElementById('ImagenBigInner1');
	x.style.visibility = "hidden";
	//window.location.reload();
}
    catch (e) {
}
}

function cerrar()
	{
		window.parent.Ocultar();
	}
	
function Redireccionar(codpais,codciudad,nompais)
{
try {
	  window.parent.navigate('home'+ nompais +'.asp?slctpis=' + codpais + '&NomPais='+nompais+'&slctcdad=' + window.document.getElementById(codciudad).value);
}
    catch (e) {
}
}

function fnMenu(item) {
try {
   obj = document.getElementById(item);
   visible = (obj.style.display!="none")
   if (visible) {
     obj.style.display="none";
     } else {
      obj.style.display="block";
     }
}
    catch (e) {
}
}

function fnMenu1(objFuente,objDivAfectado) 
        {
        try {
        	  var ObjDiv = document.getElementById(objDivAfectado);
            var AtributoSRC = objFuente.getAttribute('src');
            var visible = (ObjDiv.style.display!="none");
            
            if (visible) {
                //CAMBIA VISUALIZACION
                ObjDiv.style.display="none";
                //CAMBIA IMAGEN
                objFuente.setAttribute('src', AtributoSRC.replace('bt_menos_colapsa.jpg','bt_mas_colapsa.jpg'));
            } 
            else {
                //CAMBIA VISUALIZACION
                ObjDiv.style.display="block";
                //CAMBIA IMAGEN
                objFuente.setAttribute('src', AtributoSRC.replace('bt_mas_colapsa.jpg','bt_menos_colapsa.jpg'));
            }
        }
           catch (e) {
        }
        }

function fnMenu2(objFuente,objDivAfectado) 
        {
        try {
        	  var ObjDiv = document.getElementById(objDivAfectado);
            var AtributoSRC = objFuente.getAttribute('src');
            var visible = (ObjDiv.style.display!="none");
            
            if (visible) {
                //CAMBIA VISUALIZACION
                ObjDiv.style.display="none";
                //CAMBIA IMAGEN
                objFuente.setAttribute('src', AtributoSRC.replace('bt_mas_colapsa.jpg','bt_menos_colapsa.jpg'));
            } 
            else {
                //CAMBIA VISUALIZACION
                ObjDiv.style.display="block";
                //CAMBIA IMAGEN
                objFuente.setAttribute('src', AtributoSRC.replace('bt_menos_colapsa.jpg','bt_mas_colapsa.jpg'));
                
            }
        }
           catch (e) {
        }    
        }        

/*****************************METODOS DE SLIDER HORIZONTAL VERTICAL*********************************************/
function AjustaTamanoSlaider(idulContenedor)
{
    var objulContenedor = document.getElementById(idulContenedor);

    if(objulContenedor != null)
    {
        var lstli = objulContenedor.getElementsByTagName('li');
        var i,altotammax = 0;
        
        for(i = 0; i < lstli.length; i++)
        {
           if(navigator.appName == "Microsoft Internet Explorer")
           {    
           	 // alert(lstli[i].offsetHeight);
           	 // alert(altotammax);
                if(lstli[i].offsetHeight > altotammax)
                    altotammax = lstli[i].offsetHeight + 25;
           }
           else 
           {
                if(lstli[i].clientHeight > altotammax)
                    altotammax = lstli[i].clientHeight + 25;
           }
        }
        
        objulContenedor.style['height'] = altotammax -10 + 'px';
        lstli[lstli.length - 1].style['height'] = altotammax  + 'px';
    }
}
/*****************************FIN METODOS DE SLIDER HORIZONTAL VERTICAL*********************************************/
/*************************************FUNCION DE VIDEOS**************************************************/
function IntroducirReproductorVideo(idDivReproductor, UrlVideo, extencionVideo, ancho, alto)
{
    var objDivContenedor = document.getElementById(idDivReproductor);
    var ContenidoDiv = "";
    try {
    if(objDivContenedor != null)
    {
        if(UrlVideo.length > 0 && extencionVideo.length > 0 && !isNaN(ancho) && !isNaN(alto))
        {
            if(extencionVideo == 'flv' || extencionVideo == 'swf')
            {
                var s1 = new SWFObject("flash/mediaplayer.swf","mediaplayer",ancho,alto,7);
                s1.addParam("allowfullscreen","true");
                s1.addVariable("width",ancho);
                s1.addVariable("height",alto);
                s1.addVariable("file",UrlVideo);
                s1.write(idDivReproductor);
            }
            else if(extencionVideo == 'wmv' || extencionVideo == 'avi' || extencionVideo == 'mpg' || extencionVideo == 'mpeg')
            {
                var TipoObjeto, Plugin, CodeBase;
                if(extencionVideo == 'mpg' || extencionVideo == 'mpeg')
                {
                    TipoObjeto = "application/x-mplayer2";
                    Plugin = "";
                    CodeBase = "";
                }
                else
                {
                    TipoObjeto = "application/x-mplayer2";
                    Plugin = "http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,0,0,0";
                    CodeBase = "http://www.microsoft.com/Windows/MediaPlayer/";
                }
                ContenidoDiv = '<object classid="clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95" width="' + ancho + 'px" height="' + alto + 'px" codebase="' + CodeBase + '"> ' +
                               '    <param name="Filename" value="' + UrlVideo + '"/> ' +
                               '    <param name="AutoStart" value="true"> ' +
                               '    <param name="ShowControls" value="true"> ' +
                               '    <param name="BufferingTime" value="2"> ' +
                               '    <param name="ShowStatusBar" value="false"> ' +
                               '    <param name="AutoSize" value="true"> ' +
                               '    <param name="InvokeURLs" value="false"> ' +
                               '    <param name="width" value="' + ancho + '"> ' +
                               '    <param name="height" value="' + alto + '"> ' +
                               '    <embed src="' + UrlVideo + '" type="' + TipoObjeto + '" autostart="1" enabled="1" showstatusbar="1" showdisplay="0" showcontrols="1" pluginspage="' + CodeBase + '" CODEBASE="' + Plugin + '" width="' + ancho + 'px" height="' + alto + 'px"></embed> ' +
                               '</object> ' 
            }
            else
            {
                ContenidoDiv = "Este video no se encuentra disponible";
            }
        }
        else
        {
            ContenidoDiv = "Este video no se encuentra disponible";
        }
        //VERIFICA SI DEBE INCLUIR CONTENIDO EN EL DIV
        if(ContenidoDiv.length > 0)
        {
            if(navigator.appName == "Microsoft Internet Explorer")
            {
                var contenidodivaux = '<div id="' + idDivReproductor + '" class="cntr_controlvideo" style="width:' + ancho +'px;height:' + alto + 'px;">' + ContenidoDiv + '</div> ';
                objDivContenedor.outerHTML = contenidodivaux;
            }
            else
            {
                objDivContenedor.innerHTML = ContenidoDiv;
            }
        }
    }
    else
    {
        alert('Error cargando video');
    }
    }
           catch (e) {
    }
}
/*************************************FIN FUNCION DE VIDEOS**************************************************/

/************************Funciones de manipulacion de iframe contenedor************************/
var ClaseIframeContenedor = function()
{
    var e;
    //CONSTRUCTOR
    
    function IframeContenedor(onombreObjeto)
    {
    try {
        this.nombreObjeto = onombreObjeto;
        this.objIframeContenedor = null;
        }
        catch (e) {
	}
    }
    //INICIALIZACION
    IframeContenedor.prototype.inicia = function(objBodyPagina)
    {
    try {
        if(objBodyPagina.frameElement != null)
        {
            objIframeContenedor = objBodyPagina.frameElement;
            eval(nombreObjeto + '.ReescalaFrame();');
        }
    }
        catch (e) {
	}
    }
    //ESCALA IFRAME
    IframeContenedor.prototype.ReescalaFrame = function()
    {   
		
        if(objIframeContenedor != null)
        {
			
        	var ymax = 0;
            //CAPTURA ALTO Y ANCHO DE LA PAGINA DE CONTENIDO
            if(BrowserDetect.browser == "Firefox")
            {
            
                ymax = objIframeContenedor.contentWindow.scrollMaxY + objIframeContenedor.contentWindow.innerHeight;                
            
            }
            else
            {
           
                ymax = objIframeContenedor.contentWindow.document.body.scrollHeight;                     
            }
						
            objIframeContenedor.style['height'] = ymax + 'px';
			
        }
		
    }
    //FUNCION DE NAVEGACION GLOBAL
    IframeContenedor.prototype.RedirectTotal = function(strUrlDestino)
    {
    try {
        if(window.parent != null && strUrlDestino.length > 0)
        {
            window.parent.location.href = strUrlDestino;
        }
    }
        catch (e) {
	}
    }
    //FUNCIONES DE USO GENERAL
    function iecompattest(){
    try {
        return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
    }
        catch (e) {
	}
    }    
    return{IframeContenedor:IframeContenedor}
}();
/************************Fin Funciones de manipulacion de iframe contenedor************************/

/**************************FUNCION DE MUESTRA DE MENSAJES INFORMATIVOS***************************/
var ClaseLightBox = function()
{
    function LightBox(onombreObjeto,iddivSobrepuesto, iddivpostBack)
    {
    try {
        this.nombreObjeto = onombreObjeto;
        this.objDivSobrepuesto = document.getElementById(iddivSobrepuesto);
        this.objDivPostBack = document.getElementById(iddivpostBack);
        
        
        this.AltoPagina = 0;
        this.AnchoPagina = 0;
        
        this.objAjax = new ClaseAjax.Ajax('this.objAjax');
        
        this.lstObjSelect = null;
    }
        catch (e) {
	}
    }
    LightBox.prototype.inicia = function()
    {   
        //INICIA ELEMENTOS DE LIGHTBOX GRANDE
    try {
        if(BrowserDetect.browser == "Firefox")
        {
            this.AltoPagina = window.scrollMaxY + window.innerHeight;
            this.AnchoPagina = window.scrollMaxX + window.innerWidth;
        }
        else
        {
            this.AltoPagina = window.document.body.scrollHeight;
            this.AnchoPagina = window.document.body.scrollWidth;            
        }
        if(this.objDivSobrepuesto != null && this.objDivPostBack != null)
        {
            //INICIA PROPIEDADES DEL MENSAJE GLOBAL
            this.objDivSobrepuesto.style['display'] = 'none';
            this.objDivSobrepuesto.style['position'] = 'absolute';
            this.objDivSobrepuesto.style['top'] = '0px';
            this.objDivSobrepuesto.style['left'] = '0px';
            this.objDivSobrepuesto.style['width'] = '0px';
            this.objDivSobrepuesto.style['height'] = '0px';
        }
        //CAPTURA TODOS LOS SELECT QUE EXISTEN EN EL FORMULARIO
        this.lstObjSelect = document.getElementsByTagName('select');
    }
        catch (e) {
	}
    }
    //MUESTRA MENSAJE SOBRE LA VENTANA TOTAL
    LightBox.prototype.MostrarTotalMensaje = function(strMensaje)
    {
        var i;
        try {
        if(this.objDivSobrepuesto != null && this.objDivPostBack != null)
        {
            //CAPTURA POSICION ACTUAL DE LA VENTANA
            var topActual = document.all? iecompattest().scrollTop : pageYOffset;
            topActual = topActual + 20;
        
            //MUESTRA MENSAJE
            this.objDivPostBack = CambiaContenidoDiv(this.objDivPostBack.id, strMensaje);

            this.objDivSobrepuesto.style['display'] = 'block';
            this.objDivSobrepuesto.style['width'] = this.AnchoPagina + 'px';
            this.objDivSobrepuesto.style['height'] = this.AltoPagina + 'px';
            this.objDivSobrepuesto.zIndex = '500';
            
            this.objDivPostBack.style['margin'] = topActual + 'px' + ' 0px 0px 0px';
            
            //OCULTA LOS OBJETOS SELECT EN IE
            if(BrowserDetect.browser == 'Explorer')
            {
                if(this.lstObjSelect != null)
                {
                    for(i = 0; i < this.lstObjSelect.length; i++)
                    {
                        this.lstObjSelect[i].style['visibility'] = 'hidden';
                    }
                }
            }
        }
    }
        catch (e) {
	}        
    } 
    //MUESTRA PETICION URL SOBRE LA VENTANA TOTAL
    LightBox.prototype.MostrarTotalURL = function(strURL, Parametros)
    {
    try {
        if(this.objDivSobrepuesto != null && this.objDivPostBack != null)
        {
            //CAPTURA POSICION ACTUAL DE LA VENTANA
            var topActual = document.all? iecompattest().scrollTop : pageYOffset;
            topActual = topActual + 20;
                    
            //REALIZA POSTBACK SINCRONICO
            var strResultado = this.objAjax.RealizaPostBackSincrono(strURL, 'POST', 1, Parametros);
            //MUESTRA MENSAJE
            this.objDivPostBack = CambiaContenidoDiv(this.objDivPostBack.id, strResultado);

            this.objDivSobrepuesto.style['display'] = 'block';
            this.objDivSobrepuesto.style['width'] = this.AnchoPagina + 'px';
            this.objDivSobrepuesto.style['height'] = this.AltoPagina + 'px';
            this.objDivSobrepuesto.zIndex = '500';
            
            this.objDivPostBack.style['margin'] = topActual + 'px' + ' 0px 0px 0px';
        }
    }
        catch (e) {
	}        
    }  
    //OCULTA LIGHTBOX TOTAL  
    LightBox.prototype.OcultarTotal = function()
    {
    try {
        if(this.objDivSobrepuesto != null && this.objDivPostBack != null)
        {
            //MUESTRA MENSAJE
            this.objDivPostBack = CambiaContenidoDiv(this.objDivPostBack.id, '');

            this.objDivSobrepuesto.style['display'] = 'none';
            this.objDivSobrepuesto.style['width'] = '0px';
            this.objDivSobrepuesto.style['height'] = '0px';
            this.objDivSobrepuesto.zIndex = '0';
            
            this.objDivPostBack.style['margin'] = '0px';
            
            //MUESTRA LOS OBJETOS SELECT EN IE
            if(BrowserDetect.browser == 'Explorer')
            {
                if(this.lstObjSelect != null)
                {
                    for(i = 0; i < this.lstObjSelect.length; i++)
                    {
                        this.lstObjSelect[i].style['visibility'] = '';
                    }
                }
            }            
        }
    }
        catch (e) {
	}        
    } 
    //FUNCION QUE MUESTRA NUBE INFORMATIVA AL COSTADO DEL CONTROL
    LightBox.prototype.MuestraNubeLadoControl = function(idDivMostrar,strMensaje,strPlantilla)
    {
    try {
        var objDivMostrar = document.getElementById(idDivMostrar);
        if(objDivMostrar != null)
        {
            objDivMostrar = CambiaContenidoDiv(idDivMostrar,strPlantilla.replace('##mensaje##',strMensaje));
            objDivMostrar.style['display'] = 'block';
        }
    }
        catch (e) {
	}
    }
    //FUNCION QUE OCULTA NUBE INFORMATIVA AL COSTADO DEL CONTROL
    LightBox.prototype.OcultaNubeLadoControl = function(idDivMostrar)
    {
    try {
        var objDivMostrar = document.getElementById(idDivMostrar);
        if(objDivMostrar != null)
            objDivMostrar.style['display'] = 'none';
    }
        catch (e) {
	}    
    }
    //FUNCIONES DE USO GENERAL   
    function CambiaContenidoDiv(idDiv ,strNuevoContenido)
    {
    try {
        var objDiv = document.getElementById(idDiv);    
        if(objDiv != null)
        {
            if(BrowserDetect.browser == 'Explorer')
            {
                objDiv.outerHTML = objDiv.outerHTML.substring(0,1 + objDiv.outerHTML.indexOf('>')) + strNuevoContenido + '</div>';                
            }
            else
            {
                objDiv.innerHTML = strNuevoContenido;
            }
            return document.getElementById(idDiv);
        }
        else
            return null;
    }
        catch (e) {
	}
    }
    function iecompattest()
    {
    try {
    return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
    }
        catch (e) {
	}
    }

    return{LightBox:LightBox}
}();
/**************************FIN FUNCION DE MUESTRA DE MENSAJES INFORMATIVOS***************************/

/**************************FUNCION DE MUESTRA DE MENSAJES INFORMATIVOS***************************/
var ClasePaginador = function()
{
    function Paginador(onombreObjeto,oidContenerdorLista,omaxItemsPagina,omaxPaginasHoja,oidDivContenedorPaginador,onombreobjIframeContenedor,oplantillaPaginador,oplantillaPaginaAtras,oplantillaPaginaAdelante,oPlantillaItemSeleccionado,oPlantillaItem, oPlantillaSeparador)
    {
    try {
        this.nombreObjeto = onombreObjeto;
        this.ContenerdorLista = null;
        this.idContenerdorLista = oidContenerdorLista;
        this.lstElementosPaginar = null;
        this.maxItemsPagina = new Number(omaxItemsPagina);
        if(this.maxItemsPagina == 0)
        	this.maxItemsPagina = 3;
        this.maxPaginasHoja = new Number(omaxPaginasHoja);
        if(this.maxPaginasHoja == 0)
        	this.maxPaginasHoja = 5;
        	
        this.idDivContenedorPaginador = oidDivContenedorPaginador;
        this.nombreobjIframeContenedor = onombreobjIframeContenedor;
        	
        this.NumeroPaginas = 0;
        this.NumeroHojas = 0;

				this.HojaActual = 0;
        this.PaginaActual = 0;
        this.ItemActual = 0;

        
        this.plantillaPaginador = oplantillaPaginador;
        this.plantillaPaginaAtras = oplantillaPaginaAtras.replace('**href**', 'javascript:' + this.nombreObjeto + '.CambiaHoja(\'-\');');
        this.plantillaPaginaAdelante = oplantillaPaginaAdelante.replace('**href**', 'javascript:' + this.nombreObjeto + '.CambiaHoja(\'+\');');
        this.PlantillaItemSeleccionado = oPlantillaItemSeleccionado;
        this.PlantillaItem = oPlantillaItem; 
        this.PlantillaSeparador = oPlantillaSeparador;
    }
        catch (e) {
	}
        	
    }
    Paginador.prototype.inicia = function()
    { 
    	var i;
    try {  
      this.ContenerdorLista = document.getElementById(this.idContenerdorLista);

    	if(this.ContenerdorLista != null)
    	{
    		//obtiene la lista total de items
    		this.lstElementosPaginar = this.ContenerdorLista.getElementsByTagName('dt');
    		//obtiene los valores iniciales del paginador
    		this.NumeroPaginas =  Math.ceil(this.lstElementosPaginar.length / this.maxItemsPagina);
    		this.NumeroHojas = Math.ceil(this.NumeroPaginas/this.maxPaginasHoja);
    		
    		eval(this.nombreObjeto + '.CambiaHoja(\'i\');');
    	}
    }
        catch (e) {
	}
  	}
  	Paginador.prototype.CambiaHoja = function(Accion)
  	{
  	try {
  		//obtiene la nueva pagina
  		if(Accion == 'i')
  		{
  			this.HojaActual = 0;
  		}
  		else if(Accion == '+')
  		{
  			this.HojaActual++;
				if(this.HojaActual > this.NumeroHojas)
					this.HojaActual = this.NumeroHojas - 1;
  		}
  		else// if(Accion == '-')
  		{
  				this.HojaActual--;
  				if(this.HojaActual < 0)
  					this.HojaActual = 0;
  		}
  		
  		//obtiene la pagina actual
  		this.PaginaActual = this.HojaActual * this.maxPaginasHoja;
  		//obtiene el primer item de la pagina
  		this.ItemActual = this.PaginaActual * this.maxItemsPagina;
  		//muestra los items y el paginador
  		eval(this.nombreObjeto + '.MuestraItems();');
    }
        catch (e) {
	}
  	}
  	Paginador.prototype.CambiaPagina = function(intNuevaPagina)
  	{
  	try {
  		if(!isNaN(intNuevaPagina))
  		{
  				//obtiene pagina actual
				  this.PaginaActual = intNuevaPagina;
				  if(this.PaginaActual < 0)
				  {
				  	this.PaginaActual = 0;
				  }
				  else if(this.PaginaActual > this.NumeroPaginas)
				  {
				  	this.PaginaActual = this.NumeroPaginas - 1;
				  }
				  //obtiene el primer item de la pagina
  				this.ItemActual = this.PaginaActual * this.maxItemsPagina;
		  		//muestra los items y el paginador
		  		eval(this.nombreObjeto + '.MuestraItems();');
  		}
    }
        catch (e) {
	}
  	}
  	Paginador.prototype.MuestraItems = function()
  	{
  	try {
  		//muestra y oculta los items adecuados
  		for(i=0; i < this.lstElementosPaginar.length; i++)
    	{
    			//oculta o muestra los items
    			if(i >= this.ItemActual && i < (this.ItemActual + this.maxItemsPagina))
    			{
    				this.lstElementosPaginar[i].style['display'] = 'block';
    			}
    			else
    			{
    				this.lstElementosPaginar[i].style['display'] = 'none';
    			}
    	}
    	eval(this.nombreObjeto + '.MuestraPaginador();');
    }
        catch (e) {
	}
  	}
  	Paginador.prototype.MuestraPaginador = function()
  	{
  	try {
  		var DivContenedorPaginador = document.getElementById(this.idDivContenedorPaginador);
  		if(DivContenedorPaginador != null && this.NumeroPaginas > 1)
  		{
  			var i, ctrlItemsMostrar = '', ctrlPaginador;
  			var PaginaInicial = this.HojaActual * this.maxPaginasHoja;
  			var PaginaFinal = (this.HojaActual + 1) * this.maxPaginasHoja;
  			if(PaginaFinal > this.NumeroPaginas)
  			{
  				PaginaFinal = this.NumeroPaginas;
  			}
  			
  			for(i = PaginaInicial; i < PaginaFinal; i++)
  			{
  				if(i == this.PaginaActual)
  				{
  					ctrlItemsMostrar = ctrlItemsMostrar + this.PlantillaItemSeleccionado.replace('**item**',i + 1);
  				}
  				else
  				{
  					ctrlItemsMostrar = ctrlItemsMostrar + this.PlantillaItem.replace('**item**', i + 1).replace('**href**','javascript:'+ this.nombreObjeto +'.CambiaPagina(' + i + ');');
  				}
  				if((i + 1) < PaginaFinal)
  				{ 
  					ctrlItemsMostrar = ctrlItemsMostrar + this.PlantillaSeparador;
  				}
  			}
	  		//muestra pagina adelante y atras
	  		if(this.HojaActual > 0)
	  		{
	  			ctrlPaginador = this.plantillaPaginador.replace('**PaginaAtras**',this.plantillaPaginaAtras);
	  		}
	  		else
	  		{
	  			ctrlPaginador = this.plantillaPaginador.replace('**PaginaAtras**','');
	  		}
	  		if(this.HojaActual < (this.NumeroHojas - 1))
	  		{
	  			ctrlPaginador = ctrlPaginador.replace('**PaginaAdelante**',this.plantillaPaginaAdelante);
	  		}
	  		else
	  		{
	  			ctrlPaginador = ctrlPaginador.replace('**PaginaAdelante**','');
	  		}
	  		ctrlPaginador = ctrlPaginador.replace('**items**',ctrlItemsMostrar);
	  		
	  		//muestra el paginador final
	  		if(BrowserDetect.browser == 'Explorer')
        {
            DivContenedorPaginador.outerHTML = '<div id="' + this.idDivContenedorPaginador + '">' + ctrlPaginador + '</div>';
        }
        else
        {
            DivContenedorPaginador.innerHTML = ctrlPaginador;
        }
        //si esta dentro de un iframe se reescala el iframe
        if(this.nombreobjIframeContenedor.length > 0)
        {
        	eval(this.nombreobjIframeContenedor + '.ReescalaFrame();');
        }
  		}
  	}
        catch (e) {
	}
  	}
    return{Paginador:Paginador}
}();
    	
/**************************FUNCION DE MUESTRA DE MENSAJES INFORMATIVOS***************************/

/**************************FUNCION DE LICITACIONES************************************************/
var ClaseLicitaciones = function()
{
    //CONSTRUCTOR
    function Licitaciones(onombreObjeto)
    {
    try {
        this.nombreObjeto = onombreObjeto;
        this.objAjaxLicitaciones = null;
        this.lstFiltrosAplicados = '';
    }
        catch (e) {
	}
    }
    //INICIALIZACION
    Licitaciones.prototype.inicia = function()
    {
    try {
        this.objAjaxLicitaciones = new ClaseAjax.Ajax(this.nombreObjeto + '.objAjaxLicitaciones');
        this.objAjaxLicitaciones.inicia();
    }
        catch (e) {
	}
    }
    //FUNCION DE PAGINACION
    Licitaciones.prototype.Paginar = function(intNuevaPagina,idDivContenedor, idFormFiltro)
    {
    try {
        var i, strFiltro;
        var objFormFiltro = document.getElementById(idFormFiltro);
        if(intNuevaPagina > 0 && objFormFiltro != null)
        {
            //ARMA CADENA DE POSTBACK CON LOS VALORES DE LOS FILTROS SELECCIONADOS
            var lstInput = objFormFiltro.getElementsByTagName('input');
            strFiltro = '';
            for(i = 0; i < lstInput.length; i++)
            {
                strFiltro = strFiltro + lstInput[i].name + '=' + lstInput[i].value + '&';
            }
            //REALIZA POSTBACK ASINCRONO DE NUEVO CONTENIDO DE LA PAGINA
            this.objAjaxLicitaciones.RealizaPostBackAsincronico('programas/licitaciones/Licitacion_Buscador_v2.asp', 'POST', this.nombreObjeto + '.FinPaginar(\\\'' + idDivContenedor + '\\\')', 1, strFiltro + 'isCallBack=1&Accion=Paginar&NuevaPagina=' + intNuevaPagina)
        }
    }
        catch (e) {
	}
    }
    Licitaciones.prototype.FinPaginar = function(idDivContenedor)
    {
    try {
        if(this.objAjaxLicitaciones.objRespuestaPostback != 'false')
        {
            CambiaContenidoDiv(idDivContenedor,this.objAjaxLicitaciones.objRespuestaPostback);
        }
        else
        {
            //ERROR EN LA EJECUCION DE LA PAGINACION
        }
    }
        catch (e) {
	}
    }
    //FUNCIONES DE FILTRADO
    Licitaciones.prototype.InvocarFiltro = function(idFormFiltro, idInputFiltro, strNuevoValor)
    {
    try {
        var objFormFiltro = document.getElementById(idFormFiltro);    
        var objInputFiltro = document.getElementById(idInputFiltro);         
        if(objFormFiltro != null)
        {
            if(objInputFiltro == null)
            {
                //INSERTA NUEVO FILTRO SELECCIONADO
                var NuevoNodo = document.createElement('input');
                NuevoNodo.setAttribute('id',idInputFiltro);
                NuevoNodo.setAttribute('name',idInputFiltro);
                NuevoNodo.setAttribute('type','hidden');
                NuevoNodo.setAttribute('value',strNuevoValor);
                objFormFiltro.appendChild(NuevoNodo)
            }
            else 
            {
                //CAMBIA EL VALOR DEL FILTRO SELECCIONADO
                objInputFiltro.value = strNuevoValor;
            }
            //REALIZA SUBMIT DEL FORM
            objFormFiltro.submit();
        }
    }
        catch (e) {
	}
    }
    Licitaciones.prototype.EliminarFiltro = function(idFormFiltro, idInputFiltro)
    {
    try {
        var objFormFiltro = document.getElementById(idFormFiltro);    
        var objInputFiltro = document.getElementById(idInputFiltro);         
        if(objFormFiltro != null)
        {
            if(objInputFiltro != null)
            {
                //REMUEVE EL NODO DEL FORM
                objInputFiltro.setAttribute('id','');
                objInputFiltro.setAttribute('name','');
                objInputFiltro.setAttribute('value','');
            }
            //REALIZA SUBMIT DEL FORM
            objFormFiltro.submit();
        }
    }
        catch (e) {
	}
    }
    //FUNCION DE ACTUALIZACION CIUDADES
    Licitaciones.prototype.ActualizaCiudad = function(idDivContenedor,idCtrlDpto,idCtrlTipo,idCtrlEnt,idCtrlCat)
    {
    try {
        var objDpto = document.getElementById(idCtrlDpto);
        if(objDpto != null)
        {
            var lstAux = objDpto.value.split('|');
            var objTipo = document.getElementById(idCtrlTipo);
            if(objTipo != null)
            {
                var lstAux1 = objTipo.value.split('|');
            }
            var objEnt = document.getElementById(idCtrlEnt);
            if(objEnt != null)
            {
                var lstAux2 = objEnt.value.split('|');
            }
            var objCat = document.getElementById(idCtrlCat);
            if(objCat != null)
            {
                var lstAux3 = objCat.value.split('|');
            }
            if(lstAux.length >= 2 && !isNaN(lstAux[0]))
            {
                //REALIZA POSTBACK ASINCRONO DE NUEVO CONTENIDO DE LA PAGINA
                this.objAjaxLicitaciones.RealizaPostBackAsincronico('programas/licitaciones/Licitacion_v2.asp', 'POST', this.nombreObjeto + '.FinActualizaCiudad(\\\'' + idDivContenedor + '\\\')', 1, 'isCallBack=1&Accion=Ciudad&Dpto=' + lstAux[0] + '&Tipo=' + lstAux1[0] + '&Entidad=' + lstAux2[0] + '&Categoria=' + lstAux3[0]);
            }
        }
    }
        catch (e) {
	}
    }
    Licitaciones.prototype.ActualizaCiudadAgente = function(idDivContenedor, idCtrlDpto)
    {
    try {
        var objDpto = document.getElementById(idCtrlDpto);
        if(objDpto != null)
        {
            if(!isNaN(objDpto.value))
            {
                //REALIZA POSTBACK ASINCRONO DE NUEVO CONTENIDO DE LA PAGINA
                this.objAjaxLicitaciones.RealizaPostBackAsincronico('programas/licitaciones/Licitacion_Agente_v2.asp', 'POST', this.nombreObjeto + '.FinActualizaCiudad(\\\'' + idDivContenedor + '\\\')', 1, 'isCallBack=1&Accion=Ciudad&Dpto=' + objDpto.value);
            }
        }
    }
        catch (e) {
	}
    }
    Licitaciones.prototype.FinActualizaCiudad = function(idDivContenedor)
    {
    try {
        CambiaContenidoDiv(idDivContenedor,this.objAjaxLicitaciones.objRespuestaPostback);
    }
        catch (e) { 
	}
    }
    
    //Prueba filtros
    
    //FUNCION DE ACTUALIZACION CIUDADES
    Licitaciones.prototype.ActualizaFiltro = function(idDivContenedor,idCtrlDpto,idCtrlDpto1,idCtrlDpto2,filtro,origen)
    {
    try {
        var objDpto = document.getElementById(idCtrlDpto);
        var objDpto1 = document.getElementById(idCtrlDpto1);
        var objDpto2 = document.getElementById(idCtrlDpto2);
        if(objDpto != null)
        {
            var lstAux = objDpto.value.split('|');
            //alert("aqui"+lstAux[0]);
            //if(lstAux.length >= 2 && !isNaN(lstAux[0]))
            //{
                //REALIZA POSTBACK ASINCRONO DE NUEVO CONTENIDO DE LA PAGINA
                var lstAux1;
                var lstAux2;
                if(objDpto1 != null)
                {
                    lstAux1 = objDpto1.value.split('|');
                }
                else
                {
                    lstAux1=('')
                }
                if(objDpto2 != null)
                {
                    lstAux2 = objDpto2.value.split('|');
                }
                else
                {
                    lstAux2=('')
                }
                if (origen == 1)
                {
                    this.objAjaxLicitaciones.RealizaPostBackAsincronico('programas/licitaciones/Licitacion_v2.asp', 'POST', this.nombreObjeto + '.FinActualizaEntidad(\\\'' + idDivContenedor + '\\\')', 1, 'isCallBack=1&Accion=' + filtro +'&Tipo=' + lstAux[0], origen);
                }
                if (origen == 2)
                {
                    this.objAjaxLicitaciones.RealizaPostBackAsincronico('programas/licitaciones/Licitacion_v2.asp', 'POST', this.nombreObjeto + '.FinActualizaEntidad(\\\'' + idDivContenedor + '\\\')', 1, 'isCallBack=1&Accion=' + filtro +'&Entidad=' + lstAux[0] + '&Tipo=' + lstAux1[0], origen);
                }
                if (origen == 3)
                {
                    this.objAjaxLicitaciones.RealizaPostBackAsincronico('programas/licitaciones/Licitacion_v2.asp', 'POST', this.nombreObjeto + '.FinActualizaEntidad(\\\'' + idDivContenedor + '\\\')', 1, 'isCallBack=1&Accion=' + filtro +'&Categoria=' + lstAux[0] + '&Entidad=' + lstAux1[0] + '&Tipo=' + lstAux2[0], origen);
                }
            //}
        }
    }
        catch (e) {
	}
    }
    Licitaciones.prototype.FinActualizaEntidad = function(idDivContenedor,origenfiltro)
    {
    try {
        
        CambiaContenidoDiv(idDivContenedor,this.objAjaxLicitaciones.objRespuestaPostback);
        //alert(ajaxentro);
        if (origenfiltro == 1)
        {   
             if (ajaxentro == 1) 
            {
              objLicitaciones.ActualizaFiltro('divCategorias','param','Categoria',1);
              ajaxentro=2;
            }
            if (ajaxentro == 2) 
            {
              objLicitaciones.ActualizaFiltro('divDepartamentos','param','Depto',1);
              ajaxentro=0;
            }
        }
        else
        {
            if (ajaxentro == 1) 
            {
              objLicitaciones.ActualizaFiltro('divDepartamentos','Id_EmpresaLicitante','Depto',2);
              ajaxentro=2;
            }
        }
       
        
    }
        catch (e) {
	}
    }
    
    
    
    //Fin Prueba filtros 
    
    //FUNCIONES DE USO GENERAL   
    function CambiaContenidoDiv(idDiv ,strNuevoContenido)
    {
    try {
        var objDiv = document.getElementById(idDiv);    
        if(objDiv != null)
        {
            if(BrowserDetect.browser == 'Explorer')
            {
                objDiv.outerHTML = objDiv.outerHTML.substring(0,1 + objDiv.outerHTML.indexOf('>')) + strNuevoContenido + '</div>';                
            }
            else
            {
                objDiv.innerHTML = strNuevoContenido;
            }
            return document.getElementById(idDiv);
        }
        else
            return null;
    }
        catch (e) {
	}
    }
    return{Licitaciones:Licitaciones}
}();
/**************************FIN FUNCION DE LICITACIONES********************************************/

var objAjaxLeo = new ClaseAjax.Ajax('objAjaxLeo');
objAjaxLeo.inicia();
function Ajax2Niveles(idcontrolevaluar, url)
{
try {  
	objAjaxLeo.RealizaPostBackAsincronico(url, 'POST', 'fnCambiarContenidoDiv(\\\'' + idcontrolevaluar + '\\\')', 1, 'posvector= 0')
}
    catch (e) {
}
}

function fnCambiarContenidoDiv(iddropdown)
{
try {
    var objDdlCambiar = document.getElementById(iddropdown);
    if(objDdlCambiar != null)
    {  
        if(navigator.appName == "Microsoft Internet Explorer")
        {
            objDdlCambiar.innerHTML = objAjaxLeo.objRespuestaPostback;
        }
        else
        {
            objDdlCambiar.innerHTML = objAjaxLeo.objRespuestaPostback;
        }
    }
}
    catch (e) {
}
}

function VotarArticulo(idobj, possel)
{
try {	
	 if(!isNaN(possel))
                    {
                        var i;
                        for(i = 1; i < 6; i++)
                        {
                            var objDiv = document.getElementById(idobj + i);
                            if(objDiv != null)
                            {
                                if(i <= possel)
                                {
                                    objDiv.className = 'btn_staron';
                                }
                                else
                                {
                                    objDiv.className = 'btn_starof';
                                }
                            }
                            else
                            {
                                break;
                            }
                        }
                    }
}
    catch (e) {
}
}

function VotarArticuloout(idobj, possel)
{
try {	
	 if(!isNaN(possel))
                    {
                        var i;
                        for(i = 1; i < 6; i++)
                        {
                            var objDiv = document.getElementById(idobj + i);
                            if(objDiv != null)
                            {
                                if(i <= possel)
                                {
                                    objDiv.className = 'btn_staron';
                                }
                                else
                                {
                                    objDiv.className = 'btn_starof';
                                }
                            }
                            else
                            {
                                break;
                            }
                        }
                    }
}
    catch (e) {
}
}

function fnMenu1(objFuente,objDivAfectado) 
{
try {
        	  var ObjDiv = document.getElementById(objDivAfectado);
            var AtributoSRC = objFuente.getAttribute('src');
            var visible = (ObjDiv.style.display!="none");
            
            if (visible) {
                //CAMBIA VISUALIZACION
                ObjDiv.style.display="none";
                //CAMBIA IMAGEN
                objFuente.setAttribute('src', AtributoSRC.replace('bt_menos_colapsa.jpg','bt_mas_colapsa.jpg'));
            } 
            else {
                //CAMBIA VISUALIZACION
                ObjDiv.style.display="block";
                //CAMBIA IMAGEN
                objFuente.setAttribute('src', AtributoSRC.replace('bt_mas_colapsa.jpg','bt_menos_colapsa.jpg'));
            }
}
    catch (e) {
}
}
