function notImplementedFunction()
{
	alert("Not Implemented");
}

var JsUtility = {};

JsUtility.Browser = {};

JsUtility.Browser.InternetExplorer = {};
JsUtility.Browser.Firefox = {};
JsUtility.Browser.Safari = {};
JsUtility.Browser.Opera = {};
JsUtility.Browser.agent = null;
JsUtility.Browser.name = navigator.appName;
JsUtility.Browser.version = parseFloat(navigator.appVersion);

if (navigator.userAgent.indexOf(' MSIE ') > -1) 
{
    JsUtility.Browser.agent = JsUtility.Browser.InternetExplorer;
    JsUtility.Browser.version = parseFloat(navigator.userAgent.match(/MSIE (\d+\.\d+)/)[1]);
}
else if (navigator.userAgent.indexOf(' Firefox/') > -1) 
{
    JsUtility.Browser.agent = JsUtility.Browser.Firefox;
    JsUtility.Browser.version = parseFloat(navigator.userAgent.match(/ Firefox\/(\d+\.\d+)/)[1]);
    JsUtility.Browser.name = 'Firefox';
}
else if (navigator.userAgent.indexOf(' Safari/') > -1) 
{
    JsUtility.Browser.agent = JsUtility.Browser.Safari;
    JsUtility.Browser.version = parseFloat(navigator.userAgent.match(/ Safari\/(\d+\.\d+)/)[1]);
    JsUtility.Browser.name = 'Safari';
}
else if (navigator.userAgent.indexOf('Opera/') > -1) 
{
    JsUtility.Browser.agent = JsUtility.Browser.Opera;
}

JsUtility.init= function()
{
    this.backCompat;
    this.m_accidentalEnterKey = false;
    
    this.defineKeyCodes();
    this.Digits = "0123456789";
    this.AlphaNumeric = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
    this.SpecialMessageIdentifier = "#!#";
    
    this.EventsCache = new Array();
    this.ObjectsToBeDeleted = new Array();
    this.ControlsById = new Array();
    this.ControlsByObjectId = new Array();
}
JsUtility.inherit = function(descendant, base)
{
	function copyProtoType(){}
		
	copyProtoType.prototype = base.prototype;
	
	descendant.prototype = new copyProtoType();
	descendant.prototype.constructor = descendant;
	
	descendant.baseConstructor = base;
	descendant.base = base.prototype;
};

JsUtility.createDelegate = function(instance, method) 
{
    return function() 
    {
        return method.apply(instance, arguments);
    }
}

JsUtility.isBackCompat = function()
{
    if(this.backCompat == null)
        this.backCompat = (document.compatMode && document.compatMode != "BackCompat") ? false : true;
    
    return this.backCompat;
};

JsUtility.getSessionHashCode= function()
{
    if(typeof(SessionHashCode) == "undefined")
        return "";
    
    return SessionHashCode;
}

JsUtility.attachEvent = function(element, eventName, handler, capture)
{
    try
    {
		if(typeof(element) == "string")
			element = document.getElementById(element);
		
	    if(element.addEventListener)
		    element.addEventListener(eventName, handler, capture);
	    else element.attachEvent('on' + eventName, handler);
    	
	    this.EventsCache[this.EventsCache.length] = new Array(element, eventName, handler, capture ? capture : true);
	}
	catch(e){}
	
};

JsUtility.detachEvent = function(element, eventName, handler, capture)
{
	if(typeof(element) == "string")
		element = document.getElementById(element);
		
	if(element.removeEventListener)
		element.removeEventListener(eventName, handler, capture);
	else element.detachEvent('on' + eventName, handler);
};


JsUtility.cleanupEventsCache= function()
{
    try
    {
        for(var i = this.EventsCache.length - 1; i >= 0; i--)
        {
            this.detachEvent(this.EventsCache[i][0], this.EventsCache[i][1], this.EventsCache[i][2], this.EventsCache[i][3]);
            this.EventsCache[i] = null;
        }
        
        this.EventsCache = null;
    }
    catch(e){}
};
JsUtility.deleteMeOnUnload= function(obj)
{
	this.ObjectsToBeDeleted.push(obj);
}
JsUtility.deleteObjects= function(obj)
{
	while(this.ObjectsToBeDeleted.length > 0)
	{
		var _obj = this.ObjectsToBeDeleted.pop();
		
		if(_obj && _obj != null)
		{
			if(_obj.dispose)
				_obj.dispose();
		}
	}
}
JsUtility.getEventTarget = function(e)
{
	if(!e)
		e = window.event;
	if(e)
		return document.all ? e.srcElement : e.target;
	else return null;
};
JsUtility.getRealEventTarget = function(e, eventSrcId)
{
	if(!e)
		e = window.event;
	
	if(e)
	{
		var _eventTarget = document.all ? e.srcElement : e.target;
		
		while(typeof(_eventTarget) != "undefined" && _eventTarget != null)
		{
			if(_eventTarget[eventSrcId])
				return _eventTarget;
			
			_eventTarget = _eventTarget.parentNode ? _eventTarget.parentNode : _eventTarget.parentElement;
		}
	}
	
	return null;
};
JsUtility.stopPropagation = function(e)
{
	if(!e)
	    e = window.event;
	
	if(e)
	{  
		e.cancelBubble = true;
		if(e.stopPropagation)
			e.stopPropagation();
	}
};

JsUtility.preventDefault = function(e)
{
	if(typeof(e) == "undefined")
	    e = event ? event : window.event;

	if(e)
	{
	    if(typeof(e.cancelBubble) != "undefined")
	        e.cancelBubble = true;

		if(typeof(e.stopPropagation) != "undefined")
			e.stopPropagation();

		if(typeof(e.preventDefault) != "undefined")
			e.preventDefault();
	}
};

JsUtility.getCurrentStyle= function(element) 
{
    var _view = (element.ownerDocument ? element.ownerDocument : element.documentElement).defaultView;
    
    if(_view && element !== _view && _view.getComputedStyle)
        return _view.getComputedStyle(element, null);
    else if(element.currentStyle)
        return element.currentStyle;
    else return element.style;
}
JsUtility.getStyleProperty= function(style, property)
{
    if(style.getPropertyValue)
        return style.getPropertyValue(property);
    else if(style.getAttribute)
        return style.getAttribute(property);
    
    return style[property];
}
JsUtility.getRootOwner= function(element)
{
    if(this.isBackCompat())
    {
        if(element)
            return element.ownerDocument.body;
        else return document.body;
    }
    else
    {
        if(element)
            return element.ownerDocument.documentElement;
        else return document.documentElement;
    }
}

