/* 
  Copyright 2007 - Certifica.com 
  $Id: certifica.js 1918 2007-06-20 14:06:07Z leus $
*/ 

//CERTIFICA.COM : CODIGO DE certifica.js

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;
var cert_ReferrerParms = null;
var cert_customSearch = false;

function cert_normalizePath(sPath)
{
    var sProtocol = cert_getProtocol();
    var sRet = 'home/default';
    var regexSlashes = /\/\/+/g;
    var regexInvalid = /[^A-Z0-9_.\/]/gi;
    var aDefaultPages = [
        'index.html', 'index.htm', 'index.asp', 'index.php',
        'default.asp', 'index.cfm'
    ];

    sPath = unescape(sPath);
    if (sPath && sPath.length > 0 &&
        (sProtocol == 'http:' || sProtocol == 'https:')) {
        sPath = sPath.replace(regexInvalid, '');
        // Si es un directorio, se agrega una pagina por defecto
        if (sPath.charAt(sPath.length - 1) == '/') {
            sPath += aDefaultPages[0];
        }
        sPath = sPath.replace(regexSlashes, '/');

        var aParts = sPath.split('/');
        var aElems = new Array();
        for (var i = 0; i < aParts.length; i++) {
            if (aParts[i] && aParts[i] != '') {
                aElems.push(aParts[i]);
            }
        }

        if (aElems.length == 0) {
            aElems.push('home');
            aElems.push('default');
        }

        if (aElems.length == 1) {
            aElems.unshift('home');
        }

        for (var i = 0; i < aDefaultPages.length; i++) {
            if (aElems[aElems.length - 1] == aDefaultPages[i]) {
                aElems[aElems.length - 1] = 'default';
                break;
            }
        }
        sRet = aElems.join('/');
    }
    return sRet;
}

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) {
      referrer = cert_getReferrer14();
	} else {
/*@cc_on
  @if(@_jscript_version >= 5 )
   try { 
      if ( self != top ) referrer = top.document.referrer;
   } catch(e) {};
  @end
  @*/
  }

  if (referrer) {
	  if (cert_customSearch) {
		var re = new RegExp('(https?:\/\/[^/]*)\/?.*$');
		referrer = referrer.replace(re, '$1/buscInterno');
	  }
	  referrer = cert_appendExtraReferrerParms(referrer);
  }
  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. */
/* Sólo necesita los parámetros iSiteId y sPath       */
function cert_getURL(iSiteId, sPath, sAppend) 
{
    var size, colors, referrer, url;
    size = colors = referrer = 'otro';
    var o = cert_qVal('url_origen');
    var proto = cert_getProtocol();
    if (proto != 'https:')
        proto = 'http:';
    
    if (o != null && o != '')
       referrer = o;
    else 
       referrer = escape(cert_getReferrer());
    if ( window.screen.width ) size = window.screen.width;
    if ( window.screen.colorDepth ) colors = window.screen.colorDepth;
    else if ( window.screen.pixelDepth ) colors = window.screen.pixelDepth;
	if (sPath == 'url')
		sPath = cert_normalizePath(sPath);
    url = 
       proto + '//hits.e.cl/cert/hit.dll?sitio_id=' + iSiteId + '&path=' + sPath +
       '&referer=' + referrer + '&size=' + size + '&colors=' + colors;
    url += '&java=' + navigator.javaEnabled() + '&flash=' + cert_getFlashVersion();
    if (sAppend)
        url += sAppend;
    return url;    
}

function cert_addExtraReferrerParm(sName, sValue)
{
	if (!cert_ReferrerParms) {
		cert_ReferrerParms = new Object();
	}

	cert_ReferrerParms[sName] = sValue;
}

function cert_appendExtraReferrerParms(sReferrer)
{
	if (cert_ReferrerParms && sReferrer) {
		var sAppend = '';
		for (var n in cert_ReferrerParms) {
			sAppend += n + '=' + cert_ReferrerParms[n] + '&';
		}
		if (sAppend) {
			if (sReferrer.indexOf('?') != -1) {
				sReferrer += '&' + sAppend;
			} else {
				sReferrer += '?' + sAppend;
			}
		}
	}
	return sReferrer;
}

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


