﻿/// <reference path="ClientScreenSize.js" />
/// <reference name="MicrosoftAjax.js" />
var Tmer = null;
var mintScrollTop = 0;

function GetLiEventTarget(e) {
    if (e.target) {

        if (e.target.parentNode.tagName == 'LI') {
            return e.target.parentNode;
        }
        else
            return e.target;
    }
    else if (e.srcElement) {
        if (e.srcElement.parentNode.tagName == 'LI') {
            return e.srcElement.parentNode;
        }
        else
            return e.srcElement;
    }
}

function GetEventTarget(e) {
    if (e.target) {
        return e.target;
    }
    else if (e.srcElement) {
        return e.srcElement;
    }
}
function CancelSpanEvents(mainItemNode) {
    var objNode = null;
    for (var htmlTagCount = 0; htmlTagCount <= mainItemNode.getElementsByTagName('A').length - 1; htmlTagCount++) {
        objNode = mainItemNode.getElementsByTagName('A').item(htmlTagCount);
        //            objNode.onmouseover = ReturnEventFalse;
        //            objNode.onmouseout  = ReturnEventFalse;
        //            objNode.onclick     = ReturnEventFalse;
        //            objNode.onmouseup   = ReturnEventFalse;
        //            objNode.onmousedown = ReturnEventFalse;
    }
}

function $addHandler(element, stringEventName, handler) {
    var strWhen = 'on';
    if (stringEventName.toString().substring(0, 2) == "on") {
        strWhen = "";
    }
    element.setAttribute(strWhen + stringEventName, handler);
}
function $removeHandler(element, stringEventName) {
    var strWhen = 'on';
    try {
        if (stringEventName.toString().substring(0, 2) == "on") {
            strWhen = "";
        }
        element.removeAttribute(strWhen + stringEventName);
    }
    catch (e) {
        alert("Error : removing handler with custom $removerHandler function");
    }
}
function HideNode(node) {
    if (IsNullOrUndefined(node) == false) {
        node.style.display = 'none';
    }
}
function ShowNode(node) {
    if (IsNullOrUndefined(node) == false) {
        node.style.display = '';
    }
}

/*  function HideAll(nodeList, optional_exceptionItemIndex)
{
if(optional_exceptionItemIndex != null)
{          
for(var x = 0; x <= nodeList.length - 1; x++)
{
if(x != parseInt(optional_exceptionItemIndex))
{
HideNode(nodeList[x]);
}
}
}            
else
{
for(var x = 0; x <= nodeList.length - 1; x++)
HideNode(nodeList[x]);
}
}
*/
function SetTimer(evt) {
    try { Tmer = evt; } catch (e) { }
}

