this.STVisitorValue = "ee9ba102f1b04430823f992b570fe7b1";
this.STCallbackInterval = 8000;
this.STHandlerFile = "ST.ashx";
this.STLastCallbackImageHeight = 0;
this.STLastCallbackAction = 0;
this.STTimeoutID = 0;
this.STPortalURL = "";
this.STImgHeightActions = 
{
    None: 1,
    DisableAsyncCallback: 2,
    EnableAsyncCallback: 3,
    RemoveFromListPerm: 4,
    RemoveFromList: 5,
    ForceChat: 6, 
    InviteChat: 7,
    SendClientLocation: 8,
    NavigateUrl: 9,
    PopupUrl: 10,
    OfferSurvey: 11,
    Biggest_Image: 12
}
var STMovableInvite = null,
    STIsInviteMoving = false,
    STSessionTimedOut = false,
    STWindowPosX = 0,
    STWindowPosY = 0,
    STCleanerInterval = 5,
    STCurrentInterval = 0,
    STScriptIDs = new Array();

function SmarterTrackAction()
{
    this.OnNormalCheck = function()
    {
        // does nothing
    }
    this.EnableAsyncCallback = function()
    {
        // does nothing
    }
    this.DisableAsyncCallback = function()
    {
        try
        {
            clearTimeout(STTimeoutID);
        }
        catch (err) { }
    }
    this.RemoveFromListPerm = function()
    {
        STset_cookiePerm("StopTracking", "true");
        try
        {
            clearTimeout(STTimeoutID);
        }
        catch (err) { }
    }
    this.RemoveFromList = function()
    {
        var paramCook = STget_cookie("OutputParameter");
        if (paramCook != "")
        {
            STset_cookieTime("StopTracking", "true", ";expires=" + paramCook);
        }
        try
        {
            clearTimeout(STTimeoutID);
        }
        catch (err) { }
    }
    this.ForceChat = function()
    {
        STInjectScript("&forcechat=true", "");
    }
    this.InviteChat = function(interactId)
    {
        STInjectScript("&sendinvite=true", interactId);
    }
    
    this.OfferSurvey = function(interactId)
    {
        STInjectScript("&survey=true", interactId);
    }  
    
    this.SendClientLocation = function()
    {
        // feature is not allowed
    }
    this.NavigateUrl = function()
    {
        // feature is only allowed from an initiated chat
    }
    this.PopupUrl = function()
    {
        // feature is not allowed
    }
}
function SmarterTrackObject(portal)
{      
    this.TrackingUrl = portal + "App_Themes/Horizon/Javascript/" + STHandlerFile;
    this.TrackPage = function()
    {
        this.GetTrackingCode("");
    }
    this.TrackVirtualPage = function(pagename)
    {
        this.GetTrackingCode(pagename);
    }
    this.GetTrackingCode = function(virtualpage)
    {
        try
        {
            // check and see if this is a tracked session or co-browsing session
            var stopCookie = STget_cookie("StopTracking");
            if (stopCookie == null || (stopCookie != null && stopCookie != "true"))
            {
                //STset_cookiePerm("PortalUrl", portal);
                STPortalURL = portal;
                var rid = Math.round(Math.random()*2147483647);
                var trackingDivName = "SmarterTrackingArea"+rid;
                var interactDivName = "SmarterInteractiveArea"+rid;                        
                var isInjectCapable = false;
                try
                {
                    STInjectScript("&firstrun=true&sendactionscript=true&dt="+STEscapeTitle()+"&ref="+STEncode(document.referrer)+"&pp="+STEncode(window.location.href)+"&tzo="+new Date().getTimezoneOffset(), interactDivName);
                    isInjectCapable = true;
                }
                catch (err)
                {
                    // browser was not capable of script injection
                }
                
                document.write("<div style='z-index:151;position:absolute;left:0px;top:0px;"+STGetVisibilityFalse()+"' id='"+interactDivName+"'></div>");
                if (isInjectCapable)
                    STTimeoutID = setTimeout("STRetrackScript('"+interactDivName+"', '"+virtualpage+"');", STCallbackInterval);
                
                var cbMS = 900000;
                if (cbMS > 0)
                {
                    setTimeout("clearTimeout(STTimeoutID);STSessionTimedOut=true;", cbMS);
                }
            }
        }
        catch (err) { }
    }
    this.SetSTVariable = function(key, val)
    {
        // the only values that the key and val cannot have are "=" and "^". These special characters will be replaced with predefined text and checked for server side.
        var varKey = key.replace("=", "@@EQUALS@@").replace("%3D", "@@EQUALS@@");
        varKey = varKey.replace("^", "@@CARET@@").replace("%5E", "@@CARET@@");
        varKey = STEncode(varKey);
        
        var varVal = val.replace("=", "@@EQUALS@@").replace("%3D", "@@EQUALS@@");
        varVal = varVal.replace("^", "@@CARET@@").replace("%5E", "@@CARET@@");
        varVal = STEncode(varVal);
        
        var extras = "&dt="+STEscapeTitle()+"&pp="+STEncode(window.location.href)+"&tzo="+new Date().getTimezoneOffset();
        STInjectScript("&inputparameter=SetVariable%3D" + varKey + "%5E" + varVal + extras, "");
    }
    this.ClearSTVariable = function(key)
    {
        var varKey = key.replace("=", "@@EQUALS@@").replace("%3D", "@@EQUALS@@");
        varKey = varKey.replace("^", "@@CARET@@").replace("%5E", "@@CARET@@");
        varKey = STEncode(varKey);
        var extras = "&dt="+STEscapeTitle()+"&pp="+STEncode(window.location.href)+"&tzo="+new Date().getTimezoneOffset();
        STInjectScript("&inputparameter=ClearVariable%3D" + varKey + extras, "");
    }
    this.ClearAllSTVariables = function()
    {
        var extras = "&dt="+STEscapeTitle()+"&pp="+STEncode(window.location.href)+"&tzo="+new Date().getTimezoneOffset();
        STInjectScript("&inputparameter=ClearVariables%3Dtrue" + extras, "");
    }
    this.ClearSTVariableStartingWith = function(key)
    {
        var varKey = key.replace("=", "@@EQUALS@@").replace("%3D", "@@EQUALS@@");
        varKey = varKey.replace("^", "@@CARET@@").replace("%5E", "@@CARET@@");
        varKey = STEncode(varKey);
        var extras = "&dt="+STEscapeTitle()+"&pp="+STEncode(window.location.href)+"&tzo="+new Date().getTimezoneOffset();
        STInjectScript("&inputparameter=ClearVariablesStartingWith%3D" + varKey + extras, "");
    }
}
this.STButton = function()
{
    this.Text = "";
    this.OnClick = "";
}
this.STTextBox = function()
{
    this.ID = "";
    this.LabelText = "";
}
function SmarterTrackMessage()
{
    // attributes
    this.InteractID = "";
    this.HorizontalAlign = "";
    this.HorizontalOffset = "";
    this.VerticalOffset = "";
    this.VerticalAlign = "";
    this.IsAbsolutePosition = "false";
    this.IsSecureConnection = false;
    this.Message = "";
    this.ThemeName = "";
    this.FromName = "";
    this.ShowFromName = "false";
    this.Type = "confirmation";
    this.PortalUrl = "";
    this.AvatarIconURL = "";
    this.ShowFields = false;
    this.ShowAvatar = true;
    this.Title = "";
    this.AcceptButton = new STButton();
    this.RejectButton = new STButton();
    this.NameTextBox = new STTextBox();
    this.EmailTextBox = new STTextBox();
    
    this.Draw = function()
    {
        var interactArea = document.getElementById(this.InteractId);
        if (interactArea == null)
        {
            return false;
        }
        var conWidth = 314;
        var conHeight = this.Type == "alert" ? 170 : 196;
        
        var winWidth = 0;
        var winOuterWidth = 0;
        var winHeight = 0;
        var winOuterHeight = 0;
        if (parseInt(navigator.appVersion)>3) 
        {
            if (navigator.appName=="Netscape") 
            {
                if (document.body.offsetHeight && document.body.offsetWidth)
                {
                    winWidth = document.body.offsetWidth;
                    winHeight = document.body.offsetHeight;
                }
                else
                {
                    winWidth = window.innerWidth;
                    winHeight = window.innerHeight;
                }
            }
            if (navigator.appName.indexOf("Microsoft")!=-1)
            {
                winWidth = document.body.offsetWidth;
                winHeight = document.body.offsetHeight;
            }
        }
        
        if (window.innerWidth)
        {
            winOuterWidth = window.innerWidth;
            winOuterHeight = window.innerHeight;
        }
        else if (document.documentElement && 
            document.documentElement.clientWidth &&
            document.documentElement.clientWidth != 0)
        {
            winOuterWidth = document.documentElement.clientWidth;
            winOuterHeight = document.documentElement.clientHeight;
        }
        else
        {
            winOuterWidth = document.getElementsByTagName("body")[0].clientWidth;
            winOuterHeight = document.getElementsByTagName("body")[0].clientHeight;
        }

        var adjLeft = 0;
        var adjTop = 0;
        if (parseFloat(this.HorizontalOffset) > screen.width)
            this.HorizontalOffset = "0";
        if (parseFloat(this.VerticalOffset) > screen.height)
            this.VerticalOffset = "0";
        
        var bufferSpacer = 0;
        switch (this.HorizontalAlign)
        {
            case "left": adjLeft = 0 + parseFloat(this.HorizontalOffset); break;
            case "center": adjLeft = Math.round((winWidth - conWidth) / 2)
             + parseFloat(this.HorizontalOffset); break;
            case "right": 
                if (navigator.appName == "Netscape")
                    bufferSpacer = 20;
                else
                    bufferSpacer = 0;
                
                adjLeft = Math.round(winWidth - conWidth - bufferSpacer) - parseFloat(this.HorizontalOffset);
                break;
        }
        
        var posAbs = this.IsAbsolutePosition == "True" || this.IsAbsolutePosition == "true" ? true : false;
        var scrollTopPx = 0;

        if (document.body.scrollTop)
            scrollTopPx = document.body.scrollTop;
        else if (document.documentElement.scrollTop)
            scrollTopPx = document.documentElement.scrollTop;
        else if (window.pageYOffset)
            scrollTopPx = window.pageYOffset;
         
        switch (this.VerticalAlign)
        {
            case "top": 
                if (posAbs)
                {
                    adjTop = 0 + parseFloat(this.VerticalOffset);
                }
                else
                {
                    adjTop = scrollTopPx + parseFloat(this.VerticalOffset);
                }
                break;
            case "center": 
                if (posAbs)
                {
                    adjTop = Math.round((winHeight - conHeight) / 2) + parseFloat(this.VerticalOffset);
                }
                else
                {
                    adjTop = Math.round((winOuterHeight - conHeight) / 2) + scrollTopPx + parseFloat(this.VerticalOffset);
                }
                break;
            case "bottom":
                if (posAbs)
                {
                    adjTop = Math.round(winHeight - conHeight) - parseFloat(this.VerticalOffset);
                }
                else
                {
                    if (navigator.appName == "Netscape")
                        bufferSpacer = 0;
                    else
                        bufferSpacer = 63;
                        
                    adjTop = ((Math.round(winOuterHeight - conHeight) - bufferSpacer) + scrollTopPx) - parseFloat(this.VerticalOffset);
                }
                break;
        }
        
        interactArea.style.left = adjLeft+"px";
        interactArea.style.top = adjTop+"px";
        
        STSetVisibility(this.InteractId, true);
            
        var randomIdentifier = "ST_"+Math.round(Math.random()*2147483647);
        if (this.NameTextBox.ID == "")
            this.NameTextBox.ID = randomIdentifier+"_txtName";
        if (this.EmailTextBox.ID == "")
            this.EmailTextBox.ID = randomIdentifier+"_txtEmail";
        
        var leftTileID = randomIdentifier+"_leftChatTile";
        var centerTileID = randomIdentifier+"_centerChatTile";
        var rightTileID = randomIdentifier+"_rightChatTile";
        
        var leftRejectTileID = randomIdentifier+"_leftRejectTile";
        var centerRejectTileID = randomIdentifier+"_centerRejectTile";
        var rightRejectTileID = randomIdentifier+"_rightRejectTile";

        // styles
        var invitationDir = this.PortalUrl+"App_Themes/"+this.ThemeName+"/Images/Invitations/";
        var windowDir = this.PortalUrl+"App_Themes/"+this.ThemeName+"/Controls/Window/";
        
        var wmUrl = invitationDir + (this.Type == "confirmation" ? "WMConfirmation.gif" : "WMAlert.gif");
        var blueTextColor = "#335771";
        var blueColor = "#436985";
        var greenColor = "#3F621B";
        
        var conStyle = "width: "+conWidth+"px;height: "+conHeight+"px;padding: 0px;margin: 0px;";        
        var windowTopTile = "width: 304px;height:25px;cursor: move;border-left: solid 1px "+blueColor+";border-top: solid 1px "+blueColor+";border-right: solid 1px "+blueColor+";background-image: url("+windowDir+"CssImg/PopIn_UpperTile.png);background-repeat: repeat-x;";
        var windowTopTitleText = "width: 276px;padding-left: 5px;font: 9pt Arial,Verdana;font-weight: bold;color: #ffffff;vertical-align: middle;text-align: left;";
        var windowBodyText = "font: 8pt Arial,Verdana;color: #444444;text-align: left;";
        var windowTopClose = "padding: 0px;width: 26px;text-align: right;vertical-align: top;";
        var windowWM = "text-align: left;background-color: #ffffff;width: 184px;height: 150px;border-right: solid 1px "+blueColor+";border-bottom: solid 1px "+blueColor+";background-image: url("+wmUrl+");background-repeat:no-repeat;background-position: bottom right;";
        var windowWMNoAvatar = "padding: 16px 0px 0px 22px;text-align: left;background-color: #ffffff;width: 299px;height: 150px;border-left: solid 1px "+blueColor+";border-right: solid 1px "+blueColor+";border-bottom: solid 1px "+blueColor+";background-image: url("+wmUrl+");background-repeat:no-repeat;background-position: bottom right;";
        var windowMessageArea = "text-align: left;vertical-align: top;padding-left: 3px;padding-top: 8px;padding-right: 3px;";
        var windowEntryArea = "text-align: left;vertical-align: bottom;padding-left: 3px;padding-bottom: 13px; padding-right: 3px;";
        var windowTextBox = "width: 145px";
        var windowAgent = "background-color: #ffffff;border-left: solid 1px "+blueColor+";border-bottom: solid 1px "+blueColor+";width: 120px;height: 150px;";
        var windowNoAgent = "background-color: #ffffff;border-left: solid 1px "+blueColor+";border-bottom: solid 1px "+blueColor+";width: 2px;height: 150px;";
        var windowAgentFromText = "text-align: center;font: 8pt Arial,Verdana;color: #444444;padding-bottom: 3px;";
        var centerContext = "text-align: center;vertical-align: middle;";
        var windowAgentSpan = "background-color: #ffffff;padding-left: 10px;";
        
        var windowFarRight = "width: 6px;height: 25px;";
        var windowdFarRightMiddle = "width 6px; height: 150px;";
        var btmButtonAreaLeft = "width: 124px;height: 32px;";
        var btmButtonAreaTile = "width: 180px;height: 32px;border-left: solid 1px "+blueColor+";background-image: url("+invitationDir+"Button/Button_Tile.gif);background-repeat: repeat-x;background-position: top right;";
        var btmButtonAreaRight = windowFarRight+"height: 88px;background-image: url("+invitationDir+"Button/Button_RightCap.gif);background-repeat: no-repeat;background-position: bottom left;";
        
        var btmButtonArea = "width: 132px;height: 100%;text-align: right;vertical-align: middle;";
        var btmButtonArrow = "width: 48px;height: 100%;text-align: center;vertical-align: middle;";
        
        var buttonLeftTile = "width: 2px;height: 21px;background-image: url("+invitationDir+"Button/StartBtn_LeftCap.gif);background-repeat: no-repeat;";
        var buttonRightTile = "width: 2px;height: 21px;background-image: url("+invitationDir+"Button/StartBtn_RightCap.gif);background-repeat: no-repeat;";
        var buttonCenterTile = "width: 60px;height: 21px;text-align: center;background-image: url("+invitationDir+"Button/StartBtn_Tile.gif);background-repeat: repeat-x;";
        var buttonBlueText = centerContext+"color: "+blueTextColor+";font: 9pt Arial;";
        var buttonSpacer = "width: 3px;";
        
        var cursorStyle = "cursor: pointer;";
        var anchorStyle = "text-decoration: none;border: none;";
        var tableMax = "height: 100%;";
        
        if (this.FromName == "")
            this.FromName = "Agent";
        
        var fromText = "";
        if (this.ShowFromName == "true")
        {
            fromText = "<div style='"+windowAgentFromText+"'>"+this.FromName+"</div>";
        }
        var avatarSrc = "";
        if (this.AvatarIconURL == "AgentIcon.gif") 
        {
            
            avatarSrc = invitationDir+this.AvatarIconURL;
        }
        else
        {
            avatarSrc = this.AvatarIconURL;
        }
        
        var s = "";
        
        // build invitation HTML with the styles above
        s += "<table style='"+conStyle+"' cellpadding='0' cellspacing='0'>";
        
        var MovableBarAreaID = "SmarterBar"+Math.round(Math.random()*2147483647);
        // top row (where header and close are)
        s += "<tr><td colspan='2' style='"+windowTopTile+"'>";
        s += "<table cellpadding='0' cellspacing='0'><tr>";
        s += "<td id='"+MovableBarAreaID+"' onmousedown=\"STOnMouseInviteDown(e);\" onmouseup=\"STOnMouseInviteUp(e);\" style='"+windowTopTitleText+"'>"+this.Title+"</td>";
        s += "<td style='"+windowTopClose+"'>";
        s += "<img style='"+cursorStyle+"' src='"+windowDir+"Img/close.gif' onClick=\""+this.RejectButton.OnClick+"STCloseMessage('"+this.InteractId+"');\" /></td>";
        s += "</tr></table></td><td style='"+windowFarRight+"'></td></tr>";
        
        // middle row (where body of invitation is)
        s += "<tr style='height: 150px;'>";
        
        if (this.ShowAvatar)
        {
            s += "<td style='"+windowAgent+"'>";
            s += "<span style='"+windowAgentSpan+"'>";
            s += "<img src='"+avatarSrc+"' />"+fromText+"</span></td>";
        }

        var msgColSpan = (this.ShowAvatar ? "" : " colspan='2'");
        s += "<td"+msgColSpan+" style='"+(this.ShowAvatar ? windowWM : windowWMNoAvatar)+"'><table style='"+tableMax+"text-align:left;' cellpadding='0' cellspacing='0'><tr>";
        s += "<td style='"+windowMessageArea+"'><div style='"+windowBodyText+"'>"+this.STTrackingMessageDecoder(this.Message)+"</div></td></tr>";
        
        if (this.ShowFields)
        {
            s += "<tr><td style='"+windowEntryArea+"'><div style='"+windowBodyText+"'>"+this.NameTextBox.LabelText+"</div>";
            s += "<div><input type='text' id='"+this.NameTextBox.ID+"' width='120' style='"+windowTextBox+"' /></div>";
            s += "<div style='"+windowBodyText+"'>"+this.EmailTextBox.LabelText+"</div>";
            s += "<div><input type='text' id='"+this.EmailTextBox.ID+"' width='120' style='"+windowTextBox+"' /></div>";
            s += "</td></tr>";
        }
        s += "</table></td>";
        
        if (this.Type == "confirmation")
        {
            s += "<td rowspan='2' style='"+btmButtonAreaRight+"'></td></tr>";
            
            // bottom row (where chat invite button is)
            s += "<tr><td colspan='2'><table style='width: 100%;' cellpadding='0' cellspacing='0'><tr>";
            s += "<td style='"+btmButtonAreaLeft+"'></td>";
            s += "<td style='"+btmButtonAreaTile+"'>";
            s += "<table style='"+tableMax+"' cellpadding='0' cellspacing='0'><tr>";
            s += "<td style='"+btmButtonArrow+"'><img src='"+invitationDir+"Button/Arrow.gif' /></td>";
            s += "<td style='"+btmButtonArea+"'><table cellpadding='0' cellspacing='0'<tr><td>";
            
            // Accept button
            s += "<a style='"+anchorStyle+cursorStyle+"' onmouseover=\"STOnButton1Over('"+randomIdentifier+"', '"+invitationDir+"');\" ";
            s += "onmouseout=\"STOnButton1Out('"+randomIdentifier+"', '"+invitationDir+"');\" href='javascript:STHrefNull();' ";
            s += "onClick=\""+this.AcceptButton.OnClick+"STCloseMessage('"+this.InteractId+"');\"><table cellpadding='0' cellspacing='0'><tr>";
            s += "<td id='"+leftTileID+"' style='"+buttonLeftTile+"'></td>";
            s += "<td id='"+centerTileID+"' style='"+buttonCenterTile+"'><span style='"+buttonBlueText+"'>"+this.AcceptButton.Text+"</span></td>";
            s += "<td id='"+rightTileID+"' style='"+buttonRightTile+"'></td></tr></table></a></td>";
            
            // Spacer
            s += "<td style='"+buttonSpacer+"'></td><td>";
            
            // Reject button
            s += "<a style='"+anchorStyle+cursorStyle+"' onmouseover=\"STOnButton2Over('"+randomIdentifier+"', '"+invitationDir+"');\" ";
            s += "onmouseout=\"STOnButton2Out('"+randomIdentifier+"', '"+invitationDir+"');\" href='javascript:STHrefNull();' ";
            s += "onClick=\""+this.RejectButton.OnClick+"STCloseMessage('"+this.InteractId+"');\">";
            s += "<table cellpadding='0' cellspacing='0'><tr>";
            s += "<td id='"+leftRejectTileID+"' style='"+buttonLeftTile+"'></td>";
            s += "<td id='"+centerRejectTileID+"' style='"+buttonCenterTile+"'><span style='"+buttonBlueText+"'>"+this.RejectButton.Text+"</span></td>";
            s += "<td id='"+rightRejectTileID+"' style='"+buttonRightTile+"'></td></tr></table></a></td></tr></table></td>";
            s += "</tr></table></td>";
        }
        else
        {
            s += "<td style='"+windowdFarRightMiddle+"'></td>";
        }
        
        // ends table container
        s += "</tr></table></td></tr></table>";
        
        var flashFile = this.PortalUrl + "UserControls/SoundControl1.swf";
        var soundFile = this.PortalUrl+"App_Themes/"+this.ThemeName+"/Sounds/Chat_NewChat.mp3";
        var flashProto = this.IsSecureConnection ? "https" : "http";
        // write out the flash sound object and check if it's supported
        s += "<div style='position: absolute; height: 1px; width: 1px; top: 0px; left: 0px;'>";
        s += "<object id='STFlashControlTrackScripting' name='STFlashControlTrackScripting' classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' " + 
            "codebase='" + flashProto + "://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0'" +
            "style='width:1px;height:1px' width='1' height='1'>"
        s += "<param name='allowScriptAccess' value='sameDomain' />";
        s += "<param name='movie' value='" + flashFile + "' />";
        s += "<param name='menu' value='false' >";
        s += "<param name='quality' value='high' />";
        s += "<param name='scale' value='noborder' >";
        s += "<param name='bgcolor' value='#fffffff' />";
        s += "<param name='wmode' value='transparent' />";
        s += "<embed src='" + flashFile + "' quality='high' wmode='transparent' menu='false' scale='noborder' " + 
            "bgcolor='#ffffff' width='1px' height='1px' name='STFlashControlTrackScripting_mozilla' id='STFlashControlTrackScripting_mozilla' " + 
            "allowScriptAccess='sameDomain' type='application/x-shockwave-flash' " + 
            "pluginspage='http://www.macromedia.com/go/getflashplayer' />";
        s += "</object></div>";
         
        interactArea.innerHTML = s;
        STPlaySoundFlash(soundFile);
        
        var MovableBar = document.getElementById(MovableBarAreaID);
        if (MovableBar)
        {
            MovableBar.onmousedown = this.STOnMouseInviteDown;
            MovableBar.onmouseup = this.STOnMouseInviteUp;
            STMovableInvite = interactArea;
        }
    }
    this.STTrackingMessageDecoder = function(message)
    {   
        return message;
    }

    this.STOnMouseInviteDown = function(e)
    {
        try
        {
            if (STMovableInvite)
            {
                STIsInviteMoving = true;
            }
            if (navigator.appName == "Netscape")
            {
                STWindowPosX = e.layerX;
                STWindowPosY = e.layerY;
            }
            else
            {
                STWindowPosX = event.offsetX;
                STWindowPosY = event.offsetY;
            }  
        }  
        catch (err) { }
    }
    this.STOnMouseInviteUp = function(e)
    {
        STIsInviteMoving = false;
    }
}
function STAddHandler(target,eventName,handlerName) 
{
    if (target.addEventListener)
    {
	    target[eventName + handlerName] = function(e){return target[handlerName](e)};
	    target.addEventListener(eventName, target[eventName + handlerName], false);
    }
    else if (target.attachEvent)
    {
	    target[eventName + handlerName] = function(e){return target[handlerName](e)};
	    target.attachEvent("on" + eventName, target[eventName + handlerName]);
    }
    else 
    { 
	    var originalHandler = target["on" + eventName]; 
	    if (originalHandler)
	    {
		    target[eventName + handlerName] = function(e){originalHandler(e); return target[handlerName](e);};
		    target["on" + eventName] = target[eventName + handlerName]; 
	    }
	    else 
	    {
		    target["on" + eventName] = target[handlerName]; 
	    }
    } 
}
function STPlaySoundFlash(url)
{
    setTimeout("STPlaySoundFlashInternal(\""+url+"\");", 50);
}
function STPlaySoundFlashInternal(url)
{
    var item = document.getElementById('STFlashControlTrackScripting_mozilla');
    if (item == undefined)
	    item = document.getElementById('STFlashControlTrackScripting');
    if (item != undefined)
	    item.SetVariable("fName", url);
}
document.STOnMouseUpInviteListener = function(evt)
{
    STIsInviteMoving = false;
}
document.STOnMouseMoveInviteListener = function(evt)
{
    try
    {
        var winWidth = 0;
        var winHeight = 0;
        if (parseInt(navigator.appVersion)>3) 
        {
            if (navigator.appName=="Netscape") 
            {
                if (document.body.offsetHeight && document.body.offsetWidth)
                {
                    winWidth = document.body.offsetWidth;
                    winHeight = document.body.offsetHeight;
                }
                else
                {
                    winWidth = window.innerWidth;
                    winHeight = window.innerHeight;
                }
            }
            if (navigator.appName.indexOf("Microsoft")!=-1)
            {
                winWidth = document.body.offsetWidth;
                winHeight = document.body.offsetHeight;
            }
        }
        
        
        if (STIsInviteMoving && STMovableInvite != null)
        {
            if (navigator.appName == "Netscape")
            {
                if (evt.pageX < winWidth)
                    STMovableInvite.style.left = (evt.pageX - STWindowPosX) + 'px';
                if (evt.pageY < winHeight)
                    STMovableInvite.style.top = (evt.pageY - STWindowPosY) + 'px';
            }
            else
            {
                if (event.clientX < winWidth)
                    STMovableInvite.style.left = event.clientX-STWindowPosX + document.body.scrollLeft + 'px';
                if (event.clientY < winHeight)
                    STMovableInvite.style.top = event.clientY-STWindowPosY + document.body.scrollTop + 'px';
            }
            return false;
        }
    }
    catch (err) { }
}
STAddHandler(document, "mousemove", "STOnMouseMoveInviteListener");
STAddHandler(document, "mouseup", "STOnMouseUpInviteListener");
function STSetVisibility(id, isVisible)
{
    var objToSet = document.getElementById(id);
    if (navigator.appName.indexOf("Microsoft")!=-1)
    {
        objToSet.style.visibility = isVisible == true ? "visible" : "hidden";
    }
    else
    {
        objToSet.style.display = isVisible == true ? "" : "none";
    }
}
function STOnButton1Over(idPrefix, imageDir)
{
    var leftTileID = idPrefix+"_leftChatTile";
    var centerTileID = idPrefix+"_centerChatTile";
    var rightTileID = idPrefix+"_rightChatTile";
    
    document.getElementById(leftTileID).style.backgroundImage = "url("+imageDir+"Button/StartBtn_LeftCap_Over.gif)";
    document.getElementById(centerTileID).style.backgroundImage = "url("+imageDir+"Button/StartBtn_Tile_Over.gif)";
    document.getElementById(rightTileID).style.backgroundImage = "url("+imageDir+"Button/StartBtn_RightCap_Over.gif)";
}
function STOnButton1Out(idPrefix, imageDir)
{
    var leftTileID = idPrefix+"_leftChatTile";
    var centerTileID = idPrefix+"_centerChatTile";
    var rightTileID = idPrefix+"_rightChatTile";
    
    document.getElementById(leftTileID).style.backgroundImage = "url("+imageDir+"Button/StartBtn_LeftCap.gif)";
    document.getElementById(centerTileID).style.backgroundImage = "url("+imageDir+"Button/StartBtn_Tile.gif)";
    document.getElementById(rightTileID).style.backgroundImage = "url("+imageDir+"Button/StartBtn_RightCap.gif)";
}
function STOnButton2Over(idPrefix, imageDir)
{
    var leftTileID = idPrefix+"_leftRejectTile";
    var centerTileID = idPrefix+"_centerRejectTile";
    var rightTileID = idPrefix+"_rightRejectTile";
    
    document.getElementById(leftTileID).style.backgroundImage = "url("+imageDir+"Button/StartBtn_LeftCap_Over.gif)";
    document.getElementById(centerTileID).style.backgroundImage = "url("+imageDir+"Button/StartBtn_Tile_Over.gif)";
    document.getElementById(rightTileID).style.backgroundImage = "url("+imageDir+"Button/StartBtn_RightCap_Over.gif)";
}
function STOnButton2Out(idPrefix, imageDir)
{
    var leftTileID = idPrefix+"_leftRejectTile";
    var centerTileID = idPrefix+"_centerRejectTile";
    var rightTileID = idPrefix+"_rightRejectTile";
    
    document.getElementById(leftTileID).style.backgroundImage = "url("+imageDir+"Button/StartBtn_LeftCap.gif)";
    document.getElementById(centerTileID).style.backgroundImage = "url("+imageDir+"Button/StartBtn_Tile.gif)";
    document.getElementById(rightTileID).style.backgroundImage = "url("+imageDir+"Button/StartBtn_RightCap.gif)";
}
function STHrefNull()
{
}
function STCloseMessage(interactId)
{
    var interactArea = document.getElementById(interactId);
    STSetVisibility(interactId, false);
    interactArea.innerHTML = "";
}

