var __aspxInvalidDimension = -10000;
var __aspxInvalidPosition = -10000;
var __aspxAbsoluteLeftPosition = -10000;
var __aspxAbsoluteRightPosition = 10000;
var __aspxMenuZIndex = 20000;
var __aspxPopupControlZIndex = 10000;

var /* const */ __aspxCheckSizeCorrectedFlag = true;
var __aspxCallBackSeparator = ":";
var __aspxItemIndexSeparator = "i";
var __aspxCallBackErrorPrefix = "####";

var __aspxItemClassName = "dxi";

var __aspxHTMLLoaded = false;

var __aspxEmptyAttributeValue = "DXEmpty";
var __aspxEmptyCachedValue = "DXNull";
var __aspxCachedRules = new Object();

var __aspxDateFormatInfo = {
    twoDigitYearMax: 2029,
    ts: ":",    ds: "/",
    am: "AM",   pm: "PM"
};

// Debug 
function _aspxGetActiveElement() {
    try{
        return document.activeElement;    
    }
    catch(e) { 
    }
    return null;
}
function _aspxInsp(obj) {
	alert(_aspxGetObjInfo(obj));
}
function _aspxGetObjInfo(obj) {
	var array = new Array();
	for(var key in obj) {
	    if(key.indexOf("on") != 0 && key.indexOf("outer") != 0 && key.indexOf("inner") != 0) {
	        try{
			    var value = "" + eval("obj." + key);
			    if(value.indexOf("function") < 0)
				    array.push(" " + key + " = " + value);
		    }
		    catch(e){
		    }
		}
	}
	array.sort();
	return array.join("\t");
}
// Browsers
var __aspxAgent = navigator.userAgent.toLowerCase();
var __aspxOpera = (__aspxAgent.indexOf("opera") > -1);
var __aspxOpera9 = (__aspxAgent.indexOf("opera/9") > -1 || __aspxAgent.indexOf("opera 9") > -1);
var __aspxSafari = __aspxAgent.indexOf("safari") > -1;
var __aspxSafariMacOS = __aspxSafari && __aspxAgent.indexOf("macintosh") > -1;
var __aspxIE = (__aspxAgent.indexOf("msie") > -1 && !__aspxOpera);
var __aspxIE55 = (__aspxAgent.indexOf("5.5") > -1 && __aspxIE);
var __aspxIE7 = (__aspxAgent.indexOf("7.") > -1 && __aspxIE);
var __aspxNotIEOperaSafari = !__aspxSafari && !__aspxIE && !__aspxOpera;
var __aspxFirefox = (__aspxAgent.indexOf("firefox") > -1) && __aspxNotIEOperaSafari;
var __aspxMozilla = (__aspxAgent.indexOf("mozilla") > -1) && __aspxNotIEOperaSafari;
var __aspxNetscape = (__aspxAgent.indexOf("netscape") > -1) && __aspxNotIEOperaSafari;
var __aspxNS = __aspxFirefox  || __aspxMozilla || __aspxNetscape;
// Array
function _aspxArrayPush(array, element){
    if(_aspxIsExists(array.push))
	    array.push(element);
    else	 
        array[array.length] = element;
}
function _aspxArrayInsert(array, element, position){
	if(0 <= position && position < array.length){
		for(var i = array.length; i > position; i --)
			array[i] = array[i - 1];
		array[position] = element;
	}
	else
	    _aspxArrayPush(array, element);
}

function _aspxArrayRemove(array, element){
    var index = _aspxArrayIndexOf(array, element);
    if(index > -1) _aspxArrayRemoveAt(array, index);
}
function _aspxArrayRemoveAt(array, index){
	if(index >= 0  && index < array.length){
		for(var i = index; i < array.length - 1; i++)
			array[i] = array[i + 1];
		array.pop();
	}
}
function _aspxArrayClear(array){
	while(array.length > 0)
		array.pop();
}
function _aspxArrayIndexOf(array, element){
	for(var i = 0; i < array.length; i++){
		if(array[i] == element)
			return i;
	} 
	return -1;
}
var __aspxDefaultBinarySearchComparer = function(arrayElement, value) { if(arrayElement == value) return 0; else return arrayElement < value ? -1 : 1; };
function _aspxArrayBinarySearch(array, value, binarySearchComparer, startIndex, length) {
    if(!_aspxIsExists(binarySearchComparer))
        binarySearchComparer = __aspxDefaultBinarySearchComparer;
    if(!_aspxIsExists(startIndex))
        startIndex = 0;
    if(!_aspxIsExists(length))
        length = array.length - startIndex;        
    var endIndex = (startIndex + length) - 1;
    while (startIndex <= endIndex) {
        var middle =  (startIndex + ((endIndex - startIndex) >> 1));
        var compareResult = binarySearchComparer(array[middle], value);
        if (compareResult == 0)
            return middle;
        if (compareResult < 0)
            startIndex = middle + 1;
        else
            endIndex = middle - 1;
    }
    return -(startIndex + 1);
}

// Timer
function _aspxSetTimeout(callString, timeout){
    return window.setTimeout(callString, timeout);
}
function _aspxClearTimer(timerID){
    if(timerID > -1)
        window.clearTimeout(timerID);
    return -1;
}
// Interval
function _aspxSetInterval(callString, interval){
    return window.setInterval(callString, interval);
}
function _aspxClearInterval(timerID){
    if(timerID > -1)
        window.clearInterval(timerID);
    return -1;
}
// Utils
function _aspxCloneObject(srcObject) {
  if(typeof(srcObject) != 'object') return srcObject;
  if (srcObject == null) return srcObject;
    
  var newObject = new Object();
 
  for(var i in srcObject) 
    newObject[i] = srcObject[i];
 
  return newObject;
}
function _aspxIsExistsType(type){
	return (type != "undefined");
}
function _aspxIsExists(obj){
	return (typeof(obj) != "undefined") && (obj != null);
}
function _aspxIsFunction(obj){
	return typeof(obj) == "function";
}
function _aspxGetDefinedValue(value, defaultValue){
    return (typeof(value) != "undefined") ? value : defaultValue;
}

function _aspxSetInputSelection(input, startPos, endPos){
    startPos = _aspxGetDefinedValue(startPos, 0);
    endPos = _aspxGetDefinedValue(endPos, input.value.length);
    if (__aspxIE) {
        var range = input.createTextRange();
        range.collapse(true);
        range.moveStart("character", startPos);
        range.moveEnd("character", endPos - startPos);
        range.select();
    } else
        input.setSelectionRange(startPos, endPos);
}
function  _aspxHasInputSelection(input){
    var selectionStart = 0;
    var selectionEnd = 0;
    if(__aspxIE){
        var curRange = document.selection.createRange();
        var copyRange = curRange.duplicate();
        
        curRange.move('character', - input.value.length);
        curRange.setEndPoint('EndToStart', copyRange);
        
        var selectionStart = curRange.text.length;
        var selectionEnd = selectionStart + copyRange.text.length;
    } else{
        selectionStart = input.selectionStart;
        selectionEnd = input.selectionEnd;
    }
    return (selectionStart == selectionEnd);
}

function _aspxPreventElementDragAndSelect(element, isSkipMouseMove){
    if(__aspxIE){
        _aspxAttachEventToElement(element, "selectstart", new function(){ return false;});
        if(!isSkipMouseMove)
            _aspxAttachEventToElement(element, "mousemove", _aspxClearSelectionOnMouseMove);
        _aspxAttachEventToElement(element, "dragstart", _aspxPreventDragStart);
    }
}
function _aspxClearSelection(){
    try{
        if (_aspxIsExists(window.getSelection)){
            if (__aspxSafari)
                window.getSelection().collapse();
            else
                window.getSelection().removeAllRanges();
        }
        else if (_aspxIsExists(document.selection)){
            if(_aspxIsExists(document.selection.empty))
                document.selection.empty();
		    else if(_aspxIsExists(document.selection.clear))
			    document.selection.clear();
	    }
	}
	catch(e){
	}
}
function _aspxClearSelectionOnMouseMove(evt){
    if (!__aspxIE || (evt.button != 0)) 
        _aspxClearSelection();
}
function _aspxPreventDragStart(evt){
    evt = _aspxGetEvent(evt);
    var element = _aspxGetEventSource(evt);
    element.releaseCapture(); 
    return false;
}

function _aspxGetElementById(id){
    if(_aspxIsExists(document.getElementById))
	    return document.getElementById(id);
	else
	    return document.all[id];
}
function _aspxGetParentNode(element){
	return element.parentNode;
}
function _aspxGetIsParent(parentElement, element){
	while(element != null){
		if(element.tagName == "BODY") return false;
		if(element == parentElement) return true;
		element = _aspxGetParentNode(element);
	}
	return false;
}
function _aspxGetParentById(element, id){
	element = _aspxGetParentNode(element);
	while(element != null){
		if(element.id == id) return element;
		element = _aspxGetParentNode(element);
	}
	return null;
}
function _aspxGetParentByTagName(element, tagName) {
    tagName = tagName.toUpperCase();
    while(element != null) {
        var name = element.tagName.toUpperCase();
        if(name == "BODY") return null;
        if(name == tagName) return element;
        element = _aspxGetParentNode(element);
    }
    return null;
}
function _aspxGetParentByClassName(element, className) {
    while(element != null) {
        if(element.tagName.toUpperCase() == "BODY") return null;
        if(element.className.indexOf(className) != -1) return element;
        element = _aspxGetParentNode(element);
    }
    return null;
}
function _aspxGetChildById(element, id){
	return __aspxIE ? element.all[id] : _aspxGetElementById(id);
}
function _aspxGetElementsByTagName(element, tagName){
	if(element != null){		
		tagName = tagName.toUpperCase();
		return _aspxIsExists(element.all) ? element.all.tags(tagName) : element.getElementsByTagName(tagName);
	}
	return null;
}
function _aspxGetChildByTagName(element, tagName, index) {
	if(element != null){				
		var collection = _aspxGetElementsByTagName(element, tagName);
		if(collection != null){
			if(index < collection.length)
				return collection[index];
		}
	}
	return null;
}
function _aspxGetChildTextNode(element, index) {
	if(element != null){
	    var collection = new Array();
	    _aspxGetChildTextNodeCollection(element, collection);
		if(index < collection.length)
			return collection[index];
	}
	return null;
}
function _aspxGetChildTextNodeCollection(element, collection) {
    for(var i = 0; i < element.childNodes.length; i ++){
        var childNode = element.childNodes[i];
        if(_aspxIsExists(childNode.nodeValue))
            _aspxArrayPush(collection, childNode);
        _aspxGetChildTextNodeCollection(childNode, collection);
    }
}
function _aspxGetChildsByClassName(element, className) {
	var collection = _aspxIsExists(element.all) ? element.all : element.getElementsByTagName('*');
	
    var ret = new Array();
	if(collection != null) {
        for(var i = 0; i < collection.length; i ++) {
            if (collection[i].className.indexOf(className) != -1)
                ret.push(collection[i]);
        }
	}
	return ret;
}
function _aspxGetParentByPartialId(element, idPart){
	while(element != null){
	    if(_aspxIsExists(element.id)) {
		    if(element.id.indexOf(idPart) > -1) return element;
		}
		element = _aspxGetParentNode(element);
	}
	return null;
}
function _aspxGetElementsByPartialId(element, partialName, list) {
    if(!_aspxIsExists(element.id)) return;
    if(element.id.indexOf(partialName) > -1) {
        list.push(element);
    }
    for(var i = 0; i < element.childNodes.length; i ++) {
        _aspxGetElementsByPartialId(element.childNodes[i], partialName, list);
    }
}
function _aspxRemoveElement(element) {
	if(_aspxIsExistsElement(element)) {	
		var parent = element.parentNode;
		if(_aspxIsExistsElement(parent))
			parent.removeChild(element);
	}
	element = null;
}
function _aspxGetEvent(evt){
    return (typeof(event) != "undefined") ? event : evt; 
}
function _aspxPreventEvent(evt){
    if (__aspxNS)
        evt.preventDefault();
    else
		evt.returnValue = false;
    return false;
}
function _aspxPreventEventAndBubble(evt){
    _aspxPreventEvent(evt);
    if (__aspxNS)
        evt.stopPropagation();
    evt.cancelBubble = true;
    return false;
}

