﻿if (!SIGI || !SIGI.DateTime) {
    throw ("SIGI.Validation depends on the following scripts. Please make sure these are included.\nSIGI.js, SIGI.Generics.js");
}

// Browser object for detecting various versions of browsers
function BrowserObject() {

    // convert all characters to lowercase to simplify testing
    this.agent = navigator.userAgent.toLowerCase();

    // *** BROWSER VERSION ***
    // Note: On IE5, these return 4, so use this.isIE5up to detect IE5.
    this.majorVersion = parseInt(navigator.appVersion);
    this.minorVersion = parseFloat(navigator.appVersion);

    // Note: Opera and WebTV spoof Navigator.  We do strict client detection.
    // If you want to allow spoofing, take out the tests for opera and webtv.
    this.isNavigator = ((this.agent.indexOf('mozilla') != -1)
						&& (this.agent.indexOf('spoofer') == -1)
						&& (this.agent.indexOf('compatible') == -1)
						&& (this.agent.indexOf('opera') == -1)
						&& (this.agent.indexOf('webtv') == -1)
						&& (this.agent.indexOf('hotjava') == -1));
    this.isGecko = (this.agent.indexOf('gecko') != -1);
    this.isIE = ((this.agent.indexOf("msie") != -1)
						&& (this.agent.indexOf("opera") == -1));
    // KNOWN BUG: On AOL4, returns false if IE3 is embedded browser
    // or if this is the first browser window opened.  Thus the
    // variables this.isAOL, this.isAOL3, and this.isAOL4 aren't 100% reliable.
    this.isAOL = (this.agent.indexOf("aol") != -1);
    this.isOpera = (this.agent.indexOf("opera") != -1);

    this.isWebTV = (this.agent.indexOf("webtv") != -1);
    this.isTVNavigator = ((this.agent.indexOf("navio") != -1) || (this.agent.indexOf("navio_aoltv") != -1));
    this.isAOLTV = this.isTVNavigator;
    this.isHotJava = (this.agent.indexOf("hotjava") != -1);

    this.isNavigator2 = (this.isNavigator && (this.majorVersion == 2));
    this.isNavigator3 = (this.isNavigator && (this.majorVersion == 3));
    this.isNavigator4 = (this.isNavigator && (this.majorVersion == 4));
    this.isNavigator4up = (this.isNavigator && (this.majorVersion >= 4));
    this.isNavigatorOnly = (this.isNavigator && ((this.agent.indexOf(";nav") != -1)
							|| (this.agent.indexOf("; nav") != -1)));
    this.isNavigator6 = (this.isNavigator && (this.majorVersion == 5));
    this.isNavigator6up = (this.isNavigator && (this.majorVersion >= 5));

    this.isIE3 = (this.isIE && (this.majorVersion < 4));
    this.isIE4 = (this.isIE && (this.majorVersion == 4) && (this.agent.indexOf("msie 4") != -1));
    this.isIE4up = (this.isIE && (this.majorVersion >= 4));
    this.isIE5 = (this.isIE && (this.majorVersion == 4) && (this.agent.indexOf("msie 5.0") != -1));
    this.isIE5_5 = (this.isIE && (this.majorVersion == 4) && (this.agent.indexOf("msie 5.5") != -1));
    this.isIE5up = (this.isIE && !this.isIE3 && !this.isIE4);
    this.isIE5_5up = (this.isIE && !this.isIE3 && !this.isIE4 && !this.isIE5);
    this.isIE6 = (this.isIE && (this.majorVersion == 4) && (this.agent.indexOf("msie 6.") != -1));
    this.isIE6up = (this.isIE && !this.isIE3 && !this.isIE4 && !this.isIE5 && !this.isIE5_5);


    this.isAOL3 = (this.isAOL && this.isIE3);
    this.isAOL4 = (this.isAOL && this.isIE4);
    this.isAOL5 = (this.agent.indexOf("aol 5") != -1);
    this.isAOL6 = (this.agent.indexOf("aol 6") != -1);


    this.isOpera2 = (this.agent.indexOf("opera 2") != -1 || this.agent.indexOf("opera/2") != -1);
    this.isOpera3 = (this.agent.indexOf("opera 3") != -1 || this.agent.indexOf("opera/3") != -1);
    this.isOpera4 = (this.agent.indexOf("opera 4") != -1 || this.agent.indexOf("opera/4") != -1);
    this.isOpera5 = (this.agent.indexOf("opera 5") != -1 || this.agent.indexOf("opera/5") != -1);
    this.isOpera5up = (this.isOpera && !this.isOpera2 && !this.isOpera3 && !this.isOpera4);

    this.isHotJava3 = (this.isHotJava && (this.majorVersion == 3));
    this.isHotJava3up = (this.isHotJava && (this.majorVersion >= 3));

    // *** JAVASCRIPT VERSION CHECK ***
    this.jsVersion = 0;
    if (this.isNavigator2 || this.isIE3) this.jsVersion = 1.0;
    else if (this.isNavigator3) this.jsVersion = 1.1;
    else if (this.isOpera5up) this.jsVersion = 1.3;
    else if (this.isOpera) this.jsVersion = 1.1;
    else if ((this.isNavigator4 && (this.minorVersion <= 4.05)) || this.isIE4) this.jsVersion = 1.2;
    else if ((this.isNavigator4 && (this.minorVersion > 4.05)) || this.isIE5) this.jsVersion = 1.3;
    else if (this.isHotJava3up) this.jsVersion = 1.4;
    else if (this.isNavigator6 || this.isGecko) this.jsVersion = 1.5;
    // NOTE: In the future, update this code when newer versions of JS
    // are released. For now, we try to provide some upward compatibility
    // so that future versions of Nav and IE will show they are at
    // *least* JS 1.x capable. Always check for JS version compatibility
    // with > or >=.
    else if (this.isNavigator6up) this.jsVersion = 1.5;
    // NOTE: ie5up on mac is 1.4
    else if (this.isIE5up) this.jsVersion = 1.3

    // HACK: no idea for other browsers; always check for JS version with > or >=
    else this.jsVersion = 0.0;

    // *** PLATFORM ***
    this.isWindows = ((this.agent.indexOf("win") != -1) || (this.agent.indexOf("16bit") != -1));
    // NOTE: On Opera 3.0, the userAgent string includes "Windows 95/NT4" on all
    //        Win32, so you can't distinguish between Win95 and WinNT.
    this.isWindows95 = ((this.agent.indexOf("win95") != -1) || (this.agent.indexOf("windows 95") != -1));

    // is this a 16 bit compiled version?
    this.isWindows16 = ((this.agent.indexOf("win16") != -1) ||
               (this.agent.indexOf("16bit") != -1) || (this.agent.indexOf("windows 3.1") != -1) ||
               (this.agent.indexOf("windows 16-bit") != -1));

    this.isWindows31 = ((this.agent.indexOf("windows 3.1") != -1) || (this.agent.indexOf("win16") != -1) ||
                    (this.agent.indexOf("windows 16-bit") != -1));

    this.isWindowsme = ((this.agent.indexOf("win 9x 4.90") != -1));
    this.isWindows2k = ((this.agent.indexOf("windows nt 5.0") != -1));

    // NOTE: Reliable detection of Win98 may not be possible. It appears that:
    //       - On Nav 4.x and before you'll get plain "Windows" in userAgent.
    //       - On Mercury client, the 32-bit version will return "Win98", but
    //         the 16-bit version running on Win98 will still return "Win95".
    this.isWindows98 = ((this.agent.indexOf("win98") != -1) || (this.agent.indexOf("windows 98") != -1));
    this.isWindowsnt = ((this.agent.indexOf("winnt") != -1) || (this.agent.indexOf("windows nt") != -1));
    this.isWindows32 = (this.isWindows95 || this.isWindowsnt || this.isWindows98 ||
                    ((this.majorVersion >= 4) && (navigator.platform == "Win32")) ||
                    (this.agent.indexOf("win32") != -1) || (this.agent.indexOf("32bit") != -1));

    this.isOS2 = ((this.agent.indexOf("os/2") != -1) ||
                    (navigator.appVersion.indexOf("OS/2") != -1) ||
                    (this.agent.indexOf("ibm-webexplorer") != -1));

    this.isMac = (this.agent.indexOf("mac") != -1);
    // hack ie5 js version for mac
    if (this.isMac && this.isIE5up) this.jsVersion = 1.4;
    this.isMac68k = (this.isMac && ((this.agent.indexOf("68k") != -1) ||
                               (this.agent.indexOf("68000") != -1)));
    this.isMacPPC = (this.isMac && ((this.agent.indexOf("ppc") != -1) ||
                                (this.agent.indexOf("powerpc") != -1)));

    this.isSun = (this.agent.indexOf("sunos") != -1);
    this.isSun4 = (this.agent.indexOf("sunos 4") != -1);
    this.isSun5 = (this.agent.indexOf("sunos 5") != -1);
    this.isSunI86 = (this.isSun && (this.agent.indexOf("i86") != -1));
    this.isIrix = (this.agent.indexOf("irix") != -1);    // SGI
    this.isIrix5 = (this.agent.indexOf("irix 5") != -1);
    this.isIrix6 = ((this.agent.indexOf("irix 6") != -1) || (this.agent.indexOf("irix6") != -1));
    this.isHPUX = (this.agent.indexOf("hp-ux") != -1);
    this.isHPUX9 = (this.isHPUX && (this.agent.indexOf("09.") != -1));
    this.isHPUX10 = (this.isHPUX && (this.agent.indexOf("10.") != -1));
    this.isAIX = (this.agent.indexOf("aix") != -1);      // IBM
    this.isAIX1 = (this.agent.indexOf("aix 1") != -1);
    this.isAIX2 = (this.agent.indexOf("aix 2") != -1);
    this.isAIX3 = (this.agent.indexOf("aix 3") != -1);
    this.isAIX4 = (this.agent.indexOf("aix 4") != -1);
    this.isLinux = (this.agent.indexOf("inux") != -1);
    this.isSCO = (this.agent.indexOf("sco") != -1) || (this.agent.indexOf("unix_sv") != -1);
    this.isUnixWare = (this.agent.indexOf("unix_system_v") != -1);
    this.isMpras = (this.agent.indexOf("ncr") != -1);
    this.isReliant = (this.agent.indexOf("reliantunix") != -1);
    this.isDec = ((this.agent.indexOf("dec") != -1) || (this.agent.indexOf("osf1") != -1) ||
           (this.agent.indexOf("dec_alpha") != -1) || (this.agent.indexOf("alphaserver") != -1) ||
           (this.agent.indexOf("ultrix") != -1) || (this.agent.indexOf("alphastation") != -1));
    this.isSinix = (this.agent.indexOf("sinix") != -1);
    this.isFreeBSD = (this.agent.indexOf("freebsd") != -1);
    this.isBSD = (this.agent.indexOf("bsd") != -1);
    this.isUnix = ((this.agent.indexOf("x11") != -1) || this.isSun || this.isIrix || this.isHPUX ||
                 this.isSCO || this.isUnixWare || this.isMpras || this.isReliant ||
                 this.isDec || this.isSinix || this.isAIX || this.isLinux || this.isBSD || this.isFreeBSD);
    this.isVMS = ((this.agent.indexOf("vax") != -1) || (this.agent.indexOf("openvms") != -1));
    this.isToolTippingForValidation = false;
    this.skipNextBlur = false;
    this.lastElementFocused = "";
    this.lastElementBlurred = "";
    this.testString = "";
}
SIGI.Browser = new BrowserObject();


