$win=window;$doc=$win.document;
// jXHR.js (JSON-P XHR)
// v0.1 (c) Kyle Simpson
// MIT License
(function(c){var b=c.setTimeout,d=c.document,a=0;c.jXHR=function(){var f,h,o,i,n=null;function m(){try{i.parentNode.removeChild(i)}catch(p){}}function l(){h=false;f="";m();i=null;j(0)}function g(q){try{n.onerror.call(n,q,f)}catch(p){throw new Error(q)}}function k(){if((this.readyState&&this.readyState!=="complete"&&this.readyState!=="loaded")||h){return}this.onload=this.onreadystatechange=null;h=true;if(n.readyState!==4){g("Script failed to load ["+f+"].")}m()}function j(p,q){q=q||[];n.readyState=p;if(typeof n.onreadystatechange==="function"){n.onreadystatechange.apply(n,q)}}n={onerror:null,onreadystatechange:null,readyState:0,open:function(q,p){l();internal_callback="cb"+(a++);(function(r){c.jXHR[r]=function(){try{j.call(n,4,arguments)}catch(s){n.readyState=-1;g("Script failed to run ["+f+"].")}c.jXHR[r]=null}})(internal_callback);f=p.replace(/=\?/,"=jXHR."+internal_callback);j(1)},send:function(){b(function(){i=d.createElement("script");i.setAttribute("type","text/javascript");i.onload=i.onreadystatechange=function(){k.call(i)};i.setAttribute("src",f);d.getElementsByTagName("head")[0].appendChild(i)},0);j(2)},setRequestHeader:function(){},getResponseHeader:function(){return""},getAllResponseHeaders:function(){return[]}};l();return n}})($win);
/* Copyright (c) 2009-2011 TUILUX, Inc. Todos os direitos reservados. */
function TUILUX(){}Array.prototype.contains=function(c){var a=false,b;if("undefined"!==typeof c){for(b=0;b<this.length;b++){if((typeof this[b]===typeof c)&&(this[b]==c)){a=true;break}}}return a};(function(){TUILUX.version="3.3";TUILUX.debugMode=false;TUILUX.bookFellowItem=function(a){var b=TUILUX.cookie;b.crud(b.fellowItemRepository,a)};TUILUX.postFacebookLike=function(){var a,b,d,i,l,g,j=TUILUX_VARS,h=TUILUX,k=TUILUX.service,c=TUILUX.logging;a=h.validation.isFacebookLikePostAllowed();if(a){try{i=h.hookFBUserID();l=(j.ITEM_ID)?j.ITEM_ID:"";g=new Date().getTime();b=encodeURI(k.servicePrefix+"/monitorService/pid/"+j.PARTNER_ID+"/facebookLike?externalItemId="+l+"&facebookUserId="+i+"&ts="+g);k.track("facebookLike",b);c.track("TUILUX MONITOR","facebookLike",b)}catch(f){c.warning("Invalid TUILUX_VARS to post facebookLike");c.track("MONITOR ERROR","facebookLike",b)}}return false};TUILUX.postItemAccess=function(){var m,p,i,h,f,o,j,c,n,r,k,a,t=TUILUX_VARS,b=TUILUX,g=b.cookie,s=b.service,l=b.logging,d=b.validation;m=d.isWatchedItemPostAllowed();if(m){t.ORDER=undefined;try{i=1;p=$doc.location.href;if(typeof p!=="undefined"){if(p.indexOf("rec=1")>-1){t.RECOMMENDED=true;b.bookRecommendedItemAccess(t.ITEM_ID)}h=p.indexOf("src=");if(h>-1){i=p.charAt(h+4)}}o=t.ITEM_ID;j=b.hookUserID();n=t.USER_EMAIL;n=d.isValidEmail(n)?n:null;c=d.isValidValue(t.USER_IP)?t.USER_IP:null;a=new Date().getTime();t.FELLOW_ID=g.crud(g.fellowItemRepository);r=t.FELLOW_ID;k=t.RECOMMENDED;k=(k||k=="1")?true:false;f=encodeURI(s.servicePrefix+"/monitorService/pid/"+t.PARTNER_ID+"/itemAccess?itemIdExternal="+o+(j?"&user.id="+j:"")+(n?"&user.email="+n:"")+(c?"&userIpAddress="+c:"")+(r?"&fellowIdItem="+r:"")+(k?"&recommended="+k:"")+(i?"&src="+i:"")+"&ts="+a);s.track("itemAccess",f);l.track("TUILUX MONITOR","itemAccess",f)}catch(q){l.warning("Invalid TUILUX_VARS to post itemAccess");l.track("MONITOR ERROR","itemAccess",f)}}b.bookFellowItem(t.ITEM_ID);return false};TUILUX.hookUserID=function(){var b=TUILUX.cookie,d=TUILUX.validation,a=TUILUX_VARS.USER_ID,c=/\d+/;if(d.isValidValue(a)&&c.test(a)){b.setUserToCookie(a)}else{a=b.crud(b.userLoggedRepository);if(d.isValidValue(a)&&c.test(a)){TUILUX_VARS.USER_ID=a}else{a=null}}return a};TUILUX.hookFBUserID=function(){var b=TUILUX.cookie,d=TUILUX.validation,a=TUILUX_VARS.FB_USER_ID,c=/\d+/;if(d.isValidValue(a)&&c.test(a)){b.setFBUserToCookie(a)}else{a=b.crud(b.fbUserLoggedRepository);if(d.isValidValue(a)&&c.test(a)){TUILUX_VARS.FB_USER_ID=a}else{a=null}}return a};TUILUX.bookRecommendedItemAccess=function(a){var d=TUILUX.cookie,c,b;b=d.crud(d.recItemAccessRepository);if(!b){c=new Array()}else{c=b.split(",")}if(!c.contains(a)){c.push(a);b=c.toString();d.crud(d.recItemAccessRepository,b,d.recsExpireDays)}};TUILUX.postOrderedItems=function(){var m=true,k,b,n,a,g,q,j,d,l,f,p,h=TUILUX.logging,r=TUILUX,c=r.validation;k=c.isOrderedItemPostAllowed(m);if(k){g=TUILUX_VARS;q=g.ORDER;r.setRecommendedParams(q);d=(/\d+/.test(g.ORDER_NUMBER))?g.ORDER_NUMBER:0;n=r.hookUserID();email=g.USER_EMAIL;email=c.isValidEmail(email)?email:null;a=(g.USER_IP)?g.USER_IP:"";p=new Date().getTime();sending=new Array();for(j=0;j<q.length;j++){l=(q[j].ITEM_PRICE)?q[j].ITEM_PRICE:0;f=q[j].RECOMMENDED;f=(f||f=="1")?true:false;b=encodeURI(TUILUX.service.servicePrefix+"/monitorService/pid/"+g.PARTNER_ID+"/itemOrder?orderNumber="+d+(n?"&user.id="+n:"")+(email?"&user.email="+email:"")+(a?"&userIpAddress="+a:"")+(q[j].ITEM_ID?"&itemIdExternal="+q[j].ITEM_ID:"")+(l?"&itemUnitPrice="+l:"")+(q[j].ITEM_AMOUNT?"&itemAmount="+q[j].ITEM_AMOUNT:"")+(f?"&recommended="+f:"")+"&ts="+p);try{TUILUX.service.track("itemOrder"+j,b)}catch(o){}h.track("TUILUX MONITOR","itemOrder"+j,b)}}else{h.warning("Validation.isOrderedItemPostAllowed(): "+k+"\nurl = "+b);h.track("MONITOR ERROR","itemOrder",b)}return false};TUILUX.postCartedItems=function(){var m=false,c,b,n,a,g,q,k,d,l,f,p,r=TUILUX,h=r.logging,j=r.validation;c=j.isOrderedItemPostAllowed(m);if(c){g=TUILUX_VARS;q=g.ORDER;r.setRecommendedParams(q);n=r.hookUserID();email=g.USER_EMAIL;email=j.isValidEmail(email)?email:null;a=(g.USER_IP)?g.USER_IP:"";p=new Date().getTime();sending=new Array();for(k=0;k<q.length;k++){l=(q[k].ITEM_PRICE)?q[k].ITEM_PRICE:0;f=q[k].RECOMMENDED;f=(f||f=="1")?true:false;b=encodeURI(TUILUX.service.servicePrefix+"/monitorService/pid/"+g.PARTNER_ID+"/itemCart?itemIdExternal="+q[k].ITEM_ID+(n?"&user.id="+n:"")+(email?"&user.email="+email:"")+(a?"&userIpAddress="+a:"")+(f?"&recommended="+f:"")+"&ts="+p);try{TUILUX.service.track("itemCart"+k,b)}catch(o){}h.track("TUILUX MONITOR","itemCart"+k,b)}}else{h.warning("Validation.isCartItemPostAllowed(): "+c+"\nurl = "+b);h.track("MONITOR ERROR","itemCart",b)}return false};TUILUX.setRecommendedParams=function(a){var d,c,f=TUILUX.cookie,b;b=f.crud(f.recItemAccessRepository);if(b){d=b.split(",");if(d){for(c=0;c<a.length;c++){if(!a[c].RECOMMENDED){a[c].RECOMMENDED=d.contains(a[c].ITEM_ID)}}}}};TUILUX.getRecommendations=function(o){var i,l,m,a,h,f,j,b,n,g,c=5,k=TUILUX,d=TUILUX.logging;m=TUILUX_VARS;a=m.ITEM_BASE;h=new RegExp("(https?://)?[a-zA-Z0-9.-/]*/");if(h.test(TUILUX_VARS.ITEM_BASE)){f=escape(a);f=f.replace(/\/{1}/gi,"%2F");f=f.replace(/\+{1}/gi,"%2B");a=f}g=("undefined"!==typeof(m.REC_AMOUNT))?m.REC_AMOUNT:c;j=new Date().getTime();b=encodeURI(k.service.servicePrefix+"/recService/pid/"+m.PARTNER_ID+"/getRecommendations/"+a+"?max="+g+"&ts="+j+"&recApi="+o+"&callback=?");n=function(r){var t,q,p=null;try{q=r?r:undefined;if("undefined"!==typeof(q)){p=o.toLowerCase();if(p==="hybrid"){TUILUX.gui.recommendationHeader=m.RECOMMENDATION_HEADER;t=$doc.getElementById("tuilux")}else{if(p==="content"){TUILUX.gui.recommendationHeader=m.RECOMMENDATION_CONTENT_HEADER}else{if(p==="behavior"){TUILUX.gui.recommendationHeader=m.RECOMMENDATION_BEHAVIOR_HEADER}else{if(p==="cross_sell"){TUILUX.gui.recommendationHeader=m.RECOMMENDATION_CROSS_SELL_HEADER}}}t=$doc.getElementById("tuilux-"+p)}renderedTags=TUILUX.gui.renderRecommendedItems(q);t.innerHTML="";t.appendChild(renderedTags)}else{d.track("RECOMMENDATION ERROR","getRecommendations",b)}}catch(s){d.logException(s)}};k.service.send(b,n)};TUILUX.cookie={recsExpireDays:7,fellowItemRepository:"_tfi",recItemAccessRepository:"_tria",userLoggedRepository:"_tul",fbUserLoggedRepository:"_tfbul",COOKIE_EXPIRES_FACTOR:(24*60*60*1000),crud:function(b,l,m){var d,f=new Date(),n,a,g,h,j,k;if("undefined"!==typeof b&&"undefined"!==typeof l){if(m){f.setTime(f.getTime()+(m*this.COOKIE_EXPIRES_FACTOR));d="; expires="+f.toGMTString()}else{d=""}a=(("https:"==$doc.location.protocol)?"true":undefined),$doc.cookie=b+"="+escape(l)+((d)?d:"")+((n)?"; path="+escape(n):"")+((a)?"; secure":"");return this.crud(b)}else{if("undefined"!==typeof b){g=b+"=";h=$doc.cookie.split(";");for(j=0;j<h.length;j++){k=h[j];while(k.charAt(0)==" "){k=k.substring(1,k.length)}if(k.indexOf(g)==0){return unescape(k.substring(g.length,k.length))}}}}return""},setUserToCookie:function(a){var b=TUILUX.cookie;b.crud(b.userLoggedRepository,a,999)},setFBUserToCookie:function(a){var b=TUILUX.cookie;b.crud(b.fbUserLoggedRepository,a,999)}};TUILUX.gui={recommendationHeader:undefined,renderRecommendedItems:function(t){if("undefined"===typeof(t)){return null}var n,a,l,i,s,j,h,r,g,p,b,k,c,o,m,f,d;try{if("undefined"===typeof(this.recommendationHeader)){this.recommendationHeader="Voce pode se interessar por:"}n=$doc.createElement("div");n.setAttribute("class","tuilux_rec");n.setAttribute("className","tuilux_rec");a=$doc.createElement("div");a.setAttribute("class","tuilux_header_div");a.setAttribute("className","tuilux_header_div");i=$doc.createElement("div");i.setAttribute("id","tuiluxLogo");i.setAttribute("class","tuilux_logo_img");i.setAttribute("className","tuilux_logo_img");tuiluxLogoLink=$doc.createElement("a");tuiluxLogoLink.setAttribute("id","tuilux_logo_link");tuiluxLogoLink.setAttribute("class","tuilux_logo_link");tuiluxLogoLink.setAttribute("className","tuilux_logo_link");tuiluxLogoLink.setAttribute("href","http://www.tuilux.com.br");tuiluxLogoLink.setAttribute("target","_blank");tuiluxImg=$doc.createElement("img");tuiluxImg.setAttribute("id","tuilux_logo_img");tuiluxImg.setAttribute("src",TUILUX.service.protocol+"d2qlyqz1nxxzps.cloudfront.net/img/tuilux.png");tuiluxLogoLink.appendChild(tuiluxImg);i.appendChild(tuiluxLogoLink);headerTextDiv=$doc.createElement("div");headerTextDiv.setAttribute("id","tuilux_header_text_div");l=$doc.createElement("h3");l.setAttribute("class","tuilux_header");l.setAttribute("className","tuilux_header");l.innerHTML=this.recommendationHeader;headerTextDiv.appendChild(l);a.appendChild(headerTextDiv);a.appendChild(i);n.appendChild(a);c=(t.recommendation)?t.recommendation.recommendationsList:t.recommendationsList;o=TUILUX.util;for(k=0;k<c.length;k++){s=c[k];p=s.name;f=s.page;m=s.image;d=s.price;j=$doc.createElement("div");j.setAttribute("class","tuilux_item");j.setAttribute("className","tuilux_item");h=$doc.createElement("a");h.setAttribute("class","tuilux_item_link");h.setAttribute("className","tuilux_item_link");h.setAttribute("id",c[k].id);f=(f.indexOf("?")>-1)?f+"&rec=1":f+"?rec=1";h.setAttribute("href",f);if(TUILUX.service.protocol==="https://"){m=m.replace("http://","https://")}r=$doc.createElement("img");r.setAttribute("class","tuilux_item_image");r.setAttribute("className","tuilux_item_image");r.setAttribute("alt",p);r.setAttribute("src",m);g=$doc.createElement("span");g.setAttribute("class","tuilux_item_name");g.setAttribute("className","tuilux_item_name");g.innerHTML=p;if(d){b=$doc.createElement("span");b.setAttribute("class","tuilux_item_price");b.setAttribute("className","tuilux_item_price");b.innerHTML="R$"+o.floatToCurrency(d)}h.appendChild(r);h.appendChild($doc.createElement("br"));h.appendChild(g);j.appendChild(h);j.appendChild($doc.createElement("br"));if(d){j.appendChild(b)}n.appendChild(j);a=l=j=h=r=g=itemPriveSpan=null}}catch(q){TUILUX.logging.logException(q);this.rendered=false}return n}};TUILUX.logging={logInAlert:function(a){TUILUX.messages.showMessage("Error name: "+a.name+"\nError message: "+a.message)},logException:function(a){this.error("Error name: "+a.name+"\nError message: "+a.message);if(TUILUX.debugMode){_gaq.push(["_trackEvent","TUILUX JS Exception: "+(a.name||"Error"),a.message||a,$doc.location.href])}},log:function(a){if("undefined"!==typeof(console)&&"undefined"!==typeof(console.log)){console.log(a)}},warning:function(a){if("undefined"!==typeof(console)&&"undefined"!==typeof(console.warn)){console.warn(a)}},error:function(a){if("undefined"!==typeof(console)&&"undefined"!==typeof(console.error)){console.error(a)}},track:function(a,c,b){if(TUILUX.debugMode){_gaq.push(["_trackEvent","TUILUX JS TRACKING: "+(a||"Default"),c,b])}}};TUILUX.messages={messageLog:new Array(),addMessage:function(a){this.messageLog.push("\n"+a)},showMessage:function(a){$win.alert(a)},showMessageLog:function(){TUILUX.logging.log("These are the messages so far:"+this.messageLog.join(""));this.cleanMessageLog()},cleanMessageLog:function(){this.messageLog=new Array()}};TUILUX.service={protocol:(("https:"==$doc.location.protocol)?"https://":"http://"),server:"apps.tuilux.com.br",servicePrefix:undefined,send:function(a,f,d){try{var b=new jXHR();if(!d){b.onerror=function(h,g){TUILUX.logging.log("Message: "+h)}}else{b.onerror=d}if(f){b.onreadystatechange=function(g){if(b.readyState===4){f(g)}}}b.open("GET",a);b.send()}catch(c){TUILUX.logging.logException(c)}},track:function(f,c){var d,a,b;b=$doc.getElementById("tuilux");if(b){d=b}else{d=$doc.getElementsByTagName("body")[0]}a=$doc.createElement("img");a.id=f;a.src=c;a.setAttribute("style","display: none;");d.appendChild(a);d=a=null}};TUILUX.validation={isValidValue:function(b){var a=(b&&((typeof b==="string"&&b.replace(/^\s+|\s+$/g,"").length>0)||typeof b==="number"))?true:false;return a},isValidEmail:function(a){return/^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/.test(a)},isValidTuiluxVars:function(b){var a=true,d=this,c=TUILUX.messages;if("undefined"===typeof(b)){c.addMessage("TUILUX_VARS is undefined");a=false}if(!d.isValidValue(b.PARTNER_ID)){c.addMessage("PARTNER_ID is undefined");a=false}if("undefined"!==typeof(b.ITEM_RECOMMENDED_EXPR)&&"undefined"!==typeof(jQuery)&&jQuery(b.ITEM_RECOMMENDED_EXPR).size()==0){c.addMessage("JQuery expression was not correctly set");a=false}return a},validateItemOrder:function(a){var c=false,b;try{for(b=0;b<a.length;b++){c=this.isValidValue(a[b].ITEM_ID)&&this.isValidValue(a[b].ITEM_AMOUNT)}}catch(d){c=false;TUILUX.logging.log("Error\nname: "+d.name+"\nmessage: "+d.message)}return c},isWatchedItemPostAllowed:function(){var a=false,b=TUILUX_VARS.ITEM_ID;a=this.isValidValue(b);return a},isRecommendedItemPostAllowed:function(){var a=false,b=TUILUX_VARS.ITEM_ID;a=this.isValidValue(b);return a},isOrderedItemPostAllowed:function(d){var a=false,b=false,c;c=TUILUX_VARS;if("undefined"!==typeof c.ORDER){b=this.validateItemOrder(c.ORDER)}else{b=false}if(d){a=(this.isValidValue(c.USER_ID)&&b)}else{a=b}return a},isFacebookLikePostAllowed:function(){var a=false,c=false,b;b=TUILUX_VARS;if(b.FB_USER_ID&&b.ITEM_ID){c=true}else{c=false}return c}};TUILUX.util={browser:undefined,setBrowser:function(){var a=navigator.userAgent.toLowerCase();this.browser={version:(a.match(/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/)||[])[1],safari:/webkit/.test(a),opera:/opera/.test(a),chrome:/chrome/.test(a),msie:((/msie/.test(a))&&!(/opera/.test(a))),mozilla:(/mozilla/.test(a))&&(!/(compatible|webkit)/.test(a)),konqueror:a.match(/konqueror/i)}},floatToCurrency:function(d){var b,a,c,f;b=0;if(d<0){d=Math.abs(d);b=1}if(isNaN(d)){d="0"}a=Math.floor((d*100+0.5)%100);d=Math.floor((d*100+0.5)/100).toString();if(a<10){a="0"+a}for(f=0;f<Math.floor((d.length-(1+f))/3);f++){d=d.substring(0,d.length-(4*f+3))+"."+d.substring(d.length-(4*f+3))}c=d+","+a;if(b==1){c=" - "+c}return c}};TUILUX.init={inited:false,ourScriptTag:undefined,tuiluxUrlMatcher:"(https?://)?[a-zA-Z0-9.-/]*/tuilux(?:.min)?.js.*",ourScriptPath:undefined,gaScriptPath:undefined,setupOurScriptTag:function(){var c,b,a;c=document.getElementsByTagName("script");b=new RegExp(this.tuiluxUrlMatcher);for(a=c.length-1;a>=0;a--){if("undefined"!==c[a]&&b.test(c[a].src)){this.ourScriptTag=c[a];return false}}},setupServicePrefix:function(){var b,a,d,c;b=("https:"==document.location.protocol)?true:false;d=TUILUX.service.protocol;a=TUILUX.service.server;if(a.indexOf("localhost")>-1){c=(b)?":8443":":8080";a=a+c}TUILUX.service.servicePrefix=d+a+"/sisrec-ws-ws/services"},loadScript:function(c,b){var a=$doc.createElement("script");a.setAttribute("type","text/javascript");a.setAttribute("src",b);a.setAttribute("id",c);$doc.getElementsByTagName("head")[0].appendChild(a)},startUp:function(){var a=TUILUX.init,b=TUILUX.util;b.setBrowser();a.setupOurScriptTag();a.setupServicePrefix();a.initialize()},decideWhatToDo:function(c){var d=TUILUX,a=TUILUX.logging;if(c.ITEM_WATCHED){a.log("Tuilux is going to post watched item");try{d.postItemAccess()}catch(b){d.logging.logException(b)}}if(c.ITEM_CARTED){a.log("Tuilux is going to post carted items");try{d.postCartedItems()}catch(b){d.logging.logException(b)}}if(c.ITEM_ORDERED){a.log("Tuilux is going to post ordered items");try{d.postOrderedItems()}catch(b){d.logging.logException(b)}}if(c.GET_RECOMMENDED){a.log("Tuilux is going to get recommended items");d.gui.recommendationHeader=c.RECOMMENDATION_HEADER;try{d.getRecommendations("HYBRID")}catch(b){d.logging.logException(b)}}if(c.GET_RECOMMENDED_CONTENT){a.log("Tuilux is going to get content recommended items");try{d.getRecommendations("CONTENT")}catch(b){d.logging.logException(b)}}if(c.GET_RECOMMENDED_BEHAVIOR){a.log("Tuilux is going to get behavior recommended items");try{d.getRecommendations("BEHAVIOR")}catch(b){d.logging.logException(b)}}if(c.GET_RECOMMENDED_CROSS_SELL){a.log("Tuilux is going to get cross sell recommended items");try{d.getRecommendations("CROSS_SELL")}catch(b){d.logging.logException(b)}}},initialize:function(){var d=TUILUX,b=TUILUX.init,a;if(b.inited){return}if(!b.inited){b.inited=true;d.logging.log("- Tuilux Component Initialized -")}a=function(f){if(d.validation.isValidTuiluxVars(f)){b.decideWhatToDo(TUILUX_VARS)}else{d.messages.showMessageLog()}};try{if(TUILUX_VARS){a(TUILUX_VARS)}else{d.logging.log("TUILUX_VARS not defined")}}catch(c){d.logging.logException(c)}}}})();if(TUILUX.debugMode){var _gaq=_gaq||[],_i=TUILUX.init,gaScriptPath;gaScriptPath=(("https:"==document.location.protocol)?"https://ssl.":"http://www.");gaScriptPath=_i.gaScriptPath+"google-analytics.com/ga.js";_i.loadScript("gaScript",gaScriptPath);_gaq.push(["_setAccount","UA-1427374-2"],["_trackPageview"]);_gaq.push(["_setDomainName",document.domain],["_setAllowLinker",true],["_setAllowHash",false])}function addLoadEvent(a){var b=window.onload;if(typeof window.onload!="function"){window.onload=a}else{window.onload=function(){if(b){b()}a()}}}try{addLoadEvent(TUILUX.init.startUp)}catch(e){TUILUX.logging.logException(e)};

