﻿
var sPath = "http://blstc.msn.com/br/intl/spec/pt-br/ie8-hotmail/";
document.getElementById('div_ie8').style.display = 'none';

if (location.href.indexOf("intelygenz.com")!=-1){	//DEV
//	sPath = "http://almax/msn_msn/msn07_aspnet2/www/msn10_canales/especiales/ms06_ie8_launcher/";
	sPath = ""
}

//document.write('<scr'+'ipt src="http://217.116.22.243/especiales/libs/msn_i_hits.js" type="text/javascript"></scr'+'ipt>');
document.write('<DIV id="reporting">');
document.write('	<scr'+'ipt type="text/javascript">var s_account="msnportalbrilovemessenger";</scr'+'ipt>');
document.write('	<scr'+'ipt src="http://blstj.msn.com/br/om/js/s_code.js" type="text/javascript"></scr'+'ipt>');
document.write('	<IMG id="ctag">');
document.write('	<DIV id="omni">');
document.write('	</DIV>');
document.write('	<SCR'+'IPT type="text/javascript"><!--if(navigator.appVersion.indexOf("MSIE")>=0)document.write(unescape("%3C")+"\!-"+"-")//--></SCR'+'IPT>');
document.write('</DIV>');

document.write('<scr'+'ipt src="http://www.microsoft.com/brasil/msn/hotmail/js/jquery131.js" type="text/javascript"></scr'+'ipt>');
document.write('<scr'+'ipt src="http://www.microsoft.com/brasil/msn/hotmail/js/script.js" type="text/javascript"></scr'+'ipt>');

var t;
// Datos para el TAGGING
var nDI = 14144, nPI = 9566, nPS = 72694;
g_sCtag = "http://c.br.msn.com/c.gif?di="+ nDI +"&pi="+ nPI +"&ps="+ nPS +"&tp="+ document.location.href +"&rf=";

// Si el usuario tiene IE8 o Windows Seven, redirigimos automaticamente
if (ValidaVersionIE()) {
	document.location.href="http://mail.live.com";
} else {
	InnerPage();
}
//inicia secuencia de test
//guarda la cookie
GuardarCookie("miGalleta", "test")
mifecha=new Date();
if(CogerCookie("iniciopromo")==null) GuardarCookie("iniciopromo", mifecha.getTime())
//espera 1 segundo (algunos navegadores requieren un tiempo para guardar la cookie)
if(CogerCookie("iniciopromo")!=0) {
	setTimeout("startit()",1000);
} else {
	document.location.href="http://mail.live.com";
}

//COMPROBACION DE COOKIES HABILITADAS
//Autor: Iv&aacute;n Nieto P rez
//Este script y otros muchos pueden
//descarse on-line de forma gratuita
//en El C&oacute;digo: www.elcodigo.com
function CogerValorCookie(indice) {
    //indice indica el comienzo del valor
    var galleta = document.cookie
    //busca el final del valor, dado por ;, a partir de indice
    var finDeCadena = galleta.indexOf(";", indice)
    //si no existe el ;, el final del valor lo marca la longitud total de la cookie
    if (finDeCadena == -1)
        finDeCadena = galleta.length
    return unescape(galleta.substring(indice, finDeCadena))
}

function CogerCookie(nombre) {
    var galleta = document.cookie
    //construye la cadena con el nombre del valor
    var arg = nombre + "="
    var alen = arg.length           //longitud del nombre del valor
    var glen = galleta.length       //longitud de la cookie
    var i = 0
    while (i < glen) {
        var j = i + alen                    //posiciona j al final del nombre del valor
        if (galleta.substring(i, j) == arg) //si en la cookie estamo ya en nombre del valor
            return CogerValorCookie(j)      //devuleve el valor, que esta a partir de j
        i = galleta.indexOf(" ", i) + 1     //pasa al siguiente
        if (i == 0)
            break                           //fin de la cookie
    }
    return null                             //no se encuentra el nombre del valor
}

function GuardarCookie (nombre, valor) {
    //crea la cookie: incluye el nombre y la ruta donde esta guardada
    //cada valor esta separado por ; y un espacio
//    document.cookie = nombre + "=" + escape(valor) + "; path=/"

		// Ejemplo del uso de Cookies con fecha de expiraci n, que viene dada en d as en el parametro 'expiredays'
		var exdate = new Date();
		exdate.setDate(exdate.getDate() + 365);
		document.cookie = nombre + "=" + escape(valor) + "; expires="+exdate.toGMTString() + "; path=/";
}

function CheckIE() {
	return (navigator.appName == "Microsoft Internet Explorer");
}

function ValidaVersionIE() {
	var oUserAgent = window.navigator.userAgent.toLowerCase();
	var nVersion = parseFloat( oUserAgent.substring( oUserAgent.indexOf('msie ') + 5 ) );
	// validamos si el navegador es IE8 o si el usuario tiene Windows 7
	//if( (CheckIE() && nVersion == 8) || (navigator.userAgent.indexOf("Windows NT 6.1") > -1) ) {
	if( (CheckIE() && nVersion == 8) ) {
		return true;
	} else {
		if( (CheckIE() && (navigator.userAgent.indexOf("Windows NT 6.1") > -1)) ) {	
			return true;
		} else {
			return false;
		}
	}
}