//cookie support functions
function setCookie(c_name, value, expiredays) {
    var exdate = new Date();
    exdate.setDate(exdate.getDate() + expiredays);
    document.cookie = c_name + "=" + escape(value) +
        ((expiredays == null) ? "" : ";expires=" + exdate.toUTCString());
}

function getCookie(c_name) {
    if (document.cookie.length > 0) {
        c_start = document.cookie.indexOf(c_name + "=");
        if (c_start != -1) {
            c_start = c_start + c_name.length + 1;
            c_end = document.cookie.indexOf(";", c_start);
            if (c_end == -1) c_end = document.cookie.length;
            return unescape(document.cookie.substring(c_start, c_end));
        }
    }
    return "";
}

function Rectangle(left, top, right, bottom) {
    this.Base();
    this.left = 0;
    this.top = 0;
    this.right = 0;
    this.bottom = 0;
    this.width = 0;
    this.height = 0;


    // left may be a rectangle object passed in
    if (left && typeof left == "object") {
        var rect = left;

        if (rect.screenX != null) // MOZILLA
            this.setRect(rect.x, rect.y, rect.x + rect.width, rect.y + rect.height);
        else // IE
            this.setRect(rect.left, rect.top, rect.right, rect.bottom);

        // otherwise it's a left coordinate
    } else if (left && top && right && bottom) {
        this.setRect(left, top, right, bottom);
    }
}
Rectangle.inherits(SIGI.Base);
Rectangle.prototype.containsRectangle = function(rectangle) {
    return this.contains(rectangle.left, rectangle.top, rectangle.width, rectangle.height);
}
Rectangle.prototype.contains = function(left, top, width, height) {
    return this.width > 0 && this.height > 0 && width > 0 && height > 0
		&& left >= this.left && left + width <= this.left + this.width
		&& top >= this.top && top + height <= this.top + this.height;
}
Rectangle.prototype.intersects = function(rectangle) {
    return rectangle.width > 0 && rectangle.height > 0 && this.width > 0 && this.height > 0
	&& rectangle.left < this.right && rectangle.right > this.left
	&& rectangle.top < this.bottom && rectangle.bottom > this.top;
}
Rectangle.prototype.setRect = function(x, y, r, b) {
    this.left = x;
    this.top = y;
    this.right = r;
    this.bottom = b;
    this.width = r - x;
    this.height = b - y;
}
Rectangle.prototype.intersect = function(rectangle) {
    var x = (this.left > rectangle.left) ? this.left : rectangle.left;
    var y = (this.top > rectangle.top) ? this.top : rectangle.top;
    var r = (this.right < rectangle.right) ? this.right : rectangle.right;
    var b = (this.bottom < rectangle.bottom) ? this.bottom : rectangle.bottom;
    return new SIGI.Rectangle(x, y, r, b);
}
SIGI.Rectangle = Rectangle;
Rectangle = null;

