var _$W     = window;
var _$N     = navigator;
var _$L     = location;
var _$H     = history;
var _$D     = document;
var _TN_    = "";
var _NN_    = "none";

// Browser Detect v1.1.7
function hxjBrowser() {
    var ua = _$N.userAgent.toLowerCase(); 
    
    // browser engine name
    this.isGecko       = (ua.indexOf('gecko') != -1 && ua.indexOf('safari') == -1);
    this.isAppleWebKit = (ua.indexOf('applewebkit') != -1);
    
    // browser name
    this.isSafari = (ua.indexOf('safari') != - 1);
    this.isOpera  = (ua.indexOf('opera') != -1 || _$W.opera); 
    this.isMozilla= (this.isGecko && ua.indexOf('gecko/') + 14 == ua.length);
    this.isFirefox= (ua.indexOf('firefox') != -1);
    this.isNS     = (ua.indexOf('netscape') != -1);
    this.isIE     = (ua.indexOf('msie') != -1 && _$W.showHelp); 
    
    // dom support
    this.isDOM1   = (document.getElementById);
    this.isDOM2   = (document.addEventListener && document.removeEventListener);
    
    // platform
    this.isWin    = (ua.indexOf('win') != -1);
    this.isMac    = (ua.indexOf('mac') != -1);
    this.isUnix   = (ua.indexOf('unix') != -1 || ua.indexOf('sunos') != -1 || ua.indexOf('bsd') != -1 || ua.indexOf('x11') != -1)
    this.isLinux  = (ua.indexOf('linux') != -1);
    
    // browser version
    this.versionMinor = parseFloat(_$N.appVersion); 
    
    // correct version number
    if (this.isGecko && !this.isMozilla) {
        this.versionMinor = parseFloat( ua.substring( ua.indexOf('/', ua.indexOf('gecko/') + 6) + 1 ) );
    }
    else if (this.isMozilla) {
        this.versionMinor = parseFloat( ua.substring( ua.indexOf('rv:') + 3 ) );
    }
    else if (this.isIE && this.versionMinor >= 4) {
        this.versionMinor = parseFloat( ua.substring( ua.indexOf('msie ') + 5 ) );
    }
    else if (this.isSafari) {
        this.versionMinor = parseFloat( ua.substring( ua.lastIndexOf('safari/') + 7 ) );
    }
    else if (this.isOpera) {
        this.versionMinor = parseFloat( ua.substring( ua.indexOf('opera') + 6 ) );
    }
        
    this.versionMajor = parseInt(this.versionMinor); 
    
    // specific browser shortcuts
    this.isNS4x  = (this.isNS && this.versionMajor == 4);
    this.isNS4up = (this.isNS && this.versionMinor >= 4);
    this.isNS6x  = (this.isNS && this.versionMajor == 6);
    this.isNS6up = (this.isNS && this.versionMajor >= 6);
    this.isNS7x  = (this.isNS && this.versionMajor == 7);
    this.isNS7up = (this.isNS && this.versionMajor >= 7);
    
    this.isIE5x  = (this.isIE && this.versionMajor == 5);
    this.isIE5up = (this.isIE && this.versionMajor >= 5);
    this.isIE55  = (this.isIE && this.versionMinor == 5.5);
    this.isIE55up= (this.isIE && this.versionMinor >= 5.5);
    this.isIE6x  = (this.isIE && this.versionMajor == 6);
    this.isIE6up = (this.isIE && this.versionMajor >= 6);

    // Write a cookie value
    this.setCookie = function(name, value, expires, path, domain, secure) {
        var curCookie = name + '=' + escape(value) + ((expires) ? '; expires=' + expires.toGMTString() : '') + ((path) ? '; path=' + path : '') + ((domain) ? '; domain=' + domain : '') + ((secure) ? '; secure' : '');
        document.cookie = curCookie;
    }
    // Retrieve a named cookie value
    this.getCookie = function(name) {
        var dc = document.cookie;
        
        // find beginning of cookie value in document.cookie
        var prefix = name + "=";
        var begin = dc.indexOf("; " + prefix);
        if (begin == -1) {
            begin = dc.indexOf(prefix);
            if (begin != 0) 
                return null;
        }
        else {
            begin += 2;
        }
        
        // find end of cookie value
        var end = document.cookie.indexOf(";", begin);
        if (end == -1) 
            end = dc.length;
        
        // return cookie value
        return unescape(dc.substring(begin + prefix.length, end));
    }
}
var _$B = new hxjBrowser();

function INHERIT_CLASS(oThis, oParent, sObjName) {     
    oThis[sObjName] = oParent; 
      
    for (var sProperty in oParent) { 
        try {
            oThis[sProperty] = oParent[sProperty]; 
        }
        catch(excp) {
        }
    }   
}

