NS6 = (document.getElementById&&!document.all)
IE = (document.all)
NS = (navigator.appName=="Netscape" && navigator.appVersion.charAt(0)=="4")
var xCoord=yCoord=0;
var ticker_indicadores;
var ticker_suplementos;
var ticker_opiniones;
var ticker_estilos;
var imagen_seleccionada;
var source_seleccionada;
var timer=0;
var control_seleccionado = '';

function cambiarTextFile(div, nombre_file)
{
        if(typeof div != 'undefined')
        {
                document.getElementById(div).innerHTML="<input type='file' name='"+nombre_file+"' size='50' />";
        }
}

function cambiarOpcionFormulario(formulario, opcion)
{
	formulario.opcion.value = opcion;
	formulario.submit();
}

function eliminarDiv(div)
{
        if(typeof div != 'undefined')
        {
                document.getElementById(div).innerHTML="";
        }
}

function cambiarFuenteEditorial(div_foto, foto, div_nombre, nombre)
{
	if(typeof div_nombre != 'undefined')
	{
		document.getElementById(div_nombre).innerHTML=nombre;
	}

	if(typeof div_foto != 'undefined')
	{
		if(foto != "")
			document.getElementById(div_foto).innerHTML="<img src='"+foto+"' border=0 />";
		else
			document.getElementById(div_foto).innerHTML="";

	}
}

function cambiarImagen(imagen, source)
{
	if(imagen != imagen_seleccionada)
	{
		document.getElementById(imagen_seleccionada).src=source_seleccionada;
		imagen_seleccionada=imagen;
		source_seleccionada=document.getElementById(imagen).src;
		document.getElementById(imagen).src=source;
	}
}

function ocultarDiv(div)
{
	if(typeof document.getElementById(div) != 'undefined')
	{
	       document.getElementById(div).style.visibility='hidden';
	}
}

//	funcion buscador Paginas Amarillas
function paginas_amarillas()
{
	if(typeof document.getElementById("busqueda_paginas_amarillas") != 'undefined')
	{
		destino="http://paginasamarillas.com/pagamanet/web/companyCategory.aspx?ipa=1&ica=0&ici=*&ies=*&nci=*&nes=Todos%20los%20Estados&idi=1&txb="+document.getElementById("busqueda_paginas_amarillas").value+"&tbu=2&pg=1&tipo=categoria&k=62424";
		window.open(destino);
	}
}

//	funcion buscador sitio
function buscar(formulario)
{
	if (formulario.optGoogle[1].checked)
	{
		formulario.q.value=formulario.q.value +'  site:www.larepublica.com.co';
		formulario.action="http://pruebas.larepublica.com.co/php/web/busqueda_google.php";
	}
	else
	{
		formulario.action="http://pruebas.larepublica.com.co/php/web/buscar.php";
	}

	formulario.submit();
}

/*	Funcion Personalizada para el efecto BOX	*/
function GB_republica(caption, url, /* optional */ height, width, callback_fn)
{
	var options = {
        	caption: caption,
                height: height || 600,
                width: width || 1000,
                fullscreen: false,
                center_win: true,
                show_loading: true,
                callback_fn: callback_fn
	}

        var win = new GB_Window(options);
        return win.show(url);
}

/*	Funcion banner derecho	*/
function publicidadDerecha(div)
{
	if(screen.width>=1024 && screen.height>=768)
	{ 
		if(typeof document.getElementById(div) != "undefined")
			document.getElementById(div).style.display="block"; 
			
	}
}

/*	inicializa los indicadores del ticker	*/
function inicializarIndicadores()
{
//	zxcCSBanner('ticker_indicadores', 'H', 160, 10, Indicadores);
//        zxcBannerStart('ticker_indicadores', -1);
	activarTicker('indicadores_cabezote', 2, 3000);
}

/*	Cambia las galerias	*/
function cambiarGaleria(id_tipo_multimedia, id_multimedia, id_seccion_web)
{
	$('#galeria').html("<img src='/imagenes/web/cargando_mini.gif' border='0' />");
	$.ajax({
        	type: "POST",
                url: "/php/web/getMultimedia.php",
                data: "id_tipo_multimedia="+id_tipo_multimedia+"&id_multimedia="+id_multimedia+"&id_seccion_web="+id_seccion_web,
                global: true,
                complete: function (xhr)
                	{
                        	$('#galeria').html(xhr.responseText);
                        }
        });
}