/*
These two methods were commented out of SIGI.js
SIGI.Rectangle is found here after splitting SIGI.js into seperate files
The methods are added at this point, after SIGI.Rectangle is defined
*/
SIGIObject.prototype.getElementPosition = function(element) {
    var rect = null;
    if (element.getBoundingClientRect) {
        rect = new SIGI.Rectangle(element.getBoundingClientRect());
    } else if (document.getBoxObjectFor) {
        rect = new SIGI.Rectangle(document.getBoxObjectFor(element));
    }
    SIGI.Window.refresh();
    rect.top += SIGI.Window.scrollY;
    rect.bottom += SIGI.Window.scrollY;
    rect.left += SIGI.Window.scrollX;
    rect.right += SIGI.Window.scrollX;
    return rect;
}
SIGIObject.prototype.getElementRelativePosition = function(element) {
    var rect = new SIGI.Rectangle();
    if (element) {
        rect.left += element.offsetLeft - (element.scrollLeft || 0);
        rect.top += element.offsetTop - (element.scrollTop || 0);
        rect.width = (element.offsetWidth || 0);
        rect.height = (element.offsetHeight || 0);
        rect.right = rect.left + rect.width;
        rect.bottom = rect.top + rect.height;
    }
    return rect;
}


function WindowObject() {
    this.Base();
    this.width = 0;
    this.height = 0;
    this.scrollX = 0;
    this.scrollY = 0;
    this.refresh();
}
WindowObject.inherits(SIGI.Base);
WindowObject.prototype.getWindowWidth = function() {
    this.width = 0;
    if (window.innerWidth)
        this.width = window.innerWidth - 18;
    else if (document.documentElement && document.documentElement.clientWidth)
        this.width = document.documentElement.clientWidth;
    else if (document.body && document.body.clientWidth)
        this.width = document.body.clientWidth;

    return this.width;
}
WindowObject.prototype.getWindowHeight = function() {
    this.height = 0;
    if (window.innerHeight) this.height = window.innerHeight - 18;
    else if (document.documentElement && document.documentElement.clientHeight)
        this.height = document.documentElement.clientHeight;
    else if (document.body && document.body.clientHeight)
        this.height = document.body.clientHeight;
    return this.height;
}
WindowObject.prototype.getScrollX = function() {
    this.scrollX = 0;
    if (typeof window.pageXOffset == "number") this.scrollX = window.pageXOffset;
    else if (document.documentElement && document.documentElement.scrollLeft)
        this.scrollX = document.documentElement.scrollLeft;
    else if (document.body && document.body.scrollLeft)
        this.scrollX = document.body.scrollLeft;
    else if (window.scrollX)
        this.scrollX = window.scrollX;
    return this.scrollX
}
WindowObject.prototype.getScrollY = function() {
    this.scrollY = 0;
    if (typeof window.pageYOffset == "number") this.scrollY = window.pageYOffset;
    else if (document.documentElement && document.documentElement.scrollTop)
        this.scrollY = document.documentElement.scrollTop;
    else if (document.body && document.body.scrollTop)
        this.scrollY = document.body.scrollTop;
    else if (window.scrollY)
        this.scrollY = window.scrollY;
    return this.scrollY;
}
WindowObject.prototype.refresh = function() {
    this.getWindowWidth();
    this.getWindowHeight();
    this.getScrollX();
    this.getScrollY();
}