function hxj_FindObject(v){
    if(_$D.getElementById)return _$D.getElementById(v);
    if(_$D.all)return _$D.all[v];
}
function hxj_FindObjectInIFrame(frmv, v){
	var $iF = null;
	var $obj = null;
	
	if (_$D.frames) {
		$iF = _$D.frames(frmv);
    }
	else {
		$iF = _$D.getElementById(frmv);
	}

 	if ($iF) {
 		var $dom = ($iF.contentDocument) ? $iF.contentDocument : $iF.document;
 		    	
    	if ($dom.getElementById) {
    		$obj = $dom.getElementById(v);
    	}
    	else if ($dom.all) {
    		$obj = $dom.all[v];
    	}
    }
    
    return $obj;
}
function hxj_ReplaceStr(str, find, replace) {
	return str.replace(find, replace);
}
function hxj_LowerCase(v){
    if(v)return v.toLowerCase();
    return _TN_;
}
function hxj_UpperCase(v){
    if(v)return v.toUpperCase();
    return _TN_;
}
function hxj_MakePixel(px){
    px = (!isNaN(px)) ? px+="px" : px;
    return px;
}
function hxj_MakePercent(pc){
    pc = (!isNaN(pc)) ? pc+="%" : pc;
    return pc;
}
function hxj_ParseInt(v, radix){	
    var i = parseInt(v, radix ? radix : 10);
    return (isNaN(i)) ? 0 : i;
}
function hxj_Sleep(nMillisec) {
	var now = new Date();
	var exitTime = now.getTime() + nMillisec;
	while (true) {
		now = new Date();
		if (now.getTime() > exitTime)
			break;
	}
}
//
// Adds event to window.onload without overwriting currently assigned onload functions.
//
function hxj_AddEvent(obj, evtname, func) {
	evtname = hxj_LowerCase(evtname);
	
	// Mozilla event capturing
	if (typeof document.addEventListener == "function") {
		if (evtname.substr(0, 2) == "on")
			evtname = evtname.substr(2);
			
		obj.addEventListener(evtname, func, false);
	}	
	else {	// IE event capturing
		if (evtname.substr(0, 2) != "on")
			evtname = "on" + evtname;
			
		obj.attachEvent(evtname, func);
	}
}
//
// Removes event to window.onload without overwriting currently assigned onload functions.
//
function hxj_RemoveEvent(obj, evtname, func) {
	evtname = hxj_LowerCase(evtname);
	
	// Mozilla event capturing
	if (typeof document.addEventListener == "function") {
		if (evtname.substr(0, 2) == "on")
			evtname = evtname.substr(2);
			
		obj.removeEventListener(evtname, func, false);
	}	
	else {	// IE event capturing
		if (evtname.substr(0, 2) != "on")
			evtname = "on" + evtname;
			
		obj.detachEvent(evtname, func);
	}
}


function hxjArray() {
    this.length = 0;
    
    this.push = function(obj){
        this[this.length] = obj;
        this.length++;
    }
    this.pop = function(){
        var obj = null;
        if (this.length > 0) {
            obj = this[this.length-1];
            delete this[this.length-1];
            this.length--;
        }
        
        return obj;
    }
    this.insertAt = function(pos, obj){
        if (pos < 0 || pos >= this.length)
            return;
        
        for (var i=this.length; i>pos; i--) {
            this[i] = this[i-1];
        }
        
        this[pos] = obj;
        this.length++;
    }
    this.removeAt = function(pos){
        var obj = null;
        
        if (pos < 0 || pos >= this.length)
            return null;
        
        obj = this[pos];                
        for (var i=pos; i<this.length-1; i++) {
            this[i] = this[i+1];
        }
        delete this[this.length-1];
        this.length--;
        
        return obj;
    }
    this.remove = function(obj){
        return this.removeAt(this.find(obj));
    }
    this.find = function(obj){
        for (var i=0; i<this.length; i++) {
            if (this[i] == obj)
                return i;
        }
        
        return -1;
    }
}

function hxjMap() {
    this.length = 0;
    
    this.isExist = function(key){
        return (this[key]) ? true : false;
    }
    this.get = function(key){
        return this[key];
    }
    this.put = function(key, val){
        var prev = null;
        
        if (this[key]) {
            prev = this[key];
        }
        else {
            this.length++;
        }
        
        this[key] = val;        
        return prev;
    }
    this.remove = function(key){
        var val = null;
        
        if (this[key]) {
            val = this[key];
            delete this[key];
            this.length--;
        }
        
        return val;
    }
}

