if (window.SIGI) throw ("SIGI.js is included in this document multiple times. There can be only one!");
var ie = document.all
var ns6 = document.getElementById && !document.all

// Basic Prototypes

/*
Type.prototype.initializeBase = function(baseClass, parms) {

if (!parms)
this.apply(baseClass);
else
this.apply(alert, baseClass);
}
*/

// here we expand the String Object to add a trim function
String.prototype.trim = function() {
    // Use a regular expression to replace leading and trailing 
    // spaces with the empty string
    return this.replace(/(^\s*)|(\s*$)/g, "");
}
function trim(value) {
    return value.toString().trim();
}
String.prototype.ltrim = function() {
    // Use a regular expression to replace leading and trailing 
    // spaces with the empty string
    return this.replace(/(^\s*)/g, "");
}
function ltrim(value) {
    return value.toString().ltrim();
}
String.prototype.rtrim = function() {
    // Use a regular expression to replace trailing 
    // spaces with the empty string
    return this.replace(/(\s*$)/g, "");
}
function rtrim(value) {
    return value.toString().rtrim();
}
function replaceInString(string, start, length, value) {
    return string.substring(0, start) + value + string.substring(start + length);
}

String.prototype.qtrim = function() {
    // Use a regular expression to replace leading and trailing spaces
    // as well as any quotes that might be surrounding, but leaves 
    // spaces inside quotes
    var value = this.trim();
    if (/(^\x27|\x22)[\s\S]*(\x27|\x22$)/.test(value)) {
        value = value.slice(1, value.length - 1);
    }
    return value;
}
function qtrim(value) {
    return value.toString().qtrim();
}
String.prototype.left = function(length) {
    if (this.length > length) {
        return this.slice(0, length);
    } else {
        return this;
    }
}
function left(value, length) {
    return value.toString().left(length);
}
String.prototype.right = function(length) {
    if (this.length > length)
        return this.slice(this.length - length);
    else
        return this;
}
function right(value, length) {
    return value.toString().right(length);
}
String.prototype.mid = function(start, length) {
    if (length != null)
        return this.substr(start - 1, length);
    else
        return this.substr(start - 1);
}
function mid(value, start, length) {
    return value.toString().mid(start, length);
}
String.prototype.fill = function(value, length) {
    var ret = value;
    if (value == null) ret = "";
    while (ret.length < length) {
        ret = ret.concat(value);
    }
    return ret;
}
String.prototype.repeat = function(iterations) {
    var ret = this;
    for (var i = 1; i < iterations; i++) {
        ret = ret.concat(this);
    }
    return ret;
}
String.prototype.pad = function(padChar, length, direction) {
    var sPadding = padChar.fill(padChar, length);
    var value = this;
    if (direction == "left") {
        value = sPadding + value;
        value = value.slice(value.length - length);
    } else {
        value += sPadding;
        value = value.slice(0, length);
    }
    return value;
}
String.prototype.encode = function(values) {
    // Encodes a string so that it is safe to pass in a URL
    // Supports encoding specified characters by passing as 
    // a parameter
    var chars = "^{}|><][`";
    var value = this;
    if (values != null) chars = values + chars;
    for (var i = 0; i < chars.length; i++) {
        var ch = chars.charCodeAt(i).toString(16);
        var xch = "x" + ch;
        var re = new RegExp("\x5c" + xch, "g");
        value = value.replace(re, "%" + ch);
    }
    return value;
}
// strips out any non-digit charachters from a string
String.prototype.getNumbers = function() {
    return this.replace(/[^0-9.]/g, "");
}
// strips out any non-digit charachters from a string
String.prototype.removeCommas = function() {
    return this.trim().replace(/,/g, "");
}
//checks to see if the string is in a list of values
String.prototype.strIn = function() {
    for (var i = 0; i < arguments.length; i++) {
        if (this.valueOf() == arguments[i])
            return true;
    }
    return false;
}
String.prototype.insertCommas = function() {
    /*  Inserts commas into a given string every 
    3rd charachter from the right, or from the 
    left-most decimal point */
    var value = this;
    if (value.removeCommas().isNumeric()) {
        value = new Number(value.removeCommas()).toString();
        var len = value.search(/\./);
        if (len < 0) len = value.length;
        for (var i = 1; i < len; i++) {
            if (i % 3 == 0)
                value = value.slice(0, len - i) + "," + value.slice(len - i);
        }
    }
    return value;
}
String.prototype.isNumeric = function() {
    var value = this.removeCommas();
    if (value.length == 0) return false;
    return /^(-)?\d*(\.\d*)?$/.test(value);
}
String.prototype.toBoolean = function() {
    var value = this.toString().trim().toLowerCase();
    if (value.isNumeric()) {
        if (parseInt(value) != 0)
            return true;
        else
            return false;
    }
    switch (value) {
        case "true":
        case "yes":
            return true;
        default:
            return false;
    }
}
function toBoolean(value) {
    if (value)
        return value.toString().toBoolean();
    else
        return false;
}
String.prototype.toNumber = function() {
    if (this.isNumeric()) {
        var value = this.removeCommas();
        return new Number(value);
    } else {
        return 0;
    }
}
function toNumber(value) {
    return value.toString().toNumber();
}
String.prototype.format = function() {
    if (this.test(/{\d+}/g)) {
        var string = this;
        if (arguments.length > 1) {
            for (var i = 0; i < arguments.length; i++) {
                var token = "{" + (i).toString() + "}";
                string = string.replace(token, arguments[i]);
            }
        }
        return string;
    } else {
        return this;
    }
}
String.prototype.formatCurrency = function(displayCents) {

    var bDisplayCents = true;

    if (arguments.length > 0) {
        if (arguments[0] == false)
            bDisplayCents = false;
    }

    num = this.toString().replace(/\$|\,/g, '');

    if (isNaN(num))
        num = "0";

    sign = (num == (num = Math.abs(num)));
    num = Math.floor(num * 100 + 0.50000000001);
    cents = num % 100;

    num = Math.floor(num / 100).toString();

    if (cents < 10)
        cents = "0" + cents;

    for (var i = 0; i < Math.floor((num.length - (1 + i)) / 3); i++)
        num = num.substring(0, num.length - (4 * i + 3)) + ',' +
		num.substring(num.length - (4 * i + 3));

    if (bDisplayCents)
        return (((sign) ? '' : '-') + '$' + num + '.' + cents);
    else
        return (((sign) ? '' : '-') + '$' + num);
}
Number.prototype.formatNumber = function() {
    /*  formats a number, parameters are based on and are identical
    to VB's format number with the exception of the vbTriState 
    Enums being mere booleans. Currency is an added parameter 
    to support formatting as currency. */
    var num = this;
    var anum = Math.abs(this);
    var value = anum.toString();

    if (arguments.length > 0 && arguments[0] > 0)
        value = anum.toFixed(arguments[0]);
    if (arguments.length > 1) {
        if (arguments[1] == true) {
            if (anum < 1 && anum >= 0 && value.slice(0, 1) != "0")
                value = "0" + value;
        } else if (anum < 1 && anum >= 0 && value.slice(0, 1) == "0") {
            value = value.slice(1);
        }
    }
    if (arguments.length > 3 && arguments[3] == true)
        value = value.insertCommas();
    if (arguments.length > 4 && arguments[4] == "currency")
        value = "$" + value;
    if (arguments.length > 2 && arguments[2] == true && num < 0) {
        value = "(" + value + ")";
    } else if (num < 0) {
        value = "-" + value;
    }
    return value;
}
Number.prototype.formatCurrency = function() {
    // Formats a number, as currency 
    // Parameters are based on and are identical
    // to VB's FormatCurrency number with the exception of the vbTriState 
    // Enums being mere booleans.
    return this.formatNumber(arguments[0], arguments[1], arguments[2], arguments[3], "currency");
}
Array.prototype.find = function(value) {
    for (var i = 0; i < this.length; i++) {
        if (value == this[i]) return i;
    }
    return -1;
}