switch(JsUtility.Browser.agent) {
    case JsUtility.Browser.InternetExplorer:
        JsUtility.getElementPosition = function JsUtility$getElementPosition(element)
        {
            // For a document element, return zero.
            if (element.self || element.nodeType === 9) 
                return {x:0, y:0};
            
            // Here there is a small inconsistency with what other browsers would give for wrapping elements:
            // the bounding rect can be different from the first rectangle. getBoundingRect is used here
            // because it's more consistent and because clientRects need to be offset by the coordinates
            // of the frame in the parent window, which is not always accessible to script (if it's in a different
            // domain in particular).
            var clientRect = element.getBoundingClientRect();
            if (!clientRect) 
                return {x:0, y:0};
            
            
            var documentElement = JsUtility.isBackCompat() ? element.ownerDocument.body : element.ownerDocument.documentElement;
            
            // Substracting 2px for the border of the viewport. This can be changed in IE6 by applyting a border
            // to the HTML element but this is not supported by Atlas. It cannot be changed in IE7.
            var offsetX = clientRect.left - 2 + documentElement.scrollLeft,
                offsetY = clientRect.top - 2 + documentElement.scrollTop;
            
            // When the window is an iframe, the frameborder needs to be added. This is only available from
            // script when the parent window is in the same domain as the frame, hence the try/catch.
            try 
            {
                var f = element.ownerDocument.parentWindow.frameElement || null;
                if (f) 
                {
                    // frameBorder has a default of "1" so undefined must map to 0, and "0" and "no" to 2.
                    var offset = (f.frameBorder === "0" || f.frameBorder === "no") ? 2 : 0;
                    offsetX += offset;
                    offsetY += offset;
                }
            }
            catch(ex) {}    
            
            return {x: offsetX, y: offsetY};
        }
        break;
    case JsUtility.Browser.Safari:
        JsUtility.getElementPosition = function JsUtility$getElementPosition(element)
        {
            if ((element.window && (element.window === element)) || element.nodeType === 9) 
                return {x:0, y:0};

            var offsetX = 0;
            var offsetY = 0;

            var previous = null;
            var previousStyle = null;
            var currentStyle;
            for (var parent = element; parent; previous = parent, previousStyle = currentStyle, parent = parent.offsetParent) 
            {
                currentStyle = JsUtility.getCurrentStyle(parent);
                var tagName = parent.tagName;

                if ((parent.offsetLeft || parent.offsetTop) && ((tagName !== "BODY") || (!previousStyle || previousStyle.position !== "absolute"))) 
                {
                    offsetX += parent.offsetLeft;
                    offsetY += parent.offsetTop;
                }
            }

            currentStyle = JsUtility.getCurrentStyle(element);
            var elementPosition = currentStyle ? currentStyle.position : null;
            var elementPositioned = elementPosition && (elementPosition !== "static");
            if (!elementPosition || (elementPosition !== "absolute"))
            {
                for (var parent = element.parentNode; parent; parent = parent.parentNode) 
                {
                    tagName = parent.tagName;

                    if ((tagName !== "BODY") && (tagName !== "HTML") && (parent.scrollLeft || parent.scrollTop)) 
                    {
                        offsetX -= (parent.scrollLeft || 0);
                        offsetY -= (parent.scrollTop || 0);
                    }
                    
                    currentStyle = JsUtility.getCurrentStyle(parent);
                    var parentPosition = currentStyle ? currentStyle.position : null;

                    if (parentPosition && (parentPosition === "absolute")) 
                        break;
                }
            }

            return {x: offsetX, y: offsetY};
        }
        break;
    case JsUtility.Browser.Opera:
        JsUtility.getElementPosition = function JsUtility$getElementPosition(element)
        {

            if ((element.window && (element.window === element)) || element.nodeType === 9) 
                return {x:0, y:0};

            var offsetX = 0;
            var offsetY = 0;

            var previous = null;
            for (var parent = element; parent; previous = parent, parent = parent.offsetParent) 
            {
                var tagName = parent.tagName;

                offsetX += parent.offsetLeft || 0;
                offsetY += parent.offsetTop || 0;
            }

            var elementPosition = element.style.position;
            var elementPositioned = elementPosition && (elementPosition !== "static");

            for (var parent = element.parentNode; parent; parent = parent.parentNode) 
            {
                tagName = parent.tagName;

                if ((tagName !== "BODY") && (tagName !== "HTML") && (parent.scrollLeft || parent.scrollTop) &&
                    ((elementPositioned &&
                    ((parent.style.overflow === "scroll") || (parent.style.overflow === "auto"))))) 
                {
                                        
                    offsetX -= (parent.scrollLeft || 0);
                    offsetY -= (parent.scrollTop || 0);
                }
                
                var parentPosition = (parent && parent.style) ? parent.style.position : null;

                elementPositioned = elementPositioned || (parentPosition && (parentPosition !== "static"));
            }

            return {x: offsetX, y: offsetY};
        }
        break;
    default:
        JsUtility.getElementPosition = function JsUtility$getElementPosition(element)
        {
            if ((element.window && (element.window === element)) || element.nodeType === 9)
                return {x:0, y:0};

            var offsetX = 0;
            var offsetY = 0;
            var previous = null;
            var previousStyle = null;
            var currentStyle = null;
            
            for (var parent = element; parent; previous = parent, previousStyle = currentStyle, parent = parent.offsetParent) 
            {
                var tagName = parent.tagName;
                currentStyle = JsUtility.getCurrentStyle(parent);

                if ((parent.offsetLeft || parent.offsetTop) &&
                    !((tagName === "BODY") &&
                    (!previousStyle || previousStyle.position !== "absolute"))) 
                {

                    offsetX += parent.offsetLeft;
                    offsetY += parent.offsetTop;
                }

                if (previous !== null && currentStyle)
                {
                    if ((tagName !== "TABLE") && (tagName !== "TD") && (tagName !== "HTML")) 
                    {
                        offsetX += parseInt(currentStyle.borderLeftWidth) || 0;
                        offsetY += parseInt(currentStyle.borderTopWidth) || 0;
                    }
                    
                    if (tagName === "TABLE" &&
                        (currentStyle.position === "relative" || currentStyle.position === "absolute")) 
                    {
                        offsetX += parseInt(currentStyle.marginLeft) || 0;
                        offsetY += parseInt(currentStyle.marginTop) || 0;
                    }
                }
            }

            currentStyle = JsUtility.getCurrentStyle(element);
            var elementPosition = currentStyle ? currentStyle.position : null;
            var elementPositioned = elementPosition && (elementPosition !== "static");
            if (!elementPosition || (elementPosition !== "absolute"))
            {
                for (var parent = element.parentNode; parent; parent = parent.parentNode) 
                {
                    tagName = parent.tagName;

                    if ((tagName !== "BODY") && (tagName !== "HTML") && (parent.scrollLeft || parent.scrollTop)) 
                    {
                        offsetX -= (parent.scrollLeft || 0);
                        offsetY -= (parent.scrollTop || 0);

                        currentStyle = JsUtility.getCurrentStyle(parent);
                        offsetX += parseInt(currentStyle.borderLeftWidth) || 0;
                        offsetY += parseInt(currentStyle.borderTopWidth) || 0;
                    }
                }
            }

            return {x: offsetX, y: offsetY};
        }
        break;

}