function hxjHash() {
    this.length = 0;
    this.bucket = new Array();
    
    for (var i=0; i<17; i++) {
        this.bucket[i] = new hxjMap();
    }
    
    this._hashKey = function(key){
        var	h = 0;
    
    	if (!key || key.length <= 0)
    		return 0;
    
    	h = key.length;
    	e = key + (h - 1);
        
        for (var i = h-1; i >= 0; i--) {
    	    h = ((h >> 1) ^ (h << (key.charAt(i) % 31))) ^ key.charAt(i);
    	}
            
    	return h%17;    	
    }
    this.isExist = function(key){
        var hash = this._hashKey(key);
        return this.bucket[hash].isExist(key);
    }
    this.get = function(key){
        var hash = this._hashKey(key);                
        return this.bucket[hash].get(key);
    }
    this.put = function(key, value){
        var hash = this._hashKey(key);
        var prev = null;
        
        prev = this.bucket[hash].put(key, value);
        if (!prev)
            this.length++;
        
        return prev;
    }
    this.remove = function(key){
        var hash = this._hashKey(key);
        var val = null;
        
        val = this.bucket[hash].remove(key);
        if (val)
            this.length--;
                    
        return val;
    }
}

function hxjPoint(x, y) {
    this.x = (x!=null) ? x : 0;
    this.y = (y!=null) ? y : 0;
    
    this.Offset = function(x, y){
        this.x += x;
        this.y += y;
    }
}

function hxjRect(left, top, right, bottom) {
    this.left = (left!=null) ? left : 0;
    this.top = (top!=null) ? top : 0;
    this.right = (right!=null) ? right : this.left;
    this.bottom = (bottom!=null) ? bottom : this.top;
    
    this.Width = function(){
        return this.right-this.left;
    }
    this.Height = function(){
        return this.bottom-this.top;
    }
    this.OffsetRect = function(x, y){
        this.left += x;
        this.right += x;
        this.top += y;
        this.bottom += y;
    }
    this.DeflateRect = function(x, y){
        this.left += x;
        this.right -= x;
        this.top += y;
        this.bottom -= y;
    }
    this.InflateRect = function(x, y){
        this.left -= x;
        this.right += x;
        this.top -= y;
        this.bottom += y;
    }
    this.PtInRect = function(x, y){
        if ((this.left <= x) && (this.right >= x) && (this.top <= y) && (this.bottom >= y))
            return true;
        return false;
    }
    this.TopLeft = function(){
        return new hxjPoint(this.left, this.top);
    }
    this.BottomRight = function(){
        return new hxjPoint(this.right, this.bottom);
    }
    this.CenterPoint = function(){
        var x = this.left + ((this.right - this.left) / 2);
        var y = this.top + ((this.bottom - this.top) / 2);
        
        return new hxjPoint(x, y);
    }
    this.CopyRect = function(){
        return new hxjRect(this.left, this.top, this,right, this.bottom);
    }
    this.IntersectRect = function(rc){
        var newRc = null;
        
        if (this.PtInRect(rc.left, rc.top) 
                || this.PtInRect(rc.right, rc.top) 
                || this.PtInRect(rc.left, rc.bottom)
                || this.PtInRect(rc.right, rc.bottom)
                || rc.PtInRect(this.left, this.top) 
                || rc.PtInRect(this.right, this.top) 
                || rc.PtInRect(this.left, this.bottom)
                || rc.PtInRect(this.right, this.bottom)) {
            newRc = new hxjRect();
            newRc.left = (this.left <= rc.left) ? rc.left: this.left;            
            newRc.top = (this.top <= rc.top) ? rc.top : this.top;
            newRc.right = (this.right <= rc.right) ? this.right : rc.right;
            newRc.bottom = (this.bottom <= rc.bottom) ? this.bottom : rc.bottom;
        }
        
        return newRc;
    }    
}
var rcDefault = new hxjRect();
var objMap = new hxjMap();

function hxjObject(){
    this.sID = _TN_;
        
    this.Init   = function(){}
    this.Uninit = function(){}
}

