/*************FUNCIONES JAVASCRIPT PROGRAMAS DESARROLLADOS JAIRO****************/

/************************************FUNCIONES BASICAS DE AJAX**********************************************/
//VARIABLES GLOBALES FUNCIONAMIENTO DEL COMPONENTE AJAX
var objXmlHttpPostBack;
var objRespuestaPostback;
var objTemporizadorPostback;
var objFuncionFinalizacionPostBack;
var objTipoRespuestaPostBack = 0;

//INICIA LAS VARIABLES GLOBALES DEL COMPONENTE AJAX
objXmlHttpPostBack = CreaObjetoAjax();

//FUNCION CREA EL OBJETO AJAX QUE REALIZA EL POSTBACK
function CreaObjetoAjax() 
{ 
    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;
} 
//FUNCION QUE REALIZA EL LLAMADO ASINCRONICO
function RealizaPostBackAsincronico(UrlLlamado, MetodoLlamado, FuncionFinalizacion, TipoRespuesta, Parametros)
{
    //LIMPIA Y DETIENE EL TEMPORIZADOR
    clearTimeout(objTemporizadorPostback);
    if(objXmlHttpPostBack)
    {
        //while(objXmlHttpPostBack.readyState == 0 || objXmlHttpPostBack.readyState == 4){}
    
        if(objXmlHttpPostBack.readyState == 0 || objXmlHttpPostBack.readyState == 4)
        {
            if(UrlLlamado.length > 0 && FuncionFinalizacion.length > 0)
            {
                objFuncionFinalizacionPostBack = FuncionFinalizacion;
                objTipoRespuestaPostBack = TipoRespuesta;
                objRespuestaPostback = '';
                objXmlHttpPostBack.onreadystatechange = CambioEstadoRequest;
                objXmlHttpPostBack.open(MetodoLlamado,UrlLlamado,true);
                if(MetodoLlamado == 'POST')
                {
                    objXmlHttpPostBack.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
                    objXmlHttpPostBack.setRequestHeader("Content-length", Parametros.length);
                    objXmlHttpPostBack.setRequestHeader("Connection", "close");            
                    objXmlHttpPostBack.send(Parametros);                
                }
                else
                    objXmlHttpPostBack.send(null);
            }
            else
            {
                //alert('parametros incompletos');
            }
        }
        else
        {
            //alert('Procesando solicitud...');
        }
    }
}
//FUNCION QUE ATIENDE EL LLAMADO ASINCRONICO
function CambioEstadoRequest()
{
    //if(objXmlhttp.readyState == 1){CARGANDO}
    //else if(objXmlhttp.readyState == 2){SIN CONTENIDO}
    //else if(objXmlhttp.readyState == 3){INGRESANDO OBJETOS}
    //else if(objXmlhttp.readyState == 4){COMPLETA}
    if(objXmlHttpPostBack.readyState == 4)
    {
        if(objXmlHttpPostBack.status == 200)
        {
            if(objTipoRespuestaPostBack == 0)
            {
                objRespuestaPostback = objXmlHttpPostBack.responseXML;
            }
            else
            {
                objRespuestaPostback = objXmlHttpPostBack.responseText;
            }
            objTemporizadorPostback = setTimeout(objFuncionFinalizacionPostBack, 1);
            
        }
        else
        {
			if(typeof console != 'undefined')
				console.error('Error de Servidor Respuesta de la peticion : ' + objXmlHttpPostBack.status);
            //alert('Error de Servidor Respuesta de la peticion : ' + objXmlHttpPostBack.status);
            //alert(objXmlHttpPostBack.responseText);
        }
    }
    else
    {
        //EJECUTA FUNCION DE ESPERA DE LA RESPUESTA
        //alert(objXmlHttpPostBack.readyState)
    }
}

/************************************FIN FUNCIONES BASICAS DE AJAX**********************************************/
//ejemplos
/*function Prueba()
{
    //RealizaPostBackAsincronico("pruebaajax.asp?IsCallBack=1&param1=tag&param2=en estó", "GET", "pruebarx()",1)
}
function pruebarx()
{
    //alert(objRespuestaPostback);
}*/

/************************************PETICIONES AJAX**********************************************/
//FUNCION ACTUALIZA DROPDOWN CARRITO COMPRAS
function ActualizaddTipoPago(iddropdown, codPedidoProducto)
{
    var objDdlCambiar = document.getElementById(iddropdown);
    if(objDdlCambiar != null)
    {  
        if(navigator.appName == "Microsoft Internet Explorer")
        {
            objDdlCambiar.outerHTML = objRespuestaPostback;
        }
        else
        {
            objDdlCambiar.innerHTML = objRespuestaPostback;
        }
        //RECALCULA EL CARRITO
        setTimeout("RecalcularSubtotalesCarrito('" + codPedidoProducto  + "', 1)", 1);
    }
}
//FUNCION FIN ALMACENAMIENTO ASINCRONICO DE CAMBIOS EN EL CARRITO
function FinGuardaCambiosCarrito(){}