JsUtility.getEventOffsets= function(e)
{
	if(document.all)
		return {x: e.offsetX, y: e.offsetY};
	else return {x: e.layerX, y: e.layerY};
		
	var _target = e.target;
	if (typeof(_target.offsetLeft) == 'undefined')
		_target = _target.parentNode;
	
	var _pageCoord = this.getPageCoords(_target);
	var _eventCoord = {x: window.pageXOffset + e.clientX, y: window.pageYOffset + e.clientY};
	
	return {x: _eventCoord.x - _pageCoord.x, y: _eventCoord.y - _pageCoord.y};
}
JsUtility.getPageCoords= function(element) 
{
	var _result = {x : 0, y : 0};
  
	while (element) 
	{
		_result.x += element.offsetLeft + element.scrollLeft;
		_result.y += element.offsetTop + element.scrollTop;
		
		element = element.offsetParent;
	}

	return _result;
}
JsUtility.getMargins= function(element)
{
    var _result = 0;
    
    var _currentStyle = this.getCurrentStyle(element);
    
    if(this.isBackCompat())
    {
        _result += parseInt(_currentStyle.marginTop) || 0;
        _result += parseInt(_currentStyle.marginBottom) || 0;
    }
    else
    {
        _result += parseInt(_currentStyle.borderTopWidth) || 0;
        _result += parseInt(_currentStyle.borderBottomWidth) || 0;
        _result += parseInt(_currentStyle.paddingTop) || 0;
        _result += parseInt(_currentStyle.paddingBottom) || 0;
        _result += parseInt(_currentStyle.marginTop) || 0;
        _result += parseInt(_currentStyle.marginBottom) || 0;
    }
    
    return _result;
};
JsUtility.getHeightWithMargins= function(element)
{
    var _result = 0;
    
    if(element)
    {
        _result = element.offsetHeight;
        
        try
	    {
	        _result += this.getMargins(element);
	    }
	    catch(ex){}
    }
    
    return _result;
}
JsUtility.showShim = function (shim, target)
{
    if(document.all && target)
    {
        if(!shim)
        {
            shim = document.createElement("IFRAME");
            shim.src = "javascript:false;";
            shim.style.position = "absolute";
            shim.style.visibility = "hidden";
            shim.style.filter = "progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)";

            document.body.appendChild(shim);
        }

        shim.style.width = target.offsetWidth;
        shim.style.height = target.offsetHeight;
        shim.style.top = target.style.top;
        shim.style.left = target.style.left;
        shim.style.zIndex = target.style.zIndex - 1;
        shim.style.visibility = "visible";
    }

    return shim;
};

JsUtility.hideShim = function (shim)
{
    if(document.all && shim)
    {
		shim.style.visibility = "hidden";
		shim.style.top = "-50000px";
        shim.style.left = "-50000px";
	}
};

JsUtility.defineKeyCodes = function ()
{
    this.VK_BACKSPACE  = 8;
    this.VK_TAB        = 9;
    this.VK_ENTER      = 13;
    this.VK_ESCAPE     = 27;
    this.VK_PAGE_UP    = 33;
    this.VK_PAGE_DOWN  = 34;
    this.VK_END        = 35;
    this.VK_HOME       = 36;
    this.VK_LEFT_ARROW = 37;
    this.VK_UP_ARROW   = 38;
    this.VK_RIGHT_ARROW= 39;
    this.VK_DOWN_ARROW = 40;
    this.VK_INSERT     = 45;
    this.VK_DELETE     = 46;
};

var _logPanel = null;

JsUtility.writeLog = function(msg)
{
	try
	{
		Debug.writeln(msg);
	}
	catch(exception)
	{
	}
	//return;
	
	if(_logPanel == null)
	{
		_logPanel = document.getElementById("LogPanel");
		//document.body.appendChild(_logPanel);
	}
	
	if(_logPanel)
	{
	var _logEntry = document.createElement("DIV");
	var _date = new Date();
	
	_logEntry.innerHTML = _date.getTime() + " --- " + msg;
	_logPanel.appendChild(_logEntry);
	}
}

JsUtility.trimText = function(input)
{
    if(typeof(input) == "undefined")
        return "";
    
    var _result = input;
    
    if(typeof(input) != "string")
        _result = new String(input);
    
    return _result.replace(/^\s+|\s+$/g, '');
}
JsUtility.trimStart = function(input)
{
    if(typeof(input) == "undefined")
        return "";
    
    var _result = input;
    
    if(typeof(input) != "string")
        _result = new String(input);
    
    return _result.replace(/^\s+/, '');
}
JsUtility.trimEnd = function(input)
{
    if(typeof(input) == "undefined")
        return "";
    
    var _result = input;
    
    if(typeof(input) != "string")
        _result = new String(input);
    
    return _result.replace(/\s+$/, '');
}
JsUtility.stringIsNullOrEmpty= function(value, trim)
{
	if(typeof(value) != "string")
		return true;
	
	if(trim)
		value = this.trimText(value);
	
	return value.length == 0;
}
JsUtility.stringFormat= function(format)
{
    var _result = "" + format;
    
    for(var i=1; i < arguments.length; i++)
        _result = _result.replace(new RegExp("\\{" + (i - 1) + "\\}"), "" + arguments[i]);
    
    return _result;
}
JsUtility.replace= function(input, search, replace) 
{
    var _index = input.indexOf(search);
    var _result = "";

    if(_index == -1) 
        return input;

    _result += input.substring(0, _index) + replace;

    if( _index + search.length < input.length)
        _result += this.replace(input.substring(_index + search.length, input.length), search, replace);

    return _result;
}