/*	Cambia los sondeos	*/
function cambiarSondeo(id_pregunta, formulario_sondeo, id_seccion_web)
{
	var div_formulario='#'+formulario_sondeo;
	$(div_formulario).html("<img src='/imagenes/web/cargando_mini.gif' border='0' />");
	$.ajax({
        	type: "POST",
                url: "/php/web/getSondeo.php",
                data: "id_pregunta="+id_pregunta+"&formulario_sondeo="+formulario_sondeo+"&id_seccion_web="+id_seccion_web,
                global: true,
                complete: function (xhr)
                	{
                        	$(div_formulario).html(xhr.responseText);
                        }
        });
}

/*      Cambia la pagina impresa        */
function getPaginaImpresa(div, id_seccion, consecutivo, fecha)
{
        $(div).html("<img src='/imagenes/web/cargando_mini.gif' border='0' />");
        $.ajax({
                type: "POST",
                url: "/php/web/getPaginaImpresa.php",
                data: "id_seccion="+id_seccion+"&consecutivo="+consecutivo+"&fecha="+fecha,
                global: true,
                complete: function (xhr)
                        {
                                $(div).html(xhr.responseText);
                        }
        });
}


/*	Votar sondeo	*/
function votarSondeo(div, formulario, opcion)
{
	var id_respuesta=0;
	var ver_resultados=false;
	var id_pregunta=formulario.id_pregunta.value;

	if(opcion == 'votar')
	{
		//verifico si viene una respuesta
		for(i=0; i < formulario.id_respuesta.length; i++)
	        {
			if(formulario.id_respuesta[i].checked)
                		id_respuesta=formulario.id_respuesta[i].value;

		}

	        if(id_respuesta)
        	{
			ver_resultados=1;
			$(div).html("<img src='/imagenes/web/cargando_mini.gif' border='0' />").show('fast');
		}
	}
	else
	{
		ver_resultados=1;
		$(div).html("<img src='/imagenes/web/cargando_mini.gif' border='0' />").show('fast');
	}

	if(ver_resultados)
	{	
		$.ajax({
        		type: "POST",
               		url: "/php/web/voto_sondeo.php",
		        data: "id_pregunta="+id_pregunta+"&id_respuesta="+id_respuesta,
        	        global: true,
               		complete: function (xhr)
                		{
	                       		$(div).html(xhr.responseText);
	               	        }
		});
	}
} 

/*	Calculadora	*/
function calcularDivisa(cantidad, moneda_origen, moneda_destino)
{
	$('#resultado_calcular').html("<img src='/imagenes/web/cargando_mini.gif' border='0' />");
	$.ajax({
        	type: "POST",
                url: "/php/web/calculadora.php",
                data: "cantidad="+cantidad+"&moneda_origen="+moneda_origen+"&moneda_destino="+moneda_destino,
                global: true,
                complete: function (xhr)
                	{
                        	$('#resultado_calcular').html(xhr.responseText);
                        }
        });
}

function leftTrim(sString) 
{
	while (sString.substring(0,1) == ' ')
	{
		sString = sString.substring(1, sString.length);
	}
	
	return sString;
}

function rightTrim(sString) 
{
	while (sString.substring(sString.length-1, sString.length) == ' ')
	{
		sString = sString.substring(0,sString.length-1);
	}
	
	return sString;
}

function trimAll(sString) 
{
	while (sString.substring(0,1) == ' ')
	{
		sString = sString.substring(1, sString.length);
	}
	
	while (sString.substring(sString.length-1, sString.length) == ' ')
	{
		sString = sString.substring(0,sString.length-1);
	}
	
	return sString;
}