/* Crea la URL para un sitio con Search Engine interno. */
function cert_getURL_CustomSearch(iSiteId, sPath, sSearchString)
{
	cert_customSearch = true;
	cert_addExtraReferrerParm('q', sSearchString);

	return cert_getURL(iSiteId, sPath);
}

/* 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);
}

/* Efectúa una redirección 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 página actual */
function tagCertifica(iSiteId, sPath) 
{
    document.writeln(cert_getAnchor(cert_getURL(iSiteId, sPath)));
}

/* Marca un hit en la página actual, usando eCommerce */
function tagCertifica_eCommerce(iSiteId, sPath, iAmount) 
{
    document.writeln(cert_getAnchor(cert_getURL_eCommerce(iSiteId, sPath, iAmount)));
}

/* Marca un hit en la página actual, agregando parametros de Search Engines internos */
function tagCertifica_CustomSearch(iSiteId, sPath, sSearchString) 
{
    document.writeln(cert_getAnchor(cert_getURL_CustomSearch(iSiteId, sPath, sSearchString)));
}
/* 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();

// FIN certifica.JS

//CERTIFICA.COM : CODIGO DE certifica-js14.js
/* 
  Copyright 2004 - Certifica.com 
  $Id: certifica-js14.js,v 1.4 2004/10/27 20:12:21 leus Exp $
*/
	function cert_getReferrer14(){
	   var referrer = document.referrer;
	   try { 
		  if ( self != top ) 
			 referrer = top.document.referrer;
	   } catch(e) {
		  referrer = document.referrer;
	   }
	   return referrer;
	}

//FIN certifica-js14.js


//CERTIFICA.COM : CABECERA TERRA

/* Se busca una cadena y se elimina */

function cert_depura_ruta(v_ruta_buscada ,v_rutacompleta, v_dato) 
{
	  v_url2=v_dato.toLowerCase();
      v_posicion=v_url2.lastIndexOf(v_ruta_buscada);
      v_dato="/"+v_url2.substring(v_posicion+v_ruta_buscada.length,v_url2.length);
      v_datoback=v_dato;
      v_dato2=v_dato.charAt(v_dato.length-1);
      v_cadena="/";
      v_otracadena="|";
      v_contador2=0;
      while (v_datoback.indexOf(v_cadena) > -1) 
      {  v_dato3=v_datoback.indexOf(v_cadena);
         v_datoback=v_datoback.substring(0,v_dato3)+v_otracadena+v_datoback.substring(v_dato3+1,v_datoback.length);
         v_contador2=v_contador2+1;
       }
       if (v_dato2 == '/')
       { v_dato=v_dato+"home/";
       }
	   return v_dato;

}

/*Se utiliza para hacer consistencia de las secciones y validar ciertas excepciones de nombres
que deben aparecer en los reportes con otros nombres.  También se elimina la palabra SHARED.
Las subsecciones de deportes se envían a la sección DEPORTES
*/

