var persistclose=0
var startX=25
var startY=0
var verticalpos="fromtop"


var divs_duplicado = new Array(10); 

function iecompattest(){
	return(document.compatMode&&document.compatMode!="BackCompat")? document.documentElement : document.body
}
function get_cookie(Name){
	var search=Name+"="
	var returnvalue=""
	if(document.cookie.length>0){
		offset=document.cookie.indexOf(search)
		if(offset !=-1){
			offset+=search.length
			end=document.cookie.indexOf(";",offset)
			if(end==-1)end=document.cookie.length
			returnvalue=unescape(document.cookie.substring(offset,end))}}
	return returnvalue
}

var fWidth;
function getLeftLightbox(divcito){
	//For old IE browsers
	if(document.all)
		fWidth = document.body.clientWidth;
	//For DOM1 browsers
	else if(document.getElementById &&!document.all)
		fWidth = innerWidth;
	else if(document.getElementById)
		fWidth = innerWidth;
	//For Opera
	else if (is.op)
		fWidth = innerWidth;
	//For old Netscape
	else if (document.layers)
		fWidth = window.innerWidth;
	var widthdivcito = obtenerEstilo(divcito,"width");
	return ((fWidth/2)-(widthdivcito/2))+"px";
}

function obtenerEstilo(elemento,estilo){
	if(elemento.width)
	   return elemento.width;
	
	style = estilo;
	value=elemento.style.estilo;
	if (!value) {
		  if (document.defaultView && document.defaultView.getComputedStyle) {
			var css = document.defaultView.getComputedStyle(elemento, null);
			value = css ? css[style] : null;
		  } else if (elemento.currentStyle) {
			value = elemento.currentStyle[style];
		  }
	}
	if(isNaN(value))
	   return elemento.offsetWidth;
	else if(value)
		return value.replace("px","");
	else
		return 0;
}

function abrirLightbox(windowID, borrarContenido, contenedorcampos){
	if(borrarContenido==1){
	         document.getElementById(contenedorcampos).innerHTML = divs_duplicado[windowID].innerHTML;
    }
   	ponerVelo();
	this.id=windowID
	barheight=document.getElementById(this.id).offsetHeight
	var ns=(navigator.appName.indexOf("Netscape")!=-1)|| window.opera
	var d=document
	function ml(id){
		var el=d.getElementById(id)
		if(!persistclose || persistclose&&get_cookie("remainclosed")=="")
		el.style.display="block"
		if(d.layers)el.style=el
		el.sP=function(x,y){this.style.left=getLeftLightbox(el);this.style.top=y+"px";}
		el.x=startX
		if(verticalpos=="fromtop"){
			el.y=ns ? pageYOffset : iecompattest().scrollTop
	        fHeight=ns ? (window.innerHeight/2)-(el.offsetHeight/2) : (iecompattest().clientHeight/2)-(el.offsetHeight/2)
	        el.y=el.y+fHeight
	    }else{
			el.y=ns ? pageYOffset+innerHeight : iecompattest().scrollTop+iecompattest().clientHeight
			el.y-=startY
		}
		el.sP(el.x,el.y)
		return el}
	ftlObj=ml(this.id)
}


function enviarInfoAbuso(){
    
    document.formenviarabuso.mensajeusuabuso.value=strip_tags(document.formenviarabuso.mensajeusuabuso.value);
    
    var indice=document.formenviarabuso.abusos.options.selectedIndex;	
	var tipo_abuso = document.formenviarabuso.abusos.options[indice].value;	
	var mensaje_abuso=document.formenviarabuso.mensajeusuabuso.value;	
	var comentario_reportado = document.formenviarabuso.num_comentario.value;
	var autor_reportado = document.formenviarabuso.autor_comentario.value;
							
	if(isEmpty(mensaje_abuso))
	{
		alert("Por favor, escriba el mensaje");
		return;
	}
    

	try{
	   var navegador = getversion();
	}catch(err){
	   navegador = "imposible determinar";  
	}
	try{
	   var os = getOS();
	}catch(err){
		os = "imposible determinar";
	}
	//para tomar la direccion de la pagina desde donde fue enviado
	var dirpagina = document.location.href;   
    document.getElementById("contentcamposAbuso").innerHTML = "<br><br><br><h3>Enviando solicitud, por favor espere...</h3><br><br><br>";    
    incluirObjeto("MOSTRAR_GRACIAS_ABUSO","comentarios@portafolio.com",tipo_abuso,mensaje_abuso,navegador, os, dirpagina,comentario_reportado,autor_reportado,"contentcamposAbuso");        
    
}

function cerrarLightboxVotar(windowID){
    document.getElementById("mensajevotar").innerHTML = '';
    cerrarLightbox(windowID);
}
function cerrarLightbox(windowID){
	quitarVelo();
	this.id=windowID
	if(persistclose)
	document.cookie="remainclosed=1"
	document.getElementById(this.id).style.display="none"    
}
function JSWindow(windowID){
	document.getElementById('vermask').className='layerlightver'
	oTable=document.createElement("table")
	oTable.cellSpacing=0
	oTable.cellPadding=0
	oTable.border=0
	var windowdiv=document.getElementById(windowID)
	var urlight=document.getElementById(windowID)
	while(windowdiv.hasChildNodes())windowdiv.removeChild(windowdiv.firstChild)
	windowdiv.appendChild(oTable)
	var oTR=oTable.insertRow(0)
	oTD=oTR.insertCell(0)
	oTD.innerHTML="<img src='"+urlight.value+"' border=0>"}

function ponerVelo(){
   document.getElementById('vermask').className='layerlightver';
}
function quitarVelo(){
   document.getElementById('vermask').className='';
}

function mostrarRecursoMultimedia(respuesta){
   
   if(document.getElementById("contenidoReproductor")){
    var divmulti = document.getElementById("contenidoReproductor").innerHTML=respuesta;
    abrirLightbox("lightboxMultimedia",0);
    if (fileRec != '' && idDivRec != '' && tipoRec != '') {
       generarVideoJS(fileRec , idDivRec, tipoRec, 320, 288);
       fileRec = '';
       idDivRec = '';
       tipoRec = '';
    }
   }else
   {
   var divmulti = document.getElementById("reproducirVideoInicial").innerHTML=respuesta;
    //abrirLightbox("lightboxMultimedia",0);
    if (fileRec != '' && idDivRec != '' && tipoRec != '') {
       generarVideoJSEnDiv(fileRec , idDivRec, tipoRec, 481, 394);
       fileRec = '';
       idDivRec = '';
       tipoRec = '';
    }
   }
}

function enviarError(idform){
   
    form =  document.getElementById(idform);
    
    //para tomar el enlace de la pagian en la que se encuentra
    var link = document.getElementById("redireccion").value;
    
form.nombreUsu.value=strip_tags(form.nombreUsu.value);
form.correoUsu.value=strip_tags(form.correoUsu.value);
form.mensajeUsu.value=strip_tags(form.mensajeUsu.value); 

    var nombreusua=form.nombreUsu.value;
	var correousua=form.correoUsu.value;
	var mensaje=form.mensajeUsu.value; 
	

	if(isEmpty(nombreusua))
	{
		alert("Por favor, escribe tu nombre");
		return;
	}
	
	if(!isEmail(correousua))
	{
		alert("Tu dirección de correo electrónico no es válida");
		return;
	}

	if(isEmpty(mensaje))
	{
		alert("Por favor, escribe tu  mensaje");
		return;
	}	
	 document.getElementById("contentcamposError").innerHTML = "<br><br><br><h1>D&aacuate;nos un segundo. Estamos enviando tus observaciones a nuestro equipo editorial.</h1><br><br><br>";
     incluirObjeto("ENVIAR_ERROR",nombreusua, correousua, mensaje, link, "contentcamposError");
                
  } 
  function enviarContacto(idform, tipoContacto){
   
    form =  document.getElementById(idform);
    
    var nombreusua=form.nombreUsu.value;
    var cedulausua = form.cedulaUsu.value;
    var telefonousua = form.telefonoUsu.value;
    var correousua=form.correoUsu.value;
	var mensaje=form.mensajeUsu.value; 
	
	if(isEmpty(nombreusua))
	{
		alert("Por favor, escribe tu nombre");
		return;
	}
	
	if(isEmpty(cedulausua))
	{
		alert("Por favor, escribe tu cédula");
		return;
	}
	
	if(isEmpty(telefonousua))
	{
		alert("Por favor, escribe tu teléfono");
		return;
	}
	
	if(!isEmail(correousua))
	{
		alert("Tu dirección de correo electrónico no es válida");
		return;
	}

	if(isEmpty(mensaje))
	{
		alert("Por favor, escribe tu  mensaje");
		return;
	}
     //tomo el tipo de contacto 	
	 var tipo = document.getElementById("tipoContacto").innerHTML;
	  	
	 document.getElementById("contentcamposcontact").innerHTML = "<br><br><br><h1>Enviando reporte, por favor espere...</h1><br><br><br>";
     incluirObjeto("ENVIAR_CONTACTO",nombreusua, cedulausua, telefonousua, correousua, mensaje,tipo,"contentcamposcontact");
                
  } 
  
  function enviarAmigo (idform, idRecurso){
   
    form =  document.getElementById(idform);
    
    //para tomar el enlace de la pagian en la que se encuentra
    var link = document.getElementById("redireccion").value;
    
    form.nombreor.value=strip_tags(form.nombreor.value);
	form.mailor.value=strip_tags(form.mailor.value);
	form.nombredes.value=strip_tags(form.nombredes.value);
	form.maildes.value=strip_tags(form.maildes.value);
	form.mensaje.value=strip_tags(form.mensaje.value);


    var nombreorigen=form.nombreor.value;
	var mailorigen=form.mailor.value;
	var nombredestino=form.nombredes.value;
    var maildestino=form.maildes.value;
  	var mensajemail=form.mensaje.value;
	 
	

	if(isEmpty(nombreorigen))
	{
		alert("Por favor, escriba su nombre");
		return;
	}
	
	if(!isEmail(mailorigen))
	{
		alert("Su dirección de correo electrónico no es válida");
		return;
	}
    if(isEmpty(nombredestino))
	{
		alert("Por favor, escriba el nombre del destinatario");
		return;
	}
	
	if(!isEmail(maildestino))
	{
		alert("La dirección de correo electrónico del destinatario no es válida");
		return;
	}
	if(isEmpty(mensajemail))
	{
		alert("Por favor, escriba el mensaje");
		return;
	}	
	 document.getElementById("contentcamposAmigo").innerHTML = "<div class='uncamporegistro'><br><br><br><h1>Un segundo por favor, estamos enviando la información a la persona.</h1><br><br><br></div>";
     incluirObjeto("ENVIAR_AMIGO",nombreorigen,mailorigen,nombredestino,maildestino,mensajemail, link,idRecurso, "contentcamposAmigo");
                
  } 
  
  function enviarInformanos (idform){
   
    form =  document.getElementById(idform);
    
    //para tomar el enlace de la pagian en la que se encuentra
    var link = document.getElementById("redireccion").value;
    
    var infonombre=form.infoNombre.value;
    var infoapellido=form.infoApellido.value;
	var infomail=form.infoMail.value;
    var infotipo=form.infoTipo.value;
    var infodirec=form.infoDirec.value;
    var infotele=form.infoTele.value;
    var infocelu=form.infoCelu.value;
    var infociudad=form.infoCiudad.value;
	var infomensaje=form.infoMensaje.value;

	if(isEmpty(infonombre))
	{
		alert("Por favor, escribe tu nombre");
		return;
	}
	if(isEmpty(infoapellido))
	{
		alert("Por favor, escribe tu apellido");
		return;
	}
	
	if(!isEmail(infomail))
	{
		alert("Tu dirección de correo electrónico no es válida");
		return;
	}
    if(isEmpty(infotipo))
	{
		alert("Por favor, elije un tipo");
		return;
	}
	
	if(isEmpty(infodirec))
	{
		alert("Por favor, escribe tu dirección");
		return;
	}
	
	if(isEmpty(infotele))
	{
		alert("Por favor, escribe tu teléfono");
		return;
	}
	if(isEmpty(infocelu))
	{
		alert("Por favor, escribe tu  celular");
		return;
	}
	
	if(isEmpty(infociudad))
	{
		alert("Por favor, escribe tu  Ciudad");
		return;
	}
	
	if(isEmpty(infomensaje))
	{
		alert("Por favor, escribe tu  mensaje");
		return;
	}	
	 document.getElementById("contentcamposInformanos").innerHTML = "<div class='uncamporegistro'><br><br><br><h1>D&aacute;nos un segundo. Estamos enviando tu informaci&oacute;n a nuestro equipo editorial.</h1><br><br><br></div>";
     incluirObjeto("ENVIAR_INFORMANOS",infonombre,infoapellido,infomail,infotipo,infodirec,infotele,infocelu,infociudad,infomensaje,"contentcamposInformanos");
                
  } 
  
  
  function isEmail (s)
  {
    if (isEmpty(s)) 
      if (isEmail.arguments.length == 1) return false;
      else return (isEmail.arguments[1] == true);
      var i = 1;
      var sLength = s.length;
      while ((i < sLength) && (s.charAt(i) != "@")) i++;
      
      if ((i >= sLength) || (s.charAt(i) != "@")) return false;
      else i += 2;
      
      while ((i < sLength) && (s.charAt(i) != "."))i++;
      
      if ((i >= sLength - 1) || (s.charAt(i) != ".")) return false;
      else return true;
  }
    
  function isEmpty(s)
  {   
	return ((s == null) || (s.length == 0));
  }
  
  
  function staticbarAbuso(windowID,numComentario,autorReportado){
    this.numComentario = numComentario;
    this.autorReportado = autorReportado;
    document.formenviarabuso.num_comentario.value = numComentario;
    document.formenviarabuso.autor_comentario.value = autorReportado;
	this.id=windowID;
//	barheight=document.getElementById("topbar"+this.id).offsetHeight
	var ns=(navigator.appName.indexOf("Netscape")!=-1)|| window.opera
	var d=document
	function ml(id){
		var el=d.getElementById(id)
		if(!persistclose || persistclose&&get_cookie("remainclosed")=="")
		el.style.display="block"
		if(d.layers)el.style=el
		el.sP=function(x,y){this.style.left=x+"%";this.style.top=y+"px";}
		el.x=startX
		if(verticalpos=="fromtop")
		el.y=startY
		else{
			el.y=ns ? pageYOffset+innerHeight : iecompattest().scrollTop+iecompattest().clientHeight
			el.y-=startY}
		return el}
	window.stayTopLeft=function(){
		if(verticalpos=="fromtop"){
			var pY=ns ? pageYOffset : iecompattest().scrollTop
			ftlObj.y+=(pY+startY-ftlObj.y)/8}
		else{
			var pY=ns ? pageYOffset+innerHeight-barheight: iecompattest().scrollTop+iecompattest().clientHeight-barheight
			ftlObj.y+=(pY-startY-ftlObj.y)/8}
		ftlObj.sP(ftlObj.x,ftlObj.y)
		setTimeout("stayTopLeft()",10)}
	ftlObj=ml("topbar"+this.id)
	stayTopLeft()
}