var _$ENUM_WS={left:0,top:1,width:2,height:3,position:4,align:6,valign:7,margin:8,high3dcolor:9,low3dcolor:10,followscroll:11,zindex:12,resizable:13,minwidth:14,maxwidth:15,minheight:16,maxheight:17,bgcolor:18,onbgcolor:19,bgimage:20,onbgimage:21,border:22,onborder:23,txtcolor:24,ontxtcolor:25,cursor:26,font:27,onfont:28,layoutGrid:29,onlayoutGrid:30,lineHeight:31,padding:32,txtDecoration:33,ontxtDecoration:34,txtOverflow:35,txtTransform:36,letterSpacing:37,zoom:38,dragable:39,rawcss:40,fontfamily:41,fontsize:42,fontstyle:43,fontweight:44,onfontfamily:45,onfontSize:46,onfontstyle:47,onfontweight:48,filter:49,onfilter:50,overflow:51,orientation:52};
function hxjWinStyle(sID){
    INHERIT_CLASS(this, new hxjObject(), "hxjObject");    

    for (var $i in _$ENUM_WS)
        this[$i]=null;
    this.built = 0;
    this.sID = sID;
    
    this.Init = function(){
        if (!this.built) {
            if (!this.cursor) this.cursor = "hand";
            if (!_$B.isIE && this.cursor == "hand") this.cursor = "pointer";
            if (!this.padding || this.padding<=0) this.padding = 1;
            if (!this.margin) this.margin = 0;
            if (!this.width && this.itemwidth) this.width = this.itemwidth;
            if (!this.position) this.position = "absolute";
            if (this.position == "fixed" && !_$B.isNS) this.position = "absolute";
            if (this.overflow == "scroll") this.overflow = "auto";
        }
                
        this.built = 1;   
    }
    this.toString = function(){
        if (!this.built) this.Init();
        
        var it = (this.left) ? ("left:"+hxj_MakePixel(this.left)) : _TN_;
        it += (this.top) ? (";top:"+hxj_MakePixel(this.top)) : _TN_;
        it += (this.width) ? (";width:"+hxj_MakePixel(this.width)) : _TN_;
        it += (this.height) ? (";height:"+hxj_MakePixel(this.height)) : _TN_;        
        it += (this.position) ? (";position:"+this.position) : _TN_;
        it += (this.margin) ? (";margin:"+hxj_MakePixel(this.margin)) : _TN_;        
        if (this.high3dcolor && this.low3dcolor) {
            it += (";border-bottom-color:"+this.high3dcolor);
            it += (";border-right-color:"+this.high3dcolor);
            it += (";border-top-color:"+this.low3dcolor);
            it += (";border-left-color:"+this.low3dcolor);
        }
        it += (this.zindex) ? (";z-index:"+this.zindex) : _TN_;
        it += (this.bgcolor) ? (";background-color:"+this.bgcolor) : _TN_;
        it += (this.bgimage) ? (";background-image:url("+this.bgimage+")") : _TN_;
        it += (this.border) ? (";border:"+this.border) : _TN_;
        it += (this.txtcolor) ? (";color:"+this.txtcolor) : _TN_;
        if (this.font) {
            it += ";font:"+this.font;
        }
        else {
            it += (this.fontfamily) ? (";font-family:"+this.fontfamily) : _TN_;
            it += ";font-size:" + ((this.fontsize) ? this.fontsize : "normal");
            it += ";font-style:" + ((this.fontstyle) ? this.fontstyle : "75%");
            it += ";font-weight:"+ ((this.fontweight) ? this.fontweight : "normal");
        }
        it += (this.layoutGrid) ? (";layout-grid:"+this.layoutGrid) : _TN_;
        it += (this.lineHeight) ? (";line-height:"+hxj_MakePixel(this.lineHeight)) : _TN_;
        it += (this.padding) ? (";padding:"+hxj_MakePixel(this.padding)) : _TN_;
        it += (this.txtDecoration) ? (";text-decoration:"+this.txtDecoration) : _TN_;
        it += (this.txtOverflow) ? (";text-overflow:"+this.txtOverflow) : _TN_;
        it += (this.txtTransform) ? (";text-transform:"+this.txtTransform) : _TN_;
        it += (this.letterSpacing) ? (";letter-spacing:"+hxj_MakePixel(this.letterSpacing)) : _TN_;
        it += (this.txtTransform) ? (";text-transform:"+this.txtTransform) : _TN_;
        it += (this.overflow) ? (";overflow:"+this.overflow) : _TN_;
        it += (this.zoom) ? (";zoom:"+hxj_MakePercent(this.zoom)) : _TN_;
        it += (this.rawcss) ? (";"+this.rawcss) : _TN_;
        it += ";visibility:hidden";

        return it;
    }
}

var WS_NOMOVE       = 0x01;
var WS_NOSIZE       = 0x02;
var WS_SHOWWINDOW   = 0x04;
var WS_HIDEWINDOW   = 0x08;

function HXJ_TRACE(sText){
    var $oTrace = hxj_FindObject("hxjTraceWin");
    if (!$oTrace) {
        var $dB = (_$D.body) ? _$D.body : _$D.documentElement;
        var $oTrace = _$D.createElement("DIV");
        
        $oTrace.id = "hxjTraceWin";
        $oTrace.style.left = "4px";
        $oTrace.style.top = ($dB.clientHeight-200)+"px";
        $oTrace.style.width = "400px";
        $oTrace.style.height = "200px";
        $oTrace.style.overflow = "scroll";
        $oTrace.style.border = "1px solid #000000";
        $oTrace.style.position = "absolute";
        $oTrace.style.display = "block";
        $oTrace.style.backgroundColor = "#FFFFFF";
                
        $dB.appendChild($oTrace);
    }
    
    if ($oTrace) {
        var d = new Date();
        var t = d.getHours()+":"+d.getMinutes()+":"+d.getSeconds()+" -- "+sText+"<br>";
        
        if (_$B.isIE) {
            $oTrace.insertAdjacentHTML("beforeEnd", t);
        }
        else {
            $oTrace.innerHTML = $oTrace.innerHTML + t;
        }
        $oTrace.scrollIntoView(true);
    }
}