function cert_terra_secciones(v_rutacompleta, v_dato) 
{
 var v_datoback, v_cadena, v_dato3, v_dato2, v_otracadena , v_url2=v_dato;
 var v_contador2 , v_posicion , v_return;
   if (v_rutacompleta.indexOf("/shared/") > 0)
    { v_dato = cert_depura_ruta("/shared/" ,v_rutacompleta, v_url2) 
      v_return = v_dato;
      if ((v_rutacompleta.indexOf("/ligaseuropeas/") > 0) || (v_rutacompleta.indexOf("/tenis/") > 0) || (v_rutacompleta.indexOf("/formula12006/") > 0) || (v_rutacompleta.indexOf("/formula1/") > 0) || (v_rutacompleta.indexOf("/formula12005/") > 0) || (v_rutacompleta.indexOf("/sudamericana2005/") > 0) || (v_rutacompleta.indexOf("/mundialsub202005/") > 0) || (v_rutacompleta.indexOf("/basquet2006/") > 0) || (v_rutacompleta.indexOf("/olimpiadas2000/") > 0) || (v_rutacompleta.indexOf("/copaamerica2004/") > 0) || (v_rutacompleta.indexOf("/libertadores2006/") > 0) || (v_rutacompleta.indexOf("/eurocopa2004/") > 0) || (v_rutacompleta.indexOf("/copaamerica2007/") > 0) || (v_rutacompleta.indexOf("/libertadores2007/") > 0) || (v_rutacompleta.indexOf("/formula12007/") > 0) || (v_rutacompleta.indexOf("/panamericanos2007/") > 0) || (v_rutacompleta.indexOf("/mundialsub20/") > 0) || (v_rutacompleta.indexOf("/mundialsub17/") > 0) || (v_rutacompleta.indexOf("/copasudamericana2007/") > 0) || (v_rutacompleta.indexOf("/futbollatino/") > 0) || (v_rutacompleta.indexOf("/eliminatorias2010/") > 0) || (v_rutacompleta.indexOf("/pekin2008/") > 0) || (v_rutacompleta.indexOf("/mundialdeclubes07/") > 0) || (v_rutacompleta.indexOf("/libertadores2008/") > 0) || (v_rutacompleta.indexOf("/formula12008/") > 0))
      {v_return = "/deportes"+v_dato;
      }
    }
    else if (v_rutacompleta.indexOf("/global/") > 0)
     {v_return = "/noticias"+v_dato;
     }
     else if (v_rutacompleta.indexOf("/thegirl2005/") > 0)
     {v_return = "/thegirl"+v_dato;
     }
     else if (v_rutacompleta.indexOf("/webgames/") > 0)
     {v_return = "/games/juegos_web"+v_dato;
     }
     else if (v_rutacompleta.indexOf("/juegos/") > 0)
     {v_return = "/games/juegos_clasicos"+v_dato;
     }
     else if (v_rutacompleta.indexOf("/bienestar/") > 0)
     {
       v_return = "/bienestar_femenino"+v_dato;
     }
	else if (rutacompleta.indexOf("/php/galeria/") > 0)
     { v_dato = cert_depura_ruta("/php/galeria/" ,v_rutacompleta, v_url2) 
       v_return = "/entretenimiento/php-galeria"+v_dato;
     }
	else if (rutacompleta.indexOf("/discovirtual/") > 0)
     { v_dato = cert_depura_ruta("/discovirtual/" ,v_rutacompleta, v_url2) 
       v_return = "/isp/discovirtual"+v_dato;
     }
	else if (rutacompleta.indexOf("/fotolog/") > 0)
     { v_dato = cert_depura_ruta("/fotolog/" ,v_rutacompleta, v_url2) 
       v_return = "/fotolog"+v_dato;
     }
	else if (rutacompleta.indexOf("/album/") > 0)
     { v_dato = cert_depura_ruta("/album/" ,v_rutacompleta, v_url2) 
       v_return = "/album"+v_dato;
     }
	else if (rutacompleta.indexOf("/registro/") > 0)
     { v_dato = cert_depura_ruta("/registro/" ,v_rutacompleta, v_url2) 
       v_return = "/registro"+v_dato;
     }
	else if (rutacompleta.indexOf("/tureportero/") > 0)
     { v_dato = cert_depura_ruta("/tureportero/" ,v_rutacompleta, v_url2) 
       v_return = "/tureportero"+v_dato;
     }
    else if (v_rutacompleta.indexOf("/saludybelleza/") > 0)
     {  v_dato = cert_depura_ruta("/saludybelleza/" ,v_rutacompleta, v_url2) 
		v_return = "/dietas_belleza"+v_dato;
     }
    else if (v_rutacompleta.indexOf("terramovil/eliminatorias2010") > 0)
     {  v_dato = cert_depura_ruta("/terramovil/" ,v_rutacompleta, v_url2) 
		v_return = "/terramovil"+v_dato;
     }	 
    else if ((v_rutacompleta.indexOf("/ligaseuropeas/") > 0) || (v_rutacompleta.indexOf("/tenis/") > 0) || (v_rutacompleta.indexOf("/formula12006/") > 0) || (v_rutacompleta.indexOf("/formula1/") > 0) || (v_rutacompleta.indexOf("/formula12005/") > 0) || (v_rutacompleta.indexOf("/sudamericana2005/") > 0) || (v_rutacompleta.indexOf("/mundialsub202005/") > 0) || (v_rutacompleta.indexOf("/basquet2006/") > 0) || (v_rutacompleta.indexOf("/olimpiadas2000/") > 0) || (v_rutacompleta.indexOf("/copaamerica2004/") > 0) || (v_rutacompleta.indexOf("/libertadores2006/") > 0) || (v_rutacompleta.indexOf("/eurocopa2004/") > 0) || (v_rutacompleta.indexOf("/copaamerica2007/") > 0) || (v_rutacompleta.indexOf("/libertadores2007/") > 0) || (v_rutacompleta.indexOf("/formula12007/") > 0) || (v_rutacompleta.indexOf("/panamericanos2007/") > 0) || (v_rutacompleta.indexOf("/mundialsub20/") > 0) || (v_rutacompleta.indexOf("/mundialsub17/") > 0) || (v_rutacompleta.indexOf("/copasudamericana2007/") > 0) || (v_rutacompleta.indexOf("/futbollatino/") > 0) || (v_rutacompleta.indexOf("/eliminatorias2010/") > 0) || (v_rutacompleta.indexOf("/pekin2008/") > 0) || (v_rutacompleta.indexOf("/mundialdeclubes07/") > 0) || (v_rutacompleta.indexOf("/libertadores2008/") > 0) || (v_rutacompleta.indexOf("/formula12008/") > 0))
      {v_return = "/deportes"+v_dato;
      } 
    else {

     v_datoback=v_dato;
      v_dato2=v_dato.charAt(v_dato.length-1);
      v_cadena="/";
      v_otracadena="|";
      while (v_datoback.indexOf(v_cadena) > -1) 
      {  v_dato3=v_datoback.indexOf(v_cadena);
         v_datoback=v_datoback.substring(0,v_dato3)+v_otracadena+v_datoback.substring(v_dato3+1,v_datoback.length);     
      }
      if (v_dato2 == '/')
       { v_dato=v_dato+"home/";
       }

    v_return = v_dato;
      }
return v_return;
}