function STget_cookie(Name) 
{
  var search = Name + "="
  var returnvalue = "";
  if (document.cookie.length > 0) {
    offset = document.cookie.indexOf(search)
    // if cookie exists
    if (offset != -1) { 
      offset += search.length
      // set index of beginning of value
      end = document.cookie.indexOf(";", offset);
      // set index of end of cookie value
      if (end == -1) end = document.cookie.length;
      returnvalue=unescape(document.cookie.substring(offset, end))
      }
   }
  return returnvalue;
}
function STset_cookieTemp(Name, Value)
{
    document.cookie =  this.STEncode(Name) +'='+ this.STEncode(Value) + "; path=/";
}
function STset_cookiePerm(Name, Value)
{
    document.cookie =  this.STEncode(Name) +'='+ this.STEncode(Value) + ';expires=Fri, 1 Jan 2038 10:00:00 GMT; path=/';
}
function STset_cookieTime(Name, Value, Expires)
{
    document.cookie =  this.STEncode(Name) +'='+ this.STEncode(Value) + Expires + "; path=/";
}
function STdel_cookie(Name)
{
    document.cookie = name + "=; expires=Thu, 01-Jan-70 00:00:01 GMT; path=/";
}
function STGetVisitorCookie()
{
    var visitCookie = STget_cookie("siteuidut");
    if (visitCookie == null || visitCookie == "")
    {
        STset_cookiePerm("siteuidut", this.STVisitorValue);
        return this.STVisitorValue;
    }
    else
    {
        return visitCookie;
    }
}
function STEncode(text)
{
    try
    {
        return encodeURIComponent(text);
    }
    catch(ex)
    {
        return escape(text);
    }
}
function STStrStartsWith(str)
{
    return this.match("^"+str) == str;
}
function STRetrackScript(interactId, virtualpage)
{
    try
    {
        try
        {
            if (STCurrentInterval >= STCleanerInterval)
            {
                // clean the head of the page - this controls the size of the page from getting out of control
                var head = document.getElementsByTagName("head").item(0);
                for (var i = 0; i < STScriptIDs.length; i++)
                {
                    head.removeChild(document.getElementById(STScriptIDs[i]));
                }
                STScriptIDs = new Array();
                STCurrentInterval = 0;
            }
            else
            {
                STCurrentInterval++;
            }
        }
        catch (err) { }
    
        var vpQS = "";
        if (virtualpage != "")
        {
            vpQS = "&vp="+STEncode(virtualpage);
        }
        var SC = "&ref="+STEncode(document.referrer)+"&dt="+STEscapeTitle()+"&pp="+STEncode(window.location.href)+vpQS+"&tzo="+new Date().getTimezoneOffset();
        STInjectScript(SC, interactId);
        
        if (STSessionTimedOut == false)
        {
            STTimeoutID = setTimeout("STRetrackScript('"+interactId+"', '"+virtualpage+"');", STCallbackInterval);
        }
    }
    catch (err) { }
}
function STSendAction(visitorId, action, interactId)
{
    try
    {
        if (STGetVisitorCookie() != visitorId)
            return;
            
        this.STLastCallbackImageHeight = action;
        if (action > 1)
            this.STLastCallbackAction = action;
        
        var STAction = new SmarterTrackAction();
        switch (action)
        {
            case this.STImgHeightActions.None: STAction.OnNormalCheck(); break; 
            case this.STImgHeightActions.EnableAsyncCallback: STAction.EnableAsyncCallback(); break;
            case this.STImgHeightActions.DisableAsyncCallback: STAction.DisableAsyncCallback(); break;
            case this.STImgHeightActions.RemoveFromListPerm: STAction.RemoveFromListPerm(); break;
            case this.STImgHeightActions.ForceChat: STAction.ForceChat(interactId); break;
            case this.STImgHeightActions.InviteChat: STAction.InviteChat(interactId); break;
            case this.STImgHeightActions.SendClientLocation: STAction.SendClientLocation(); break;
            case this.STImgHeightActions.NavigateUrl: STAction.NavigateUrl(); break; 
            case this.STImgHeightActions.PopupUrl: STAction.PopupUrl(); break; 
            case this.STImgHeightActions.OfferSurvey: STAction.OfferSurvey(interactId); break;
            default: break;
        }
    }
    catch (err) { }
}