JsUtility.joinStringWithLength = function(separator, itemsArray, startIndex, length)
{
	var _result = "";
	
	for(var i = startIndex; i < startIndex + length; i++)
		_result += (_result.length == 0 ? "" : separator) + itemsArray[i];
	
	return _result;
}
JsUtility.joinString = function (separator, itemsArray)
{
	if(itemsArray != null)
		return JsUtility.joinStringWithLength(separator, itemsArray, 0, itemsArray.length);
		
	return "";
}
JsUtility.htmlEncode= function(input, encodeSpace)
{
    if(typeof(input) == "undefined")
        return "";
    
    var _result = input;
    
    if(typeof(input) != "string")
        _result = new String(input);
    
    _result = this.replace(_result, "&", "&amp;");
    _result = this.replace(_result, ">", "&gt;");
    _result = this.replace(_result, "<", "&lt;");
    if(encodeSpace)
        _result = this.replace(_result, " ", "&nbsp;");
     
    return _result;
}
JsUtility.htmlAttributeEncode= function(input, encodeSpace)
{
    if(typeof(input) == "undefined")
        return "";
    
    var _result = input;
    
    if(typeof(input) != "string")
        _result = new String(input);

    _result = this.replace(_result, "&", "&amp;");
    _result = this.replace(_result, "\"", "&quot;");
    _result = this.replace(_result, ">", "&gt;");
    _result = this.replace(_result, "<", "&lt;");
    
    if(encodeSpace)
        _result = this.replace(_result, " ", "&nbsp;");
     
    return _result;
}
JsUtility.xmlEncode= function(input)
{
    if(typeof(input) == "undefined")
        return "";
    
    var _result = input;
    
    if(typeof(input) != "string")
        _result = new String(input);

    _result = this.replace(_result, "&", "&amp;");
    _result = this.replace(_result, ">", "&gt;");
    _result = this.replace(_result, "<", "&lt;");
    
    return _result;
}


JsUtility.removeClassName= function(element, className)
{
    if(element && className && className.length > 0)
    {
        className = this.trimText(className);
        element.className = this.replace(element.className, className, "");
    }
}

JsUtility.makeElementUnselectable= function(element)
{
	if(document.all)
	{
		element.unselectable = 'on' ;

		var e, i = 0 ;
		while (e = element.all[ i++ ])
		{
			switch ( e.tagName )
			{
				case 'IFRAME' :
				case 'TEXTAREA' :
				case 'INPUT' :
				case 'SELECT' :
					break ;
				default :
					e.unselectable = 'on' ;
			}
		}
	}
	else
	{
		element.style.MozUserSelect	= 'none'
	}
}

JsUtility.attachCallback= function(name, fptr)
{
    if(!this.m_callbacks)
        this.m_callbacks = new Array();
    
    var _fptrs = this.m_callbacks[name];
    if(!_fptrs)
    {
        _fptrs = new Array();
        this.m_callbacks[name] = _fptrs;
    }    
    
    _fptrs[_fptrs.length] = fptr;
}
JsUtility.invokeCallback= function(name, args)
{
    if(this.m_callbacks)
    {
        var _fptrs = this.m_callbacks[name];
        
        if(_fptrs && _fptrs.length > 0)
        {
            for(var i=0; i < _fptrs.length; i++)
            {
                var _fptr = _fptrs[i];
                
                if(_fptr && typeof(_fptr) == "function")
                {
                    if(args)
                        _fptr(args);
                    else _fptr();
                }
            }
        }
    }
}

JsUtility.attachToSyntheticResizeEvent = function(handler)
{
    this.attachCallback("OnSyntheticResize", handler);
}
JsUtility.fireSyntheticResizeEvent = function(element)
{
    this.invokeCallback("OnSyntheticResize", [element]);
}
JsUtility.preloadImages= function(images)
{
    if(!images)
        return;
        
    if(!this.m_preloadImages)
        this.m_preloadImages = new Array();
        
    for(var i=0; i < images.length;i++)
    {   
        var _img = new Image(); 
        _img.src = images[i];
        
        this.m_preloadImages.push(_img);
    }
}
JsUtility.preloadImagesFromHashtable= function(images)
{
    if(!images)
        return;
    
    var _images = new Array();
    for(key in images)
		_images.push(images[key]);
	
	this.preloadImages(_images);
}
JsUtility.stringCompare= function(a, b)
{
    if(a)
        return a.localeCompare(b);
    else if(b)
        return -1;
    else return 0;    
}
JsUtility.pathCompare= function(a, b, pathChar)
{
	
	if( a == b)
		return 0;
	
	if(!pathChar || typeof(pathChar) != "string" || pathChar.length == 0)
		pathChar = "\\";
		
	var _pa = a.indexOf(pathChar)
	var _pb = b.indexOf(pathChar)
	

	var _a = _pa >= 0 ? a.substring(0, _pa) : a;
	var _b = _pb >= 0 ? b.substring(0, _pb) : b;
	
	var _c = this.stringCompare(_a, _b);
	
	if(_c == 0)
	{
		if(_pa > 0)
			return _pb < 1 ? 1 : this.pathCompare(a.substring(_pa + 1, a.length), b.substring(_pb + 1, b.length), pathChar);
		else return _pb > 0 ? -1 : 0;
	}
	else return _c;
}

JsUtility.isMatchTFSPattern= function(pattern, value)
{
    if(!pattern || pattern == null)
        return true;
    
    var _pattern = ValidatorTrim(pattern);
    
    if(_pattern.length == 0)
        return true;
    
    if(!value || value == null)
        return false;
        
    var _value = ValidatorTrim(value);

    if(_value.length == 0)
        return false;
    
    if(_value.length != _pattern.length)
        return false;
    
    for(var i=0; i < _pattern.length; i++)
    {
        var _pc = _pattern.charAt(i);
        var _vc = _value.charAt(i);
        
        if(_pc == "X" || _pc == "x")
            continue;

        if(_pc == "N" || _pc == "n")
            if(this.Digits.indexOf(_vc) < 0)
                return false;
            else continue;
                
        if(_pc == "A" || _pc == "a")
            if(this.AlphaNumeric.indexOf(_vc) < 0)
                return false;
            else continue;
        
        if(_pc.toUpperCase() != _vc && _pc.toLowerCase() != _vc)
            return false;
    }
    
    return true;
}

JsUtility.initCallback= function()
{
    __theFormPostData = "";
    __theFormPostCollection = new Array();
    
    try
    {
        JsUtility.invokeCallback("__InitCallback");
    }
    catch(e)
    {
    }
    
    WebForm_InitCallback();
}

JsUtility.registerScript= function(scriptSource, onload)
{
    var _script = document.createElement("SCRIPT");
    _script.language = "javascript";
    _script.type = "text/javascript";
    _script.src = scriptSource;
    
    if(typeof(onload) == "function")
        _script.onload = onload;
        
    document.body.appendChild(_script);
}
JsUtility.flatoutPartitionedArray= function(array, result)
{
    var _result = [];
    
    if(array)
    {
        var _count = array.length;
        for(var i=0; i < _count; i++)
        {
            var _array = array[i];
            for(var j=0; j < _array.length; j++)
                _result.push(_array[j]);
        }
    }
    
    return _result;
}
JsUtility.createHashArray= function(source, caseSensitive)
{
    if(!source.Hashtable)
    {
        source.Hashtable = new Array();
        
        if(caseSensitive)
        {
            for(var i=0; i < source.length; i++)
                source.Hashtable[source[i]] = i;
        }
        else
        {
            for(var i=0; i < source.length; i++)
                source.Hashtable[source[i].toUpperCase()] = i;
        }
    }
}
JsUtility.lookupValue= function(source, value, caseSensitive)
{
    if(!source || !source.Hashtable)
        return false;
    
    if(caseSensitive)
        return typeof(source.Hashtable["" + value]) != "undefined";
    else return typeof(source.Hashtable[("" + value).toUpperCase()]) != "undefined";
}