function _aspxGetEventSource(evt){
    evt = _aspxGetEvent(evt);
    if(!_aspxIsExists(evt)) return null; 
	return __aspxIE ? evt.srcElement : evt.target;
}
function _aspxGetEventX(evt){
    return evt.clientX  - _aspxGetIEDocumentClientOffset(true) + (__aspxSafari ? 0 : _aspxGetDocumentScrollLeft());
}
function _aspxGetEventY(evt){
    return evt.clientY - _aspxGetIEDocumentClientOffset(false) + (__aspxSafari ? 0 : _aspxGetDocumentScrollTop());
}
function _aspxGetIEDocumentClientOffset(IsX){
    var clientOffset = 0;
    if(__aspxIE){
        if(_aspxIsExists(document.documentElement))
            clientOffset = IsX ? document.documentElement.clientLeft : document.documentElement.clientTop;
        if(clientOffset == 0 && _aspxIsExists(document.body))
            var clientOffset = IsX ? document.body.clientLeft : document.body.clientTop;
    }
    return clientOffset;
}
function _aspxGetIsLeftButtonPressed(evt){
    evt = _aspxGetEvent(evt);
    if(!_aspxIsExists(evt)) return false;
	if(__aspxIE)
	    return evt.button == 1;
	else if(__aspxNS || __aspxSafari)
	    return evt.which == 1;
	else if (__aspxOpera)
	    return evt.button == 0;	    
    return true;	    
}
function _aspxGetWheelDelta(evt){
    var ret = __aspxNS ? -evt.detail : evt.wheelDelta;
    if (__aspxOpera)
        ret = -ret;
    return ret;
}

function _aspxDelCookie(name, value){
    _aspxSetCookieInternal(name, value, new Date(1999, 11, 31));
}
function _aspxSetCookie(name, value){
    var date = new Date();
    date.setFullYear(date.getFullYear() + 1);
    _aspxSetCookieInternal(name, value, date);
}
function _aspxSetCookieInternal(name, value, date){
    document.cookie = name + "=" + escape(value) + "; expires=" + date.toGMTString();
}

function _aspxGetElementDisplay(element){
	return element.style.display != "none";
}
function _aspxSetElementDisplay(element, value){
	element.style.display = value ? "" : "none";
}
function _aspxGetElementVisibility(element){
	return element.style.visibility != "hidden";
}
function _aspxSetElementVisibility(element, value){
	element.style.visibility = value ? "" : "hidden";
}

function _aspxGetCurrentStyle(element){
    if (__aspxIE)
        return element.currentStyle;
    else if (__aspxOpera && !__aspxOpera9)
        return window.getComputedStyle(element, null);
    else
        return document.defaultView.getComputedStyle(element, null);
}
function _aspxCreateStyleSheet(){
    if(__aspxIE)
        return document.createStyleSheet();
    else{
        var styleSheet = document.createElement("STYLE");
        document.body.appendChild(styleSheet);
        return document.styleSheets[document.styleSheets.length - 1];
    }
}
function _aspxGetStyleSheetRules(styleSheet){
    try {
        return __aspxIE ? styleSheet.rules : styleSheet.cssRules;
    }
    catch(e) {
        return null;
    }
}

function _aspxGetStyleSheetRule(className){
    if(_aspxIsExists(__aspxCachedRules[className])){
        if(__aspxCachedRules[className] != __aspxEmptyCachedValue)
            return __aspxCachedRules[className];
        return null;
    }
    for(var i = 0; i < document.styleSheets.length; i ++){
        var styleSheet = document.styleSheets[i];
        var rules = _aspxGetStyleSheetRules(styleSheet);
        if(rules != null){
            for(var j = 0; j < rules.length; j ++){
                if(rules[j].selectorText == "." + className){
                    __aspxCachedRules[className] = rules[j];
                    return rules[j];
                }
            }
        }
    }
    __aspxCachedRules[className] = __aspxEmptyCachedValue;
    return null;
}

function _aspxRemoveStyleSheetRule(styleSheet, index){
    var rules = _aspxGetStyleSheetRules(styleSheet);
    if(rules != null && rules.length > 0 && rules.length >= index){
        if(__aspxIE)
            styleSheet.removeRule(index);
        else            
            styleSheet.deleteRule(index);     
    }                
}

function _aspxAddStyleSheetRule(styleSheet, selector, cssText){
    if(!_aspxIsExists(cssText) || cssText == "") return;
    if(__aspxIE)
        styleSheet.addRule(selector, cssText);
    else
        styleSheet.insertRule(selector + " { " + cssText + " }", styleSheet.cssRules.length);
}
function _aspxSetPointerCursor(element) {
    if(element.style.cursor == "")
        element.style.cursor = __aspxIE ? "hand" : "pointer";
}

function _aspxGetIsValidPosition(pos){
    return pos != __aspxInvalidPosition && pos != -__aspxInvalidPosition;
}
function _aspxGetAbsoluteX(curEl){
    return _aspxGetAbsolutePositionX(curEl);
}
function _aspxGetAbsoluteY(curEl){
    return _aspxGetAbsolutePositionY(curEl);
}
function _aspxGetAbsolutePositionX(curEl){
    if (__aspxIE)
        return _aspxGetAbsolutePositionX_IE(curEl);
    if (__aspxOpera)
        return _aspxGetAbsolutePositionX_Opera(curEl);
    return _aspxGetAbsolutePositionX_Other(curEl);
}
function _aspxGetAbsolutePositionX_Opera(curEl){
    var pos = 0;
    while (curEl != null) {
        pos += curEl.offsetLeft;
        curEl = curEl.offsetParent;
    }
    return pos;
}
function _aspxGetAbsolutePositionX_IE(curEl){
    var pos = 0;
    var isFirstCycle = true;
    while (curEl != null) {
        pos += curEl.offsetLeft;
        if (!isFirstCycle && curEl.offsetParent != null)
            pos -= curEl.scrollLeft;
        var tagName = curEl.tagName.toUpperCase();
        if (!isFirstCycle && tagName != "TABLE")
            pos += curEl.clientLeft;
        isFirstCycle = false;
        
        curEl = curEl.offsetParent;
    }
    return pos;
}
function _aspxGetAbsolutePositionX_Other(curEl){
    var pos = 0;
    var isFirstCycle = true;
    while (curEl != null) {
        pos += curEl.offsetLeft;
        if (!isFirstCycle && curEl.offsetParent != null)
            pos -= curEl.scrollLeft;
        isFirstCycle = false;
        curEl = curEl.offsetParent;
    }
    return pos;
}

function _aspxGetAbsolutePositionY(curEl){
    if (__aspxIE)
        return _aspxGetAbsolutePositionY_IE(curEl);
    if (__aspxOpera)
        return _aspxGetAbsolutePositionY_Opera(curEl);
    if(__aspxNS)
        return _aspxGetAbsolutePositionY_NS(curEl);
    return _aspxGetAbsolutePositionY_Other(curEl);
}

function _aspxGetAbsolutePositionY_Opera(curEl){
    var pos = 0;
    while (curEl != null) {
        pos += curEl.offsetTop;
        curEl = curEl.offsetParent;
    }
    return pos;
}

function _aspxGetAbsolutePositionY_IE(curEl){
    var pos = 0;
    var isFirstCycle = true;
    while (curEl != null) {
        pos += curEl.offsetTop;
        if (!isFirstCycle && curEl.offsetParent != null)
            pos -= curEl.scrollTop;
        var tagName = curEl.tagName.toUpperCase();
        if (!isFirstCycle && tagName != "TABLE")
            pos += curEl.clientTop;
        isFirstCycle = false;
        
        curEl = curEl.offsetParent;
    }
    return pos;
}

function _aspxGetAbsolutePositionY_NS(element){
    var curEl = element;
    var pos = 0;
    var isFirstCycle = true;
    while (curEl != null) {
        pos += curEl.offsetTop;
        if (!isFirstCycle && curEl.offsetParent != null)
            pos -= curEl.scrollTop;
        
        isFirstCycle = false;
        curEl = curEl.offsetParent;
    }
    
    // B91523
    curEl = element;
    while (curEl != null) {
        var tagname = curEl.tagName.toUpperCase();
        if(tagname == "BODY") break;
        
        var style = _aspxGetCurrentStyle(curEl);
        if(tagname == "DIV" && (style.position == "" || style.position == "static")){
            pos -= curEl.scrollTop;
        }
        curEl = curEl.parentNode;
    }
    return pos;
}

