
// tab width 4
/*window.onerror = function ( sDesc, sPage, iLine ) { // error handling
		
		// public damage control
		if ( document.location.host != "localhost:9080" ) {
			
			window.status = "Line " + iLine + ": " + sDesc;
			return true;
		}
		// mozilla early warning system
		else if ( document.evaluate ) {
			var report = "Human error in line " + iLine + ":\n" + sDesc + "\n" + sPage;
			alert ( report );
			throw ( report );
			return true;
		}
}*/

/**
 * top object
 */
var oGod = {

		DUMMY_LINK	: "javascript:void(false);",
		
		oBroadcast 	: {}, // broadcaster
		iLanguage 	: 0,  // default language setting
		aResizers 	: [], // resize statements
		aLoaders 	: [], // onload statements
		
		// initialization
		mPush		: function () { arguments [ 0 ][ arguments [ 0 ].length ] = arguments [ 1 ]},
		mOnload 	: function () { var i = 0; while ( i < arguments.length ) oGod.mPush ( oGod.aLoaders,  arguments [ i++ ])},
		mOnresize 	: function () { var i = 0; while ( i < arguments.length ) oGod.mPush ( oGod.aResizers, arguments [ i++ ])},
		mExecute 	: function () { var i = 0; while ( i < arguments [ 0 ].length ) arguments[ 0 ][ i++ ](); },
		mResize 	: function () { oGod.mExecute ( oGod.aResizers ); },
		mLoad 		: function () { oGod.mExecute ( oGod.aLoaders ); oGod.mBroadcast ( "onload statements evaluated" );},
		
		// central broadcasting service
		mSubscribe : function ( sBroadcast, oFunction ) {
			if ( !oGod.oBroadcast [ sBroadcast ]) oGod.oBroadcast [ sBroadcast ] = [ oFunction ];
			else oGod.mPush ( oGod.oBroadcast [ sBroadcast ], oFunction );
		},
		mUnsubscribe : function ( sBroadcast, oFunction ) {
			var aSubscribers = oGod.oBroadcast [ sBroadcast ]; 
			var i = 0; while ( aSubscribers [ i ]) {
				if ( aSubscribers [ i ] == oFunction ) aSubscribers [ i ] = new Function ();
				i++;
			}
		},
		mBroadcast : function ( sBroadcast ) {
			if ( oGod.oBroadcast [ sBroadcast ]) oGod.mExecute ( oGod.oBroadcast [ sBroadcast ] );
		}
}

/**
 * sniffer
 */
var oClient = {

		mEval : function ( bStatement ) { return bStatement ? true : false; },
		mPass : function () {
			oClient.bMozilla	= oClient.mEval ( document.evaluate );
			oClient.bOpera		= oClient.mEval ( window.opera && document.addEventListener );
			oClient.bIE			= oClient.mEval ( document.all && document.createElement && !oClient.bOpera );
			oClient.bIEwin 		= oClient.mEval ( oClient.bIE && navigator.platform.indexOf ( "Win" ) !=-1 );
			oClient.bIEmac 		= oClient.mEval ( oClient.bIE && !oClient.bIEwin );
			oClient.bSafari 	= oClient.mEval ( navigator.appVersion.toLowerCase ().indexOf ( "safari" ) !=-1 );
			oClient.bPass		= oClient.bMozilla || oClient.bOpera || oClient.bIE || oClient.bSafari;
			return oClient.bPass;
		}
}

/**
 * utility functions
 */