function enviarContacto1(accion){
    var frmEnviarPTmp = document.getElementById('formlb');
    frmEnviarPTmp.accionUsu.setAttribute("value", accion);
    abrirLightbox("lightboxContactenos" , accion, 'contentcamposContactenos');
    document.getElementById('vermask').className='layerlightver';
}

function enviarContacto2(idform){
    form =  document.getElementById(idform);
    
    
form.nombreUsu.value=strip_tags(form.nombreUsu.value);
form.cedulaUsu.value=strip_tags(form.cedulaUsu.value);
form.telefonoUsu.value=strip_tags(form.telefonoUsu.value);
form.correoUsu.value=strip_tags(form.correoUsu.value);
form.mensajeUsu.value=strip_tags(form.mensajeUsu.value); 

    var nombreusua = form.nombreUsu.value;
    var cedulausua = form.cedulaUsu.value;
    var telefonousua = form.telefonoUsu.value;
	var correousua = form.correoUsu.value;
	var mensaje = form.mensajeUsu.value;
	var accion = form.accionUsu.value; 
	

	if(isEmpty(nombreusua))
	{
		alert("Por favor, escriba su nombre");
		return;
	}
	
	if(isEmpty(cedulausua))
	{
		alert("Por favor, escriba su cedula");
		return;
	}
	
	if(isEmpty(telefonousua))
	{
		alert("Por favor, escriba su teléfono");
		return;
	}
	
	if(!isEmail(correousua))
	{
		alert("Su dirección de correo electrónico no es válida");
		return;
	}

	if(isEmpty(mensaje))
	{
		alert("Por favor, escriba su mensaje");
		return;
	}	
	 document.getElementById("contentcamposContactenos").innerHTML = "<br><br><br><h1>D&eacute;nos un segundo. Estamos enviando su informaci&oacute;n a nuestro equipo.</h1><br><br><br>";
     incluirObjeto("ENVIAR_CONTACTO",nombreusua, cedulausua, telefonousua, correousua, mensaje, accion, "contentcamposContactenos");
}


function cargarDetalle(objeto,id,desde,hasta,pagina,div)
{
    abrirLightbox("lightboxPreload",'contentpreload');
    document.getElementById('vermask').className='layerlightver';    
    incluirObjeto(objeto,id,desde,hasta,pagina,div);
    //setTimeOut(cerrarLightbox('lightboxPreload'), 100);
    /*window.onload=function(){
    self.location.hash = "#ancla";
    }*/
}

function cargarDetalle0(objeto,id,desde,hasta,pagina,div)
{
    document.getElementById(div).innerHTML = '<div style="margin:0 auto 0 auto; width:80px" ><img src="/images/ajax-loader.gif" alt="Cargando..." /></div>';
    incluirObjeto(objeto,id,desde,hasta,pagina,div);
}



function evento(){
    abrirLightbox("lightboxPublicarEvento",'contentcamposEvento');
    document.getElementById('vermask').className='layerlightver';
}

function enviarEvento(idform){
    form =  document.getElementById(idform);
    
	var evento = form.evento.value;
	var desc = form.desc.value;
	var fecha = form.fecha.value;
	var lugar = form.lugar.value;
	var hora = form.hora.value;
	var nombre = form.nombre.value;
	var tel = form.tel.value;
	var correo = form.correo.value;	

	
	if(isEmpty(evento))
	{
		alert("Por favor, escriba el nombre del evento");
		return;
	}
	
	if(isEmpty(desc))
	{
		alert("Por favor, escriba una descripción");
		return;
	}
	
	if(isEmpty(fecha))
	{
		alert("Por favor, escriba la fecha del evento");
		return;
	}
	
	if(isEmpty(lugar))
	{
		alert("Por favor, escriba el lugar del evento");
		return;
	}
	
	if(isEmpty(hora))
	{
		alert("Por favor, escriba la hora del evento");
		return;
	}
	
	if(isEmpty(nombre))
	{
		alert("Por favor, escriba su nombre");
		return;
	}
	
	if(isEmpty(tel))
	{
		alert("Por favor, escriba su teléfono");
		return;
	}
	if(!isEmail(correo))
	{
		alert("Su dirección de correo electrónico no es válida");
		return;
	}
	
	 document.getElementById("contentcamposEvento").innerHTML = "<br><br><br><h1>D&eacute;nos un segundo. Estamos enviando su evento.</h1><br><br><br>";
	 
     incluirObjeto("ENVIAR_EVENTO", evento, desc, fecha, lugar, hora, nombre, tel, correo, "contentcamposEvento");
}

function recordarPass(){
    abrirLightbox("lightboxRecordarClave" , 'contentcamposRecordar');
    document.getElementById('vermask').className='layerlightver';
}

function recordarPass2(idform){
    form =  document.getElementById(idform);
    
	var correousua = form.correoUsu.value;	

	
	if(!isEmail(correousua))
	{
		alert("Su dirección de correo electrónico no es válida");
		return;
	}
	
	 document.getElementById("contentcamposRecordar").innerHTML = "<br><br><br><h1>D&eacute;nos un segundo. Estamos enviando su solicitud.</h1><br><br><br>";
     incluirObjeto("RECORDAR_PASSWORD", correousua, "contentcamposRecordar");
}

function java(){
    abrirLightbox("lightboxJava" , 'contentjava');
    document.getElementById('vermask').className='layerlightver';
}

function borrarCalculo(id,idUser){
    abrirLightbox("lightboxBorrarCalculo" , 'contentborrarCalculo');
    document.getElementById("contentborrarCalculo").innerHTML = "<br><br><br><h3>Se est&aacute; borrando el c&aacute;lculo realizado<br>por favor espere...</h3><br><br><br>";
    document.getElementById('vermask').className='layerlightver';
    incluirObjeto("BORRAR_CALCULO", id, idUser, "contentborrarCalculo");
}function swapIt(o, nomContenido, pordefecto, navigation, contenedor) {
	o.blur(); //Esto quita el foco de la pestaña a la que le hicieron click
	
	//Si el click fue sobre la paestaña actual, retorno
	if (o.className == pordefecto) return false;
  
    //Tomo todos los links que hay dentro del div de navegacion
	var list = document.getElementById(navigation).getElementsByTagName("a");
	
	//Aca le quito la clase "pordefecto" a la pestaña que lo tiene en el momento
	for (var i = 0; i < list.length; i++) {
		if (list[i].className == pordefecto) {
			list[i].className = "";	
		}
	}
	
	//le doy la clase "pordefecto" a la pestaña actual
  	o.className = pordefecto;
  	
  	//tomo el div contenedor de los divs de contenido y a cada uno le pongo display=none
	list = document.getElementById(contenedor).childNodes;
	for (var i = 0; i < list.length; i++) {
		if (list[i].tagName == "DIV") list[i].style.display = "none";
	}
  
    //Le doy display=block al div que corresponde a la pestaña que voy a mostrar
	var top = document.getElementById(nomContenido);
	top.style.display = "block";

	return false;
}

function recargarObjeto2(nombre_objeto, div_respuesta, o, pordefecto, cual){
   
    //Quitar el foco de la pestaña a la que le hicieron click
     o.style.display='block';
     o.blur(); 
             
    //Quitarle el estilo a la pestaña actual
    var list = document.getElementById('NavigationMiPortafolio').getElementsByTagName("a");
    for (var i = 0; i < list.length; i++) {
		if (list[i].className == pordefecto) {
			list[i].className = "";	
		}
	}
	//clase a la pestaña del click
	o.className = pordefecto;
    
    incluirObjeto(nombre_objeto, cual, div_respuesta);   
}function cambiarFuente(iddiv, accion){
    var estilo;
    divcito = document.getElementById(iddiv);
    elementsp=divcito.getElementsByTagName('p'); 
    claseActual = elementsp[0].className;
    switch (accion) {         
        case 'aumenta2':
          estilo = 'masmas';
 
        break;
        case 'aumenta1':
          estilo = 'mas';
            
        break;
        default:
            estilo = '';
    }
    for(i=0;i<elementsp.length;i++){
        if(elementsp[i].id!="noaumenta"){
            elementsp[i].className = estilo;
        }
    }
}

function cambiarFuente2(iddiv, accion){
    var estilo;
    divcito = document.getElementById(iddiv);
    elementsdiv=divcito.getElementsByTagName('div');
    alert("cuantos divs"+elementsdiv.length);
    for(j=0;j<elementsdiv.length;j++){
    elementsp=elementsdiv[j].getElementsByTagName('p'); 
    alert("cuantos ps"+elementsp.length);
    if(elementsp.length>0)
    {
    claseActual = elementsp[0].className;
    switch (accion) {
        case 'aumenta':
            if (claseActual == '') {
                estilo = 'mas';
            }else {
                estilo = 'masmas';
            }
        break;
        case 'disminuye':
            if (claseActual == 'masmas') {
                estilo = 'mas';
            }else {
                estilo = '';
            }
        break;
        default:
            estilo = '';
    }
    for(i=0;i<elementsp.length;i++){
        
            elementsp[i].className = estilo;
        
    }
   }
  }  
}function agregarMyPregunta()
{	  
     var enviar = true;
     
     with(document.nuevaPregunta){
        if(!titulo.value){document.getElementById("errorAdd").innerHTML = "Ingrese el título de la pregunta";
        enviar = false;}
        if(!publicacion.value){document.getElementById("errorAdd").innerHTML = "Ingrese la categoría de la pregunta";
        enviar = false;}
        
        if(enviar){
           abrirLightbox('lightboxAgregarPregunta',0,'contentcamposAgregarPregunta');
   	       document.getElementById("contentcamposAgregarPregunta").innerHTML = "<br><br><br><p>Estamos agregando tu pregunta.</p><br><br><br>";
     
           incluirObjeto("AGREGAR_PREGUNTA",idUsuario,titulo.value, descripcion.value, publicacion.value, mymail.checked, 'contentcamposAgregarPregunta');
        }
     }
} 