function _aspxGetAbsolutePositionY_Other(curEl){
    var pos = 0;
    var isFirstCycle = true;
    while (curEl != null) {
        pos += curEl.offsetTop;
        if (!isFirstCycle && curEl.offsetParent != null)
            pos -= curEl.scrollTop;
        
        isFirstCycle = false;
        curEl = curEl.offsetParent;
    }
    return pos;
}

function _aspxGetPositionElementOffset(element, isX){
    var curEl = element.offsetParent;
    var offset = 0;
    var position = "";
        while(curEl != null) {
        var tagName = _aspxIsExists(curEl.tagName) ? curEl.tagName.toLowerCase() : "";
        if(tagName != "td" && tagName != "tr"){
            var style = _aspxGetCurrentStyle(curEl);
            if (style.position == "absolute" || style.position == "fixed" || style.position == "relative") {
                offset += isX ? curEl.offsetLeft : curEl.offsetTop;
                if (__aspxIE || __aspxOpera9 || __aspxSafariMacOS)
                    offset += _aspxPxToInt(isX ? style.borderLeftWidth : style.borderTopWidth);
            }
        }
        curEl = curEl.offsetParent;
    }
    return offset;
}
function _aspxPxToInt(px) {
    var result = 0;
    if (px != null && px != "") {
        try {
            var indexOfPx = px.indexOf("px");
            if (indexOfPx > -1)
                result = parseInt(px.substr(0, indexOfPx));
        } catch(e) { }
    }
    return result;
}
function _aspxGetClearClientWidth(element) {
    var currentStyle = _aspxGetCurrentStyle(element);
    return element.offsetWidth - _aspxPxToInt(currentStyle.paddingLeft) - _aspxPxToInt(currentStyle.paddingRight) -
        _aspxPxToInt(currentStyle.borderLeftWidth) - _aspxPxToInt(currentStyle.borderRightWidth);
}
function _aspxGetClearClientHeight(element) {
    var currentStyle = _aspxGetCurrentStyle(element);
    return element.offsetHeight - _aspxPxToInt(currentStyle.paddingTop) - _aspxPxToInt(currentStyle.paddingBottom) -
        _aspxPxToInt(currentStyle.borderTopWidth) - _aspxPxToInt(currentStyle.borderBottomWidth);
}
function _aspxSetOffsetWidth(element, widthValue) {
    var currentStyle = _aspxGetCurrentStyle(element);    
    var value = widthValue - _aspxPxToInt(currentStyle.marginLeft) - _aspxPxToInt(currentStyle.marginRight);    
    // B90988
    if(value > -1) 
		element.style.width = value + "px";
}
function _aspxSetOffsetHeight(element, heightValue) {
    var currentStyle = _aspxGetCurrentStyle(element);
    var value = heightValue - _aspxPxToInt(currentStyle.marginTop) - _aspxPxToInt(currentStyle.marginBottom);
    // B90988
    if(value > -1)
		element.style.height = value + "px";
}
function _aspxFindOffsetParent(element) {
    if (__aspxIE)
        return element.offsetParent;
    var currentElement = element.parentNode;
    while(_aspxIsExistsElement(currentElement) && currentElement.tagName.toUpperCase() != "BODY") {
        if (currentElement.offsetWidth > 0 && currentElement.offsetHeight > 0)
            return currentElement;
        currentElement = currentElement.parentNode;
    }
    return document.body;
}
function _aspxGetDocumentScrollTop(){
    if(__aspxSafari || __aspxIE55 || document.documentElement.scrollTop == 0)
        return document.body.scrollTop;
    return document.documentElement.scrollTop;
}
function _aspxGetDocumentScrollLeft(){
    if(__aspxSafari || __aspxIE55 || document.documentElement.scrollLeft == 0)
        return document.body.scrollLeft;
    return document.documentElement.scrollLeft;
}
function _aspxGetDocumentClientWidth(){
    if(__aspxSafari || __aspxIE55 || document.documentElement.clientWidth == 0)
        return document.body.clientWidth;
    return document.documentElement.clientWidth;
}
function _aspxGetDocumentClientHeight(){
    if (__aspxSafari) 
        return window.innerHeight;
    if(__aspxIE55 || __aspxOpera || document.documentElement.clientHeight == 0)
        return document.body.clientHeight;
    return document.documentElement.clientHeight;
}
function _aspxGetClientLeft(element){
    return _aspxIsExists(element.clientLeft) ? element.clientLeft : (element.offsetWidth - element.clientWidth) / 2;
}
function _aspxGetClientTop(element){
    return _aspxIsExists(element.clientTop) ? element.clientTop : (element.offsetHeight - element.clientHeight) / 2;
}
function _aspxSetFocus(element) {
    try {
        element.focus();
    }
    catch (e) {
    }
}
function _aspxIsFocusableCore(element, skipContainerVisibilityCheck) {
    var current = element;
    while(_aspxIsExists(current)) {
        if (current == element || !skipContainerVisibilityCheck(current)) {
            if (current.tagName.toLowerCase() == "body")
                return true;
            if (current.disabled || !_aspxGetElementDisplay(current) || !_aspxGetElementVisibility(current))
                return false;
        }
        current = current.parentNode;
    }
    return true;
}
function _aspxIsFocusable(element) {  
    return _aspxIsFocusableCore(element, function(o) { return false; });
}
function _aspxAttachEventToElement(element, eventName, func) {
    if(__aspxNS || __aspxSafari)
        element.addEventListener(eventName, func, true);
    else {
        if(eventName.toLowerCase().indexOf("on") != 0) 
            eventName = "on"+eventName;
        element.attachEvent(eventName, func);
    }
}
function _aspxDetachEventFromElement(element, eventName, func) {
    if(__aspxNS || __aspxSafari)
        element.removeEventListener(eventName, func, true);
    else {
        if(eventName.toLowerCase().indexOf("on") != 0) 
            eventName = "on"+eventName;
        element.detachEvent(eventName, func);
    }
}
function _aspxAttachEventToDocument(eventName, func) {
    _aspxAttachEventToElement(document, eventName, func);
}
function _aspxCreateEventHandlerFunction(funcName, controlName, withHtmlEventArg) {
    return withHtmlEventArg ? new Function("event", funcName + "('" + controlName + "', event);") :
								new Function(funcName + "('" + controlName + "');");
}

function _aspxCreateClass(parentClass, properties) {
    var ret = function() {
        if (ret.preparing) 
            return delete(ret.preparing);
        if (ret.constr) {
            this.constructor = ret;
            ret.constr.apply(this, arguments);
        }
    }
    ret.prototype = {};
    if(_aspxIsExists(parentClass)) {
        parentClass.preparing = true;
        ret.prototype = new parentClass;
        ret.prototype.constructor = parentClass;
        ret.constr = parentClass;
    }
    if(_aspxIsExists(properties)) {
        var constructorName = "constructor";
        for(var name in properties){
            if (name != constructorName) 
                ret.prototype[name] = properties[name];
        }
        if (properties[constructorName] && properties[constructorName] != Object)
            ret.constr = properties[constructorName];
    }
    return ret;
}
// Attributes
function _aspxGetAttribute(obj, attrName){
    if(_aspxIsExists(obj.getAttribute))
        return obj.getAttribute(attrName);
    else if(_aspxIsExists(obj.getPropertyValue))
        return obj.getPropertyValue(attrName);
    return null;
}
function _aspxSetAttribute(obj, attrName, value){
    if(_aspxIsExists(obj.setAttribute))
        obj.setAttribute(attrName, value);
    else if(_aspxIsExists(obj.setProperty))
        obj.setProperty(attrName, value, "");
}
function _aspxRemoveAttribute(obj, attrName){
    if(_aspxIsExists(obj.removeAttribute))
        obj.removeAttribute(attrName);
    else if(_aspxIsExists(obj.removeProperty))
        obj.removeProperty(attrName);
}
function _aspxIsExistsAttribute(obj, attrName){
    var value = _aspxGetAttribute(obj, attrName);
    return (value != null) && (value != "");
}
function _aspxChangeAttributeExtended(obj, attrName, savedObj, savedAttrName, newValue){
    if(!_aspxIsExistsAttribute(savedObj, savedAttrName)){
        var oldValue = _aspxIsExistsAttribute(obj, attrName) ? _aspxGetAttribute(obj, attrName) : __aspxEmptyAttributeValue;
        _aspxSetAttribute(savedObj, savedAttrName, oldValue);
    }
    _aspxSetAttribute(obj, attrName, newValue);
}
function _aspxChangeAttribute(obj, attrName, newValue){
    _aspxChangeAttributeExtended(obj, attrName, obj, "saved" + attrName, newValue);
}
function _aspxChangeStyleAttribute(obj, attrName, newValue){
    _aspxChangeAttributeExtended(obj.style, attrName, obj, "saved" + attrName, newValue);
}
function _aspxResetAttributeExtended(obj, attrName, savedObj, savedAttrName){
    if(!_aspxIsExistsAttribute(savedObj, savedAttrName)){
        var oldValue = _aspxIsExistsAttribute(obj, attrName) ? _aspxGetAttribute(obj, attrName) : __aspxEmptyAttributeValue;
        _aspxSetAttribute(savedObj, savedAttrName, oldValue);
     }
    _aspxSetAttribute(obj, attrName, "");
    _aspxRemoveAttribute(obj, attrName);
}
function _aspxResetAttribute(obj, attrName){
    _aspxResetAttributeExtended(obj, attrName, obj, "saved" + attrName);
}
function _aspxResetStyleAttribute(obj, attrName){
    _aspxResetAttributeExtended(obj.style, attrName, obj, "saved" + attrName);
}
function _aspxRestoreAttributeExtended(obj, attrName, savedObj, savedAttrName){
    if(_aspxIsExistsAttribute(savedObj, savedAttrName)){
        var oldValue = _aspxGetAttribute(savedObj, savedAttrName);
        if(oldValue != __aspxEmptyAttributeValue)
            _aspxSetAttribute(obj, attrName, oldValue);
        else
            _aspxRemoveAttribute(obj, attrName);
        _aspxRemoveAttribute(savedObj, savedAttrName);
    }
}
function _aspxRestoreAttribute(obj, attrName){
    _aspxRestoreAttributeExtended(obj, attrName, obj, "saved" + attrName);
}
function _aspxRestoreStyleAttribute(obj, attrName){
    _aspxRestoreAttributeExtended(obj.style, attrName, obj, "saved" + attrName);
}
// String Utils
function _aspxLTrim(value) {	
    var re = /\s*((\S+\s*)*)/;
    return value.replace(re, "$1");	
}
function _aspxRTrim(value) {	
    var re = /((\s*\S+)*)\s*/;
    return value.replace(re, "$1");	
}
function _aspxTrim(value) {	
    return _aspxLTrim(_aspxRTrim(value));	
}
//Url utils
function _aspxNavigateUrl(url, target) {
    var javascriptPrefix = "javascript:";
	if(url == "")
		return;
	else if(url.indexOf(javascriptPrefix) != -1) 
	    eval(url.substr(javascriptPrefix.length));
	else {
		if(target != "") {
			if(_aspxIsSpecialTarget(target))
				_aspxNavigateSpecialTarget(url, target);
			else {
				var frame = _aspxGetFrame(top.frames, target);
				if(frame != null)
					frame.location.href = url; 
			}
		}
		else
		    location.href = url;
	}
}
function _aspxIsSpecialTarget(target) {
	var targets = ["_blank", "_media", "_parent", "_search", "_self", "_top"];
	return _aspxArrayIndexOf(targets, target.toLowerCase()) > -1;
}
function _aspxNavigateSpecialTarget(url, target) {
	target = target.toLowerCase();
	if("_top" == target)
		top.location.href = url;
	else if("_self" == target)
		location.href = url;
	else if("_search" == target)
		window.open(url, 'blank');
	else if("_media" == target)
		window.open(url, 'blank');
	else if("_parent" == target)
		window.parent.location.href = url;
	else if("_blank" == target)
		window.open(url, 'blank');
}
function _aspxGetFrame(frames, name) {
	for(var i = 0; i < frames.length; i++) {
	    try {
		    var frame = frames[i];
		    if(frame.name == name) 
		        return frame;	

		    frame = _aspxGetFrame(frame.frames, name);
		    if(frame != null)   
		        return frame;	
	    }
		catch(e) {
		}	
	}
	return null;
}

