﻿// JScript File
var browserType;

if (document.layers) { browserType = "nn4" }
if (document.all) { browserType = "ie" }
if (window.navigator.userAgent.toLowerCase().match("gecko")) {
    browserType = "gecko"
}

function Hide(strVal) {
    if (browserType == "gecko")
        document.poppedLayer = eval('document.getElementById("' + strVal + '")');
    else if (browserType == "ie")
        document.poppedLayer = eval('document.getElementById("' + strVal + '")');
    else
        document.poppedLayer = eval('document.layers["' + strVal + '"]');

    if (document.poppedLayer) {
        document.poppedLayer.style.display = "none";
}
}

function Show(strVal) {
    if (browserType == "gecko")
        document.poppedLayer = eval('document.getElementById("' + strVal + '")');
    else if (browserType == "ie")
        document.poppedLayer = eval('document.getElementById("' + strVal + '")');
    else
        document.poppedLayer = eval('document.layers["' + strVal + '"]');

    if (document.poppedLayer)
        document.poppedLayer.style.display = "inline";
}

// Detect if the browser is IE or not.
// If it is not IE, we assume that the browser is NS.
var IE = document.all ? true : false

// If NS -- that is, !IE -- then set up for mouse capture
if (!IE) document.captureEvents(Event.MOUSEMOVE)

// Set-up to use getMouseXY function onMouseMove
document.onmousemove = getMouseXY;

// Temporary variables to hold mouse x-y pos.s
var mouseX = 0
var mouseY = 0

// Main function to retrieve mouse x-y pos.s
function getMouseXY(e) {
    if (IE) { // grab the x-y pos.s if browser is IE
        //mouseX = event.clientX + document.documentElement.scrollLeft + document.body.scrollLeft
        //mouseY = event.clientY + document.documentElement.scrollTop + document.body.scrollTop
        mouseX = event.clientX + document.documentElement.scrollLeft
        mouseY = event.clientY + document.documentElement.scrollTop
    } else {  // grab the x-y pos.s if browser is NS
        mouseX = e.pageX
        mouseY = e.pageY
    }
    // catch possible negative values in NS4
    if (mouseX < 0) { mouseX = 0 }
    if (mouseY < 0) { mouseY = 0 }

    return true
}

function documentKeyDown(event) {
    var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;

    if (keyCode == 13) {
        //event.returnValue=false; 
        event.cancel = true;
    }
}

function Anthem_Error(result) {
    alert('Anthem Exception: ' + result.error);
}

function BackButton_onclick() {
    history.go(-1);
}

if (!document.layers && !document.all && !document.getElementById)
    event = "test"

function showtip(current, e, text) {
    if (document.all || document.getElementById) {
        thetitle = text.split('<br>')

        if (thetitle.length > 1) {
            thetitles = ''

            for (i = 0; i < thetitle.length; i++)
                thetitles += thetitle[i]

            current.title = thetitles
        }
        else {
            current.title = text
        }
    }
    else if (document.layers) {
        document.tooltip.document.write('<layer bgColor="white" style="border:1px solid black;font-size:12px;">' + text + '</layer>')
        document.tooltip.document.close()
        document.tooltip.left = e.pageX + 5
        document.tooltip.top = e.pageY + 5
        document.tooltip.visibility = "show"
    }
}

function hidetip() {
    if (document.layers)
        document.tooltip.visibility = "hidden"
}

/* Start of Tutorial Code */
var WindowObjectReference;

function Tutor(StartPage) {
    StartPage = (typeof StartPage == 'undefined') ? 'index.html' : StartPage + '.html';

    WindowObjectReference = window.open('/Tutorials/MarketingSalsa/' + StartPage, 'newwindow', 'width=850,height=500,left=10,top=100,screenX=10,screenY=100')
    WindowObjectReference.focus();

    //new popUp(10, 200, 860, 550, "TutorialDiv" , '/Tutorials/MarketingSalsa/'+StartPage, "white", "black", "10pt Verdana", "Tutorial", "#990033", "white", "#669933", "#669933", "black", true, true, true, true, true, false, '/JavaScript/DivPopup/min.gif', '/JavaScript/DivPopup/max.gif' , '/JavaScript/DivPopup/close.gif', '/JavaScript/DivPopup/resize.gif');
}

function WhyGuy(Visible, xPos, yPos, Caption, MessageBody) {
    if (Visible) {
        document.getElementById('WhyGuyCaption').innerHTML = "<b><font face='Arial' size='2' color='#FFDE7B'>" + Caption + "</font></b>";
        document.getElementById('WhyGuyBody').innerHTML = "<b><font face='Arial' size='1' color='#000000'>" + MessageBody + "</font></b>";
        document.getElementById('WhyGuy').style.left = xPos + "px";
        document.getElementById('WhyGuy').style.top = yPos + "px";
        //document.all['WhyGuy'].style.visibility = 'visible';

        Show('WhyGuy');

        if (document.all['AstonishingMailDocApplet']) {
            document.all['AstonishingMailDocApplet'].style.visibility = 'hidden';
        }
    }
    else {
        Hide('WhyGuy');

        //document.all['WhyGuy'].style.visibility = 'hidden';

        if (document.all['AstonishingMailDocApplet']) {
            document.all['AstonishingMailDocApplet'].style.visibility = 'visible';
        }
    }
}

function findPosX(obj) {
    var curleft = 0;
    if (obj.offsetParent) {
        while (1) {
            curleft += obj.offsetLeft;
            if (!obj.offsetParent) {
                break;
            }
            obj = obj.offsetParent;
        }
    } else if (obj.x) {
        curleft += obj.x;
    }
    return curleft;
}
function findPosY(obj) {
    var curtop = 0;
    if (obj.offsetParent) {
        while (1) {
            curtop += obj.offsetTop;
            if (!obj.offsetParent) {
                break;
            }
            obj = obj.offsetParent;
        }
    } else if (obj.y) {
        curtop += obj.y;
    }
    return curtop;
}

function getPos(inputElement) {
    var coords = new Object();
    coords.x = 0;
    coords.y = 0;
    try {
        targetElement = inputElement;
        if (targetElement.x && targetElement.y) {
            coords.x = targetElement.x;
            coords.y = targetElement.y;
        } else {
            if (targetElement.offsetParent) {
                coords.x += targetElement.offsetLeft;
                coords.y += targetElement.offsetTop;
                while (targetElement = targetElement.offsetParent) {
                    coords.x += targetElement.offsetLeft;
                    coords.y += targetElement.offsetTop;
                }
            } else {
                //alert(\"Could not find any reference for coordinate positioning.\");
            }
        }
        return coords;
    } catch (error) {
        //alert(error.msg);
        return coords;
    }
}

function Point(x, y) {
    this.x = x;
    this.y = y;
}

function getObjCoords(o) {
    var oX = 0;
    var oY = 0;
    if (o.offsetParent) {
        while (1) {
            oX += o.offsetLeft;
            oY += o.offsetTop;
            if (!o.offsetParent) {
                break;
            }
            o = o.offsetParent;
        }
    } else if (o.x) {
        oX += o.x;
        oY += o.y;
    }
    //alert(oX + \":\" + oY);
    return new Point(oX, oY);
}