﻿// JScript File

/* used to handle the enter key event for an element */
function IsEnterKeyPressed(e)
{
    if ((e.which && e.which == 13) || (e.keyCode && e.keyCode == 13))	
        return true;
}        

//BEGIN - Anthem related function to show the loading...on the top left of the page
var waitElement;
var showWaitElement = true;
var scrollX, scrollY = -1;

function AnthemLoading() {
    CreateWaitElement();
    if (window.addEventListener) {
        window.addEventListener('scroll', MoveWaitElement, false);
        window.addEventListener('resize', MoveWaitElement, false);
    }
    else if (window.attachEvent) {
        window.attachEvent('onscroll', MoveWaitElement);
        window.attachEvent('onresize', MoveWaitElement);
    }
}

function MoveWaitElement() {
    var scrollYT, scrollXT;
    if (!waitElement)
	    CreateWaitElement();
    if (typeof(window.pageYOffset) == "number") { 
	    scrollYT = window.pageYOffset; 
	    scrollXT = window.pageXOffset; 
    } 
    else if (document.body && document.documentElement && document.documentElement.scrollTop) { 
	    scrollYT = document.documentElement.scrollTop; 
	    scrollXT = document.body.scrollLeft;
    }
    else if (document.body && typeof(document.body.scrollTop) == "number") { 
	    scrollYT = document.body.scrollTop; 
	    scrollXT = document.body.scrollLeft; 
    } 
    if (scrollX != scrollXT || scrollY != scrollYT) {
	    scrollX = scrollXT;
	    scrollY = scrollYT;
	    var width = document.body.clientWidth;
	    waitElement.style.top = scrollYT + "px";
	    waitElement.style.right = -scrollXT +  "px";
    }
}

function CreateWaitElement() {
    var elem = document.getElementById('__AnthemCall_Wait');
    if (!elem) {
        elem = document.createElement("div");
        elem.id = '__AnthemCall_Wait';
        elem.style.position = 'absolute';
        elem.style.height = 17;
        elem.style.paddingLeft = "3px";
        elem.style.paddingRight = "3px";
        elem.style.fontSize = "11px";
        elem.style.fontFamily = 'Arial, Verdana, Tahoma';
        elem.style.border = "#000000 1px solid";
        elem.style.backgroundColor = "DimGray";
        elem.style.color = "#ffffff";
        elem.innerHTML = 'Loading...';
        elem.style.visibility = 'hidden';
        document.body.insertBefore(elem, document.body.firstChild);
    }
    waitElement = elem;
}

function Anthem_PreCallBack()
{
    //document.body.style.cursor='wait';
    //window.status = 'Querying Server, Please wait ...';
    if (waitElement && showWaitElement) {
        waitElement.style.visibility = "visible";
        MoveWaitElement();
    }
}

function Anthem_PostCallBack()
{
    //document.body.style.cursor='auto';
    //window.status = '';
    if (waitElement && showWaitElement)
        waitElement.style.visibility = "hidden";
}

//END - Anthem related function to show the loading...on the top left of the page