var oTools = {

		// extend native interfaces
		mInit : function () {
			
			if ( !window.Node ) window.Node = { ELEMENT_NODE: 1, ATTRIBUTE_NODE: 2, TEXT_NODE: 3 };
			if ( !Array.prototype.push ) {
				Array.prototype.push = function () {
					var iLength = this.length;
					var i = 0; while ( i < arguments.length ) this [ iLength + i ] = arguments [ i++ ];
					return this.length;
				}
			}
			String.prototype.contains = function ( sString ) {
				return this.indexOf ( sString ) !=-1;
			}
			String.prototype.attach = function ( sClass ) {
				var string = this;
				return string += ( string == "" ? "" : " " ) + sClass;
			}
			String.prototype.detach = function ( sClass ) {
				var string = this;
				return string.replace (( string.contains ( " " ) ? " " : "" ) + sClass, "" );
			}
			String.prototype.trim = function () {
				var string = this;
				string = string.replace( /^\s+/g, "" );// strip leading
				return string.replace( /\s+$/g, "" );// strip trailing				
			}
			
			if ( !String.prototype.splitStr ) {
				String.prototype.splitStr = function ( sep ) {
					var tempArr=[];
					var rest=true;
					var val=this;
					while (rest) 
					{
						var start=val.indexOf(sep);
						if (start!=-1) 
						{
							tempArr.push(val.substring(0,start));
							val=val.substring(start + sep.length);
						}
						else 
						{
							tempArr.push(val);
							rest=false;
						}
					}
					return tempArr;
				}
			}
			
			String.prototype.replaceAll = function (item, replacement) {
			 var retVal = '';
			 try{
			  item=item.replace('\\','\\\\').replace('$','\\$').replace('*','\\*').replace('.','\\.').replace('?','\\?').replace('+','\\+').replace('(','\\(').replace(')','\\)').replace('/','\\/').replace('[','\\[').replace(']','\\]').replace('{','\\{').replace('}','\\}').replace('|','\\|');
			  //alert(item);
			  retVal=this.replace( new RegExp(item,"g"), replacement );
			 }
			 catch(ex){
			  //alert(ex);
			  var str=this, aOccurs = str.splitStr(item);
			  for(var i = 0; i < aOccurs.length; i++)
			  retVal += aOccurs[i] + ((aOccurs.length - 1)==i ? '' : replacement);
			 }
			 return retVal;
			}
		},
		
		mMap : function (arr, func) {
			/*for (var i=0;i<arr.length;i++) {
				arr[i]=func(arr[i]);
			}*/
			for (var word in arr) {
				arr[word]=func(arr[word]);
			}
		},
		
		// add-remove event listener
		mListener : function ( bAdd, oNode, sEvent, oHandler, bCapture ) {
			if ( document.addEventListener ) oNode [ bAdd ? "addEventListener" : "removeEventListener" ] ( sEvent, oHandler, bCapture );
			else if ( document.attachEvent ) oNode [ bAdd ? "attachEvent" : "detachEvent" ] ( "on" + sEvent, oHandler );
			else oNode [ "on" + sEvent ] = bAdd ? oHandler : null;
		},
		
		// emulate Element.contains
		mContains : function ( oNode, oTarget ) {
			var bContains = false;
			while ( oNode.parentNode ) 
				if ( oNode.parentNode == oTarget ) { bContains = true; break; }
				else oNode = oNode.parentNode;
			return bContains;
		},
		
		// get ancestor by nodename
		mGetAncestorByNodeName : function ( oNode, sNodeName ) {
			while ( oNode.parentNode ) {
				if ( oNode.parentNode.nodeName.toLowerCase () == sNodeName ) { 
					return oNode.parentNode; 
					break; 
				}
				else oNode = oNode.parentNode;
			}
			return null;
		},
		
		// recursive nodetree infiltrator
		mInfectnodetree : function ( oNode, oHandler ) {
			oHandler ( oNode );
			var i = 0; while ( i < oNode.childNodes.length ) {
				if ( oNode.childNodes.item ( i ).nodeType == Node.ELEMENT_NODE ) {
					oTools.mInfectnodetree ( oNode.childNodes.item ( i ), oHandler );
				}
				i++;
			}
		},
		
		// hack stylesheets
		mDeclare : function ( sClasses ) {
			if ( oClient.bMozilla ) {
				var oSheet = document.styleSheets [ document.styleSheets.length - 1 ];
				if ( oSheet ) oSheet.insertRule ( sClasses, oSheet.cssRules.length );
			}
			else document.write ( "<style type=\"text/css\">" + sClasses + "</style>" );
		},
		
		// shorthand elements by ID
		mMount : function () {
			var i = 0, sRef; 
			while (( sRef = arguments [ i++ ]) != null ) {
				this [ sRef ] = document.getElementById ( sRef ) ? document.getElementById ( sRef ) : null; 
			}
		},
		
		// measure
		mWindow : function ( sProperty ) {
			var iReturn;
			var oDocelement = document [ "documentElement" ? "documentElement" : "body" ];
			switch ( sProperty ) {
				case "xscroll":	iReturn = window.pageXOffset ? window.pageXOffset : oDocelement.scrollLeft; break;
				case "yscroll":	iReturn = window.pageYOffset ? window.pageYOffset : oDocelement.scrollTop; break;
				case "height" : iReturn = window.innerHeight ? window.innerHeight : document.body.clientHeight; break;
				case "width"  :	iReturn = window.innerWidth ? window.innerWidth : document.body.clientWidth+15; break;
				case "top"    :	iReturn = oClient.bIE ? window.screenTop : window.screenY; break;
				case "left"   :	iReturn = oClient.bIE ? window.screenLeft : window.screenX; break;
			}
			return isNaN ( iReturn ) ? 0 : iReturn;
		}
}