// Callbacks
function _aspxIsValidElement(element){
   if(__aspxIE)
        return _aspxIsExists(element.parentNode) && _aspxIsExists(element.parentNode.tagName);
    else{
        if(element.offsetParent != null)
            return true;
        while(element != null){
            if(_aspxIsExists(element.tagName) && element.tagName == "BODY")
                return true;
            element = element.parentNode;
        }
        return false;
    }
}
function _aspxIsValidElements(elements){
    if (!_aspxIsExists(elements)) return false;    
    for(var i = 0; i < elements.length; i ++){
        if(_aspxIsExists(elements[i]) && !_aspxIsValidElement(elements[i]))
            return false;
    }
    return true;
}
function _aspxIsExistsElement(element){
    return _aspxIsExists(element) && _aspxIsValidElement(element);
}
// event
ASPxClientEvent = _aspxCreateClass(null, {
    constructor: function(){
	    this.handlerList = [];
	},
	AddHandler: function (handler) {
		_aspxArrayPush(this.handlerList, handler);
	},
	RemoveHandler: function (handler) {
	    _aspxArrayRemove(this.handlerList, handler);
	},
	ClearHandlers: function () {
	    _aspxArrayClear(this.handlerList);
	},
	FireEvent: function (obj, args) {
		for(var i = 0; i < this.handlerList.length; i ++)
			this.handlerList[i](obj, args);
	},
    IsEmpty: function () {
		return (this.handlerList.length == 0);
	}
});

ASPxClientCollection = _aspxCreateClass(null, {
    constructor: function(){
	    this.elements = new Object();
	},
	
	Add: function(element){
		this.elements[element.name] = element;
	},
	Get: function(name){
	    return this.elements[name];
	},
	
	// controls group operations
	AdjustControlsSize: function(container, checkSizeCorrectedFlag) {
	    this.ProcessControlsInConatiner(container, checkSizeCorrectedFlag, function(control, check) {
	        control.CorrectSize(check);
	    });
	},
	CollapseControls: function(container, checkSizeCorrectedFlag) {
	    this.ProcessControlsInConatiner(container, checkSizeCorrectedFlag, function(control, check) {
	        control.CollapseControl(check);
	    });
	},
	
	AtlasInitialize: function(){
	    _aspxProcessScripts();
	    _aspxProcessLinks();
	},
	Initialize: function(){
	    this.InitializeElements();
	    if(_aspxIsExistsType(typeof(Sys)) && _aspxIsExistsType(typeof(Sys.Application)))
            Sys.Application.add_load(aspxCAInit);
	},
	InitializeElements: function(){
        for(var name in this.elements) {
            var control = this.elements[name];
            if(!ASPxClientControl.prototype.isPrototypeOf(control)) continue;
            
            if (!control.isInitialized)
                control.Initialize();
	    }
	    this.AfterInitializeElements(true);
	    this.AfterInitializeElements(false);
	},
	AfterInitializeElements: function(leadingCall) {
	    for(var name in this.elements){
            var control = this.elements[name];
            if(!ASPxClientControl.prototype.isPrototypeOf(control)) continue;
            
	        if (control.leadingAfterInitCall && leadingCall || !control.leadingAfterInitCall && !leadingCall) {
                if(!this.elements[name].isInitialized)
                    this.elements[name].AfterInitialize();
	        }
	    }
	},
	ProcessControlsInConatiner: function(container, checkSizeCorrectedFlag, processingProc) {
	    for (var controlName in this.elements) {
	        var control = this.elements[controlName];
	        if(!ASPxClientControl.prototype.isPrototypeOf(control)) continue;
	        
	        if (_aspxIsExists(container) && _aspxIsExists(control.GetMainElement)) {
	            var mainElement = control.GetMainElement();
	            if (_aspxIsExists(mainElement) && !_aspxGetIsParent(container, mainElement))
	                continue;
	        }
	        processingProc(control, checkSizeCorrectedFlag);
	    }
	}
});
// control
ASPxClientControl = _aspxCreateClass(null, {
    constructor: function(name){
        this.name = name;
        this.uniqueID = name;

        this.autoPostBack = false;
        this.callBack = null;
        this.allowMultipleCallbacks = true;
        this.requestCount = 0;

        this.isInitialized = false;
        this.leadingAfterInitCall = false; // AfterInitialize call will be displaced to the begining of call queue
        this.sizeCorrectedOnce = false;
        this.serverEvents = [];
        
        this.sizeCorrectedOnce = false;
        
        this.mainElement = null;
        this.renderIFrameForPopupElements = false;
        
        this.Init = new ASPxClientEvent();
        this.BeginCallback = new ASPxClientEvent();
        this.EndCallback = new ASPxClientEvent();
        
        aspxGetControlCollection().Add(this);        
    },
    Initialize: function(){
        if(this.callBack != null)
            this.InitializeCallBackData();
    },
    AfterInitialize: function(){
        this.CorrectSize(__aspxCheckSizeCorrectedFlag);
        this.isInitialized = true;
        if(_aspxIsExists(this.RaiseInit))
            this.RaiseInit();
    },
    InitializeCallBackData: function(){
    },
    
    // Size correction
    CollapseControl: function(checkSizeCorrectedFlag) {
    
    },
    IsVisibleWhenCorrectingSize: function() {
        return this.IsVisible();
    },
    CorrectSize: function(checkSizeCorrectedFlag) {
        if (checkSizeCorrectedFlag && this.sizeCorrectedOnce)
            return;
        var mainElement = this.GetMainElement();
        if (!_aspxIsExists(mainElement) || !this.IsVisibleWhenCorrectingSize())
            return;
        this.CorrectSizeCore();
        this.sizeCorrectedOnce = true;
    },
    CorrectSizeCore: function() {

    },
    
    RegisterServerEventAssigned: function(eventNames){
        for(var i = 0; i < eventNames.length; i++)
            this.serverEvents[eventNames[i]] = true;
    },
    IsServerEventAssigned: function(eventName){
        return _aspxIsExists(this.serverEvents[eventName]);
    },
    
    GetChild: function(idPostfix){
        var mainElement = this.GetMainElement();
        return _aspxIsExists(mainElement) ? _aspxGetChildById(this.GetMainElement(), this.name + idPostfix) : null;
    },
    GetItemElementName: function(element) {
        var name = "";
        if (_aspxIsExists(element.id))
            name = element.id.substring(this.name.length + 1);
        return name;
    },
    GetLinkElement: function(element) {
        if (element != null) {
            if (element.tagName.toUpperCase() == "A")
                return element;
            else
                return _aspxGetChildByTagName(element, "A", 0);
        }
        return null;
    },
    GetMainElement: function(){
        if(!_aspxIsExistsElement(this.mainElement))
            this.mainElement = _aspxGetElementById(this.name);
        return this.mainElement;
    },

    OnControlClick: function(clickedElement, htmlEvent) {
    },
    // CallBack
    GetLoadingPanelElement: function(){
        return _aspxGetElementById(this.name + "_LP");
    },
    CreateLoadingPanelClone: function(element, parentElement){
        var cloneElement = element.cloneNode(true);
        cloneElement.id = element.id + "V";
        parentElement.appendChild(cloneElement);
        return cloneElement;
    },
    CreateLoadingPanelInsideContainer: function(parentElement){
        if(parentElement == null) return;
        
        var element = this.GetLoadingPanelElement();
        if (element != null){
            var itemsTable = _aspxGetChildByTagName(parentElement, "TABLE", 0);
            var width = (itemsTable != null) ? itemsTable.offsetWidth : parentElement.clientWidth;
            var height = (itemsTable != null) ? itemsTable.offsetHeight : parentElement.clientHeight;
            parentElement.innerHTML = "";
            
            var table = document.createElement("TABLE");
            parentElement.appendChild(table);
            table.border = 0;
            table.cellPadding = 0;
            table.cellSpacing = 0;
            table.style.height = height + "px";
            table.style.width = width + "px";
            var tbody = document.createElement("TBODY");
            table.appendChild(tbody);
            var tr = document.createElement("TR");
            tbody.appendChild(tr);
            var td = document.createElement("TD");
            tr.appendChild(td);
            td.align = "center";
            td.vAlign = "middle";
            
            element = this.CreateLoadingPanelClone(element, td);
            _aspxSetElementDisplay(element, true);
            return element;
        }
        else
            parentElement.innerHTML = "&nbsp;";
        return null;
    },
    CreateLoadingPanelWithAbsolutePosition: function(parentElement, offsetElement){
        if(parentElement == null) return;
        
        if(!_aspxIsExists(offsetElement))
            offsetElement = parentElement;
        var element = this.GetLoadingPanelElement();
        if(element != null){
            element = this.CreateLoadingPanelClone(element, parentElement);
            element.style.position = "absolute";
            _aspxSetElementDisplay(element, true);
            this.SetLoadingPanelLocation(offsetElement, element);
            return element;
        }
        return null;
    },
    CreateLoadingPanelInline: function(parentElement){
        if(parentElement == null) return;

        var element = this.GetLoadingPanelElement();
        if(element != null){
            element = this.CreateLoadingPanelClone(element, parentElement);
            _aspxSetElementDisplay(element, true);
            return element;
        }
        return null;
    },
    SetLoadingPanelLocation: function(element, loadingPanel) {
        var ptX = this.GetElementScrollLocationAndSize(_aspxGetAbsoluteX(element), element.offsetWidth, _aspxGetDocumentScrollLeft(), _aspxGetDocumentClientWidth());
        var ptY = this.GetElementScrollLocationAndSize(_aspxGetAbsoluteY(element), element.offsetHeight, _aspxGetDocumentScrollTop(), _aspxGetDocumentClientHeight());
        
        loadingPanel.style.left = ptX.pos + ((ptX.size - loadingPanel.offsetWidth) / 2) - _aspxGetOffset(element, true) + "px";
        loadingPanel.style.top = ptY.pos +((ptY.size - loadingPanel.offsetHeight) / 2) - _aspxGetOffset(element, false) + "px";
    },
    GetElementScrollLocationAndSize: function(abs, size, scrollPos, scrollSize) {
        var pt = new Object();
        pt.pos = abs;
        pt.size = size;
        if(abs < scrollPos + scrollSize) {
            if(abs < scrollPos) {
                pt.pos = scrollPos;
                pt.size -= scrollPos - abs;
            }
            if(pt.size + pt.pos > scrollPos + scrollSize) {
                pt.size = scrollSize - (pt.pos - scrollPos);
            }
        }
        return pt;
    },
    GetLoadingDiv: function(){
        return _aspxGetElementById(this.name + "_LD");
    },
    CreateLoadingDiv: function(parentElement, offsetElement){
        if(parentElement == null) return;
    
        if(!_aspxIsExists(offsetElement))
            offsetElement = parentElement;
        var div = this.GetLoadingDiv();
        if(div != null){
            div = div.cloneNode(true);
            parentElement.appendChild(div);
            div.style.position = "absolute";
            div.style.left = _aspxGetRelevantX(offsetElement, parentElement) + "px";
            div.style.top = _aspxGetRelevantY(offsetElement, parentElement) + "px";
            div.style.width = offsetElement.offsetWidth + "px";
            div.style.height = offsetElement.offsetHeight + "px";
            _aspxSetElementDisplay(div, true);
            return div;
        }
        return null;
    },
    // visibility & display check
    IsVisible: function() {
        var element = this.GetMainElement();
        while(_aspxIsExists(element) && element.tagName != "BODY") {
            if (!_aspxGetElementVisibility(element) || !_aspxGetElementDisplay(element))
                return false;
            element = element.parentNode;
        }
        return true;
    },
    // display check
    IsDisplayed: function(){
        var element = this.GetMainElement();
        while(_aspxIsExists(element) && element.tagName != "BODY") {
            if(!_aspxGetElementDisplay(element)) 
                return false;
            element = element.parentNode;
        }
        return true;
    },        
    InCallback: function() {
        return this.requestCount > 0;
    },
    DoBeginCallback: function(command) {
        if (_aspxIsExists(this.RaiseBeginCallback)) {
            if(!_aspxIsExists(command)) {
                command = "";
            }
            this.RaiseBeginCallback(command);    
        }
	    if(_aspxIsExists(WebForm_InitCallback)) {
	        __theFormPostData = "";
            __theFormPostCollection = new Array();
            this.ClearPostBackEventInput("__EVENTTARGET");
            this.ClearPostBackEventInput("__EVENTARGUMENT");
            WebForm_InitCallback();
        }
    },
    ClearPostBackEventInput: function(id){
        var element = _aspxGetElementById(id);
        if(element != null) element.value = "";
    },
    CreateCallback: function(arg, command) {
        if(!this.CanCreateCallback()) 
            return;
        
        this.requestCount++;
        this.DoBeginCallback(command);
        this.callBack(arg);    
    },
    CanCreateCallback: function() {
        return this.allowMultipleCallbacks || !this.InCallback();
    },
    DoEndCallback: function(){
        _aspxSetTimeout(_aspxProcessScripts, 1);
        
        if (_aspxIsExists(this.RaiseEndCallback))
            this.RaiseEndCallback();        
    },
    DoCallback: function(result){
        this.requestCount--;
        if(result.indexOf(__aspxCallBackErrorPrefix) > -1)
            this.DoCallbackError(result);
        else {            
            this.OnCallback(result);
        }        
        this.DoEndCallback();
    },
    DoCallbackError: function(result){
        var pos = result.indexOf(__aspxCallBackErrorPrefix);
        if(pos > -1) 
            result = result.substr(pos + __aspxCallBackErrorPrefix.length);
        else
            result = "A server error has occurred while a callBack has being processed on the server.";
        this.OnCallbackError(result);
    },
    DoControlClick: function(evt){
        var clickedElement = __aspxIE ? evt.srcElement : evt.target;
        this.OnControlClick(clickedElement, evt);
    },
    OnCallback: function(result){
    },    
    OnCallbackError: function(result){
    },
    SendPostBack: function(params){
        __doPostBack(this.uniqueID, params);
    }
});