/***************************************************************/
/*	SIGI Object Model
/*	Create the Root Object that all objects inherit from
/*	in the SIGI Model
/***************************************************************/
function Base() { }
// Provides a context for methods called on events that 
// by default end up in the global context
Base.prototype.context = function(method) {
    var self = this;
    return function() { return method.apply(self, arguments) };
};
/*Base.prototype.timeout = function(handler, delay){
var wrapper = obj.context(handler);
return window.setTimeout(wrapper, delay ? delay : 0);
};
Base.prototype.clone = function(){
if (this._clone.prototype!==this) {
this._clone = function(){};
this._clone.prototype = this;
}
return new this._clone();
};
*/
// This method allows any class to inherit from a specified class
Function.prototype.inherits = function(baseClass) {
    var prop;
    if (this == baseClass) {
        throw ("Error - cannot derive from self");
        return;
    }
    var self = this;
    for (prop in baseClass.prototype) {
        /*if (typeof(baseClass.prototype[prop]) == "function" && !this.prototype[prop]) {
        this.prototype[prop] = baseClass.prototype[prop];
        }
        */
        if (typeof (baseClass.prototype[prop]) == "function") {
            if (prop.substring(0, 5) != "base_") {
                var methodName = "base_" + prop;
                this.prototype[methodName] = baseClass.prototype[prop];
            }
            if (!this.prototype[prop]) {
                this.prototype[prop] = baseClass.prototype[prop];
            }
        }
    }

    var name = baseClass.toString();
    var re = /function\s+(\w+)\s*\(.*/;
    if (re.test) {
        name = re.exec(name)[1];
        this.prototype[name] = baseClass;
    }
}


// Create the Root for the SIGI Client Object Model
function SIGIObject() {
    this.Base();
    this.Base = Base;
    this.clientPath = this.getClientThemePath();
    this.instanceId = null;
    this.Form = null;
    this.inputCase = "CaseMixed";
    this.preventBackspace = false;
    this.allowContextMenu = true;
    this.transitionFrame = null;
    this.transitionDocument = null;
    this.progressFrame = null;
    //this.transitionControl = null;
    this._AJAXenabled = false;
    this._bodyCursor = "";
};

SIGIObject.inherits(Base);


SIGIObject.prototype.attachEvent = function(object, eventName, eventHandler) {
    if (window.attachEvent) {
        if (!/^on/.test(eventName)) eventName = "on" + eventName;
        object.attachEvent(eventName, eventHandler);
    } else if (window.addEventListener) {
        eventName = eventName.replace(/^on/, "");
        object.addEventListener(eventName, eventHandler, false);
    }
}
SIGIObject.prototype.detachEvent = function(object, eventName, eventHandler) {
    if (window.detachEvent) {
        object.detachEvent(eventName, eventHandler);
    } else if (window.removeEventListener) {
        eventName = eventName.replace(/^on/, "");
        object.removeEventListener(eventName, eventHandler, false);
    }
}
SIGIObject.prototype.cancelEvent = function(e) {
    // Stop an event from bubbling up the event DOM
    e = e || window.event;
    if (e.stopPropagation) {
        e.stopPropagation();
        e.preventDefault();
    } else if (typeof e.cancelBubble != "undefined") {
        e.cancelBubble = true;
        e.returnValue = false;
    }
    return false;
}
SIGIObject.prototype.ieEvent = function(e) {
    if (e && !this.Browser.isIE) {
        window.event = e;
        window.event.srcElement = e.target;
    }
}
SIGIObject.prototype.getClientPath = function(pathType) {
    if (pathType)
        return this.clientPath + pathType + "/";
    else
        return this.clientPath;
}

SIGIObject.prototype.getClientThemePath = function() {
    var head = document.getElementById("PageStyleSheet")
    var path;
    var bNotFound = false;
    if (head) {
        var startIndex;
        var endIndex;
        startIndex = head.href.indexOf("Theme_");
        if (startIndex > 0) {
            endIndex = head.href.indexOf("/", startIndex)
            path = head.href.substr(0, endIndex)
        }
        else
            bNotFound = true;
    }
    else
        bNotFound = true;

    if (bNotFound)
        path = "/SIGI_NET/v2_0/Client/Theme_2"

    return path;
}

SIGIObject.prototype.formatURL = function(url) {
    if (this.Form && this.instanceId) {
        var re = /instanceid=[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}/gi;

        // if query string anchors found make sure the anchors stay at the end of the query string
        var iAnchor;
        if ((iAnchor = url.indexOf("#")) != -1) {
            if (/\?/.test(url)) {
                url = url.substr(0, iAnchor) + "&InstanceID=" + this.instanceId + url.substr(iAnchor, url.length);
            }
            else {
                url = url.substr(0, iAnchor) + "?InstanceID=" + this.instanceId + url.substr(iAnchor, url.length);
            }
        }
        else {
            if (!re.test(url)) {
                if (/\?/.test(url)) {
                    url += "&InstanceID=" + this.instanceId;
                } else {
                    url += "?InstanceID=" + this.instanceId;
                }
            }
        }

        if (this.Form.allowBrowserNavigation == false) {
            // set a page transaction ID to prevent user browser navigation
            var transactionID = this.newGuid();
            var cookieName = "TID" + this.instanceId.replace(/\-/g, "");
            this.removeCookie(cookieName);
            this.setCookie(cookieName, escape(transactionID), null, "/");
            url = this.addQueryString(url, "TID=" + transactionID);
        }
    }

    return url;
}

SIGIObject.prototype.setCookie = function(cookieName, cookieValue, expireDate, cookiePath) {
    // Pass in three strings - the name of the cookie, the value,
    // and the expire date.
    // Pass in a "" empty string for expireDate to set a session 
    // cookie (no expires date).
    // Pass in any other date for expire as a number of days to 
    // be added to today's date.

    strCookie = cookieName + "=";
    if (cookieValue != null)
        strCookie += escape(cookieValue);
    if (expireDate != null) {
        var expires = expireDate.toGMTString();
        strCookie += ";expires=" + expires;
    }
    if (cookiePath != null) {
        strCookie += ";path=" + cookiePath;
    }
    document.cookie = strCookie;
}

SIGIObject.prototype.removeCookie = function(cookieName) {
    // Pass in the name of the cookie as a string and it will be removed.
    var expireDate = new Date();
    expireDate.setDate(expireDate.getDate() - 1);
    this.setCookie(cookieName, " ", expireDate);
}


SIGIObject.prototype.toHex = function(number, length) {
    var arr = "0123456789ABCDEF";
    var hex = arr.substr(number & 15, 1);
    while (number > 15) { number >>= 4; hex = arr.substr(number & 15, 1) + hex; }
    if (length != null) {
        if (hex.length < length) hex = hex.pad("0", length, "left");
    }
    return hex;
}

SIGIObject.prototype.newGuid = function() {
    //111BF2E8-299A-4727-9331-CA6E2E2A9470
    var g1 = this.toHex(Math.floor(Math.random() * 4294967295), 8);
    var g2 = this.toHex(Math.floor(Math.random() * 65535), 4);
    var g3 = this.toHex(Math.floor(Math.random() * 65535), 4);
    var g4 = this.toHex(Math.floor(Math.random() * 65535), 4);
    var g5 = this.toHex(Math.floor(Math.random() * 281474976710655), 12);
    return g1 + "-" + g2 + "-" + g3 + "-" + g4 + "-" + g5;
}

SIGIObject.prototype.addQueryString = function(url, queryString) {

    var testQueryString = queryString.encode().replace(/([\[\]\\\?\$\*\+\{\}\(\)])/g, "\\$1");
    var regEx = new RegExp(testQueryString, "i");
    if (regEx.test(url)) {
        return url;
    }
    if (url.search(/\?/) == -1) {
        return url + "?" + queryString.encode();
    } else {
        var name = queryString.substring(0, queryString.indexOf("="));
        var re = new RegExp(name + "=.*?(&|$)");
        if (name.length && re.test(url)) {
            return url.replace(re, queryString.encode() + "\$1");
        } else {
            return url + "&" + queryString.encode();
        }
    }
}

SIGIObject.prototype.navigateURL = function(url, target) {
    url = this.formatURL(url);
    if (target != null && target != "_top") {
        window.open(url, target);
    } else {
        window.navigate(url);
    }
}
SIGIObject.prototype.showPageTransition = function() {
        
    if (this.transitionFrame) {
        //save the cursor for the document body - needed for ajax postback
        this._bodyCursor = window.document.body.style.cursor;   
        this.transitionFrame.style.display = "block";
        this.transitionFrame.style.top = "0px";
        this.transitionFrame.style.left = "0px";
        this.transitionFrame.style.height = "100%";
        this.transitionFrame.style.width = "100%";
    }
}
//SIGIObject.prototype.hidePageTransition = function() {
//    
//    if (this.transitionFrame) {
//        this.transitionFrame.style.display = "hidden";
//        this.transitionFrame.style.top = "0px";
//        this.transitionFrame.style.left = "0px";
//        this.transitionFrame.style.height = "0%";
//        this.transitionFrame.style.width = "0%";
//    }
//}
SIGIObject.prototype.hidePageTransition = function() {
    if (this.transitionFrame) {
        this.transitionFrame.style.display = "none";
    }
}
SIGIObject.prototype.showProgressBar = function(msg, left, top, width, height, progressBarStyle) {
    var sframeSrc = "";
    if (this.progressFrame) {
        if (!progressBarStyle)
            progressBarStyle = "progressbarstyle1";

        //        switch (progressBarStyle.toLowerCase()) {
        //            case "progressbarstyle1":
        //                sframeSrc = SIGI.getClientThemePath() + "/Pages/SIGI.ProgressScreen2.htm";
        //            default:
        //                sframeSrc = SIGI.getClientThemePath() + "/Pages/SIGI.ProgressScreen2.htm";
        //        }

//        sframeSrc = SIGI.getClientThemePath() + "/Pages/SIGI.ProgressScreen1.htm";
//        if (SIGI.Browser.isIE)
//            document.frames("SIGI_ProgressScreen").location.href = sframeSrc;
//        else
//            document.getElementById('SIGI_ProgressScreen').src = sframeSrc;
        //this.progressFrame.src = sframeSrc;
        document.getElementById('SIGI_ProgressScreen').style.display = "block";
        if (SIGI.Browser.isIE)
            this.progressFrame.ProgressBar.WaitScreen.style.display = "inline";
        else
            this.progressFrame.ProgressBar.WaitScreen.style.display = "inline-table";


        if (!msg) { msg = "Processing request ..."; }
        if (!width) { width = "100%" }
        if (!height) { height = "100%" }
        if (!left) { left = 0; }
        if (!top) { top = 0; }

        this.progressFrame.ProgressBar.WaitMsg.innerHTML = msg;

        this.progressFrame.style.display = "block";
        this.progressFrame.style.width = width;
        this.progressFrame.style.height = height;
        this.progressFrame.style.left = left;
        this.progressFrame.style.top = top;
        this.progressFrame.waitScreen = true;
        this.progressFrame.ProgressBar.startProgress();
        for (var i = 0; i < 1000000; i++) {
            //document.write(i);
        }
    }
}
SIGIObject.prototype.hideProgressBar = function() {
if ((this.progressFrame) && ((this.progressFrame.ProgressBar.stopProgress))) {
        this.progressFrame.ProgressBar.stopProgress();
        this.progressFrame.style.display = "none";
    }
}
SIGIObject.prototype.openWindowOnload = function(url, target, features) {
    this.attachEvent(window, "onload", function() { window.open(url, target, features); });
}
SIGIObject.prototype.showModalDialog = function(url, vArguments, width, height, scroll) {
    var scrollValue = scroll ? scroll : "no";
    var sFeatures = "dialogHeight:" + height + "px; dialogWidth:" + width + "px;status: yes; scroll: " + scrollValue + "; help: no";
    var page = this.formatURL(url);
    return window.showModalDialog(page, vArguments, sFeatures);

}
SIGIObject.prototype.showModelessDialog = function(url, vArguments, width, height) {
    var sFeatures = "dialogHeight:" + height + "px; dialogWidth:" + width + "px;status: yes; scroll: no; help: no"
    var date = new Date();
    var page = this.formatURL(url);

    page = this.addQueryString(page, "dt=" + date.getTime());

    return window.showModelessDialog(page, vArguments, sFeatures);

    //return raiseOnDialogClose(url, ret);
}
SIGIObject.prototype.msgBox = function(messageText, buttons, title) {
    var sResponse;

    //var w = 300;
    //var h = 150;

    var w = 600;
    var h = 300;

    if (arguments.length > 3) {
        w = arguments[3];
        if (arguments.length > 4) {
            h = arguments[4];
        }
    }
    sResponse = this.showModalDialog(SIGI.getClientThemePath() + "/Pages/SIGI.Msgbox.htm", messageText + "|" + buttons + "|" + title, w, h);

    if (sResponse == null)
        sResponse = "cancel"

    return sResponse.toLowerCase();
}
SIGIObject.prototype.messageBox = SIGIObject.prototype.msgBox;
/*
SIGIObject.prototype.addQueryString = function (url, queryString) {
var testQueryString = queryString.encode().replace(/([\[\]\\\?\$\*\+\{\}\(\)])/g,"\\$1");
var regEx = new RegExp(testQueryString,"i");
if (regEx.test(url)) return url;
if (url.search(/\?/) == -1)
return url + "?" + queryString;
else
return url + "&" + queryString;
}
*/
SIGIObject.prototype.getValue = function(control, trim) {
    if (trim == null) trim = true;
    if (control) {
        if (typeof (control.value) == "string") {
            if (control.tagName.toLowerCase() == "dropdownlist") {
                if (control.value.length == 0) {
                    var text = control.text;
                    if (trim) text = text.trim();
                    if (text.toLowerCase() == control.emptySelectionText.toLowerCase()) {
                        text = "";
                    }
                    return text;
                }
            } else if (control.className.toLowerCase() == "maskededit") {
                var cliptext = $SIGIfind(control.id).get_text();
                return cliptext;
            } else if (control.className.toLowerCase() == "combobox") {
                if ($SIGIfind(control.id.toString().replace("_Text", "")).get_value() == $SIGIfind(control.id.toString().replace("_Text", "")).get_emptyOptionText())
                    return "";
                else
                    return $SIGIfind(control.id.toString().replace("_Text", "")).get_value();
            }

            if (trim)
                return control.value.trim();
            else
                return control.value;
        }
        if (typeof (control.tagName) == "undefined" && typeof (control.length) == "number") {
            var j;
            for (j = 0; j < control.length; j++) {
                var inner = control[j];
                if (typeof (inner.value) == "string" && (inner.type != "radio" || inner.status == true)) {
                    if (trim)
                        return inner.value.trim();
                    else
                        return inner.value;
                }
            }
        } else {
            return this.getValueRecursive(control, trim);
        }
        return "";
    }
}
SIGIObject.prototype.getValueRecursive = function(control, trim) {
    if (trim == null) trim = true;

    if (typeof (control.value) == "string" && (control.type != "radio" || control.status == true)) {
        if (trim)
            return control.value.trim();
        else
            return control.value;
    }
    var i, value;
    for (i = 0; i < control.childNodes.length; i++) {
        value = this.getValueRecursive(control.childNodes[i]);
        if (value != "") {
            if (trim)
                return value.trim();
            else
                return value;
        }
    }
    return "";
}
SIGIObject.prototype.getCurrentStyle = function(element, styleName) {
    var style = null;
    if (element.currentStyle) {
        if (/\-[a-z]/.test(styleName)) {
            styleName = styleName.replace(/\-([a-z])/gi, function(match) { return match.toUpperCase().replace("-", "") });
        }
        style = element.currentStyle[styleName];
    } else if (window.getComputedStyle) {
        if (/\[A-Z]/.test(styleName)) {
            styleName = styleName.replace(/\[A-Z]/g, function(match) { return "-" + match.toLowerCase() });
        }
        style = document.defaultView.getComputedStyle(element, null).getPropertyValue(styleName);
    }
    return style;
}
SIGIObject.prototype.addCssClass = function(element, className) {
    if (!this.hasCssClass(element, className)) {
        if (element.className.length > 0)
            element.className += " " + className;
        else
            element.className = className;
    }
}
SIGIObject.prototype.removeCssClass = function(element, className) {
    if (this.hasCssClass(element, className)) {
        element.className = element.className.replace(className, "").trim();
    }
}
SIGIObject.prototype.hasCssClass = function(element, className) {
    if (element && element.className) {
        var regEx = new RegExp(className, "i");
        return regEx.test(element.className);
    } else {
        return false;
    }
}
SIGIObject.prototype.hasChildren = function(element) {
    return (element && element.childNodes && element.childNodes.length > 0);
}
SIGIObject.prototype.isEditable = function(element) {
    if (element) {
        if (element.isContentEditable) return true;
        switch (element.tagName.toUpperCase()) {
            case "INPUT": case "TEXTAREA": case "DROPDOWNLIST":
                return true;
        }
    }
    return false;
}
SIGIObject.prototype.isChanged = function(element) {
    if (!element || !element.tagName) return false;

    switch (element.tagName) {
        case "FORM":
            if (this.Form) return this.Form.isFormChanged(element);
        default:
            if (element.type) {
                switch (element.type) {
                    case "hidden":
                        return false;
                    case "checkbox":
                    case "radio":
                        return (element.checked != element.defaultChecked);
                    case "select-one":
                        if (element.defaultIndex) return (element.selectedIndex != parseInt(element.defaultIndex))
                }
            }
            if (element.defaultValue != null) {
                var value = "";
                if (($SIGIfind(element.id)) && ($SIGIfind(element.id).get_textWithMask)) {
                    if ($SIGIfind(element.id).get_text().length > 0)
                        value = $SIGIfind(element.id).get_textWithMask();
                }
                else
                    value = this.getValue(element, false);
                return (value != null && value != element.defaultValue);
            }
    }
    return false;
}
SIGIObject.prototype.isFocusable = function(element) {
    if (element.tabIndex != null &&
		element.tabIndex > -1 &&
		element.disabled != null &&
		element.disabled == false &&
		this.getCurrentStyle(element, "visibility") != "hidden" &&
		this.getCurrentStyle(element, "display") != "none") {
        return true;
    } else {
        return false;
    }
}
SIGIObject.prototype.setFocus = function(element) {
    if (this.isFocusable(element)) {
        try {
            element.focus();
            return true;
        } catch (exc) {
            return false;
        }
    }
    return false;
}
SIGIObject.prototype.setNextFocus = function(startElement, stayInElement) {
    if (!startElement) return null;

    if (this.setFocus(startElement)) {
        return startElement;
    } else {
        var focusElement;
        if (this.hasChildren(startElement)) {
            focusElement = this.setNextFocus(startElement, stayInElement);
        }
        if (!focusElement && !stayInElement && startElement.nextSibling) {
            focusElement = this.setNextFocus(startElement.nextSibling, stayInElement);
        }
        return focusElement;
    }
}
SIGIObject.prototype.findChildOfTagName = function(srcElement, tagName) {
    if (srcElement == null || tagName == null) return null;

    if (this.hasChildren(srcElement)) {
        for (var i = 0; i < srcElement.childNodes.length; i++) {
            var child = srcElement.childNodes[i];
            if (child && child.tagName && child.tagName.toLowerCase() == tagName.toLowerCase()) {
                return child;
            } else if (this.hasChildren(child)) {
                child = this.findChildOfTagName(child, tagName);
                if (child) return child;
            }
        }
    }
}
SIGIObject.prototype.findParentOfTagName = function(srcElement, tagName) {
    if (srcElement == null || tagName == null) return null;

    while (srcElement.parentNode != null) {
        if (srcElement.tagName) {
            if (srcElement.tagName.toLowerCase() == tagName.toLowerCase()) {
                return srcElement;
            }
        } else {
            return null;
        }
        srcElement = srcElement.parentNode;
    }
}
SIGIObject.prototype.findChildOfClassName = function(srcElement, className) {
    if (srcElement == null || className == null) return null;

    if (this.hasChildren(srcElement)) {
        for (var i = 0; i < srcElement.childNodes.length; i++) {
            var child = srcElement.childNodes[i];
            if (SIGI.hasCssClass(child, className)) {
                return child;
            } else if (this.hasChildren(child)) {
                child = this.findChildOfClassName(child, className);
                if (child) return child;
            }
        }
    }
}
SIGIObject.prototype.findParentOfClassName = function(srcElement, className) {
    if (srcElement == null || className == null) return null;

    while (srcElement.parentNode != null) {
        if (SIGI.hasCssClass(srcElement)) {
            return srcElement;
        }
        srcElement = srcElement.parentNode;
    }
}
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;
}
SIGIObject.prototype.getIFrameDocument = function(frameId) {
    // if contentDocument exists, W3C compliant (Mozilla)
    if (document.getElementById(frameId).contentDocument) {
        return document.getElementById(frameId).contentDocument;
    } else {
        // IE
        return document.frames[frameId].document;
    }
}
SIGIObject.prototype.insertElement = function(target, element, where) {
    if (target && element) {
        switch (where) {
            case "before":
                if (target.insertAdjacentElement) {
                    target.insertAdjacentElement("beforeBegin", element)
                } else if (target.parentNode && target.parentNode.insertBefore) {
                    target.parentNode.insertBefore(element, target);
                } else {
                    throw ("Cannot insert element. Browser not supported");
                }
                break;
            case "after":
                if (target.insertAdjacentElement) {
                    target.insertAdjacentElement("afterEnd", element)
                } else if (target.parentNode && target.parentNode.insertBefore) {
                    if (target.nextSibling)
                        target.parentNode.insertBefore(element, target.nextSibling);
                    else
                        target.parentNode.appendChild(element);
                } else {
                    throw ("Cannot insert element. Browser not supported");
                }
                break;
            case "afterBegin":
                if (target.insertAdjacentElement) {
                    target.insertAdjacentElement("afterBegin", element)
                } else if (target.insertBefore) {
                    if (target.childNodes.length > 0 && target.childNodes[0] != null)
                        target.insertBefore(element, target.childNodes[0]);
                    else
                        target.appendChild(element);
                } else {
                    throw ("Cannot insert element. Browser not supported");
                }
            default:
                target.appendChild(element);
                break;
        }
    }

}
SIGIObject.prototype.watchProperty = function(element, propertyName, handler) {
    if (SIGI.Browser.isIE) {
        if (!element.__watchedProperties) element.__watchedProperties = new Array();
        var prop = new Object();
        prop.handling = false;
        prop.propertyName = propertyName;
        prop.oldValue = element[propertyName];
        prop.handler = handler;
        element.__watchedProperties.push(prop);
        element.attachEvent("onpropertychange", this.context(this._onelementpropertychange));
    } else if (element.watch) {
        element.watch(propertyName, handler);
    }
}
SIGIObject.prototype._onelementpropertychange = function() {
    var element = event.srcElement;
    if (element.__watchedProperties) {
        for (var i = 0; i < element.__watchedProperties.length; i++) {

            if (event.propertyName == element.__watchedProperties[i].propertyName && !element.__watchedProperties[i].handling) {
                element.__watchedProperties[i].handling = true;
                element[element.__watchedProperties[i].propertyName] = element.__watchedProperties[i].handler(element.__watchedProperties[i].propertyName, element.__watchedProperties[i].oldValue, element[event.propertyName], element);
                element.__watchedProperties[i].handling = false;
                return;
            }
        }
    }
}
SIGIObject.prototype.changeState = function(element, disabled) {
    if (!element || !element.tagName) return;

    var tagName = element.tagName.toLowerCase();
    var type = (element.type != null) ? element.type : null;


    if (element.onclick && !element.enabledOnClick) {
        element.enabledOnClick = element.onclick;
    }

    if (element.label) {
        if (typeof element.label == "string") {
            var label = document.getElementById(element.label);
            if (label)
                element.label = label
        }
        element.label.disabled = disabled;
    }
    //element.onclick = function() {if (this.disabled) return false; else if (this.enabledOnClick) return this.enabledOnClick();}

    switch (tagName) {
        case "input":
            switch (type) {
                case "text":
                    if (disabled) {
                        element.className = "TextBoxDisabled";
                    } else {
                        element.className = "TextBox";
                    }
                case "password":
                    if (disabled) {
                        SIGI.addCssClass(element, "DISABLEDINPUT");
                    } else {
                        SIGI.removeCssClass(element, "DISABLEDINPUT");
                    }
                default:
                    element.disabled = disabled;
            }
            return;
            break;
        case "textarea":
            if (disabled) {
                element.className = "TextBoxDisabled";
            } else {
                element.className = "MultLineTextBox";
            }
            element.disabled = disabled;
            return;
            break;
        case "a":
            if (disabled) {
                if (element.href) {
                    element.enabledHref = element.href;
                    element.href = "javascript: var i=0;"; // this is dumb, but I needed something completely innocuous;
                }
            } else {
                if (element.enabledHref) element.href = element.enabledHref;
            }
        default:
            if (this.hasChildren(element)) {
                for (var i = 0; i < element.childNodes.length; i++) {
                    this.changeState(element.childNodes[i], disabled);
                }
            }
            element.disabled = disabled;

    }
}
SIGIObject.prototype.disable = function(element) {
    this.changeState(element, true);
}
SIGIObject.prototype.enable = function(element) {
    this.changeState(element, false);
}
// Checks to see if a given keycode is allowed for a control
SIGIObject.prototype.isKeyCodeAllowed = function(element, keyCode) {
    var allowKeys = element.getAttribute("allowKeys");
    var ignoreKeys = element.getAttribute("ignoreKeys");
    var allow = true;

    // check if keyCode is in defined list of allowed keys
    if (allowKeys && allowKeys.length > 0) {
        allowKeys = "[" + allowKeys + "]";
        var sTest = String.fromCharCode(keyCode);
        var template = new RegExp(allowKeys, "g");
        allow = template.test(sTest);
    }
    // check if keyCode is in defined list of ignored keys
    if (ignoreKeys && ignoreKeys.length > 0) {
        ignoreKeys = "[" + ignoreKeys + "]";
        var sTest = String.fromCharCode(keyCode);
        var template = new RegExp(ignoreKeys, "g");
        allow = !template.test(sTest);
    }
    return allow;
}
/******************* Global Event handling *******************/
SIGIObject.prototype._onstatustext = function(e) {
    try {
        this.ieEvent(e);
        var statusText = null;
        var element = event.srcElement;

        while (element && !statusText && element != document.body) {
            statusText = element.getAttribute("statusText");
            if (!statusText) statusText = element.getAttribute("title");
            if (!statusText || statusText.length == 0) statusText = element.getAttribute("alt");
            element = element.parentNode;
        }

        if (statusText) {
            window.status = statusText;
            event.returnValue = true;
            return true;
        }
    } catch (ex) { }
}
SIGIObject.prototype._onclearstatustext = function(e) {
    this.ieEvent(e);
    window.status = window.defaultStatus;
    event.returnValue = true;
    return true;
}
// Handles the user pressing backspace to prevent
// the page from returning to the previous page.
SIGIObject.prototype._onkeydown = function(e) {
    this.ieEvent(e);
    var keyCode = event.keyCode;
    var element = event.srcElement;
    if (keyCode == 8 && !this.isEditable(element)) {
        event.keyCode = 0;
        event.returnValue = false
    }
}
// Handles case transformation on a given control
SIGIObject.prototype._onkeypress = function(e) {
    this.ieEvent(e);
    var element = event.srcElement;
    if (!this.isEditable(element)) return;

    var keyCode
    if (event.keyCode != 0)
        keyCode = event.keyCode;
    else
        keyCode = event.charCode;

    //alert(event.charCode);
    var inputCase = element.getAttribute("inputCase");
    if (inputCase == null) inputCase = this.inputCase;

    switch (inputCase.toLowerCase()) {
        case "casemixed":
            break;
        case "caselower":
            if (keyCode > 64 && keyCode < 91) {
                event.keyCode = keyCode + 32;
            }
            break;
        case "caseupper":
            if (keyCode > 96 && keyCode < 123) {
                event.keyCode = keyCode - 32;
            }
            break;
    }
    if (!this.isKeyCodeAllowed(element, keyCode)) {
        event.keyCode.value = 0;
        event.returnValue = false;
        if (event.preventDefault) event.preventDefault();
        if (event.stopPropagation) event.stopPropagation();
        return false;
    } else {
        return true;
    }
}