/**
 * layout manager
 */
var oLayout = {

		mInit : function () {
			
			// mount shorthands
			oLayout.oRoot = document [ document.documentElement ? ( oClient.bIEmac ? "body" : "documentElement" ) : "body" ];
			oLayout.mMount = oTools.mMount;
			oLayout.mMount ( "main", "worksheet");
			oLayout['worksheet'].initialWidth=oLayout['worksheet'].offsetWidth;
			
			// flip accesskey infobox
			oLayout.oRoot.onkeydown = function ( e ) {
				var oKeys = document.getElementById ( "accesskeys" );
				e = e ? e : window.event;
				var iKey = e.keyCode;	
				if ( iKey != 18 && iKey != 17 && e.altKey ) {
					var sKey = String.fromCharCode ( iKey );
					if ( sKey == "0" && oKeys ) {
						oKeys.style.display = oKeys.style.display != "block" ? "block" : "none";
						oKeys.onclick = function () {
							return false;
						}
					}
					// implement mozilla-like acceskeys for explorer
					else if ( oClient.bIEwin ) {
						var sNode = e.srcElement.nodeName.toLowerCase ();
						var oLink = oLinks.oAccesskeys [ sKey.toLowerCase ()];
						if ( oLink && sNode != "input" && sNode != "textarea" ) {
							if ( oLink.onclick && oLink.fireEvent ) {
								try { oLink.fireEvent ( "onclick" )}
								catch ( exception ) {}
							} else document.location = oLink.href;
						}
					}
				}
				
			}
			
			// explorer specific
			if ( oClient.bIEwin ) {
			
				// setup min-width/max-width controllers
				if ( oLayout.workspace ) oLayout.mFlex ( oLayout.workspace );
				if ( oLayout.toolbar ) oLayout.mFlex ( oLayout.toolbar );
			
				// silence dummy links
				oLayout.oRoot.attachEvent ( "onclick", function () {
					var oNode = window.event.srcElement;
					if ( oNode.href && oNode.href.indexOf ( oGod.DUMMY_LINK ) !=-1 ) 
						window.event.returnValue = false;
				});
			}
			 
			// add subscriptions
			oGod.mSubscribe ( "onload statements evaluated", oLinks.mInit );
			oGod.mSubscribe ( "onload statements evaluated", oLayout.mOpen );
		},
		
		// manage spots and toolbar on horizontal adjustments
		mSpot : function () {
			if ( !oLayout.spots || oLayout.bFixed ) return;
			else if ( !oLayout.spots.iLimit ) oLayout.spots.iLimit = 852;
			if ( oLayout.workspace.offsetWidth < oLayout.spots.iLimit && ( oLayout.spots ? oLayout.spots.className == "" : true )) {
				if ( oLayout.spots ) oLayout.spots.className = "lowresolution";
			}
			else if ( oLayout.workspace.offsetWidth >= oLayout.spots.iLimit && ( oLayout.spots ? oLayout.spots.className != "" : true )) {
				if ( oLayout.spots ) oLayout.spots.className = "";
			}
		},
		
		// setup toolbar control
		mScroll : function () {
			if ( !oLayout.toolbar ) return;
			else if ( oClient.bMozilla ) { // patching bug #189308 [bug-dependant patch!]
				document.documentElement.addEventListener ( "DOMAttrModified", function ( e ) {
					if ( e.attrName == "curpos" ) oLayout.mToolbar ();
				}, false );
			}
			else ( oClient.bIEwin ? oLayout.main : window ).onscroll = oLayout.mToolbar;
		},
		
		// manage toolbar on vertical adjustments
		mToolbar : function ( bFloat ) {
			if ( oClient.bIEmac ) {
				oLayout.stage.appendChild ( oLayout.toolbar );
				return;
			}
			else if ( !oLayout.toolbar || (oLayout.toolbar.bFloat != null && oLayout.toolbar.bFloat == false )) return;
			else if ( bFloat == false ) {
				oLayout.stage.appendChild ( oLayout.toolbar );
				oLayout.toolbar.bFloat = false;
				return;
			}
			oLayout.toolbar.style.left = oLayout.workspace.offsetLeft + 1 + "px";
			oLayout.iScroll = oClient.bIEwin ? oLayout.appspace.scrollTop : window.pageYOffset ? window.pageYOffset : document.body.scrollTop;
			oLayout.iClientHeight = window.innerHeight ? window.innerHeight : document.body.clientHeight;
			
			var b1 = oLayout.toolbar.offsetTop > oLayout.workspace.offsetHeight - oLayout.iScroll - 60;
			var b2 = oLayout.workspace.offsetHeight - oLayout.iScroll - oLayout.iClientHeight > 60;
			switch ( oLayout.toolbar.parentNode ) {
				case document.body :
					if ( b1 ) oLayout.stage.appendChild ( oLayout.toolbar );
					break;
				case oLayout.stage :
					if ( b2 ) document.body.appendChild ( oLayout.toolbar );
					break;
				default :
					if ( b1 ) oLayout.stage.appendChild ( oLayout.toolbar );
					if ( b2 ) document.body.appendChild ( oLayout.toolbar );
					break;
			}
			if ( oLayout.toolbar.flex ) oLayout.toolbar.flex ();
		},
		
		// hide while loading
		mClose : function () {
			oTools.mDeclare ( "#worksheet { visibility:hidden; }" );
		},
		
		// show when loaded
		mOpen : function () {
			oLayout.mToolbar ();
			if ( oLayout.worksheet ) oLayout.worksheet.style.visibility = "visible";
			oGod.mBroadcast ( "core functions evaluated" );
		},
		
		// call manually to update layout when doing display adjustments
		mUpdate : function () {
			oLayout.mToolbar ();
			if ( oClient.bIEwin && oLayout.toolbar ) { // bug
				oLayout.toolbar.style.display = "none";
				oLayout.toolbar.style.display = "block";
			}
			oGod.mBroadcast ( "layout updated" );
		},
		
		// pseudoimplement min-width/max-width for explorer
		mFlex : function ( oNode ) {
		 
			var bToolbar	= oNode == oLayout.toolbar;
			var sAutoflex	= oNode.currentStyle.width;
			var iMaxclient	= 964;
			var iMinclient	= 770;
			var iMinwidth	= 708;
			var iMaxwidth	= 900;
	
			oNode.flex = function () {
				if ( bToolbar && this.parentNode == oLayout.stage ) { // unflex fixed toolbar
					this.style.width = "100%";
					return;
				}
				var iWidth = window.oTools.mWindow ( "width" );
				if ( iWidth > iMaxclient && this.sFlex != "max" ) this.sFlex = "max";
				else if ( iWidth < iMinclient && this.sFlex !="min" ) this.sFlex = "min";
				else if ( iWidth < iMaxclient && iWidth > iMinclient && this.sFlex != "auto" ) this.sFlex = "auto";
				switch ( this.sFlex ) {
					case "min" :
						this.style.width = iMinwidth + ( bToolbar ? 15 : 0 ) + "px";
						break;
					case "max" :
						this.style.width = iMaxwidth + ( bToolbar ? 15 : 0 ) + "px";
						break;
					case "auto" :
						this.style.width = sAutoflex;
						break;
				}
			}
			oNode.flex ();
			window.attachEvent ( "onresize", function () { oNode.flex (); });
		},
		mPrint : function () { // macintosh explorer no cant print
			try { window.print (); }
			catch ( exception ) {
				alert ( "Din browser understotter ikke automatisk print." );
			}
		}
}