//lee la cookie y muestra un mensaje u otro en funcion de que la lectura tenga exito o no
function BorraCookiep(name) {
	var cookie_date = new Date ();  // current date & time
	cookie_date.setTime ( cookie_date.getTime() - 1 );
	document.cookie = name+"=;expires=" + cookie_date.toGMTString();
}
function BorraCookie(name) {
  var date = new Date();
  date.setTime(date.getTime()+(-1*24*60*60*1000));
  var expires = "; expires="+date.toGMTString();
  document.cookie = name+"=undefined"+expires;
}

function ira() {
	clearTimeout(t);
	document.location.href = "http://mail.live.com";
}
function IrBandeja() {
	if ( document.getElementById('norecordar').checked ) {
		GuardarCookie("iniciopromo", 0);		
	}
	var nVez = Number(CogerCookie("vez"));
	if (nVez != null) {
		GuardarCookie("vez", (nVez % 3) + 1 );
	}
	clearTimeout(t);
	document.location.href = "http://mail.live.com";
}

function Descargar(nVersion) {
	//clearTimeout(t);
	if ( document.getElementById('norecordar').checked ) {
		GuardarCookie("iniciopromo", 0);		
	}
	var sDownload = "";
	if ( !CheckIE() ) sDownload = "noie";
	switch( nVersion ) {
		case 1:
			document.location.href = "http://www.microsoft.com/brasil/windows/internet-explorer/default.aspx?WT.mc_id=1636"
			break;
		case 2:
			document.location.href = "http://www.microsoft.com/brasil/windows/internet-explorer/default.aspx?WT.mc_id=1637"
			//if (navigator.platform == "Win32") {
				//document.location.href = "http://www.vivelive.com/sniffingvista32" + sDownload;
			//} else {
				//document.location.href = "http://www.vivelive.com/sniffingvista64" + sDownload;
			//}
			break;
		case 3:
			//document.location.href = "http://g.msn.com/1me10IE8eses/103";
			break;
	}
}

function startit() {
	t=setTimeout("ira()", 30000); //va a destino despues de 30ss
//		if(CogerCookie("vez") >= 3) document.location.href="http://mail.live.com";

	if ( CogerCookie("miGalleta") == "test" ) {
  	var one_day = 1000 * 60 * 60 * 24;
    // Calculamos el parcial reiniciandolo cada 30 d as
    parcial = Math.floor((mifecha.getTime() - CogerCookie("iniciopromo")) / one_day) % 30;

    if (parcial >= 0 && parcial < 5 && CogerCookie("vez") == 1) {
			document.location.href="http://mail.live.com";
		}	else {
			if (parcial >= 5 && parcial < 10 && CogerCookie("vez") == 2) {
				document.location.href="http://mail.live.com";
			} else {
				if(parcial >= 10 && parcial < 31 && CogerCookie("vez") == 3) {
					document.location.href="http://mail.live.com";
				}
			}
		}
	}	else {
		document.location.href="http://mail.live.com"
	}
}

function InnerPage(){
	var oDiv = document.getElementById ("div_ie8")
	document.getElementById('div_ie8').style.display = '';
	if (oDiv){
		oDiv.innerHTML = DrawPage()
	}
}