function hxj_MoveWindow(oObject, x, y, cx, cy){
    var $OS= oObject.style;
            
    $OS.position = "absolute";
    if (_$B.isOpera) {
        if (x) $OS.left = x;
        if (y) $OS.top = y;
        if (cx) $OS.pixelWidth = cx;
        if (cy) $OS.pixelHeight = cy;   
    }
    else {    	
        if (x) $OS.left = hxj_MakePixel(x);
        if (y) $OS.top = hxj_MakePixel(y);
        if (cx) $OS.width = hxj_MakePixel(cx);
        if (cy) $OS.height = hxj_MakePixel(cy);
    }
    
    if (oObject.firstChild) {
    	if (_$B.isSafari) {
    	    if (cx) oObject.firstChild.width  = "98%";
	        if (cy) oObject.firstChild.height = "98%";
    	}
    	else {
	        if (cx) oObject.firstChild.style.width  = "100%";
	        if (cy) oObject.firstChild.style.height = "100%";
	    }
    }
}

function hxj_GetObjectRect(oObject){
    var $dB = (_$D.body) ? _$D.body : _$D.documentElement;
    var $mcdb = $dB.currentStyle;
    var $OS = oObject.style;
    var x = 0;
    var y = 0;
    var cx = oObject.offsetWidth;
    var cy = oObject.offsetHeight;
     
    if (_$B.isOpera) {
        cx = $OS.pixelWidth;
        cy = $OS.pixelHeight;
    }
	            
    for (; oObject; oObject = oObject.offsetParent) {
        y += (oObject.offsetTop - oObject.scrollTop);
        x += (oObject.offsetLeft + oObject.scrollLeft);            
    }
    
    if (_$B.isSafari) {
        x -= $dB.offsetLeft;
        y -= $dB.offsetTop;
    }
    
    x -= $dB.scrollLeft;
    y += $dB.scrollTop;

    if (_$B.isMac && $mcdb) {
        var mcT=$mcdb.marginTop;            
        if (mcT) y = y + parseInt(mcT);
        var mcL = $mcdb.marginLeft;
        if (mcL) x = x + parseInt(mcL);
    }
    
    if (x < 0 && hxj_ParseInt($OS.left) > 0)
    	x = hxj_ParseInt($OS.left);
    if (y < 0 && hxj_ParseInt($OS.top) > 0)
    	y = hxj_ParseInt($OS.top);

    return new hxjRect(x, y, x+cx, y+cy);
}

