var eplrnd = (new String(Math.random())).substring(2,8) + (((new Date()).getTime()) & 262143);
var sw = (self.innerWidth ? self.innerWidth : (document.documentElement && document.documentElement.clientWidth) ? document.documentElement.clientWidth : document.body ? document.body.clientWidth : "");
var sh = (self.innerHeight ? self.innerHeight : (document.documentElement && document.documentElement.clientHeight) ? document.documentElement.clientHeight : document.body ? document.body.clientHeight : "");
var wh = (sw && sh) ? (sw.toString(16) + "x" + sh.toString(16)) : "";
var sitio_id = '';
var seccion_id = '';

function eplAD(espacio_id) {
  var ad = '<scri' + 'pt language="JavaScript" type="text/javascript" src="http://ads.e-planning.net/eb/3/' + sitio_id + '/' + seccion_id + '/' + espacio_id + '?o=j&rnd=' + eplrnd + (wh ? ('&n=' + wh) : '') + '"></scri' + 'pt>';
  document.write(ad);
}

/* Encuestas */
function AbrirEncuesta(form,popup) {
  var mando = 0;
  for (i=0;i<form.respId.length;i++){
    if(form.respId[i].checked == true){ mando = 1; }
  }
  if (mando == 1){
    window.open('', popup, 'toolbar=no,menubar=no,location=no,scrollbars=no,resizable=no,width=430,height=457');
  } else {
    alert('Seleccione un item');
    return false;
  } 
  return true;
}

function AbrirEncuestaSimple(form, popup) {
  window.open('', popup, 'toolbar=no,menubar=no,location=no,scrollbars=no,resizable=no,width=430,height=457');
  form.submit();
  return true;
}

function calcularAlto(idiframe){
  document.getElementById(idiframe).height=document.getElementById(idiframe).contentWindow.document.body.scrollHeight;
}

/* Funcion Random mas oportunidades */
function randomArray(muestra, universo)
  {if (universo < muestra)
    {vec = randomArray(universo, universo);
     }
   else
    {vec = new Array(muestra);
     for(ii = 0; ii < muestra; ii++)
      {repetido = true;
       while (repetido)
        {nn = Math.floor((Math.random() * universo));
         repetido = false;
         for(jj = 0; jj < ii; jj++)
          if (vec[jj] == nn)
            repetido = true;
         }
       vec[ii] = nn;
       }
     }
  return vec;
  }

/* Ticker de noticias */

function stringReplace(orig, que, por)
  {pos = orig.indexOf(que);
   while (pos > -1)
    {orig = orig.substring(0, pos) + por + orig.substring(pos + que.length, orig.length);
     pos = orig.indexOf(que);
     }

  return orig;
  }

var caracteresBuenos = new Array('á', 'é', 'í', 'ó', 'ú', 'ñ', 'Ñ','¿', '¡', '"', 'Ç', 'ç','ü', '“', '”');
var caracteresMalos = new Array('&aacute;', '&eacute;', '&iacute;', '&oacute;', '&uacute;', '&ntilde;', '&Ntilde;','&iquest;', '&iexcl;', '&quot;', '&Ccedil;', '&ccedil;','&uuml;', '&ldquo;', '&rdquo;');

var listaNoticiasItem = 0;    // item actual
var listaNoticiasLetra = -1;  // letra que se esta tipeando
var listaNoticiasSpan = null;

function iniciarNewsticker()
  {for(var ii = 0; ii < kNoticias; ii++)
    for(var jj = 0; jj <= caracteresBuenos.length; jj++)
      listaNoticias[ii] = stringReplace(listaNoticias[ii], caracteresMalos[jj], caracteresBuenos[jj]);
      //listaNoticias[ii].replace('/' + caracteresMalos[jj] + '/gi', caracteresBuenos[jj]);

   listaNoticiasSpan = document.getElementById('newsticker');
   setTimeout('newsticker()', 1001);
   }

function newsticker()
  {if (listaNoticiasLetra < listaNoticias[listaNoticiasItem].length)
    {
     listaNoticiasLetra = listaNoticiasLetra + 2;
     cursor = "<span class=t07a>|</span>";
     listaNoticiasSpan.innerHTML = "<span class=\"rj\">" + listaNoticias[listaNoticiasItem].substring(0, listaNoticiasLetra) + "</span>" + cursor;
     setTimeout('newsticker()', 250)
     }
   else
    {// item nuevo
     listaNoticiasLetra = -1;
     listaNoticiasItem++;
     if (listaNoticiasItem >= listaNoticias.length)
      listaNoticiasItem = 0;
     setTimeout('newsticker()', 5000)
     }
   }