/*
 * scanning and modifying document links
 */
var oLinks = {

		oAccesskeys : {},
		aHints : [],

		// general link treatment - collect accesskeys and setup focus
		mInit : function () {
		
			var oLink, i = 0, sHref = document.location.href.toString ();
			while (( oLink = document.links [ i++ ]) != null ) {
				var sKey = oLink.getAttribute ( "accesskey" );
				if ( sKey ) oLinks.oAccesskeys [ sKey ] = oLink;
				if ( oLink.href == sHref && !oClient.bOpera ) {
					oLayout.oFocus = oLink;
					var focus = function () {
						try { oLayout.oFocus.focus ();} 
						catch ( hiddenElementException ) {};
					}
					oGod.mSubscribe ( "core functions evaluated", focus );
				}
				if ( oLink.rel ) oLinks.mRel ( oLink );
			}
			oLinks.mHints ();
			oGod.mBroadcast ( "hyperlink actions implemented" );
		},
		
		// special link treatment
		mRel : function ( oLink ) {
			
			function lookup ( sRel ) { // lookup rel attribute
				var rel = oLinks.oRels [ sRel ];
				if ( rel ) rel ( oLink );
				else {
					// lookup special rel attributes
					var split = sRel.split ( "#" );
					var specialrel =  oLinks.oRels [ split [ 0 ]];
					if ( specialrel ) specialrel ( oLink, split [ 1 ]);
				}
			}
			// parsing whitespace separated list of rels
			var i = 0, sRel, aRels = oLink.rel.split ( " " );
			while (( sRel = aRels [ i++ ]) != null ) lookup ( sRel );
		},
		
		// various window openers
		mPopup : function ( oLink, sArgs ) {
			var aTitles = [
				"Siden abner i et nyt vindue",
				"Opens a new window",
				"Achtung popup"
			];
			if ( !oLink.title ) 
				oLink.title = aTitles [ oGod.iLanguage ];
			if ( arguments [ 1 ]) {
				oLink.onclick = function () {
					window.open ( oLink.href, "", sArgs );
					return false;
				}
			}
			else oLink.target = "_blank";
		},
		
		// incrementally z-index hints - in reverse document order, starting at 10
		mHints : function () {
			var z = 10, i = oLinks.aHints.length, oLink;
			while (( oLink = oLinks.aHints [ --i ]) != null ) {
				oLink.style.zIndex = z++;
			}
		},
		
		// methods to match rel-attributes [extended by various scripts]
		oRels : {
			pdf : function ( oLink ) { 
				oLinks.mPopup ( oLink );
			},
			external : function ( oLink ) { 
				oLinks.mPopup ( oLink );
			},
			elearning : function ( oLink ) {
				var sArgs = "width=791,height=571,scrollbars=0,resizeable=0";
				oLinks.mPopup ( oLink, sArgs );
			},
			ebanking : function ( oLink ) {
				var sArgs = "status=1,scrollbars=1,resizable=1";
				oLinks.mPopup ( oLink, sArgs );
			},
			popup : function ( oLink, sType ) {
				var args = "";
				if ( arguments [ 1 ]) {
					var iW = sType == "centerfold" ? 800 : sType == "spreadfold" ? 600 : 454;
					var iH = 571;
					var iT = 0.5 * ( oTools.mWindow ( "height" ) - iH );
					var iL = 0.5 * ( oTools.mWindow ( "width" ) - iW );
					args = "width=" + iW + ",height=571,top=" + iT + ",left=" + iL + ",status=1,scrollbars=1,resizable=1";
				}
				oLinks.mPopup ( oLink, args );
			},
			hint : function ( oLink ) {
				oLinks.aHints.push ( oLink );
				oLink.onfocus = function ( e ) {
					e = e ? e : window.event;
					var bActivate = e.type == "focus";
					this.className = this.className [ bActivate ? "attach" : "detach" ] ( "selected" );
				}
				oLink.onblur = oLink.onfocus;
				if ( oClient.bOpera ) {
					// and safari too?
					oLink.onclick = oLink.focus;
				}
			}
		}
}