var _$ENUM_EM={OnCreate:0,OnDestroy:1,OnActivate:2,OnBeforeActivate:3,OnBeforeDeactivate:4,OnBlur:5,OnClick:6,OnContextMenu:7,OnControlSelect:8,OnDblClick:9,OnDeactivate:10,OnDrag:11,OnDragEnd:12,OnDragEnter:13,OnDragLeave:14,OnDragOver:15,OnDragStart:16,OnDrop:17,OnFocus:18,OnKeypress:19,OnMousedown:20,OnMousemove:21,OnMouseout:22,OnMouseover:23,OnMouseup:24,OnResize:25,OnScroll:26,OnStyle:27};
function hxjWindow(){
    INHERIT_CLASS(this, new hxjObject(), "hxjObject");    
    
    for (var $i in _$ENUM_EM)
        this[$i]=null;
        
    this.oParent = null;
    this.oStyle = null;
    this.oObject = null;    
        
    this.Create = function(oParent, sID, oStyle){        
        this.oParent = oParent;        
        this.oStyle = oStyle;
        this.sID = sID;
        
        this.EVENT_MAP();
        this.FUNCTION_MAP();
        
        if (this.OnCreate) this.OnCreate();
        
        var sEl = "<DIV id='"+sID+"' ";
        if (this.OnActivate) sEl += "onactivate='hxjWindow_OnActivate(this, event)' ";
        if (this.OnBeforeActivate) sEl += "onbeforeactivate='hxjWindow_OnBeforeActivate(this, event)' ";
        if (this.OnBeforeDeactivate) sEl += "onbeforedeactivate='hxjWindow_OnBeforeDeactivate(this, event)' ";
        if (this.OnBlur) sEl += "onblur='hxjWindow_OnBlur(this, event)' ";
        if (this.OnClick) sEl += "onclick='hxjWindow_OnClick(this, event)' ";
        if (this.OnContextMenu) sEl += "oncontextmenu='hxjWindow_OnContextMenu(this, event)' ";
        if (this.OnControlSelect) sEl += "oncontrolselect='hxjWindow_OnControlSelect(this, event)' ";
        if (this.OnDblClick) sEl += "ondblclick='hxjWindow_OnDblClick(this, event)' ";
        if (this.OnDeactivate) sEl += "ondeactivate='hxjWindow_OnDeactivate(this, event)' ";
        if (this.OnDrag) sEl += "ondrag='hxjWindow_OnDrag(this, event)' ";
        if (this.OnDragEnd) sEl += "ondragend='hxjWindow_OnDragEnd(this, event)' ";
        if (this.OnDragEnter) sEl += "ondragenter='hxjWindow_OnDragEnter(this, event)' ";
        if (this.OnDragLeave) sEl += "ondragleave='hxjWindow_OnDragLeave(this, event)' ";
        if (this.OnDragOver) sEl += "ondragover='hxjWindow_OnDragOver(this, event)' ";
        if (this.OnDragStart) sEl += "ondragstart='hxjWindow_OnDragStart(this, event)' ";
        if (this.OnDrop) sEl += "ondrop='hxjWindow_OnDrop(this, event)' ";
        if (this.OnFocus) sEl += "onfocus='hxjWindow_OnFocus(this, event)' ";
        if (this.OnKeypress) sEl += "onkeypress='hxjWindow_OnKeypress(this, event)' ";
        if (this.OnMousedown) sEl += "onmousedown='hxjWindow_OnMousedown(this, event)' ";
        if (this.OnMousemove) sEl += "onmousemove='hxjWindow_OnMousemove(this, event)' ";
        if (this.OnMouseup) sEl += "onmouseup='hxjWindow_OnMouseup(this, event)' ";
        if (this.OnResize) sEl += "onresize='hxjWindow_OnResize(this, event)' ";
        if (this.OnScroll) sEl += "onscroll='hxjWindow_OnScroll(this, event)' ";
        if (this.OnSelectStart) sEl += "onselectstart='return hxjWindow_OnSelectStart(this, event)' ";
        if (this.OnMouseout) sEl += "onmouseout='hxjWindow_OnMouseout(this, event)' ";
        if (this.OnMouseover) sEl += "onmouseover='hxjWindow_OnMouseover(this, event)' ";
        
        sEl += (oStyle && oStyle.align) ? ("align="+oStyle.align) : _TN_;
        sEl += " style='"+ ((this.OnStyle) ? this.OnStyle() : ((oStyle) ? oStyle.toString() : _TN_)) +"'>\r\n";
        if (this.OnDraw) sEl += this.OnDraw();
        sEl += "</DIV>\r\n";
        
        if (oParent) {
            var oObjP = hxj_FindObject(oParent.sID);
            if (oObjP) {
                if (_$B.isIE) {
                    oObjP.insertAdjacentHTML("beforeEnd", sEl);
                }
                else {
                    oObjP.innerHTML = oObjP.innerHTML + sEl;
                }
            }
            else {
                _$D.write(sEl);
            }
        }
        else {
            _$D.write(sEl);            
        }
        
        this.oObject = hxj_FindObject(sID);
        if (!this.oObject)
            throw("hxjlib.js - hxWindow::Create: failed to create DOM object");
                        
        objMap.put(sID, this);
    }
    this.Destroy = function(){
        if (this.oObject) {
            if (this.OnDestroy()) this.OnDestroy();            
            this.oObject.removeNode(true);
        }
        
        if (objMap[this.sID])
            delete objMap.remove(this.sID);
    }    
    this.ShowWindow = function(bShow){
        if (!this.oObject)
            throw("hxjlib.js - hxWindow::ShowWindow: DOM object is null or not created");
        
        if (this.OnShowWindow) this.OnShowWindow(bShow);        
        
        this.ApplyFilter(bShow);
        if (bShow) {
            this.oObject.style.zIndex = (this.oStyle && this.oStyle.zindex) ? this.oStyle.zindex : 999;
            this.oObject.style.visibility = "visible";
            if (this.oStyle && this.oStyle.overflow == "auto") {
                this.oObject.scrollTop = 0;
                this.oObject.scrollLeft = 0;
            }
        }
        else {
            if (_$B.isMac) this.oObject.style.overflow = "hidden";
            this.oObject.style.visibility = "hidden";
        }
        this.PlayFilter(bShow);
    }
    this.ApplyFilter = function(bShow){
        if (!this.oObject)
            throw("hxjlib.js - hxWindow::ApplyFilter: DOM object is null or not created");
            
        if (this.oObject.filters) {
            var $OS = this.oObject.style;
            var sFlt = (bShow) ? this.oStyle.onfilter : this.oStyle.filter;
            if (sFlt) {
                var iedf="FILTER:";
                
                if (this.oObject.filters[0]) 
                    this.oObject.filters[0].stop();
                
                sFlt = sFlt.split(";");
                for (var i=0; i< sFlt.length; i++) {
                    iedf += " progid:DXImageTransform.Microsoft."+ sFlt[i];
                    if(_$N.userAgent.indexOf("MSIE 5.5") > 0)
                        break;
                }
                
                $OS.filter=iedf;
                if (this.oObject.filters[0])
                    this.oObject.filters[0].apply();
            }            
        }
    }
    this.PlayFilter = function(bShow){
        if (!this.oObject)
            throw("hxjlib.js - hxWindow::PlayFilter: DOM object is null or not created");
        
        if (this.oObject.filters) {
            var sFlt = (bShow) ? this.oStyle.onfilter : this.oStyle.filter;
            if (sFlt && this.oObject.filters[0])
                this.oObject.filters[0].play();
        }
    }
    this.RedrawWindow = function(){
        if (!this.oObject)
            throw("hxjlib.js - hxWindow::RedrawWindow: DOM object is null or not created");
        
        if (this.OnDraw)        
            this.oObject.innerHTML = this.OnDraw();        
    }
    this.GetWindowRect = function(){
        if (!this.oObject)
            throw("hxjlib.js - hxWindow::GetWindowRect: DOM object is null or not created");
            
        return hxj_GetObjectRect(this.oObject);
    }    
    this.MoveWindow = function(x, y, cx, cy){
        if (!this.oObject)
            throw("hxjlib.js - hxWindow::MoveWindow: DOM object is null or not created");
        
        hxj_MoveWindow(this.oObject, x, y, cx, cy);
    }    
    this.SetWindowPos = function(oParent, x, y, cx, cy, nFlags){
        var $OS = this.oObject.style;
            
        if (nFlags & WS_NOMOVE) {
            x = null;
            y = null;
        }        
        if (nFlags & WS_NOSIZE) {
            cx = null;
            cy = null;
        }
        
        this.MoveWindow(x, y, cx, cy);
        
        if ((nFlags & WS_SHOWWINDOW) 
                || (nFlags & WS_HIDEWINDOW)) {            
            this.ShowWindow((nFlags & WS_SHOWWINDOW) ? true : false);
        }
    }

    this.EVENT_MAP = function(){}
    this.FUNCTION_MAP = function(){}
    
}