/* POPUP */
function Popup(url,name,width,height,resize,scroll) {
  var dialogWin = new Object();
  dialogWin.width = width;
  dialogWin.height = height;
  now = new Date();
  var millis=now.getTime();
  var mstr=""+millis;
  if (navigator.appName == "Netscape") {
    dialogWin.left = window.screenX + ((window.outerWidth - dialogWin.width) / 2);
    dialogWin.top = window.screenY + ((window.outerHeight - dialogWin.height) / 2);
    var attr = 'screenX=' + dialogWin.left + ',screenY=' + dialogWin.top + ',resizable=' + resize + ',width=' + dialogWin.width + ',height=' + dialogWin.height + ',scrollbars=' + scroll + ',menubar=no,location=no,toolbar=no,status=no,directories=no';
  } else if (document.all) {
    dialogWin.left = (screen.width - dialogWin.width) / 2;
    dialogWin.top = (screen.height - dialogWin.height) / 2;
    var attr = 'left=' + dialogWin.left + ',top=' + dialogWin.top + ',resizable=' + resize + ',width=' + dialogWin.width + ',height=' + dialogWin.height + ',scrollbars=' + scroll + ',menubar=no,location=no,toolbar=no,status=no,directories=no';
  }
window.open(url,name,attr);
}

/* PRELOAD DE IMAGENES */
var status = 1;
var toc = new Array();

function item(off, over){
  this.off = new Image(); this.off.src = off;
  this.over = new Image(); this.over.src = over;
}
function cache(id, off, over){
  item[id] = new item(off, over);
  toc[toc.length] = id;
}
function over(id){
  document[id].src = item[id].over.src;
}
function out(id){
  document[id].src = item[id].off.src;
}

/* Cookies */
function getCookie(nameOfCookie)
        {if (document.cookie.length > 0)
                {begin = document.cookie.indexOf(nameOfCookie + "=");
                 if (begin != -1)
                        begin += nameOfCookie.length + 1;
                 else
                        return null;
                 end = document.cookie.indexOf(";", begin);
                 if (end == -1)
                        end = document.cookie.length;
                 return unescape(document.cookie.substring(begin, end));
                 }

         return null;
         }

var nombreclarin = unescape(getCookie("UC"));
var regCookieLogin = getCookie("REG");
var controlCookieLogin = getCookie("Control");
var pd = window.location;

/* VALIDACIÓN BUSCADOR  */
function ValidarPalabraBuscador(estevalor){
  estevalor.value = estevalor.value.split('?').join(' ');
  estevalor.value = estevalor.value.split(',').join(' ');
  while(''+estevalor.value.indexOf('  ') > 0)
    estevalor.value = estevalor.value.split('  ').join(' ');
  while(''+estevalor.value.charAt(0)==' ')
    estevalor.value = estevalor.value.substring(1,estevalor.value.length);
  while(''+estevalor.value.charAt(estevalor.value.length-1)==' ')
    estevalor.value = estevalor.value.substring(0,estevalor.value.length-1);
  if ((estevalor.value=="") || (estevalor.value==" ") ||  (estevalor.value=="  ") || (estevalor.value=="   ")) {
    alert("Debe ingresar una palabra para que inicie la búsqueda.");
    return false;
    }

  //var checkOK = "._-áéíóúÁÉÍÓÚçÇãÃõÕüÜàÀêÊ~`@!#$%^&*()-_=+[]{}''|\/<>,.;:\"";
  var checkOK = "._-~`@!#$%^&*()-_=+[]{}'|\/<>,.;:\"";
  var checkStr = estevalor.value;
  var decPoints = 0;
  var allNum = "";
  for (i = 0;  i < checkStr.length;  i++){
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j < checkOK.length){
      alert("Ingrese una palabra válida.");
      return false;
    }
    allNum += ch;
  }

  return true;
}

function Valida(esteform,estevalor){
  if (!ValidarPalabraBuscador(estevalor)){
    estevalor.focus();
  } else {
    if(esteform.pubId.selectedIndex == 2) {
      esteform.action = 'http://www.ubbi.com/resultados.asp';
      esteform.q.value = estevalor.value
      esteform.submit();
    } else {
      esteform.action = 'http://www.servicios.clarin.com/buscador/jsp/resultados.jsp';
      esteform.submit();
    }
  }
}

function ValidaCheck(esteform){
  var estevalor = esteform.query;
  if (!ValidarPalabraBuscador(estevalor)){
    estevalor.focus();
  } else {
    if(esteform.pubId.selectedIndex == 2) {
      esteform.action = 'http://www.buscador.clarin.com/buscador/google';
      esteform.q.value = escape(estevalor.value);
      return true;
    } else {
      esteform.action = 'http://www.buscador.clarin.com/buscador/notas';
      esteform.query.value = UTF8.encode(estevalor.value);
       return true;
    } 
  }
  return false;
}



/* 
  Copyright 2009 - Certifica.com 
  $Id$
*/

DEFAULT_PIVOT_NAME = 'cert_Pivot';
DEFAULT_REDIRECT_TIME = 3000;
DEFAULT_PERIODIC_REDIRECT_TIME = 60000;
DEFAULT_ORIGIN_COOKIE_NAME = 'cert_Origin';