var __aspxControlCollection = null;
function aspxGetControlCollection(){
    if(__aspxControlCollection == null)
        __aspxControlCollection = new ASPxClientCollection();
    return __aspxControlCollection;
}

function aspxCAInit(){
    aspxGetControlCollection().AtlasInitialize();
}
function aspxCallback(result, context){
    var control = aspxGetControlCollection().Get(context);
    if(control != null)
        control.DoCallback(result);
}
function aspxCallbackError(result, context){
    var control = aspxGetControlCollection().Get(context);
    if(control != null)
        control.DoCallbackError(result);    
}

function aspxCClick(name, evt) {
    var control = aspxGetControlCollection().Get(name);
    if(control != null) control.DoControlClick(evt);
}

//StateController
var __aspxHoverStyleSheet = null;
var __aspxPressedStyleSheet = null;
var __aspxSelectedStyleSheet = null;
var __aspxDisabledStyleSheet = null;
var __aspxHoverItemKind = "HoverStateItem";
var __aspxPressedItemKind = "PressedStateItem";
var __aspxSelectedItemKind = "SelectedStateItem";
var __aspxDisabledItemKind = "DisabledStateItem";
var __aspxStyleCount = 0;

ASPxStateItem = _aspxCreateClass(null, {
    constructor: function(name, className, cssText, postfixes, imageUrls, imagePostfixes, kind){
        this.name = name;
        this.className = className;
        this.customClassName = "";
        this.resultClassName = "";
        this.cssText = cssText;
        this.postfixes = postfixes;
        this.imageUrls = imageUrls;
        this.imagePostfixes = imagePostfixes;
        this.kind = kind;
        this.enabled = true;
        
        this.elements = null;
        this.images = null;
        this.linkColor = null;
        this.lintTextDecoration = null;
    },
    
    CreateStyleRule: function(){
        if(this.cssText != ""){
            var styleSheet = this.GetStyleSheet();
            if(_aspxIsExists(styleSheet)){
                var cssText = "";
                var attributes = this.cssText.split(";");
                for(var i = 0; i < attributes.length; i++){
                    if(attributes[i] != "")
                        cssText += attributes[i] + " !important;";
                }
                var className = "dxh" + __aspxStyleCount;
                _aspxAddStyleSheetRule(styleSheet, "." + className, cssText);
                __aspxStyleCount++;
                return className;
            }
        }
        return "";
    },
    GetResultClassName: function(){
        if(this.resultClassName == ""){
            if(this.customClassName == "")
                this.customClassName = this.CreateStyleRule();
            if(this.className != "" && this.customClassName != "")
                this.resultClassName = this.className + " " + this.customClassName;
            else if(this.className != "")
                this.resultClassName = this.className;
            else if(this.customClassName != "")
                this.resultClassName = this.customClassName;
        }
        return this.resultClassName;
    },
    GetStyleSheet: function(){
        if(!_aspxIsExists(__aspxDisabledStyleSheet))
            __aspxDisabledStyleSheet = _aspxCreateStyleSheet();
        if(!_aspxIsExists(__aspxSelectedStyleSheet))
            __aspxSelectedStyleSheet = _aspxCreateStyleSheet();
        if(!_aspxIsExists(__aspxHoverStyleSheet))
            __aspxHoverStyleSheet = _aspxCreateStyleSheet();
        if(!_aspxIsExists(__aspxPressedStyleSheet))
            __aspxPressedStyleSheet = _aspxCreateStyleSheet();
        switch(this.kind){
            case __aspxDisabledItemKind:
                return __aspxDisabledStyleSheet;
            case __aspxHoverItemKind:
                return __aspxHoverStyleSheet;
            case __aspxPressedItemKind:
                return __aspxPressedStyleSheet;
            case __aspxSelectedItemKind:
                return __aspxSelectedStyleSheet;
        }
        return null;
    },
    GetElements: function(element){
        if(!_aspxIsExists(this.elements) || !_aspxIsValidElements(this.elements)){
            if(_aspxIsExists(this.postfixes) && this.postfixes.length > 0){
                this.elements = new Array();
                var parentNode = _aspxGetParentNode(element);
                if(_aspxIsExists(parentNode)){
                    for(var i = 0; i < this.postfixes.length; i++){
                        var id = this.name + this.postfixes[i];
                        this.elements[i] = _aspxGetChildById(parentNode, id);
                    }
                }
            }
            else
                this.elements = [element];
        }
        return this.elements;
    },
    GetImages: function(element){
        if(!_aspxIsExists(this.images) || !_aspxIsValidElements(this.images)){
            this.images = new Array();
            if(_aspxIsExists(this.imagePostfixes) && this.imagePostfixes.length > 0){
                var elements = this.GetElements(element);
                for(var i = 0; i < this.imagePostfixes.length; i++){
                    var id = this.name + this.imagePostfixes[i];
                    for(var j = 0; j < elements.length; j++){
                        if(!_aspxIsExists(elements[j])) continue;
                        
                        this.images[i] = _aspxGetChildById(elements[j], id);
                        if(_aspxIsExists(this.images[i]))
                            break;
                    }
                }
            }
        }
        return this.images;
    },
    
    Apply: function(element){        
        this.ApplyStyle(element);
        if(_aspxIsExists(this.imageUrls) && this.imageUrls.length > 0)
            this.ApplyImage(element);
    },
    ApplyStyle: function(element){
        var elements = this.GetElements(element);
        for(var i = 0; i < elements.length; i++){
            if(!_aspxIsExists(elements[i])) continue;

            var className = elements[i].className.replace(this.GetResultClassName(), "");
            elements[i].className = _aspxTrim(className) + " " + this.GetResultClassName();
            if(!__aspxOpera || __aspxOpera9)
                this.ApplyStyleToLinks(elements, i);
        }
    },
    ApplyStyleToLinks: function(elements, index){
        var linkCount = 0;
        var savedLinkCount = -1;
        if(_aspxIsExists(elements[index]["savedLinkCount"]))
            savedLinkCount = parseInt(elements[index]["savedLinkCount"]);
        do{
            if(savedLinkCount > -1 && savedLinkCount <= linkCount)
                break;
            var link = elements[index]["link" + linkCount];
            if(!_aspxIsExists(link)){
                link = _aspxGetChildByTagName(elements[index], "A", linkCount);
                if(_aspxIsExists(link))
                    elements[index]["link" + linkCount] = link;
            }
            if(_aspxIsExists(link))
                this.ApplyStyleToLinkElement(link);
            else
                elements[index]["savedLinkCount"] = linkCount;
            linkCount++;
        }
        while(link != null)
    },
    ApplyStyleToLinkElement: function(link){
        if(this.GetLinkColor() != "")
            _aspxChangeAttributeExtended(link.style, "color", link, "saved" + this.kind + "Color", this.GetLinkColor());
        if(this.GetLinkTextDecoration() != "")
            _aspxChangeAttributeExtended(link.style, "textDecoration", link, "saved" + this.kind + "TextDecoration", this.GetLinkTextDecoration());
    },
    ApplyImage: function(element){
        var images = this.GetImages(element);
        for(var i = 0; i < images.length; i++){
            if(!_aspxIsExists(images[i]) || !_aspxIsExists(this.imageUrls[i]) || this.imageUrls[i] == "") continue;
            if(_aspxIsAlphaFilterUsed(images[i]))            
                _aspxChangeAttributeExtended(images[i].style, "filter", images[i], "saved" + this.kind + "Filter", 
                    "progid:DXImageTransform.Microsoft.AlphaImageLoader(src=" + this.imageUrls[i] + ", sizingMethod=scale)");                
            else
                _aspxChangeAttributeExtended(images[i], "src", images[i], "saved" + this.kind + "Src", this.imageUrls[i]);
        }
    },
    Cancel: function(element){
        this.CancelStyle(element);
        if(_aspxIsExists(this.imageUrls) && this.imageUrls.length > 0)
            this.CancelImage(element);
    },
    CancelStyle: function(element){
        var elements = this.GetElements(element);
        for(var i = 0; i < elements.length; i++){
            if(!_aspxIsExists(elements[i])) continue;
            
            var className = _aspxTrim(elements[i].className.replace(this.GetResultClassName(), ""));
            elements[i].className = className;
            if(!__aspxOpera || __aspxOpera9)
                this.CancelStyleFromLinks(elements, i);
        }
    },
    CancelStyleFromLinks: function(elements, index){
        var linkCount = 0;
        var savedLinkCount = -1;
        if(_aspxIsExists(elements[index]["savedLinkCount"]))
            savedLinkCount = parseInt(elements[index]["savedLinkCount"]);
        do{
            if(savedLinkCount > -1 && savedLinkCount <= linkCount)
                break;
            var link = elements[index]["link" + linkCount];
            if(!_aspxIsExists(link)){
                link = _aspxGetChildByTagName(elements[index], "A", linkCount);
                if(_aspxIsExists(link))
                    elements[index]["link" + linkCount] = link;
            }
            if(_aspxIsExists(link))
                this.CancelStyleFromLinkElement(link);
            else
                elements[index]["savedLinkCount"] = linkCount;
            linkCount++;
        }
        while(link != null)
    },
    CancelStyleFromLinkElement: function(link){
        if(this.GetLinkColor() != "")
            _aspxRestoreAttributeExtended(link.style, "color", link, "saved" + this.kind + "Color");
        if(this.GetLinkTextDecoration() != "")
            _aspxRestoreAttributeExtended(link.style, "textDecoration", link, "saved" + this.kind + "TextDecoration");
    },
    CancelImage: function(element){
        var images = this.GetImages(element);
        for(var i = 0; i < images.length; i++){
            if(!_aspxIsExists(images[i]) || !_aspxIsExists(this.imageUrls[i]) || this.imageUrls[i] == "") continue;
            if(_aspxIsAlphaFilterUsed(images[i]))
                _aspxRestoreAttributeExtended(images[i].style, "filter", images[i], "saved" + this.kind + "Filter");
            else
                _aspxRestoreAttributeExtended(images[i], "src", images[i], "saved" + this.kind + "Src");
        }
    },
    Clone: function(){
        return new ASPxStateItem(this.name, this.className, this.cssText, this.postfixes, 
            this.imageUrls, this.imagePostfixes, this.kind);
    },
    
    GetLinkColor: function(){
        if(!_aspxIsExists(this.linkColor)){
            var rule = _aspxGetStyleSheetRule(this.customClassName);
            this.linkColor = _aspxIsExists(rule) ? rule.style.color : null;
            if(!_aspxIsExists(this.linkColor)){
                var rule = _aspxGetStyleSheetRule(this.className);
                this.linkColor = _aspxIsExists(rule) ? rule.style.color : null;
            }
            if(this.linkColor == null) 
                this.linkColor = "";
        }
        return this.linkColor;
    },
    GetLinkTextDecoration: function(){
        if(!_aspxIsExists(this.linkTextDecoration)){
            var rule = _aspxGetStyleSheetRule(this.customClassName);
            this.linkTextDecoration = _aspxIsExists(rule) ? rule.style.textDecoration : null;
            if(!_aspxIsExists(this.linkTextDecoration)){
                var rule = _aspxGetStyleSheetRule(this.className);
                this.linkTextDecoration = _aspxIsExists(rule) ? rule.style.textDecoration : null;
            }
            if(this.linkTextDecoration == null) 
                this.linkTextDecoration = "";
        }
        return this.linkTextDecoration;
    }
});

