var metric = new Object();
var chatObj = new Object();

metric.acernoActive = true;   // set to true if you want to send aCerno tags
metric.doubleclickActive = true;   // set to true if you want to send doubleclick tags
metric.useAkamaiJS = true;    // set to true if you want to used the akamaized javascript files
metric.omnitureActive = true; // set to true if you want omniture activated
chatObj.chatActive = true;    // set to true if you want astara reactive/proactive chat enabled.

function getProtocol() {
    var url = document.URL;
    if (url != undefined && url != null) {
        var idx = url.indexOf("https:");
        if (idx >= 0) {
            return "https";
        }
    }
    return "http";
}
var isSecure = (getProtocol() == "https") ? true : false;
var jsPrefix = "";
if (metric.useAkamaiJS && isSecure) {
    jsPrefix = "https://a248.e.akamai.net/f/597/774/12h/www.landsend.com";
} else if (metric.useAkamaiJS) {
    jsPrefix = "http://aka.landsend.com";
}

chatObj.writeReactiveLink = function() {
    var chatHTML="";
    if(this.chatActive){
        chatHTML+="<div id=\"chatContainer\" style=\"width:145px; font-family:Arial, Helvetica, sans-serif; font-size:11px; color:#444444;\">"
        chatHTML+="<div id=\"chatAvailable\">";
        chatHTML+="<div><img style=\"float:left; padding:0px; margin:0px;\" ";
        chatHTML+="src=\""+jsPrefix+"/images/chat/reactiveChat_header.gif\" alt=\"Get Live Help\" /></div>";
        chatHTML+="<div style=\"clear:both; padding:0px 3px 4px 3px;\">By text chat or phone - free!</div>";
        chatHTML+="<div>";
        chatHTML+="<a href=\"javascript:webChatPop('Template=257356');\" style=\"padding:0px 5px 0px 0px;\"><img style=\"border:0px;\" src=\""+getProtocol()+"://as00.estara.com/webcare/public/linkimage.php?ulbid=257356\" alt=\"Chat Online\"></a>";
        chatHTML+="<a href=\"javascript:webVoicePop('Template=257346');\"><img style=\"border:0px;\" src=\""+getProtocol()+"://as00.estara.com/webcare/public/linkimage.php?ulbid=257346\" alt=\"Call Me\"></a>";
        chatHTML+="</div>";
        chatHTML+="</div>";
        chatHTML+="</div>";
    } else{
        chatHTML+="<div id=\"chatContainer\" style=\"width:145px; font-family:Arial, Helvetica, sans-serif; font-size:11px; color:#444444;\">"
        chatHTML+="<div id=\"chatNotAvailable\">";
        chatHTML+="<div><img style=\"float:left; padding:0px; margin:0px;\" ";
        chartHTML+="src=\""+jsPrefix+"/images/chat/reactiveChat_header.gif\" alt=\"Get Live Help\" /></div>";
        chatHTML+="<div style=\"clear:both; padding:0px 3px 4px 3px;\">Speak with a live person!</div>";
        chatHTML+="<div style=\"clear:both; padding:0px 3px 4px 3px; font-size:13px; font-weight:bold;\">800.963.4816</div>";
        chatHTML+="</div>";
        chatHTML+="</div>";
    }
    document.write(chatHTML);
}

chatObj.sendOmnitureControlGroupTag = function() {
    s_omtr.eVar36="Control_Group";
    s_omtr.events="event36";
    
    var s_code=s_omtr.tl();
    if(s_code)document.write(s_code);
}

if (typeof getCookie == 'undefined') {
    function getCookie(name) {
        var nameEQ = name + "=";
        var ca = document.cookie.split(';');
        for(var i=0;i < ca.length;i++) {
            var c = ca[i];
            while (c.charAt(0)==' ') {
                c = c.substring(1,c.length);
            }
            if (c.indexOf(nameEQ) == 0) {
                return c.substring(nameEQ.length,c.length);
            }
        }
        return "";
    }
}
if(chatObj.chatActive){
    window.cartTotalAmt = getCookie("cTotal");
    function eStara_quick_append(u) {
        var s=document.createElement('script');
        s.setAttribute('type','text/javascript');
        s.setAttribute('src',u);
        s.setAttribute('charset','UTF-8');
        if(typeof(window.attachEvent)!='undefined') {
            document.body.appendChild(s);
        } else {
            document.getElementsByTagName('head').item(0).appendChild(s);
        }
    }            
    function eStara_loadlr(){
        try{
            eStara_quick_append('//as00.estara.com/fs/lr.php?onload=1&accountid=200106289523',0);
        } catch(e) {}
    }
    if (typeof(window.addEventListener)!='undefined') {
        window.addEventListener('load',eStara_loadlr,false);
    } else if(typeof(document.addEventListener)!='undefined') {
        document.addEventListener('load',eStara_loadlr,false);
    } else if(typeof(window.attachEvent)!='undefined') {
        window.attachEvent('onload',eStara_loadlr);
    }
    var script = "<script language='JavaScript' type='text/javascript' src='"+jsPrefix+"/js/InitiateCall2.js'></script>";
	document.writeln("");
	document.writeln(script);
	document.writeln("");
}

// this is just a dummy object that we create ONLY when omniture
// is turned off so we have function stubs that other parts of the
// page might try to call.
function dummyOmnitureObj() {
  this.getQueryParam         = function(str) {};
  this.getValOnce            = function(str1, str2, str3) {};
  this.apl                   = function(str1, str2, str3) {};
  this.getDaysSinceLastVisit = function() {};
  this.s_doPlugins           = function(str) {};
  this.t                     = function() {};
  this.tl                    = function() {};
}
// omniture script tag to output if omniture is active.
var omnitureScript = "<script language='JavaScript' type='text/javascript' src='"+jsPrefix+"/js/s_code.js' ></script>";
if(metric.omnitureActive){
	document.writeln("");
	document.writeln(omnitureScript);
	document.writeln("");
}else{
	// create dummy object for omniture variables to latch onto
	s_omtr = new dummyOmnitureObj();
}


// Coremetrics is dead. Here lie the stubs for coremetrics
function dummyCMObj() {
  this.addTP                 = function() {};
}
cm = new dummyCMObj();
function cmCreatePageviewTag() {}
function cmCreateTechPropsTag(str1, str2) {}
function cmCreateTechPropsTag(str1, str2, str3) {}
function cmCreateDefaultPageviewTag() {}
function cmDisplayShop5s() {}
function cmCreateProductviewTag(str1, str2, str3) {}
function cmCreateShopAction5Tag(str1, str2, str3, str4, str5) {}
function cmCreateRegistrationTag(str1, str2, str3, str4, str5) {}
function cmSetLinkedProductCategories(str1) {}
function cmMVMUsageTag(str1,str2,str3,str4,str5,str6,str7) {}
function cmMVMProductTag(str1,str2,str3,str4) {}
function cmSetProductCategories(str1) {}
function cmSetProduction() {}
function cmPageviewOnClick(str1, str2) {}
function cmGetProductIndex(str1) {}
function cmCreateShopAction9Tag(str1,str2,str3,str4,str5,str6,str7,str8) {}
function cmDisplayShop9s() {}
function cmCreateOrderTag(str1,str2,str3,str4,str5,str6,str7) {}
function cmCreateErrorTag(str1) {}
function cmGetPageViewTagSrc(str1, str2) {}
function getOSK() {}
function cmApp() {}
function cmTP(str) {}