var cert_CustomCounters = null;
var cert_CustomAttributes = null;

function cert_qVal(sValue) 
{
    var pos = String(document.location).indexOf('?');
    if (pos != -1) {
       var query = String(document.location).substring(pos+1);
       var vars = query.split("&");
       for (var i=0; i < vars.length; i++) {
          var pair = vars[i].split("=");
          if (pair[0] == sValue)
             return pair[1];
       }       
    }
    return null;  
}

function cert_getCookie(sName) {
  var dc = document.cookie;
  var prefix = sName + "=";
  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));
}

function cert_setCookie(sName, sValue, dtExpires, sPath, sDomain, bSecure) {
  document.cookie = sName + "=" + escape(sValue) +
      ((dtExpires) ? "; expires=" + dtExpires.toGMTString() : "") +
      ((sPath) ? "; path=" + sPath : "") +
      ((sDomain) ? "; domain=" + sDomain : "") +
      ((bSecure) ? "; secure" : "");
}

function cert_getReferrer()
{
   var referrer = document.referrer;
   if (self.cert_getReferrer14)
      return cert_getReferrer14();
/*@cc_on
  @if(@_jscript_version >= 5 )
   try { 
      if ( self != top ) referrer = top.document.referrer;
   } catch(e) {};
  @end
  @*/
  return referrer;
}

/* Obtiene el tipo de protocolo del documento actual. */
function cert_getProtocol()
{
    if (window && window.location && window.location.protocol)
        return window.location.protocol;
    return null;
}
 
/* Crea una cookie con el contenido del referrer para evaluarlo
  en el paso final, si es necesario. */
function cert_setOrigin()
{
  var c = cert_getCookie(DEFAULT_ORIGIN_COOKIE_NAME);
  if (!c) {
    var l = cert_getReferrer();
    if (l) {
      var re = new RegExp('https?:\/\/([^\/]+)');
      var m = re.exec(l);
      if (m) {
        var m2 = re.exec(document.location);
        if (m2) {
          if (m[1] != m2[1]) {
            c = m[1];
          }
        }
      }
    }
    if (!c) {
      c = 'directo';
    }
    cert_setCookie(DEFAULT_ORIGIN_COOKIE_NAME, c);
  } 
}

function cert_getFlashVersion()
{
  var flashVersion = -1;
  if (navigator.plugins && navigator.plugins.length) {
    var objFlash = navigator.plugins["Shockwave Flash"];
    if (objFlash) {
      if (objFlash.description) {
        flashDesc = objFlash.description;
        flashVersion = flashDesc.charAt(flashDesc.indexOf('.')-1);
      }
    }

    if (navigator.plugins["Shockwave Flash 2.0"]) {
      flashVersion = 2;
    }
  } else if (navigator.mimeTypes && navigator.mimeTypes.length) {
    x = navigator.mimeTypes['application/x-shockwave-flash'];
    if (x && x.enabledPlugin) {
      flashVersion = 0; // no detectada!
    }
  }

  /*@cc_on
  for(var i = 10; i > 0; i--) {
    try {
      var flash = new ActiveXObject("ShockwaveFlash.ShockwaveFlash." + i);
      flashVersion = i;
      break;
    } catch(e){}
  }  
  @*/
  return flashVersion;
}

/* Crea la URL para obtener un pageview de Certifica. */
/* Solo necesita los parametros iSiteId y sPath       */
function cert_getURL(iSiteId, sPath, sAppend) 
{
    var referrer, url;
    referrer = 'otro';
    var o = cert_qVal('url_origen');
    var proto = cert_getProtocol();
    if (proto != 'MV_Imaging.html')
        proto = 'MV_Imaging.html';
    
    if (o != null && o != '')
       referrer = o;
    else 
       referrer = escape(cert_getReferrer());
    url = 
       proto + '//hits.e.cl/cert/hit.dll?sitio_id=' + iSiteId + '&path=' + sPath +
       '&referer=' + referrer ;
    url += '&java=' + navigator.javaEnabled() + '&flash=' + cert_getFlashVersion();
    if (sAppend)
        url += sAppend;
    return url;    
}

function cert_addCustomAttribute(sType, sValue)
{
  if (!cert_CustomAttributes) {
    cert_CustomAttributes = new Object();
  }

  cert_CustomAttributes[sType] = sValue;
}

function cert_addCustomCounter(sType, iValue)
{
  if (iValue && iValue > 0) {
    if (!cert_CustomCounters) {
      cert_CustomCounters = new Object();
    }

    if (cert_CustomCounters[sType]) {
      cert_CustomCounters[sType] += iValue;
    } else {
      cert_CustomCounters[sType] = iValue;
    }
  }
}