function recargarObjeto(nombre_objeto, div_respuesta, o, pordefecto, pasar_variable, pagina, inactivar, poner_texto){
   
    //Quitar el foco de la pestaña a la que le hicieron click
     o.style.display='block';
     o.blur(); 
     
     //Inactivar una pestaña
     if(inactivar){
        document.getElementById(inactivar).style.display='none';
     }
     if(poner_texto)
         document.getElementById('ver_seccion').innerHTML = poner_texto;
    
        
    //Quitarle el estilo a la pestaña actual
    var list = document.getElementById('NavigationMiPortafolio').getElementsByTagName("a");
    for (var i = 0; i < list.length; i++) {
		if (list[i].className == pordefecto) {
			list[i].className = "";	
		}
	}
	//clase a la pestaña del click
	o.className = pordefecto;
    
    incluirObjeto(nombre_objeto, pasar_variable, pagina, div_respuesta);   
}


function recargarObjetoMultimedia(nombre_objeto, div_respuesta, o, pordefecto, pasar_variable, pagina, inactivar, poner_texto, consulta_obj){

     //Imagen cargando
     document.getElementById('listado_respuesta').innerHTML = "<p align='center'><img src='http://www.vive.in/images/ajax-loader.gif' /></p>";

     //Si no viene objeto en pestaña a desactivar, se carga la primera pestaña
     if(o=='pestanaJugar'){
        o = document.getElementById('ver_ultimos');
     }

    //Quitar el foco de la pestaña a la que le hicieron click
     o.style.display='block';
     o.blur(); 
     
     //Inactivar una pestaña
     if(inactivar){
        document.getElementById(inactivar).style.display='none';
     }
     //Si hay q asignar un titlo con elparametro de busqueda
     if(poner_texto)
         document.getElementById('EncabezadoHomeMulti').innerHTML = poner_texto;
    
 
    //Quitarle el estilo a la pestaña actual
    var list = document.getElementById('NavigationMiPortafolio').getElementsByTagName("a");
    for (var i = 0; i < list.length; i++) {
		if (list[i].className == pordefecto) {
			list[i].className = "";	
		}
	}
	//clase a la pestaña del click
	o.className = pordefecto;
	
	//Almaceno el filtro en u div invisible
    document.getElementById('guardarBuscador').innerHTML = pasar_variable;
    
    if(!consulta_obj)
       consulta_obj = 0;
    incluirObjeto(nombre_objeto, pasar_variable, pagina, consulta_obj, div_respuesta); 
    
    var dirActual = window.location.href;
    var posi = dirActual.search("#");
    if(posi && posi!="-1")
       var direccion = dirActual.slice(0, (posi));
    else
       var direccion = dirActual;
    
    window.location.href = direccion+"#inicioPaginador";  
   
    //document.getElementById('listado_respuesta').style.class = 'tab masVistos';
    
}