SIGIObject.prototype._oncontrolactivate = function(e) {
    this.ieEvent(e);
    if (this.isEditable(event.srcElement)) {
        try {
            // store the current background color
            event.srcElement.__backgroundColor = this.getCurrentStyle(event.srcElement, "background-color");
            // set background color to highlighted
            if (event.srcElement.type != "button")
                event.srcElement.style.backgroundColor = "#E2EFFF";
            // set controls case transformation
        } catch (ex) { }
    }
}
SIGIObject.prototype._oncontroldeactivate = function(e) {
    this.ieEvent(e);
    if (this.isEditable(event.srcElement)) {
        // restore the control's background color
        event.srcElement.style.backgroundColor = event.srcElement.__backgroundColor;
    }
}
SIGIObject.prototype._ontextboxkeydown = function(e) {
    this.ieEvent(e);
    if (event.srcElement.maxLength && event.srcElement.maxLength > -1 && event.srcElement.value.length >= event.srcElement.maxLength) {
        var allow = new Array(8, 9, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46);
        if (event.ctrlKey == false && allow.find(event.keyCode) == -1) {
            event.returnValue = false;
            event.keyCode = 0;
        }
    }
}
SIGIObject.prototype._ontextboxbeforepaste = function(e) {
    this.ieEvent(e);
    if (event.srcElement.maxLength && event.srcElement.maxLength > -1) {
        var pasteText = window.clipboardData.getData("Text");
        if ((event.srcElement.value.length + pasteText.length) > event.srcElement.maxLength) {
            event.returnValue = false;
        }
    }
}
SIGIObject.prototype._ontextboxpaste = function(e) {
    this.ieEvent(e);
    if (event.srcElement.maxLength && event.srcElement.maxLength > -1) {
        var pasteText = window.clipboardData.getData("Text");
        if ((event.srcElement.value.length + pasteText.length) > event.srcElement.maxLength) {
            event.returnValue = false;
        }
    }
}
SIGIObject.prototype._oncontextmenu = function(e) {
    this.ieEvent(e);
    if (event.altKey == true && event.ctrlKey == true) {
        return true;
    }
    try {
        if (this.allowContextMenu != true && !((event.srcElement.tagName == "INPUT" && event.srcElement.type == "text") || event.srcElement.tagName == "TEXTAREA")) {
            event.returnValue = false;
        }
    } catch (exc) {
        event.returnValue = false;
    }
}
SIGIObject.prototype._onreadystatechange = function(e) {
    this.ieEvent(e);
    try {
        if (document.getElementById("SIGI_Transition")) {
            this.transitionFrame = document.getElementById("SIGI_Transition");
            this.transitionDocument = SIGI.getIFrameDocument("SIGI_Transition");
            this.transitionDocument.body.style.cursor = "wait";
        }

        if (document.getElementById("SIGI_ProgressScreen")) {

            this.progressFrame = document.getElementById("SIGI_ProgressScreen");
            this.progressFrame.ProgressBar = SIGI.getIFrameDocument("SIGI_ProgressScreen");

            this.progressFrame.ProgressBar.Icon = this.progressFrame.ProgressBar.getElementById("icon");
            this.progressFrame.ProgressBar.Message = this.progressFrame.ProgressBar.getElementById("txtMessage");
            this.progressFrame.ProgressBar.ToolTip = this.progressFrame.ProgressBar.getElementById("ToolTip");
            this.progressFrame.ProgressBar.WaitScreen = this.progressFrame.ProgressBar.getElementById("WaitScreen");
            this.progressFrame.ProgressBar.WaitMsg = this.progressFrame.ProgressBar.getElementById("WaitMsg");

            this.progressFrame.ProgressBar.startProgress = window.frames["SIGI_ProgressScreen"].start_Progress;
            this.progressFrame.ProgressBar.stopProgress = window.frames["SIGI_ProgressScreen"].stop_Progress;
            this.progressFrame.ProgressBar.showProgress = window.frames["SIGI_ProgressScreen"].set_Progress;
            this.progressFrame.ProgressBar.body.style.cursor = "wait";
        }

    } catch (ex) { }

    if ((this.Browser.isIE && document.readyState == "complete") || !this.Browser.isIE) {
        this.hidePageTransition();
        this.hideProgressBar();
    }

}
SIGIObject.prototype._AJAXpageLoaded = function() {

    this.hidePageTransition();
    this.hideProgressBar();
    
    //reset the cursor for the document body - needed for ajax postback
    window.document.body.style.cursor = " "
    window.document.body.style.cursor = this._bodyCursor

}