function cert_getCustomTags()
{
  var sRet = '';
  var ct_atrib = '', ct_acum = '';
  if (cert_CustomAttributes) {
    ct_atrib = 'ct_atrib=';
    for (var i in cert_CustomAttributes) {
      ct_atrib += i + ':' + cert_CustomAttributes[i] + ';';
    }
  }

  if (cert_CustomCounters) {
    ct_acum = 'ct_acum=';
    for (var i in cert_CustomCounters) {
      ct_acum += i + ':' + cert_CustomCounters[i] + ';';
    }
  }

  if (ct_atrib || ct_acum) {
    if (ct_atrib) {
      sRet += '&' + ct_atrib;
    }
    if (ct_acum) {
      sRet += '&' + ct_acum;
    }
  }
  return sRet;
}


/* Crea la URL para un sitio con e-Commerce. */
function cert_getURL_eCommerce(iSiteId, sPath, sAmount)
{
  var sOrigin = null;

  if ((sOrigin = cert_getCookie(DEFAULT_ORIGIN_COOKIE_NAME))) {
    cert_addCustomAttribute('origin', sOrigin);
  }

  if (sAmount) {
    cert_addCustomCounter('money', sAmount);
  }

  var sAppend = cert_getCustomTags();

  return cert_getURL(iSiteId, sPath, sAppend);
}
  
    
/* Efectua un hit en certifica usando una imagen pivote. */
function cert_registerHit(iSiteId, sPath, sPivotName) 
{
   var sAppend = '&cert_cachebuster=' + (1 + Math.floor (Math.random() * 10000));
   if ( !sPivotName )
      sPivotName = DEFAULT_PIVOT_NAME;
   if ( document.images )
      if ( document.images[sPivotName] )
         document.images[sPivotName].src = cert_getURL(iSiteId, sPath, sAppend);
}

/* Efectua una redireccion marcando la ruta de salida */
function cert_registerHitAndRedirect( sURL, iSiteId, sPath, sPivotName ) 
{
   cert_registerHit( iSiteId, sPath, sPivotName );
   setTimeout( "location.href = '" + sURL + "'", DEFAULT_REDIRECT_TIME );
}

/* Abre una nueva ventana, marcando el hit */
function cert_registerHitAndOpenWindow( sURL, iSiteId, sPath, sPivotName, sName, sFeatures, bReplace )
{
   cert_registerHit( iSiteId, sPath, sPivotName );
   if (!sName)
      sName = 'Downloads';
   if (!sFeatures)
      sFeatures = 'toolbar=no,location=no,directories=no,status=yes,menubar=no, scrollbars=no,resizable=no,width=425,height=510,screenX=20,screenY=20';
   window.open( sURL, 
      sName, 
      sFeatures, 
      bReplace 
   );
   return false;
}

/* Marca el hit y reemplaza/abre una URL en el frame 'sName' */
function cert_registerHitAndReplaceOtherFrame( sURL, sName, iSiteId, sPath, sPivotName ) 
{
   cert_registerHitAndOpenWindow( sURL, iSiteId, sPath, sPivotName, sName, 0, true );
}

/* Marca el hit y reemplaza/abre una URL en el frame 'sName' */
function cert_registerHitAndReplaceThisFrame( sURL, iSiteId, sPath, sPivotName ) 
{
   cert_registerHitAndRedirect( sURL, iSiteId, sPath, sPivotName );
}

/* Marca el hit y baja un archivo */
function cert_registerHitAndDownloadFile( sURL, iSiteId, sPath, sPivotName ) 
{
   cert_registerHitAndRedirect( sURL, iSiteId, sPath, sPivotName );
}

function cert_getAnchor(sUrl)
{
    return '<img src="' + sUrl + '" width="1" height="1" border="0" alt="Certifica.com">';
}

/* Marca un hit en la pagina actual */

function hitCertifica(iSiteId, sPath, sAppend) 
{
    
    document.writeln(cert_getAnchor(cert_getURL(iSiteId, sPath, sAppend)));

    cert_areasporhora(iSiteId, sPath, sAppend); 
}

/* Marca un hit en la pagina actual, usando eCommerce */

function tagCertifica_eCommerce(iSiteId, sPath, iAmount) 
{
    document.writeln(cert_getAnchor(cert_getURL_eCommerce(iSiteId, sPath, iAmount)));
}

/* Marca un registro cada iTime milisegundos.  */
function cert_registerPeriodicHit( iSiteId, sPath, sPivotName, iTime ) 
{
   if ( !sPivotName )
      sPivotName = DEFAULT_PIVOT_NAME;
   if ( !iTime )
      iTime = DEFAULT_PERIODIC_REDIRECT_TIME;

   cert_registerHit( iSiteId, sPath, sPivotName );
   setTimeout( 'cert_registerPeriodicHit( ' + iSiteId + ', "' + sPath + '", "' + sPivotName + '", ' + iTime + ')', iTime );
}