/**
 * emulate png alphatransparency for explorer
 */
var oTabs = { // 
		
		// transforming tabs onload
		mInit : function () {
			if ( oClient.bIEwin && document.namespaces ) { // pass ie55+
				
				var oT = document.getElementById ( "tabs" );
				if ( oT ) {
					try {
						var i = 0, tab, aT = oT.getElementsByTagName ( "li" );
						while (( tab = aT.item ( i++ )) != null ) setup ( tab );
						oGod.mOnresize ( function () { // rendering bug
							oT.style.display = "none";
							oT.style.display = "block";
						});
						oT.className = "transformed";
					}
					catch ( exception ) { // mysterious exception known to some systems...
						return;
					}
				}
				function update () {
					var display = window.event.type == "mouseover" ? "inline" : "none";
					this [ "right" ].style.display = display;
					this [ "left"  ].style.display = display;
				}
				function setup ( oNode ) {
					function convert ( position, node ) {
						var image 			= document.createElement ( "img" );
						image.src 			= "/inc/graphics/core/x.gif";
						var clone			= image.cloneNode ( true );
						var background 		= node.currentStyle.backgroundImage.split ( '"' )[ 1 ];
						image.style.filter 	= "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + background + "',sizingMethod='crop');";
						clone.style.filter 	= "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + background.replace ( "off", "on" ) + "',sizingMethod='crop');";
						oNode [ position ]	= clone;
						node.appendChild 	( image );
						node.appendChild	( clone );
					}
					convert ( "right", oNode.getElementsByTagName ( "span" ).item ( 0 ));
					convert ( "left", oNode.getElementsByTagName ( "a" ).item ( 0 ));
					oNode.update = update;
					oNode.onmouseover = oNode.update;
					oNode.onmouseout = oNode.update;
					oNode.update ();
				}
			}
		}
}