SIGIObject.prototype.setTextBoxMaxLength = function(textbox, maxLength, maxLengthError) {
    textbox.maxLength = maxLength;
    this.attachEvent(textbox, "onkeydown", this.context(this._ontextboxkeydown));
    this.attachEvent(textbox, "onbeforepaste", this.context(this._ontextboxbeforepaste));
    this.attachEvent(textbox, "onpaste", this.context(this._ontextboxpaste));
    textbox.maxLengthError = maxLengthError;
}
SIGIObject.prototype._setForm = function(form) {
    if (form && SIGI.FormObject) {
        this.Form = new SIGI.FormObject(form);
        this.instanceId = this.Form.InstanceID;
    }
}
SIGIObject.prototype._attachEvents = function() {
    if (!this.Browser.isIE) {
        this.attachEvent(window, "onload", this.context(this._onreadystatechange));
    } else {
        this.attachEvent(document, "onreadystatechange", this.context(this._onreadystatechange));
    }
    this.attachEvent(document.body, "onmouseover", this.context(this._onstatustext));
    this.attachEvent(document.body, "onmouseout", this.context(this._onclearstatustext));
    this.attachEvent(document.body, "onactivate", this.context(this._onstatustext));
    this.attachEvent(document.body, "ondeactivate", this.context(this._onclearstatustext));
    this.attachEvent(document.body, "onactivate", this.context(this._oncontrolactivate));
    this.attachEvent(document.body, "ondeactivate", this.context(this._oncontroldeactivate));
    this.attachEvent(document.body, "onkeypress", this.context(this._onkeypress));
    if (this.preventBackspace) this.attachEvent(document.body, "onkeydown", this.context(this._onkeydown));
    if (!this.allowContextMenu) this.attachEvent(document.body, "oncontextmenu", this.context(this._oncontextmenu));
}
SIGIObject.prototype.init = function(mainForm, clientPath) {
    if (clientPath) this.clientPath = clientPath;
    SIGI._setForm(mainForm);
    if (SIGI.CallbackObject) SIGI.Callback = new SIGI.CallbackObject();
    // Added for compatibility with ASP.net validators;
    if (SIGI.Validation) Page_ClientValidate = function() { return SIGI.Validation.Validate(true); };
    this._attachEvents();

    //set default callback function
    SIGI.callServer = function() { throw ("Callback must be defined server-side using SIGI.Web.UI.Page.RegisterPageCallback"); };

    if (!(typeof(Sys) == "undefined" )){
        this._AJAXenabled = true;
    }

    if (this._AJAXenabled) {
        Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(this.context(this._AJAXpageLoaded));
    }

}
SIGI = new SIGIObject();
Base = null;