//CERTIFICA.COM : CABECERA TERRA

/* Definición de variables*/
dominio=document.domain;
url=document.location.pathname;
rutacompleta=document.location.href;
dato=url;


/* Definición de variables para pruebas 
dominio="www.pe.terra.com";
url="/shared/tecnologia/";
rutacompleta="http://www.pe.terra.com/shared/tecnologia/";
document.writeln("<b>Dominio Utilizado:</b>      "+dominio+"<br>");
document.writeln("<b>Pathname:</b>      "+url+"<br>");
document.writeln("<b>Ruta completa o href: </b>"+rutacompleta+"<br>");
dato=url;
*/

//Se valida si la página está cargada en uno de los 3 dominios principales
//Se valida si la página está cargada en uno de los 3 dominios principales
if (dominio=="terra.com.pe" || dominio=="www.terra.com.pe" || dominio=="www.pe.terra.com" || dominio=="contenidos.terra.com.pe" )
 { //Validación de secciones tomando en cuenta las excepciones (ej:bienestar,saludybelleza y se elimina el SHARED
  vcertifica_path = cert_terra_secciones(rutacompleta, url);
  vcertifica_sitio=18873;
 }
else //Se valida si la página está en algún subdominio de TERRA y se carga el tráfico a una ruta, pudiendo redirigirlo a otra cuenta Metric
	{ 
	datoback=dato;
	dato2=dato.charAt(dato.length-1);
	cadena="/";
	otracadena="|";
	contador=0;
	contador2=0;
	while (datoback.indexOf(cadena) > -1) 
		{  dato3=datoback.indexOf(cadena);
		   datoback=datoback.substring(0,dato3)+otracadena+datoback.substring(dato3+1,datoback.length);
		   contador2=contador2+1;
		}
	if (dato2 == '/')
		{ dato=dato+"home/";
		}

	if (rutacompleta.indexOf("clientes.terra.com.pe") > 0)	
	{   vcertifica_path="/otras_secciones/clientes.terra"+dato;
		vcertifica_sitio=18873;
	}    
	else if (rutacompleta.indexOf("antivirusonline.terra.com.pe") > 0)
	{	vcertifica_path="/isp/antivirusonline"+dato;
		vcertifica_sitio=18873;
	}
	else if (rutacompleta.indexOf("betoortiz") > 0 || rutacompleta.indexOf("beto") > 0 )
	{	vcertifica_path="/beto_ortiz"+dato;
		vcertifica_sitio=18873;
	}
	else if (rutacompleta.indexOf("lahabitaciondehenryspencer") > 0 )
	{	vcertifica_path="/blog/lahabitaciondehenryspencer/"+dato;
		vcertifica_sitio=18873;
	}	
	else if (rutacompleta.indexOf("filtro.terra.com.pe") > 0)
	{	  vcertifica_path="/isp/filtro"+dato;
	      vcertifica_sitio=18873;
	}
	else if (rutacompleta.indexOf("discovirtual.terra.com.pe") > 0)
	{	  vcertifica_path="/isp/discovirtual"+dato;
	      vcertifica_sitio=18873;
	}
	else if (rutacompleta.indexOf("pe.invertia.com") > 0)
	{	  vcertifica_path="/invertia"+dato;
	      vcertifica_sitio=18873;
	}
	else if (rutacompleta.indexOf("yamanejo.terra.com.pe") > 0)
	{	vcertifica_path="/yamanejo"+dato;
	    vcertifica_sitio=18873;
	}
	else if (rutacompleta.indexOf("seguridad.terra.com.pe") > 0)
	{	vcertifica_path="/seguridad"+dato;
	    vcertifica_sitio=18873;
	}
	else if (rutacompleta.indexOf("atraeme.terra.com.pe") > 0)
	{	vcertifica_path="/atraeme"+dato;
	    vcertifica_sitio=18873;
	}
	else if (rutacompleta.indexOf("diccionario.terra.com.pe") > 0)
	{	vcertifica_path="/diccionario"+dato;
	    vcertifica_sitio=18873;
	}
	else if (rutacompleta.indexOf("fotolog.terra.com.pe") > 0)
	{	vcertifica_path="/fotolog"+dato;
	    vcertifica_sitio=18873;
	}
	else if (rutacompleta.indexOf("miramifoto.terra.com.pe") > 0)
	{	vcertifica_path="/miramifoto"+dato;
	    vcertifica_sitio=18873;
	}
	else if (rutacompleta.indexOf("postulante.terra.com.pe") > 0)
	{	vcertifica_path="/postulante"+dato;
	    vcertifica_sitio=18873;
	}
	else if (rutacompleta.indexOf("antivirus.terra.com.pe") > 0)
	{	vcertifica_path="/antivirus"+dato;
	    vcertifica_sitio=18873;
	}
	else if (rutacompleta.indexOf("conectadisney.terra.com.pe") > 0)
	{	vcertifica_path="/conectadisney"+dato;
	    vcertifica_sitio=18873;
	}
	else if (rutacompleta.indexOf("extranet.terra.com.pe") > 0)
	{	vcertifica_path="/extranet"+dato;

	    vcertifica_sitio=18873;
	}
	else if (rutacompleta.indexOf("www.rumbo.com.pe") > 0)
	{	vcertifica_path="/rumbo"+dato;
	    vcertifica_sitio=18873;
	}
	else if (rutacompleta.indexOf("buscador.terra.com.pe") > 0)
	{	vcertifica_path="/buscador"+dato;
	    vcertifica_sitio=18873;
	}
	else if (rutacompleta.indexOf("tiempo.terra.com.pe") > 0)
	{	vcertifica_path="/tiempo"+dato;
	    vcertifica_sitio=18873;
	}
	else if (rutacompleta.indexOf("secure.iquiero.com.com.pe") > 0)
	{	vcertifica_path="/iquiero"+dato;
	    vcertifica_sitio=18873;
	}
	else if (rutacompleta.indexOf("comprasenusa.pe.terra.com.com.pe") > 0)
	{	vcertifica_path="/compras_en_usa"+dato;
	    vcertifica_sitio=18873;
	}
	else if (rutacompleta.indexOf("correoweb.terra.com.pe") > 0 || rutacompleta.indexOf("webmail.terra.com.pe") > 0)
	{	vcertifica_path="/correo_web"+dato;
	    vcertifica_sitio=18873;
	}
	else if (rutacompleta.indexOf("portadamail.terra.com.pe") > 0)
	{	vcertifica_path="/correo_web/terramail"+dato;
		vcertifica_sitio=18873;
	}
	else if (rutacompleta.indexOf("correo.terra.com.pe") > 0)
	{	vcertifica_path="/correo_gratuito"+dato;
	    vcertifica_sitio=18873;
	}
	else if (rutacompleta.indexOf("sms.terra.com.pe") > 0)
	{	vcertifica_path="/sms"+dato;
	    vcertifica_sitio=18873;
	}
	else if (rutacompleta.indexOf("postales.pe.terra.com.com.pe") > 0)
	{	vcertifica_path="/postales"+dato;
	    vcertifica_sitio=18873;
	}
	else if ((rutacompleta.indexOf("cine.terra.com.pe") > 0) || (rutacompleta.indexOf("cartelera.com.pe") > 0) || (rutacompleta.indexOf("cineperu.com.pe") > 0) || (rutacompleta.indexOf("cines.com.pe") > 0) || (rutacompleta.indexOf("cine.com.pe ") > 0) )
	{ vcertifica_path="/cine"+dato;
	    vcertifica_sitio=18873;
	}
	else if ((rutacompleta.indexOf("terrarock.pe") > 0) || (rutacompleta.indexOf("terrarock.com.pe") > 0)  )
	{ vcertifica_path="/terrarock"+dato;
	    vcertifica_sitio=18873;
	}	
	else if (rutacompleta.indexOf("habla.chat-pe.terra.com.pe") > 0)
	{	vcertifica_path="/chat"+dato;
	    vcertifica_sitio=18873;
	}
	else if (rutacompleta.indexOf("habla02.chat-pe.terra.com.pe") > 0)
	{	vcertifica_path="/chat"+dato;
	    vcertifica_sitio=18873;
	}
	else if (rutacompleta.indexOf("terra.pe.laborum.com") > 0)
	{	vcertifica_path="/empleo"+dato;
	    vcertifica_sitio=18873;
	}
	else if (rutacompleta.indexOf("data.terra.com.pe") > 0)
	{	vcertifica_path=dato;
	    vcertifica_sitio=18873;
	}
	else if (rutacompleta.indexOf("habla03.chat-pe.terra.com.pe") > 0)
	{	vcertifica_path="/chat"+dato;
	     vcertifica_sitio=18873;
	}
	else if (rutacompleta.indexOf("habla01.chat-pe.terra.com.pe") > 0)
	{	vcertifica_path="/chat"+dato;
	     vcertifica_sitio=18873;
	 }
	else if (rutacompleta.indexOf("download.terra.com.pe") > 0)
	{	vcertifica_path="/download"+dato;
	     vcertifica_sitio=18873;
    }
	else if (rutacompleta.indexOf("terra-latinoamerica.softonic.com#pe") > 0)
	{	vcertifica_path="/download"+dato;
	     vcertifica_sitio=18873;
	 }
	else if (rutacompleta.indexOf("t-controla.terra.com.pe") > 0)
	{	vcertifica_path="/t_controla"+dato;
	     vcertifica_sitio=18873;
	}
	else if (rutacompleta.indexOf("t-responde.terra.com.pe") > 0)
	{	vcertifica_path="/t_responde"+dato;
	     vcertifica_sitio=18873;
	}
	else if (rutacompleta.indexOf("radio1160.terra.com.pe") > 0)
	{	vcertifica_path="/radio1160"+dato;
	     vcertifica_sitio=18873;
	 }
	else if (rutacompleta.indexOf("correoweb.bonus.com.pe") > 0)
	{	vcertifica_path="/correobonus"+dato;
	     vcertifica_sitio=18873;
	}
	else if (rutacompleta.indexOf("inmuebles.terra.com.pe") > 0)
	{	vcertifica_path="/inmuebles"+dato;
	     vcertifica_sitio=18873;
	}
	else if (rutacompleta.indexOf("almasgemelas.terra.com.pe") > 0)
	{	vcertifica_path="/almasgemelas"+dato;
	     vcertifica_sitio=18873;
	}
	else if (rutacompleta.indexOf("datamovil.terra.com.pe") > 0)
	{	vcertifica_path="/datamovil"+dato;
	     vcertifica_sitio=18873;
	 }
	else if (rutacompleta.indexOf("premiumcablenet.terra.com.pe") > 0)
	{	vcertifica_path="/premiumcablenet"+dato;
	     vcertifica_sitio=18873;
	}
	else if (rutacompleta.indexOf("videoblog") > 0)
	{	vcertifica_path="/videoblog"+dato;
	     vcertifica_sitio=18873;
	}	
	else if (rutacompleta.indexOf("games1") > 0)
	{	vcertifica_path="/games/"+dominio+dato;
	     vcertifica_sitio=18873;
	}		
	else if (rutacompleta.indexOf("marcablanca") > 0)
	{	vcertifica_path="/terramovil/ringtones_imagenes/"+dato;
	     vcertifica_sitio=18873;
	}	
	else if (rutacompleta.indexOf("blog.terra.com.pe") > 0)
	
	{ 
	
	blog_posicion = rutacompleta.lastIndexOf("blog.terra.com.pe"); 
	
	blog_seccion="/"+rutacompleta.substring(7,blog_posicion-1);
	
	vcertifica_path = "/blog"+blog_seccion+"/paginas_internas";
	
	vcertifica_sitio=18873;
	
	}
	

	else if (rutacompleta.indexOf("tusvideos.terra.com.pe") > 0)
	{	vcertifica_path="/tusvideos"+dato;
	     vcertifica_sitio=18873;
    }
	else if (rutacompleta.indexOf("gaia.terra.com.pe") > 0)
	{	 vcertifica_path="/gaia"+dato;
	     vcertifica_sitio=18873;
	}
	else if (rutacompleta.indexOf("match.terra") > 0)
	{	 vcertifica_path="/match"+dato;
	     vcertifica_sitio=18873;
	}	
	else   //Se envía el tráfico a "Otras Secciones" tomando el dominio y la ruta depurada.
	{	vcertifica_path="/otras_secciones/"+dominio+dato;
	    vcertifica_sitio=18873;		 
	}
}