SIGI.WindowObject = WindowObject;
WindowObject = null;
SIGI.Window = new SIGI.WindowObject();


/*Bridgeline support */
function clearText(ElemID) {
    var tempElem = document.getElementById(ElemID);
    if (tempElem) {
        tempElem.value = "";
    }
}


/* Function to resize the Text of a Block */
function resizeText(multiplier) {
    var c = document.getElementById("contentText");
    var d = document.getElementById("SMScontentText");

    if (c == null) {
        if (d.style.fontSize == "") {
            d.style.fontSize = "1.0em";
        }
        if (multiplier == "-1" || multiplier == "+1")
            d.style.fontSize = parseFloat(d.style.fontSize) + (multiplier * 0.2) + "em";
        else if (ReadCookie("FontSize") != -1)
            d.style.fontSize = ReadCookie("FontSize");
        document.cookie = "FontSize=" + d.style.fontSize;
    }
    else {
        if (c.style.fontSize == "") {
            c.style.fontSize = "1.0em";
        }
        if (multiplier == "-1" || multiplier == "+1")
            c.style.fontSize = parseFloat(c.style.fontSize) + (multiplier * 0.2) + "em";
        else if (ReadCookie("FontSize") != -1)
            c.style.fontSize = ReadCookie("FontSize");
        document.cookie = "FontSize=" + c.style.fontSize;
    }
}