// 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));
}
SIGI.Browser = new BrowserObject();
/*****************************************************************/
/*		SIGI.DateTimeObject
/*		Accessible as SIGI.DateTime
/****************************************************************/
function DateTimeObject() { }
DateTimeObject.inherits(SIGI.Base);

DateTimeObject.prototype.getDate = function(date) {
    var oDate;
    if (typeof (date) == "object") {
        if (date instanceof Date) {
            return date;
        }
        else {
            if (date instanceof String) {
                oDate = this.parseDate(date.toString());
            }
            else {
                try {
                    if (date.className.toLowerCase() == "date") {
                        oDate = date.date;
                    }
                    else {
                        oDate = this.parseDate(date.value);
                    }
                }
                catch (exc) {
                    try {
                        oDate = new Date(date);
                    } catch (exc2) {
                        return null;
                    }
                }
            }
        }
    }
    else {
        oDate = this.parseDate(date);
    }

    if (oDate == null || isNaN(oDate)) {
        return null;
    }
    return oDate;
}

DateTimeObject.prototype.parseDate = function(date) {
    var oDate = null;
    var sDate = window.trim(date.toString());
    var sMonth = '';
    var sDay = '';
    var sYear = '';

    try {
        oDate = Date.parse(sDate);
        if (!(oDate == null || isNaN(oDate))) return new Date(oDate);
    } catch (ex) { }

    if (/^\d{6}|\d{8}$/.test(sDate)) {
        sMonth = sDate.slice(0, 2);
        sDay = sDate.slice(2, 4);
        sYear = sDate.slice(4);
    } else if (new RegExp("^\d{1,2}[/.-]\d{1,2}[/.-](\d{2}|\d{4})$").test(sDate)) {
        var aDate;
        aDate = sDate.split(new RegExp("[/.-]"));
        if (aDate.length == 3) {
            sMonth = aDate[0];
            sDay = aDate[1];
            sYear = aDate[2];
        }
    } else {
        oDate = new Date(date);
        if (isNaN(oDate)) {
            return null;
        } else {
            return oDate;
        }
    }
    if (sYear.length == 2) sYear = this.fullYear(sYear);
    oDate = new Date(sYear, sMonth - 1, sDay);
    var tmpStrDate = this.fixDigits(sMonth, 2) + this.fixDigits(sDay, 2) + this.fixDigits(sYear, 4)
    if (this.formatDate(oDate, "mmddyyyy") == tmpStrDate)
        return oDate;

    return null;
}