nuevo_tag = false;
terra_info_service = "PubPE";
terra_info_channel = "";
terra_stats_idCrtfc = "";
terra_info_channeldetail = "";
terra_info_type = "";
terra_info_id = "";

if(vcertifica_path.indexOf("match")>0)
{
	nuevo_tag = true; 
	terra_info_channel = "pe.vidayestilo.almasgemelas";
	terra_stats_idCrtfc = "26014";
	terra_info_type = "cap";
	terra_info_id = dato;
} 

if(vcertifica_path.indexOf("correo_web")>0)
{
	nuevo_tag = true; 
	terra_info_channel = "pe.comunidad.email";
	terra_stats_idCrtfc = "26018";
	terra_info_type = "cap";
	terra_info_id = dato;	
	
	document.write('\n<script language="JavaScript" type="text/javascript">\n');
	document.write('<!-- \n');
	document.write('var flagConteoCorreo = "ok"; \n');
	document.write('//-->\n');
	document.write('</script>\n');	
}

if(vcertifica_path.indexOf("doloresdelirio")>-1)
{
	nuevo_tag = true;
	terra_info_channel = "pe.entretenimiento.musica";
	terra_info_channeldetail = "";
	terra_stats_idCrtfc = "25991";	
	terra_info_type = "cap";	
		
	terra_info_id = dato.replace("\/doloresdelirio\/",""); 
	//El home tiene su propio tag
}