function StopTimer() {
    try { clearTimeout(Tmer) } catch (e) { }
}
function StringContains(strEvalString, strStringToFind) {
    if (strEvalString != "") {

        if (strEvalString.split(strStringToFind).length > 0) {
            return true;
        }
        else
            return false;
    }
    else
        return false;
}
function ShowAll(nodeList) {
    for (var x = 0; x <= nodeList.length - 1; x++) {
        ShowNode(nodeList[x]);
    }
}
function adminSeeNodeHtml(node) {
    var tx = document.createElement("TEXTAREA");
    tx.style.cssText = "position:absolute;top:100px;left:10px;zIndex:20000;width:90%;height:650px;background-color:#626262;color:#ffffff;";
    tx.innerText = node.innerHTML;
    document.body.appendChild(tx);
}
function doAdminSeeNodeTest() {
    if (document.body.childNodes.item(document.body.childNodes.length - 1).tagName == 'TEXTAREA') {
        document.body.removeChild(document.body.childNodes.item(document.body.childNodes.length - 1));
    }
    else {
        //adminSeeNodeHtml(mobjControlNode);
        adminSeeNodeHtml(objTblBdy);
    }
}
function HideAllStartingFromLast(nodeList, nodeToStopAt) {
    if (nodeList && nodeToStopAt) {
        ShowAll(nodeList);
        for (var x = nodeList.length - 1; x >= 0; x = (x - 1)) {
            if (nodeList[x] == nodeToStopAt) {
                break;
            }
            else {
                HideNode(nodeList[x]);
                UpdateListViewImage(nodeList[x]);
            }
            /* else if(nodeList[x].getElementsByTagName('LI').length >= 1)
            {

                }*/

        }
    }
    else if (nodeList)
        for (var x = nodeList.length - 1; x >= 1; x = (x - 1)) {
        HideNode(nodeList[x]);
    }
}
function UpdateListViewImage(item) {
    if (item.getElementsByTagName('IMG').length > 0)
        item.getElementsByTagName('IMG').item(0).src = objHideSubListImg.src;
}
function SetNodeStyle(node, cssStyleString) {
    node.style.cssText = cssStyleString;
}
function newNode(tagName, bolAppendToDocument) {
    if (IsNullOrUndefined(bolAppendToDocument) == false && bolAppendToDocument == true) {
        document.body.appendChild(document.createElement(tagName));
        return document.body.lastChild;
    }
    else
        return document.createElement(tagName);
}
function GetAtt(node, Attribute, bolParseInt32) {
    if (IsNullOrUndefined(node) == false) {
        if (IsNullOrUndefined(Attribute) == false) {
            if (IsNullOrUndefined(bolParseInt32) != true) {
                return parseInt(node.getAttribute(Attribute).toString());
            }
            else {
                return node.getAttribute(Attribute);
            }
        }
        else {
            if (IsNullOrUndefined(bolParseInt32) == false) {
                return -1;
            }
            else {
                return "";
            }
        }
    }
    else return false;
}
function SetAtt(node, Attribute, Value) {
    node.setAttribute(Attribute, Value);
    return node;
}
function GetClientWidth() {
    var intClientWidth = 0;
    if (typeof (window.innerWidth) == 'number') {
        //Non-IE
        intClientWidth = window.innerWidth;
    } else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
        //IE 6+ in 'standards compliant mode'
        intClientWidth = document.documentElement.clientWidth;
    } else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
        //IE 4 compatible
        intClientWidth = document.body.clientWidth;
    }
    return intClientWidth
}

function GetClientHeight() {
    var intClientHeight = 0;
    if (typeof (window.innerWidth) == 'number') {
        //Non-IE
        intClientHeight = window.innerHeight;
    } else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
        //IE 6+ in 'standards compliant mode'
        intClientHeight = document.documentElement.clientHeight;
    } else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
        //IE 4 compatible
        intClientHeight = document.body.clientHeight;
    }
    return intClientHeight
}
function IsNullOrUndefined(value) {
    if (value != null && value != undefined && value != "" && value != '') {
        return false;
    }
    else {
        return true;
    }
}
function ReturnEventFalse(e) {
    e = e || window.event;
    event.cancelBubble = true;
    return false;
}

function WatermarkTextBox_onfocus(strLabelText, e) {

    e = e || window.event;
    var objTextBox = e.target || e.srcElement;
    if (objTextBox.value == strLabelText || (strLabelText == "Password" && objTextBox.value == "")) {
        objTextBox.value = "";
        objTextBox.style.fontStyle = '';
        objTextBox.style.color = '';
        if (strLabelText == "Password") {
            try { watermark.style.display = 'none'; } catch (ex) { }
        }
    }
}

function WatermarkTextBox_onblur(strLabelText, e) {
    e = e || window.event;
    var objTextBox = e.target || e.srcElement;
    if (objTextBox.value == "") {

        if (strLabelText == "Password") {
            try { watermark.style.display = ''; } catch (ex) { }
        }
        else {
            objTextBox.value = strLabelText;
            objTextBox.style.fontStyle = 'italic';
            objTextBox.style.color = 'gray';
        }
    }
}