JsUtility.updateValidator= function(validator, id)
{
    if(typeof(Page_Validators) == "undefined")
            Page_Validators = new Array();
        
    var _valIndex = -1;
    for(var i=0; i < Page_Validators.length; i++)
    {
        var _val = Page_Validators[i];
        if(_val && _val.valId && _val.valId == id)
        {
            _valIndex = i;
            break;
        }
    }
    
    if(typeof(validator) != "undefined" && validator != null)
    {
        if(_valIndex >= 0)
            Page_Validators[_valIndex] = validator;
        else Page_Validators[Page_Validators.length] = validator;
    }
    else if(_valIndex >= 0)
        Page_Validators.splice(_valIndex, 1);
}
JsUtility.cloneObject= function(o)
{
	var _result = new Object();
	
	for(var key in o)
		_result[key] = o[key];
		 
	return _result;
}
JsUtility.applyStyle= function(element, style)
{
	if(!element || !style)
		return;
	
	var _cssText = "";
	for(var key in style)
	{
		if(key != "cssClass")
			_cssText += key + ":" + style[key] + ";";
	}
	
	element.style.cssText = _cssText;
	
	if(style.cssClass)
		element.className = style.cssClass;
}

JsUtility.applyCss= function(elementIds, css)
{
	if (elementIds)
	{
		for(var i = 0; i < elementIds.length; i++)
		{
			var _element = document.getElementById(elementIds[i]);
			if(_element)
				_element.className = css;
		}
	}
}


JsUtility.getParentByTagName= function(element, tagName) 
{
    var _parent = element.parentNode;
    var _upperTagName = tagName.toUpperCase();
    
    while(_parent 
		&& _parent != document 
		&& _parent.tagName 
		&& _parent.tagName.toUpperCase() != _upperTagName) 
    {
        _parent = _parent.parentNode ? _parent.parentNode : _parent.parentElement;
    }
    
    return _parent;
}
JsUtility.getElementByTagName= function(element, tagName) 
{
    var _elements = this.getElementsByTagName(element, tagName);
    if (_elements && _elements.length > 0) 
        return _elements[0];
    else return null;
}
JsUtility.getElementsByTagName= function(element, tagName) 
{
    if (element && tagName) 
    {
        if (element.getElementsByTagName)
            return element.getElementsByTagName(tagName);
        if (element.all && element.all.tags)
            return element.all.tags(tagName);
    }
    
    return null;
}
JsUtility.getElementValue= function(element, trim, defaultValue)
{
	if(typeof(element) == "string")
		element = document.getElementById(element);
	
	if(element && element.value)
	{
		if(trim)
			return this.trimText(element.value);
		else return element.value;
	}
	
	if(typeof(defaultValue) != "undefined")
		return defaultValue;
		
	return "";
}
JsUtility.setElementValue= function(element, value)
{
	if(typeof(element) == "string")
		element = document.getElementById(element);
	
	if(element)
		element.value = value;
}
JsUtility.setElementInnerHTML= function(element, value)
{
	if(typeof(element) == "string")
		element = document.getElementById(element);

	if(element)
		element.innerHTML = value;
}
JsUtility.enableElement= function(element, enable)
{
	if(typeof(element) == "string")
		element = document.getElementById(element);

	if(element)
	{
		element.removeAttribute("disabled");
		element.disabled = enable ? false : true;
	}
}
JsUtility.setElementVisibility= function(element, visible, displayStyle)
{
	if(typeof(element) == "string")
		element = document.getElementById(element);

	if(element)
	{
		if(!displayStyle)
			displayStyle = "block";
			
		element.style.display = visible ? displayStyle : "none";
		element.style.visibility = visible ? "visible" : "hidden";
	}
}
JsUtility.hideElement= function(element, hide)
{
	if(typeof(element) == "string")
		element = document.getElementById(element);
	
	if(element)
		element.style.display = hide ? "none" : "";
}
JsUtility.focusElement= function(element)
{
	var _element = typeof(element) == "string" ? document.getElementById(element) : element;
	
	if(_element && _element.focus)
		_element.focus();
}

JsUtility.showHideElement = function(imgId, tblId)
{
	var _img = document.getElementById(imgId);
	var _tbl = document.getElementById(tblId);
	if(_img && _tbl)
	{
		var _show = _tbl.style.display == "" || _tbl.style.display == "none";
		
		_img.src = JsUtility.replace(_img.src, _show ? "plus.gif" : "minus.gif", _show ? "minus.gif" : "plus.gif");
		_tbl.style.display = _show ? "block" : "none";
	}
}

JsUtility.showHideElements = function(imgIds, tblIds, show)
{
	for(var i = 0; i < tblIds.length; i++)
	{
		var _img = document.getElementById(imgIds[i]);
		var _tbl = document.getElementById(tblIds[i]);
		if(_img && _tbl)
		{
			_img.src = JsUtility.replace(_img.src, show ? "plus.gif" : "minus.gif", show ? "minus.gif" : "plus.gif");
			_tbl.style.display = show ? "block" : "none";
		}
	}
}