cert_setOrigin();


function cert_areasporhora(iSiteId, sPath, sAppend)
{        
  
   var NewId='';   
   var NewPath='';
   var sPath2='';
                     
   sPath=sPath.toLowerCase();
   sPath=sPath.replace(/\/\//g, "/");
   var fragmento=sPath.split("http://www.dimnetcorp.com/");   
  
   m=1;
   while (m < (fragmento.length-1)){
            
      sPath2=sPath2 + fragmento[m] + "/";
      m++;
   } 

   sPath2=sPath2 + "+";
   sPath2=sPath2.replace("/+",""); 
   sPath=sPath2;
         
   if (iSiteId == 105903) 
   {
      if (sPath == 'twitter/home')
      {
    NewId=201768;
          NewPath='twitter/index';
      }
            
      if (sPath == 'homeclarin/homewidgets') 
      {
    NewId=201769;
          NewPath='widgets/index';
      }

      if (sPath == 'clarin/buscadorgoles')
      {
    NewId=201770;
          NewPath='buscadorgoles/index';
      }
 
      if (sPath == 'edicionesanteriores/edicionesanteriores') 
      {
    NewId=201771;
          NewPath='edicionesanteriores/index';
      }

      if (sPath == 'homeclarin/edicionesanteriores') 
      {
    NewId=201772;
          NewPath='homeclarin/edicionesanteriores';
      }
   }

   if (iSiteId == 200048)
   {
      if (sPath == 'busquedaclarin/resultados') 
      {
    NewId=201773;
          NewPath='busquedaclarin/index';
      }

      if (sPath == 'busquedainternet/resultados') 
      {
    NewId=201774;
          NewPath='busquedaInternet/index';
      }

   }

   if (iSiteId == 200047)
   {
      if (sPath == 'ole/buscadorgoles') 
      {
    NewId=201775;
          NewPath='Ole/buscadorGoles';
      }
   }

   if (iSiteId == 200045)
   {
      if (sPath == 'tn/buscadorgoles') 
      {
    NewId=201776;
          NewPath='tn/buscadorGoles';
      }
   }

   if (iSiteId == 200137)
   { 

      if (sPath == 'la100/otrasradios/romantica') 
      {
    NewId=201777;
          NewPath='la100/romantica';
      }

      if (sPath == 'la100/otrasradios/nacional') 
      {
    NewId=201778;
          NewPath='la100/nacional'; 
      }

      if (sPath == 'la100/otrasradios/80') 
      {
    NewId=201779;
          NewPath='la100/80';
      }
         
      if (sPath == 'la100/otrasradios/reggaeton') 
      {
    NewId=201780;
          NewPath='la100/reggaeton';
      }

      if (sPath == 'la100/otrasradios/ricardo_arjona')
      {
    NewId=201781;
          NewPath='la100/ricardo_arjona'; 
      }

      if (sPath == 'la100/otrasradios/top_40') 
      {
    NewId=201782;
          NewPath='la100/top_40';  
      }

      if (sPath == 'la100/otrasradios/90') 
      {
    NewId=201783;
          NewPath='la100/90';  
      }
        
      if (sPath == 'la100/otrasradios/lentos') 
      {
    NewId=201784;
          NewPath='la100/lentos';
      }

      if (sPath == 'la100/otrasradios/retro_mix') 
      {
    NewId=201785;
          NewPath='la100/retro_mix';
      }

      if (sPath == 'la100/otrasradios/sabina') 
      {
    NewId=201786;
          NewPath='la100/sabina'; 
      }

      if (sPath == 'la100/otrasradios/lo_mejor_2008') 
      {
    NewId=201787;
          NewPath='la100/lo_mejor_2008';
      }

      if (sPath == 'la100/otrasradios/lo_mejor_2009') 
      {
    NewId=201788;
          NewPath='la100/lo_mejor_2009';               
      }             
   }

   if (NewId != 0) 
   {
      document.writeln(cert_getAnchor(cert_getURL(NewId, NewPath, sAppend)));
               
   }

}



/* Certifica IAB */

<!--DOCUMENT CONTENT_TYPE="text/javascript"  -->

DEFAULT_REFRESH_TIME = 600000;
REFRESH_LIMIT = 600000;
var cert_IsAutoRefresh = false;

/* Funciones internas al script Certifica-IAB */
function cert_setCookie(name, value, expires, path, domain, secure) {
  var curCookie = name + "=" + escape(value) +
      ((expires) ? "; expires=" + expires.toGMTString() : "") +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      ((secure) ? "; secure" : "");
  document.cookie = curCookie;
}

function cert_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));
}