/* Function to Expand Collapse the Questions & Answers in FAQ  */
function toggle(objID) {
    // open the answer to the question when the question is clicked
    //close the answer when the "close" link is clicked OR when the question is clicked again
    //to keep the answser open if the question is clicked before "close" is clicked, update this function to take an additional parameter for hide or show
    var curElem = document.getElementById(objID);
    if (curElem) {
        var curElemParent = curElem.parentNode;
        /*class "opened" is applied to li in CSS; assuming li is parent of clicked element*/
        /*if "opened" is in the class name then we know the hidden content is showing*/
        if (curElemParent.className.indexOf("opened") != -1) {
            curElemParent.className = curElemParent.className.replace("opened", "");
            curElem.style.display = "none";
        } else {
            curElemParent.className += " opened";
            curElem.style.display = "block";
        }
    }
}

/* Function to Toggle the Contents of TABs*/
function toggleTabs(containerID, tabID) {
    var curContainer = document.getElementById(containerID);
    var curTab = document.getElementById(tabID);
    var arrDivs = document.getElementsByTagName("DIV");
    for (i = 0; i < arrDivs.length; i++) {
        if ((arrDivs[i].id.indexOf("tab") != -1) || (arrDivs[i].id.indexOf("content") != -1)) {
            arrDivs[i].className = arrDivs[i].className.replace(" current", "");
        }
        if ((arrDivs[i].id == containerID) || (arrDivs[i].id == tabID)) {
            arrDivs[i].className += " current";
        }
    }
}