/**
 * navigationlists
 */
var oMenus = {

		// scan navigationlists
		mInit : function () {
			var i = 0, oList, aLists = document.getElementsByTagName ( "ul" );
			while (( oList = aLists.item ( i++ )) != null ) { 
				if ( oList.className == "nl" ) {
					if ( oList.parentNode.id == "topmenu" ) oMenus.mTopmenu ( oList );
					else oMenus.mSubmenu ( oList );
				}
			}
		},
		
		// topmenu
		mTopmenu : function ( oList ) {
		
			var self = this;
			
			// expand
			function expand ( e ) {
			
				e = e ? e : window.event;
				if ( e.keyCode && e.keyCode != 13 ) return;
				var oA = e.target ? e.target : e.srcElement;
				if ( oA.nodeType == Node.TEXT_NODE ) oA = oA.parentNode;
				if ( !oA.href || oA.bToolbox ) return;
				else oList.onmouseup = listen;
				
				if ( oA.href == oGod.DUMMY_LINK ) {
				
					var oLI = oA.parentNode;
					var oUL = oLI.parentNode;	
					reset ( oUL.getElementsByTagName ( "ul" ));
					reset ( oUL.getElementsByTagName ( "a" ));
					
					try {
						oLI.getElementsByTagName ( "ul" ).item ( 0 ).className = "active";
						if ( oUL.className == "active" ) oUL.className = "on";
						if ( self.oTimeout ) clearTimeout ( self.oTimeout );
						self.oTimeout = setTimeout ( collapse, 12000 );
						oA.className = "on";
					}
					catch ( exception ) {
						oUL.className = "on";
						oA.className = "selected";
						if ( self.oTimeout ) window.clearTimeout ( self.oTimeout );
					}
				}
			}
			
			// collapse
			function collapse () {
			
				reset ( oList.getElementsByTagName ( "ul" ));
				reset ( oList.getElementsByTagName ( "a" ));
				if ( self.oTimeout ) window.clearTimeout ( self.oTimeout );
				
				if ( aSelects.length ) {
					var i = 0, oA;
					while (( oA = aSelects [ i++ ]) != null ) {
						var oLI = oA.parentNode;
						var oUL = oLI.getElementsByTagName ( "ul" ).item ( 0 );
						if ( oUL ) {
							oUL.className = "on";
							oA.className = "on";
						}
						else oA.className = "selected";
					}	
				}
			}
			
			// listen
			function listen () {
				oLayout.oRoot.onmousedown = function ( e ) {
					e = e ? e : window.event;
					var oNode = e.target ? e.target : e.srcElement;
					if ( !oTools.mContains ( oNode, oList )) collapse ();
					this.onmousedown = null;
				}
			}
			
			// reset
			function reset ( aNodes ) {
				if ( aNodes.length ) {
					var i = 0, oNode;
					while (( oNode = aNodes.item ( i++ )) != null ) {
						if ( !oNode.bToolbox && oNode.className != "" ) 
							oNode.className = "";
					}
				}
			}
			
			// enable keyboard navigation
			var i = 0, aSelects = [], oLink, aLinks = oList.getElementsByTagName ( "a" );
			while (( oLink = aLinks.item ( i++ )) != null ) {
				if ( !oLink.href ) oLink.href = oGod.DUMMY_LINK;
				if ( oLink.className == "on" || oLink.className == "selected" ) 
					aSelects [ aSelects.length ] = oLink;
			}
			oList.onmousedown = expand;
			oList.onkeydown = expand;
		},
		
		// submenus
		mSubmenu : function ( oList ) {
	
			// action
			function action ( e ) {
				e = e ? e : window.event;
				if ( e.type == "keydown" && e.keyCode != 13 ) return;
				var oNode = e.target ? e.target : e.srcElement;
				if ( oNode.nodeType == 3 ) oNode = oNode.parentNode;
				var oList = oNode.parentNode.getElementsByTagName ( "ul" ).item ( 0 );
				var bUpdate = true;
				switch ( oNode.className ) {
					case "label" : 
						oNode.className = "on"; 
						oList.className = "on"; 
						break;
					case "on" : 
						oNode.className = "label"; 
						oList.className = ""; 
						break;
					default : 
						bUpdate = false;
				}
				oLayout.mUpdate ();
			}
			// enable keyboard navigation + optional expand sitemap
			var i = 0, oLink, aLinks = oList.getElementsByTagName ( "a" ), bSitemap = document.getElementById ( "sydbanksitemap" );
			while (( oLink = aLinks.item ( i++ )) != null ) {
				if ( !oLink.href ) oLink.href = oGod.DUMMY_LINK;
				if ( bSitemap && oLink.className == "label" ) {
					oLink.className = "on";
					oLink.parentNode.getElementsByTagName ( "ul" ).item ( 0 ).className = "on";
				}
			}
			oList.onmousedown = action;
			oList.onkeydown = action;
		}
}