DateTimeObject.prototype.fullYear = function(year) {
    if (year.length == 2) {
        if (year > 60)
            year = "19" + year;
        else
            year = "20" + year;
    }
    else {
        if (year.length > 4)
            year = 0;
    }
    return year;
}

DateTimeObject.prototype.isValidDate = function(date) {
    var oDate = this.getDate(date);
    return (oDate != null);
}

DateTimeObject.prototype.dateDiff = function(interval, date1, date2) {
    var datea = this.getDate(date1);
    var dateb = this.getDate(date2);

    if (datea == null || dateb == null) {
        return 0;
    }

    var diff = datea.getTime() - dateb.getTime();
    var result = 0;

    switch (interval) {
        case "m":
            result = Math.round(diff / (1000 * 60 * 60 * 24 * 30));
            break;
        case "y":
            result = Math.round(diff / (1000 * 60 * 60 * 24 * 365));
            break;
        default:
            result = Math.round(diff / (1000 * 60 * 60 * 24));
            break;
    }
    return result;
}

DateTimeObject.prototype.dateAdd = function(interval, number, date) {
    var oDate = this.getDate(date);
    if (oDate == null) {
        return null;
    }

    var m = oDate.getMonth();
    var d = oDate.getDate();
    var y = oDate.getFullYear();

    switch (interval) {
        case "m":
            m = m + number;
            break;
        case "d":
            d = d + number;
            break;
        case "y":
            y = y + number;
    }

    var dt = new Date(y, m, d);
    return dt;
}