ASPxClientStateEventArgs = _aspxCreateClass(null, {
    constructor: function(item, element){
        this.item = item;
        this.element = element;
    }
});

ASPxStateController = _aspxCreateClass(null, {
    constructor: function(){
        this.hoverItems = new Object();
        this.pressedItems = new Object();
        this.selectedItems = new Object();
        this.disabledItems = new Object();
        
        this.currentHoverElement = null;
        this.currentHoverItemName = null;
        this.currentPressedElement = null;
        this.currentPressedItemName = null;
        this.savedCurrentPressedElement = null;
        this.savedCurrentMouseMoveSrcElement = null;
        
        this.AfterSetHoverState = new ASPxClientEvent();
        this.AfterClearHoverState = new ASPxClientEvent();
        this.AfterSetPressedState = new ASPxClientEvent();
        this.AfterClearPressedState = new ASPxClientEvent();
        this.AfterDisabled = new ASPxClientEvent();
        this.AfterEnabled = new ASPxClientEvent();
        this.BeforeSetHoverState = new ASPxClientEvent();
        this.BeforeClearHoverState = new ASPxClientEvent();
        this.BeforeSetPressedState = new ASPxClientEvent();
        this.BeforeClearPressedState = new ASPxClientEvent();
        this.BeforeDisabled = new ASPxClientEvent();
        this.BeforeEnabled = new ASPxClientEvent();
    },    
    AddHoverItem: function(name, className, cssText, postfixes, imageUrls, imagePostfixes){
        this.AddItem(this.hoverItems, name, className, cssText, postfixes, imageUrls, imagePostfixes, __aspxHoverItemKind);
    },
    AddPressedItem: function(name, className, cssText, postfixes, imageUrls, imagePostfixes){
        this.AddItem(this.pressedItems, name, className, cssText, postfixes, imageUrls, imagePostfixes, __aspxPressedItemKind);
    },
    AddSelectedItem: function(name, className, cssText, postfixes, imageUrls, imagePostfixes){
        this.AddItem(this.selectedItems, name, className, cssText, postfixes, imageUrls, imagePostfixes, __aspxSelectedItemKind);
    },
    AddDisabledItem: function(name, className, cssText, postfixes, imageUrls, imagePostfixes){
        this.AddItem(this.disabledItems, name, className, cssText, postfixes, imageUrls, imagePostfixes, __aspxDisabledItemKind);
    },
    AddItem: function(items, name, className, cssText, postfixes, imageUrls, imagePostfixes, kind){
        if(_aspxIsExists(postfixes) && postfixes.length > 0){
            for(var i = 0; i < postfixes.length; i ++){
                var elementName = name + postfixes[i];
                items[elementName] = new ASPxStateItem(name, className, cssText, postfixes, imageUrls, imagePostfixes, kind);
            }
        }
        else
            items[name] = new ASPxStateItem(name, className, cssText, postfixes, imageUrls, imagePostfixes, kind);
    },
    
    GetHoverElement: function(srcElement){
        return this.GetItemElement(srcElement, this.hoverItems, __aspxHoverItemKind);
    },
    GetPressedElement: function(srcElement){
        return this.GetItemElement(srcElement, this.pressedItems, __aspxPressedItemKind);
    },
    GetSelectedElement: function(srcElement){
        return this.GetItemElement(srcElement, this.selectedItems, __aspxSelectedItemKind);
    },
    GetDisabledElement: function(srcElement){
        return this.GetItemElement(srcElement, this.disabledItems, __aspxDisabledItemKind);
    },
    GetItemElement: function(srcElement, items, kind){
        if(_aspxIsExists(srcElement) && _aspxIsExists(srcElement["cached" + kind])){
            var cachedElement = srcElement["cached" + kind];
            if(cachedElement != __aspxEmptyCachedValue && cachedElement[kind].enabled)
                return cachedElement;
            return null;
        }
        
        var element = srcElement;
        while(element != null) {
            var item = items[element.id];
            if(_aspxIsExists(item)){
                srcElement["cached" + kind] = element;
                element[kind] = item;
                return item.enabled ? element : null;
            }
            element = _aspxGetParentNode(element);
        }
        if(_aspxIsExists(srcElement))
            srcElement["cached" + kind] = __aspxEmptyCachedValue;
        return null;
    },
    
    DoSetHoverState: function(element){
        var item = element[__aspxHoverItemKind];
        if(_aspxIsExists(item)){
            var args = new ASPxClientStateEventArgs(item, element);
            this.BeforeSetHoverState.FireEvent(this, args);
            item.Apply(element);
            this.AfterSetHoverState.FireEvent(this, args);
        }
    },
    DoClearHoverState: function(element){
        var item = element[__aspxHoverItemKind];
        if(_aspxIsExists(item)){
            var args = new ASPxClientStateEventArgs(item, element);
            this.BeforeClearHoverState.FireEvent(this, args);
            item.Cancel(element);
            this.AfterClearHoverState.FireEvent(this, args);
        }
    },
    DoSetPressedState: function(element){
        var item = element[__aspxPressedItemKind];
        if(_aspxIsExists(item)){
            var args = new ASPxClientStateEventArgs(item, element);
            this.BeforeSetPressedState.FireEvent(this, args);
            item.Apply(element);
            this.AfterSetPressedState.FireEvent(this, args);
        }
    },
    DoClearPressedState: function(element){
        var item = element[__aspxPressedItemKind];
        if(_aspxIsExists(item)){
            var args = new ASPxClientStateEventArgs(item, element);
            this.BeforeClearPressedState.FireEvent(this, args);
            item.Cancel(element);
            this.AfterClearPressedState.FireEvent(this, args);
        }
    },
    SetCurrentHoverElement: function(element){
        if(_aspxIsExists(this.currentHoverElement) && !_aspxIsValidElement(this.currentHoverElement)){
            this.currentHoverElement = null;
            this.currentHoverItemName = "";
        }
        if(this.currentHoverElement != element){
            var item = (element != null) ? element[__aspxHoverItemKind] : null;
            var itemName = (item != null) ? item.name : "";
            if(this.currentHoverItemName != itemName){
                if(this.currentHoverElement != null)
                    this.DoClearHoverState(this.currentHoverElement);
                this.currentHoverElement = element;
                item = (element != null) ? element[__aspxHoverItemKind] : null;
                this.currentHoverItemName = (item != null) ? item.name : "";
                if(this.currentHoverElement != null)
                    this.DoSetHoverState(this.currentHoverElement);
            }
        }
    },
    SetCurrentPressedElement: function(element){
        if(_aspxIsExists(this.currentPressedElement) && !_aspxIsValidElement(this.currentPressedElement)){
            this.currentPressedElement = null;
            this.currentPressedItemName = "";
        }
            
        if(this.currentPressedElement != element){
            if(this.currentPressedElement != null)
                this.DoClearPressedState(this.currentPressedElement);
            this.currentPressedElement = element;
            var item = (element != null) ? element[__aspxPressedItemKind] : null;
            this.currentPressedItemName = (item != null) ? item.name : "";
            if(this.currentPressedElement != null)
                this.DoSetPressedState(this.currentPressedElement);
        }
    },
    SetCurrentHoverElementBySrcElement: function(srcElement){
        var element = this.GetHoverElement(srcElement);
        this.SetCurrentHoverElement(element);
    },
    SetCurrentPressedElementBySrcElement: function(srcElement){
        var element = this.GetPressedElement(srcElement);
        this.SetCurrentPressedElement(element);
    },
    SelectElement: function(element){
        var item = element[__aspxSelectedItemKind];
        if(_aspxIsExists(item))
            item.Apply(element);
    },    
    SelectElementBySrcElement: function(srcElement){
        var element = this.GetSelectedElement(srcElement);
        if(element != null) this.SelectElement(element);
    },    
    DeselectElement: function(element){
        var item = element[__aspxSelectedItemKind];
        if(_aspxIsExists(item))
            item.Cancel(element);
    },    
    DeselectElementBySrcElement: function(srcElement){
        var element = this.GetSelectedElement(srcElement);
        if(element != null) this.DeselectElement(element);
    },
    DisableElement: function(element){
        var element = this.GetDisabledElement(element);
        if(element != null) {
            var item = element[__aspxDisabledItemKind];
            if(_aspxIsExists(item)){
                var args = new ASPxClientStateEventArgs(item, element);
                this.BeforeDisabled.FireEvent(this, args);
                if(item.name == this.currentPressedItemName)
                    this.SetCurrentPressedElement(null);
                if(item.name == this.currentHoverItemName)
                    this.SetCurrentHoverElement(null);
                item.Apply(element);
                this.SetMouseStateItemsEnabled(item.name, item.postfixes, false);
                this.AfterDisabled.FireEvent(this, args);
            }
        }
    },    
    EnableElement: function(element){
        var element = this.GetDisabledElement(element);
        if(element != null) {
            var item = element[__aspxDisabledItemKind];
            if(_aspxIsExists(item)){
                var args = new ASPxClientStateEventArgs(item, element);
                this.BeforeEnabled.FireEvent(this, args);
                item.Cancel(element);
                this.SetMouseStateItemsEnabled(item.name, item.postfixes, true);
                this.AfterEnabled.FireEvent(this, args);
            }
        }
    },    
    SetMouseStateItemsEnabled: function(name, postfixes, enabled){   
        if(_aspxIsExists(postfixes) && postfixes.length > 0){
            for(var i = 0; i < postfixes.length; i ++){
                this.SetItemsEnabled(this.hoverItems, name + postfixes[i], enabled);
                this.SetItemsEnabled(this.pressedItems, name + postfixes[i], enabled);
            }
        }
        else{
            this.SetItemsEnabled(this.hoverItems, name, enabled);
            this.SetItemsEnabled(this.pressedItems, name, enabled);
        }        
    },
    SetItemsEnabled: function(items, name, enabled){   
        if(_aspxIsExists(items[name])) items[name].enabled = enabled;
    },
    
    OnMouseMove: function(evt){
        var srcElement = _aspxGetEventSource(evt);
        if(srcElement == this.savedCurrentMouseMoveSrcElement) return;
        this.savedCurrentMouseMoveSrcElement = srcElement;
        
        if(__aspxIE && !_aspxGetIsLeftButtonPressed(evt) && this.savedCurrentPressedElement != null){
            this.savedCurrentPressedElement = null;
            this.SetCurrentPressedElement(null);
        }
             
        if(this.savedCurrentPressedElement == null)
            this.SetCurrentHoverElementBySrcElement(srcElement);
        else{
            var element = this.GetPressedElement(srcElement);
            if(element != this.currentPressedElement){
                if(element == this.savedCurrentPressedElement)
                    this.SetCurrentPressedElement(this.savedCurrentPressedElement);
                else
                    this.SetCurrentPressedElement(null);
            }
        }
    },
    OnMouseDown: function(evt){
        if(!_aspxGetIsLeftButtonPressed(evt)) return;
        var srcElement = _aspxGetEventSource(evt);
        this.OnMouseDownOnElement(srcElement);
    },
    OnMouseDownOnElement: function(element){
        if(this.GetPressedElement(element) == null) return;
        
        this.SetCurrentHoverElement(null);
        this.SetCurrentPressedElementBySrcElement(element);
        this.savedCurrentPressedElement = this.currentPressedElement;
    },
    OnMouseUp: function(evt){
        var srcElement = _aspxGetEventSource(evt);
        this.OnMouseUpOnElement(srcElement);
    },
    OnMouseUpOnElement: function(element){
        if(this.savedCurrentPressedElement == null) return;
        this.savedCurrentPressedElement = null;
        this.SetCurrentPressedElement(null);
        this.SetCurrentHoverElementBySrcElement(element);
    },
    OnMouseOver: function(evt){
        var element = _aspxGetEventSource(evt);
        if (_aspxIsExists(element) && element.tagName == "IFRAME")
            this.OnMouseMove(evt);
    },
    OnSelectStart: function(evt){
        if ((this.savedCurrentPressedElement != null) && 
            (!_aspxIsExists(this.savedCurrentPressedElement.needClearSelection)))  {
            _aspxClearSelection();
            return false;
        }
    }
});

