Advertisement
swarog

superfish 1

Apr 30th, 2012
781
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (function() {
  2. spsupport.p = {
  3.     sfDomain:       superfish.b.pluginDomain,
  4.     sfDomain_:      superfish.b.pluginDomain,
  5.     imgPath:        (superfish.b.sm ? superfish.b.pluginDomain.replace("http:","https:") : superfish.b.pluginDomain.replace("https","http"))  + "images/",
  6.     cdnUrl:         superfish.b.cdnUrl,
  7.     appVersion:     superfish.b.appVersion,
  8.     clientVersion:  superfish.b.clientVersion,
  9.     site:           superfish.b.pluginDomain,
  10.     sessRepAct:     "trackSession.action",
  11.     isIE:           0,
  12.     isIEQ:          +document.documentMode == 5 ? 1 : 0 ,
  13.     nil: {
  14.         pPos: 0
  15.     },
  16.     sfIcon: {
  17.         jBtns: 0,
  18.         nl:     0,
  19.         maxSmImg: {
  20.             w: 88,
  21.             h: 70
  22.         },
  23.         ic:     0,
  24.         evl:    'sfimgevt',
  25.         icons:  [],
  26.         big: {
  27.             w: (superfish.b.redIcon ? 104 : 95),
  28.             h: (superfish.b.redIcon ? 34 : 25)
  29.         },
  30.         small: {
  31.             w: (superfish.b.redIcon ? 73 : 65),
  32.             h: (superfish.b.redIcon ? 34 : 25)
  33.         },
  34.         an: 0,
  35.         imPos: 0,
  36.         prog: {
  37.             time: 1000,
  38.             node: 0,
  39.             color: (superfish.b.redIcon ? '#ffffff' : '#398AFD'),
  40.             opac : (superfish.b.redIcon ? '0.5' : '0.3'),
  41.             e: 0,   /* end */
  42.             w: (superfish.b.redIcon ? [93, 66] : [93, 63]),
  43.             h: 23
  44.         }
  45.     },
  46.     temp: 0,
  47.  
  48.     onFocus: -1,
  49.     psuHdrHeight: 22,
  50.     psuRestHeight: 26,
  51.     oopsTm: 0,
  52.     iconTm: 0,
  53.     dlsource: superfish.b.dlsource,
  54.     w3iAFS: superfish.b.w3iAFS,
  55.     CD_CTID: superfish.b.CD_CTID,
  56.     userid: superfish.b.userid,
  57.     statsReporter: superfish.b.statsReporter,
  58.     minImageArea: ( 60 * 60 ),
  59.     aspectRatio: ( 1.0/2.0 ),
  60.     supportedSite: 0,
  61.     ifLoaded: 0,
  62.     ifExLoading: 0,
  63.     itemsNum: 1,
  64.     tlsNum: 1,
  65.     statSent: 0,
  66.  
  67.     icons: 0,
  68.     partner: superfish.b.partnerCustomUI ? superfish.b.images + "/" : "",
  69.    
  70.     prodPage: {
  71.         s: 0,   // sent - first request
  72.         i: 0,   // images count
  73.         p: 0,   // product image
  74.         e: 0,   // end of slideup session
  75.         d: 210, // dimension of image
  76.         l: 1000, // line - in px from top
  77.         reset: function(){
  78.             this.s = 0;  
  79.             this.i = 0;  
  80.             this.p = 0;  
  81.             this.e = 0;  
  82.         }        
  83.     },
  84.    
  85.     SRP: {
  86.         p: [],    // pic
  87.         i: 0,    // images count
  88.         c: 0,   /* counter of tries */
  89.         ind: 0, /* index of current image */
  90.         lim: 0, /* limit of requests on SRP */
  91.         reset: function(){
  92.             this.p = [];  
  93.             this.i = 0;            
  94.             this.c = 0;
  95.             this.ind = 0;
  96.         }        
  97.     },
  98.     pageType: "NA",
  99.    
  100.     iJq:    0,   // "inject jquery flag"
  101.     jJqcb:  0,   // jquery callback
  102.     iSf:    0,   // "inject jquery flag"  
  103.     iTpc:   0,  // "inject top ppc flag"
  104.     iCpn:   0,  // "inject coupons flag"    
  105.    
  106.     before: -1  // Close before
  107. };
  108. spsupport.api = {
  109.     jsonpRequest: function(url, data, successFunc, errorFunc, callBack, postCB){
  110.         try{
  111.             if( callBack == null ){
  112.                 var date = new Date();
  113.                 callBack = "superfishfunc" + date.getTime();
  114.             }
  115.             window[callBack] = function(json) {
  116.                 if(successFunc != null)
  117.                     successFunc(json);
  118.             };
  119.             sufio.io.script.get({
  120.                 url: url + ( url.indexOf("?") > -1 ? "&" : "?" ) + "callback=" + callBack,
  121.                 content: data,
  122.                 load: function(response, ioArgs) {
  123.                     window[callBack]  = null;
  124.                     if( !spsupport.p.isIE ){
  125.                         if( postCB) {
  126.                             setTimeout(function() {
  127.                                 postCB();
  128.                             }, 50);
  129.                         }
  130.                     }
  131.                 },
  132.                 error: function(response, ioArgs) {
  133.                     window[callBack]  = null;
  134.                     if(errorFunc != null)
  135.                         errorFunc( response, ioArgs);
  136.  
  137.                     if( !spsupport.p.isIE ){
  138.                         if( postCB) {
  139.                             setTimeout(function() {
  140.                                 postCB();
  141.                             }, 50);
  142.                         }
  143.                     }
  144.                 }
  145.  
  146.             });
  147.         }
  148.         catch(ex){
  149.         }
  150.     },
  151.  
  152.     sTime: function( p ){
  153.         if( p == 0 ){
  154.             this.sTB = new Date().getTime();
  155.             this.sT = 0;
  156.         }else if(p == 1){
  157.             this.sT = new Date().getTime() - this.sTB;
  158.         }else{
  159.             return ( spsupport.p.before == 1 && this.sT == 0 ? new Date().getTime() - this.sTB : this.sT );
  160.         }
  161.     },
  162.  
  163.     getDomain: function(){
  164.         var dD = document.location.host;
  165.         var dP = dD.split(".");
  166.         var len = dP.length;
  167.         if ( len > 2 ){
  168.             var co = ( dP[ len - 2 ] == "co" ? 1 : 0 );
  169.             dD = ( co ? dP[ len - 3 ] + "." : "" ) + dP[ len - 2 ] + "." + dP[ len - 1 ];
  170.         }
  171.         return dD;
  172.     },
  173.     validDomain: function(){
  174.         try{
  175.             var d = document;
  176.             if( d == null || d.domain == null ||
  177.                 d == undefined || d.domain == undefined || d.domain == ""
  178.                 || d.location == "about:blank" || d.location == "about:Tabs"
  179.                 || d.location.toString().indexOf( "superfish.com/congratulation.jsp" ) > -1  ){
  180.                 return false;
  181.             }else{
  182.                 return (/^([a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,5}$/).test( d.domain );
  183.             }
  184.         }catch(e){
  185.             return false;
  186.         }
  187.     },
  188.  
  189.     init: function(){
  190.         var sp = spsupport.p;
  191.         if( window.sufio )
  192.             return;
  193.  
  194.         if( !spsupport.api.validDomain() )
  195.             return;
  196.  
  197.         this.dojoReady = 0;
  198.         sp.cdnUrl = (superfish.b.sm ? sp.cdnUrl.replace("http:","https:") : sp.cdnUrl);
  199.  
  200.         if ( ! top.djConfig ){
  201.             djConfig = {};
  202.         }
  203.         djConfig.afterOnLoad = true;
  204.         djConfig.baseScriptUri = sp.cdnUrl;
  205.         djConfig.useXDomain = true;
  206.         djConfig.scopeMap = [ ["dojo", "sufio"], ["dijit", "sufiw"], ["dojox", "sufix"] ];
  207.         djConfig.require = ["dojo.io.script" ,"dojo._base.html", "dojo.window"];
  208.         djConfig.modulePaths =  {
  209.             "dojo": sp.cdnUrl + "dojo",
  210.             "dijit": sp.cdnUrl + "dijit",
  211.             "dojox": sp.cdnUrl + "dojox"
  212.         };
  213.  
  214.         superfish.b.inj(window.document, sp.cdnUrl + "dojo/dojo.xd.js",
  215.             1,
  216.             function(){
  217.                 sufio.addOnLoad(function(){
  218.                     spsupport.api.dojoLoaded();
  219.                 });
  220.             });
  221.     },
  222.        
  223.     // sends request on search results page
  224.     sSrp: function() {
  225.         var sp = spsupport.p;
  226.         var sa = spsupport.api;
  227.         var im = sp.SRP.p[sp.SRP.ind];
  228.         sp.pageType = (spsupport.whiteStage.rv || spsupport.p.textOnly ? "PP" : "SRP");
  229.         if (sp.SRP.c < sp.SRP.lim && sp.SRP.ind < sp.SRP.p.length && im.getAttribute("nosureq") != "1") {
  230.             sp.prodPage.p = im;
  231.             sa.puPSearch(1, im);
  232.             sp.SRP.ind++;
  233.             sp.SRP.c++;
  234.         }        
  235.     },
  236.    
  237.     gotMessage: function( param, from ){
  238.         if(from && from.indexOf("superfish.com") == -1 ){
  239.             return;
  240.         }
  241.        
  242.         if ( param ){
  243.             param = param + "";
  244.             var prep = param.split( "|" );
  245.         }
  246.         var sp = spsupport.p;
  247.         var i;
  248.         if (prep && prep.length) {
  249.         var fromPsu = ( prep.length > 5 ? 1 : 0);
  250.         if ( fromPsu ) {
  251.             if (sp.prodPage.e) {
  252.                 return;
  253.             }
  254.         }
  255.  
  256.         param = ( +prep[ 0 ] );
  257. //        spsupport.log("5 gotMessage " + param);
  258.        
  259.         if (param > 3000) {
  260.             return;
  261.         }
  262.        
  263.         var sfu = superfish.util;
  264.         var sa = spsupport.api;
  265.         if( param == 101 ){ // sys down
  266.             sfu.sysDown();
  267.         }
  268.         else{
  269.             if( param == -7890 ){ // init
  270.                 sp.ifLoaded = 1;
  271.                 if( sfu && sfu.standByData != 0 ){
  272.                     sa.sTime(0);
  273.                     sfu.sendRequest( sfu.standByData );
  274.                     sfu.standByData = 0;
  275.                 }
  276.             }
  277.             else if( param >= 200 && param < 2000 ){
  278.                 // 200 - ( idrentical only - false, failure )
  279.                 // 211 - ( idrentical only - false, identical is not empty, similar is not empty )
  280.  
  281.                 sp.itemsNum = +prep[1];
  282.                 sp.tlsNum = +prep[2];
  283.                 sfu.updIframeSize(sp.itemsNum, sp.tlsNum, fromPsu);
  284.                 sfu.showContent();
  285.                 sa.sTime(1);
  286.                
  287.                 if (!fromPsu) {
  288.                     if (superfish.inimg) {
  289.                         for (i in superfish.inimg.res) {
  290.                             superfish.inimg.res[i] = 0;
  291.                         }
  292.                         if (param < 221) {
  293.                         }
  294.                         else {
  295.                             superfish.inimg.res[prep[3]] = sp.itemsNum;
  296.                             superfish.inimg.spl(prep[3]);
  297.                         }
  298.                     }
  299.                     if (sfu.currImg == sp.sfIcon.ic.img && sp.sfIcon.prog.e > 0) {
  300.                         sp.before = 0;
  301.                         sfu.openPopup(sp.imPos, sp.appVersion, 0);                        
  302.                     }
  303.                 }
  304.  
  305.                 sp.before = 0;
  306.  
  307.                 if( param == 200 ){
  308.                     if( !fromPsu) {
  309.                         if (superfish.p.onAir != 2) {
  310.                             if (sfu.currImg) {
  311.                                 sfu.currImg.setAttribute("sfnoicon", "1");
  312.                             }
  313.  
  314.                             if (! superfish.b.coupons || prep.length <= 2) {
  315.                                 sp.oopsTm = setTimeout(function() {
  316.                                     if(!sp.isIE){
  317.                                         sfu.jPopup().fadeOut(800, function() {
  318.                                             sfu.closePopup();
  319.                                         });
  320.                                     }
  321.                                     else {
  322.                                         sfu.closePopup();
  323.                                     }
  324.                                 }, 3000 );
  325.                             }
  326.                         }
  327.                     }
  328.                     else {
  329.                         if( !sp.prodPage.e &&  sp.prodPage.s ) {
  330.                             if(superfish.b.inimgSrp && sp.prodPage.i == 0) {
  331.                                 sp.prodPage.s = 0;
  332.                                 sa.sSrp();
  333.                             }
  334.                         }
  335.                     }
  336.                 }
  337.                 else if( param > 200 ){
  338.                     if( superfish.b && superfish.b.inimg  && fromPsu){
  339.                         if( sp.prodPage.s && !sp.prodPage.e && superfish.p.onAir == 2){
  340.                             sp.prodPage.e = 1;
  341.                             if (superfish.b.inimg && superfish.inimg && superfish.inimg.itn) {
  342.                                 superfish.inimg.init(prep[3], +prep[4], sfu, spsupport.p, superfish.b, sp.prodPage.p);
  343.                                 sa.fixDivsPos();
  344.                                 if(superfish.b.inimgSrp && sp.prodPage.i == 0) {
  345.                                     sp.prodPage.s = 0;
  346.                                     sp.prodPage.e = 0;
  347.                                     sa.sSrp();
  348.                                 }
  349.                             }
  350.                             else if (superfish.b.initPSU) {
  351.                                 superfish.b.initPSU( prep[2] );
  352.                             }
  353.                         }
  354.                         superfish.util.requestImg();
  355.                     }
  356.                 }
  357.             }
  358.             // searchget
  359.             else if (param > 2001) {
  360.                 if (prep[1]) {
  361.                     sp.before = 0;
  362.                     superfish.sg.init(prep[1]);
  363.                     sfu.closePopup();
  364.                 }
  365.             }
  366.  
  367.             else if( param == 20 ){
  368.                 sfu.closePopup();
  369.             }
  370.             else if( param == 30 ){
  371.                 superfish.publisher.report(101);
  372.             }
  373.         }
  374.         }
  375.     },
  376.  
  377.     dojoLoaded: function()  {
  378.         this.dojoReady = 1;
  379.         spsupport.p.textOnly = 0;
  380.         if (!spsupport.sites.isBlackList()) {
  381.             if (!spsupport.p.iJq) {
  382.                 spsupport.p.iJq = 1;
  383.  
  384.                var originalJq = window.jQuery,
  385.                    correctJqVersion = originalJq ? originalJq.fn.jquery === '1.7.1' : false;
  386. //               if( correctJqVersion ){
  387. //                    spsupport.p.$ = originalJq;
  388. //                    spsupport.api.jQLoaded();
  389. //                }
  390. //                else {
  391.                     // load cdn jq
  392.                     superfish.b.cdnJQUrl = (superfish.b.sm ? superfish.b.cdnJQUrl.replace("http:","https:") : superfish.b.cdnJQUrl);
  393.                     yepnope([{
  394.                         load: superfish.b.cdnJQUrl,
  395.                         callback: function(){
  396.                             (function($) {
  397.                                 if (!spsupport.p.jJqcb) {
  398.                                     spsupport.p.jJqcb = 1;
  399.                                     spsupport.p.$ = jQuery.noConflict(true);
  400.  
  401.                                     // return original jq object
  402.                                     window.jQuery = originalJq;
  403.  
  404.                                     spsupport.api.jQLoaded();
  405.                                     spsupport.p.$.expr[':'].regex = function(elem, index, match) { var matchParams = match[3].split(','),validLabels = /^(data|css):/, attr = {method: matchParams[0].match(validLabels) ? matchParams[0].split(':')[0] : 'attr',property: matchParams.shift().replace(validLabels,'')},regexFlags = 'ig',regex = new RegExp(matchParams.join('').replace(/^\s+|\s+$/g,''), regexFlags);return regex.test(spsupport.p.$(elem)[attr.method](attr.property));}
  406.                                 }
  407.                             })(jQuery);
  408.                         }
  409.                     }]);
  410. //                }
  411.                 }
  412.             }
  413.     },
  414.    
  415.     jQLoaded: function() {
  416.             var sp = spsupport.p;
  417.             sp.isIE = sp.$.browser.msie;
  418.             sp.isFF = sp.$.browser.mozilla;
  419.             sp.isIE7 = sp.isIE  && parseInt(sp.$.browser.version, 10) === 7;
  420.             if (!spsupport.sites.isBlackStage()) {
  421.             spsupport.sites.searchget();
  422.             spsupport.api.userIdInit();
  423.             if(sp.isIE && window.spMsiSupport){
  424.                 if( !this.isOlderVersion( '1.2.1.0', sp.clientVersion ) ){
  425.                     spMsiSupport.validateUpdate();
  426.                 }
  427.                 if(sp.isIE7) {
  428.                     sp.isIEQ = 1;
  429.                 }
  430.             }
  431.            
  432.             setTimeout( function(){
  433.                 spsupport.sites.care();
  434.                 spsupport.sites.urlChange();
  435.             }, 1 );
  436.  
  437.             setTimeout( function(){
  438.                 sp.$(window).unload(function() {    
  439.                     if(superfish.p && superfish.p.onAir){
  440.                         superfish.util.bCloseEvent(sp.$("#SF_CloseButton")[0], 2);
  441.                     }
  442.                 });
  443.             }, 2000 );
  444.         }
  445.     },
  446.  
  447.     userIdInit: function(){
  448.         var sp = spsupport.p;
  449.         var spa = spsupport.api;
  450.         var data = {
  451.             "dlsource":sp.dlsource
  452.         }
  453.         if(sp.w3iAFS != ""){
  454.             data.w3iAFS = sp.w3iAFS;
  455.         }
  456.  
  457.         if( sp.CD_CTID != "" ){
  458.             data.CD_CTID = sp.CD_CTID;
  459.         }
  460.  
  461.         if(sp.userid != "" && sp.userid != undefined){
  462.             spa.onUserInitOK({
  463.                 userId: sp.userid,
  464.                 statsReporter: sp.statsReporter
  465.             });
  466.         }
  467.         else { // widget
  468.             spa.jsonpRequest(
  469.                 sp.sfDomain_ + "initUserJsonp.action",
  470.                 data,
  471.                 spa.onUserInitOK,
  472.                 spa.onUserInitFail,
  473.                 "superfishInitUserCallbackfunc"
  474.                 );
  475.         }
  476.     },
  477.  
  478.     onUserInitOK: function(obj) {
  479.         var sa = spsupport.api;
  480.         var sp = spsupport.p;
  481.        
  482.         if(!obj || !obj.userId || (obj.userId == "")){
  483.             sa.onUserInitFail();
  484.         } else{
  485.             sp.userid = obj.userId;
  486.             sp.statsReporter = obj.statsReporter;
  487.             sa.isURISupported( document.location );
  488.         }
  489.     },
  490.  
  491.  
  492.     ASU_OK: function( obj ){
  493.         if( !obj ){
  494.             spsupport.api.AS_Fail();
  495.         }
  496.         else{ }
  497.     },
  498.     ASU_Fail: function(){},
  499.  
  500.     isURISupported: function(url){
  501.         var sfa = spsupport.api;
  502.         spsupport.p.merchantName = "";
  503.         sfa.jsonpRequest(
  504.             spsupport.p.sfDomain_ + "getSupportedSitesJSON.action?ver=" + superfish.b.wlVersion,
  505.             0,
  506.             sfa.isURISupportedCB,
  507.             sfa.isURISupportedFail,
  508.             "SF_isURISupported");
  509.     },
  510.    
  511.     injCpn: function(st) {  /* st - site type: 1 - wl, 2 - st, 3 - cpn wl */
  512.         var sp = spsupport.p;
  513.         var st1 = (st == 3 ? "cpn" : (st == 2 ? "st" : (st == 1 ? "wl" : "n/a")));
  514.         sp.iCpn = 1;
  515.         superfish.b.inj(window.document, superfish.b.site + "coupons/get.jsp?pi=" + sp.dlsource + "&ui=" + sp.userid + "&st="+ st1 + "&v=" + sp.appVersion /* + "&mn="+spsupport.p.merchantName */, 1);
  516.     },    
  517.    
  518.     prc: function(id, pc) {
  519.         var num = id.charCodeAt(id.length - 1) + id.charCodeAt(id.length - 2) - 96;
  520.         var rg = 100/148; /* range: (122+122)-(48+48) */        
  521.         return (num*rg < pc);
  522.     },
  523.    
  524.     isURISupportedCB: function(obj) {
  525.         var sfa = spsupport.api;
  526.         var sp = spsupport.p;
  527.         var sfb = superfish.b;
  528.         var w = spsupport.whiteStage;
  529.  
  530.         sp.totalItemCount = obj.totalItemCount;
  531.         var domain = sfa.getDomain();
  532.         if (spsupport.txtSr) {
  533.             spsupport.txtSr.useWl(obj);
  534.         }
  535.         var sS = obj.supportedSitesMap[domain];
  536.         if (!sS && spsupport.txtSr) {
  537.             sS = spsupport.txtSr.siteInfo(domain);
  538.         }
  539.         superfish.partner.init();
  540.         superfish.publisher.init();
  541.         if( sS ) {
  542.             sp.supportedSite = 1;
  543.         }
  544.         else {
  545.             if (!sfb.ignoreWL) {
  546.                 w.st = (sfb.stDt ? w.isStore() : 0);                
  547.             }
  548.             if (sfb.ignoreWL || w.st) {
  549.                 sS = sfa.getSiteInfo();
  550.  
  551.                 if (w.st) {
  552.                     sfb.icons = 0;
  553.                     sp.prodPage.d = 149;
  554.                     superfish.b.inimgSrp = 0;
  555.                 }
  556.             }
  557.         }
  558.        
  559.         if( sS && !sfa.isBLSite( obj )){
  560.             if (sfb.topPpc && !sp.iTpc) {
  561.                 sp.iTpc = 1;
  562.                 spsupport.sites.topPpc(sS);
  563.             }
  564.             sfa.injectIcons(sS);
  565.             if (superfish.b.cpn[0] && !sp.iCpn) {
  566.                 sfa.injCpn(spsupport.p.supportedSite ? 1 : 2);
  567.             }
  568.            
  569.         }
  570.         else {
  571.             if (superfish.b.rvDt) {
  572.             //request revew WL            
  573.                 sfa.jsonpRequest(
  574.                     spsupport.p.sfDomain_ + "rvwl.action?ver=" + sfb.rvWLver,
  575.                     0,
  576.                     sfa.rvWlCB,
  577.                     sfa.rvWlFail,
  578.                     sfb.rvWLcb);
  579.             }else if(superfish.b.inImgDt) {
  580.                 if(w.isProductInPage()){
  581.                         sfb.icons = 0;
  582.                     sS = sfa.getSiteInfo();
  583.                     sfa.injectIcons(sS);
  584.                 }
  585.             }  
  586.                
  587.             if (superfish.b.cpn[0] || superfish.b.cpn[1]) {
  588.             //request coupons WL            
  589.                 sfa.jsonpRequest(
  590.                     spsupport.p.sfDomain_ + "getCouponsSupportedSites.action?ver=" + sfb.cpnWLver,
  591.                     0,
  592.                     sfa.cpnWlCB,
  593.                     sfa.cpnWlFail,
  594.                     sfb.cpnWLcb);          
  595.             }
  596.  
  597.             if( !sp.icons ){
  598.                 setTimeout(sfa.saveStatistics, 400);
  599.             }
  600.         }
  601.     },
  602.     getSiteInfo: function(){
  603.          sS = {};
  604.          sS.imageURLPrefixes = "";
  605.          sS.merchantName = this.getDomain();
  606.          return sS;
  607.     },
  608.     cpnWlCB: function(o) {      
  609.         var sa = spsupport.api;
  610.         var d = sa.getDomain();
  611.         if (o.a && o.a.indexOf(d) > -1 && !spsupport.p.iCpn) {
  612.             sa.injCpn(3);
  613.         }
  614.     },
  615.  
  616.     cpnWlFail: function(o) {
  617.     },
  618.  
  619.     rvWlCB: function(o) {  
  620.         var sa = spsupport.api;
  621.         var sp = spsupport.p;
  622.         var sfb = superfish.b;        
  623.        
  624.         var sS = o.supportedSitesMap[ sa.getDomain() ];  
  625.         if( sS ) {
  626.             spsupport.whiteStage.rv = 1;
  627.             sfb.icons = 0;
  628.             sfb.inimgSrp = (sfb.inimg ? 1 : 0);
  629.             sa.injectIcons( sS );
  630.         }else if(superfish.b.inImgDt) {
  631.             if(spsupport.whiteStage.isProductInPage()){
  632.                 sfb.icons = 0;
  633.                 sS = sa.getSiteInfo();
  634.                 sa.injectIcons(sS);
  635.             }
  636.         }
  637.     },
  638.  
  639.     rvWlFail: function(o) {},
  640.     isURISupportedFail: function(obj) {},
  641.  
  642.     isBLSite: function(obj){
  643.         var isBL = 0;
  644.         if ( obj.blockedSubDomains ){
  645.             for (var s = 0 ; s < obj.blockedSubDomains.length && !isBL ; s++ ){
  646.                 var loc = top.location + "";
  647.                 if (loc.indexOf(obj.blockedSubDomains[s]) >= 0){
  648.                     isBL = 1;
  649.                 }
  650.             }
  651.         }
  652.         return isBL;
  653.     },
  654.    
  655.     injectIcons: function( sS ) {
  656.         spsupport.p.supportedImageURLs = sS.imageURLPrefixes;
  657.         spsupport.p.merchantName = sS.merchantName;
  658.         spsupport.sites.preInject();
  659.         spsupport.api.careIcons( 0 );
  660.     },
  661.    
  662.     addSuperfishSupport: function(){
  663.         superfish.b.xdmsg.init(
  664.             spsupport.api.gotMessage,
  665.             ( spsupport.p.isIE7 ? 200 : 0 ) );
  666.  
  667.         if( !top.superfishMng ){
  668.             top.superfishMng = {};
  669.         }
  670.         if( !top.superfish ){
  671.             top.superfish = {};
  672.         }
  673.  
  674.         if( !top.superfish.p ){ // params
  675.             top.superfish.p = {
  676.                 site: spsupport.p.site,
  677.                 totalItemsCount: spsupport.p.totalItemCount,
  678.                 cdnUrl: spsupport.p.cdnUrl,
  679.                 appVersion: spsupport.p.appVersion
  680.             };
  681.         }
  682.  
  683.         if( !top.superfish.util && !spsupport.p.iSf){
  684.             spsupport.p.iSf = 1;
  685.             superfish.b.inj(window.document, superfish.b.site + "js/sf_si.js?version=" + spsupport.p.appVersion, 1);
  686.         }
  687.     },
  688.  
  689.     careIcons: function( rep ){
  690.         var sp = spsupport.p;
  691.         var spd = spsupport.domHelper;
  692.         var doc = {elem: sp.$(document)};
  693.        
  694.         sp.icons = this.startDOMEnumeration();
  695.         if (window.conduitToolbarCB && sp.icons > 0 && spsupport.isShowConduitWinFirstTimeIcons){
  696.             conduitToolbarCB("openPageForFirstTimeIcons");
  697.         }
  698.  
  699.         if( sp.icons > 0 || spsupport.sites.ph2bi() ){
  700.             spsupport.api.addSuperfishSupport();
  701.            
  702.             spd.addOnresizeEvent(function() {
  703.                 spsupport.api.fixDivsPos();
  704.             });
  705.  
  706.             spd.addFocusEvent(function() {
  707.                 sp.onFocus = 1;
  708.                 spsupport.api.startDOMEnumeration();
  709.             });
  710.  
  711.             spd.addBlurEvent(function() {
  712.                 sp.onFocus = 0;
  713.                 if (superfish.b.tm) {
  714.                     clearTimeout(superfish.b.tm);
  715.                 }
  716.             });
  717.  
  718.             // check for document resize
  719.             var checkDocResize = function(){
  720.                 doc.width = doc.elem.width();
  721.                 doc.height = doc.elem.height();
  722.                 setTimeout(function(){
  723.                     // check dimensions for change
  724.                     if( doc.height !== doc.elem.height() || doc.width !== doc.elem.width() ){
  725.                         checkDocResize();
  726.                     } else {
  727.                         // start the product grabber
  728.                         spsupport.api.startDOMEnumeration();
  729.                     }
  730.                 }, 250);
  731.             };
  732.  
  733.             // monitor all click events in the document
  734.             doc.elem.on('click', function(e){
  735.                 // target only a elements
  736.                 if( e.target.nodeName.toLowerCase() === 'a' ){
  737.                     checkDocResize();
  738.                 }
  739.             });
  740.  
  741.             spd.addUnloadEvent(spsupport.api.unloadEvent);
  742.             spsupport.api.vMEvent();
  743.  
  744.             //sufio.addOnLoad(function(){
  745.             sp.$(document).ready(function(){    
  746.                 setTimeout(function(){
  747.                     spsupport.api.wRefresh(1300);
  748.                     spsupport.api.saveStatistics()
  749.                 }, spsupport.sites.gRD() );
  750.             });
  751.         } else {
  752.             if(rep == 7){
  753.                 spsupport.api.saveStatistics();
  754.             } else {
  755.                 setTimeout(function(){
  756.                     spsupport.api.careIcons( ++rep );
  757.                 }, 1300 + rep * 400) ;
  758.             }
  759.         }
  760.     },
  761.    
  762.     vMEvent: function(){
  763.         try{
  764.             if( window.superfish && window.superfish.util ){
  765.                 var pDiv = superfish.util.bubble();
  766.                 if( pDiv ){
  767.                     spsupport.domHelper.addEListener( pDiv, spsupport.api.blockDOMSubtreeModified, "DOMSubtreeModified");
  768.                     return;
  769.                 }
  770.             }
  771.         }catch(e){}
  772.         setTimeout( "spsupport.api.vMEvent()", 500 );
  773.     },
  774.  
  775.     puPSearch: function(rep, im){
  776.         if (rep < 101) {
  777.             var sp = spsupport.p;
  778.             var sg = superfish.sg;
  779.             var si = superfish.inimg;
  780.             if(superfish.b.inimg || sg && sg.sSite){
  781.                 if( sp.prodPage.s < 2 || (superfish.p && superfish.p.onAir == 1) ){
  782.                     setTimeout(function(){
  783.                         var sfu = superfish.util;
  784.                         if (sfu) {
  785.                             if( sp.prodPage.s < 2 && !sp.prodPage.e){
  786.                                 var o = spsupport.api.getItemPos(im);
  787.                                 spsupport.p.imPos = o;
  788.                                 var ob;
  789.                                 var ifSg = (sg ? sg.sSite : 0);
  790.                                 var ii = (superfish.b.inimg && si ? si.vi(o.w, o.h) : 0);
  791.                                 ii = (ii > 1 ? ii : 0);
  792.                                 ii = (!superfish.b.inimgSrp && superfish.b.suEnabled[1] && sp.prodPage.i <= 0 ? 0 : ii);
  793.                                 if (si) {
  794.                                     si.itn = ii;
  795.                                 }
  796.                                 // sp.SRP.p
  797.                                 var c1 = 1; // (ii > 1 ? 0 : 1);        /* get items card by card or first from each card */
  798.                                 if (superfish.b.inimg && si && ii < 2 && !ifSg) { /* if no room for ii avoid request */
  799.                                     if (superfish.b.inimgSrp && sp.prodPage.i == 0) {
  800.                                         sp.SRP.c = (sp.SRP.c > 0 ? sp.SRP.c-1 : 0);
  801.                                         spsupport.api.sSrp();
  802.                                     }
  803.                                 }  
  804.                                 else {
  805.                                     ob = spsupport.api.getItemJSON(im);
  806.                                     sfu.prepareData(ob, 1, ifSg, c1, (Math.max(ii, 4)), (si ? si.iiInd : 0));                                    
  807.                                     sfu.openPopup(o, sp.appVersion, 1);
  808.                                     sfu.lastAIcon.x = o.x;
  809.                                     sfu.lastAIcon.y = o.y;
  810.                                     sfu.lastAIcon.w = o.w;
  811.                                     sfu.lastAIcon.h = o.h;
  812.                                     sfu.lastAIcon.img = im;
  813.                                     sp.prodPage.s = 2;
  814.                                 }
  815.                             }
  816.                             }
  817.                             else {
  818.                             setTimeout(function() {
  819.                                 spsupport.api.puPSearch(rep+1, im);
  820.                             }, 100);
  821.                         }
  822.                     }, 30);  
  823.                 }
  824.             }
  825.         }
  826.     },
  827.  
  828.     onDOMSubtreeModified: function( e ){
  829.         var spa = spsupport.api;
  830.         spa.killIcons();
  831.         if(spa.DOMSubtreeTimer){
  832.             clearTimeout(spa.DOMSubtreeTimer);
  833.         }
  834.         spa.DOMSubtreeTimer = setTimeout("spsupport.api.onDOMSubtreeModifiedTimeout()",1000);
  835.     },
  836.     onDOMSubtreeModifiedTimeout: function(){
  837.         clearTimeout(spsupport.api.DOMSubtreeTimer);
  838.         spsupport.api.startDOMEnumeration();
  839.     },
  840.     blockDOMSubtreeModified: function(e,elName){
  841.         e.stopPropagation();
  842.     },
  843.     createImg: function( src ) {
  844.         var img = new Image();
  845.         img.src = src;
  846.         return img;
  847.     },
  848.     loadIcons: function() {
  849.         var sp = spsupport.p;
  850.         var nm = superfish.b.redIcon ? 'ri' : (superfish.b.whiteIcon ? 'wi' : 'si');
  851.         if( sp.sfIcon.icons.length == 0 ){
  852.             for (var i = 0; i < 4; i++) {
  853.                 sp.sfIcon.icons[ i ] = spsupport.api.createImg( sp.imgPath + sp.partner + nm + i + ".png?v=" + sp.appVersion );
  854.             }
  855.         }
  856.     },
  857.  
  858.     killIcons: function() {
  859.         superfish.publisher.imgs = [];
  860.         var bs = this.sfButtons();
  861.         if( bs ){
  862.             document.body.removeChild( bs );
  863.             }
  864.         if (spsupport.p.sfIcon && spsupport.p.sfIcon.ic) {
  865.             spsupport.p.sfIcon.ic.style.top = -200 + "px";
  866.         }
  867.     },
  868.    
  869.     fixDivsPos: function() {
  870.         var sp = spsupport.p;
  871.         var bc = sp.$('#sfButtons');
  872.         sp.$('div', bc).each(function() {
  873.             if( this.img ){
  874.                 var p = spsupport.api.getImagePosition(this.img);
  875.                 this.style.left = p.x + 'px';
  876.                 this.style.top = p.y + 'px';
  877.             }
  878.         });
  879.         spsupport.api.fixIiPos();
  880.     },
  881.    
  882.     fixIiPos: function() {
  883.         var ii, ps, ts;
  884.         if (superfish.inimg && superfish.inimg.ii) {
  885.             for (var i in superfish.inimg.ii) {
  886.                 ii = superfish.inimg.ii[i];
  887.                 if (ii && ii.img) {
  888.                     ps = spsupport.api.getImagePosition(ii.img);
  889.                     ts = ps.y + ps.h;
  890.                     if (ps.x != 0) {
  891.                         ii.style.left = ps.x + 'px';
  892.                         ii.style.top = ts + 'px';                    
  893.                     }
  894.                 }
  895.             }
  896.         }        
  897.     },  
  898.  
  899.     startDOMEnumeration: function(){
  900.         var sfa = spsupport.api;
  901.         var ss = spsupport.sites;
  902.         var sp = spsupport.p;
  903.         var sb = superfish.b;
  904.         var found = 0;
  905.         sfa.killIcons();
  906.         sp.SRP.p = [];
  907.         if( ss.validRefState() ){
  908.             if (sb.icons) {
  909.                 var imSpan = sp.$('<span id="sfButtons"></span>').appendTo(document.body)[0];
  910.             }
  911.  
  912.             var iA = ss.gVI();
  913.             var images = ( iA ? iA : document.images );
  914.             var imgType = 0;
  915.             var noSu;
  916.  
  917.             for( var i=0, l=images.length; i < l; i++ ){
  918.                 imgType = sfa.isImageSupported( images[i] );
  919.                 if ((spsupport.whiteStage.rv || spsupport.whiteStage.pip) && imgType) {
  920.                     imgType = (sb.rvi(images[i]) ? imgType : 0);
  921.                 }
  922.                 if( imgType ){
  923.                     if (sb.icons) {
  924.                         if (! found) {
  925.                             sfa.loadIcons();
  926.                             sfa.addSFProgressBar( imSpan );
  927.                             if (!sp.sfIcon.ic) {
  928.                                 sfa.addSFIcon(document.body);
  929.                             }
  930.                             sfa.addAn();
  931.                         }
  932.                         sfa.addSFDiv(imSpan, images[i]);
  933.                     }
  934.                     noSu = images[i].getAttribute("nosureq");
  935.                     if (noSu != "1") {
  936.                         if(!sb.multiImg){
  937.                             var imgPos = sfa.getImagePosition(images[i]);
  938.                             var res = sfa.validateSU(images[i], parseInt( imgPos.y + images[i].height - 45 ));
  939.                             if( !res &&  !sp.prodPage.i /* && !sp.SRP.i */ ){
  940.                                 sp.SRP.p[sp.SRP.p.length] = images[i];
  941.                                 sp.SRP.i ++;
  942.                             }
  943.                         }
  944.  
  945.                         superfish.publisher.pushImg(images[i]);
  946.                     }
  947.                     found++;
  948.                 }
  949.             }
  950.            
  951.             // enter srp
  952.             if( (sb.suEnabled[1] || superfish.b.inimgSrp) && spsupport.sites.su() && !sp.prodPage.p && !sp.prodPage.s && sp.SRP.p.length ){  
  953.                 if( superfish.sg ){
  954.                     superfish.sg.sSite = 0;
  955.                 }
  956.                 sp.SRP.lim = superfish.b.inimgSrp ?
  957.                     superfish.b.inimgSrp
  958.                     : sb.suEnabled[1] ? sb.suEnabled[1] : 0;
  959.                
  960.                 sp.SRP.lim = Math.min(sp.SRP.lim, sp.SRP.p.length);
  961.                
  962.                 sfa.sSrp();
  963.             }    
  964.             if(found > 0){
  965.                 if (sb.icons) {
  966.                     sp.sfIcon.nl = sp.$("div", imSpan);
  967.                 }
  968.  
  969.                 setTimeout(function(){
  970.                     if( !spsupport.p.statSent ){
  971.                         sfa.saveStatistics();
  972.                         spsupport.p.statSent = 1;
  973.                     }
  974.                 }, 700);
  975.             }
  976.         }
  977.         return found;
  978.     },
  979.  
  980.     imageSupported: function( src ){
  981.         if( src.indexOf( "amazon.com" ) > -1  && src.indexOf( "videos" ) > -1 ){
  982.             return 0;
  983.         }
  984.         try{
  985.             var sIS = spsupport.p.supportedImageURLs;
  986.  
  987.             if( sIS.length == 0 )
  988.                 return 1;
  989.             for( var i = 0; i < sIS.length; i++ ){
  990.                 if( src.indexOf( sIS[ i ] ) > -1 ){
  991.                     return 1;
  992.                 }
  993.             }
  994.         }catch(ex){
  995.             return 0;
  996.         }
  997.         return 0;
  998.     },
  999.  
  1000.     isImageSupported: function(img){
  1001.         var sp = spsupport.p;
  1002.         var evl = +img.getAttribute(sp.sfIcon.evl);
  1003.  
  1004.         if(evl == -1) {
  1005.             return 0;
  1006.         }
  1007.         if(evl == 1) {
  1008.             return 1;
  1009.         }
  1010.        
  1011.         var src = "";
  1012.         try{
  1013.             src = img.src.toLowerCase();
  1014.         }catch(e){
  1015.             return 0;
  1016.         }
  1017.  
  1018.         var iHS = src.indexOf("?");
  1019.         if( iHS != -1 ){
  1020.             src = src.substring( 0, iHS );
  1021.         }                
  1022.  
  1023.         if( src.length < 4 ){
  1024.             return 0;
  1025.         }
  1026.        
  1027.         var ext = src.substring(src.length - 4, src.length);
  1028.         if(ext == ".gif" || ext == ".png" || ext == ".php") {
  1029.             return 0;
  1030.         }
  1031.  
  1032.         var iW = img.width;
  1033.         var iH = img.height;
  1034.  
  1035.         if( ( iW * iH ) < sp.minImageArea ) {
  1036.             return 0;
  1037.         }
  1038.         if(!(spsupport.whiteStage.rv || spsupport.whiteStage.pip)){
  1039.             var ratio = iW/iH;
  1040.             if( ( iW * iH > 2 * sp.minImageArea ) &&
  1041.                 ( ratio < sp.aspectRatio || ratio > ( 1 / sp.aspectRatio ) ) ) {
  1042.                 return 0;
  1043.             }
  1044.         }
  1045.  
  1046.         if (img.getAttribute("usemap")) {
  1047.             return 0;
  1048.         }
  1049.  
  1050.         if( !this.imageSupported( img.src ) ) {
  1051.             return 0;
  1052.         }
  1053.  
  1054.         // check if item is visible
  1055.         if( !spsupport.api.isVisible( img ) ){
  1056.             return 0;
  1057.         }
  1058.  
  1059.         // check if object is not hiding in a scroll list
  1060.         if( !spsupport.api.isViewable( img ) ){
  1061.             return 0;
  1062.         }
  1063.  
  1064.         var imgPos = spsupport.api.getImagePosition(img);
  1065.         if (imgPos.x < 0 || imgPos.y < 10) {
  1066.             return 0;
  1067.         }
  1068.  
  1069.         if( spsupport.sites.imgSupported( img ) ){
  1070.             if(( iW <= sp.sfIcon.maxSmImg.w ) || ( iH <= sp.sfIcon.maxSmImg.h ) ){
  1071.                 return 2;
  1072.             }
  1073.             else {
  1074.                 return 1;
  1075.             }
  1076.         }
  1077.         else{
  1078.             return 0;
  1079.         }
  1080.     },
  1081.  
  1082.     wRefresh : function( del ){
  1083.         setTimeout( function() {
  1084.             spsupport.api.startDOMEnumeration();
  1085.         }, del * 2 );
  1086.     },
  1087.  
  1088.     // checks if the element is not hiding in an overflow:hidden parent
  1089.     isViewable: function ( obj ){
  1090.  
  1091.         var p = spsupport.api.overflowParent( obj.parentNode );
  1092.  
  1093.         if( p ){
  1094.             var r = spsupport.api.getItemPos( obj ),
  1095.                 pPos = spsupport.api.getItemPos( p );
  1096.  
  1097.             // check the elements position relative to it's overflowing parent
  1098.             if ( r.x >= pPos.x + pPos.w || r.y >= pPos.y + pPos.h ){
  1099.                 return 0;
  1100.             } else if ( r.x + r.w <= pPos.x || r.y + r.h <= pPos.y ) {
  1101.                 return 0;
  1102.             }
  1103.         }
  1104.  
  1105.         return 1;
  1106.     },
  1107.    
  1108.     // returns the hiding parent of the element
  1109.     overflowParent: function( obj ){
  1110.         if( !obj || !obj.parentNode || obj == document ) return 0;
  1111.  
  1112.         if( obj.offsetHeight < obj.scrollHeight || obj.offsetWidth < obj.scrollWidth ){
  1113.             if( spsupport.p.$(obj).css('overflow') === 'hidden' && spsupport.p.$(obj.parentNode).css('overflow') === 'visible' ){
  1114.                 return obj;
  1115.             }
  1116.         }
  1117.         return spsupport.api.overflowParent( obj.parentNode );
  1118.     },
  1119.    
  1120.     // checks if the element is visible
  1121.     isVisible: function( obj ){
  1122.  
  1123.         var width = obj.offsetWidth,
  1124.             height = obj.offsetHeight;
  1125.  
  1126.         return !(
  1127.             ( width === 0 && height === 0 )
  1128.             || ( !spsupport.p.$.support.reliableHiddenOffsets && ((obj.style && obj.style.display)
  1129.                 || spsupport.p.$.css( obj, "display" )) === "none")
  1130.         );
  1131.     },
  1132.  
  1133.     sfIPath: function( iType ){ /* 1 - large, 2 - small */
  1134.         var sp = spsupport.p;
  1135.         var icn = ( iType == 2  ?  2  :  0 );
  1136.         return( {
  1137.             r : sp.sfIcon.icons[ icn ].src,
  1138.             o : sp.sfIcon.icons[ icn + 1 ].src
  1139.         } );
  1140.     },
  1141.    
  1142. //    shOverlay: function() {
  1143. //        var sfu = superfish.util;
  1144. //        if (sfu) {
  1145. //            var n = sfu.overlay();
  1146. //            if (n) {
  1147. //                n.style.display = 'block';
  1148. //            }
  1149. //        }        
  1150. //    },
  1151.    
  1152.     osr: function(nI, su) {   /* open search results */
  1153.         var sa = this;
  1154.         var sfu = superfish.util;
  1155.         var sp = spsupport.p;
  1156.         var act = "findByUrlLanding.action";
  1157.         var flp = 0;  /* from landing page */
  1158.         var pu = window.location.href;
  1159.         var osi;    /* original session id */
  1160.         if (pu.indexOf(act) > -1) {
  1161.             flp = 1;
  1162.             var ar = pu.split("&");
  1163.             for (var i=1; i<ar.length; i++) {
  1164.                 if (ar[i].indexOf("sessionid") > -1) {
  1165.                     osi = ar[i].split("=")[1];
  1166.                     break;
  1167.                 }
  1168.             }
  1169.            
  1170.         }
  1171.         var o = sa.getItemJSON(nI.img);
  1172.         var stt = (sp.supportedSite ? "wl" : (spsupport.whiteStage.st ? "st" : (spsupport.whiteStage.rv ? "rv" : (spsupport.whiteStage.pip ? "pip" : "ign"))));
  1173.         var ac = superfish.p.site + act + "?";        
  1174.         ac = ac +
  1175.             "userid=" + decodeURIComponent(o.userid) +
  1176.             "&sessionid=" + sfu.getUniqueId() +
  1177.             "&dlsource=" + sp.dlsource +
  1178.             ( sp.CD_CTID != "" ? "&CD_CTID=" + sp.CD_CTID : "" ) +
  1179.             "&merchantName=" + o.merchantName +
  1180.             "&imageURL=" + o.imageURL +
  1181.             "&imageTitle=" + o.imageTitle +
  1182.             "&imageRelatedText=" + o.imageRelatedText +
  1183.             "&documentTitle=" + o.documentTitle  +
  1184.             "&productUrl=" + o.productUrl +
  1185.             (o.pr ? "&pr=" +  o.pr : "") +
  1186.             "&slideUp=" + su +
  1187.             "&ii=0&identical=0" +
  1188.             "&pageType=" + sp.pageType +
  1189.             "&siteType=" + stt +
  1190.             (spsupport.p.isIE7 || flp ? "" : "&pageUrl=" + pu) +
  1191.             "&ip=" + superfish.b.ip +
  1192.             (osi ? "&origSessionId=" + osi : "") +
  1193.             ((superfish.b.tg && superfish.b.tg != "") ? "&tg=" + superfish.b.tg : "") +
  1194.             "&br=" + sa.dtBr();
  1195.            
  1196.             window.location.href = ac;
  1197.     },
  1198.  
  1199.     goSend: function(ev, nI, anim) {
  1200.         var sfu = superfish.util;
  1201.         var sa = this;
  1202.         var sp = spsupport.p;
  1203.         var img = nI.img;
  1204.         if(sfu) {
  1205.             if (ev == 1 || ev == 2) {
  1206.                 if (sfu.currImg != img) {
  1207.                     // sfu.lastAIcon.img = img;
  1208.                     sfu.currImg = img;
  1209.                     sp.imPos = sa.getItemPos(img);
  1210.                     //if (superfish.b.preSlideUpOn) {
  1211.                     if (superfish.p.onAir) {
  1212.                         sfu.closePopup();
  1213.                     }
  1214.                     sfu.prepareData(sa.getItemJSON(img), 0, 0, 0, 0);
  1215.                     nI.sent = 1;
  1216.                     clearTimeout(sp.iconTm);
  1217.                     clearTimeout(sp.oopsTm);
  1218.                     sp.prodPage.e = 1;
  1219.                 }
  1220.             }
  1221.             if (ev == 1 || ev == 3) {
  1222.                 nI.src = spsupport.api.sfIPath(nI.type).r;
  1223.                 sa.resetPBar(anim, nI);
  1224. //                this.shOverlay();
  1225.                 sp.sfIcon.prog.e = 2;
  1226.                 if (sfu.currImg == img && sp.before == 0) {
  1227.                     sfu.updIframeSize(sp.itemsNum, sp.tlsNum, 0);
  1228.                     sfu.openPopup(sp.imPos, sp.appVersion, 0);
  1229.                 }
  1230.             }
  1231.         }
  1232.         else {
  1233.             setTimeout (function(){
  1234.                 spsupport.api.goSend(ev, nI, anim);
  1235.             }, 400);
  1236.         }
  1237.     },
  1238.  
  1239.     resetPBar: function(anim, nI) {
  1240.         var sp = spsupport.p;
  1241.         var pBar = sp.sfIcon.prog.node;
  1242.         //var pBar = sp.$(sp.sfIcon.prog.node);
  1243. //        pBar.stop().css({
  1244. //            width: "0px",
  1245. //            display: "none"
  1246. //        });
  1247.         if( pBar ){
  1248.             anim.stop();
  1249.             sufio.style(
  1250.                 pBar ,{
  1251.                     width: "0px",
  1252.                     display: "none"
  1253.                 });
  1254.         }
  1255.         nI.sent = 0;
  1256.     },
  1257.    
  1258.     hdIcon: function() {
  1259.       var sp = spsupport.p;
  1260.       sp.$(sp.sfIcon.ic).css({
  1261.           'top': '-100px'
  1262.         });
  1263.     },
  1264.    
  1265.     addSFIcon: function(parent){        
  1266.         var sp = spsupport.p;
  1267.         var sfu = superfish.util;
  1268.         var sa = spsupport.api;
  1269.         var hWidth = parseInt(sp.sfIcon.prog.w[0]/4.2);
  1270.         var hWidth2 = parseInt(sp.sfIcon.prog.w[1]/4.2);
  1271.         var nm = superfish.b.redIcon ? 'ri' : (superfish.b.whiteIcon ? 'wi' : 'si');
  1272.         sp.sfIcon.ic = sa.createImg( sp.imgPath + sp.partner + nm + 0 + ".png?v=" + sp.appVersion );
  1273.         var nI = sp.sfIcon.ic;
  1274.         nI.setAttribute(sp.sfIcon.evl, '-1');
  1275.         nI.title = " See Similar ";
  1276.         nI.style.position = "absolute";
  1277.         nI.style.top = -200 + "px";
  1278.         nI.style.left = -200 + "px";
  1279.         var zindex = 12005;
  1280.         if (spsupport.p.isIE7) {
  1281.             zindex = zindex*100;
  1282.         }
  1283.         nI.style.zIndex = zindex;
  1284.         nI.style.cursor = "pointer";
  1285.         /* BUG IN IE */
  1286.         nI.style.width = "" + sp.sfIcon.big.w + "px";
  1287.         nI.style.height = "" + sp.sfIcon.big.h + "px";
  1288.         nI.type = 1;
  1289.         nI.src = sa.sfIPath(nI.type).r;
  1290.        
  1291.         var anim = sufio.animateProperty({
  1292.             node: sp.sfIcon.prog.node,
  1293.             duration: sp.sfIcon.prog.time,
  1294.             properties: {
  1295.                 width: {
  1296.                     start: "0",
  1297.                     end:  sp.sfIcon.prog.w[0],
  1298.                     unit: "px"
  1299.                 }
  1300.             },
  1301.             onEnd: function() {
  1302.                 if (superfish.b.lp) {
  1303.                     sa.osr(nI, 0);
  1304.                 }
  1305.                 else {
  1306.                     sa.goSend(3, nI, anim);
  1307.                 }
  1308.             }
  1309.         });
  1310.        
  1311.         var anim2 = sufio.animateProperty({
  1312.             node: sp.sfIcon.prog.node,
  1313.             duration: sp.sfIcon.prog.time,
  1314.             properties: {
  1315.                 width: {
  1316.                     start: "0",
  1317.                     end:  sp.sfIcon.prog.w[1],
  1318.                     unit: "px"
  1319.                 }
  1320.             },
  1321.             onEnd: function() {
  1322.                 if (superfish.b.lp) {
  1323.                     sa.osr(nI, 0);
  1324.                 }
  1325.                 else {
  1326.                     sa.goSend(3, nI, anim2);
  1327.                 }
  1328.             }
  1329.         });
  1330.  
  1331.  
  1332.         sufio.connect( anim,'onAnimate', function( curveValue ){
  1333.             if ( !nI.sent ) {
  1334.                 if( parseInt(curveValue.width) >= hWidth && !superfish.b.lp){
  1335.                     spsupport.api.goSend(2, nI, anim);
  1336.                 }
  1337.             }
  1338.         });
  1339.        
  1340.         sufio.connect( anim2,'onAnimate', function( curveValue ){
  1341.             if ( !nI.sent ) {
  1342.                 if( parseInt(curveValue.width) >= hWidth2 && !superfish.b.lp){
  1343.                     spsupport.api.goSend(2, nI, anim2);
  1344.                 }
  1345.             }
  1346.         });
  1347.  
  1348.        
  1349.         nI.onmouseout = function(e){
  1350.             if (!e) {
  1351.                 e = window.event;
  1352.             }
  1353.             var relTarget = ( (e.relatedTarget) ? e.relatedTarget : e.toElement );
  1354.             if( relTarget != sp.sfIcon.prog.node ){
  1355.                 this.src = spsupport.api.sfIPath(this.type).r;
  1356.                 sp.sfIcon.prog.e = (sp.sfIcon.prog.e == 2 ? 2 : 0);
  1357.                 var anm = (nI.type == 1 ? anim : anim2);
  1358.                 spsupport.api.resetPBar(anm, this);
  1359.                 if (sp.sfIcon.prog.e == 0) {
  1360.                     if (sfu) {
  1361.                         sfu.hideLaser();
  1362.                     }
  1363.                     else {
  1364.                         if (spsupport.p.sfIcon.an) {
  1365.                             spsupport.p.sfIcon.an.style.top = '-2000px';
  1366.                             spsupport.p.sfIcon.an.style.left = '-2000px';
  1367.                         }
  1368.                     }
  1369.                 }
  1370.                 if (sp.before == 2) {
  1371.                     if (sfu) {
  1372.                         sfu.reportClose();
  1373.                     }
  1374.                 }
  1375.             }
  1376.         };
  1377.  
  1378.         nI.onmouseover  = function(e){
  1379.                 if (!e) {
  1380.                     e = window.event;
  1381.                 }
  1382.                 var relTarget = ( (e.relatedTarget) ? e.relatedTarget : e.fromElement );
  1383.                 if ( relTarget != sp.sfIcon.prog.node) {
  1384.                     // var typ = (this.w > sp.sfIcon.small.w ? 1 : 2);
  1385.                     this.src = spsupport.api.sfIPath(this.type).o;
  1386.                     sp.sfIcon.prog.e = 1;
  1387.                     if (sp.sfIcon.prog.node) {
  1388.                         var iProp = ( nI.type == 2  ?  sp.sfIcon.small  :  sp.sfIcon.big );
  1389.                         var dif = iProp.h - sp.sfIcon.prog.h;
  1390.                         sp.$(sp.sfIcon.prog.node).css({
  1391.                                 display: "block",
  1392.                                 top: parseInt( nI.style.top ) + dif - (superfish.b.redIcon ? 5 : (superfish.b.whiteIcon ? 1 : 2)) + "px",
  1393.                                 left: parseInt( nI.style.left ) + (superfish.b.redIcon ? 5 : (superfish.b.whiteIcon ? 1 : 2)) + "px"
  1394.                             });
  1395.                         var ip = spsupport.api.getItemPos(nI.img);
  1396.                         var anm = (nI.type == 1 ? anim : anim2);
  1397.                         anm.play();    
  1398.                         if (superfish.util) {
  1399.                             superfish.util.hideLaser();
  1400.                                 superfish.util.showLaser(ip);
  1401.                         }
  1402.                     }
  1403.                 }
  1404.         };
  1405.  
  1406.         sp.sfIcon.prog.node.onmouseout = function(e){
  1407.             if (!e) {
  1408.                 e = window.event;
  1409.             }
  1410.             var relTarget = ( e.relatedTarget ? e.relatedTarget: e.toElement );
  1411.             if( !relTarget ||  relTarget != sp.sfIcon.ic ){
  1412.                 sp.sfIcon.ic.onmouseout( e );
  1413.             }
  1414.         };
  1415.            
  1416.        
  1417.         nI.onmousedown = function(e){
  1418.             var evt = e || window.event;
  1419.             if( evt && evt.button == 2 ) {
  1420.                 return;
  1421.             }
  1422.             if (this.img) {
  1423.                 var anm = (nI.type == 1 ? anim: anim2);
  1424.                 if (superfish.b.lp) {
  1425.                     spsupport.api.osr(nI, 0);
  1426.                 }
  1427.                 else {
  1428.                     spsupport.api.goSend(1, this, anm);
  1429.                 }
  1430.             }
  1431.         };
  1432.        
  1433.         sp.sfIcon.prog.node.onmousedown = function(e){
  1434.             nI.onmousedown();
  1435.         };
  1436.        
  1437.         parent.appendChild( nI );
  1438.     },
  1439.    
  1440.     addSFDiv: function(pr, img) {
  1441.         var bi = 600;
  1442.         var sp = spsupport.p;
  1443.         var spi = sp.sfIcon;
  1444.         var spa = spsupport.api;
  1445.            
  1446.         var dv = document.createElement("div");
  1447.            
  1448.         var imgPos = spsupport.api.getImagePosition(img);
  1449.         if (img.width > bi || img.height > bi || imgPos.x < 0 || imgPos.y < 10) {
  1450.             return;
  1451.         }
  1452.            
  1453.         sufio.style(
  1454.             dv ,{
  1455.                 border: 'none', //"solid 1px",
  1456.                 backgroundColor: "#fff",
  1457.                 opacity: 0.01,
  1458.                 zIndex: "12002",
  1459.                 //zIndex: "-1",
  1460.                 position: "absolute",
  1461.                 width: (img.width) + "px",
  1462.                 height: (img.height) + "px",
  1463.                 top: parseInt(imgPos.y) + "px",
  1464.                 display: "inline-block",
  1465.                 left: parseInt(imgPos.x) + "px"
  1466.             });
  1467.        
  1468.         dv.img = img;
  1469.                
  1470.         dv.onmouseover  = function(e){
  1471.             if (!e) {
  1472.                 e = window.event;
  1473.             }
  1474.             var relTarget = e.relatedTarget ? e.relatedTarget : e.fromElement;
  1475.             if (superfish.p.onAir && superfish.util && this.img == superfish.util.currImg) {
  1476.                 return;
  1477.             }
  1478.             if ( relTarget != spi.ic) { // && relTarget != cv) {
  1479.                 var nI = spi.ic;
  1480.                 nI.img = this.img;
  1481.                 if (superfish.util) {
  1482.                     superfish.util.hideLaser();
  1483.                 }
  1484.  
  1485.                 var imgPos = spa.getImagePosition(img);
  1486.                 var lf = parseInt(this.style.left);
  1487.                 var tp = parseInt(this.style.top);
  1488.                 if (Math.abs(imgPos.x - lf) > 100 || Math.abs(imgPos.y - tp) > 100) {
  1489.                     spa.startDOMEnumeration();
  1490.                 }
  1491.                 if(( img.width <= spi.maxSmImg.w ) || ( img.height <= spi.maxSmImg.h ) ) {
  1492.                     spsupport.p.$(nI).css({
  1493.                         width:  spi.small.w + "px",
  1494.                         height: spi.small.h + "px"
  1495.                     });
  1496.  
  1497.                     nI.src = spsupport.api.sfIPath(2).r;
  1498.                     nI.type = 2;
  1499.                 }
  1500.                 else {
  1501.                     spsupport.p.$(nI).css({
  1502.                         width:  spi.big.w + "px",
  1503.                         height: spi.big.h + "px"
  1504.                     });
  1505.                     nI.src = spsupport.api.sfIPath(1).r;
  1506.                     nI.type = 1;
  1507.                 }
  1508.  
  1509.                 var io = (nI.type == 1 ? spi.big : spi.small);
  1510.                 var t = superfish.b.redIcon || superfish.b.whiteIcon ? (imgPos.y + 2) : (img.height > 199 ? (imgPos.y + img.height - io.h + 3) : (imgPos.y + img.height - img.height/6));
  1511.                 var l = superfish.b.redIcon || superfish.b.whiteIcon ? (imgPos.x - (io.w - img.width)/2) : (img.width > spi.big.w*2 ? (imgPos.x + 1) : (imgPos.x - (io.w - img.width)/2));
  1512.                 nI.style.top = "" + parseInt(t) + "px";
  1513.                 nI.style.left = "" + parseInt(l) + "px";
  1514.             }
  1515.                
  1516.             sp.sfIcon.nl.show(); //.style("display","inline-block");
  1517.             this.style.display = "none";
  1518.         };
  1519.            
  1520.         pr.appendChild(dv);
  1521.        
  1522.     },
  1523.  
  1524.     validateSU: function( im, iT ){
  1525.         var sp = spsupport.p;
  1526.         var cnd = (superfish.b.inimg ? parseInt(iT) > 0 : true);
  1527.         var cndM = im.width > sp.prodPage.d && im.height > sp.prodPage.d && parseInt(iT) < sp.prodPage.l;
  1528.         cndM = cndM && cnd && sp.prodPage.p != im || spsupport.sites.validProdImg();
  1529.         if( spsupport.sites.su() && !sp.prodPage.s &&
  1530.             ( spsupport.p.supportedSite || spsupport.whiteStage.st ?
  1531.                 cndM :
  1532.                 sp.prodPage.p != im )
  1533.             ){
  1534.             sp.prodPage.s = 1;
  1535.             sp.prodPage.i ++;
  1536.             sp.pageType = "PP";
  1537.             sp.prodPage.p = im;
  1538.             sp.SRP.reset();
  1539.             setTimeout(function() {
  1540.                 spsupport.api.puPSearch(1, im);
  1541.             }, 30);
  1542.             return(1);
  1543.         }
  1544.         return(0);
  1545.     },
  1546.    
  1547.     addSFProgressBar: function(iNode){
  1548.         var bProp = spsupport.p.sfIcon.prog;
  1549.         if( !bProp.node ) {
  1550.             bProp.node = sufio.place("<div id='sfIconProgressBar'></div>", iNode, "after" );
  1551.             var rd = superfish.b.redIcon ? 10 : 4;
  1552.             bProp.node.setAttribute('style', '-moz-border-radius : '+rd+'px; -webkit-border-radius : '+rd+'px; border-radius: '+rd+'px;');
  1553.             sufio.style( bProp.node ,{
  1554.                 position: "absolute",
  1555.                 overflow: "hidden",
  1556.                 width: "0px",
  1557.                 height: bProp.h + "px",
  1558.                 zIndex: "12008",
  1559.                 cursor: "pointer",
  1560.                 backgroundColor: bProp.color,
  1561.                 opacity: bProp.opac
  1562.             });
  1563.         }
  1564.     },
  1565.    
  1566.     addAn: function(){
  1567.         var sp = spsupport.p;
  1568.         if( !sp.sfIcon.an ) {            
  1569.             sp.sfIcon.an = sufio.place("<div id='sfImgAnalyzer'></div>", sufio.body());
  1570.             sufio.style(sp.sfIcon.an ,{
  1571.                 position: "absolute",
  1572.                 overflow: "hidden",
  1573.                 width: "24px",
  1574.                 height: "100px",
  1575.                 zIndex: "12000",
  1576.                 top: "-200px",
  1577.                 left: "-200px",
  1578.                 filter: "progid:DXImageTransform.Microsoft.AlphaImageLoader(src=" + spsupport.p.imgPath + spsupport.p.partner + "/scan.png,sizingMethod='image')",
  1579.                 background: "url(" + sp.imgPath + sp.partner + "scan.png) repeat-y"
  1580.                
  1581.             });
  1582.         }
  1583.     },
  1584.  
  1585.     sfButtons: function(){
  1586.         return document.getElementById("sfButtons");
  1587.     },
  1588.    
  1589.     getImagePosition: function(img) {
  1590.        
  1591.         var jqImage = spsupport.p.$(img),
  1592.             imgPos = jqImage.position(),
  1593.             imgOffset = jqImage.offset();
  1594.  
  1595.         // returns an object that duplicates the returned dojo coords method.
  1596.         // the returned options are for legacy purposes
  1597.         return {
  1598.             l: imgPos.left,
  1599.             t: imgPos.top,
  1600.             w: jqImage.outerWidth(true),
  1601.             h: jqImage.outerHeight(true),
  1602.             x: imgOffset.left,
  1603.             y: imgOffset.top
  1604.         }
  1605.     },
  1606.  
  1607.     getMeta: function(name) {
  1608.         var mtc = spsupport.p.$('meta[name = "'+name+'"]');
  1609.         if(mtc.length){
  1610.             return  mtc[0].content;
  1611.         }
  1612.         return '';
  1613.     },
  1614.    
  1615.     getLinkNode: function(node, level){
  1616.         var lNode = 0;
  1617.         if (node) {
  1618.             var tn = node;
  1619.             for (var i = 0; i < level; i++) {
  1620.                 if (tn) {
  1621.                     if (tn.nodeName.toUpperCase() == "A") {
  1622.                         lNode = tn;
  1623.                         break;
  1624.                     }
  1625.                     else {
  1626.                         tn = tn.parentNode;
  1627.                     }
  1628.                 }
  1629.             }
  1630.         }
  1631.         return lNode;
  1632.     },
  1633.  
  1634.     textFromLink: function(lNode, url, sec, all){
  1635.         var sfMN = spsupport.p.merchantName.toLowerCase();
  1636.         var txt = lNode.getAttribute("title");
  1637.         txt = txt ? txt+" ": "";
  1638.         if( url.indexOf( "javascript" ) == -1 ){
  1639.             url = url.replace(/http:\/\//g, "");
  1640.             if( sfMN != "sears" ){
  1641.                 url = url.replace( document.domain, "");
  1642.             }
  1643.             var urlLC = url.toLowerCase();
  1644.             var _url = ""
  1645.             var plus = url.lastIndexOf( "+", url.length - 1 );
  1646.             _url = ( plus > -1 ? url.substr( plus + 1, url.length - 1 ) : "" );
  1647.             urlLC = ( plus > -1 ? url.substr( plus + 1, url.length - 1 ) : urlLC );
  1648.             var q = 'a[href *= "' + (_url != "" ? _url : url ) + '"], a[href *= "' + urlLC  + '"]';
  1649.             q = (all && sec ? 'a' : q);
  1650.             //var nodes = (sec ? sufio.query(q, sec) : sufio.query(q));
  1651.             var nodes = (sec ? spsupport.p.$(q, sec) : spsupport.p.$(q));
  1652.             nodes.each(
  1653.                 function() {
  1654.                     if( (_url !="" && this.href.toLowerCase().indexOf( url, 0) > -1 ) || _url =="" || all) {
  1655.                         txt += (" " + spsupport.api.getTextOfChildNodes(this)) ;
  1656.                     }
  1657.                 });
  1658.         }
  1659.         return spsupport.p.$.trim(txt);
  1660.     },
  1661.  
  1662.     getTextOfChildNodes: function(node){
  1663.         var txtNode = "";
  1664.         var ind;
  1665.         for( ind = 0; ind < node.childNodes.length; ind++ ){
  1666.             if( node.childNodes[ ind ].nodeType == 3 ) { // "3" is the type of <textNode> tag
  1667.                 txtNode = spsupport.p.$.trim( txtNode + " " + node.childNodes[ ind ].nodeValue );
  1668.             }
  1669.             if( node.childNodes[ ind ].childNodes.length > 0 ) {
  1670.                 txtNode = spsupport.p.$.trim( txtNode +
  1671.                     " "  + spsupport.api.getTextOfChildNodes( node.childNodes[ ind ] ) );
  1672.             }
  1673.         }
  1674.         return txtNode;
  1675.     },
  1676.  
  1677.     vTextLength: function( t ) {
  1678.         if( t.length > 1000 ){
  1679.             return "";
  1680.         }else if( t.length < 320 ){
  1681.             return t;
  1682.         }else{
  1683.             if( spsupport.p.isIE7 ){
  1684.                 return t.substr(0, 320);
  1685.             }
  1686.             return t;
  1687.         }
  1688.     },
  1689.    
  1690.     showDivs: function() {
  1691.       var bs = this.sfButtons();
  1692.       spsupport.p.$('div', spsupport.p.$(bs)).show();
  1693.     },    
  1694.  
  1695.     getItemJSON: function( img ) {
  1696.         var spa = spsupport.api;
  1697.         var sp = spsupport.p;
  1698.         var iURL = "";
  1699.         try{
  1700.             iURL = decodeURIComponent( img.src );
  1701.         }catch(e){
  1702.             iURL = img.src;
  1703.         }
  1704.        
  1705.         var relData = spsupport.sites.getRelText( img.parentNode, spa.getLinkNode, spa.textFromLink );
  1706.         var pt = ( sp.prodPage.i > 0 ? "PP": "SRP" );
  1707.        
  1708.         // var pTxt = '';
  1709.         var dt = (pt == 'PP' && img != sp.prodPage.p ? '' : encodeURIComponent( document.title + spsupport.api.getMK( img ) ));
  1710.         var irt = ( relData ? encodeURIComponent( spa.vTextLength(  relData.iText  ) ) : '' );
  1711.         var it = spsupport.whiteStage.rv || spsupport.whiteStage.pip ? spa.getTitleText() :encodeURIComponent(spsupport.p.$.trim( img.title + " " + img.alt ));
  1712.         var pu = ( relData ? relData.prodUrl : "" );
  1713.         // var pr = superfish.b.gp();        
  1714. //        if (spsupport.whiteStage.rv) {            
  1715. ////            var del = '@@';
  1716. ////            pTxt = del + this.getMeta('keywords') + del + superfish.publisher.extractTxt(img) + del + (spsupport.p.isIE7 ? "" : window.location.href);
  1717. //            dt = dt + ' ' + irt + ' ' + it;
  1718. //            irt = '';
  1719. //            it = '';
  1720. //            }
  1721.         var pr = superfish.b.gp(img);
  1722.         var jsonObj = {
  1723.             userid: encodeURIComponent( sp.userid ),
  1724.             merchantName: encodeURIComponent( spa.merchantName() ),
  1725.             dlsource: sp.dlsource ,
  1726.             appVersion: sp.appVersion,
  1727.             documentTitle: dt,
  1728.             imageURL: encodeURIComponent( spsupport.sites.vImgURL( iURL ) ),
  1729.             //+ "?" + new Date().getTime() ),        // !!! SERVER CAHCE FREE
  1730.             imageTitle: it,
  1731.             imageRelatedText: irt,
  1732.             pr: pr,
  1733.             // productUrl: encodeURIComponent(( relData ? relData.prodUrl : "" ) + pTxt)
  1734.             productUrl: encodeURIComponent(pu)
  1735.         };
  1736.         return jsonObj;
  1737.     },
  1738.    
  1739.     /**
  1740.      * Return the item name from the page title text
  1741.      */
  1742.     getTitleText: function(){
  1743.         var text = spsupport.p.$('title').text().toLowerCase();
  1744.         var reviewIndex = text.indexOf("review");
  1745.         var pipeIndex = text.indexOf("|");
  1746.         if (pipeIndex !== -1){
  1747.             text = text.substr(0, pipeIndex);
  1748.         }
  1749.         if (reviewIndex !== -1 ){
  1750.             //case the first word is review
  1751.             if(reviewIndex < 5){
  1752.                 text = text.split("review")[1];
  1753.             }else{
  1754.                 text = text.substr(0, reviewIndex-1);
  1755.             }  
  1756.         }
  1757.         return text;
  1758.     },
  1759.  
  1760.     getItemPos: function(img) {
  1761.         var iURL = "";
  1762.         try{
  1763.             iURL = decodeURIComponent( img.src );
  1764.         }catch(e){
  1765.             iURL = img.src;
  1766.         }
  1767.        
  1768.         var imgPos = spsupport.api.getImagePosition( img );
  1769.         var jsonObj = {
  1770.             imageURL: encodeURIComponent( spsupport.sites.vImgURL( iURL ) ),
  1771.             x: imgPos.x,
  1772.             y: imgPos.y,
  1773.             w: img.width || img.offsetWidth,
  1774.             h: img.height || img.offsetHeight
  1775.         };
  1776.         return jsonObj;
  1777.     },
  1778.  
  1779.     // Get Meta Keywords
  1780.     getMK: function( i ){
  1781.         var dd = document.domain.toLowerCase();
  1782.         if( ( dd.indexOf("zappos.com") > -1 || dd.indexOf("6pm.com") > -1 ) &&
  1783.             ( spsupport.p.prodPage.i > 0 && spsupport.p.prodPage.p  == i ) ){
  1784.             var kw = spsupport.p.$('meta[name = "keywords"]');
  1785.             if( kw.length){
  1786.                 kw = kw[0].content.split(",");
  1787.                 var lim = kw.length > 2 ? kw.length - 3 : kw.length - 1;
  1788.                 var kwc = "";
  1789.                 for( var j = 0; j <= lim; j++ ){
  1790.                     kwc = kw[ j ] + ( j < lim ? "," : ""  )
  1791.                 }
  1792.                 return " [] " + kwc;
  1793.             }
  1794.         }
  1795.         return "";
  1796.     },
  1797.  
  1798.     merchantName: function()  {
  1799.         return  spsupport.p.merchantName;
  1800.     },
  1801.     superfish: function(){
  1802.         return window.top.superfish;
  1803.     },
  1804.  
  1805.     sendMessageToExtenstion: function( msgName, data ){
  1806.         var d = document;
  1807.         if(sufio){
  1808.             var jsData = sufio.toJson(data);
  1809.             if (spsupport.p.isIE) {
  1810.                 try {
  1811.                     // The bho get the parameters in a reverse order
  1812.                     window.sendMessageToBHO(jsData, msgName);
  1813.                 } catch(e) {}
  1814.             } else {
  1815.                 var el = d.getElementById("sfMsgId");
  1816.                 if (!el){
  1817.                     el = d.createElement("sfMsg");
  1818.                     el.setAttribute("id", "sfMsgId");
  1819.                     d.body.appendChild(el);
  1820.                 }
  1821.                 el.setAttribute("data", jsData);
  1822.                 var evt = d.createEvent("Events");
  1823.                 evt.initEvent(msgName, true, false);
  1824.                 el.dispatchEvent(evt);
  1825.             }
  1826.         }
  1827.     },
  1828.     saveStatistics: function() {
  1829.         var sp = spsupport.p;
  1830.         if( document.domain.indexOf("superfish.com") > -1 ||
  1831.             sp.dlsource == "conduit" ||
  1832.             sp.dlsource == "pagetweak" ||
  1833.             sp.dlsource == "similarweb"){
  1834.             return;
  1835.         }
  1836.         var imageCount = 0;
  1837.         var sfButtons = spsupport.api.sfButtons();
  1838.         if( sfButtons != null ){
  1839.             imageCount = sfButtons.children.length;
  1840.         }
  1841.         var data = {
  1842.             "imageCount": imageCount,
  1843.             "ip": superfish.b.ip
  1844.         }
  1845.         if( spsupport.api.isOlderVersion( '1.2.0.0', sp.clientVersion ) ){
  1846.             data.Url = document.location;
  1847.             data.userid = sp.userid;
  1848.             data.versionId = sp.clientVersion;
  1849.             data.dlsource = sp.dlsource;
  1850.  
  1851.             if( sp.CD_CTID != "" ) {
  1852.                 data.CD_CTID = sp.CD_CTID;
  1853.             }
  1854.             spsupport.api.jsonpRequest( sp.sfDomain_ + "saveStatistics.action", data );
  1855.         } else  {
  1856.             spsupport.api.sendMessageToExtenstion("SuperFishSaveStatisticsMessage", data);
  1857.         }
  1858.     },
  1859.  
  1860.     isOlderVersion: function(bVer, compVer) {
  1861.         var res = 0;
  1862.         var bTokens = bVer.split(".");
  1863.         var compTokens = compVer.split(".");
  1864.  
  1865.         if (bTokens.length == 4 && compTokens.length == 4){
  1866.             var isEqual = 0;
  1867.             for (var z = 0; z <= 3 && !isEqual && !res ; z++){
  1868.                 if (+(bTokens[z]) > +(compTokens[z])) {
  1869.                     res = 1;
  1870.                     isEqual = 1;
  1871.                 } else if (+(bTokens[z]) < +(compTokens[z])) {
  1872.                     isEqual = 1;
  1873.                 }
  1874.             }
  1875.         }
  1876.         return res;
  1877.     },
  1878.  
  1879.     leftPad: function( val, padString, length) {
  1880.         var str = val + "";
  1881.         while (str.length < length){
  1882.             str = padString + str;
  1883.         }
  1884.         return str;
  1885.     },
  1886.  
  1887.     getDateFormated: function(){
  1888.         var dt = new Date();
  1889.         return dt.getFullYear() + spsupport.api.leftPad( dt.getMonth() + 1,"0", 2 ) + spsupport.api.leftPad( dt.getDate(),"0", 2 ) + "";
  1890.     },
  1891.    
  1892.     dtBr: function() {
  1893.         var ua = navigator.userAgent;
  1894.         var br = "unknown";
  1895.         if (ua) {
  1896.             ua = ua.toLowerCase();
  1897.             if (ua.indexOf("msie 7") > -1){
  1898.                 br = "ie7";
  1899.             }
  1900.             else if (ua.indexOf("msie 8") > -1) {
  1901.                 br = "ie8";
  1902.             }
  1903.             else if (ua.indexOf("msie 9") > -1) {
  1904.                 br = "ie9";
  1905.             }
  1906.             else if (ua.indexOf("firefox/5") > -1) {
  1907.                 br = "ff5";
  1908.             }
  1909.             else if (ua.indexOf("firefox/6") > -1) {
  1910.                 br = "ff6";
  1911.             }
  1912.             else if (ua.indexOf("firefox/7") > -1) {
  1913.                 br = "ff7";
  1914.             }
  1915.             else if (ua.indexOf("firefox/8") > -1) {
  1916.                 br = "ff8";
  1917.             }
  1918.             else if (ua.indexOf("firefox/9") > -1) {
  1919.                 br = "ff9";
  1920.             }
  1921.             else if (ua.indexOf("firefox/10") > -1) {
  1922.                 br = "ff10";
  1923.             }
  1924.             else if (ua.indexOf("firefox") > -1) {
  1925.                 br = "ff";
  1926.             }
  1927.             else if (ua.indexOf("chrome") > -1) {
  1928.                 br = "ch";
  1929.             }
  1930.             else if (ua.indexOf("apple") > -1) {
  1931.                 br = "sa";
  1932.             }
  1933.         }
  1934.         return br;
  1935.     },
  1936.  
  1937.     nofityStatisticsAction:function(action) {
  1938.         var sp = spsupport.p;
  1939.         if(sp.w3iAFS != ""){
  1940.             data.w3iAFS = sp.w3iAFS;
  1941.         }
  1942.         if(sp.CD_CTID != ""){
  1943.             data.CD_CTID = sp.CD_CTID;
  1944.         }
  1945.  
  1946.         spsupport.api.jsonpRequest( sp.sfDomain_ + "notifyStats.action", {
  1947.             "action": action,
  1948.             "userid": sp.userid,
  1949.             "versionId": sp.clientVersion,
  1950.             "dlsource": sp.dlsource,
  1951.             "browser": navigator.userAgent
  1952.         });
  1953.     },
  1954.     unloadEvent: function(){
  1955.     }
  1956. };
  1957.  
  1958. spsupport.domHelper = {
  1959.     oldOnMouseMove: 0,
  1960.  
  1961.     addOnresizeEvent : function(func){
  1962.         if (typeof window.onresize != 'function'){
  1963.             window.onresize = func;
  1964.         } else {
  1965.             var oldonresize = window.onresize;
  1966.             window.onresize = function(e) {
  1967.                 if( oldonresize ){
  1968.                     if (spsupport.p.isIE) {
  1969.                         oldonresize(e);
  1970.                     }
  1971.                     else {
  1972.                         setTimeout( oldonresize,350 );
  1973.                     }
  1974.                 }
  1975.                 if( spsupport.p.isIE ) {
  1976.                     func(e);
  1977.                 }
  1978.                 else {
  1979.                     setTimeout(func, 200);
  1980.                 }
  1981.             }
  1982.         }
  1983.     },
  1984.     addFocusEvent: function(func){
  1985.         var oldonfocus = window.onfocus;
  1986.         if (typeof window.onfocus != 'function') {
  1987.             window.onfocus = func;
  1988.         }else{
  1989.             window.onfocus = function(e)  {
  1990.                 if (oldonfocus) {
  1991.                     oldonfocus(e);
  1992.                 }
  1993.                 func(e);
  1994.             }
  1995.         }
  1996.     },
  1997.  
  1998.     addBlurEvent: function(func){
  1999.         var oldonblur = window.onblur;
  2000.         if (typeof window.onblur != 'function') {
  2001.             window.onblur = func;
  2002.         }else{
  2003.             window.onblur = function(e)  {
  2004.                 if (oldonblur) {
  2005.                     oldonblur(e);
  2006.                 }
  2007.                 func(e);
  2008.             }
  2009.         }
  2010.     },
  2011.  
  2012.     addUnloadEvent : function(func){
  2013.         var oldonunload = window.onunload;
  2014.         if (typeof window.onunload != 'function'){
  2015.             window.onunload = func;
  2016.         } else {
  2017.             window.onunload = function(e) {
  2018.                 if (oldonunload) {
  2019.                     oldonunload(e);
  2020.                 }
  2021.                 func(e);
  2022.             }
  2023.         }
  2024.     },
  2025.    
  2026.     addEListener : function(node, func, evt ){
  2027.         if( window.addEventListener ){
  2028.             node.addEventListener(evt,func,false);
  2029.         }else{
  2030.             node.attachEvent(evt,func,false);
  2031.         }
  2032.     }
  2033. };
  2034.  
  2035. spsupport.api.init();
  2036. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement