// Habilita / Desabilita a notificacao de eventos
__UNEAR_ENABLE_NOTIFICATION__ = true;

if (location.host == "www.assineabril.com.br") {
	// Endereco do servidor do U.Web
	__UNEAR_SERVER_URL__ = "http://secure.unear.com/abril/UwebServer/Uweb.ashx";
	// Endereco do servidor seguro do U.Web
	__UNEAR_SERVER_HTTPS_URL__ = "https://secure.unear.com/abril/UwebServer/Uweb.ashx";
}
else {
	// Endereco do servidor do U.Web
	__UNEAR_SERVER_URL__ = "http://200.244.55.210/UWebServer/Uweb.ashx";
	// Endereco do servidor seguro do U.Web
	__UNEAR_SERVER_HTTPS_URL__ = "http://200.244.55.210/UWebServer/Uweb.ashx";
}

// Valores default para encerramento de sessão
__UNEAR_Default_Exit_01__ = true;
__UNEAR_Default_Exit_02__ = "Geral";

//(auto|none|dominio) Coloca nome do dominio no cookie
__UNEAR_COOKIE_DOMAIN__ = "auto";

/*******  Unear U.Web API. U.NEAR (c) 2009.  *******/

UNEAR_JSRequest_IdCounter=1;UNEAR_JSRequest.prototype.uwv="ga1c4";function UNEAR_JSRequest(A){this.url=A;this.id=UNEAR_JSRequest_IdCounter++;this.AddParameter("js",this.id);this.AddParameter("r",Math.floor(Math.random()*10000))}UNEAR_JSRequest.prototype.AddParameter=function(A,B){if(B==undefined||B==null||B===""||this.HasParameter(A)){return }if(this.url.indexOf("?")>=0){this.url+="&"+A+"="+encodeURIComponent(B)}else{this.url+="?"+A+"="+encodeURIComponent(B)}};UNEAR_JSRequest.prototype.HasParameter=function(B){var C=this.url.indexOf("?");var A=this.url.indexOf("=",C);while(C!=-1&&A!=-1){if(this.url.substring(C+1,A)==B){return true}C=this.url.indexOf("&",A);A=this.url.indexOf("=",C)}return false};UNEAR_JSRequest.prototype.Send=function(){this.AddParameter("uwurl",window.location.href);this.AddParameter("ume",1);var A=document.createElement("script");A.src=this.url.replace(/ /g,"+");A.id="__unear_javascript__"+this.id;A.type="text/javascript";A.request_time=new Date().getTime();A.onResponse=this.OnResponse;document.getElementsByTagName("head")[0].appendChild(A)};function UNEAR_Session(){this.hc=this.GetCookie("uwhc");if(!this.hc){this.uwuid=this.GetCookie("anom_user_id");this.uwluid=this.GetCookie("user_id");if(this.uwuid){this.SetCookie("anom_user_id",this.uwuid,100000);document.cookie="anom_user_id=;expires=Thu, 01-Jan-1970 00:00:01 GMT"}if(this.uwluid){this.SetCookie("user_id",this.uwluid,100000);document.cookie="user_id=;expires=Thu, 01-Jan-1970 00:00:01 GMT"}this.SetCookie("uwhc","1",100000);this.hc=1}if(this.hc&&this.hc==1){this.uwluid=this.GetCookie("user_id");if(this.uwluid&&this.uwluid.indexOf("DBM_")>-1){this.DeleteCookie("user_id")}this.SetCookie("uwhc","2",100000);this.hc=2}}UNEAR_Session.prototype.Initialize=function(){this.GetId();this.GetUser();this.SetReferrer()};UNEAR_Session.prototype.GetDomain=function(){if(__UNEAR_COOKIE_DOMAIN__=="auto"){var A=document.domain;if(A.substring(0,4)=="www."){A=A.substring(4,A.length)}__UNEAR_COOKIE_DOMAIN__=A}else{if(__UNEAR_COOKIE_DOMAIN__=="none"){__UNEAR_COOKIE_DOMAIN__=null}}return __UNEAR_COOKIE_DOMAIN__};UNEAR_Session.prototype.GenerateID=function(){var H=navigator.userAgent.length-1;var A="",B;for(B=0;B<32;B++){var F=navigator.userAgent.charCodeAt((4*B)%H);var E=navigator.userAgent.charCodeAt((4*B+1)%H);var D=navigator.userAgent.charCodeAt((4*B+2)%H);var C=navigator.userAgent.charCodeAt((4*B+3)%H);var G=(Math.random()*255+F+E+D+C)%16;A+=Math.floor(G).toString(16).toLowerCase()}return A.substring(0,8)+"-"+A.substring(8,12)+"-"+A.substring(12,16)+"-"+A.substring(16,20)+"-"+A.substring(20,32)};UNEAR_Session.prototype.GetReferrer=function(){return this.GetCookie("referrer")};UNEAR_Session.prototype.SetReferrer=function(){if(this.GetReferrer()==null){this.SetCookie("referrer",document.referrer,0)}};UNEAR_Session.prototype.IsLogged=function(){var A=this.GetCookie("logged");if(A==null){return false}return A};UNEAR_Session.prototype.GetUser=function(){var A=this.GetCookie("anom_user_id");if(A!=null){return A}else{return this.GenerateUserId()}};UNEAR_Session.prototype.GetLoggedUser=function(){return this.GetCookie("user_id")};UNEAR_Session.prototype.Login=function(A){if(this.GetLoggedUser()!=null&&this.GetLoggedUser()!=A){this.GenerateUserId();this.GenerateSessionId()}this.SetCookie("user_id",A,100000);this.SetCookie("logged",true,0)};UNEAR_Session.prototype.Logoff=function(){this.DeleteCookie("logged")};UNEAR_Session.prototype.GetId=function(){var A=this.GetCookie("session_id");if(A==null){return this.GenerateSessionId()}else{return A}};UNEAR_Session.prototype.GenerateSessionId=function(){var A="session_"+this.GenerateID();this.SetCookie("session_id",A,0);return A};UNEAR_Session.prototype.GenerateUserId=function(){var A="user_"+this.GenerateID();this.SetCookie("anom_user_id",A,100000);return A};UNEAR_Session.prototype.GetCookie=function(A){var D=document.cookie.split(";");for(var B in D){var C=D[B].split("=");if(C.length>1){var E=C[0].replace(/^\s+|\s+$/g,"");if(E==A){if(C.length<2){return""}return decodeURIComponent(C[1].replace(/^\s+|\s+$/g,""))}}}return null};UNEAR_Session.prototype.SetCookie=function(C,D,A){var E=null;if(A){var B=new Date();B.setTime(new Date().getTime()+A*8640000);E=B.toGMTString()}if(D==null){D=""}cookieDomain=this.GetDomain();cookiePath="/";document.cookie=C+"="+encodeURIComponent(D)+(cookiePath?(";path="+cookiePath):"")+(A?(";expires="+E):"")+(cookieDomain?(";domain=."+cookieDomain):"")};UNEAR_Session.prototype.DeleteCookie=function(A){cookieDomain=this.GetDomain();cookiePath="/";if(this.GetCookie(A)){document.cookie=A+"="+(cookiePath?(";path="+cookiePath):"")+";expires=Thu, 01-Jan-1970 00:00:01 GMT"+(cookieDomain?(";domain=."+cookieDomain):"")}};function UnearUWeb(){this.ServerLocation=(document.location.protocol=="https:")?__UNEAR_SERVER_HTTPS_URL__:__UNEAR_SERVER_URL__;this.session=new UNEAR_Session();this.session.Initialize();this.MaxWait=5000}UnearUWeb.prototype.BuildEmptyRequest=function(){var req=new UNEAR_JSRequest(this.ServerLocation);var self=this;var userId=this.session.GetLoggedUser();req.AddParameter("sessionId",this.session.GetId());req.AddParameter("userId",this.session.GetUser());if(userId){req.AddParameter("loggedUserId",userId)}req.AddParameter("logged",this.session.IsLogged());var referrer=this.session.GetReferrer();if(referrer!=""){req.AddParameter("referrer",referrer)}req.AddParameter("Url",window.location.href);req.AddParameter("screenResolution",screen.width+" x "+screen.height+" x "+screen.colorDepth);req.RequestTime=new Date().getTime();req.MaxWait=this.MaxWait;req.OnResponse=function(response){var dt=new Date().getTime()-req.RequestTime;if(dt<req.MaxWait){eval(response);var uweb_content=eval("__uweb_content__"+req.id);if(uweb_content&&uweb_content.db){self.session.SetCookie("dbm",uweb_content.db)}if(uweb_content&&uweb_content.bo){self.session.SetCookie("bo",uweb_content.bo)}if(uweb_content&&uweb_content.es&&uweb_content.es.length>=2){self.session.SetCookie("exit_0",(uweb_content.es[0].toLowerCase()=="true"),0);self.session.SetCookie("exit_1",uweb_content.es[1],0)}if(uweb_content&&uweb_content.ct){req.content=uweb_content.ct;for(var i=0;i<req.content.length;i++){el=document.getElementById(req[i]);if(req[i]&&el){el.innerHTML=req.content[i]}}if(typeof (req.callback)=="function"){req.callback(uweb_content.ct)}}}};req.DefineTimeout=function(timeout){this.MaxWait=timeout};req.EnviaRequisicao=function(){this.Send()};req.DefineRetorno=function(callbackFunction){req.callback=callbackFunction;if(req.content){callbackFunction(req.content)}};req.DefineConteudo=function(i,elementId){req[i]=elementId;if(req.content&&req.content[i]){document.getElementById(elementId).innerHTML=req.content[i]}};return req};UnearUWeb.prototype.BuildRequest=function(B,A){var C=this.BuildEmptyRequest();C.AddParameter("interactionType",B);C.AddParameter("eventObject",A);return C};UnearUWeb.prototype.GetUser=function(){return this.session.GetLoggedUser()};UnearUWeb.prototype.IsLogged=function(){return this.session.IsLogged()};UnearUWeb.prototype.Logoff=function(){var A=this.session.GetLoggedUser();request=this.BuildRequest("Logoff","Logoff");this.session.Logoff();return request};UnearUWeb.prototype.Login=function(A){if(A!=""){this.session.Login(A)}return this.BuildRequest("Login","Login")};UnearUWeb.prototype.ProcessEvent=function(B,A){this.BuildRequest(B,A).Send()};UnearUWeb.prototype.SendRequest=function(B){try{if(B==null){return }if(!(__UNEAR_ENABLE_NOTIFICATION__)){return }B.AddParameter("internalSource",this.session.GetCookie("internalSource"));B.AddParameter("partner",this.session.GetCookie("partner"));B.AddParameter("source",this.session.GetCookie("source"));B.AddParameter("subSource",this.session.GetCookie("subSource"));var E=this.session.GetCookie("bo");var A=this.session.GetCookie("dbm");var C=this.session.GetCookie("eDbm");if(E){B.AddParameter("bo",E)}if(A){B.AddParameter("db",A)}else{if(C){B.AddParameter("edbm",C);this.session.DeleteCookie("eDbm")}}B.Send()}catch(D){}};UnearUWeb.prototype.EncerraSessao=function(){var C=this.BuildEmptyRequest();C.AddParameter("interactionType","EndSession");this.SendRequest(C);var B=this.session.GetCookie("exit_0");var A=this.session.GetCookie("exit_1");if(B==null){B=__UNEAR_Default_Exit_01__}if(A==null){A=__UNEAR_Default_Exit_02__}return[B,A]};UnearUWeb.prototype.EventoPageView=function(I,F,D,B,C,G,J,A,K){try{var E=this.BuildRequest("PageView",I);E.AddParameter("objectCategory",F);E.AddParameter("campaign",D);E.AddParameter("campaignName",B);E.AddParameter("campaignType",C);E.AddParameter("campaignTypeCategory",G);E.AddParameter("itemCode",J);E.AddParameter("itemName",A);E.AddParameter("signaturePeriod",K);this.SendRequest(E);return E}catch(H){}};UnearUWeb.prototype.EventoBannerClick=function(G,C,B,A,F){try{var D=this.BuildRequest("BannerClick",G);D.AddParameter("campaign",C);D.AddParameter("campaignName",B);D.AddParameter("campaignType",A);D.AddParameter("campaignTypeCategory",F);this.SendRequest(D)}catch(E){}};UnearUWeb.prototype.EventoBannerClickLink=function(G,C,B,A,F,E){try{this.EventoBannerClick(G,C,B,A,F);window.location=E}catch(D){}};UnearUWeb.prototype.EventoTransacao=function(L,E,M,F,C,D,H,B,J,K,O,A,N){try{var G=this.BuildRequest("Transaction",L);G.AddParameter("objectCategory",N);G.AddParameter("moneyValue",E);G.AddParameter("signaturePeriod",M);G.AddParameter("campaign",F);G.AddParameter("campaignName",C);G.AddParameter("campaignType",D);G.AddParameter("campaignTypeCategory",H);G.AddParameter("payForm",B);G.AddParameter("payMethod",J);G.AddParameter("orderCode",K);G.AddParameter("itemCode",O);G.AddParameter("itemName",A);this.SendRequest(G)}catch(I){}};UnearUWeb.prototype.EventoLogin=function(A){try{this.session.DeleteCookie("bo");this.session.DeleteCookie("dbm");this.SendRequest(this.Login(A))}catch(B){}};UnearUWeb.prototype.EventoLogoff=function(){try{this.session.DeleteCookie("bo");this.session.DeleteCookie("dbm");this.SendRequest(this.Logoff())}catch(A){}};UnearUWeb.prototype.DefineOrigem=function(D,A,B){try{this.session.SetCookie("partner",D,0);this.session.SetCookie("source",A,0);this.session.SetCookie("subSource",B,0)}catch(C){}};UnearUWeb.prototype.DefineOrigemInterna=function(A){try{this.session.SetCookie("internalSource",A,0)}catch(B){}};UnearUWeb.prototype.RegistraDBM=function(B){try{var A=this.session.GetCookie("dbm");if((A==null)&&(this.session.GetLoggedUser()==null)&&(this.ValidaDbm(B))){this.session.SetCookie("eDbm",B,0);this.session.SetCookie("user_id","DBM_"+B,100000)}}catch(C){}};UnearUWeb.prototype.ClearParameters=function(){try{this.genericRequest=this.BuildEmptyRequest()}catch(A){}};UnearUWeb.prototype.AddParameter=function(A,B){try{if(this.genericRequest==null){ClearParameters()}this.genericRequest.AddParameter(A,B)}catch(C){}};UnearUWeb.prototype.Notify=function(){try{SendRequest(this.genericRequest)}catch(A){}};UnearUWeb.prototype.ValidaDbm=function(C){var A="0123456789";var D;var B=true;if(C.length==0){return false}for(i=0;i<C.length&&B==true;i++){D=C.charAt(i);if(A.indexOf(D)==-1){B=false}}return B};