//FUNCION DE LLAMADO DEL DOCUMENTO DE REPRODUCCION DE VIDEOS
function CallBackDocumentoVideo(UrlLlamado, FuncionFin, Estado, Parametros)
{
    if(Estado == 1)
    {
        RealizaPostBackAsincronico(UrlLlamado,'POST',FuncionFin,1,Parametros);
    }
    else if(objLightBox != null)
    {
        if(Estado == 2 && strMensajeRegistreseVideos != null)
        {
            objLightBox.MostrarTotalMensaje(strMensajeRegistreseVideos);
        }
        else if(Estado == 3 && strMensajeActivarModuloVideos != null)
        {
            objLightBox.MostrarTotalMensaje(strMensajeActivarModuloVideos);
        }
    }
}
function FinCallBackDocumentoVideo(iddivcontenido)
{
    var objCambiar = document.getElementById(iddivcontenido);
    if(objCambiar != null)
    {  
        if(navigator.appName == "Microsoft Internet Explorer")
        {
            objCambiar.outerHTML = '<div id="' + iddivcontenido + '">' + objRespuestaPostback + '</div>';
        }
        else
        {
            objCambiar.innerHTML = objRespuestaPostback;
        }
        //INVOCA EL PRIMER VIDEO
        LlamaPrimerVideoDocumento();
        if(document.getElementById('divlstVideosSeleccionados') != null)
        {
            if(objRespuestaPostback.indexOf('tagcantidadvideosrelacionados') > 0)
            {
               var numitems = objRespuestaPostback.substring(objRespuestaPostback.indexOf('tagcantidadvideosrelacionados'), objRespuestaPostback.indexOf('>',objRespuestaPostback.indexOf('tagcantidadvideosrelacionados')));
               numitems = numitems.replace(/\"/g,'');
               numitems = numitems.replace(/=/g,'');
               numitems = numitems.replace(/tagcantidadvideosrelacionados/g,'');

                if(!isNaN(numitems) && numitems == 0)
                {
                    document.getElementById('divlstVideosSeleccionados').style['display']='none';
                }
            }
        }
    }
}
function LlamaPrimerVideoDocumento()
{
    var objlnkPrimerVideo = document.getElementById('lnk_PrimerVideoGenerado');
    if(objlnkPrimerVideo != null && objlnkPrimerVideo.href != null)
    {
        eval(objlnkPrimerVideo.href.replace('javascript:',''));
    }
}

function FinCallBackListadoVideos(iddivcontenido)
{
    var objCambiar = document.getElementById(iddivcontenido);
    if(objCambiar != null)
    {  
        if(navigator.appName == "Microsoft Internet Explorer")
        {
            objCambiar.outerHTML = '<div id="' + iddivcontenido + '" class="column02_video">' + objRespuestaPostback + '</div>';
        }
        else
        {
            objCambiar.innerHTML = objRespuestaPostback;
        }
    }
}

/************************************FIN PETICIONES AJAX**********************************************/

/********************************CALCULOS CARRITO**********************************************/
function FormatoPesosCarrito(Valor)
{
	var ValorRetorno = '0', i;
	if(Valor != null)
	{
		//ValorRetorno = Valor.toLocaleString();
		
		if(Valor > 999)
		{
			ValorRetorno = Valor.toLocaleString();
			ValorRetorno = ValorRetorno.toString().replace(/,/g,'#');
			ValorRetorno = ValorRetorno.toString().replace(/\./g,'#');
			var ValorRetornoAux = ValorRetorno.split('#');
			var CadenaFinal = '';
			if(ValorRetornoAux.length > 0)
			{
				CadenaFinal = ValorRetornoAux[0].toString();
				for(i=1;i<ValorRetornoAux.length;i++)
				{
					if(ValorRetornoAux[i].toString().length == 3)
					{
						CadenaFinal = CadenaFinal + ',' + ValorRetornoAux[i];
					}
				}
			}
			ValorRetorno = CadenaFinal;
		}
		else
		{
			ValorRetorno = Valor;
		}
	}
	return ValorRetorno;
}
function CalculaTodoCarrito(codPedidoProducto, AccionEjecutada)
{
    var objCtrlLstProductos = document.getElementById('txtLstProductosCarritoCompras');
    var objCtrlTotal = document.getElementById('divTxtValorTotalProducto');
    var Cantidad = 0;
    var CodProducto = 0;
    if(objCtrlLstProductos != null && objCtrlTotal != null)
    {
        var lstProductos = objCtrlLstProductos.value.split('|');
        var TotalPedido = 0;

        for(var i = lstProductos.length - 1 ; i >= 0; i--)
        {
            if(lstProductos[i] > 0)
            {
                var Respuesta = CalculadorCarrito(lstProductos[i]);
                if(Respuesta.split('|').length >= 3)
                {
                    TotalPedido = TotalPedido + new Number(Respuesta.split('|')[0]);
                    if(codPedidoProducto == lstProductos[i])
                    {
                        Cantidad = Respuesta.split('|')[1];
                        CodProducto = Respuesta.split('|')[2];
                    }
                }
            }
        }
				objCtrlTotal.innerHTML = FormatoPesosCarrito(TotalPedido);
		        
        //REALIZA POSTBACK ASINCRONO PARA ALMACENAR LOS CAMBIOS REALIZADOS
        RealizaPostBackAsincronico(window.location.href, 'POST', 'FinGuardaCambiosCarrito()', 1, 'IsCallBack=1&ActualizaDatos=1&codPedidoProducto=' + codPedidoProducto + '&CodProducto=' + CodProducto + '&AccionEjecutada=' + AccionEjecutada + '&Cantidad=' + Cantidad);
    }
	return false;
}
function CalculadorCarrito(codPedidoProducto)
{
    var ValorNeto = 0;
    var objDdlCambiar = document.getElementById('ddlTipoPresentacion_' + codPedidoProducto);
    var Cantidad = 0;
    var CodProducto = 0;
    if(objDdlCambiar != null)
    {
        //OBTIENE EL VALOR SELECCIONADO
        var ValorSeleccionado = objDdlCambiar.value.split("|");
        if(ValorSeleccionado.length >= 4)
        {
            //0 --> codpedidoproducto
            //1 --> codproducto
            //2 --> valor unidad
            //3 --> porcentaje iva entero
            
            //OBTIENE EL CODIGO DE PRODUCTO
            CodProducto = ValorSeleccionado[1];

            //OBTIENE LOS CONTROLES A MODIFICAR
            var objCantidad = document.getElementById('txtCantidad_' + ValorSeleccionado[0]);
            var objTotalProducto = document.getElementById('tdtxtValorTotalProducto_' + ValorSeleccionado[0]);
            if(objCantidad != null && objTotalProducto != null && !isNaN(objCantidad.value.replace(/ /g,'')))
            {
                //OBTIENE EL VALOR POR UNIDAD Y EL PORCENTAJE DEL IVA Y LA CANTIDAD
                var ValorUnidad = new Number(ValorSeleccionado[2].replace(/\./g,'').replace(/,/g,'').replace(/ /g,''));
                var PorcentajeIVA = new Number(ValorSeleccionado[3].replace(/\./g,'').replace(/,/g,'').replace(/ /g,''));
                Cantidad = new Number(objCantidad.value.replace(/ /g,''));
                
                var ValorButo = ValorUnidad * Cantidad;
                ValorNeto = new Number(ValorButo * (1 + (PorcentajeIVA/100)));
				objTotalProducto.innerHTML = '$' + FormatoPesosCarrito(ValorNeto);
            }
        }
    }

    return ValorNeto + '|' + Cantidad + '|' + CodProducto;
}
function BorrarProductoCarrito(codPedidoProducto)
{
    var objCtrlLstProductos = document.getElementById('txtLstProductosCarritoCompras');
    if(objCtrlLstProductos != null)
    {
        //RETIRA EL PRODUCTO DE LA LISTA DE PRODUCTOS
        var lstProductos = objCtrlLstProductos.value.split('|');
        var NuevaLista = '';
        var ContieneItem = false;

        for(var i = 0; i < lstProductos.length; i++)
        {
            if(lstProductos[i] > 0 && codPedidoProducto == lstProductos[i])
            {
                //ELIMINA EL OBJETO VISUALMENTE
                var objProductoBorrar = document.getElementById('trCtrlTodoProducto_' + codPedidoProducto);
                
                if(objProductoBorrar != null)
                {
                    while (objProductoBorrar.childNodes[0])
                    {
                        objProductoBorrar.removeChild(objProductoBorrar.childNodes[0]);
                    }                
                }
            }
            else
            {
                if(lstProductos[i].length > 0)
                    ContieneItem = true;
                    
                NuevaLista = NuevaLista + lstProductos[i] + '|';
            }
        }
        objCtrlLstProductos.value = NuevaLista;
        //RECALCULA EL VALOR TOTAL DEL CARRITO
        RecalcularSubtotalesCarrito(codPedidoProducto, 0);
        //VERIFICA NUMERO DE ITEMS EXISTENTES PARA NO MOSTRAR EL LINK DE SOLICITAR PEDIDO
		/* 
		  @Modificado: 2010-07-29 Wilson Guasca 
		  El diseño de la pantalla cambió, ahora se ocultará únicamente el botón de procesar el pedido
		*/
        if(ContieneItem == false)
        {
            // if(document.getElementById('divMuestraSolicitarProductoCarrito') != null)
                // document.getElementById('divMuestraSolicitarProductoCarrito').style['display'] = 'none';
			var InputProcesarPedido = document.getElementById('btnProcesarPedido');
            if(InputProcesarPedido != null)
				InputProcesarPedido.style['visibility'] = 'hidden';
        }
    }
}
function txtCantidad_PierdeFoco(codPedidoProducto, NuevaCantidad)
{
    var objCantidad = document.getElementById('txtCantidad_' + codPedidoProducto);
    if(objCantidad != null)
    {    
        if(!isNaN(NuevaCantidad) && NuevaCantidad >= 0)
        {
            objCantidad.value = new Number(NuevaCantidad.replace(/\./g,'').replace(/,/g,'').replace(/ /g,''));
        }
        else
        {
            objCantidad.value = '1';
            alert('Solo se permiten valores numericos enteros.');            
        }
        RecalcularSubtotalesCarrito(codPedidoProducto, 1);            
    }
}

/********************************FIN CALCULOS CARRITO******************************************/

/********************************ENVIO DE FORM******************************************/
function ValidaEnviaForm(idform,FuncionEvaluacion)
{
    var objForma = document.getElementById(idform);
    if(objForma != null)
    {
        //EJECUTA LA FUNCION DE VALIDACION DE POSTBACK
        if(FuncionEvaluacion.replace(/ /g,'').length > 0)
        {
            if(eval(FuncionEvaluacion) == true)
            {
                objForma.submit();
            }
        }
        else
        {
            objForma.submit();
        }
    }
    else
    {
        alert('obj forma no encontrado');
    }
}
/********************************FIN ENVIO DE FORM******************************************/
/******************************METODOS DE CONTACTENOS DEL CARRITO***************************/
function ValidaFormaContactenosCarrito()
{
    var Retorno = true;
    //VALIDA LOS CAMPOS DEL FORMULARIO
    
    //VALIDACION DE CAMPOS SIMPLES DE TEXTO
    if(document.getElementById('txtNombre').value.replace(/ /g,'').length == 0)
    {
        alert('El nombre Campo Nombre es obligarotio');
        Retorno = false;
    }
    else if(document.getElementById('txtApellido').value.replace(/ /g,'').length == 0)
    {
        alert('El nombre Campo Apellido es obligarotio');
        Retorno = false;
    }
    else if(document.getElementById('txtProfesion').value.replace(/ /g,'').length == 0)
    {
        alert('El nombre Campo Profesión es obligarotio');
        Retorno = false;
    }
    else if(document.getElementById('txtTelefono').value.replace(/ /g,'').length == 0)
    {
        alert('El nombre Campo Teléfono es obligarotio');
        Retorno = false;
    }
    else if(document.getElementById('txtTelefonoOficina').value.replace(/ /g,'').length == 0)
    {
        alert('El nombre Campo Teléfono Oficina  es obligarotio');
        Retorno = false;
    }
    else if(document.getElementById('txtDireccion').value.replace(/ /g,'').length == 0)
    {
        alert('El nombre Campo Dirección es obligarotio');
        Retorno = false;
    }
    else if(document.getElementById('txtDireccionOficina').value.replace(/ /g,'').length == 0)
    {
        alert('El nombre Campo Dirección Oficina es obligarotio');
        Retorno = false;
    }
    
    //VALIDACION DE CAMPOS NUMERICOS
    if(document.getElementById('txtCelular').value.replace(/ /g,'').length == 0 || isNaN(document.getElementById('txtCelular').value.replace(/ /g,'')))
    {
        alert('El nombre Campo Teléfono Movil es obligarotio y solo permite valores numéricos.');
        Retorno = false;
    }
    else
        document.getElementById('txtCelular').value = document.getElementById('txtCelular').value.replace(/\./g,'').replace(/,/g,'').replace(/ /g,'');
    //VALIDACION DE EMAIL
    Retorno = ValidaEstructuraEmail(document.getElementById('txtEmail').value.replace(/ /g,''), true, true);
    return Retorno;
}
function ValidaFormaContactenosCarrito2()
{
    var Retorno = true;
    //VALIDA LOS CAMPOS DEL FORMULARIO
    
    //VALIDACION DE CAMPOS SIMPLES DE TEXTO
    if(document.getElementById('txtNumId').value.replace(/ /g,'').length == 0)
    {
        alert('El número de identificación es obligatorio');
        Retorno = false;
    }
    else if(document.getElementById('txtDepartamento').value.replace(/ /g,'').length == 0)
    {
        alert('El departamento es obligatorio');
        Retorno = false;
    }
    else if(document.getElementById('txtCiudad').value.replace(/ /g,'').length == 0)
    {
        alert('La ciudad es obligatoria');
        Retorno = false;
    }
    else if(document.getElementById('txtNombres').value.replace(/ /g,'').length == 0)
    {
        alert('Los nombres son obligatorios');
        Retorno = false;
    }
    else if(document.getElementById('txtApellido1').value.replace(/ /g,'').length == 0)
    {
        alert('El primer apellido es obligatorio');
        Retorno = false;
    }
    else if(document.getElementById('txtApellido2').value.replace(/ /g,'').length == 0)
    {
        alert('El segundo apellido es obligatorio');
        Retorno = false;
    }
    else if (!ValidaEstructuraEmail(document.getElementById('txtEmail').value.replace(/ /g,''), true, true))
    {
		Retorno = false;
    }
     else if(document.getElementById('txtDireccion').value.replace(/ /g,'').length == 0)
    {
        alert('La dirección es obligatoria');
        Retorno = false;
    }
     else if(document.getElementById('txtTelefonoFijo').value.replace(/ /g,'').length == 0)
    {
        alert('El teléfono fijo es obligatorio');
        Retorno = false;
    }
    
        
    //VALIDACION DE EMAIL
	//if (Retorno)
	//{
	//Retorno = ValidaEstructuraEmail(document.getElementById('txtEmail').value.replace(/ /g,''), true, true);
	//}
	   
    return Retorno;
}
//FUNCION DE VALIDACION DE EMAIL
function ValidaEstructuraEmail(addr,man,db) 
{
    if (addr == '' && man) {if (db) alert('El email es obligatorio.');return false;}
    if (addr == '') return true;
    var invalidChars = '\/\'\\ ";:?!()[]\{\}^|';
    for (i=0; i<invalidChars.length; i++) {
        if (addr.indexOf(invalidChars.charAt(i),0) > -1) {if (db) alert('El email contiene caracteres invalidos.');return false;}
    }
    for (i=0; i<addr.length; i++) {
        if (addr.charCodeAt(i)>127){if (db) alert("El email contiene caracteres no ascii.");return false;}
    }
    var atPos = addr.indexOf('@',0);
    if (atPos == -1){if (db) alert('El email debe contener el simbolo @');return false;}
    if (atPos == 0){if (db) alert('El email no debe iniciar con @');return false;}
    if (addr.indexOf('@', atPos + 1) > - 1) {if (db) alert('El email solo debe contener un simbolo @');return false;}
    if (addr.indexOf('.', atPos) == -1) {if (db) alert('El dominio del email es invalido.');return false;}
    if (addr.indexOf('@.',0) != -1) {if (db) alert('El simbolo \'@.\' no es valido.');return false;}
    if (addr.indexOf('.@',0) != -1){if (db) alert('El simbolo \'.@\' no es valido.');return false;}
    if (addr.indexOf('..',0) != -1) {if (db) alert('El simbolo \'..\' no es valido.');return false;}
    var suffix = addr.substring(addr.lastIndexOf('.')+1);
    if (suffix.length != 2 && suffix != 'com' && suffix != 'net' && suffix != 'org' && suffix != 'edu' && suffix != 'int' && suffix != 'mil' && suffix != 'gov' & suffix != 'arpa' && suffix != 'biz' && suffix != 'aero' && suffix != 'name' && suffix != 'coop' && suffix != 'info' && suffix != 'pro' && suffix != 'museum') {
        if (db) alert('El dominio del email es invalido.');return false;}
    return true;
}

/******************************FIN METODOS DE CONTACTENOS DEL CARRITO***************************/

/******************************METODOS DE ACORDEON**********************************************/

var AcordeonModificado=function()
{
	var tm=sp=3;
	
	function slider(n)
	{
	    this.nm=n; 
	    this.arr=[]; 
	    this.classdespliega=[]; 
	    this.classoculta=[];
	}
	
	slider.prototype.init=function(t, c)
	{
		var a,h,s,l,i; 
		a=document.getElementById(t); 
		h = a.getElementsByTagName('dt'); 
		s = a.getElementsByTagName('dd'); 
		
		this.l=h.length;
		
		for(i=0; i<this.l; i++)
		{
		    var d = h[i]; 
		    this.arr[i] = d; 
		    
		    var valdespliega = d.getAttribute("classdespliega");
		    var valoculta = d.getAttribute("classoculta");

		    this.classdespliega[i] = valdespliega?valdespliega:'';
		    this.classoculta[i] = valoculta?valoculta:'';
		    
		    d.onclick = new Function(this.nm+'.pro(this)'); 
		    if(c == i)
		    {
		        d.className = this.classdespliega[i];
		    }
		    else
		    {
		        d.className = this.classoculta[i];
		    }
		}
		l=s.length;
		for(i=0;i<l;i++)
		{
		    var d = s[i]; 
		    d.mh = d.offsetHeight; 
		    if(c!=i)
		    {
		        d.style.height=0; 
		        d.style.display='none'
		    }
		}
	}
	
	slider.prototype.pro=function(d)
	{
		for(var i=0;i<this.l;i++)
		{
			var h=this.arr[i], s=h.nextSibling; 
			s=s.nodeType!=1?s.nextSibling:s; 
			clearInterval(s.tm);
			if(h==d && s.style.display == 'none')
			{
			    s.style.display=''; 
			    su(s,1); 
			    h.className = this.classdespliega[i];
			}
			else if(s.style.display == '')
			{
			    su(s,-1); 
			    h.className = this.classoculta[i];
			}
		}
	}
	
	function su(c,f){c.tm=setInterval(function(){sl(c,f)},tm)}
	
	function sl(c,f)
	{
		var h=c.offsetHeight, m=c.mh, d=f==1?m-h:h; 
		c.style.height=h+(Math.ceil(d/sp)*f)+'px';
		c.style.opacity=h/m; 
		c.style.filter='alpha(opacity='+h*100/m+')';
		if(f==1&&h>=m)
		{
		    clearInterval(c.tm)
		}
		else if(f!=1&&h==1)
		{
		    c.style.display='none'; 
		    clearInterval(c.tm)
		}
	}
	return{slider:slider}
}();

/******************************FIN METODOS DE ACORDEON**********************************************/

/*******************************FUNCIONES DE REPRODUCCION DE VIDEO*********************************/
function VerificarIntroduccionVideo(idDivReproductor, UrlVideo, extencionVideo, ancho, alto,Estado)
{
    if(Estado == 1)
    {
        IntroducirReproductorVideo(idDivReproductor, UrlVideo, extencionVideo, ancho, alto);
    }
	else
		//if(Estado == 2 && objLightBox != null && strMensajeRegistreseVideos != null)
   {
		Mostrar('RegistroVideos.asp','800','443');
      //  objLightBox.MostrarTotalMensaje(strMensajeRegistreseVideos);
    //}
   //else if(Estado == 3 && objLightBox != null && strMensajeActivarModuloVideos != null)
   // {
    //    objLightBox.MostrarTotalMensaje(strMensajeActivarModuloVideos);
    }
}
function IntroducirReproductorVideo(idDivReproductor, UrlVideo, extencionVideo, ancho, alto)
{
    var objDivContenedor = document.getElementById(idDivReproductor);
    var ContenidoDiv = "";
    
    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.addParam("wmode","transparent");
								s1.addVariable("width",ancho);
                s1.addVariable("height",alto);
                s1.addVariable("file",UrlVideo);
								s1.addVariable("autostart","true");
				
                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="wmode" value="transparent"> ' +
                               '    <param name="width" value="' + ancho + '"> ' +
                               '    <param name="height" value="' + alto + '"> ' +
                               '    <embed src="' + UrlVideo + '" type="' + TipoObjeto + '" autostart="1" enabled="1" showstatusbar="0" showdisplay="0" showcontrols="1" pluginspage="' + CodeBase + '" CODEBASE="' + Plugin + '" width="' + ancho + 'px" height="' + alto + 'px"></embed> ' +
                               '</object> ' 
            }
            else
            {
                ContenidoDiv = '<img alt="" src="g/img_videos_default.gif" style="height: 269; width: 326" />';
            }
        }
        else
        {
            ContenidoDiv = '<img alt="" src="g/img_videos_default.gif" style="height: 269px; width: 326px;" />';
        }
        //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');
    }
}
/*******************************FIN FUNCIONES DE REPRODUCCION DE VIDEO****************************/