function DrawPage(){
	sHTML = ""
	sHTML += "<div class='wrapper'>"
	sHTML += "  <img src='"+sPath+"logoWL.jpg' width='175' height='23' alt='Windows Live' />"
	sHTML += "  <div class='contenido'>"
	sHTML += "  	<br /><br />"
	if ( CheckIE() ) {
		sHTML += "  	<div id='mastertitle'>Alerta de Segurança: Seu navegador está desatualizado!<BR /></div>"
	} else {
		sHTML += "  	<div id='mastertitle'>O Hotmail recomenda o download gratuito do novo Internet Explorer 8<BR /></div>"
	}
	sHTML += "    <BR />"
	sHTML += " 		<div class='derecha'>"
	sHTML += "      <img src='"+sPath+"logoIE8.jpg' width='225' height='34' alt='Internet Explorer 8' />"
	sHTML += "      <br /><br />"
	sHTML += ""
	sHTML += "      <div id='winXp'>"
//	sHTML += "      	<a href='http://www.vivelive.com/sniffingxp'><img src='http://www.vivelive.com/internetexplorer8/img/img_descarga_winxp.gif' width='245' height='48' alt='Instalar ahora' /></a>"
	if ( CheckIE() ) {
		sHTML += "      	&nbsp;&nbsp;&nbsp;&nbsp;<a href='#' onclick='Descargar(1);return false;'><img src='"+sPath+"instalar-agora.jpg' width='218' height='48' alt='Instalar agora' /></a>"
	} else {
		sHTML += "      	&nbsp;&nbsp;&nbsp;&nbsp;<a href='#' onclick='Descargar(2);return false;'><img src='"+sPath+"instalar-agora.jpg' width='218' height='48' alt='Instalar agora' /></a>"	
	}
	sHTML += "      </div>"
	
	sHTML += "      &nbsp;&nbsp;&nbsp;&nbsp;<a href='#' onclick='IrBandeja()'><img src='"+sPath+"bot_ircaixa.jpg' width='214' height='50' alt='Ir para a Caixa de Entrada' /></a>"
	sHTML += "      <br />"
	sHTML += "      <span style='margin-left: 35px; font-family: Verdana; font-size: 11px;'><input type='checkbox' id='norecordar' name='k_noRecordar' alt='Não recordar' />&nbsp;Não exibir mais esta mensagem</span>"
	sHTML += "		</div><!-- fin derecha-->"

	sHTML += "   	<span class='linea'>"
	sHTML += "     	<img src='"+sPath+"linea_separacion.jpg' width='1' height='291' alt='.' />"
	sHTML += "     	<img src='http://www.vivelive.com/internetexplorer8/img/pix-cookiesie8.gif' width='1' height='1' alt='' />"
	sHTML += "   	</span>"
	sHTML += " 		<div class='izquierda'>"
	sHTML += " 		<table id='tabla' width='100%' border='0'>"
	//if ( CheckIE() ) {
    sHTML += " 			<tr><td colspan='2' style='font-family: Verdana;'>O Hotmail recomenda que você baixe gratuitamente o novo Internet Explorer 8. Por que você deve baixar?<br /></td></tr>"
	//}
	sHTML += " 		<tr><td><img src='"+sPath+"bot-mail.jpg' class='img_btn' /></td><td valign='middle'><strong>Hotmail em apenas um clique:</strong> acelere o acesso aos seus e-mails usando a barra de ferramentas.</td></tr>"
	sHTML += " 		<tr><td><img src='"+sPath+"bot-lupa.jpg' class='img_btn' /></td><td valign='middle'><strong>Privacidade</strong>: ative o <strong>modo seguro</strong> e navegue na Internet sem deixar nenhum rastro.</td></tr>"
	sHTML += " 		<tr><td><img src='"+sPath+"bot-candado.jpg' class='img_btn' /></td><td valign='middle'><strong>Segurança</strong>: deixe que o filtro SmartScreen elimine o lixo eletrônico para você.</td></tr>"
	sHTML += " 		</table>"
	sHTML += " 		</div><!-- fin izquierda-->"

	sHTML += "  </div>"
	sHTML += "</div>"

	return sHTML
}

function PageHit() {
	s.charSet='UTF-8';
	s.linkInternalFilters='javascript:,specials.br.msn.com';
	s.pageName='ie8intercept';
	s.server='specials.br.msn.com';
	s.prop1='BR_Specials';
	s.prop2='pt-br';
	s.channel='specials.br.msn.com';
	s.prop22='False';
	s.prop25='';
	s.prop26='';
	s.prop3='ie8interceptpage';
	s.prop4='ie8interceptpage';
	s.prop5='Iie8interceptpage';
	s.prop49='';
	s.prop50=escape(document.URL);
	s.eVar1=s.getQueryParam('cp-documentid');
	s.prop11='';
	s.prop37='';

	GenerarPageHit();
}


function GenerarPageHit(a_sOmni){

	var oS,f,s_code;
	var sError = "init";
	try{
		sError = "No existe s o g_oTagsDoc da error";
		var oDoc = document;
		if (g_oTagsDoc) {
			oDoc = g_oTagsDoc.document
			oS = g_oTagsDoc.s
		}
		else{
			oS = s
		}
		if(oDoc.getElementById('omni')){
			sError = "Error con a_sOmni";
			if (a_sOmni){
				for (f=0;f<a_sOmni.length;f=f+2){
					oS[a_sOmni[f]] = a_sOmni[f+1]	
				}	
			}
			sError = "Error con s_code";
			s_code= oS.t();
			if(s_code) oDoc.write(s_code);
		}
		if (!g_oCtag) g_oCtag = oDoc.getElementById('ctag')
		if(g_oCtag){
			if (!g_sCtag) g_sCtag = g_oCtag.src
			g_oCtag.src=g_sCtag+"&"+new Date().getTime();
		}
	}
	catch(Ex){
		status = "GenerarPageHit:"+sError+"."+Ex;	//+ Ex;
		return;
	}

} 


if ( window.addEventListener ) {	// Estandar DOM
	window.addEventListener("load", function (){ PageHit(); return false; }, false);
}	else if(window.attachEvent) {	//IE7
	var bOk = window.attachEvent("onload", function (){ PageHit(); return false; });
} else {					// Navegadores antiguos
	window.onload = function (){ PageHit(); return false; }
}