// == SIGI.UI.Control Class ==
function _SIGI_UI_ControlClass() {

    // TODO: call base class constructor->Component
    //_SIGI_UI_ControlClass.intializeBase()
    this._id = null;
    this._element = null;
}

_SIGI_UI_ControlClass.inherits(_SIGIComponentClass);

_SIGI_UI_ControlClass.prototype._onselect = function(e) {
};
_SIGI_UI_ControlClass.prototype._onfocus = function(e) {
    if (this._element && this._element.id) {
        setCookie('testString', getCookie('testString') + 'LastFocus-' + this._element.id + '|', 1);
        setCookie('lastElementFocused', this._element.id, 1);
    }
    else {
        setCookie('testString', getCookie('testString') + 'FocusMissed|', 1);
    }
};
_SIGI_UI_ControlClass.prototype._onmouseup = function(e) {
};
_SIGI_UI_ControlClass.prototype._onKeyPress = function(e) {
};
_SIGI_UI_ControlClass.prototype._onkeydown = function(e) {
};
_SIGI_UI_ControlClass.prototype._onblur = function(e) {
    if (this._element && this._element.id) {
        setCookie('testString', getCookie('testString') + 'LastBlur-' + this._element.id + '|', 1);
        setCookie('lastElementBlurred', this._element.id, 1);
    }
    else {
        setCookie('testString', getCookie('testString') + 'BlurMissed|', 1);
    }
};
_SIGI_UI_ControlClass.prototype._onchange = function(e) {
};

_SIGI_UI_ControlClass.prototype.get_element = function() {
    return this._element;
}

_SIGI_UI_ControlClass.prototype.set_element = function(element) {
    this._element = element;
    if (this._element.attachEvent || this._element.addEventListener) {
        SIGI.attachEvent(this._element, "onselect", this.context(this._onselect));
        SIGI.attachEvent(this._element, "onfocus", this.context(this._onfocus));
        SIGI.attachEvent(this._element, "onmouseup", this.context(this._onmouseup));
        SIGI.attachEvent(this._element, "onkeypress", this.context(this._onKeyPress));
        SIGI.attachEvent(this._element, "onkeydown", this.context(this._onkeydown));
        SIGI.attachEvent(this._element, "onblur", this.context(this._onblur));
        SIGI.attachEvent(this._element, "onchange", this.context(this._onchange));
    }
}