function cert_deleteCookie(name, path, domain) {
  if (cert_getCookie(name)) {
    document.cookie = name + "=" +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
}

function cert_RefreshInt()
{
  var now = new Date();

  cert_setCookie('autorefresh_time', now.getTime());
  location.reload();
}

function cert_IsAutoRefresh_func() {
    var now = new Date();
    var tsCookie = cert_getCookie('autorefresh_time');
  
    cert_deleteCookie('autorefresh_time');
  
    if (tsCookie) {
        var d = now.getTime() - tsCookie;
        if (d <= REFRESH_LIMIT) {
            return true;
        } else {
            return false;
        }
    } else {
        return false;
    }
}
/*
 * Funciones PUBLICAS
 */

/*
 * cert_Refresh: permite hacer autorefresh de la pagina y cumplir con las normas
 *               fijadas por el IAB al respecto.
 *
 * iTime: tiempo en segundos en el cual se deberá hacer autorefresh
 *
 */
function cert_Refresh( iTime ) {
  var refreshTime;
  refreshTime = ((iTime) ? iTime*1000 : DEFAULT_REFRESH_TIME);

  cert_IsAutoRefresh = cert_IsAutoRefresh_func();
  setTimeout( 'cert_RefreshInt()', refreshTime );
}

/* tagCertificaIAB: permite registrar un pageview, y cumplir con las normas del IAB en lo relativo a los autorefresh.
   isHome: Valor 1 o 0, para indicar si la pagina marcada es el home o no (1=Home). */
function tagCertificaIAB(iSiteId, isHome){
    var now = new Date();
    var mustCount = true;
    var path;

    if (cert_IsAutoRefresh) {
        path = '/autorefresh';
        if (isHome) {
            var tsCookie = cert_getCookie('cert_hit_time');
            var d = now.getTime() - tsCookie;
            if (d < DEFAULT_REFRESH_TIME) {
                mustCount = false;
            }
        } else {
            mustCount = false;
        }
    } else {
       path = '/normal';
    }
    if (mustCount) {
       var url;
       if (isHome) {
           cert_setCookie('cert_hit_time', now.getTime());
           path = '/home' + path;
       } else {
           path = '/resto_sitio' + path;
       }
       url = 
       'http://hits.e.cl/cert/hit.dll?sitio_id=' + iSiteId + '&path=' + path;
       document.writeln( '<img src="' + url + '" width="1" height="1" border="0" alt="Certifica.com">' );
    }
}

function fullscreen(url){
  window.open('/shared/v5/swf/tvplayer/' + url,'','width=400,height=200');
}

/*=SOLUCION FLASH========================================================================================*/
/*
 SWFObject v1.4.2: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
*/
if(typeof deconcept == "undefined") var deconcept = new Object();
if(typeof deconcept.util == "undefined") deconcept.util = new Object();
if(typeof deconcept.SWFObjectUtil == "undefined") deconcept.SWFObjectUtil = new Object();
deconcept.SWFObject = function(swf, id, w, h, ver, c, useExpressInstall, quality, xiRedirectUrl, redirectUrl, detectKey){
  if (!document.getElementById) { return; }
  this.DETECT_KEY = detectKey ? detectKey : 'detectflash';
  this.skipDetect = deconcept.util.getRequestParameter(this.DETECT_KEY);
  this.params = new Object();
  this.variables = new Object();
  this.attributes = new Array();
  if(swf) { this.setAttribute('swf', swf); }
  if(id) { this.setAttribute('id', id); }
  if(w) { this.setAttribute('width', w); }
  if(h) { this.setAttribute('height', h); }
  if(ver) { this.setAttribute('version', new deconcept.PlayerVersion(ver.toString().split("."))); }
  this.installedVer = deconcept.SWFObjectUtil.getPlayerVersion();
  if(c) { this.addParam('bgcolor', c); }
  var q = quality ? quality : 'high';
  this.addParam('quality', q);
  this.setAttribute('useExpressInstall', useExpressInstall);
  this.setAttribute('doExpressInstall', false);
  var xir = (xiRedirectUrl) ? xiRedirectUrl : window.location;
  this.setAttribute('xiRedirectUrl', xir);
  this.setAttribute('redirectUrl', '');
  if(redirectUrl) { this.setAttribute('redirectUrl', redirectUrl); }
}
deconcept.SWFObject.prototype = {
  setAttribute: function(name, value){
    this.attributes[name] = value;
  },
  getAttribute: function(name){
    return this.attributes[name];
  },
  addParam: function(name, value){
    this.params[name] = value;
  },
  getParams: function(){
    return this.params;
  },
  addVariable: function(name, value){
    this.variables[name] = value;
  },
  getVariable: function(name){
    return this.variables[name];
  },
  getVariables: function(){
    return this.variables;
  },
  getVariablePairs: function(){
    var variablePairs = new Array();
    var key;
    var variables = this.getVariables();
    for(key in variables){
      variablePairs.push(key +"="+ variables[key]);
    }
    return variablePairs;
  },
  getSWFHTML: function() {
    var swfNode = "";
    if (navigator.plugins && navigator.mimeTypes && navigator.mimeTypes.length) { // netscape plugin architecture
      if (this.getAttribute("doExpressInstall")) { this.addVariable("MMplayerType", "PlugIn"); }
      swfNode = '<embed type="application/x-shockwave-flash" src="'+ this.getAttribute('swf') +'" width="'+ this.getAttribute('width') +'" height="'+ this.getAttribute('height') +'"';
      swfNode += ' id="'+ this.getAttribute('id') +'" name="'+ this.getAttribute('id') +'" ';
      var params = this.getParams();
       for(var key in params){ swfNode += [key] +'="'+ params[key] +'" '; }
      var pairs = this.getVariablePairs().join("&");
       if (pairs.length > 0){ swfNode += 'flashvars="'+ pairs +'"'; }
      swfNode += '/>';
    } else { // PC IE
      if (this.getAttribute("doExpressInstall")) { this.addVariable("MMplayerType", "ActiveX"); }
      swfNode = '<object id="'+ this.getAttribute('id') +'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+ this.getAttribute('width') +'" height="'+ this.getAttribute('height') +'">';
      swfNode += '<param name="movie" value="'+ this.getAttribute('swf') +'" />';
      var params = this.getParams();
      for(var key in params) {
       swfNode += '<param name="'+ key +'" value="'+ params[key] +'" />';
      }
      var pairs = this.getVariablePairs().join("&");
      if(pairs.length > 0) {swfNode += '<param name="flashvars" value="'+ pairs +'" />';}
      swfNode += "</object>";
    }
    return swfNode;
  },
  write: function(elementId){
    if(this.getAttribute('useExpressInstall')) {
      // check to see if we need to do an express install
      var expressInstallReqVer = new deconcept.PlayerVersion([6,0,65]);
      if (this.installedVer.versionIsValid(expressInstallReqVer) && !this.installedVer.versionIsValid(this.getAttribute('version'))) {
        this.setAttribute('doExpressInstall', true);
        this.addVariable("MMredirectURL", escape(this.getAttribute('xiRedirectUrl')));
        document.title = document.title.slice(0, 47) + " - Flash Player Installation";
        this.addVariable("MMdoctitle", document.title);
      }
    }
    if(this.skipDetect || this.getAttribute('doExpressInstall') || this.installedVer.versionIsValid(this.getAttribute('version'))){
      var n = (typeof elementId == 'string') ? document.getElementById(elementId) : elementId;
      n.innerHTML = this.getSWFHTML();
      return true;
    }else{
      if(this.getAttribute('redirectUrl') != "") {
        document.location.replace(this.getAttribute('redirectUrl'));
      }
    }
    return false;
  }
}

/* ---- detection functions ---- */
deconcept.SWFObjectUtil.getPlayerVersion = function(){
  var PlayerVersion = new deconcept.PlayerVersion([0,0,0]);
  if(navigator.plugins && navigator.mimeTypes.length){
    var x = navigator.plugins["Shockwave Flash"];
    if(x && x.description) {
      PlayerVersion = new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/, "").replace(/(\s+r|\s+b[0-9]+)/, ".").split("."));
    }
  }else{
    // do minor version lookup in IE, but avoid fp6 crashing issues
    // see http://blog.deconcept.com/2006/01/11/getvariable-setvariable-crash-internet-explorer-flash-6/
    try{
      var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
    }catch(e){
      try {
        var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
        PlayerVersion = new deconcept.PlayerVersion([6,0,21]);
        axo.AllowScriptAccess = "always"; // throws if player version < 6.0.47 (thanks to Michael Williams @ Adobe for this code)
      } catch(e) {
        if (PlayerVersion.major == 6) {
          return PlayerVersion;
        }
      }
      try {
        axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
      } catch(e) {}
    }
    if (axo != null) {
      PlayerVersion = new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));
    }
  }
  return PlayerVersion;
}
deconcept.PlayerVersion = function(arrVersion){
  this.major = arrVersion[0] != null ? parseInt(arrVersion[0]) : 0;
  this.minor = arrVersion[1] != null ? parseInt(arrVersion[1]) : 0;
  this.rev = arrVersion[2] != null ? parseInt(arrVersion[2]) : 0;
}
deconcept.PlayerVersion.prototype.versionIsValid = function(fv){
  if(this.major < fv.major) return false;
  if(this.major > fv.major) return true;
  if(this.minor < fv.minor) return false;
  if(this.minor > fv.minor) return true;
  if(this.rev < fv.rev) return false;
  return true;
}
/* ---- get value of query string param ---- */
deconcept.util = {
  getRequestParameter: function(param) {
    var q = document.location.search || document.location.hash;
    if(q) {
      var pairs = q.substring(1).split("&");
      for (var i=0; i < pairs.length; i++) {
        if (pairs[i].substring(0, pairs[i].indexOf("=")) == param) {
          return pairs[i].substring((pairs[i].indexOf("=")+1));
        }
      }
    }
    return "";
  }
}
/* fix for video streaming bug */
deconcept.SWFObjectUtil.cleanupSWFs = function() {
  var objects = document.getElementsByTagName("OBJECT");
  for (var i=0; i < objects.length; i++) {
    objects[i].style.display = 'none';
    for (var x in objects[i]) {
      if (typeof objects[i][x] == 'function') {
        objects[i][x] = null;
      }
    }
  }
}
if (typeof window.onunload == 'function') {
  var oldunload = window.onunload;
    window.onunload = function() {
    deconcept.SWFObjectUtil.cleanupSWFs();
    oldunload();
  }
} else {
  window.onunload = deconcept.SWFObjectUtil.cleanupSWFs;
}
/* add Array.push if needed (ie5) */
if (Array.prototype.push == null) { Array.prototype.push = function(item) { this[this.length] = item; return this.length; }}