/*****************************OBJETO DE EFECTO DE DESPLAZAMIENTO DE IMAGEN************************/
var ClaseEfectoBeta = function()
{
    function EfectoBeta(oNomObeto, idObjContenedor, ointFrecuenciaCambio, ointVelocidadCambio, oblnDireccion)
    {
        this.nombreObjeto = oNomObeto; 
        this.ObjContenedor = document.getElementById(idObjContenedor);
        this.intFrecuenciaCambio = ointFrecuenciaCambio;
        this.intVelocidadCambio = ointVelocidadCambio;
        this.blnDireccion = oblnDireccion;
        
        this.AnchoObjetoContenedor = 0;
        this.lstObjetos = [];
        this.objActual = null;
        this.objSiguiente = null;
        this.TemporizadorVel = 0;
        this.TemporizadorFre = 0;
        this.NumeroCuadrosEfecto = 190;
        this.CantidadCambioEfecto = 10 / this.NumeroCuadrosEfecto;
	}
    EfectoBeta.prototype.inicia = function()
    {
        var i, arregloAux, AnchoAux, AltoAux;
        if(this.ObjContenedor != null && this.ObjContenedor.getElementsByTagName('dl').length > 0)
        {   
            //ASEGURA ALTO DEL OBJETO CONTENEDOR
            if(this.ObjContenedor.style['height'] == '')
            {
                this.ObjContenedor.style['height'] = '0px';
            }
            //OBTIENE ANCHO FINAL DEL OBJETO
            this.AnchoObjetoContenedor = this.ObjContenedor.clientWidth;
            
            this.ObjContenedor.style['position'] = 'absolute';
            this.ObjContenedor.style['width'] = this.AnchoObjetoContenedor + 'px';
            this.ObjContenedor.style['top'] = '1px';
            this.ObjContenedor.style['left'] = '1px';
            
            
            //RECORRE LISTA DE LOS OBJETOS E INICIA PROPIEDADES
            arregloAux = this.ObjContenedor.getElementsByTagName('dl');
            for(i = 0; i < arregloAux.length; i++)
            {
                if(arregloAux[i].getElementsByTagName('dt').length > 0 && arregloAux[i].getElementsByTagName('dd').length > 0)
                {
                    //ARREGLA EL HTML GENERADO POR LA SALAEDICION
					var HtmlProp = 'innerHTML';
                    if(BrowserDetect.browser == 'Explorer')
                    {
						HtmlProp = 'outerHTML';					
                    }
				    arregloAux[i].getElementsByTagName('dd')[0][HtmlProp] = unescape(arregloAux[i].getElementsByTagName('dd')[0][HtmlProp]).replace(/["']+/g,'');
                    
                    //OBTIENE LISTA DE OBJETOS A TRABAJAR
                    this.lstObjetos[i] = [arregloAux[i],arregloAux[i].getElementsByTagName('dt')[0],arregloAux[i].getElementsByTagName('dd')[0]];
                    
                    //AJUSTA PROPIEDADES GENERALES DE CADA OBJETO
                    
                    AnchoAux = 0;
                    AltoAux = 0;
                    if(this.lstObjetos[i][1].getElementsByTagName('img').length > 0)
                    {
                        AnchoAux = this.lstObjetos[i][1].getElementsByTagName('img')[0].width;
                        
                        //se quito el alto porque el posisionamiento absoluto no permite el buen funcionamiento de opacity en ie8
                        //AltoAux = (this.ObjContenedor.style['height'].replace('px','')/2) - (this.lstObjetos[i][1].getElementsByTagName('img')[0].height/2);
                        //this.lstObjetos[i][1].getElementsByTagName('img')[0].style['position'] = 'absolute';
                        //this.lstObjetos[i][1].getElementsByTagName('img')[0].style['top'] = AltoAux + 'px';
                    }
                    if(AnchoAux > this.AnchoObjetoContenedor)
                    {
                        AnchoAux = this.AnchoObjetoContenedor;
                    }
                        
                    this.lstObjetos[i][1].style['position'] = 'absolute';
                    this.lstObjetos[i][2].style['position'] = 'absolute';

                    this.lstObjetos[i][1].style['width'] = AnchoAux + 'px';
                    if(this.AnchoObjetoContenedor > AnchoAux)
                    {
                        this.lstObjetos[i][2].style['width'] = this.AnchoObjetoContenedor - AnchoAux - 1 + 'px';
                    }
                    else
                    {
                        this.lstObjetos[i][2].style['width'] = '0px';
                    }
                    
                    
                    this.lstObjetos[i][1].style['top'] = '0px';
                    this.lstObjetos[i][2].style['top'] = '0px';
                    
                    this.lstObjetos[i][1].style['height'] = this.ObjContenedor.style['height'];
                    this.lstObjetos[i][2].style['height'] = this.ObjContenedor.style['height'];

                    if(this.blnDireccion)
                    {
                        this.lstObjetos[i][1].style['left'] = '1px';
                        this.lstObjetos[i][2].style['right'] = '-1px';
                    }
                    else
                    {
                        this.lstObjetos[i][2].style['left'] = '1px';
                        this.lstObjetos[i][1].style['right'] = '1px';
                    }

                    if(i == 0)
                    {
                        //MUESTRA PRIMER OBJETO
                        CambiarBeta(this.lstObjetos[i][1],10);
                        CambiarBeta(this.lstObjetos[i][2],10);
                    }
                    else
                    {
                        //OCULTA OBJETO
                        CambiarBeta(this.lstObjetos[i][1],0);
                        CambiarBeta(this.lstObjetos[i][2],0);
                    }
                }
            }
            //INICIA TEMPORIZADOR DE FRECUENCIA
            this.TemporizadorFre =  setTimeout(this.nombreObjeto + '.iniciaEfecto()' ,this.intFrecuenciaCambio);
        }
    }
    EfectoBeta.prototype.iniciaEfecto = function()
    {
        var i;
        clearTimeout(this.TemporizadorFre);
        if(this.lstObjetos.length > 1)
        {
            //OBTIENE OBJETOS A MODIFICAR
            for(i = 0; i < this.lstObjetos.length; i++)
            {
                if(this.lstObjetos[i][1].style['opacity'] > 0)
                {
                    //OBTIENE OBJETO QUE SE MUESTRA ACTUALMENTE
                    this.objActual = this.lstObjetos[i];
                    //OBTIENE OBJETO A MOSTRAR A CONTINUACION
                    if(i < (this.lstObjetos.length - 1))
                    {
                        this.objSiguiente = this.lstObjetos[i + 1];
                    }
                    else
                    {
                        this.objSiguiente = this.lstObjetos[0];
                    }
                    break;
                }
            }
            //INICIA PROCESO DE CAMBIO DE VISUALIZACION
            if(this.objActual != null && this.objSiguiente != null && this.intVelocidadCambio > 0)
            {
                //OCULTA HTML
                this.TemporizadorVel = setTimeout(this.nombreObjeto + '.FinVelocidadCambio(1)' ,this.intVelocidadCambio);
            }
        }
    }
    EfectoBeta.prototype.FinVelocidadCambio = function(intPasoEfecto)
    {
        var betaObjetoAux, DistanciaAvance, blnbloqueo =  true;
        clearTimeout(this.TemporizadorVel);
        if(this.objActual != null && this.objSiguiente != null)
        {
            if(intPasoEfecto == 1)
            {
                //PASO OCULTA EL HTML ACTUAL
                betaObjetoAux = (this.objActual[2].style['opacity'] * 10) - this.CantidadCambioEfecto;
                CambiarBeta(this.objActual[2], betaObjetoAux);
            }
            else if(intPasoEfecto == 2)
            {
                //DESPLAZA LA IMAGEN MIENTRAS APARECE Y SE OCULTA LA IMAGEN ACTUAL
                if(this.objActual[1].style['opacity'] >= 1)
                {
                    betaObjetoAux = 9.99;
                    DistanciaAvance = this.AnchoObjetoContenedor;
                }
                else
                {
                    betaObjetoAux = (this.objActual[1].style['opacity'] * 10) - this.CantidadCambioEfecto;	                
                    if(this.blnDireccion)
                    {
                        DistanciaAvance = this.objSiguiente[1].style['left'].replace('px','') - (this.AnchoObjetoContenedor * (this.CantidadCambioEfecto/10));
                    }
                    else
                    {
                        DistanciaAvance = this.objSiguiente[1].style['right'].replace('px','') - (this.AnchoObjetoContenedor * (this.CantidadCambioEfecto/10));
                    }
                }
                
                if(DistanciaAvance < 1)
                    DistanciaAvance = 1;
                    
                if(this.blnDireccion)
                {
                    this.objSiguiente[1].style['left'] = DistanciaAvance + 'px';
                }
                else
                {
                    this.objSiguiente[1].style['right'] = DistanciaAvance + 'px';
                }
                CambiarBeta(this.objActual[1], betaObjetoAux);
                CambiarBeta(this.objSiguiente[1], 10 - betaObjetoAux);
            }
            else if(intPasoEfecto == 3)
            {
                //MUESTRA NUEVO HTML
                betaObjetoAux = (this.objSiguiente[2].style['opacity'] * 10) + this.CantidadCambioEfecto;
                CambiarBeta(this.objSiguiente[2], betaObjetoAux);
                betaObjetoAux = 10 - betaObjetoAux;
            }
            else
            {
                //FINALIZA EFECTO E INICIA ESPERA DEL SIGUIENTE CICLO
                blnbloqueo =  false;
                this.TemporizadorFre =  setTimeout(this.nombreObjeto + '.iniciaEfecto()' ,this.intFrecuenciaCambio);
            }
            
            //EVALUA CAMBIO DE PASO
            if(betaObjetoAux <= 0 && blnbloqueo)
            {
                //SE DIRIJE AL SIGUIENTE PASO
                this.TemporizadorVel = setTimeout(this.nombreObjeto + '.FinVelocidadCambio(' + (intPasoEfecto + 1) + ')' ,this.intVelocidadCambio);
            }
            else if(blnbloqueo)
            {
                //CONTINUA CON EL CICLO
                this.TemporizadorVel = setTimeout(this.nombreObjeto + '.FinVelocidadCambio(' + intPasoEfecto + ')' ,(this.intVelocidadCambio * (10 - betaObjetoAux)));
            }
        }            
    }
    //*****FUNCIONES DE USO GENERAL***********
    function CambiarBeta(objCambio,ValorCambio)
    {
        if(objCambio != null)
        {
            //value puede variar de 0-10
            if(ValorCambio > 10)
                ValorCambio = 10;
            else if(ValorCambio < 0)
                ValorCambio = 0;

            if(BrowserDetect.browser == 'Explorer' && BrowserDetect.version == '8')
            {
                objCambio.style['filter'] = 'progid:DXImageTransform.Microsoft.Alpha(Opacity=' + ValorCambio*10 + ')';
                objCambio.style['opacity'] = ValorCambio/10;
            }
            else
            {
                objCambio.style['opacity'] = ValorCambio/10;
                objCambio.style['filter'] = 'alpha(opacity=' + ValorCambio*10 + ')';
            }
            
        } 	    
    }
    return{EfectoBeta:EfectoBeta}
}();
/**********************FIN OBJETO DE EFECTO DE DESPLAZAMIENTO DE IMAGEN************************/

/***************************Funciones de deteccion de browser*********************************/
var BrowserDetect = {
    init: function () {
        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";
    },
    searchString: function (data) {
        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;
        }
    },
    searchVersion: function (dataString) {
        var index = dataString.indexOf(this.versionSearchString);
        if (index == -1) return;
        return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
    },
    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 DE MUESTRA DE MENSAJES INFORMATIVOS***************************/
var ClaseLightBox = function()
{
    function LightBox(onombreObjeto,iddivSobrepuesto, iddivpostBack)
    {
        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;
    }
    LightBox.prototype.inicia = function()
    {   
        //INICIA ELEMENTOS DE LIGHTBOX GRANDE
        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');
    }
    //MUESTRA MENSAJE SOBRE LA VENTANA TOTAL
    LightBox.prototype.MostrarTotalMensaje = function(strMensaje)
    {
        var i;
		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';
                    }
                }
            }
        }        
    } 
    //MUESTRA PETICION URL SOBRE LA VENTANA TOTAL
    LightBox.prototype.MostrarTotalURL = function(strURL, Parametros)
    {
        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';
        }        
    }  
    //OCULTA LIGHTBOX TOTAL  
    LightBox.prototype.OcultarTotal = function()
    {
        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'] = '';
                    }
                }
            }
        }        
    } 
    //FUNCION QUE MUESTRA NUBE INFORMATIVA AL COSTADO DEL CONTROL
    LightBox.prototype.MuestraNubeLadoControl = function(idDivMostrar,strMensaje,strPlantilla)
    {
        var objDivMostrar = document.getElementById(idDivMostrar);
        if(objDivMostrar != null)
        {
            objDivMostrar = CambiaContenidoDiv(idDivMostrar,strPlantilla.replace('##mensaje##',strMensaje));
            objDivMostrar.style['display'] = 'block';
        }
    }
    //FUNCION QUE OCULTA NUBE INFORMATIVA AL COSTADO DEL CONTROL
    LightBox.prototype.OcultaNubeLadoControl = function(idDivMostrar)
    {
        var objDivMostrar = document.getElementById(idDivMostrar);
        if(objDivMostrar != null)
            objDivMostrar.style['display'] = 'none';
    }
    //FUNCIONES DE USO GENERAL   
    function CambiaContenidoDiv(idDiv ,strNuevoContenido)
    {
        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;
    }
    function iecompattest(){return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body}

    return{LightBox:LightBox}
}();
/**************************FIN FUNCION DE MUESTRA DE MENSAJES INFORMATIVOS***************************/
/**************************FUNCION DE MUESTRA DE MENSAJES INFORMATIVOS***************************/
var ClaseLightBoxUnificacion = function()
{
    function LightBoxUnificacion(onombreObjeto,iddivSobrepuesto, iddivpostBack,idframeContenido,onomMetodoFinalizacion)
    {
        this.nombreObjeto = onombreObjeto;
        this.objDivSobrepuesto = document.getElementById(iddivSobrepuesto);
        this.objDivPostBack = document.getElementById(iddivpostBack);
        this.objFrameContenido = document.getElementById(idframeContenido);
        this.AltoPagina = 0;
        this.AnchoPagina = 0;
        this.nomMetodoFinalizacion = onomMetodoFinalizacion;
        //OBTIENE EL BODY STANDAR DE LA PAGINA
        this.standardbody=(document.compatMode=="CSS1Compat")? document.documentElement : document.body ;
        //CAPTURA TODOS LOS SELECT QUE EXISTEN EN EL FORMULARIO
        this.lstObjSelect = document.getElementsByTagName('select');
       
        //INICIA ELEMENTOS DE LIGHTBOX
        if(this.objDivSobrepuesto != null && this.objDivPostBack != null && this.objFrameContenido != 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';
            this.objDivPostBack.style['display'] = 'none';
            this.objFrameContenido.src = '';
        }            
    }
    //MUESTRA MENSAJE SOBRE LA VENTANA TOTAL
    LightBoxUnificacion.prototype.MostrarTotalMensaje = function(strURL)
    {
        if(this.objDivSobrepuesto != null && this.objDivPostBack != null)
        {
            //MAXIMIZA LA PAGINA
            MaximizarVentana();
        
            var i;  
            //RECALCULA TAMANO DE LA PAGINA
            this.CalculaTamanoPagina();
                  
            //CAPTURA POSICION ACTUAL DE LA VENTANA
            var topActual = document.all? iecompattest().scrollTop : pageYOffset;
            topActual = topActual + 20;
        
            //MUESTRA MENSAJE
            this.objDivSobrepuesto.style['display'] = 'block';
            this.objDivSobrepuesto.zIndex = '500';
            this.objDivSobrepuesto.style['width'] = this.AnchoPagina + 'px';
            this.objDivSobrepuesto.style['height'] = this.AltoPagina + 'px';

            this.objDivPostBack.style['position'] = 'absolute';
            this.objDivPostBack.style['display'] = 'block';
            this.objDivPostBack.zIndex = '600';
            this.objDivPostBack.style['width'] = this.AnchoPagina + 'px';
            this.objDivPostBack.style['top'] = topActual + 'px';
            
            //ASIGNA LA URL DE PETICION
            this.objFrameContenido.src = strURL;
            
            //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';
                    }
                }
            }
        }        
    } 
    //OCULTA LIGHTBOX TOTAL  
    LightBoxUnificacion.prototype.OcultarTotal = function()
    {
        if(this.objDivSobrepuesto != null && this.objDivPostBack != null && this.objFrameContenido != null)
        {
            //MUESTRA MENSAJE
            this.objFrameContenido.src = '';
            
            this.objDivSobrepuesto.style['display'] = 'none';
            this.objDivSobrepuesto.style['width'] = '0px';
            this.objDivSobrepuesto.style['height'] = '0px';
            this.objDivSobrepuesto.zIndex = '0';
            
            this.objDivPostBack.style['display'] = 'none';
            this.objDivPostBack.zIndex = '0';
            this.objDivPostBack.style['top'] = '0px';
            this.objDivPostBack.style['width'] = '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'] = '';
                    }
                }
            }            
        }        
    } 
    LightBoxUnificacion.prototype.OcultarTotalUnificacion = function(intAccionCierre,Usuario,Clave)
    {
        //EJECUTA CIERRE DE LA PAGINA
        eval(this.nombreObjeto + '.OcultarTotal()');
        //INVOCA METODO DE FINALIZACION
        eval(this.nomMetodoFinalizacion + '(' + intAccionCierre + ',"' + Usuario + '","' + Clave + '");');
    } 
    //FUNCION DE CALCULO DE TAMAÑO DE LA PAGINA
    LightBoxUnificacion.prototype.CalculaTamanoPagina = function()
    {
        if(this.AnchoPagina == null || this.AnchoPagina == 0 || this.AltoPagina == null || this.AltoPagina == 0)
        {
            //OBTIENE EL BODY STANDAR PARA TODOS LOS NAVEGADORES
            var ie=document.all && !window.opera;
            //Preliminary doc width in non IE browsers                
            var domclientWidth=document.documentElement && parseInt(document.documentElement.clientWidth) || 100000;
            this.AnchoPagina=(ie)? this.standardbody.clientWidth : (/Safari/i.test(navigator.userAgent))? window.innerWidth : Math.min(domclientWidth, window.innerWidth-16);
            this.AltoPagina=(ie)? (this.standardbody.clientHeight + this.standardbody.scrollHeight): window.innerHeight;
            
            if(BrowserDetect.browser == "Firefox")
            {
                this.AnchoPagina = this.AnchoPagina + window.scrollMaxX;
                this.AltoPagina = this.AltoPagina + window.scrollMaxY;
            }
        }
    }
    function MaximizarVentana()
    {
        top.window.moveTo(0,0);
        if (document.all) 
        {
            top.window.resizeTo(screen.availWidth,screen.availHeight);
        }
        else if (document.layers||document.getElementById) 
        {
            if (top.window.outerHeight<screen.availHeight||top.window.outerWidth<screen.availWidth)
            {
                top.window.outerHeight = screen.availHeight;
                top.window.outerWidth = screen.availWidth;
            }
        }
    }            
    function iecompattest(){return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body}
    return{LightBoxUnificacion:LightBoxUnificacion}
}();
/**************************FIN FUNCION DE MUESTRA DE MENSAJES INFORMATIVOS***************************/

		/************************FUNCIONES DE MANIPULACION DE IFRAME CONTENEDOR************************/