function _UI() {
    this._modalFunctionReturn;
}
_UI.prototype.msgBox = function(message, buttons, title, onModalCloseFunction) {
    this.showModal(message, buttons, title, onModalCloseFunction);
}
_UI.prototype.showModal = function(sMsg, buttons, title, sFunc) {
    SIGI.showPageTransition();
    var dlg = document.getElementById("SIGIModalDialog");
    var icon = document.getElementById("_SIGIModalIcon");
    var btnYes = document.getElementById("_SIGIModalbtnYes");
    var btnYesSpan = document.getElementById("_SIGIModalbtnYes_span");
    var btnNo = document.getElementById("_SIGIModalbtnNo");
    var btnNoSpan = document.getElementById("_SIGIModalbtnNo_span");
    var btnOk = document.getElementById("_SIGIModalbtnOk");
    var btnOkSpan = document.getElementById("_SIGIModalbtnOk_span");
    var btnCancel = document.getElementById("_SIGIModalbtnCancel");
    var btnCancelSpan = document.getElementById("_SIGIModalbtnCancel_span");

    dlg.style.width = "100%";
    dlg.style.height = "100%";
    dlg.style.visibility = "visible";
    icon.style.visibility = "visible";

    var btns = buttons.split(";");
    var defaultBtn;
    for (var i = 0; i < btns.length; i++) {
        switch (btns[i].toLowerCase()) {
            case "yes":
                btnYes.style.display = "inline";
                btnYesSpan.style.display = "inline";
                defaultBtn = btnYes;
                break;
            case "yes:default":
                btnYes.style.display = "inline";
                btnYesSpan.style.display = "inline";
                foundDefault = true;
                btnYes.focus();
                break;
            case "no":
                btnNo.style.display = "inline";
                btnNoSpan.style.display = "inline";
                break;
            case "no:default":
                btnNo.style.display = "inline";
                btnNoSpan.style.display = "inline";
                foundDefault = true;
                btnNo.focus();
                break;
            case "cancel":
                btnCancel.style.display = "inline";
                btnCancelSpan.style.display = "inline";
                break;
            case "cancel:default":
                btnCancel.style.display = "inline";
                btnCancelSpan.style.display = "inline";
                foundDefault = true;
                btnCancel.focus();
                break;
            case "ok":
                btnOk.style.display = "inline";
                btnOkSpan.style.display = "inline";
                defaultBtn = btnOk;
                break;
            case "ok:default":
                btnOk.style.display = "inline";
                btnOkSpan.style.display = "inline";
                foundDefault = true;
                btnOk.focus();
                break;
            case "exclamation":
                icon.src = SIGI.getClientThemePath() + "/images/SIGI.Error.Exclamation.large.gif";
                icon.style.display = "inline";
                break;
            case "information":
                icon.src = SIGI.getClientThemePath() + "../images/SIGI.Error.information.large.gif";
                icon.style.display = "inline";
                break;
            case "question":
                icon.src = SIGI.getClientThemePath() + "../images/SIGI.Error.question.large.gif";
                icon.style.display = "inline";
                break;
            case "critical":
                icon.src = SIGI.getClientThemePath() + "../images/SIGI.Error.Critical.large.gif";
                icon.style.display = "inline";
                break;
        }
    }

    if (defaultBtn != null) {
        defaultBtn.focus();
    }

    document.getElementById("_SIGIModalMessage").innerHTML = sMsg;
    document.getElementById("_SIGIModalTitle").innerHTML = title;
    this._modalFunctionReturn = sFunc;
}

_UI.prototype.closeModal = function(e) {
    var dlg = document.getElementById("SIGIModalDialog");
    var icon = document.getElementById("_SIGIModalIcon");
    var btnYes = document.getElementById("_SIGIModalbtnYes");
    var btnYesSpan = document.getElementById("_SIGIModalbtnYes_span");
    var btnNo = document.getElementById("_SIGIModalbtnNo");
    var btnNoSpan = document.getElementById("_SIGIModalbtnNo_span");
    var btnOk = document.getElementById("_SIGIModalbtnOk");
    var btnOkSpan = document.getElementById("_SIGIModalbtnOk_span");
    var btnCancel = document.getElementById("_SIGIModalbtnCancel");
    var btnCancelSpan = document.getElementById("_SIGIModalbtnCancel_span");

    dlg.style.width = "0%";
    dlg.style.height = "0%";
    btnYes.style.display = "none";
    btnYesSpan.style.display = "none";
    btnNo.style.display = "none";
    btnNoSpan.style.display = "none";
    btnOk.style.display = "none";
    btnOkSpan.style.display = "none";
    btnCancel.style.display = "none";
    btnCancelSpan.style.display = "none";
    dlg.style.visibility = "hidden";
    icon.style.visibility = "hidden";
    SIGI.hidePageTransition();

    if (this._modalFunctionReturn)
        this._modalFunctionReturn(e, "");
    this._modalFunctionReturn = null;
}