var horizontal_offset="-20px";var vertical_offset="20px";var ie=document.all;var ns6=document.getElementById&&!document.all;function clearbrowseredge(obj,whichedge){var edgeoffset=(whichedge=="rightedge")?parseInt(horizontal_offset)*-1:parseInt(vertical_offset)*-1;if(whichedge=="rightedge"){var windowedge=ie&&!window.opera?iecompattest().scrollLeft+iecompattest().clientWidth-30:window.pageXOffset+window.innerWidth-40;dropmenuobj.contentmeasure=dropmenuobj.offsetWidth;if(windowedge-dropmenuobj.x<dropmenuobj.contentmeasure)edgeoffset=dropmenuobj.contentmeasure+obj.offsetWidth+parseInt(horizontal_offset);}else{var windowedge=ie&&!window.opera?iecompattest().scrollTop+iecompattest().clientHeight-15:window.pageYOffset+window.innerHeight-18;dropmenuobj.contentmeasure=dropmenuobj.offsetHeight;if(windowedge-dropmenuobj.y<dropmenuobj.contentmeasure)edgeoffset=dropmenuobj.contentmeasure-obj.offsetHeight;}return edgeoffset;}function showhint(menucontents,obj,e,tipwidth){if((ie||ns6)&&document.getElementById("hintbox")){dropmenuobj=document.getElementById("hintbox");dropmenuobj.innerHTML=menucontents;dropmenuobj.style.left=dropmenuobj.style.top=-500;if(tipwidth!=""){dropmenuobj.widthobj=dropmenuobj.style;dropmenuobj.widthobj.width=tipwidth;}dropmenuobj.x=getposOffset(obj,"left");dropmenuobj.y=getposOffset(obj,"top");dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj,"rightedge")+obj.offsetWidth+"px";dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj,"bottomedge")+"px";dropmenuobj.style.visibility="visible";obj.onmouseout=hidetip;}}function hidetip(e){dropmenuobj.style.visibility="hidden";dropmenuobj.style.left="-500px";}function createhintbox(){var divblock=document.createElement("div");divblock.setAttribute("id","hintbox");document.body.appendChild(divblock);}if(window.addEventListener)window.addEventListener("load",createhintbox,false);else if(window.attachEvent)window.attachEvent("onload",createhintbox);else if(document.getElementById)window.onload=createhintbox;/***********************************************
* Drop Down/ Overlapping Content- © Dynamic Drive (www.dynamicdrive.com)
* This notice must stay intact for legal use.
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/
var posicion;


function getposOffset(overlay, offsettype)
{
	var totaloffset=(offsettype=="left")? overlay.offsetLeft : overlay.offsetTop;
	var parentEl=overlay.offsetParent;
	while (parentEl!=null){
		totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
		parentEl=parentEl.offsetParent;
	}
	return totaloffset;
}


function overlay(curobj, subobjstr, opcion, opt_position, x_posi){

	if(idUsuario != "" && idUsuario != null) // estoy autenticado
		return true;
	if(x_posi=="")x_posi = 0;
	if (document.getElementById){
		var subobj=document.getElementById(subobjstr)
		subobj.style.display=(subobj.style.display!="block")? "block" : "none"
		
		var myEvent = window.event ? window.event : "";
		
		if(myEvent){ // Para explorer
           		curleft = myEvent.clientX 
           		curtop = myEvent.clientY          		           	
      	}
      	else{ //el resto
			if (curobj.offsetParent) {
	           		curleft = curobj.offsetLeft
	           		curtop = curobj.offsetTop           		           	
	          
			while (curobj == curobj.offsetParent) {
				curleft += curobj.offsetLeft
				curtop += curobj.offsetTop
			    }
	      	}	
      	}
      	
        subobj.style.left = curleft+"px"
        subobj.style.top = curtop+"px"
        
        var textoCajaLogin = new Array();
        textoCajaLogin["comentario"] = "Para comentar noticias en Portafolio.com.co debe estar registrado y ser un comentarista identificado. Por favor ingrese con su usuario y contrase&ntilde;a.";
        textoCajaLogin["favorito"] = "Para poder agregar este elemento a Su Portafolio debe estar registrado. Por favor ingrese con su usuario y contrase&ntilde;a.";
        textoCajaLogin["votar"] = "Para poder votar o vetar en Portafolio.com.co debe estar registrado. Por favor ingrese con su usuario y contrase&ntilde;a.";
        textoCajaLogin["calculadora"] = "Para poder visualizar esta calculadora en Portafolio.com.co debe estar registrado. Por favor ingrese con su usuario y contrase&ntilde;a.";
        
        var tituloCajaLogin = new Array();
        tituloCajaLogin["comentario"] = "Comentar Noticia";
        tituloCajaLogin["favorito"] = "Guardar en Mi Portafolio";
        tituloCajaLogin["votar"] = "Votar y vetar";
        tituloCajaLogin["calculadora"] = "Calculadoras";
       
       
        if (opcion){
        	document.getElementById("variarTexto").innerHTML = textoCajaLogin[opcion];
        	document.getElementById("variarTitulo").innerHTML = tituloCajaLogin[opcion];
        }else{
         	document.getElementById("variarTexto").innerHTML = "Para comentar art&iacute;culos en Portafolio.com.co debe estar registrado y ser un comentarista identificado. Por favor ingrese con su usuario y contrase&ntilde;a.";
         	document.getElementById("variarTitulo").innerHTML = "Ingrese";
        }
        
        return false;
    }else{
        return true;
    }
}

function overlayclose(subobj){
 document.getElementById(subobj).style.display="none"
 document.getElementById("malAutenticado").innerHTML="";
 document.getElementById("vLoginForma").innerHTML="";
 document.getElementById("vClaveForma").innerHTML="";
 document.getElementById("password").value="";
 document.getElementById("login").value="";
}


function validarFormaLogin() 
{
   var divErrores = document.getElementById("malAutenticado");
   
   divErrores.innerHTML = "<p>Estamos validando su información...</p>";
   
   document.getElementById("vLoginForma").innerHTML = document.getElementById("vClaveForma").innerHTML = "";
   a = true;
   with(document.formaCajitaLoginFlotante) 
   {
     if (document.formaCajitaLoginFlotante.login.value == "")
     {
        document.getElementById("vLoginForma").innerHTML = "<p>Por favor, ingrese su nombre de usuario</p>";
        a = false;
     }
     if (password.value == "") 
     {
        document.getElementById("vClaveForma").innerHTML = "<p>Por favor, ingrese su clave</p>";
        a = false;
     }
     if (a)
     {
        var persi="";
        if (cookieCajiPersis.checked)
        { 
           persi = cookieCajiPersis.checked; 
        }
        incluirObjeto("AUTENTICAR_USUARIO",login.value,password.value , persi,'malAutenticado');
     }
     else
	 {
		divErrores.innerHTML = "";
		divErrores.style.background = "none";
	 }
   }
}

function validarFormaLogin2() 
{
   var divErrores = document.getElementById("malAutenticado");
   
   divErrores.innerHTML = "<p>Estamos validando su información...</p>";
   
   document.getElementById("vLoginForma").innerHTML = document.getElementById("vClaveForma").innerHTML = "";
   a = true;
   with(document.formaCajitaLoginFlotante2) 
   {
     if (document.formaCajitaLoginFlotante2.login.value == "")
     {
        document.getElementById("vLoginForma").innerHTML = "<p>Por favor, ingrese su nombre de usuario</p>";
        a = false;
     }
     if (password.value == "") 
     {
        document.getElementById("vClaveForma").innerHTML = "<p>Por favor, ingrese su clave</p>";
        a = false;
     }
     if (a)
     {
        var persi="";
        if (cookieCajiPersis.checked)
        { 
           persi = cookieCajiPersis.checked; 
        }
        incluirObjeto("AUTENTICAR_USUARIO",login.value,password.value , persi,'malAutenticado');
     }
     else
	 {
		divErrores.innerHTML = "";
		divErrores.style.background = "none";
	 }
   }
}

function validarFormaLogin() 
{
   var divErrores = document.getElementById("malAutenticado");
   
   divErrores.innerHTML = "<p>Estamos validando su información...</p>";
   
   document.getElementById("vLoginForma").innerHTML = document.getElementById("vClaveForma").innerHTML = "";
   a = true;
   with(document.formaCajitaLoginFlotante) 
   {
     if (document.formaCajitaLoginFlotante.login.value == "")
     {
        document.getElementById("vLoginForma").innerHTML = "<p>Por favor, ingrese su nombre de usuario</p>";
        a = false;
     }
     if (password.value == "") 
     {
        document.getElementById("vClaveForma").innerHTML = "<p>Por favor, ingrese su clave</p>";
        a = false;
     }
     if (a)
     {
        var persi="";
        if (cookieCajiPersis.checked)
        { 
           persi = cookieCajiPersis.checked; 
        }
        incluirObjeto("AUTENTICAR_USUARIO",login.value,password.value , persi,'malAutenticado');
     }
     else
	 {
		divErrores.innerHTML = "";
		divErrores.style.background = "none";
	 }
   }
}

//para MT
function validarFormaLogin3() 
{
   var divErrores = document.getElementById("malAutenticado");
   
   divErrores.innerHTML = "<p>Estamos validando su información...</p>";
   
   document.getElementById("vLoginForma").innerHTML = document.getElementById("vClaveForma").innerHTML = "";
   a = true;
   with(document.formaCajitaLoginFlotante) 
   {
     if (document.formaCajitaLoginFlotante.login.value == "")
     {
        document.getElementById("vLoginForma").innerHTML = "<p>Por favor, ingrese su nombre de usuario</p>";
        a = false;
     }
     if (password.value == "") 
     {
        document.getElementById("vClaveForma").innerHTML = "<p>Por favor, ingrese su clave</p>";
        a = false;
     }
     if (a)
     {
        var persi="";
        if (cookieCajiPersis.checked)
        { 
           persi = cookieCajiPersis.checked; 
        }
        incluirObjeto("AUTENTICAR_USUARIO_2",login.value,password.value , persi,'malAutenticado');
     }
     else
	 {
		divErrores.innerHTML = "";
		divErrores.style.background = "none";
	 }
   }
}

function validarFormaLoginBarra() 
{
   var divErrores = document.getElementById("malAutenticadoBarra");
   
   divErrores.innerHTML = "<p>Estamos validando su información...</p>";
   divErrores.className="verificacionVisible";
   document.getElementById("vLoginFormaBarra").innerHTML = document.getElementById("vClaveFormaBarra").innerHTML = "";
   a = true;
   with(document.formaCajitaLoginBarra) 
   {
     if (document.formaCajitaLoginBarra.login.value == "")
     {
        document.getElementById("vLoginFormaBarra").innerHTML = "<p>Por favor, ingrese su nombre de usuario</p>";
        document.getElementById("vLoginFormaBarra").className="verificacionVisible";
        a = false;
     }
     if (password.value == "") 
     {
        document.getElementById("vClaveFormaBarra").innerHTML = "<p>Por favor, ingrese su clave</p>";
        document.getElementById("vClaveFormaBarra").className="verificacionVisible";
        a = false;
     }
     if (a)
     {
        var persi="";
        if (cookieCajiPersisBarra.checked)
        { 
           persi = cookieCajiPersisBarra.checked; 
        }
        incluirObjeto("AUTENTICAR_USUARIO",loginBarra.value, passwordBarra.value, persi,'malAutenticadoBarra');
     }
     else
	 {
		divErrores.innerHTML = "";
		divErrores.style.background = "none";
	 }
   }
}

//para MT
function validarFormaLoginBarra2() 
{
   var divErrores = document.getElementById("malAutenticadoBarra");
   
   divErrores.innerHTML = "<p>Estamos validando su información...</p>";
   divErrores.className="verificacionVisible";
   document.getElementById("vLoginFormaBarra").innerHTML = document.getElementById("vClaveFormaBarra").innerHTML = "";
   a = true;
   with(document.formaCajitaLoginBarra) 
   {
     if (document.formaCajitaLoginBarra.login.value == "")
     {
        document.getElementById("vLoginFormaBarra").innerHTML = "<p>Por favor, ingrese su nombre de usuario</p>";
        document.getElementById("vLoginFormaBarra").className="verificacionVisible";
        a = false;
     }
     if (password.value == "") 
     {
        document.getElementById("vClaveFormaBarra").innerHTML = "<p>Por favor, ingrese su clave</p>";
        document.getElementById("vClaveFormaBarra").className="verificacionVisible";
        a = false;
     }
     if (a)
     {
        var persi="";
        if (cookieCajiPersisBarra.checked)
        { 
           persi = cookieCajiPersisBarra.checked; 
        }
        incluirObjeto("AUTENTICAR_USUARIO_2",loginBarra.value, passwordBarra.value, persi,'malAutenticadoBarra');
     }
     else
	 {
		divErrores.innerHTML = "";
		divErrores.style.background = "none";
	 }
   }
}



function validarFormaLoginBotones_Mercados() 
{
   var divErrores = document.getElementById("malAutenticadoBoton");
   
   divErrores.innerHTML = "<p>Estamos validando su información...</p>";
   divErrores.className="verificacionVisible";
   document.getElementById("vLoginFormaBoton").innerHTML = document.getElementById("vClaveFormaBoton").innerHTML = "";
   a = true;
   with(document.formaCajitaLoginBoton) 
   {
     if (document.formaCajitaLoginBoton.login.value == "")
     {
        document.getElementById("vLoginFormaBoton").innerHTML = "<p>Por favor, ingrese su nombre de usuario</p>";
        document.getElementById("vLoginFormaBoton").className="verificacionVisible";
        a = false;
     }
     if (password.value == "") 
     {
        document.getElementById("vClaveFormaBoton").innerHTML = "<p>Por favor, ingrese su clave</p>";
        document.getElementById("vClaveFormaBoton").className="verificacionVisible";
        a = false;
     }
     if (a)
     {
        var persi="";
        if (cookieCajiPersisBoton.checked)
        { 
           persi = cookieCajiPersisBoton.checked; 
        }
        incluirObjeto("AUTENTICAR_USUARIO",loginBoton.value, passwordBoton.value , persi,'malAutenticadoBoton');
     }
     else
	 {
		divErrores.innerHTML = "";
		divErrores.style.background = "none";
	 }
   }
}

function validarFormaLoginCalculadoras() 
{

   // alert('calculadoras');
   var divErrores = document.getElementById("malAutenticadoCalc");
   
   divErrores.innerHTML = "<p>Estamos validando su información...</p>";
   
   document.getElementById("vLoginFormaCalc").innerHTML = document.getElementById("vClaveFormaCalc").innerHTML = "";
   a = true;
   
   with(document.formaCajitaLoginFlotanteCalc) 
   {
     if (document.getElementById('loginCalc').value == "")
     {
        document.getElementById("vLoginFormaCalc").innerHTML = "<p>Por favor, ingrese su nombre de usuario</p>";
        a = false;
     }
     if (document.getElementById('passwordCalc').value == "") 
     {
        document.getElementById("vClaveFormaCalc").innerHTML = "<p>Por favor, ingrese su clave</p>";
        a = false;
     }
     if (a)
     {
        var persi="";
        if (cookieCajiPersisCalc.checked)
        { 
           persi = cookieCajiPersis.checked; 
        }
        incluirObjeto("AUTENTICAR_USUARIO",loginCalc.value,passwordCalc.value , persi,'malAutenticadoCalc');
     }
     else
	 {
		divErrores.innerHTML = "";
		divErrores.style.background = "none";
	 }
   }
   
}

function getCookie(name){
var dc = document.cookie;
var prefix=name+"=";
var begin=dc.indexOf("; "+prefix);
if(begin==-1){
begin=dc.indexOf(prefix);
if(begin!=0)return null;
}else{begin+=2;}
var end=document.cookie.indexOf(";",begin);if(end==-1){end=dc.length;}
return unescape(dc.substring(begin+prefix.length,end)).split("\n");} 
function setCookie (name, value, expires, path) {
   var curCookie = name + "=" + escape(value) + ((expires) ? "; expires=" + expires.toGMTString() : "") + ((path) ? "; path=" + path : "");
   document.cookie = curCookie;
}
function salirRegistro() {
   var expires = 0;
   var path = '/';
  var domain;
  var curCookie = 'portafolio' + "=" + escape('') + ((expires) ? "; expires=" + expires.toGMTString() : "") + ((path) ? "; path=" + path : "")+((domain) ? "; domain=" + domain: "");

   document.cookie = curCookie;
  incluirObjeto("LOGOFF_ZENCART",salirZenCart);
   
}

function salirRegistro2() {
   var expires = 0;
   var path = '/';
  var domain;
  var curCookie = 'portafolio' + "=" + escape('') + ((expires) ? "; expires=" + expires.toGMTString() : "") + ((path) ? "; path=" + path : "")+((domain) ? "; domain=" + domain: "");

   document.cookie = curCookie;
  incluirObjeto("LOGOFF_ZENCART_2",salirZenCart);
   
}

function salirZenCart(respuesta){
   if(respuesta == "OK"){
	   if (document.location.href.indexOf("zonadeusuario") >= 0)
	       document.location = "/";
	   else if(document.location.href.indexOf("registro") >= 0)
	       document.location = "/";
	   else if (document.location.href.indexOf('#') >= 0) 
	       document.location = document.location.href.substring(0,document.location.href.indexOf('#'));
	   else
	       document.location = document.location;      
   }
   else{
      alert('Problemas saliendo de ZenCart');
   }
}
function open_win(pag,nombre,propiedades){
   window.open(pag,nombre,propiedades);
}

function agregarAMiPortafolio(id_recurso)
{	  
	     abrirLightbox('lightboxAgregarAMiPortafolio',0,'contentcamposAgregar');
		 document.getElementById("contentcamposAgregar").innerHTML = "<p><center>Estamos agregando a tus favoritos.</center></p>";
  		 incluirObjeto("AGREGAR_RECURSO_FAVORITO",idUsuario,id_recurso,'contentcamposAgregar');
} 

function incluirEnviarAmigo(res){
      var divtmplb = document.createElement("div");
   divtmplb.innerHTML = res;
   document.getElementById("banderaslightbox").appendChild(divtmplb);
   
   //Llenar los campos propios del usuario
   var frmTmpEA = document.getElementById("formea");
   if(loginUsuario != "")
   {
       frmTmpEA.nombreor.setAttribute("value",nombreUsuario + " " + apellidosUsuario);
	   if(emailUsuario != '') {
		  frmTmpEA.mailor.setAttribute("value",emailUsuario);
	   }        
   }
   //Usuario no registrado
  else
  {
     frmTmpEA.nombreor.setAttribute("value","");
  	 frmTmpEA.mailor.setAttribute("value","");		
   }
   divs_duplicado["lightboxAmigo"] = document.getElementById("contentcamposAmigo").cloneNode(true);
}

function incluirEnviarError(res){
      var divtmplb = document.createElement("div");
   divtmplb.innerHTML = res;
   document.getElementById("banderaslightbox").appendChild(divtmplb);
   
   //Llenar los campos propios del usuario
   var frmTmpEA = document.getElementById("formlb");
   if(loginUsuario != "")
   {
       frmTmpEA.nombreUsu.setAttribute("value",nombreUsuario + " " + apellidosUsuario);
	   if(emailUsuario != '') 
	   {
		   frmTmpEA.correoUsu.setAttribute("value",emailUsuario);
	   }        
   }
   //Usuario no registrado
   else
   {
       frmTmpEA.nombreUsu.setAttribute("value","");
	   frmTmpEA.correoUsu.setAttribute("value","");		
   }

 	   divs_duplicado["lightboxError"] = document.getElementById("contentcamposError").cloneNode(true);
}

function incluirReportarAbuso(res){
      var divtmplb = document.createElement("div");
   divtmplb.innerHTML = res;
   document.getElementById("banderaslightbox").appendChild(divtmplb);
   
   divs_duplicado["lightboxAbuso"] = document.getElementById("contentcamposAbuso").cloneNode(true);
}


function cambiarEstilo(iddiv, nuevaclase){
   var divcito = document.getElementById(iddiv);
   divcito.className = nuevaclase;
} 


function mostrarGaleriaFotos(modulo){ 
   var divmultilightbox = document.getElementById("lightboxGaleriaRel");
   divmultilightbox.innerHTML = modulo;
   document.getElementById('vermask').className='layerlightver';
   staticbar(13);
}



var whitespace = " \t\n\r";
// s es vacio o solo caracteres de espacio
function isWhitespace (s){
    var i;
    if (isEmpty(s)) return true;
    for (i = 0; i < s.length; i++)
    {   
      var c = s.charAt(i);
      // si el caracter en que estoy no aparece en whitespace,
      // entonces retornar falso
      if (whitespace.indexOf(c) == -1) return false;
    }
    return true;
}

 
function toggle(id,id_padre) {
    if (document.getElementById(id).style.display == 'block') {
      document.getElementById(id).style.display = 'none';
    } else {
      document.getElementById(id).style.display = 'block';
      if(idUsuario != ""){
        document.formComm.id_padre.value = id_padre;
      }
    }
}

var captcha_cargado = 0;
function cargar_captcha(){
   if ( captcha_cargado == 0){
      incluirObjeto('CAPTCHA','captcha');
      captcha_cargado = 1;
   }
}


//Función para dataIFX
function myprintln(s) { document.writeln(s); }

function get_random(maxNum) {
 if (Math.random && Math.round)
 {
  var ranNum= Math.round(Math.random()*(maxNum-1));
  ranNum+=1;
  return ranNum;
 }
 else
 {
  today= new Date();
  hours= today.getHours();
  mins=   today.getMinutes();
  secn=  today.getSeconds();
  if (hours==19)
   hours=18;
  var ranNum= (((hours+1)*(mins+1)*secn)%maxNum)+1;
  return ranNum;
  }
}


//Meses del a?o
var meses = new Array("enero","febrero","marzo","abril","mayo","junio","julio","agosto","septiembre","octubre","noviembre","diciembre");
//Dias de la semana
var diasSemana = new Array("Domingo","Lunes","Martes","Mi&eacute;rcoles","Jueves","Viernes","S&aacute;bado");

//Pone al interior del div correspondiente la fecha actual
function imprimirDia(idDiv)
{
  dia = new Date();
  day = dia.getDate();
  weekDay = diasSemana[dia.getDay()];
  month = meses[dia.getMonth()];
  year = dia.getFullYear();
  
  document.getElementById(idDiv).innerHTML=weekDay+" "+day+" de "+month+" de "+year;
}


function getURLParam(strParamName){
    var strReturn = null;
    var strHref = window.location.href;
    if ( strHref.indexOf("?") > -1 ){
        var strQueryString = strHref.substr(strHref.indexOf("?")).toLowerCase();
        var aQueryString = strQueryString.split("&");
        for ( var iParam = 0; iParam < aQueryString.length; iParam++ ){
            if (
                    aQueryString[iParam].indexOf(strParamName.toLowerCase() + "=") > -1 ){
                var aParam = aQueryString[iParam].split("=");
                strReturn = aParam[1];
                break;
            }
        }
    }
    return unescape(strReturn);
}


function verificar(e) {
   if (document.buscador.q.value == "" || document.buscador.q.value == " " || document.buscador.q.value == "Busque noticias en nuestro archivo desde 1997"){ 
      alert("Por favor ingrese una palabra");
      document.buscador.q.focus(); 
      return false;
   }
   if(getCheckedValue(document.buscador.tipodebusqueda) ==""){
      document.buscador.action = "/archivo/buscar"
      //para que funcione en caliente el archivo electronico
      document.buscador.method = "GET"
   }
   return true; 
}



function doSomething(e)
{
	if (!e) var e = window.event;
	e.cancelBubble = true;
	if (e.stopPropagation) e.stopPropagation();
}


function gup( name )
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "";
  else
    return results[1];
}
function getCheckedValue(radioObj) {
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}


function generarVideoJS(video, divHTML, tipoReproduccion, ancho, alto, urlImagen) {
   // alert(tipoReproduccion);
    if(id_video_pauta && id_video_pauta != ""){
              
       
       //En la posicion [1] queda el id del video del contenido
       var split_video_contenido = video.split("-");
       
       // se reemplaza el '&' por '----' para compatibilidad con el flash. en XML_VIDEO_PAUTA se hace la conversion nuevamente
       var id_video_contenido = split_video_contenido[split_video_contenido.length-2];
       var myfile = "/video_pauta.php?video="+id_video_contenido+"----"+id_video_pauta;
    
    }
    else{
       var myfile = video;
    }
    
    
	if (ancho == '') {
	    ancho = 320;
	}
	if (alto == ''){
	    alto = 288
	}

    var s3 = new SWFObject("/reproductores/mediaplayer.swf","playlist",ancho,alto,"7");
	s3.addParam("allowfullscreen","true");
	s3.addParam("wmode","transparent");
	if (tipoReproduccion == 'audio' && urlImagen == null) {
        s3.addVariable("image","/images/imgaudiogenerico.jpg");
	}
	else if(tipoReproduccion=='video' && urlImagen != null){
	    s3.addVariable("image",urlImagen);
	}
	s3.addVariable("kenburns","true");
	s3.addVariable("file",myfile);
	s3.addVariable("width",ancho);
	s3.addVariable("height",alto);
	s3.addVariable("displaywidth" , ancho);
	s3.addVariable("displayheight" , alto);
	s3.addVariable("showicons","true");
	s3.addVariable("showstop","true");
	s3.addVariable('overstretch','fit');
	s3.addVariable("showicons","true");
	s3.addVariable("usefullscreen","true");
	s3.addVariable("searchbar" , "false");
	//s3.addVariable("logo","/images/logotipo_eltiempo.gif");
	s3.write(divHTML);
	
	if(id_video_pauta != ""){	
	   	   var img_pauta = document.createElement("img");
	   img_pauta.src =  url_registro_video;
	   $("#"+divHTML).after(img_pauta);	  
	}
	
}

var fileRec;
var idDivRec;
var tipoRec;

function cargarVariablesVideoJS (file_rec , reproductorVideoRel, video) {
    fileRec = file_rec;
    idDivRec = reproductorVideoRel;
    tipoRec = video;
}
var matriz = new Array (); 
matriz[0] = new Array ('balgrl', 'Balance General', 'Balance Sheet'); 
matriz[1] = new Array ('tact', 'Total activo', 'Total Assets');
matriz[2] = new Array ('tpas', 'Total Pasivo', 'Total Liabilities');
matriz[3] = new Array ('tpat', 'Total Patrimonio', 'Total Shareholder&rsquo;s Equity');

matriz[4] = new Array ('eres', 'Estado de Resultados', 'Income Statement');
matriz[5] = new Array ('ing', 'Ingresos', 'Net income');
matriz[6] = new Array ('utbr', 'Utilidad bruta', 'Gross profit');
matriz[7] = new Array ('utnet', 'Utilidad neta', 'Net income');

matriz[8] = new Array ('razfin', 'Razones Financieras', 'Financial ratios');
matriz[9] = new Array ('razcorr', 'Razón corriente', 'Current ratio');
matriz[10] = new Array ('razend', 'Razón de endeudamiento', 'Debt&ndash;Equity ratio');
matriz[11] = new Array ('marnet', 'Margen neto', 'Net margin');
matriz[12] = new Array ('miles1', '(en miles de pesos)', '(thousand COP$)');
matriz[13] = new Array ('miles2', '(en miles de pesos)', '(thousand COP$)');

function english_version()
{
	for(var i=0;i<matriz.length;i++){
		document.getElementById(matriz[i][0]).innerHTML = matriz[i][2];
		document.getElementById("boton").innerHTML = '<a  onclick="spanish_version(); return false;" class="vinculoEspecial">Versión en Español</a>' ;
	} 
} 

function spanish_version()
{
	for(var j=0;j<matriz.length;j++){
		document.getElementById(matriz[j][0]).innerHTML = matriz[j][1];
		document.getElementById("boton").innerHTML = '<a  onclick="english_version(); return false;" class="vinculoEspecial">English version</a>' ;
	} 
}


function facebook_click(){
	u=location.href;
	t=document.title;
	window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');
	return false;
}

function cargarVideo(archivoVideo, idDivInfo, idDivVideo, idDivDesc, urlImagen, id_video) {    
	document.getElementById("informacionVideo").innerHTML = document.getElementById(idDivInfo).innerHTML 
	document.getElementById("descripcionVideo").innerHTML = document.getElementById(idDivDesc).innerHTML 
		if (archivoVideo == '') {
	   crearVideoCity(320, 288, id_video, 0, 1, 'reproducirVideo');
       //document.getElementById("reproducirVideo").innerHTML = document.getElementById(idDivVideo).innerHTML
    }
		
	else {
		generarVideoJS(archivoVideo, 'reproducirVideo', 'video',320,288, urlImagen);			
	} 
}

function cargarAudio(archivoAudio, idDivInfo) {
	document.getElementById("informacionAudio").innerHTML = document.getElementById(idDivInfo).innerHTML 
	generarVideoJS(archivoAudio, 'reproducirAudio', 'audio', 320, 288); 
}
function cargarInfoGrafia(idDondeEstoy, idCambiar) {
	document.getElementById(idDondeEstoy).style.display = "none";
	document.getElementById(idCambiar).style.display = "block";
}
var primerFileRec = '$file_rec';
var primerdivVideoInfo = '$divVideoInfo';
var primerdivVideoPlay = '$divVideoPlay';	
function cargarPrimerVideo(respuesta){
   document.getElementById("playermercados").innerHTML = respuesta;
   cargarVideo(primerFileRec, primerdivVideoInfo, primerdivVideoPlay);
}

function mostrarOcultarDivs(id)
{
if(document.getElementById(id).style.display=="none"){
	$(document.getElementById(id)).show('slow');
	if(id=="reglasJuegos"){
		document.getElementById('reglasJuegoBtn').innerHTML="Cerrar";
	}
	if(id=="componentesJuegos"){
		document.getElementById('componentesJuegoBtn').innerHTML="Cerrar";
	}
}else if(document.getElementById(id).style.display=="block"){
	$(document.getElementById(id)).hide('slow');
	if(id=="reglasJuegos"){
		document.getElementById('reglasJuegoBtn').innerHTML="Vea más reglas del juego";
	}
	if(id=="componentesJuegos"){
		document.getElementById('componentesJuegoBtn').innerHTML="Vea más componentes del juego";
	}
}
}


function AbrirCerrarLoNuevo()
{
    if ($("#desplegar").hasClass("botonCerrar"))
     { 
	   $("#loNuevo").slideDown("slow");
	   $("#desplegar").removeClass("botonCerrar");
	   $("#desplegar").addClass("botonAbrir");
	   
	 }
	 else{	     
	    $("#loNuevo").slideUp("slow");
		$("#desplegar").removeClass("botonAbrir");
		$("#desplegar").addClass("botonCerrar");
	    
	 }

}


function loNuevo(id_recurso, file_rec)
{
  abrirLightbox('lightboxLoNuevo','contentcamposLoNuevo');
  //incluirObjeto("CARGAR_VIDEO_LO_NUEVO",id_recurso,'contentcamposLoNuevo');
  
  generarVideoJS(file_rec, "contentcamposLoNuevo", "VIDEO",481,394);
}



var fechaPublicacion;
function hora_actualizada()
{
	var fechaActual;
	date1 = new Date();
	date2 = new Date();
	diff  = new Date();
    
	date1temp = new Date(fechaPublicacion);
	date1.setTime(date1temp.getTime());
    
	var fecha = new Date();

	fechaActual = (eval(fecha.getMonth()) + 1 ) + '/' + fecha.getDate() + '/' + fecha.getFullYear() + ' ' + fecha.getHours() + ':' + fecha.getMinutes() + ':' + fecha.getSeconds();
    	    
	date2temp = new Date(fechaActual);
	date2.setTime(date2temp.getTime());
	diff.setTime(Math.abs(date1.getTime() - date2.getTime()));
	timediff = diff.getTime();
    
	weeks = Math.floor(timediff / (1000 * 60 * 60 * 24 * 7));
	timediff -= weeks * (1000 * 60 * 60 * 24 * 7);
	weeks = Math.floor(weeks * 24 * 7);
    
	days = Math.floor(timediff / (1000 * 60 * 60 * 24));
	timediff -= days * (1000 * 60 * 60 * 24);
	days = Math.floor(days * 24);
    
	hours = Math.floor(timediff / (1000 * 60 * 60)); 
	timediff -= hours * (1000 * 60 * 60);
    
    
	mins = Math.floor(timediff / (1000 * 60)); 
	timediff -= mins * (1000 * 60);
    
	secs = Math.floor(timediff / 1000); 
	timediff -= secs * 1000;

	hours = weeks + days + hours;
	textoMinutos = ' minutos';
	if (eval(mins) == 1) {
		textoMinutos = ' minuto';
	}

	if (eval(hours)<= 0) {
		horasDiferencia =  mins +  textoMinutos; 
	}else {
		textohora = ' horas ';
		if (eval(hours) == 1) {
			textohora = ' hora ';
		}
		horasDiferencia =  hours + textohora  + mins +  textoMinutos; 
	}
	document.getElementById("fecha2").innerHTML="- actualizado hace "+horasDiferencia;
}

function cambiarID(){
	if (document.regbasico.experto.checked){
		$("div#identificado").slideDown("slow");
	}else{
		$("div#identificado").slideUp("slow");
	}
	
}




function abrirBarra(){
	$("div#mibarra").slideDown("slow");
	incluirObjeto("BARRA_MI_PORTAFOLIO", "mibarra");
	document.getElementById("abrecierra").innerHTML = '<a href="javascript:cerrarBarra();">Cerrar</a>';
	//document.getElementById("abrecierra").className = "cajaVinculoEspecialCerrar";
	document.getElementById("mibarra").style.display = "block";
	
}

function cerrarBarra(){
	$("div#mibarra").slideUp("slow");
	document.getElementById("abrecierra").innerHTML = '<a href="javascript:abrirBarra();">Ver mis acciones</a>';
	//document.getElementById("abrecierra").className = "cajaVinculoEspecialAbrir";
	//document.getElementById("mibarra").style.display = "none";
}

jQuery.fn.accessNews=function(settings){
	settings=jQuery.extend({newsHeadline:"Top Stories",newsSpeed:"normal"},settings);
	return this.each(
		function(i){
			aNewsSlider.itemWidth=parseInt(jQuery(".item:eq("+i+")",".slider").css("width"))+parseInt(jQuery(".item:eq("+i+")",".slider").css("margin-right"));
			aNewsSlider.init(settings,this);
			jQuery(".verTodos > a",this).click(
				function(){
					aNewsSlider.vAll(settings,this);
					return false
				}
			)
		}
	)
};
var timer;
var timer2;
var aNewsSlider={
	itemWidth:0,
	init:function(s,p){
		jQuery(".mensaje",p).css("display","none");
		itemLength=jQuery(".item",p).length;
		if(jQuery(".verTodos",p).width()==null){
			jQuery(".news_items",p).prepend("<p class='verTodos'>"+s.newsHeadline+" [ "+itemLength+" en total ] &nbsp;-&nbsp; <a href='#'>Ver Todos</a></p>")
		}
		newsContainerWidth=itemLength*aNewsSlider.itemWidth;
		jQuery(".container",p).css("width",newsContainerWidth+"px");
		jQuery(".next",p).css("display","block");
		animating=false;
		jQuery(".next",p).click(
			function(){
				if(animating==false){
					animating=true;
					animateLeft=parseInt(jQuery(".container",p).css("left"))-(aNewsSlider.itemWidth);
					if(animateLeft+parseInt(jQuery(".container",p).css("width"))>0){
				
						jQuery(".prev",p).css("display","block");
						jQuery(".container",p).animate({left:animateLeft},s.newsSpeed,function(){
							jQuery(this).css("left",animateLeft);
							if(parseInt(jQuery(".container",p).css("left"))+parseInt(jQuery(".container",p).css("width"))<=aNewsSlider.itemWidth){
								jQuery(".next",p).css("display","none")
							}
							animating=false
						}
						
						)
						clearTimeout(timer2);
						timer=setTimeout('jQuery(".next",this).click()',5000);
					}else{
						animating=false
						clearTimeout(timer);
						jQuery(".prev",p).click();
						
					}
				}
						
				return false
			}
		);
		jQuery(".prev",p).click(
			function(){
				if(animating==false){
			
					animating=true;
					animateLeft=parseInt(jQuery(".container",p).css("left"))+(aNewsSlider.itemWidth);
					if((animateLeft+parseInt(jQuery(".container",p).css("width")))<=parseInt(jQuery(".container",p).css("width"))){
						jQuery(".next",p).css("display","block");
						jQuery(".container",p).animate({left:animateLeft},s.newsSpeed,function(){
							jQuery(this).css("left",animateLeft);
							if(parseInt(jQuery(".container",p).css("left"))==0){
								jQuery(".prev",p).css("display","none")
							}
							animating=false
						}
						
						)
						clearTimeout(timer);
						timer2=setTimeout('jQuery(".prev",this).click()',5000)
					}else{
						animating=false
						clearTimeout(timer2);
						jQuery(".next",p).click();
					}
				}
				
				return false
			}
		)
		jQuery(".next",this).click();
	
	
	},
	vAll:function(s,p){
		
		var o=p;
		while(p){
			p=p.parentNode;
			if(jQuery(p).attr("class")!=undefined&&jQuery(p).attr("class").indexOf("slider")!=-1){
				break
			}
		}
		if(jQuery(o).text().indexOf("Ver Todos")!=-1){
			jQuery(".next",p).css("display","none");
			jQuery(".prev",p).css("display","none");
			jQuery(o).text("Ver Menos");
			jQuery(".container",p).css("left","0px").css("width",aNewsSlider.itemWidth+"px")
		}else{
			jQuery(o).text("Ver Todos");
			aNewsSlider.init(s,p)
		}
	}
};

//funciones para el ticker vertical de barra mi portafolio
	  var headline_count;
      var headline_interval;
      var old_headline = 0;
      var current_headline = 0;
       
      //$(document).ready(function(){
      var scrollBarraAcciones = function(){
      //window.onload = function(){
         headline_count = $("div.headline").size();
         $("div.headline:eq("+current_headline+")").css('top', '5px');
       
         headline_interval = setInterval(headline_rotate,5000);
         $('#scrollup').hover(function() {
          	clearInterval(headline_interval);
         }, function() {
          headline_interval = setInterval(headline_rotate,5000);
          headline_rotate();
         });
         };
       //);
      
      function headline_rotate() {
        current_headline = (old_headline + 1) % headline_count;
        $("div.headline:eq(" + old_headline + ")")
          .animate({top: -33},"slow", function() {
            $(this).css('top', '38px');
          });
        $("div.headline:eq(" + current_headline + ")")
          .animate({top: 5},"slow"); 
        old_headline = current_headline;
        }
        
function cargarScroll(rec){
document.getElementById("mibarra").innerHTML = rec;
//$('#mibarra').html(rec);
scrollBarraAcciones();
}


//funciones para el ticker horizontal de barra mi portafolio
jQuery.fn.liScroll = function(settings) {
		settings = jQuery.extend({
		travelocity: 0.07
		}, settings);		
		return this.each(function(){
				var $strip = jQuery(this);
				$strip.addClass("newsticker")
				var stripWidth = 0;
				var $mask = $strip.wrap("<div class='mask'></div>");
				var $tickercontainer = $strip.parent().wrap("<div class='tickercontainer'></div>");								
				var containerWidth = $strip.parent().parent().width();	//a.k.a. 'mask' width 	
				$strip.find("li").each(function(i){
				stripWidth += jQuery(this, i).width();
				});
				$strip.width(stripWidth);			
				var defTiming = stripWidth/settings.travelocity;
				var totalTravel = stripWidth+containerWidth;								
				function scrollnews(spazio, tempo){
				$strip.animate({left: '-='+ spazio}, tempo, "linear", function(){$strip.css("left", containerWidth); scrollnews(totalTravel, defTiming);});
				}
				scrollnews(totalTravel, defTiming);				
				$strip.hover(function(){
				jQuery(this).stop();
				},
				function(){
				var offset = jQuery(this).offset();
				var residualSpace = offset.left + stripWidth;
				var residualTime = residualSpace/settings.travelocity;
				scrollnews(residualSpace, residualTime);
				});			
		});	
};
//Funcion nueva para medir lightbox, ajax, etc
function generarPageView(nombre_pagina,seccion,sub_seccion)
{
   /*s_channel = seccion?seccion:s_channel;
   s_prop1 = seccion?seccion:s_prop1;
   s_prop2 = sub_seccion?sub_seccion:s_prop2;
   s_pageName = nombre_pagina?nombre_pagina:s_pageName;
   //Registrar el page view para Certifica
   if (cert_registerHit){
       ruta = certifica_crear_ruta([s_channel, s_prop1, s_prop2,  s_pageName]);
       cert_registerHit(20837, ruta, 'cert_Pivot'); 
   }
   void(s_gs(s_account))*/
}