function estaDiligenciado(objeto, tipo)
{
	var bandera=false;

	switch(tipo)
	{
		case "text":
			if(trimAll(objeto.value) != "")
				bandera=true;
					
		break;
			
		case "select-one":
			if(objeto.selectedIndex > 0)
				bandera=true;
					
		break;
			
		case "select-multiple":
		break;
			
		case "radio":
			if(typeof objeto.length != "undefined")
			{
				for(var i=0; i < objeto.length; ++i)
					if(objeto[i].checked)
						bandera=true;
		
			}
			else
			{
				bandera=objeto.checked ? true : false;
			}
		break;
		
		case "checkbox":
			if(typeof objeto.length != "undefined")
			{
				for(var i=0; i < objeto.length; ++i)
					if(objeto[i].checked)
						bandera=true;
		
			}
			else
			{
				bandera=objeto.checked ? true : false;
			}
		break;
	}
	
	return bandera;
}

/*	funcion que retorna un verifica si un caractér digitado es un número	*/
function esNumero(e) 
{
	var charCode

	if (navigator.appName == "Netscape")
		charCode = e.which // leo la tecla que ingreso
	else
		charCode = e.keyCode // leo la tecla que ingreso
  
	if (charCode > 31 && (charCode < 48 || charCode > 57)) 
	{ 
		return false
	}
  
	return true
}

/*      Pagina de Inicio        */
function setPaginaInicio()
{
        if(IE)
        {
                home_principal.style.behavior='url(#default#homepage)';
                home_principal.setHomePage("http://www.larepublica.com.co");
        }
}

function esEmail(email)
{
        var regexp=/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;

        if(regexp.test(email))
                return true;
	else
		return false;

}

/*	Funciones para las fuentes de las noticias	*/
function ampliarF(div) {
        if(typeof $(div).offset() != undefined)
        {
                $(div).css({'font-size': '20px'});
                $(div).css({'line-height': '22px'});
        }
}

function normalF(div) {
        if(typeof $(div).offset() != undefined)
        {
                $(div).css({'font-size': '16px'});
                $(div).css({'line-height': '18px'});
        }
}

function reducirF(div) {
        if(typeof $(div).offset() != undefined)
        {
                $(div).css({'font-size': '12px'});
                $(div).css({'line-height': '14px'});
        }
}