JsUtility.executeCallback= function(callback, arg, context)
{
	if(callback)
	{
		JsUtility.invokeCallback("CallbackStatus", "progress");
		eval(callback);
	}
}
JsUtility.executeGeneralCallback= function(callback, arg, context, clientCallback, clientErrorCallback, callbackStatusName)
{
	if(callback)
	{
		if(typeof(clientCallback) == "undefined")
			clientCallback = this.onCallbackSuccess;

		if(typeof(clientErrorCallback) == "undefined")
			clientErrorCallback = this.onCallbackError;
	
		if(typeof(callbackStatusName) == "undefined")
		    callbackStatusName = "CallbackStatus";
		    
		JsUtility.invokeCallback(callbackStatusName, "progress");
		eval(callback);
	}
}
JsUtility.finishCallback= function(arg, context, isSuccess, redirectUrl, callbackStatusName)
{
    if(typeof(callbackStatusName) == "undefined")
	    callbackStatusName = "CallbackStatus";
		    
	if(isSuccess)
		JsUtility.invokeCallback(callbackStatusName, "normal");
	else
	{
		var _message = arg;
		var _isSpecialMessage = false;
		
		if(_message.charAt(_message.length - 1) == "s")
			_message = _message.substr(0, _message.length - 1);
			
		if(this.isSpecialMessage(_message))
		{
			_message = _message.substr(this.SpecialMessageIdentifier.length);
			var _index = _message.indexOf(this.SpecialMessageIdentifier);
			if(_index > 0)
			{
				_isSpecialMessage = true;
				var _sessionExpiredBehavior = _message.substr(0, _index);
				_message = this.htmlDecode(_message.substr(_index + this.SpecialMessageIdentifier.length, _message.length - _index - this.SpecialMessageIdentifier.length));
				JsUtility.invokeCallback("SessionExpired", {status:"error", error: _message});
				JsUtility.invokeCallback(callbackStatusName, {status:"error", error: _message});
				
				switch(_sessionExpiredBehavior)
				{
					case "RedirectToLoginPage":
						alert(_message);
						if(redirectUrl)
							window.location.href = redirectUrl;
						break;
					case "ConfirmCloseDialog":
						if(confirm(_message))
						{
							JsUtility.invokeCallback("BypassPageLeave", true);
							window.close();
						}
						break;
					default:
						alert(_message);
						break;
				}
			}
		}
		
		if(!_isSpecialMessage)
		{
			_message = this.htmlDecode(_message);
			JsUtility.invokeCallback(callbackStatusName, {status:"error", error: _message});
			alert(_message);
		}
	}
}
JsUtility.isSpecialMessage = function(message)
{
	if(message == null || message.length < this.SpecialMessageIdentifier.length)
		return false;
		
	return message.substr(0, this.SpecialMessageIdentifier.length) == this.SpecialMessageIdentifier;
};
JsUtility.onCallbackSuccess= function(arg, context)
{
	JsUtility.finishCallback(arg, context, true);
}
JsUtility.onCallbackError= function(arg, context)
{
	JsUtility.finishCallback(arg, context, false);
}
JsUtility.evalCallbackResult= function(callbackResult)
{
	if(typeof(callbackResult) == "string" && callbackResult.length > 0)
		return eval("(" + callbackResult + ")");
	return null;
}
JsUtility.htmlDecode= function(value)
{
	if(!this.m_htmlDecoder)
	{
		this.m_htmlDecoder = document.createElement("div");
		this.m_htmlDecoder.style.left = "-5000px";
		this.m_htmlDecoder.style.top = "-5000px";
		this.m_htmlDecoder.style.position = "absolute";
		
		document.body.appendChild(this.m_htmlDecoder);
	}

	this.m_htmlDecoder.innerHTML = value;
	
	return document.all ? this.m_htmlDecoder.innerText : this.m_htmlDecoder.textContent;
}
JsUtility.createMeasurementProbe= function()
{
    var _probe = document.createElement("div");
    _probe.id = "JsUtility_measurementProbe";
    _probe.style.position = "absolute";
    _probe.style.left = "-50000px";
    _probe.style.top = "-50000px";
    _probe.style.width = "9em";
    _probe.style.height = "18ex";
    _probe.style.overflow = "auto";
    
    document.body.appendChild(_probe);
    
    var _probeContent = document.createElement("div");
    _probeContent.style.width = "3in";
    _probeContent.style.height = "36ex";
    
    _probe.appendChild(_probeContent);
    _probe._contentProbe = _probeContent;
    
    this.m_measurementProbe = _probe;
    return _probe;
}
JsUtility.getMeasurementProbe= function()
{
    if(!this.m_measurementProbe)
        this.createMeasurementProbe();
        
    return this.m_measurementProbe;
}
JsUtility.getUnitEm= function()
{
    var _probe = this.getMeasurementProbe();
    return _probe.offsetWidth / 9;
}
JsUtility.getUnitEx= function()
{
    var _probe = this.getMeasurementProbe();
    return _probe.offsetHeight / 18;
}
JsUtility.getUnitIn= function()
{
    var _probe = this.getMeasurementProbe();
    
    return _probe._contentProbe.offsetWidth / 3;
}
JsUtility.getScrollbarWidth= function()
{
    var _probe = this.getMeasurementProbe();
    return _probe.offsetWidth - _probe.clientWidth;           
}
JsUtility.getScrollbarHeight= function()
{
    var _probe = this.getMeasurementProbe();
    return _probe.offsetHeight - _probe.clientHeight;           
}
JsUtility.getUnitAsPixel= function(unit)
{
	var _unit = unit.toLowerCase();
	var _result = parseInt(_unit);
	
	if(_unit.indexOf("px") > 0)
		_result = Math.round(parseFloat(_unit));
	else if(_unit.indexOf("em") > 0)
		_result = Math.round(parseFloat(_unit) * this.getUnitEm());
	else if(_unit.indexOf("ex") > 0)
		_result = Math.round(parseFloat(_unit) * this.getUnitEx());
	else if(_unit.indexOf("in") > 0)
		_result = Math.round(parseFloat(_unit) * this.getUnitIn());
	else if(_unit.indexOf("mm") > 0)
		_result = Math.round(parseFloat(_unit) * this.getUnitIn() / 25.4);
	else if(_unit.indexOf("cm") > 0)
		_result = Math.round(parseFloat(_unit) * this.getUnitIn() / 2.54);
	
	return _result;
}
JsUtility.getWindowClientSize= function()
{
    var _root = this.getRootOwner();
	return {width: _root.clientWidth, height: _root.clientHeight};
}
JsUtility.getClientSize= function(element)
{
    if(!element)
        return {width: 0, height: 0};

    var _result = {width: element.offsetWidth, height: element.offsetHeight};
    
    try
    {
        var _currentStyle = this.getCurrentStyle(element);
        _result.width -= parseInt(_currentStyle.paddingLeft) || 0;
        _result.width -= parseInt(_currentStyle.paddingRight) || 0;
        _result.width -= parseInt(_currentStyle.borderLeftWidth) || 0;
        _result.width -= parseInt(_currentStyle.borderRightWidth) || 0;
        
        _result.height -= parseInt(_currentStyle.paddingTop) || 0;
        _result.height -= parseInt(_currentStyle.paddingBottom) || 0;
        _result.height -= parseInt(_currentStyle.borderTopWidth) || 0;
        _result.height -= parseInt(_currentStyle.borderBottomWidth) || 0;
    }
    catch(exception)
    {
    }
    
    return _result;
}
JsUtility.getMarginalSize= function(element)
{
    if(!element)
        return {width: 0, height: 0};
        
    var _result = {width: element.offsetWidth, height: element.offsetHeight};
    
    try
    {
        var _currentStyle = this.getCurrentStyle(element);
        _result.width += parseInt(_currentStyle.marginLeft) || 0;
        _result.width += parseInt(_currentStyle.marginRight) || 0;
        _result.height += parseInt(_currentStyle.marginTop) || 0;
        _result.height += parseInt(_currentStyle.marginBottom) || 0;
    }
    catch(exception)
    {
    }
    
    return _result;
}
JsUtility.calculateDropPosition= function(dropElement, referenceElement, posCalcAlign)
{
	var _pos = this.getElementPosition(referenceElement);
	var _root = this.getRootOwner(dropElement);
	    
	if(!posCalcAlign)
	    posCalcAlign = "right-bottom";
	    
	if(posCalcAlign == "right-bottom")
	{
		_pos.x = Math.max(_pos.x, _pos.x + referenceElement.offsetWidth - dropElement.offsetWidth);
		_pos.x = Math.min(_pos.x, _root.clientWidth + _root.scrollLeft - dropElement.offsetWidth - 5);
		_pos.y += referenceElement.offsetHeight;

		if(_pos.y + dropElement.offsetHeight > _root.offsetHeight + _root.scrollTop)
			_pos.y -= (referenceElement.offsetHeight + dropElement.offsetHeight);
	}
	else if(posCalcAlign == "right-justify")
	{
		_pos.x += referenceElement.offsetWidth;
		
		if(_pos.x + dropElement.offsetWidth > _root.offsetWidth + _root.scrollLeft)
			_pos.x -= (referenceElement.offsetWidth + dropElement.offsetWidth);
		
		_pos.y = Math.min(_pos.y, _root.offsetHeight + _root.scrollTop - dropElement.offsetHeight - 5);
	}
	else if(posCalcAlign == "left-bottom")
	{
		_pos.x = Math.min(_pos.x, _root.clientWidth + _root.scrollLeft - dropElement.offsetWidth - 5);

		_pos.y += referenceElement.offsetHeight;

		if(_pos.y + dropElement.offsetHeight > _root.clientHeight + _root.scrollTop)
			_pos.y -= (referenceElement.offsetHeight + dropElement.offsetHeight);
	}
	
	if(_pos.x < 0)
		_pos.x = 0;
    
	if(_pos.y < 0)
		_pos.y = 0;
	
	return _pos;
}