function abrirVentana(url,ancho,alto){
vf=window.open(url,'FotoGrande','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,menubar=no,width='+ancho+',height='+alto)
}
//funciones para modificar la pagina de inicio
function isExplorer()
{
   if ((navigator.appName=="Microsoft Internet Explorer") && (parseInt(navigator.appVersion)>=4)) 
   {
       return true;
   }
   else if(navigator.appName == "Netscape") 
   {
      return false;   
   }
   else 
   {
      return false;
   }   
}

function modificarPaginaInicio(obj, destino)
{
   if (isExplorer())  
   {
      obj.style.behavior='url(#default#homepage)'; 
      obj.setHomePage(destino);
   }
   else 
   {  
      var respuesta = "Desde Firefox o Safari, agregue portafolio.com.co a sus favoritos presionando Ctrl+D"; 
      document.getElementById("contenidoPaginaRespuesta").innerHTML=respuesta;
      abrirLightbox("lightboxPaginaRespuesta",0);
      return false;
   }
}



/**
 * jCarouselLite - jQuery plugin to navigate images/any content in a carousel style widget.
 * @requires jQuery v1.2 or above
 *
 * http://gmarwaha.com/jquery/jcarousellite/
 *
 * Copyright (c) 2007 Ganeshji Marwaha (gmarwaha.com)
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 *
 * Version: 1.0.1
 * Note: Requires jquery 1.2 or above from version 1.0.1
 */