/**
 * topmenu toolbox
 */
var oBox = {
		
		mInit : function () {
			
			var oTopmenu = document.getElementById ( "topmenu" );
			var oToolbox = document.getElementById ( "toolbox" );
			
			// setup
			if ( oToolbox && oTopmenu ) {
				protect ( oToolbox );
				oToolbox.onmouseover = show;
				oToolbox.onkeydown = show;
				oToolbox.onmouseup = hide;
				oTopmenu.onmouseover = function ( e ) {
					if ( e ) e.stopPropagation ();
					else window.event.cancelBubble = true;
				}
			}
			// protect toolbox members from topmenu mechanics
			function protect ( node ) {
				if ( node.nodeType == Node.ELEMENT_NODE ) {
					node.bToolbox = true;
				}
				var i = node.childNodes.length;
				while ( i > 0 ) protect ( node.childNodes.item ( --i ));
			}
			// show
			function show ( e ) {
				e = e ? e : window.event;
				if ( e.type == "keydown" ) {
					if ( e.keyCode == 9 ) return;
					function collapse ( event ) {
						var oNode = event.target ? event.target : event.srcElement;
						if ( !oTools.mContains ( oNode, oToolbox )) {
							hide ();
							this.onfocus = null;
						}
					}
					// TODO: focus event no can't bubble in explorer
					oLayout.workspace.onfocus = collapse;
				}
				if ( oToolbox.className == "" ) {	
					oToolbox.className = "open";
					oToolbox.onmouseover = null;
					document.body.onmouseover = hide;
				}
			}
			// hide
			function hide ( e ) {
				setTimeout ( function () {	
					oToolbox.className = "";
					oToolbox.onmouseover = show;
					oTopmenu.onmouseout = null;
					document.body.onmouseover = null;
				}, 250 );
			}
		}
}

// Custom XML Class
var ITHXml = function(xml, alertOnError){
	// Object custom properties
	this.alertOnError = alertOnError ? true : false;
	this.DOMDocument = null;
	//Parsing parameter xml to DOM Document
	this.CreateDOMDocument(xml);
	if(alertOnError && this.CreateDOMDocument == null)
		alert('XML parameter is null or cannot parse to XML!');
}