/*      Genericos       */
function getEfectosGenericos()
{
        /*      Nube de tags    */
        $('#mostrar_nube').click(function(event) {
                event.preventDefault();

		if($("#nube_tags").is(":hidden"))
		{
			if(typeof $('#indicadores_setfx').offset() != undefined)
			{
				 $('#indicadores_setfx').hide();
			}
			
			if(typeof $('#graficos').offset() != undefined)
			{
				 $('#graficos').hide();
			}

			if(typeof $('#carrusel_multimedia').offset() != undefined)
			{
				 $('#carrusel_multimedia').hide();
			}

                	$('#nube_tags').show();
		}
		else
		{
			if(typeof $('#indicadores_setfx').offset() != undefined)
			{
				 $('#indicadores_setfx').show();
			}
			
			if(typeof $('#graficos').offset() != undefined)
			{
				 $('#graficos').show();
			}

			if(typeof $('#carrusel_multimedia').offset() != undefined)
			{
				 $('#carrusel_multimedia').show();
			}

                	$('#nube_tags').hide();
		}
        });

        $('#cerrar_nube').click(function(event) {
			if(typeof $('#indicadores_setfx').offset() != undefined)
			{
				 $('#indicadores_setfx').show();
			}
			
                	$('#nube_tags').hide();
        });

        var nube_offset=$('#mostrar_nube').offset();
        var nube_top=nube_offset.top + 20;
        $('#nube_tags').css({top:nube_top});

        /*      Dia Especial    */
        $("#img_dia_especial").click(function(event) {
                event.preventDefault();
                $("#dia_especial").slideToggle();
        });

	/*      LightBox        */
	$(".lightbox").lightbox();

	/*      Menu Indicadores        */
        var indicadores_offset=$('#ver_indicadores').offset();
        var indicadores_left=indicadores_offset.left;
	$('#opciones_indicadores').css({left:indicadores_left});

        $('#ver_indicadores').mouseover(function(event) {
                $('#opciones_indicadores').fadeIn();
        });

        $('#ver_indicadores').mouseout(function(event) {
                timer_indicadores=setTimeout("$(\"#opciones_indicadores\").fadeOut();", 500);
        });

        $("#opciones_indicadores").hover(function(event) {
                clearTimeout(timer_indicadores);},
                function(){
                        $("#opciones_indicadores").fadeOut();
        });

	/*	Menu Suplementos	*/
        var suplementos_offset=$('#ver_suplementos').offset();
        var suplementos_left=suplementos_offset.left;
	$('#opciones_suplementos').css({left:suplementos_left});

        $('#ver_suplementos').mouseover(function(event) {
                $('#opciones_suplementos').fadeIn();
        });

        $('#ver_suplementos').mouseout(function(event) {
                timer_suplementos=setTimeout("$(\"#opciones_suplementos\").fadeOut();", 500);
        });

        $("#opciones_suplementos").hover(function(event) {
                clearTimeout(timer_suplementos);},
                function(){
                        $("#opciones_suplementos").fadeOut();
        });

	/*	Menu Blogs	*/
        var opiniones_offset=$('#ver_opiniones').offset();
        var opiniones_left=opiniones_offset.left;
	$('#opciones_opinion').css({left:opiniones_left});

        $('#ver_opiniones').mouseover(function(event) {
                $('#opciones_opinion').fadeIn();
        });

        $('#ver_opiniones').mouseout(function(event) {
                timer_opiniones=setTimeout("$(\"#opciones_opinion\").fadeOut();", 500);
        });

        $("#opciones_opinion").hover(function(event) {
                clearTimeout(timer_opiniones);},
                function(){
                        $("#opciones_opinion").fadeOut();
        });

	/*	Menu Estilos	*/
        var estilos_offset=$('#ver_estilos').offset();
        var estilos_left=estilos_offset.left;
	$('#opciones_estilos').css({left:estilos_left});

        $('#ver_estilos').mouseover(function(event) {
                $('#opciones_estilos').fadeIn();
        });

        $('#ver_estilos').mouseout(function(event) {
                timer_estilos=setTimeout("$(\"#opciones_estilos\").fadeOut();", 500);
        });

        $("#opciones_estilos").hover(function(event) {
                clearTimeout(timer_estilos);},
                function(){
                        $("#opciones_estilos").fadeOut();
        });

	//Estilos para los votos
/*
	if($('.star-rating').offset() != undefined)
	{
		if(document.all)
		{
			var star_offset=$('.star-rating').offset();
			$('.star-rating a').css({top:star_offset.top});
			$('.star-rating a').css({left:star_offset.left});
			$('.star-rating .current-rating').css({top:star_offset.top});
			$('.star-rating .current-rating').css({left:star_offset.left});
		}
		else
		{
			$('.star-rating').css({position: 'relative'});
			$('.star-rating a').css({top: 0});
	                $('.star-rating a').css({left: 0});
			$('.star-rating .current-rating').css({top: 0});
	                $('.star-rating .current-rating').css({left: 0});
		}
	}
*/

	//Estilos para el footer
	if($('#footer').offset() != undefined)
	{
		if(document.all)
		{
			$('#footer #impresa #imagen').css({left: 0});
		}
		else
		{
			$('#footer').css({float: 'left'});
		}
	}

	/* 	Destacados	*/
/*
	if($('#destacados').offset() != undefined)
	{
		var lastBlock = $('#abierto');
                var maxWidth = 680;
                var minWidth = 70;

		$('#abierto').animate({width: maxWidth+"px"}, { queue:false, duration:400 });
                $(".noticia").click( function() {$(lastBlock).animate({width: minWidth+"px"}, { queue:false, duration:400 });
                				$(this).animate({width: maxWidth+"px"}, { queue:false, duration:400});
						lastBlock = this;
                                        	}
		);
	}
*/
}

/*      Funcion para activar/desactivar los controles del Bloque Horizontal     */
function activaControles(id_click)
{
        if(control_seleccionado != '')
        {
                $(control_seleccionado).hide();
                $(id_click).show();
                control_seleccionado=id_click;
        }
        else
        {
                $(id_click).show();
                control_seleccionado=id_click;
        }
}

/*      Funcion para cambiar la URL de una pagina       */
function cambiarURL(url)
{
        document.location.href=url;
}

/* Funcion para los tickers */
function activarTicker(ticker, velocidad, loops)
{
        document.getElementById(ticker).scrollAmount=velocidad
        document.getElementById(ticker).scrollDelay=20
        document.getElementById(ticker).loop=loops
}