JsUtility.setAccidentalEnter= function(value)
{
	this.m_accidentalEnterKey = value;
}
JsUtility.isAccidentalEnter= function()
{
	return this.m_accidentalEnterKey;
}
JsUtility.getKeyCode= function(e)
{
	if(typeof(e) == "undefined")
        e = window.event;
        
    return e.which ? e.which : e.keyCode;
}
JsUtility.writeLog= function(msg)
{
	if(!document.all)
		window.dump(window.location.href + "\t" + msg + "\r\n");
}
JsUtility.getValueObject= function(element, key)
{
	if(typeof(element) == "string")
		element = document.getElementById(element);
	
	if(!key)
		key = "value";
	
	if(element)
	{
		if(!element.m_valueObject)
		{
			if(!element[key])
				return null;
			element.m_valueObject = eval("(" + element[key] + ")");
		}
		
		return element.m_valueObject;
	}
	else return null;
}
JsUtility.createStdTable= function()
{
	var _result = document.createElement("table");
	_result.border = "0";
	_result.cellSpacing = "0";
	_result.cellPadding = "0";
	
	return _result;
}
JsUtility.getHashCode = function(value)
{
	var _result = 0;
	
	if(value && value.length > 0)
		for(var i=0; i < value.length; i++)
		{
			var _c = value.charCodeAt(i)
			_result = this.combineHashCodes(_result, (_c << 8) +  _c);
		}
	
	return _result;
}
JsUtility.combineHashCodes = function(hashA, hashB)
{
	return ((hashA << 5) + hashA) ^ hashB;
}
JsUtility.setControlById= function(id, control)
{
	this.ControlsById[id] = control;
}
JsUtility.setControlByObjectId= function(id, control)
{
	this.ControlsByObjectId[id] = control;
}
JsUtility.getControlById= function(id)
{
	var _result = null;
	
	if(typeof(_result = this.ControlsById[id]) != "undefined")
		return _result;
	else return null;
}
JsUtility.getControlByObjectId= function(id, control)
{
	var _result = null;
	
	if(typeof(_result = this.ControlsByObjectId[id]) != "undefined")
		return _result;
	else return null;
}
JsUtility.addTimeStampToUrl= function(url)
{
    url += "";
    var _url = url;
    var _fragment = "";
    
    var _posSharp = url.indexOf("#");
	if(_posSharp >= 0)
	{
	    _url = url.substring(0, _posSharp);
	    _fragment = url.substring(_posSharp, url.length);
	}
			
	var _now = new Date();
	
	var _posQ = _url.indexOf("?");
	_url += (_posQ >= 0 ? "&time-stamp=" : "?time-stamp=") + encodeURIComponent("" + _now.getTime());
    
    return _url + _fragment;
}
JsUtility.simplifyArguments= function(args)
{
    if(args)
    {
        if(args.length > 1)
            return args;
        else return args[0];
    }
    else return void(0);
} 
JsUtility.passArguments= function(callback, args, currentObject)
{
    var _args = new Array();
    
    if(args && args.length > 0)
    {
        for(var i=0; i < args.length; i++)
        {
            _args.push("args[" + i + "]");
        }
    }
    
    if(typeof(callback) == "function")
    {
        return eval("callback(" + _args.join(",") + ");");
    }
    else if(typeof(callback) == "string")
    {
        return eval( callback + "(" + _args.join(",") + ");");
    }
    else if(typeof(callback) != "undefined")
    {
        return callback;
    }
    else return void(0);
}
JsUtility.joinUriComponents= function(args, url, firstDelimiter, includeUndefineds)
{
    if(JsUtility.stringIsNullOrEmpty(url))
        url = "";
        
    if(JsUtility.stringIsNullOrEmpty(firstDelimiter))
    {
        if(JsUtility.stringIsNullOrEmpty(url))
            firstDelimiter = "";
        else firstDelimiter = "&";    
    }
    
    var _urlParams = "";
    
    if(args)
    {
        var _result = new Array();
        
        for(var key in args)
        {
            var _value = args[key];
            if(_value)
            {
                _result.push(key + "=" + encodeURIComponent(_value));
            }
            else if(includeUndefineds)
            {
                _result.push(key + "=");
            }
        }
               
        _urlParams = _result.join("&");
    }
    
    if(JsUtility.stringIsNullOrEmpty(_urlParams))
        return url;
    else return url + firstDelimiter + _urlParams;
}
JsUtility.addSoftBreaks = function(text, separatorChar, htmlEncode, maxPartLength)
{
    var _result = [];
    var _parts;
    var _separated = (separatorChar && separatorChar.length > 0) ? true : false;
    
    if(typeof(maxPartLength) != "number")
        maxPartLength = 50;
    
    if(_separated)
        _parts = text.split(separatorChar);
    else _parts = [text];
    
    for(var i=0; i < _parts.length; i++)
    {
        var _part = ((_separated && i != 0) ? separatorChar : "") + _parts[i];
	    var _pos = 0;
	    
	    while(_pos < _part.length)
	    {
	        if(htmlEncode)
	            _result.push(JsUtility.htmlEncode(_part.substr(_pos, maxPartLength)));
	        else _result.push(_part.substr(_pos, maxPartLength));
	        
	        _pos += maxPartLength;
        }
    }
    
    return _result.join("<wbr />");
}