DateTimeObject.prototype.getMonthText = function(date) {
    var oDate = this.getDate(date)
    var abbr = false;
    if (arguments.length > 1)
        abbr = arguments[1];

    var sMonthName = ""
    var sMonthAbbr = "";

    switch (oDate.getMonth()) {
        case 0:
            sMonthName = "January";
            sMonthAbbr = "Jan";
            break;
        case 1:
            sMonthName = "February";
            sMonthAbbr = "Feb";
            break;
        case 2:
            sMonthName = "March";
            sMonthAbbr = "Mar";
            break;
        case 3:
            sMonthName = "April";
            sMonthAbbr = "Apr";
            break;
        case 4:
            sMonthName = "May";
            sMonthAbbr = "May";
            break;
        case 5:
            sMonthName = "June";
            sMonthAbbr = "Jun";
            break;
        case 6:
            sMonthName = "July";
            sMonthAbbr = "Jul";
            break;
        case 7:
            sMonthName = "August";
            sMonthAbbr = "Aug";
            break;
        case 8:
            sMonthName = "September";
            sMonthAbbr = "Sep";
            break;
        case 9:
            sMonthName = "October";
            sMonthAbbr = "Oct";
            break;
        case 10:
            sMonthName = "November";
            sMonthAbbr = "Nov";
            break;
        case 11:
            sMonthName = "December";
            sMonthAbbr = "Dec";
            break;
    }
    if (abbr == true)
        return sMonthAbbr;
    else
        return sMonthName;
}

DateTimeObject.prototype.getDayText = function(date) {
    var oDate = this.getDate(date);
    var abbr = false;
    if (arguments.length > 1)
        abbr = arguments[1];

    var sDayAbbr = "";
    var sDayName = "";

    switch (oDate.getDay()) {
        case 0:
            sDayName = "Sunday";
            sDayAbbr = "Sun";
            break;
        case 1:
            sDayName = "Monday";
            sDayAbbr = "Mon";
            break;
        case 2:
            sDayName = "Tuesday";
            sDayAbbr = "Tue";
            break;
        case 3:
            sDayName = "Wednesday";
            sDayAbbr = "Wed";
            break;
        case 4:
            sDayName = "Thursday";
            sDayAbbr = "Thu";
            break;
        case 5:
            sDayName = "Friday";
            sDayAbbr = "Fri";
            break;
        case 6:
            sDayName = "Saturday";
            sDayAbbr = "Sat";
            break;
    }
    if (abbr == true)
        return sDayAbbr;
    else
        return sDayName;

}

DateTimeObject.prototype.formatDate = function(date, format) {
    try {
        var oDate = this.getDate(date);
        if (oDate == null) return "";
    }
    catch (exc) {
        return "";
    }

    var month = /m+/g;
    var day = /d+/g;
    var Day = /D+/g;
    var year = /y+/g;

    var monthArr = month.exec(format);
    var dayArr = day.exec(format);
    var DayArr = Day.exec(format);
    var yearArr = year.exec(format);

    var iMonth = oDate.getMonth() + 1;
    var iday = oDate.getDate();
    var iDay = oDate.getDay();
    var iYear = oDate.getFullYear();

    var sReturn = "";

    var sMonth = iMonth.toString();
    if (monthArr != null) {
        switch (monthArr[0].length) {
            case 2:
                var sMonth2 = "0" + sMonth;
                sMonth = sMonth2.slice(sMonth2.length - 2)
                break;
            case 3:
                sMonth = this.getMonthText(oDate, true);
                break;
            case 4:
                sMonth = this.getMonthText(oDate);
                break;
        }
    }


    var sday = iday.toString();
    if (dayArr != null) {
        if (dayArr[0].length > 1) {
            var sday2 = "0" + sday;
            sday = sday2.slice(sday2.length - 2);
        }
    }

    var sDay = "";
    if (DayArr != null) {
        sDay = this.getDayText(oDate, !(DayArr[0].length == 4));
    }

    var sYear = iYear.toString();
    if (yearArr != null) {
        if (yearArr[0].length < 5) {
            sYear = sYear.slice(sYear.length - yearArr[0].length);
        }
    }

    format = format.replace(/y+/gi, sYear);
    format = format.replace(/d+/g, sday);
    format = format.replace(/D+/g, sDay);
    format = format.replace(/m+/g, sMonth);

    return format;
}

DateTimeObject.prototype.fixDigits = function(value, digits) {
    if (typeof (value) == "undefined")
        return "";

    if (value.length == 0)
        return "";

    var sDigits = new String("0");
    while (sDigits.length < digits) {
        sDigits = sDigits.concat("0");
    }
    value = sDigits.concat(value);
    value = value.slice(value.length - (digits));
    return value;
}

