var ecLog = {};
ecLog.server = 'medicion.ecliente.com';

ecLog.getReferrer = function ()
{
   var referrer = document.referrer;
   var idx;
   if ( ( idx = referrer.indexOf ( '?_referrer=' ) ) == -1 )
   {
      idx = referrer.indexOf ( '&_referrer=' );
   }
   if ( idx == -1 )
   {
      return referrer;
   }
   referrer = referrer.substr ( idx + '&_referrer='.length );
   if ( ( idx = referrer.indexOf ( '&' ) ) != -1 )
   {
      referrer = referrer.substr ( 0 , idx );
   }
   if ( referrer.indexOf ( 'http://' ) == -1 && referrer.indexOf ( 'https://' ) == -1 )
   {
      referrer = 'http://' + referrer;
   }
   return referrer;
}

ecLog.jump = function ( link , popup , name , features )
{
   if ( this.t )
   {
      window.clearTimeout ( this.t );
   }
   this.click = new Image();
   this.click.src = 'http://' + this.server + '/' + link.substring ( 7 ) + '?' + 'referrer=http%3A//' + escape ( this.url ) + '&t=' + ( new Date() ).getTime();
   this.name = name;
   this.features = features;
   this.link = link;
   this.other = popup;
   this.go = false;
   this.cont = 0;
   if ( this.other )
   {
      window.open ( link , name , features );
   }
   else
   {
      this.t = window.setTimeout ( "ecLog.doJump()" , 1000 );
   }
}

ecLog.doJump = function()
{
   if ( ++this.cont == 5 )
   {
      this.go = true;
   }
   if ( this.link )
   {
      if ( this.click.complete || this.go )
      { 
         if ( this.other )
         {
            window.open ( this.link , this.name , this.features );
         }
         else
         {
            top.location.href=this.link;
         }
      }
      else
      {
         this.t = window.setTimeout ( "ecLog.doJump()" , 1000 );
      }
   }
}

if ( typeof ecPath != 'undefined' && ecPath != null && ecPath != '' )
{
   ecLog.url = ecPath;
}
else
{
   ecLog.url = window.location.host + window.location.pathname;
}
ecLog.image = new Image();
ecLog.image.src = 'http://' + ecLog.server + '/' + ecLog.url + '?referrer=' + escape ( ecLog.getReferrer() ) + '&t=' + ( new Date() ).getTime();