var __aspxStateController = null;
function aspxGetStateController(){
    if(__aspxStateController == null)
        __aspxStateController = new ASPxStateController();
    return __aspxStateController;
}

function aspxAddStateItems(method, namePrefix, classes){
    for(var i = 0; i < classes.length; i ++){
        for(var j = 0; j < classes[i][2].length; j ++) {
            var name = namePrefix;
            if(_aspxIsExists(classes[i][2][j]) && classes[i][2][j] != "")
                name += "_" + classes[i][2][j];
            var postfixes = _aspxIsExists(classes[i][3]) ? classes[i][3] : null;
            var imageUrls = _aspxIsExists(classes[i][4]) && _aspxIsExists(classes[i][4][j]) ? classes[i][4][j] : null;
            var imagePostfixes =  _aspxIsExists(classes[i][5]) ? classes[i][5] : null;
            method.call(aspxGetStateController(), name, classes[i][0], classes[i][1], postfixes, imageUrls, imagePostfixes);
        }
    }
}
function aspxAddHoverItems(namePrefix, classes){
    aspxAddStateItems(aspxGetStateController().AddHoverItem, namePrefix, classes);
}
function aspxAddPressedItems(namePrefix, classes){
    aspxAddStateItems(aspxGetStateController().AddPressedItem, namePrefix, classes);
}
function aspxAddSelectedItems(namePrefix, classes){
    aspxAddStateItems(aspxGetStateController().AddSelectedItem, namePrefix, classes);
}
function aspxAddDisabledItems(namePrefix, classes){
    aspxAddStateItems(aspxGetStateController().AddDisabledItem, namePrefix, classes);
}