DateTimeObject.prototype.now = function() {
    return new Date();
}

DateTimeObject.prototype.grgJul = function(date) {

    var result = 0;

    var lOutDate = 0;
    var lDays = new Array();
    var lGrgConvert = 0;
    var lGrgIntermediate = 0;
    var lYearr = 0;
    var lTestYear = 0;
    var lJulianConvert = 0;
    var lTestMonth = 0;
    var lMonth = 0;
    var lDayy = 0;

    lDays[1] = 0;
    lDays[2] = 31;
    lDays[3] = 59;
    lDays[4] = 90;
    lDays[5] = 120;
    lDays[6] = 151;
    lDays[7] = 181;
    lDays[8] = 212;
    lDays[9] = 243;
    lDays[10] = 273;
    lDays[11] = 304;
    lDays[12] = 334;

    lOutDate = 0;
    lGrgConvert = toNumber(date);

    lGrgIntermediate = Math.floor(lGrgConvert / 100);
    lGrgIntermediate = lGrgIntermediate * 100;

    lYearr = (lGrgConvert - lGrgIntermediate);
    lTestYear = Math.floor(lYearr / 4);
    lTestYear = (lTestYear * 4);

    lJulianConvert = lYearr * 1000;
    lYearr = lYearr - lTestYear;
    lMonth = Math.floor(lGrgConvert / 10000);
    lJulianConvert = lJulianConvert + lDays[lMonth];

    lTestMonth = lMonth * 10000;
    lGrgIntermediate = lGrgConvert - lTestMonth;
    lDayy = Math.floor(lGrgIntermediate / 100);
    lJulianConvert = lJulianConvert + lDayy;

    lOutDate = lJulianConvert;
    result = lJulianConvert;
    if (Math.floor(lOutDate / 1000) <= 50) {  //(YEAR 2000)
        result = lOutDate + 100000;
    }

    if (result == 100000) {  // IF DATE PASSED IS 0
        result = 0;           // DON'T ADD
    }
    return result;
}

DateTimeObject.prototype.isLeapYear = function(year) {
    return ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0);
}

DateTimeObject.prototype.daysInMonth = function(month, year) {
    if (month == 2) return this.isLeapYear(year) ? 29 : 28;
    else if (month == 9 || month == 4 || month == 6 || month == 11) return 30;
    else return 31;
}
SIGI.DateTimeObject = DateTimeObject;
DateTimeObject = null;
SIGI.DateTime = new SIGI.DateTimeObject();

function ConvertObject() {
    this.Base();
}
ConvertObject.inherits(SIGI.Base);
ConvertObject.prototype.toString = function(value) {
    return value.toString();
}
ConvertObject.prototype.toBoolean = function(value) {
    return value.toString().toBoolean();
}
ConvertObject.prototype.toNumber = function(value) {
    return value.toString.toNumber();
}
ConvertObject.prototype.toInteger = function(value) {
    return parseInt(value.toString().toNumber().toString());
}
ConvertObject.prototype.toDate = function(value) {
    return SIGI.DateTime.getDate(value);
}
SIGI.ConvertObject = ConvertObject;
ConvertObject = null;

SIGI.Convert = new SIGI.ConvertObject();


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;


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();


function CollectionObject() {
    this.Base();
    this.length = 0;
    this.onadd = new Function();
    this.onremove = new Function();
}
CollectionObject.inherits(SIGI.Base);

CollectionObject.prototype.add = function(item) {
    if (item == null) return;
    var index = this.length;
    this.length++;
    this[index] = item;
    this.onadd(item, index);
    return item;
}

CollectionObject.prototype.remove = function(index) {
    if (index < 0 || index > this.length - 1) return;
    var item = this[index];
    this.onremove(item, index);
    this[index] = null;
    for (var i = index; i <= this.length; i++)
        this[i] = this[i + 1];
    this.length--;
    return item;
}

CollectionObject.prototype.isEmpty = function() {
    return this.length == 0;
}
CollectionObject.prototype.count = function() {
    return this.length;
}
CollectionObject.prototype.clear = function() {
    for (var i = 0; i < this.length; i++)
        this[i] = null;
    this.length = 0;
}
CollectionObject.prototype.clone = function() {
    var c = new SIGI.CollectionObject();
    for (var i = 0; i < this.length; i++)
        c.add(this[i]);
    return c;
}
CollectionObject.prototype.indexOf = function(item) {
    for (var i = 0; i < this.length; i++) {
        if (this[i] == item)
            return i;
    }
    return -1;
}
CollectionObject.prototype.push = function(item) {
    return this.add(item);
}
CollectionObject.prototype.pop = function() {
    return this.remove(this.length - 1);
}
SIGI.CollectionObject = CollectionObject;
CollectionObject = null;

/*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.Type
function _SIGI_TypeClass() {
}

_SIGI_TypeClass.prototype.registerClass = function(typeName, baseType, interfaceTypes) {

    if (baseType) {
        typeName.inherits(baseType);
    }

}
SIGI.Type = _SIGI_TypeClass;


// == SIGI.Application Class ==
function _SIGIApplicationClass() {
    this._components = Array();

}

_SIGIApplicationClass.prototype.addComponent = function(component) {

    var id = component.get_id();
    this._components[id] = component;
}

_SIGIApplicationClass.prototype.findComponent = function(componentId) {

    var component = this._components[componentId];
    return component;
}

SIGI.Application = new _SIGIApplicationClass();
var $SIGIfind = function() { return SIGI.Application.findComponent.apply(SIGI.Application, arguments); }

// == SIGI.EventHandlerList Class ==
function _SIGI_EventHandlerListClass() {

    this._eventsArray = Array();

}

_SIGI_EventHandlerListClass.prototype.addHandler = function(eventName, handler) {


    this._eventsArray[eventName] = handler;

}

_SIGI_EventHandlerListClass.prototype.getHandler = function(eventName) {


    return this._eventsArray[eventName];

}

_SIGI_EventHandlerListClass.prototype.removeHandler = function(eventName, handler) {

    //TODO:
}

SIGI.EventHandlerList = _SIGI_EventHandlerListClass;


// == SIGI.Component Class ==
function _SIGIComponentClass() {
    this._id = null;
    this._events = null;
}

_SIGIComponentClass.inherits(SIGI.Type);

_SIGIComponentClass.prototype.get_id = function() {
    return this._id;
}

_SIGIComponentClass.prototype.set_id = function(id) {
    this._id = id;
}

_SIGIComponentClass.prototype.get_events = function() {
    return this._events;
}

_SIGIComponentClass.prototype.create = function(type, properties, events, references, element) {

    var newComp = new type;
    // todo: call component constructor

    // todo: if SIGI.UI.Control
    newComp.set_element(element);

    newComp.set_id(element.id);

    //TODO: move to Component Class contructor once base initialize is working
    newComp._events = new SIGI.EventHandlerList();
    this._eventsArray = Array();

    newComp.initialize();

    // register component with SIGI.Application
    SIGI.Application.addComponent(newComp);

    return newComp;
}

_SIGIComponentClass.prototype.context = function(method) {
    var self = this;
    return function() { return method.apply(self, arguments) };
};

SIGI.Component = new _SIGIComponentClass();
//$SIGIcreate = SIGI.Component.create;
var $SIGIcreate = function() { return SIGI.Component.create.apply(SIGI.Component, arguments); }


// == 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.get_element = function() {
    return this._element;
}

_SIGI_UI_ControlClass.prototype.set_element = function(element) {
    this._element = element;
}

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;