/* add some aliases for ease of use/backwards compatibility */
var getQueryParamValue = deconcept.util.getRequestParameter;
var FlashObject = deconcept.SWFObject; // for legacy support
var SWFObject = deconcept.SWFObject;

/*=FIN SOLUCION FLASH========================================================================================*/

function HdOver(club){
  document.getElementById(club).style.display="block";
  var equipo = "";
  if(club == 'Arg'){equipo = "<span>Argentinos</span>"}
  if(club == 'Ars'){equipo = "<span>Arsenal</span>"}
  if(club == 'Tuc'){equipo = "<span>Atl&eacute;tico Tucum&aacute;n</span>"}
  if(club == 'Ban'){equipo = "<span>Banfield</span>"}
  if(club == 'Boc'){equipo = "<span>Boca Juniors</span>"}
  if(club == 'Cha'){equipo = "<span>Chacarita</span>"}
  if(club == 'Col'){equipo = "<span>Col&oacute;n</span>"}
  if(club == 'Est'){equipo = "<span>Estudiantes (LP)</span>"}
  //if(club == 'GEJ'){equipo = "<span>Gimnasia y Esgrima (J)</span>"}
  if(club == 'GEL'){equipo = "<span>Gimnasia y Esgrima (LP)</span>"}
  if(club == 'GCr'){equipo = "<span>Godoy Cruz</span>"}
  if(club == 'Hur'){equipo = "<span>Hurac&aacute;n</span>"}
  if(club == 'Ind'){equipo = "<span>Independiente</span>"}
  if(club == 'Lan'){equipo = "<span>Lan&uacute;s</span>"}
  if(club == 'NOB'){equipo = "<span>Newell's Old Boys</span>"}
  if(club == 'Rac'){equipo = "<span>Racing</span>"}
  if(club == 'RCe'){equipo = "<span>Rosario Central</span>"}
  if(club == 'Riv'){equipo = "<span>River Plate</span>"}
  if(club == 'SLo'){equipo = "<span>San Lorenzo</span>"}
  //if(club == 'SMT'){equipo = "<span>San Mart&iacute;n (T)</span>"}
  if(club == 'Tig'){equipo = "<span>Tigre</span>"}
  if(club == 'Vel'){equipo = "<span>Velez</span>"}

  document.getElementById(club).innerHTML = equipo;

}
function HdOut(club){document.getElementById(club).style.display="none"}