function aspxAddAfterClearHoverState(handler){
    aspxGetStateController().AfterClearHoverState.AddHandler(handler);
}
function aspxAddAfterSetHoverState(handler){
    aspxGetStateController().AfterSetHoverState.AddHandler(handler);
}
function aspxAddAfterClearPressedState(handler){
    aspxGetStateController().AfterClearPressedState.AddHandler(handler);
}
function aspxAddAfterSetPressedState(handler){
    aspxGetStateController().AfterSetPressedState.AddHandler(handler);
}
function aspxAddAfterDisabled(handler){
    aspxGetStateController().AfterDisabled.AddHandler(handler);
}
function aspxAddAfterEnabled(handler){
    aspxGetStateController().AfterEnabled.AddHandler(handler);
}
function aspxAddBeforeClearHoverState(handler){
    aspxGetStateController().BeforeClearHoverState.AddHandler(handler);
}
function aspxAddBeforeSetHoverState(handler){
    aspxGetStateController().BeforeSetHoverState.AddHandler(handler);
}
function aspxAddBeforeClearPressedState(handler){
    aspxGetStateController().BeforeClearPressedState.AddHandler(handler);
}
function aspxAddBeforeSetPressedState(handler){
    aspxGetStateController().BeforeSetPressedState.AddHandler(handler);
}
function aspxAddBeforeDisabled(handler){
    aspxGetStateController().BeforeDisabled.AddHandler(handler);
}
function aspxAddBeforeEnabled(handler){
    aspxGetStateController().BeforeEnabled.AddHandler(handler);
}

_aspxAttachEventToElement(window, "load", aspxClassesWindowOnLoad);
function aspxClassesWindowOnLoad(evt){
	aspxGetControlCollection().Initialize();
	__aspxHTMLLoaded = true;
	_aspxInitializeScripts();
	window.setTimeout(_aspxProcessLinks, 1);
}

_aspxAttachEventToDocument("mousemove", aspxClassesDocumentMouseMove);
function aspxClassesDocumentMouseMove(evt){
    if(__aspxHTMLLoaded)
	    aspxGetStateController().OnMouseMove(evt);
}
_aspxAttachEventToDocument("mousedown", aspxClassesDocumentMouseDown);
function aspxClassesDocumentMouseDown(evt){
    if(__aspxHTMLLoaded)
	    aspxGetStateController().OnMouseDown(evt);
}
_aspxAttachEventToDocument("mouseup", aspxClassesDocumentMouseUp);
function aspxClassesDocumentMouseUp(evt){
    if(__aspxHTMLLoaded)
	    aspxGetStateController().OnMouseUp(evt);
}
_aspxAttachEventToDocument("mouseover", aspxClassesDocumentMouseOver);
function aspxClassesDocumentMouseOver(evt){
    if(__aspxHTMLLoaded)
	    aspxGetStateController().OnMouseOver(evt);
}
_aspxAttachEventToDocument("selectstart", aspxClassesDocumentSelectStart);
function aspxClassesDocumentSelectStart(evt){
    return aspxGetStateController().OnSelectStart(evt);	
}

function aspxFireDefaultButton(evt, buttonID){
    if (evt.keyCode == 13){
        var srcElement = _aspxGetEventSource(evt);
        if(!_aspxIsExists(srcElement) || (srcElement.tagName.toLowerCase() != "textarea")) {
        var defaultButton = _aspxGetElementById(buttonID);
        if (_aspxIsExists(defaultButton) && _aspxIsExists(defaultButton.click)) {
            if (_aspxIsFocusable(defaultButton))
                defaultButton.focus();
            defaultButton.click();
            evt.cancelBubble = true;
            if (_aspxIsFunction(evt.stopPropagation)) 
                evt.stopPropagation();
            return false;
        }
    }
    }
    return true;
}

function _aspxSweepDuplicateElements(collection, attributeName) {
    var hash = { };
    for(var i = 0; i < collection.length; i++) {
        var item = collection[i];
        var value = item[attributeName];
        if(!_aspxIsExists(value) || value == "")
            continue;
        if(_aspxIsExists(hash[value]) && _aspxIsExistsElement(item.parentNode)) {
            if(!__aspxIE || __aspxIE7 || item.tagName != "LINK")
                item.parentNode.removeChild(item);
        } else
            hash[value] = 1;
    }
}

function _aspxProcessLinks() {
    var links = document.getElementsByTagName("LINK");
    _aspxSweepDuplicateElements(links, "href");
}

// Javascript manager
var __aspxIncludeScriptPrefix = "dxis_";
var __aspxStartupScriptPrefix = "dxss_";
var __aspxIncludeScriptsCache = {};
var __aspxCreatedIncludeScripts;
var __aspxAppendedScriptsCount;
var __aspxScriptsRestartHandlers = { };

function _aspxGetScriptCode(script) {
    var text = __aspxSafari ? script.firstChild.data : script.text;
    var comment = "<!--";
    var pos = text.indexOf(comment);
    if(pos > -1)
        text = text.substr(pos + comment.length);
    return text;
}
function _aspxAppendScript(script) {
    var parent = document.getElementsByTagName("head")[0];
    if(!_aspxIsExists(parent))
        parent = document.body;        
    if(_aspxIsExists(parent)) {
        parent.appendChild(script);
    }        
}

function _aspxIsAlphaFilterUsed(img){
    return (__aspxIE && img.style.filter.indexOf("progid:DXImageTransform.Microsoft.AlphaImageLoader") > -1);
}
function _aspxIsKnownIncludeScript(script) {
    return _aspxIsExists(__aspxIncludeScriptsCache[script.src]);
}
function _aspxCacheIncludeScript(script) {
    __aspxIncludeScriptsCache[script.src] = 1;
}


function _aspxGetStartupScripts() {
    return _aspxGetScriptsCore(__aspxStartupScriptPrefix);
}
function _aspxGetIncludeScripts() {
    return _aspxGetScriptsCore(__aspxIncludeScriptPrefix);
}
function _aspxGetScriptsCore(prefix) {
    var result = [];
    var scripts = document.getElementsByTagName("SCRIPT");
    for(var i = 0; i < scripts.length; i++) {
        if (scripts[i].id.indexOf(prefix) == 0)
            result.push(scripts[i]);
    }
    return result;
}


function _aspxInitializeScripts() {
    var scripts = _aspxGetIncludeScripts();
    for(var i = 0; i < scripts.length; i++)
        _aspxCacheIncludeScript(scripts[i]);            
        
    scripts = _aspxGetStartupScripts();
    for(var i = 0; i < scripts.length; i++)
        scripts[i].executed = true;    
}
function _aspxProcessScripts() {
    __aspxCreatedIncludeScripts = [];
    __aspxAppendedScriptsCount = 0;
    
    var scripts = _aspxGetIncludeScripts();
    var immediate = false;
    var waitCount = 0;
    
    for(var i = 0; i < scripts.length; i++) {
        if(!_aspxIsKnownIncludeScript(scripts[i])) {
            waitCount++;
            var createdScript = document.createElement("script");
            __aspxCreatedIncludeScripts.push(createdScript);                       
            createdScript.type = "text/javascript";
            createdScript.src = scripts[i].src;                        
            
            if(__aspxIE) {                
                createdScript.onreadystatechange = _aspxOnScriptReadyStateChangedCallback;                
            } else {                
                if(__aspxNS)
                    createdScript.onload = _aspxOnScriptLoadCallback;
                else
                    immediate = true;
                _aspxAppendScript(createdScript);
                _aspxCacheIncludeScript(createdScript);
            }                                                                                                   
        }    
    }
    if(immediate || !waitCount)
       _aspxSetTimeout(_aspxFinalizeScriptProcessing, 1);        
}

function _aspxFinalizeScriptProcessing() {    
    var scripts = _aspxGetIncludeScripts();
    _aspxSweepDuplicateElements(scripts, "src");
    window.setTimeout(_aspxProcessLinks, 1);
    _aspxRunStartupScripts();
}

function _aspxRunStartupScripts() {
    var scripts = _aspxGetStartupScripts();
    var code;
    for(var i = 0; i < scripts.length; i++){
        if(!scripts[i].executed) {
            code = _aspxGetScriptCode(scripts[i]);                
            eval(code);
            scripts[i].executed = true;
        }
    }
    aspxGetControlCollection().InitializeElements();
    
    for(var key in __aspxScriptsRestartHandlers)
        __aspxScriptsRestartHandlers[key]();
}

function _aspxOnScriptReadyStateChangedCallback() {
    if(this.readyState == "loaded") {
        _aspxCacheIncludeScript(this);

        for(var i = 0; i < __aspxCreatedIncludeScripts.length; i++) {
            var script = __aspxCreatedIncludeScripts[i];
            if(_aspxIsKnownIncludeScript(script)) {
                if(!script.executed) {
                    script.executed = true;
                    _aspxAppendScript(script);
                    __aspxAppendedScriptsCount++;
                }
            } else
                break; 
        }    

        if(__aspxCreatedIncludeScripts.length == __aspxAppendedScriptsCount)
            _aspxFinalizeScriptProcessing();
    }    
}
function _aspxOnScriptLoadCallback() {
    __aspxAppendedScriptsCount++;
    if(__aspxCreatedIncludeScripts.length == __aspxAppendedScriptsCount)
        _aspxFinalizeScriptProcessing();
}

function _aspxAddScriptsRestartHandler(objectName, handler) {
    __aspxScriptsRestartHandlers[objectName] = handler;
}

function _aspxGetOffset(element, IsX) {
	var elementOffset = _aspxGetPositionElementOffset(element, IsX);
	return elementOffset != 0 ? elementOffset + _aspxGetIEDocumentClientOffset(IsX) : 0;
}
function _aspxGetRelevantX(element, parentElement) {
	if(!_aspxIsExists(parentElement))
		parentElement = element;
	return _aspxGetAbsoluteX(element) - _aspxGetOffset(parentElement, true);
}

function _aspxGetRelevantY(element, parentElement) {
	if(!_aspxIsExists(parentElement))
		parentElement = element;
	return _aspxGetAbsoluteY(element) - _aspxGetOffset(parentElement, false);
}