var ClaseIframeContenedor = function()
{
    //CONSTRUCTOR
    function IframeContenedor(onombreObjeto, onomObjetoControlSuperior)
    {
        this.nombreObjeto = onombreObjeto;
        this.nomObjetoControlSuperior = onomObjetoControlSuperior;
        this.objIframeContenedor = null;
    }
    //INICIALIZACION
    IframeContenedor.prototype.inicia = function(objBodyPagina)
    {
        if(objBodyPagina.frameElement != null)
        {
            this.objIframeContenedor = objBodyPagina.frameElement;
            //CAPTURA ALTO Y ANCHO DE LA PAGINA DE CONTENIDO
            if(BrowserDetect.browser == "Firefox")
            {
                ymax = this.objIframeContenedor.contentWindow.scrollMaxY + this.objIframeContenedor.contentWindow.innerHeight;
            }
            else
            {
                ymax = this.objIframeContenedor.contentWindow.document.body.scrollHeight;
            }
            this.objIframeContenedor.style['height'] = ymax + 'px';
        }
    }
    //CIERRA VENTANA
    IframeContenedor.prototype.CierraVentana = function(intAccionCierre,Usuario,Clave)
    {
        //CIERRA LA VENTANA TOTAL
        if(eval('window.parent.' + this.nomObjetoControlSuperior) != null)
        {
            eval('window.parent.' + this.nomObjetoControlSuperior + '.OcultarTotalUnificacion(' + intAccionCierre + ',"' + Usuario + '","' + Clave + '");');
        }
    }    
    return{IframeContenedor:IframeContenedor}
}();
/************************FIN FUNCIONES DE MANIPULACION DE IFRAME CONTENEDOR************************/