if(vcertifica_path.indexOf("games")>0)
{
	nuevo_tag = true; 
	terra_info_channel = "pe.entretenimiento.games";
	terra_info_channeldetail = "games1.terra.com.pe";
	terra_stats_idCrtfc = "24025";
	terra_info_type = "cap";
	terra_info_id = dato.replace("home\/","home"); 
} 

if(vcertifica_path.indexOf("terrarock")>0)
{
	nuevo_tag = true; 
	terra_info_channel = "pe.entretenimiento.musica";
	terra_info_channeldetail = "terrarock";
	terra_stats_idCrtfc = "25989";
	terra_info_type = "cap";
	terra_info_id = dato.replace("\/terrarock",""); 
	terra_info_id = terra_info_id.replace("home\/","home"); 
} 


if(nuevo_tag)
{
	document.write('\n<script language="JavaScript" type="text/javascript">\n');
	document.write('<!-- \n');
	document.write('var terra_info_service = "' + terra_info_service + '";\n');
	document.write('var terra_info_channel = "' + terra_info_channel + '";\n');
	document.write('var terra_stats_idCrtfc = ' + terra_stats_idCrtfc + ';\n');
	document.write('var terra_info_channeldetail = "' + terra_info_channeldetail + '";\n');
	document.write('var terra_info_type = "' + terra_info_type + '";\n');
	document.write('var terra_info_id = "' + terra_info_id + '";\n');

	document.write('//-->\n');
	document.write('</script>\n');

	document.write('<script type="text/javascript" charset="iso-8859-1" language="javascript" src="http://s1.trrsf.com/metrics/js/pe/content.js"></script>\n');
	document.write('<script language="javascript">if(typeof terra_stats_metrics=="undefined"){var terra_stats_metrics=function(){window.setTimeout("terra_stats_metrics()",500);}}terra_stats_metrics();</script>');

}
else
{

		terra_info_service = "PubPE";
		terra_info_channel = "pe.portada.portada";
		terra_stats_idCrtfc = "18873";
		terra_info_channeldetail = "otrocontenido";
		terra_info_type = "pag";
		terra_info_id = vcertifica_path;

		document.write('\n<script language="JavaScript" type="text/javascript">\n');
		document.write('<!-- \n');
		document.write('var terra_info_service = "' + terra_info_service + '";\n');
		document.write('var terra_info_channel = "' + terra_info_channel + '";\n');
		document.write('var terra_stats_idCrtfc = ' + terra_stats_idCrtfc + ';\n');
		document.write('var terra_info_channeldetail = "' + terra_info_channeldetail + '";\n');
		document.write('var terra_info_type = "' + terra_info_type + '";\n');
		document.write('var terra_info_id = "' + terra_info_id + '";\n');

		document.write('//-->\n');
		document.write('</script>\n');

		document.write('<script type="text/javascript" charset="iso-8859-1" language="javascript" src="http://s1.trrsf.com/metrics/js/pe/content.js"></script>\n');
		document.write('<script language="javascript">if(typeof terra_stats_metrics=="undefined"){var terra_stats_metrics=function(){window.setTimeout("terra_stats_metrics()",500);}}terra_stats_metrics();</script>');


}
/* Para pruebas
document.writeln("<br><br>");
document.writeln("<b>Sitio id Obtenido:</b>      "+vcertifica_sitio);
document.writeln("<br>");
document.writeln("<b>Ruta Obtenida:</b>      "+vcertifica_path);
*/
//SITIO_ID DE TERRA : 18873