JsUtility.waitUntil= function(condition, callback)
{
}
JsUtility.isChildOf= function(parentElement, element)
{
    if(parentElement && element)
    {
        var _parent = element.parentNode;
        
        while(_parent)
        {
            if(_parent === parentElement)
                return true;
                
            _parent = element.parentNode;
        }
    }
    
    return false;
}
JsUtility.asynchCall= function(timeOut, instance, handler, args)
{
    window.setTimeout(function(){handler.apply(instance, args);}, timeOut);
}
JsUtility.registerResizeHandler= function(handler)
{
    if(!this.m_resizeHandlers)
        this.m_resizeHandlers = [];
    
    if(!this.m_windowResizeAttached)
    {
        var _this = this;
        this.m_windowResizeAttached = true;
        JsUtility.attachEvent(window, "resize", function(e){ _this.fireResize(window, ["window", e]); }, true);
    }
        
    this.m_resizeHandlers.push(handler);
}
JsUtility.fireResize= function(element, args)
{
    if(this.m_resizeHandlers)
    {
        for(var i=0; i < this.m_resizeHandlers.length; i++)
        {
            var _handler = this.m_resizeHandlers[i];
            
            if(_handler)
            {
                this.asynchCall(0, this, _handler, [element, args]);
            }
        }
    }
}
JsUtility.deserializeNameValuePairs= function(nameValuePairs)
{
    var _pairs = ("" + nameValuePairs).split(";");
    var _result = {};
    
    for(var i=0; i<_pairs.length; i++)
    {
        var _pair = _pairs[i];
        var _name = _pair;
        var _value = "";
        
        var _pos = _pair.indexOf("=");
        
        if(_pos > 0)
        {
            _name = unescape(_pair.substr(0, _pos));
            
            if(_pos + 1 < _pair.length)
                _value = unescape(_pair.substr(_pos + 1));
        }
        
        _name = _name.replace(/^\s+|\s+$/g, '');
        
        if(_name.length > 0)
            _result[_name] = _value;
    }
    
    return _result;
}
JsUtility.serializeNameValuePairs= function(nameValueCollection)
{
    var _result = [];
    
    if(nameValueCollection)
    {
        for(var name in nameValueCollection)
        {
            _result.push(escape(name) + "=" + escape(nameValueCollection[name]));
        }
    }
    
    return _result.join(";");
}
JsUtility.setCookie= function(name, value, expiresAfterDays, expiresAfterHours, expiresAfterMinutes, expiresAfterSeconds)
{
    expiresAfterDays = parseInt(expiresAfterDays);
    expiresAfterHours = parseInt(expiresAfterHours) || 0;
    expiresAfterMinutes = parseInt(expiresAfterMinutes) || 0;
    expiresAfterSeconds = parseInt(expiresAfterSeconds) || 0;
    
    var _expiresString = "";
    
    if(!isNaN(expiresAfterDays))
    {
        var _expires = new Date();
        
        _expires.setTime(_expires.getTime() + (expiresAfterDays * 86400 + expiresAfterHours * 3600 + expiresAfterMinutes * 60 + expiresAfterSeconds) * 1000);
        _expiresString = ";expires=" + _expires.toGMTString();
    }
    
    document.cookie = escape(name) + "=" + escape(value) + _expiresString;
}
JsUtility.clearCookie= function(name)
{
    this.setCookie(name, "", -1);
}
JsUtility.getCookie= function(name)
{
    var _cookies = this.deserializeNameValuePairs(document.cookie);
    
    name = name.replace(/^\s+|\s+$/g, '');
    
    return _cookies[name] || "";
}
JsUtility.getCookieNameValuePairs= function(name)
{
    if(!name)
        name = "_TSWA_HASHTABLE_";
        
    return this.deserializeNameValuePairs(this.getCookie(name));
}
JsUtility.setCookieNameValuePairs= function(name, nameValuePairs)
{
    if(!name)
        name = "_TSWA_HASHTABLE_";
    
    this.clearCookie(name);    
    return this.setCookie(name, this.serializeNameValuePairs(nameValuePairs), 90);
}
JsUtility.getPersistentValue= function(name)
{
    var _persistenceStore = this.getCookieNameValuePairs();
    
    return _persistenceStore[name];
}
JsUtility.setPersistentValue= function(name, value)
{
    var _persistenceStore = this.getCookieNameValuePairs();
    
    _persistenceStore[name] = value;
    
    this.setCookieNameValuePairs(null, _persistenceStore);
}
JsUtility.removePersistentValue= function(name)
{
    var _persistenceStore = this.getCookieNameValuePairs();
    
    delete _persistenceStore[name];
    
    this.setCookieNameValuePairs(null, _persistenceStore);
}


JsUtility.init();
JsUtility.attachEvent(window, "unload", function(){JsUtility.cleanupEventsCache(); JsUtility.deleteObjects();}, true);
var i = 0;

function eventSink()
{
    this.m_events = new Array();
    
    this.getHandlers= function(eventName)
    {
        if(typeof(eventName) != "string" || eventName.length == 0)
            return null;
        
        var _handlers = this.m_events[eventName.toUpperCase()];
        
        if(!_handlers)
        {
            _handlers = new Array();
            this.m_events[eventName.toUpperCase()] = _handlers;
        }
        
        return _handlers;
    }
    this.attachEvent= function(eventName, handler)
    {
        var _handlers = this.getHandlers(eventName);
        
        if(_handlers && handler)
        {
            _handlers.push(handler);
        }
    }
    this.detachEvent= function(eventName, handler)
    {
        var _handlers = this.getHandlers(eventName);
        
        if(_handlers && handler)
        {
            var _index = -1;
            for(var i=0; i < _handlers.length; i++)
            {
                if(_handlers[i] == handler)
                {
                    _index = i;
                    break;
                }
            }
            
            if(_index >= 0)
            {
                _handlers.splice(_index, 1);
            }
        }
    }
    this.fireEvent= function(eventName, args)
    {
        var _handlers = this.getHandlers(eventName);
        
        if(_handlers)
        {
            for(var i=0; i < _handlers.length; i++)
            {
                var _handler = _handlers[i];
                var _this = this;
                
                if(_handlers[i] instanceof Array)
                {
                    _handler = _handlers[i][0];
                    _this = _handlers[i][1];
                }
                
                if(typeof(_handler) == "function")
                {
                    _handler.call(_this, args);
                }
                else if(typeof(_handler) == "string")
                {
                    _handler = eval(_handler);
                    if(typeof(_handler) == "function")
                        _handler(args);
                }
            }
        }
    }
}