function hxjWindow_OnActivate(oObj, event) {
    var oWin = objMap[oObj.id];    
    if (oWin) {
        oWin.OnActivate(event);    
    }
}
function hxjWindow_OnBeforeActivate(oObj, event) {
    var oWin = objMap[oObj.id];    
    if (oWin) {
        oWin.OnBeforeActivate(event);    
    }
}
function hxjWindow_OnBeforeDeactivate(oObj, event) {
    var oWin = objMap[oObj.id];    
    if (oWin) {
        oWin.OnBeforeDeactivate(event);    
    }
}
function hxjWindow_OnBlur(oObj, event) {
    var oWin = objMap[oObj.id];    
    if (oWin) {
        oWin.OnBlur(event);    
    }
}
function hxjWindow_OnClick(oObj, event) {
    var oWin = objMap[oObj.id];    
    if (oWin) {
        oWin.OnClick(event);    
    }
}
function hxjWindow_OnContextMenu(oObj, event) {
    var oWin = objMap[oObj.id];    
    if (oWin) {
        oWin.OnContextMenu(event);    
    }
}
function hxjWindow_OnControlSelect(oObj, event) {
    var oWin = objMap[oObj.id];    
    if (oWin) {
        oWin.OnControlSelect(event);    
    }
}
function hxjWindow_OnDblClick(oObj, event) {
    var oWin = objMap[oObj.id];    
    if (oWin) {
        oWin.OnDblClick(event);    
    }
}
function hxjWindow_OnDeactivate(oObj, event) {
    var oWin = objMap[oObj.id];    
    if (oWin) {
        oWin.OnDeactivate(event);    
    }
}
function hxjWindow_OnDrag(oObj, event) {
    var oWin = objMap[oObj.id];    
    if (oWin) {
        oWin.OnDrag(event);    
    }
}
function hxjWindow_OnDragEnd(oObj, event) {
    var oWin = objMap[oObj.id];    
    if (oWin) {
        oWin.OnDragEnd(event);    
    }
}
function hxjWindow_OnDragEnter(oObj, event) {
    var oWin = objMap[oObj.id];    
    if (oWin) {
        oWin.OnDragEnter(event);    
    }
}
function hxjWindow_OnDragLeave(oObj, event) {
    var oWin = objMap[oObj.id];    
    if (oWin) {
        oWin.OnDragLeave(event);    
    }
}
function hxjWindow_OnDragOver(oObj, event) {
    var oWin = objMap[oObj.id];    
    if (oWin) {
        oWin.OnDragOver(event);    
    }
}
function hxjWindow_OnDragStart(oObj, event) {
    var oWin = objMap[oObj.id];    
    if (oWin) {
        oWin.OnDragStart(event);    
    }
}
function hxjWindow_OnDrop(oObj, event) {
    var oWin = objMap[oObj.id];    
    if (oWin) {
        oWin.OnDrop(event);    
    }
}
function hxjWindow_OnFocus(oObj, event) {
    var oWin = objMap[oObj.id];    
    if (oWin) {
        oWin.OnFocus(event);    
    }
}
function hxjWindow_OnKeypress(oObj, event) {
    var oWin = objMap[oObj.id];    
    if (oWin) {
        oWin.OnKeypress(event);    
    }
}
function hxjWindow_OnMousedown(oObj, event) {
    var oWin = objMap[oObj.id];    
    if (oWin) {
        oWin.OnMousedown(event);    
    }
}
function hxjWindow_OnMousemove(oObj, event) {
    var oWin = objMap[oObj.id];    
    if (oWin) {
        oWin.OnMousemove(event);    
    }
}
function hxjWindow_OnMouseout(oObj, event) {
    var oWin = objMap[oObj.id];    
    if (oWin) {
        var nRet = oWin.OnMouseout(event);
        if (nRet && oWin.oStyle) {
            if (oWin.oStyle.onbgcolor) oObj.style.backgroundColor = (oWin.oStyle.bgcolor) ? oWin.oStyle.bgcolor : "transparent";
            if (oWin.oStyle.onbgimage) oObj.style.backgroundImage = (oWin.oStyle.bgimage) ? "url("+oWin.oStyle.bgimage+")" : _NN_;
            if (oWin.oStyle.ontxtcolor) oObj.style.color = (oWin.oStyle.txtcolor) ? oWin.oStyle.txtcolor : _TN_;
            if (oWin.oStyle.ontxtDecoration) oObj.style.textDecoration = (oWin.oStyle.txtDecoration) ? oWin.oStyle.txtDecoration : _NN_;
            if (oWin.oStyle.onlayoutGrid) oObj.style.layoutGrid = (oWin.oStyle.layoutGrid) ? oWin.oStyle.layoutGrid : _TN_;
            if (oWin.oStyle.onfont) oObj.style.font = (oWin.oStyle.font) ? oWin.oStyle.font : _TN_;
            if (oWin.oStyle.onborder) {
                oObj.style.border = (oWin.oStyle.border) ? oWin.oStyle.border : _TN_;
                oObj.style.padding = oWin.oStyle.padding+"px "+oWin.oStyle.padding+"px";
            } 
        }        
    }
}
function hxjWindow_OnMouseover(oObj, event) {
    var oWin = objMap[oObj.id];
    if (oWin) {
        var nRet = oWin.OnMouseover(event);
        if (nRet && oWin.oStyle) {
            if (oWin.oStyle.onbgcolor) oObj.style.backgroundColor = oWin.oStyle.onbgcolor;
            if (oWin.oStyle.onbgimage) oObj.style.backgroundImage = "url("+oWin.oStyle.onbgimage+")";
            if (oWin.oStyle.ontxtcolor) oObj.style.color = oWin.oStyle.ontxtcolor;
            if (oWin.oStyle.ontxtDecoration) oObj.style.textDecoration = oWin.oStyle.ontxtDecoration;
            if (oWin.oStyle.onlayoutGrid) oObj.style.layoutGrid = oWin.oStyle.onlayoutGrid;
            if (oWin.oStyle.onfont) oObj.style.font = oWin.oStyle.onfont;
            if (oWin.oStyle.cursor) oObj.style.cursor = oWin.oStyle.cursor;
            if (oWin.oStyle.onborder) {
                oObj.style.border = oWin.oStyle.onborder;
                oObj.style.padding = (oWin.oStyle.padding-1)+"px "+(oWin.oStyle.padding-1)+"px";
            }
        }
    }
}
function hxjWindow_OnMouseup(oObj, event) {
    var oWin = objMap[oObj.id];    
    if (oWin) {
        oWin.OnMouseup(event);    
    }
}
function hxjWindow_OnResize(oObj, event) {
    var oWin = objMap[oObj.id];    
    if (oWin) {
        oWin.OnResize(event);    
    }
}
function hxjWindow_OnScroll(oObj, event) {
    var oWin = objMap[oObj.id];    
    if (oWin) {
        oWin.OnScroll(event);    
    }
}
function hxjWindow_OnSelectStart(oObj, event) {
    var oWin = objMap[oObj.id];    
    if (oWin) {
        return oWin.OnSelectStart(event);    
    }    
    return false;
}