(function($) {                                          // Compliant with jquery.noConflict()
$.fn.jCarouselLite = function(o) {
    o = $.extend({
        btnPrev: null,
        btnNext: null,
        btnGo: null,
        mouseWheel: false,
        auto: null,

        speed: 200,
        easing: null,

        vertical: false,
        circular: true,
        visible: 3,
        start: 0,
        scroll: 1,

        beforeStart: null,
        afterEnd: null
    }, o || {});

    return this.each(function() {                           // Returns the element collection. Chainable.

        var running = false, animCss=o.vertical?"top":"left", sizeCss=o.vertical?"height":"width";
        var div = $(this), ul = $("ul", div), tLi = $("li", ul), tl = tLi.size(), v = o.visible;

        if(o.circular) {
            ul.prepend(tLi.slice(tl-v-1+1).clone())
              .append(tLi.slice(0,v).clone());
            o.start += v;
        }

        var li = $("li", ul), itemLength = li.size(), curr = o.start;
        div.css("visibility", "visible");

        li.css({overflow: "hidden", float: o.vertical ? "none" : "left"});
        ul.css({margin: "0", padding: "0", position: "relative", "list-style-type": "none", "z-index": "1"});
        div.css({overflow: "hidden", position: "relative", "z-index": "2", left: "0px"});

        var liSize = o.vertical ? height(li) : width(li);   // Full li size(incl margin)-Used for animation
        var ulSize = liSize * itemLength;                   // size of full ul(total length, not just for the visible items)
        var divSize = liSize * v;                           // size of entire div(total length for just the visible items)

        li.css({width: li.width(), height: li.height()});
        ul.css(sizeCss, ulSize+"px").css(animCss, -(curr*liSize));

        div.css(sizeCss, divSize+"px");                     // Width of the DIV. length of visible images

        if(o.btnPrev)
            $(o.btnPrev).click(function() {
                return go(curr-o.scroll);
            });

        if(o.btnNext)
            $(o.btnNext).click(function() {
                return go(curr+o.scroll);
            });

        if(o.btnGo)
            $.each(o.btnGo, function(i, val) {
                $(val).click(function() {
                    return go(o.circular ? o.visible+i : i);
                });
            });

        if(o.mouseWheel && div.mousewheel)
            div.mousewheel(function(e, d) {
                return d>0 ? go(curr-o.scroll) : go(curr+o.scroll);
            });

        if(o.auto)
            setInterval(function() {
                go(curr+o.scroll);
                 cambiar(0);
            }, o.auto+o.speed);

        function vis() {
             return li.slice(curr).slice(0,v);
        };

        function go(to) {
            if(!running) {

                if(o.beforeStart)
                    o.beforeStart.call(this, vis());

                if(o.circular) {            // If circular we are in first or last, then goto the other end
                    if(to<=o.start-v-1) {           // If first, then goto last
                        ul.css(animCss, -((itemLength-(v*2))*liSize)+"px");
                        // If "scroll" > 1, then the "to" might not be equal to the condition; it can be lesser depending on the number of elements.
                        curr = to==o.start-v-1 ? itemLength-(v*2)-1 : itemLength-(v*2)-o.scroll;
                    } else if(to>=itemLength-v+1) { // If last, then goto first
                        ul.css(animCss, -( (v) * liSize ) + "px" );
                        // If "scroll" > 1, then the "to" might not be equal to the condition; it can be greater depending on the number of elements.
                        curr = to==itemLength-v+1 ? v+1 : v+o.scroll;
                    } else curr = to;
                } else {                    // If non-circular and to points to first or last, we just return.
                    if(to<0 || to>itemLength-v) return;
                    else curr = to;
                }                           // If neither overrides it, the curr will still be "to" and we can proceed.

                running = true;

                ul.animate(
                    animCss == "left" ? { left: -(curr*liSize) } : { top: -(curr*liSize) } , o.speed, o.easing,
                    function() {
                        if(o.afterEnd)
                            o.afterEnd.call(this, vis());
                        running = false;
                    }
                );
                // Disable buttons when the carousel reaches the last/first, and enable when not
                if(!o.circular) {
                    $(o.btnPrev + "," + o.btnNext).removeClass("disabled");
                    $( (curr-o.scroll<0 && o.btnPrev)
                        ||
                       (curr+o.scroll > itemLength-v && o.btnNext)
                        ||
                       []
                     ).addClass("disabled");
                }

            }
            return false;
        };
    });
};

function css(el, prop) {
    return parseInt($.css(el[0], prop)) || 0;
};
function width(el) {
    return  el[0].offsetWidth + css(el, 'marginLeft') + css(el, 'marginRight');
};
function height(el) {
    return el[0].offsetHeight + css(el, 'marginTop') + css(el, 'marginBottom');
};

})(jQuery);