function GetDropDownListSelectedValue(dropDownList) {
    var intSelectedIndex = 0;
    var strValue;

    try {
        intSelectedIndex = dropDownList.selectedIndex
    }
    catch (e) {
        intSelectedIndex = 0;
    }

    try {
        strValue = dropDownList.options.item(intSelectedIndex).value;
    }
    catch (e) {
        strValue = "";
    }
    return strValue;
}

function AddToEvent(element, stringEventName, eventHandler) {
    var strEv = stringEventName.toString();

    if (strEv.substring(0, 2) != "on") {
        strEv = "on" + strEv;
    }
    if (element) {
        element.attachEvent(strEv, eventHandler);
    }
}

//Xml Async Postback Functions And Methods----------------------------------------------------------
var mxmlHttp = null;
var mobjReturnValueReciever = null;
var mstrUrl = "";
var mstrSetProperty = "";
var mstrXmlResponseValue = "";
var mstrExtendedFunction = "";
var mintTryPostBackCount = 0;


function createXMLHttpRequest() {
    if (window.ActiveXObject) {
        mxmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    else if (window.XMLHttpRequest) {
        mxmlHttp = new XMLHttpRequest();
    }
}
function DoXmlPostBack(FullUrl_String, Optional_OnPostBackComplete_ExtendedFunction) {
    mstrUrl = FullUrl_String;
    try {
        if (Optional_OnPostBackComplete_ExtendedFunction) {
            mstrExtendedFunction = GetFunctionStringValue(Optional_OnPostBackComplete_ExtendedFunction);
        }
    }
    catch (ex) {
        mstrExtendedFunction = "";
    }
    if (mxmlHttp == null) {
        createXMLHttpRequest();
        setTimeout('CheckXmlHttpObject()', 20);
    }
    else {
        mxmlHttp.open("GET", mstrUrl, true);
        mxmlHttp.onreadystatechange = updatePageValues;
        mxmlHttp.send();
        mstrUrl = "";
        return false;
    }
}
function CheckXmlHttpObject() {
    mintTryPostBackCount += 1;
    if (mxmlHttp != null) {
        mxmlHttp.open("GET", mstrUrl, true);
        mxmlHttp.onreadystatechange = updatePageValues;
        mxmlHttp.send();
        mintTryPostBackCount = 0;
    }
    else {
        if (mintTryPostBackCount <= 25)
            setTimeout('CheckXmlHttpObject()', 20);
    }
}
function updatePageValues() {
    if (mxmlHttp.readyState == 4 && mxmlHttp.status == 200) {
        if (mxmlHttp.responseText != null && mxmlHttp.responseText != "") {

            mstrXmlResponseValue = mxmlHttp.responseText;
            try { document.getElementById('iFrameDialog').src = ""; } catch (ex) { }
            if (divOverlayPanel != null) {
                //RemoveOverlay();
                var x;
                if (mstrExtendedFunction != "") {
                    setTimeout(mstrExtendedFunction, 0);
                }
                mstrExtendedFunction = "";
                try { StopWaitOverLay(); } catch (e) { }
                document.documentElement ? document.documentElement.style.overflow = 'auto' : x = 1;
                //divOverlayPanel = null;
            }
        }
    }
}
function GetXmlPostValue() {
    return mstrXmlResponseValue;
}
//------------------------------------------End XML Asyc Post Back----------------------------------------------------------------
var mevtOnEndPostBackHandler = null;
var mstrOnEndPostBackHandler = "";

function Set_OnEndPostBackHandler(Handler) {
    mevtOnEndPostBackHandler = Handler;
    mstrOnEndPostBackHandler = GetFunctionStringValue(Handler);
}

function Global_EndAsyncPostBackHandler() {
    setTimeout(mstrEndPostBackEventString, 0);
    mevtOnEndPostBackHandler = null;
    mstrEndPostBackEventString = "";
}

function Do_AsyncPostBack(eventName, eventArgs, optional_onPostBackEndHandler) {
    var prm = Sys.WebForms.PageRequestManager.getInstance();

    if (!Array.contains(prm._asyncPostBackControlIDs, eventName)) {
        prm._asyncPostBackControlIDs.push(eventName);
    }

    if (!Array.contains(prm._asyncPostBackControlClientIDs, eventName)) {
        prm._asyncPostBackControlClientIDs.push(eventName);
    }

    __doPostBack(eventName, eventArgs);
    if (optional_onPostBackEndHandler != null) {
        prm.add_endRequest(optional_onPostBackEndHandler);
    }
}

var bolFoundValidatorInput = false;
var mobjNodeToSearch = null;
var arySearcher = null;
var _validator = null;
var mstrValidatorId = "";
var mstrEndPostBackEventString = "";
var mstrWhilePostingBackEventString = "";

function Fire_EndAsyncPostBack_Listener(EventToRunOnPostBack, validatorId, OptionalMethodToRunWhilePostingBack) {
    try {
        mstrValidatorId = validatorId;
        if (bolFoundValidatorInput == false) {
            mobjNodeToSearch = document;
            mstrWhilePostingBackEventString = GetFunctionStringValue(OptionalMethodToRunWhilePostingBack);
            mstrEndPostBackEventString = GetFunctionStringValue(EventToRunOnPostBack);
        }
        else {
            mobjNodeToSearch = _validator.parentNode;
        }
        arySearcher = mobjNodeToSearch.getElementsByTagName('INPUT');
        for (var x = 0; x <= arySearcher.length - 1; x++) {
            if (arySearcher[x].className && arySearcher[x].className == validatorId) {
                _validator = arySearcher[x];
                bolFoundValidatorInput = true;
                break;
            }
        }
        if (_validator != null) {
            if (parseInt(_validator.value) != 0) {
                _validator.value = 0;
                setTimeout(mstrEndPostBackEventString, 0);
                mstrEndPostBackEventString = "";
                mstrWhilePostingBackEventString = "";
                bolFoundValidatorInput = false;
                _validator = null;
            }
            else {
                setTimeout('CheckPostBackStatus()', 25);
                if (mstrWhilePostingBackEventString != "") {
                    setTimeout(mstrWhilePostingBackEventString, 0);
                }
            }
        }
    }
    catch (e) { }
}

function CheckPostBackStatus() {
    if (bolFoundValidatorInput == false) {
        mobjNodeToSearch = document;
        bolFoundValidatorInput = true;
    }
    else {
        mobjNodeToSearch = _validator.parentNode;
    }
    arySearcher = mobjNodeToSearch.getElementsByTagName('INPUT');
    for (var x = 0; x <= arySearcher.length - 1; x++) {
        if (arySearcher[x].className && arySearcher[x].className == mstrValidatorId) {
            _validator = arySearcher[x];
            bolFoundValidatorInput = true;
        }
    }
    if (_validator != null) {
        if (parseInt(_validator.value) != 0) {
            _validator.value = 0;
            setTimeout(mstrEndPostBackEventString, 0);
            mstrEndPostBackEventString = "";
            mstrWhilePostingBackEventString = "";
            bolFoundValidatorInput = false;
            _validator = null;
        }
        else {
            setTimeout('CheckPostBackStatus()', 25);
            if (mstrWhilePostingBackEventString != "") {
                setTimeout(mstrWhilePostingBackEventString, 0);
            }
        }
    }
}

function GetQueryString(strRequestedQueryStringKey) {
    var strLoc = document.location.toString();
    var strReturnQueryStringValue = "";
    var strLocQueryStrings = "";
    var arySplitQueryStrings = null;
    var arySplitQueryStringKeyFromValue = null;

    try {
        strLocQueryStrings = strLoc.split("?")[1].toString();
    }
    catch (e) {
        strLocQueryStrings = "";
    }
    if (strLocQueryStrings != "") {
        try {
            arySplitQueryStrings = strLocQueryStrings.split("&");
            //arySplitQueryStrings = strLocQueryStrings.split("&");
        }
        catch (e) {
            arySplitQueryStrings = null;
        }
        if (arySplitQueryStrings == null) {
            strReturnQueryStringValue = strLocQueryStrings.split("=")[1];
        }
        else {
            for (var x = 0; x <= arySplitQueryStrings.length - 1; x++) {
                arySplitQueryStringKeyFromValue = arySplitQueryStrings[x].split("=");
                if (arySplitQueryStringKeyFromValue[0].toString() == strRequestedQueryStringKey) {
                    strReturnQueryStringValue = arySplitQueryStringKeyFromValue[1].toString();
                }
            }
        }
    }
    else {
        strReturnQueryStringValue = "";
    }
    return strReturnQueryStringValue;
}

function GetObjectRelativeSrc(objObject) {
    var strUrl = objObject.src.toString();
    var str = strUrl;

    strUrl = strUrl.split("/");
    return (strUrl.length > 0 ? strUrl[strUrl.length - 1] : str);
}

function GetFileNameOnly(strPath) {
    var strUrl = strPath;

    strUrl = strPath.split("/");
    return (strUrl.length > 0 ? strUrl[strUrl.length - 1] : strPath);
}

function GetRelativeUrl(bolWithQueryString) {
    var strUrl = document.location.toString();

    if (UrlHasQueryString() == true && (bolWithQueryString == null || bolWithQueryString == false)) {
        strUrl = strUrl.split("?");
        strUrl = strUrl[0];
    }

    strUrl = strUrl.split("/");

    return strUrl[strUrl.length - 1];
}

function GetRelativImgSrc(objImage) {
    var strSrc = objImage.src.toString();

    strSrc = strSrc.split("/");

    return strSrc[strSrc.length - 1];
}

function UrlHasQueryString() {
    var strLoc = document.location.toString();
    if (strLoc.indexOf("?") > -1) {
        return true;
    }
    else
        return false;
}
function RefreshIframeDoc() {
    var strAmp = "?";
    var strQuyStrRf = GetQueryString("Refreshed");

    if (strQuyStrRf == "") {
        if (UrlHasQueryString() == true) {
            strAmp = "&";
        }
        document.location = document.location + strAmp + "Refreshed=1";
    }
}


var mintLoopStop = 0;
var Tim = null;
var mobj_scriptDownloading = null;
function downloadJsFile(path, strOnScriptDownloadComplete_Stringfunction) {
    var arrScripts = document.getElementsByTagName('SCRIPT');
    var objNewScript = null;
    var bolScriptExists = false;
    var strSrc = GetFileNameOnly(path);

    for (var x = 0; x <= arrScripts.length - 1; x++) {
        if (GetObjectRelativeSrc(arrScripts[x]) == strSrc) {
            bolScriptExists = true;
            break;
        }
    }
    if (bolScriptExists == false) {
        mobj_scriptDownloading = document.createElement('SCRIPT');
        mobj_scriptDownloading.setAttribute("type", "text/javascript");
        mobj_scriptDownloading.src = path;
        document.body.appendChild(mobj_scriptDownloading);
        scriptExist(strOnScriptDownloadComplete_Stringfunction);
    }
}

function scriptExist(strOnScriptDownloadComplete_Stringfunction) {
    mintLoopStop += 1;
    try {
        try { clearTimeout(Tim); } catch (ex) { }
        if (mobj_scriptDownloading.readyState.toString() == "loaded") {
            mintLoopStop = 0;
            if (strOnScriptDownloadComplete_Stringfunction && strOnScriptDownloadComplete_Stringfunction != "") {
                RunCodeBlock(strOnScriptDownloadComplete_Stringfunction);
                //setTimeout(strOnScriptDownloadComplete_Stringfunction, 1);
            }
            mobj_scriptDownloading = null;
        }
        else if (mintLoopStop < 1000) {
            RunCodeBlock("scriptExist(\"" + strOnScriptDownloadComplete_Stringfunction + "\");");
            //Tim = setTimeout("scriptExist(\"" + strOnScriptDownloadComplete_Stringfunction + "\")", 20);
        }
    } catch (ex2) {
        alert(mintLoopStop);
    }
}
function TestTest(strMessage) {
    alert(strMessage);
}
//--------------------------------------------------------------------------------------------------
function SetPositionsAttributes(node) {
    SetAtt(node, 'X', Sys.UI.DomElement.getBounds(node).x.toString());
    SetAtt(node, 'Y', Sys.UI.DomElement.getBounds(node).y.toString());
    SetAtt(node, 'W', Sys.UI.DomElement.getBounds(node).width.toString());
    SetAtt(node, 'H', Sys.UI.DomElement.getBounds(node).height.toString());
    SetAtt(node, 'B', (GetAtt(node, 'Y', true) + GetAtt(node, 'H', true)).toString());
    SetAtt(node, 'R', (GetAtt(node, 'X', true) + GetAtt(node, 'W', true)).toString());
}
function GetPositionsAttributes(node) {
    return { X: GetAtt(node, 'X', true), Y: GetAtt(node, 'Y', true), Width: GetAtt(node, 'W', true), Height: GetAtt(node, 'H', true), Bottom: GetAtt(node, 'B', true), Right: GetAtt(node, 'R', true) };
}
var PositionAttributes = {
        SetAttributes: function(node) {
        SetAtt(node, 'X', Sys.UI.DomElement.getBounds(node).x.toString());
        SetAtt(node, 'Y', Sys.UI.DomElement.getBounds(node).y.toString());
        SetAtt(node, 'W', Sys.UI.DomElement.getBounds(node).width.toString());
        SetAtt(node, 'H', Sys.UI.DomElement.getBounds(node).height.toString());
        SetAtt(node, 'B', (GetAtt(node, 'Y', true) + GetAtt(node, 'H', true)).toString());
        SetAtt(node, 'R', (GetAtt(node, 'X', true) + GetAtt(node, 'W', true)).toString());
    },
    GetBounds: function(node) {
        return { Left: GetAtt(node, 'X', true), Top: GetAtt(node, 'Y', true), Width: GetAtt(node, 'W', true), Height: GetAtt(node, 'H', true), Bottom: GetAtt(node, 'B', true), Right: GetAtt(node, 'R', true) };
    }
}
//Vert And Horz Lines, Center Point follows mouse----------------------------------------------------------------------------------------
var objHLine = null;
var objVLine = null;
var bolAppendedLines = false;
function CreateScreenLines() {
    var intHeight = GetClientHeight();

    if (document.body.offsetHeight > intHeight) {
        intHeight = document.body.offsetHeight;
    }

    objHLine = document.createElement('DIV');
    objVLine = document.createElement('DIV');

    objHLine.style.width = '100%';
    objHLine.style.position = 'absolute';
    objHLine.style.height = '1px';
    objHLine.style.minWidth = '100%';
    objHLine.maxHeight = '1px';
    objHLine.style.minHeight = '1px';
    objHLine.style.borderTop = 'solid 1px black';

    objVLine.style.position = 'absolute';
    objVLine.style.top = '0px';
    objVLine.style.width = '1px';
    objVLine.style.height = intHeight + 'px';
    objVLine.style.minWidth = '1px';
    objVLine.style.maxWidth = '1px';
    objVLine.style.minHeight = intHeight + 'px';
    objVLine.style.borderLeft = 'solid 1px black';
    document.attachEvent("onmousemove", ShowLinesWithMouse);

}

function ShowLinesWithMouse(e) {
    e = e || window.event;
    var intTop = GetScrollTop() + e.clientY;
    var intLeft = GetScrollLeft() + e.clientX;

    if (bolAppendedLines == false) {
        bolAppendedLines = true;
        document.body.appendChild(objHLine);
        document.body.appendChild(objVLine);
    }
    objHLine.style.top = intTop;
    objVLine.style.left = intLeft;
}
//---------------------------------------------------------------------------------------------------------------------------------------


var divOverlayPanel = null;
function CreateDocumentOverLay(BackgroundColor, Opacity, Id, Z_Index, bolMatchFullDocumentHeight, bolRemoveWindowScrollBars, DefaultButtonId, bolHideOverlay, bolDontAppendToBody) {

    var intClientWidth = GetClientWidth();
    var intClientHeight = GetClientHeight();


    //Customize Properties
    var strBackgroundColor = "black";
    var intOpacity = 60;
    var intZindex = 20000;
    var intOverLayHeight = intClientHeight;
    var _bolMainWindowScrollable = false;
    var strCssText = "";
    var divOverLayId = "divOverLay";

    divOverlayPanel = document.createElement('DIV');

    if (BackgroundColor != null && BackgroundColor != "") {
        strBackgroundColor = BackgroundColor;
    }
    if (Opacity != null && Opacity != "") {
        intOpacity = Opacity;
    }
    if (Id != null && Id != "") {
        //divOverLayId = Id;
        divOverlayPanel = document.getElementById(Id);
    }
    if (Z_Index != null && Z_Index != "") {
        intZindex = Z_Index;
    }
    if (bolMatchFullDocumentHeight != null && bolMatchFullDocumentHeight != "") {
        if (bolMatchFullDocumentHeight == true) {
            intOverLayHeight += GetScrollTop();
        }
    }

    strCssText += "position:absolute;top:0px;left:0px;";
    strCssText += "height:" + intOverLayHeight + "px;min-height:" + intOverLayHeight + "px;";
    strCssText += "width:" + intClientWidth + "px;min-width:" + intClientWidth + "px;max-width:" + intClientWidth + "px;";
    strCssText += "z-index:" + intZindex + ";background-color:" + strBackgroundColor + ";"
    strCssText += "filter:alpha(opacity=" + intOpacity + ");opacity:." + (10 - (intOpacity / 10)) + "0;-moz-opacity:." + (10 - (intOpacity / 10)) + "0;";
    divOverlayPanel.style.cssText = strCssText;

    if (bolRemoveWindowScrollBars != null && bolRemoveWindowScrollBars != "") {
        if (bolRemoveWindowScrollBars == true) {
            document.documentElement.style.overflow = 'hidden';
        }
    }
    if (bolHideOverlay != null && bolHideOverlay != "" && bolHideOverlay == true) {
        HideNode(divOverlayPanel);
    }
    if (!bolDontAppendToBody || bolDontAppendToBody == false) {
        document.body.appendChild(divOverlayPanel);
    }
    return divOverlayPanel;
}
function RemoveOverlay() {
    document.body.removeChild(divOverlayPanel);
}

function CreateStandaredOverLay() {
    CreateDocumentOverLay("#ffffff", 60, null, 10000, true, false, null);
}

function StartWaitOverLay() {
    ShowNode(divOverlayPanel);
    ShowLoadingCircles();
}
function StopWaitOverLay() {
    StoppLoadingModule();
    HideNode(divOverlayPanel);
}
window.onscroll = function(e) {
    mintScrollTop = GetScrollTop();
}

function GetFunctionStringValue(EventHandler) {
    return EventHandler.toString().split("\n")[0].toString().split(" ")[1].toString().split("(")[0] + "()";
}

function GetScrollLeft() {
    return (document.documentElement ? document.documentElement.scrollLeft : document.body.scrollLeft);
}

function GetScrollTop() {
    if (document.documentElement) {
        return document.documentElement.scrollTop;
    }
    else {
        return document.body.scrollTop;
    }
}

//------Wait Overlay-------------------------------------------------------------
var I = 0;
var T = null;
var objImgs = new Array();
var mobjWaitTimerMainDiv = null;
var objDiv2 = null;
var objTbl = null;
var objTblBdy = null;
var objTblRow = null;
var mobjLoadingDark = null;
var mobjLoadingLight = null;
var mobjLoadingGif = null;
var mstrMessageHtmlText = "Please Wait...";
var WaitModuleOverlay = null;

var WaitOverlay = {
    CreateLoadingModule: function(strImgSrc, intZindex, intOpacity, overLayPanel) {
        var objImg = null;
        var objTd = null;
        var objTextNode = document.createElement('SPAN');

        WaitModuleOverlay = overLayPanel;
        objTextNode.innerHTML = mstrMessageHtmlText;

        mobjLoadingGif = document.createElement('IMG');
        mobjLoadingGif.src = strImgSrc;

        mobjWaitTimerMainDiv = document.createElement('DIV');
        objDiv2 = document.createElement('DIV');
        mobjWaitTimerMainDiv.style.cssText = "position:absolute; font-weight:bold; font-size:12pt;color:#000000;text-align:center;width:100%;z-index:" + intZindex + ";" + (intOpacity && intOpacity != null ? ("filter:alpha(opacity=" + intOpacity + ");opacity:." + (10 - (intOpacity / 10)) + "0;-moz-opacity:." + (10 - (intOpacity / 10)) + "0;") : "");
        objDiv2.style.cssText = "background-color:#ffffff;border:1px solid black;margin-top:0px;padding:10px;width:300px;margin-right:auto;margin-bottom:0px;margin-left:auto;";
        objDiv2.appendChild(mobjLoadingGif);
        objDiv2.appendChild(objTextNode);
        mobjWaitTimerMainDiv.appendChild(objDiv2);
        try { document.body.appendChild(WaitModuleOverlay); } catch (ex) { }
        document.body.appendChild(mobjWaitTimerMainDiv);
        HideNode(mobjWaitTimerMainDiv);
    },
    SetMessageHtmlText: function(strHtml) {
        mobjWaitTimerMainDiv.getElementsByTagName('DIV').item(0).getElementsByTagName('SPAN').item(0).innerHTML = strHtml;
    },
    Start: function() {
        ShowNode(WaitModuleOverlay);
        ShowNode(mobjWaitTimerMainDiv);
        mobjWaitTimerMainDiv.style.backgroundColor = 'transparent';
        mobjWaitTimerMainDiv.style.padding = '5px';
        mobjWaitTimerMainDiv.style.top = (parseInt(GetClientHeight() / 2) - parseInt(Sys.UI.DomElement.getBounds(mobjWaitTimerMainDiv).height / 2)) + 'px';
    },
    Stop: function() {
        HideNode(mobjWaitTimerMainDiv);
        HideNode(WaitModuleOverlay);
    }
};

function SetStyleForTagsOf(elementToSearch, strTag, arrStyleKeysAndValues) {
    if (elementToSearch) {
        this.Items = elementToSearch.getElementsByTagName(strTag.toUpperCase());
        if (this.Items.length > 0) {
            for (var x = 0; x <= this.Items.length - 1; x++) {
                try {
                    for (var x2 = 0; x2 <= arrStyleKeysAndValues.length - 1; x2++) {
                        this.Items[x].style[arrStyleKeysAndValues[x2][0]] = arrStyleKeysAndValues[x2][1];
                    }
                }
                catch (e) { 
                }
            }
        }
    }
}

function IsMoz() {
    return (navigator.appName.toLowerCase().indexOf('netscape') > -1 || navigator.appName.toLowerCase().indexOf('firefox') > -1 || navigator.appName.toLowerCase().indexOf('moz') > -1);
}

//Runs parsed javascript code
function RunCodeBlock(strStr) {
    if (navigator.appName.toLowerCase().indexOf('netscape') > -1 || navigator.appName.toLowerCase().indexOf('firefox') > -1 || navigator.appName.toLowerCase().indexOf('moz') > -1) {
        tempSpt = document.createElement('SPAN');
        strStr = "<SCRIPT type=\"text/javascript\">function runCode(){" + strStr + "}</SCRIPT>";
        tempSpt.innerHTML = strStr;
        document.body.appendChild(tempSpt);
        runCode();
        document.body.removeChild(tempSpt);
        tempSpt = null;
    }
    else {
        var func = new Function(strStr);
        func();
    }
}