/**************************FUNCION DE VALIDACION DE PARAMETROS DE ENTRADA***************************/
var ClaseValidaEntrada = function()
{
    function ValidaEntrada(onombreObjeto,onomObjMensaje, oplantillaMensaje, ostrMensajeTotalRegistrese)
    {
        this.nombreObjeto = onombreObjeto;
        this.nomObjMensaje = onomObjMensaje;
        this.plantillaMensaje = oplantillaMensaje;
        this.strMensajeTotalRegistrese = ostrMensajeTotalRegistrese;
        
        this.UltimoResultadoEvaluacion;
        this.lstObjSelect = null;
    }
    ValidaEntrada.prototype.inicia = function(){}
    ValidaEntrada.prototype.ValidaFormulario = function(idForm)
    {
        var objForm = document.getElementById(idForm);
        if(objForm != null)
        {
            //VALIDA TODOS LOS CAMPOS DEL DOCUMENTO
            var lstInput = jQuery( ':input[onblur]', objForm).get();
            var i, RealizaPostBack = true, ResultadoAux, oFunc, oParams;
            
            for(i = 0; i < lstInput.length; i++)
            {
                if(lstInput[i].onblur != null)
                {
                    ResultadoAux = lstInput[i].onblur.toString().substring(lstInput[i].onblur.toString().indexOf('{') + 1).split('(');
                    oFunc = eval( ResultadoAux[0]);
                    oParams = ResultadoAux[1].substring(0, ResultadoAux[1].indexOf(')')).split(',');
					for (var p in oParams)
					{
						oParams[p] = eval(oParams[p]);
						if (oParams[p] === this) oParams[p] = lstInput[i];
					}
					RealizaPostBack &= oFunc.apply( this, oParams)
                }
            }

            if(RealizaPostBack)
			{
                jQuery(objForm).submit();
			}
            else
                eval(this.nomObjMensaje).MostrarTotalMensaje(this.strMensajeTotalRegistrese);
                
        }
    }
	
    ValidaEntrada.prototype.ValidaCampo = function(objEvaluar, idDivMensaje, TipoCampo, blObligatorio, nombreCampo)
    {
        if(objEvaluar != null)
        {
            var ValorEvaluar = objEvaluar.value;
            var ResultadoVerificacion = '';

            if((objEvaluar.tagName.toLowerCase() == 'input' && objEvaluar.type.toLowerCase() == 'text') || (objEvaluar.tagName.toLowerCase() == 'textarea' ))
            {
                if(blObligatorio == true)
                {
                    if(ValorEvaluar.length > 0)
                    {
                        switch(TipoCampo.toLowerCase())
                        {
                            case "mail":
                                ResultadoVerificacion = ValidaMail(objEvaluar.value,false);
                                break;
                            case "numero":
                                if(isNaN(ValorEvaluar))
                                    ResultadoVerificacion = 'El campo ' + nombreCampo + ' solo admite valores numericos.';
                                break;
                            default:
                            		break;
                        }
                    }
                    else
                    {
                        ResultadoVerificacion = 'El campo ' + nombreCampo + ' es obligatorio en el formulario.';
                    }           
                }
            }
            else if(objEvaluar.tagName.toLowerCase() == 'select')
            {
                 if((objEvaluar.disabled != true) && (blObligatorio == true))
                {
					if ((objEvaluar.selectedIndex == -1) || (ValorEvaluar.toLowerCase() == 0))
                    {
                        ResultadoVerificacion = 'Por favor escoja un valor de la lista para el campo ' + nombreCampo + '.';
                    }
                }
            }
            if(ResultadoVerificacion.length > 0)
            {
                //MUESTRA MENSAJE DE ERROR PARA EL CONTROL
                if(this.nomObjMensaje != null)
                {
                    //eval(this.nomObjMensaje + '.MuestraNubeLadoControl(\'' + idDivMensaje + '\',\'' + ResultadoVerificacion + '\',\'' + this.plantillaMensaje + '\');');
                    eval(this.nomObjMensaje).MuestraNubeLadoControl(idDivMensaje , ResultadoVerificacion , this.plantillaMensaje);
                }
                else
                {
                    alert(ResultadoVerificacion);
                }
                return false;
            }
            else
            {
                //OCULTA MENSAJE DE ERROR PARA EL CONTROL
                eval(this.nomObjMensaje).OcultaNubeLadoControl(idDivMensaje);
                return true;
            }
        }
    }
    function ValidaMail(strmail, blnTipoRespuesta)
    {
        var strError = '',blValido = true;
        var invalidChars = '\/\'\\ ";:?!()[]\{\}^|'; 
        var atPos = strmail.indexOf('@',0); 
        var suffix = strmail.substring(strmail.lastIndexOf('.')+1);      
        
        if (strmail == '')
        {
            strError = 'El email es obligatorio.'; 
            blValido = false;
        }
        if(blValido)
        {
            for (i=0; i<invalidChars.length; i++) 
            {
                if (strmail.indexOf(invalidChars.charAt(i),0) > -1) 
                {
                    strError = 'El email contiene caracteres invalidos.';
                    blValido = false;
                    break;
                }
            }
        }
        if(blValido)
        {
            for (i=0; i<strmail.length; i++) 
            {
                if (strmail.charCodeAt(i)>127)
                {
                    strError = "El email contiene caracteres no ascii.";
                    blValido = false;
                    break;
                }
            }
        }
        if(blValido)
        {
            if (atPos == -1)
            {
                strError = 'El email debe contener el simbolo @';
                blValido = false;
            }
            else if (atPos == 0)
            {
                strError = 'El email no debe iniciar con @';
                blValido = false;
            }
            else if (strmail.indexOf('@', atPos + 1) > - 1) 
            {
                strError = 'El email solo debe contener un simbolo @';
                blValido = false;
            }
            else if (strmail.indexOf('.', atPos) == -1) 
            {
                strError = 'El dominio del email es invalido.';
                blValido = false;
            }
            else if (strmail.indexOf('@.',0) != -1) 
            {
                strError = 'El simbolo \'@.\' no es valido.';
                blValido = false;
            }
            else if (strmail.indexOf('.@',0) != -1)
            {
                strError = 'El simbolo \'.@\' no es valido.';
                blValido = false;
            }
            else if (strmail.indexOf('..',0) != -1) 
            {
                strError = 'El simbolo \'..\' no es valido.';
                blValido = false;
            }
            else if (suffix.length != 2 && suffix != 'com' && suffix != 'net' && suffix != 'org' && suffix != 'edu' && suffix != 'int' && suffix != 'mil' && suffix != 'gov' & suffix != 'arpa' && suffix != 'biz' && suffix != 'aero' && suffix != 'name' && suffix != 'coop' && suffix != 'info' && suffix != 'pro' && suffix != 'museum')
            {
                strError = 'El dominio del email es invalido.';
                blValido = false;
            }
        }
        if(blnTipoRespuesta)
            return blValido;
        else
            return strError;
    }
    return{ValidaEntrada:ValidaEntrada}
}();
/**************************FIN FUNCION DE VALIDACION DE PARAMETROS DE ENTRADA***************************/