//Jumba

//function jumba(id_jumba,ancho_jumba,alto_jumba){
function jumba(alias,espacio){

	jQuery.get('http://www.portafolio.com.co/pauta/jumba_leer.php', function(data){
		if (data=="true"){
			jQuery.get('http://www.portafolio.com.co/pauta/cargar_pauta.php?archivo=portafolio.csv&alias='+alias+'&espacio='+espacio, function(data2){
				data3 = new String(data2);
				trozos=data3.split(",");
				id_jumba = trozos[0];
				ancho_jumba = trozos[1];
				alto_jumba = trozos[2];
				
				//if (id_jumba != ""){
					//if (espacio == "home"){
						document.getElementById("jumba").innerHTML='<div class="nivel publicidad3 publicidad31"><div class="contenido-publicidad3"><p class="texto-publicidad3">Publicidad</p><iframe frameborder="0" marginwidth=0 marginheight=0 scrolling="no" width="'+ancho_jumba+'" height="'+alto_jumba+'" src="http://ad.jumbaexchange.com/st?ad_type=iframe&ad_size='+ancho_jumba+'x'+alto_jumba+'&section='+id_jumba+'"></iframe></div></div>';
					//}else{
					//	document.getElementById("jumba").innerHTML='<div class="publicidad1"><p class="texto-publicidad1">Publicidad</p><iframe frameborder="0" marginwidth=0 marginheight=0 scrolling="no" width="'+ancho_jumba+'" height="'+alto_jumba+'" src="http://ad.jumbaexchange.com/st?ad_type=iframe&ad_size='+ancho_jumba+'x'+alto_jumba+'&section='+id_jumba+'"></iframe></div>';
				//	}
				//}
			})
		}
    })
}


function enviarAyuda()
{	  
	//var frmEnviarPTmp = document.getElementById('formAy');
    //frmEnviarPTmp.accionUsu.setAttribute("value", accion);
    abrirLightbox("lightboxAyuda" , 'contentcamposAyuda');
    document.getElementById('vermask').className='layerlightver';

} 

function enviarAyuda2(idform){
    form =  document.getElementById(idform);
    
    var nombreusua = form.nombreUsu.value;
    var cedulausua = form.cedulaUsu.value;
    var telefonousua = form.telefonoUsu.value;
	var correousua = form.correoUsu.value;
	var mensaje = form.mensajeUsu.value;
	//var accion = form.accionUsu.value; 
	

	if(isEmpty(nombreusua))
	{
		alert("Por favor, escriba su nombre");
		return;
	}
	
	if(isEmpty(cedulausua))
	{
		alert("Por favor, escriba su cédula");
		return;
	}
	
	if(isEmpty(telefonousua))
	{
		alert("Por favor, escriba su teléfono");
		return;
	}
	
	if(!isEmail(correousua))
	{
		alert("Su dirección de correo electrónico no es válida");
		return;
	}

	if(isEmpty(mensaje))
	{
		alert("Por favor, escriba su mensaje");
		return;
	}	
	 document.getElementById("contentcamposAyuda").innerHTML = "<br><br><br><h1>D&eacute;nos un segundo. Estamos enviando su informaci&oacute;n a nuestro equipo.</h1><br><br><br>";
     incluirObjeto("ENVIAR_AYUDA",nombreusua, cedulausua, telefonousua, correousua, mensaje,  "contentcamposAyuda");
}


function generarVideoJSEnDiv(video, divHTML, tipoReproduccion, ancho, alto, urlImagen) {
   // alert(tipoReproduccion);
    if(id_video_pauta != ""){
              
       
       //En la posicion [1] queda el id del video del contenido
       var split_video_contenido = video.split("-");
       
       // se reemplaza el '&' por '----' para compatibilidad con el flash. en XML_VIDEO_PAUTA se hace la conversion nuevamente
       var id_video_contenido = split_video_contenido[split_video_contenido.length-2];
       var myfile = "/video_pauta.php?video="+id_video_contenido+"----"+id_video_pauta;
    
    }
    else{
       var myfile = video;
    }
    
    
	if (ancho == '') {
	    ancho = 320;
	}
	if (alto == ''){
	    alto = 288
	}

    var s3 = new SWFObject("/reproductores/mediaplayer.swf","playlist",ancho,alto,"7");
	s3.addParam("allowfullscreen","true");
	s3.addParam("wmode","transparent");
	if (tipoReproduccion == 'audio' && urlImagen == null) {
        s3.addVariable("image","/images/imgaudiogenerico.jpg");
	}
	else if(tipoReproduccion=='video' && urlImagen != null){
	    s3.addVariable("image",urlImagen);
	}
	s3.addVariable("kenburns","true");
	s3.addVariable("file",myfile);
	s3.addVariable("width",ancho);
	s3.addVariable("height",alto);
	s3.addVariable("displaywidth" , ancho);
	s3.addVariable("displayheight" , alto);
	s3.addVariable("showicons","true");
	s3.addVariable("showstop","true");
	s3.addVariable('overstretch','fit');
	s3.addVariable("showicons","true");
	s3.addVariable("usefullscreen","true");
	s3.addVariable("searchbar" , "false");
	//s3.addVariable("logo","/images/logotipo_eltiempo.gif");
	s3.write(divHTML);
	
	if(id_video_pauta != ""){	
	   	   var img_pauta = document.createElement("img");
	   img_pauta.src =  url_registro_video;
	   $("#"+divHTML).after(img_pauta);	  
	}
	
}
 

/* Funciones para validar entradas de texto de usuario
 * More info at: http://phpjs.org
 * 
 * This is version: 2.71
 * php.js is copyright 2009 Kevin van Zonneveld.
 * 
 * Portions copyright Brett Zamir (http://brett-zamir.me), Kevin van Zonneveld
 * (http://kevin.vanzonneveld.net), Onno Marsman, Michael White
 * (http://getsprink.com), Waldo Malqui Silva, Paulo Ricardo F. Santos, Jack,
 * Philip Peterson, Jonas Raoni Soares Silva (http://www.jsfromhell.com),
 * Legaev Andrey, Ates Goral (http://magnetiq.com), Martijn Wieringa, Nate,
 * Enrique Gonzalez, Philippe Baumann, Webtoolkit.info
 * (http://www.webtoolkit.info/), Theriault, Jani Hartikainen, Ash Searle
 * (http://hexmen.com/blog/), Carlos R. L. Rodrigues
 * (http://www.jsfromhell.com), Ole Vrijenhoek, travc, Michael Grier, GeekFG
 * (http://geekfg.blogspot.com), Johnny Mast (http://www.phpvrouwen.nl), Alex,
 * d3x, stag019, Andrea Giammarchi (http://webreflection.blogspot.com),
 * marrtins, Erkekjetter, Steve Hilder, Oleg Eremeev, David, Marc Palau,
 * Steven Levithan (http://blog.stevenlevithan.com), gorthaur, Arpad Ray
 * (mailto:arpad@php.net), Public Domain (http://www.json.org/json2.js),
 * gettimeofday, mdsjack (http://www.mdsjack.bo.it), Thunder.m, Alfonso
 * Jimenez (http://www.alfonsojimenez.com), KELAN, Tyler Akins
 * (http://rumkin.com), Mirek Slugen, Kankrelune
 * (http://www.webfaktory.info/), Karol Kowalski, AJ, Lars Fischer, Caio
 * Ariede (http://caioariede.com), Aman Gupta, Sakimori, Pellentesque
 * Malesuada, Breaking Par Consulting Inc
 * (http://www.breakingpar.com/bkp/home.nsf/0/87256B280015193F87256CFB006C45F7),
 * Josh Fraser
 * (http://onlineaspect.com/2007/06/08/auto-detect-a-time-zone-with-javascript/),
 * Paul, madipta, Douglas Crockford (http://javascript.crockford.com), Ole
 * Vrijenhoek (http://www.nervous.nl/), Hyam Singer
 * (http://www.impact-computing.com/), Raphael (Ao RUDLER), kenneth, T. Wild,
 * nobbler, class_exists, noname, Marco, David James, Steve Clay, marc andreu,
 * ger, john (http://www.jd-tech.net), mktime, Brad Touesnard, J A R, djmix,
 * Lincoln Ramsay, Linuxworld, Thiago Mata (http://thiagomata.blog.com),
 * Pyerre, Jon Hohle, Bayron Guevara, duncan, Sanjoy Roy, sankai, 0m3r, Felix
 * Geisendoerfer (http://www.debuggable.com/felix), Gilbert, Subhasis Deb,
 * Soren Hansen, T0bsn, Eugene Bulkin (http://doubleaw.com/), Der Simon
 * (http://innerdom.sourceforge.net/), JB, LH, Marc Jansen, Francesco, echo is
 * bad, XoraX (http://www.xorax.info), MeEtc (http://yass.meetcweb.com),
 * Peter-Paul Koch (http://www.quirksmode.org/js/beat.html), Nathan, Tim Wiel,
 * Ozh, David Randall, Bryan Elliott, Jalal Berrami, Arno, Rick Waldron,
 * Mick@el, rezna, Kirk Strobeck, Martin Pool, Daniel Esteban, Saulo Vallory,
 * Kristof Coomans (SCK-CEN Belgian Nucleair Research Centre), Pierre-Luc
 * Paour, Eric Nagel, Bobby Drake, penutbutterjelly, Christian Doebler,
 * setcookie, Gabriel Paderni, Simon Willison (http://simonwillison.net), Pul,
 * Luke Godfrey, Blues (http://tech.bluesmoon.info/), Anton Ongson, Jason Wong
 * (http://carrot.org/), Valentina De Rosa, sowberry, hitwork, Norman "zEh"
 * Fuchs, Yves Sucaet, johnrembo, Nick Callen, ejsanders, Aidan Lister
 * (http://aidanlister.com/), Philippe Jausions
 * (http://pear.php.net/user/jausions), dptr1988, Pedro Tainha
 * (http://www.pedrotainha.com), Alan C, uestla, Wagner B. Soares, T.Wild,
 * strcasecmp, strcmp, DxGx, Alexander Ermolaev
 * (http://snippets.dzone.com/user/AlexanderErmolaev), ChaosNo1, metjay, YUI
 * Library: http://developer.yahoo.com/yui/docs/YAHOO.util.DateLocale.html,
 * Blues at http://hacks.bluesmoon.info/strftime/strftime.js, taith, Robin,
 * Matt Bradley, Tim de Koning, Luis Salazar (http://www.freaky-media.com/),
 * FGFEmperor, baris ozdil, Tod Gentille, FremyCompany, Manish, Cord, Slawomir
 * Kaniecki, ReverseSyntax, Mateusz "loonquawl" Zalega, Scott Cariss,
 * Francois, Victor, stensi, vlado houba, date, gabriel paderni, Yannoo,
 * mk.keck, Leslie Hoare, Ben Bryan, Dino, Andrej Pavlovic, Andreas, DtTvB
 * (http://dt.in.th/2008-09-16.string-length-in-bytes.html), Russell Walker,
 * Garagoth, booeyOH, Cagri Ekin, Benjamin Lupton, davook, Atli Ã?Ã³r, jakes,
 * Allan Jensen (http://www.winternet.no), Howard Yeend, Kheang Hok Chin
 * (http://www.distantia.ca/), Luke Smith (http://lucassmith.name), Rival,
 * Diogo Resende
 * 
 * Dual licensed under the MIT (MIT-LICENSE.txt)
 * and GPL (GPL-LICENSE.txt) licenses.
 * 
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the
 * "Software"), to deal in the Software without restriction, including
 * without limitation the rights to use, copy, modify, merge, publish,
 * distribute, sublicense, and/or sell copies of the Software, and to
 * permit persons to whom the Software is furnished to do so, subject to
 * the following conditions:
 * 
 * The above copyright notice and this permission notice shall be included
 * in all copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 * IN NO EVENT SHALL KEVIN VAN ZONNEVELD BE LIABLE FOR ANY CLAIM, DAMAGES
 * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 * OTHER DEALINGS IN THE SOFTWARE.
 */ 


