﻿var agt = navigator.userAgent.toLowerCase();
var is_major = parseInt(navigator.appVersion);
var is_minor = parseFloat(navigator.appVersion);
var is_nav = ((agt.indexOf('mozilla') != -1) && (agt.indexOf('spoofer') == -1)
                && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera') == -1)
                && (agt.indexOf('webtv') == -1) && (agt.indexOf('hotjava') == -1));
var is_nav4 = (is_nav && (is_major == 4));
var is_nav6 = (is_nav && (is_major == 5));
var is_nav6up = (is_nav && (is_major >= 5));
var is_ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));

var offsetX = 0;
var offsetY = -150;
var opacity = 100;
var toolTipSTYLE;
var addToolStyle;

function initToolTips() {
    if (document.getElementById) {
        toolTipSTYLE = document.getElementById("toolTipLayer").style;
        addToolStyle = document.getElementById("toolTipAdd").style;
    }
    if (is_ie || is_nav6up) {
        toolTipSTYLE.visibility = "visible";
        toolTipSTYLE.display = "none";
        addToolStyle.visibility = "visible";
        addToolStyle.display = "none";
        document.onmousemove = moveToMousePos;
    }
}
function moveToMousePos(e) {
    if (!is_ie) {
        x = e.pageX;
        y = e.pageY;
    } else {
        x = event.x + document.body.scrollLeft;
        y = event.y + document.body.scrollTop;
    }

    toolTipSTYLE.left = x + offsetX + 'px';
    toolTipSTYLE.top = y + offsetY + 'px';
    return true;
}


function toolTip(msg, fg, bg) {
    if (document.getElementById) {
        toolTipSTYLE = document.getElementById("toolTipLayer").style;
    }
    if (is_ie || is_nav6up) {
        toolTipSTYLE.visibility = "visible";
        toolTipSTYLE.display = "none";
        document.onmousemove = moveToMousePos;
    }

    if (toolTip.arguments.length < 1) // if no arguments are passed then hide the tootip
    {
        if (is_nav4)
            toolTipSTYLE.visibility = "hidden";
        else
            toolTipSTYLE.display = "none";
    }
    else // show
    {
        if (!fg) fg = "#777777";
        if (!bg) bg = "#ffffe5";
        var content = "<div class=\"toolTipAdd\" id=\"toolTipSingle\">" + msg + "</div>";
        if (is_nav4) {
            toolTipSTYLE.document.write(content);
            toolTipSTYLE.document.close();
            toolTipSTYLE.visibility = "visible";
        }

        else if (is_ie || is_nav6up) {
            document.getElementById("toolTipLayer").innerHTML = content;
            toolTipSTYLE.display = 'block'
        }
    }
}

//To check if im pressing the CTRL key.  If I am, the keycodeMain will equal 17
var keycodeMain = 0;
document.onkeydown = checkKeycodeDown;
function checkKeycodeDown(e) {
    var keycode;
    if (window.event) keycode = window.event.keyCode;
    else if (e) keycode = e.which;
    if (keycode === 17)
        keycodeMain = keycode;
}
document.onkeyup = checkKeycodeUp;
function checkKeycodeUp(e) {
    var keycode;
    if (window.event) keycode = window.event.keyCode;
    else if (e) keycode = e.which;
    if (keycode === 17)
        keycodeMain = 0;
}


//Gets the querystring parameter by name
function getParameterByName(name) {
    name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
    var regexS = "[\\?&]" + name + "=([^&#]*)";
    var regex = new RegExp(regexS);
    var results = regex.exec(window.location.href);
    if (results == null)
        return "";
    else
        return decodeURIComponent(results[1].replace(/\+/g, " "));
}