/************************************FUNCIONES BASICAS DE AJAX**********************************************/

var ClaseAjax = function()
{
    //CONSTRUCTOR
    function Ajax(onombreObjeto)
    {
        this.nombreObjeto = onombreObjeto;
        this.objXmlHttpPostBack = null;
        this.objRespuestaPostback = '';
    }
    //INICIALIZACION
    Ajax.prototype.inicia = function()
    {
        this.objXmlHttpPostBack = CreaObjetoAjax();    
    }
    //REALIZA LLAMADO ASINCRONICO
    Ajax.prototype.RealizaPostBackAsincronico = function(UrlLlamado, MetodoLlamado, FuncionFinalizacion, TipoRespuesta, Parametros)
    {
        if(this.objXmlHttpPostBack)
        {
            if(this.objXmlHttpPostBack.readyState == 0 || this.objXmlHttpPostBack.readyState == 4)
            {
                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');
        }
    }
    //REALIZA LLAMADO SINCRONO
    Ajax.prototype.RealizaPostBackSincrono = function(UrlLlamado, MetodoLlamado, TipoRespuesta, Parametros)
    {
        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...';
        }
    }    
    
    //FUNCIONES DE USO GENERAL

    //FUNCION CREA EL OBJETO AJAX QUE REALIZA EL POSTBACK
    function CreaObjetoAjax() 
    { 
        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;
    }     

    return{Ajax:Ajax}
}();

/************************************FIN FUNCIONES BASICAS DE AJAX**********************************************/


/************* FIN FUNCIONES JAVASCRIPT PROGRAMAS DESARROLLADOS JAIRO****************/    