function STGetVisibilityFalse()
{
    if (navigator.appName.indexOf("Microsoft")!=-1)
    {
        return "visibility: hidden;";
    }
    else
    {
        return "display: none;";
    }
}
function STEscapeTitle()
{
    var retVal = document.title;
    
    var numQuotes = 0;
    for (var i = 0; i < retVal.length; i++)
    {
        if (retVal[i] == "'")
            numQuotes += 1;
    }
    for (var i = 0; i <= numQuotes; i++)
        retVal = retVal.replace("'", "%SQUOTE%");
   
    return STEncode(retVal);
}
function STInjectScript(inputQS, outputID)
{
    //var portalUrlCook = STget_cookie("PortalUrl");
    var portalUrl = this.STPortalURL;
    if (portalUrl != "")
    {
       var rid = Math.round(Math.random()*2147483647);
       var head = document.getElementsByTagName("head")[0];
       var script = document.createElement("script");
        
       script.id = "ST"+rid;
       STScriptIDs[STScriptIDs.length] = script.id;
       script.type = "text/javascript";
       
       var interactAreaId = "";
       if (outputID != "")
       {
           interactAreaId = "&interactId="+outputID;
       }

       script.src = portalUrl+this.STHandlerFile+"?PostID="+rid+inputQS+"&visitorId="+STGetVisitorCookie()+interactAreaId;
       head.appendChild(script);
   }
}
function STAcceptForcedChat(responseUrl)
{
    window.open(responseUrl, "LiveChat", "toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=500,height=480");
}
function STAcceptChatInvite(responseUrl, interactId, txtNameID, txtEmailID)
{
    var cName = document.getElementById(txtNameID).value;
    if (cName != "")
        cName = "&cName="+cName;
        
    var cEmail = document.getElementById(txtEmailID).value;
    if (cEmail != "")
        cEmail = "&cEmail="+cEmail;
    
    var respUrl = responseUrl+cName+cEmail;
    window.open(respUrl, "LiveChat", "toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=500,height=480");
    
    STInjectScript('&inputparameter=ChatInviteState%3DAccepted"', "");
}