function get_html_translation_table(table, quote_style) {
    // Returns the internal translation table used by htmlspecialchars and htmlentities  
    // 
    // version: 906.401
    // discuss at: http://phpjs.org/functions/get_html_translation_table
    // +   original by: Philip Peterson
    // +    revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   bugfixed by: noname
    // +   bugfixed by: Alex
    // +   bugfixed by: Marco
    // +   bugfixed by: madipta
    // +   improved by: KELAN
    // +   improved by: Brett Zamir (http://brett-zamir.me)
    // +    bugfixed by: Brett Zamir (http://brett-zamir.me)
    // %          note: It has been decided that we're not going to add global
    // %          note: dependencies to php.js. Meaning the constants are not
    // %          note: real constants, but strings instead. integers are also supported if someone
    // %          note: chooses to create the constants themselves.
    // *     example 1: get_html_translation_table('HTML_SPECIALCHARS');
    // *     returns 1: {'"': '&quot;', '&': '&amp;', '<': '&lt;', '>': '&gt;'}
    
    var entities = {}, histogram = {}, decimal = 0, symbol = '';
    var constMappingTable = {}, constMappingQuoteStyle = {};
    var useTable = {}, useQuoteStyle = {};
    
    // Translate arguments
    constMappingTable[0]      = 'HTML_SPECIALCHARS';
    constMappingTable[1]      = 'HTML_ENTITIES';
    constMappingQuoteStyle[0] = 'ENT_NOQUOTES';
    constMappingQuoteStyle[2] = 'ENT_COMPAT';
    constMappingQuoteStyle[3] = 'ENT_QUOTES';

    useTable       = !isNaN(table) ? constMappingTable[table] : table ? table.toUpperCase() : 'HTML_SPECIALCHARS';
    useQuoteStyle = !isNaN(quote_style) ? constMappingQuoteStyle[quote_style] : quote_style ? quote_style.toUpperCase() : 'ENT_COMPAT';

    if (useTable !== 'HTML_SPECIALCHARS' && useTable !== 'HTML_ENTITIES') {
        throw new Error("Table: "+useTable+' not supported');
        // return false;
    }

    if (useTable === 'HTML_ENTITIES') {
        entities['160'] = '&nbsp;';
        entities['161'] = '&iexcl;';
        entities['162'] = '&cent;';
        entities['163'] = '&pound;';
        entities['164'] = '&curren;';
        entities['165'] = '&yen;';
        entities['166'] = '&brvbar;';
        entities['167'] = '&sect;';
        entities['168'] = '&uml;';
        entities['169'] = '&copy;';
        entities['170'] = '&ordf;';
        entities['171'] = '&laquo;';
        entities['172'] = '&not;';
        entities['173'] = '&shy;';
        entities['174'] = '&reg;';
        entities['175'] = '&macr;';
        entities['176'] = '&deg;';
        entities['177'] = '&plusmn;';
        entities['178'] = '&sup2;';
        entities['179'] = '&sup3;';
        entities['180'] = '&acute;';
        entities['181'] = '&micro;';
        entities['182'] = '&para;';
        entities['183'] = '&middot;';
        entities['184'] = '&cedil;';
        entities['185'] = '&sup1;';
        entities['186'] = '&ordm;';
        entities['187'] = '&raquo;';
        entities['188'] = '&frac14;';
        entities['189'] = '&frac12;';
        entities['190'] = '&frac34;';
        entities['191'] = '&iquest;';
        entities['192'] = '&Agrave;';
        entities['193'] = '&Aacute;';
        entities['194'] = '&Acirc;';
        entities['195'] = '&Atilde;';
        entities['196'] = '&Auml;';
        entities['197'] = '&Aring;';
        entities['198'] = '&AElig;';
        entities['199'] = '&Ccedil;';
        entities['200'] = '&Egrave;';
        entities['201'] = '&Eacute;';
        entities['202'] = '&Ecirc;';
        entities['203'] = '&Euml;';
        entities['204'] = '&Igrave;';
        entities['205'] = '&Iacute;';
        entities['206'] = '&Icirc;';
        entities['207'] = '&Iuml;';
        entities['208'] = '&ETH;';
        entities['209'] = '&Ntilde;';
        entities['210'] = '&Ograve;';
        entities['211'] = '&Oacute;';
        entities['212'] = '&Ocirc;';
        entities['213'] = '&Otilde;';
        entities['214'] = '&Ouml;';
        entities['215'] = '&times;';
        entities['216'] = '&Oslash;';
        entities['217'] = '&Ugrave;';
        entities['218'] = '&Uacute;';
        entities['219'] = '&Ucirc;';
        entities['220'] = '&Uuml;';
        entities['221'] = '&Yacute;';
        entities['222'] = '&THORN;';
        entities['223'] = '&szlig;';
        entities['224'] = '&agrave;';
        entities['225'] = '&aacute;';
        entities['226'] = '&acirc;';
        entities['227'] = '&atilde;';
        entities['228'] = '&auml;';
        entities['229'] = '&aring;';
        entities['230'] = '&aelig;';
        entities['231'] = '&ccedil;';
        entities['232'] = '&egrave;';
        entities['233'] = '&eacute;';
        entities['234'] = '&ecirc;';
        entities['235'] = '&euml;';
        entities['236'] = '&igrave;';
        entities['237'] = '&iacute;';
        entities['238'] = '&icirc;';
        entities['239'] = '&iuml;';
        entities['240'] = '&eth;';
        entities['241'] = '&ntilde;';
        entities['242'] = '&ograve;';
        entities['243'] = '&oacute;';
        entities['244'] = '&ocirc;';
        entities['245'] = '&otilde;';
        entities['246'] = '&ouml;';
        entities['247'] = '&divide;';
        entities['248'] = '&oslash;';
        entities['249'] = '&ugrave;';
        entities['250'] = '&uacute;';
        entities['251'] = '&ucirc;';
        entities['252'] = '&uuml;';
        entities['253'] = '&yacute;';
        entities['254'] = '&thorn;';
        entities['255'] = '&yuml;';
    }

    if (useQuoteStyle !== 'ENT_NOQUOTES') {
        entities['34'] = '&quot;';
    }
    if (useQuoteStyle === 'ENT_QUOTES') {
        entities['39'] = '&#39;';
    }
    entities['60'] = '&lt;';
    entities['62'] = '&gt;';

    // ascii decimals for better compatibility
    entities['38'] = '&amp;';

    // ascii decimals to real symbols
    for (decimal in entities) {
        symbol = String.fromCharCode(decimal);
        histogram[symbol] = entities[decimal];
    }
    
    return histogram;
}

function htmlentities (string, quote_style) {
    // Convert all applicable characters to HTML entities  
    // 
    // version: 906.401
    // discuss at: http://phpjs.org/functions/htmlentities
  
    var histogram = {}, symbol = '', tmp_str = '', entity = '';
    tmp_str = string.toString();
    
    if (false === (histogram = this.get_html_translation_table('HTML_ENTITIES', quote_style))) {
        return false;
    }
    histogram["'"] = '&#039;';
    for (symbol in histogram) {
        entity = histogram[symbol];
        tmp_str = tmp_str.split(symbol).join(entity);
    }
    
    return tmp_str;
}

function strip_tags(str, allowed_tags) {
    // Strips HTML and PHP tags from a string  
    // version: 905.3122
    // discuss at: http://phpjs.org/functions/strip_tags
    var key = '', allowed = false;
    var matches = [];
    var allowed_array = [];
    var allowed_tag = '';
    var i = 0;
    var k = '';
    var html = '';

    var replacer = function(search, replace, str) {
        return str.split(search).join(replace);
    };

    // Build allowes tags associative array
    if (allowed_tags) {
        allowed_array = allowed_tags.match(/([a-zA-Z]+)/gi);
    }

    str += '';

    // Match tags
    matches = str.match(/(<\/?[\S][^>]*>)/gi);

    // Go through all HTML tags
    for (key in matches) {
        if (isNaN(key)) {
            // IE7 Hack
            continue;
        }

        // Save HTML tag
        html = matches[key].toString();

        // Is tag not in allowed list? Remove from str!
        allowed = false;

        // Go through all allowed tags
        for (k in allowed_array) {
            // Init
            allowed_tag = allowed_array[k];
            i = -1;

            if (i != 0) { i = html.toLowerCase().indexOf('<'+allowed_tag+'>');}
            if (i != 0) { i = html.toLowerCase().indexOf('<'+allowed_tag+' ');}
            if (i != 0) { i = html.toLowerCase().indexOf('</'+allowed_tag)   ;}

            // Determine
            if (i == 0) {
                allowed = true;
                break;
            }
        }

        if (!allowed) {
            str = replacer(html, "", str); // Custom replace. No regexing
        }
    }

    return str;
}

function cambiarPagina(menu){
	if(menu.selectedIndex !=0)
	window.document.location=menu[menu.selectedIndex].value
}
    

function mostrarOcultarRss(id){    
   if(document.getElementById(id).style.display=="none"){
        $(document.getElementById(id)).slideDown('slow');
   }else if(document.getElementById(id).style.display=="block"){
	   $(document.getElementById(id)).slideUp('slow');
    }
}


function crearVideoCity(ancho, alto, id_video, showtools, fullscreen, div)
{
  if(showtools)
  {
	showtools='&showTools=true';
  }
  else
  {
	showtools='&showTools=false';
  }
  if(fullscreen)
  {
    fullscreen='&fullscreen=true"';            
  }
  else
  {
    fullscreen='&fullscreen=false"';
  }
  var codembed='<object height="'+alto+'" width="'+ancho+'" id="videocom'+id_video+'" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,115,0" style="visibility: visible;" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000">';
	codembed+='<param name="movie" value="http://www.citytv.com.co/media/swf/Videocom.swf?videoID='+id_video+showtools+fullscreen+'">';
	codembed+='<param name="allowfullscreen" value="true">';
	codembed+='<param name="allowscriptaccess" value="always">';
	codembed+='<param name="wmode" value="transparent">';						
	codembed+='<param name="flashvars" value="videoID='+id_video+showtools+fullscreen+'&autoPlay=false">';						
	codembed+='<embed height="'+alto+'" width="'+ancho+'" flashvars="videoID='+id_video+showtools+fullscreen+'&autoPlay=false" allowfullscreen="true" allowscriptaccess="always" wmode="transparent" src="http://www.citytv.com.co/media/swf/Videocom.swf" type="application/x-shockwave-flash" style="visibility: visible;"/>';
  codembed+='</object>';
  document.getElementById(div).innerHTML = codembed;
}