ITHXml.prototype.CreateDOMDocument = function(xml){
	try{
		if(typeof(xml) == 'string'){
			if(oClient.bIE){
				var xmlDocVersions = new Array("Msxml2.DOMDocument.5.0", "Msxml2.DOMDocument.4.0", "Msxml2.DOMDocument.3.0", "Msxml2.DOMDocument", "Microsoft.DOMDocument", 'MSXML2.DOMDocument', 'Microsoft.XmlDom'); 
				for(var i = 0; i < xmlDocVersions.length; i++){
					try{
						this.DOMDocument = new ActiveXObject(xmlDocVersions[i]);
						this.DOMDocument.async = false;
						this.DOMDocument.resolveExternals = false;						
						this.DOMDocument.loadXML(xml);
					}catch(e){this.DOMDocument = null;}
				}
			}
			else if(document.implementation.createDocument){
				var parser = new DOMParser();
				this.DOMDocument = parser.parseFromString(xml, "text/xml");
			}
		}
		else if(typeof(xml) == 'object'){
			this.DOMDocument = xml;
		}
	}
	catch(ex){this.errorHandling(ex);}
}

ITHXml.prototype.errorHandling = function(oError){
	if(this.alertOnError)
		alert("An exception occurred in the script.\nError name: " + oError.name + ".\nError description: " + oError.description + ".\nError number: " + oError.number + ".\nError Message: " + oError.message); 
}

ITHXml.prototype.SelectNodes = function( xpath ){
	try{
		if ( navigator.userAgent.indexOf('MSIE') >= 0 )		// IE
			return this.DOMDocument.selectNodes( xpath ) ;
		else// Gecko
		{
			var aNodeArray = new Array();
	
			var xPathResult = this.DOMDocument.evaluate( xpath, this.DOMDocument, this.DOMDocument.createNSResolver(this.DOMDocument.documentElement), XPathResult.ORDERED_NODE_ITERATOR_TYPE, null) ;
			if ( xPathResult ) 
			{
				var oNode = xPathResult.iterateNext() ;
				while( oNode )
				{
					aNodeArray[aNodeArray.length] = oNode ;
					oNode = xPathResult.iterateNext();
				}
			} 
			return aNodeArray ;
		}
	}
	catch(e){this.errorHandling(e);return null;}
}

ITHXml.prototype.GetText = function(oNode){
	try{
		if(oClient.bIE) return oNode.text;
		else return oNode.textContent;
	}
	catch(e){this.errorHandling(e);return null;}
} 

ITHXml.prototype.SelectSingleNode = function( xpath ){
	try{
		if ( navigator.userAgent.indexOf('MSIE') >= 0 )		// IE
			return this.DOMDocument.selectSingleNode( xpath ) ;
		else// Gecko
		{
			var xPathResult = this.DOMDocument.evaluate( xpath, this.DOMDocument, this.DOMDocument.createNSResolver(this.DOMDocument.documentElement), 9, null);
			if ( xPathResult && xPathResult.singleNodeValue )
				return xPathResult.singleNodeValue ;
			else	
				return null ;
		}
	}
	catch(e){this.errorHandling(e);return null;}
}



if ( oClient.mPass ()) { // scripting for friendly browsers only
	// hide while loading
	oLayout.mClose ();
	
	// listen
	window.onload = oGod.mLoad;
	window.onresize = oGod.mResize;
	var oPageLoaderListener = setInterval('pageIsLoaded()', 50);
	
	oGod.mOnload ( // onload statements
		oTools.mInit,
		oLayout.mInit,
		oMenus.mInit,
		oBox.mInit,
		oTabs.mInit,
		oLayout.mScroll,
		oLayout.mSpot
	);
	oGod.mOnresize ( // resize statements
		oLayout.mSpot,
		oLayout.mToolbar,
		oLayout.mUpdate
	);

	function pageIsLoaded(){
		if(document.getElementById('worksheet')){
			clearInterval(oPageLoaderListener);
			window.onload = oGod.mLoad;
			window.onresize = oGod.mResize;
		}
	}
	
}