function Estadisticas(cuales,activo){
  var cajas = cuales;
  var estilo = activo;
  var div = null;
  var fechaarchivo = null; 
  var objeto = null;
  
  this.crear = crear;
  function crear(){
    objeto = new AjaxDiv(fechaarchivo,div);
  }

  this.solapas = solapas;
  function solapas(cual){
    //div = 'aj' + cual;
    for (i=0;i<cajas.length;i++){
      var divcual = document.getElementById('li' + cajas[i]);
      var divmayor = document.getElementById(cajas[i]);
      if(cajas[i] == cual){
        divcual.className = estilo;
        divmayor.style.display = 'block';
      } else{
        divcual.className = '';
        divmayor.style.display = 'none';
      }
    }
  }

  this.mostrar = mostrar;
  function mostrar(cualtorneo,cualcategoria,archivos,directorios){
    document.getElementById('linkPosiciones' + cualcategoria ).href =  directorios[cualtorneo] + 'posiciones.html';
    document.getElementById('linkFixture' + cualcategoria ).href =  directorios[cualtorneo] + 'fixture.html';
    try {
    document.getElementById('linkDescenso' + cualcategoria ).href =  directorios[cualtorneo] + 'descenso.html';
    } catch (ee) {};
    document.getElementById('linkGoleadores' + cualcategoria ).href =  directorios[cualtorneo] + 'goleadores.html';
    div = 'divtorneo' + cualcategoria;
    fechaarchivo = directorios[cualtorneo] + archivos[cualtorneo];
    crear();
    objeto.load();
  }
}

