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,"");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;}function cert_getProtocol(){if(window&&window.location&&window.location.protocol){return window.location.protocol;}return null;}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;}
/*@cc_on
	for(var i = 10; i > 0; i--) {
		try {
			var flash = new ActiveXObject("ShockwaveFlash.ShockwaveFlash." + i);
			flashVersion = i;
			break;
		} catch(e){}
	}	
	@*/
}}return flashVersion;}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;}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);}function cert_getURL_CustomSearch(iSiteId,sPath,sSearchString){cert_customSearch=true;cert_addExtraReferrerParm("q",sSearchString);return cert_getURL(iSiteId,sPath);}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);}}}function cert_registerHitAndRedirect(sURL,iSiteId,sPath,sPivotName){cert_registerHit(iSiteId,sPath,sPivotName);setTimeout("location.href = '"+sURL+"'",DEFAULT_REDIRECT_TIME);}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;}function cert_registerHitAndReplaceOtherFrame(sURL,sName,iSiteId,sPath,sPivotName){cert_registerHitAndOpenWindow(sURL,iSiteId,sPath,sPivotName,sName,0,true);}function cert_registerHitAndReplaceThisFrame(sURL,iSiteId,sPath,sPivotName){cert_registerHitAndRedirect(sURL,iSiteId,sPath,sPivotName);}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">';}function cert_getNormalizedURL(iSiteId,sPath,sDesc){sAppend=null;if(sPath.toLowerCase()=="url"){sPath=location.pathname;}if(!sDesc){sDesc=document.title;}if(sDesc){sAppend="&descr="+escape(sDesc.substr(0,30));}sPath=cert_normalizePath(sPath);return cert_getURL(iSiteId,sPath,sAppend);}function tagCertifica(iSiteId,sPath,sDesc){sURL=cert_getNormalizedURL(iSiteId,sPath,sDesc);document.writeln('<img src="'+sURL+'" width="1" height="1" border="0" alt="Certifica.com">');}function tagCertifica_eCommerce(iSiteId,sPath,iAmount){document.writeln(cert_getAnchor(cert_getURL_eCommerce(iSiteId,sPath,iAmount)));}function tagCertifica_CustomSearch(iSiteId,sPath,sSearchString){document.writeln(cert_getAnchor(cert_getURL_CustomSearch(iSiteId,sPath,sSearchString)));}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();

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 minutos en el cual se deber� hacer autorefresh
 *
 */
function cert_Refresh( iTime ) {
  var refreshTime;
  refreshTime = ((iTime) ? iTime*60*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) 
{
    hr=escape(document.location);
    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 + hr;
       document.writeln( '<img src="' + url + '" width="1" height="1" border="0" alt="Certifica.com">' );
    }
}