SIGI.UI = new _UI();
SIGI.UI.Control = _SIGI_UI_ControlClass;

// == SIGI.EventArgs Class ==
function SIGI_EventArgs() {
}

SIGI_EventArgs.prototype.Empty = function() {

    return new SIGI_EventArgs

}

SIGI.EventArgs = SIGI_EventArgs;

// == SIGI.EventClass ==
function _SIGI_EventClass() {
}

_SIGI_EventClass.prototype.format = function(oEvent) {

    if (oEvent && SIGI.Browser.isIE) {
        oEvent.charCode = (oEvent.type == "keypress") ? oEvent.keyCode : 0;
        oEvent.eventPhase = 2;
        oEvent.target = oEvent.srcElement;
        oEvent.isChar = (oEvent.charCode > 0);
        oEvent.pageX = oEvent.clientX + document.body.scrollLeft;
        oEvent.pageY = oEvent.clientY + document.body.scrollTop;
        if (oEvent.type == "mouseout") {
            oEvent.relatedTarget = oEvent.toElement;
        } else if (oEvent.type == "mouseover") {
            oEvent.relatedTarget = oEvent.fromElement;
        }
        oEvent.stopPropagation = function() {
            this.cancelBubble = true;
        };
        oEvent.preventDefault = function() {
            this.returnValue = false;
        }
        oEvent.timeStamp = (new Date).getTime();
    }
    return oEvent;
}

_SIGI_EventClass.prototype.addEventListener = function(oTarget, sEventType, fnHandler) {

    if (oTarget.addEventListener) {         // DOM compliant browsers
        oTarget.addEventListener(sEventType, fnHandler, false);
    } else if (oTarget.attachEvent) {       //IE
        oTarget.attachEvent("on" + sEventType, fnHandler);
    }
}

_SIGI_EventClass.prototype.removeEventListener = function(oTarget, sEventType, fnHandler) {

    if (oTarget.removeEventListener) {          // DOM compliant browsers
        oTarget.removeEventListener(sEventType, fnHandler, false);
    } else if (oTarget.detachEvent) {           //IE
        oTarget.detachEvent("on" + sEventType, fnHandler);
    }
}

SIGI.Event = new _SIGI_EventClass();


//Firefox Compatibility Functions
// insertAdjacentHTML(), insertAdjacentText() and insertAdjacentElement 
// for Netscape 6/Mozilla by Thor Larholm me@jscript.dk 
// Usage: include this code segment at the beginning of your document
// before any other Javascript contents. 
if (typeof HTMLElement != "undefined" && !HTMLElement.prototype.insertAdjacentElement) {
    HTMLElement.prototype.insertAdjacentElement = function(where, parsedNode) {
        switch (where) {
            case 'beforeBegin':
                this.parentNode.insertBefore(parsedNode, this);
                break;
            case 'afterBegin':
                this.insertBefore(parsedNode, this.firstChild);
                break;
            case 'beforeEnd':
                this.appendChild(parsedNode);
                break;
            case 'afterEnd':
                if (this.nextSibling) {
                    this.parentNode.insertBefore(parsedNode, this.nextSibling);
                }
                else {
                    this.parentNode.appendChild(parsedNode);
                }
                break;
        }
    }

    HTMLElement.prototype.insertAdjacentHTML = function(where, htmlStr) {
        var r = this.ownerDocument.createRange();
        r.setStartBefore(this);
        var parsedHTML = r.createContextualFragment(htmlStr);
        this.insertAdjacentElement(where, parsedHTML);
    }


    HTMLElement.prototype.insertAdjacentText = function(where, txtStr) {
        var parsedText = document.createTextNode(txtStr);
        this.insertAdjacentElement(where, parsedText);
    }
}




