// a few element ids that we need
__EUI_ID_DRAGPOINTER = "__eui_dragpointer";
__EUI_ID_DRAGSYMBOL_NO = "__eui_dragsymbol_no";
__EUI_ID_DRAGSYMBOL_YES = "__eui_dragsymbol_yes";
__EUI_ID_ANCHOR = "__eui_anchor";
__EUI_ID_INPUT_TEXT = "__eui_input_text";
__EUI_ID_INPUT_OK = "__eui_input_ok";
__EUI_ID_INPUT_CANCEL = "__eui_input_cancel";
// a few images that this funcionality works with
__EUI_ICON_TITLEBAR = "images/eui/__eui_gradient.png";
// css class extensions
__EUI_DRAGCLASSEXTENSION = "_drag";
__EUI_DROPCLASSEXTENSION = "_drop";
// custom attributes that can / need to be set in templates
__EUI_ATTRIBUTE_DRAGCLASS = "dragclass";				// the drag class of an element
__EUI_ATTRIBUTE_DROPCLASS = "dropclass";				// the ctx drop class(es, comma-separated) of an element
__EUI_ATTRIBUTE_CTXCLASS = "ctxclass";					// the ctx menu class of an element
__EUI_ATTRIBUTE_CTXID = "ctxid";							// the ctx id of the item whose ctx menu has been opened
__EUI_ATTRIBUTE_CTXINDEX = "ctxindex";					// the index of a menu entry, a power of 2
__EUI_ATTRIBUTE_CTXMODE = "ctxmode";					// the privilege configuration of a menu entry read from db
__EUI_ATTRIBUTE_CTXOMIT = "ctxomit";					// the privilege configuration of a menu entry read from db
__EUI_ATTRIBUTE_CTXRETURN = "ctxreturn";				// the retun value of a dialog opened via ctx menu
__EUI_ATTRIBUTE_CTXLABEL = "ctxlabel";					// the ctx menu and dialog label
__EUI_ATTRIBUTE_CTXDESCRIPTION = "ctxdescription";	// the ctx menu and dialog description
__EUI_ATTRIBUTE_FRAMENAME = "framename";				// the name of the frame where the initiating operation took place
__EUI_ATTRIBUTE_FORCEUI = "forceui";					// "yes" if a dialog can only be closed with ok when text is entered, "no" otherwise
// styles that need to be defined in eui.css
__EUI_CLASSNAME_FRAME = "eui_frame";
__EUI_CLASSNAME_CTXMENU = "eui_contextmenu";
__EUI_CLASSNAME_CTXMENU_ENTRY = "eui_contextmenuentry";
__EUI_CLASSNAME_CTXMENU_ENTRY_SELECTED = "eui_contextmenuentry selected";
__EUI_CLASSNAME_CTXMENU_HAS_SUBENTRIES = "eui_has_subentries";
__EUI_CLASSNAME_INFO = "eui_info";
__EUI_CLASSNAME_DLGWINDOW = "eui_dialogwindow";
__EUI_CLASSNAME_DLGTITLE = "eui_titlebar";
__EUI_CLASSNAME_DLGTITLE_DIV = "eui_titlediv";
__EUI_CLASSNAME_DLGMESSAGE_BOX = "eui_message_box";
__EUI_CLASSNAME_DLGMESSAGE = "eui_message";
__EUI_CLASSNAME_DLGINPUT_TEXT = "eui_textbox";
__EUI_CLASSNAME_DLGINPUT_OK = "eui_ok";
__EUI_CLASSNAME_DLGINPUT_CANCEL = "eui_cancel";
__EUI_CLASSNAME_DRAGSTATE = "eui_dragstate";
__EUI_CLASSNAME_POINTERIMGNO = "eui_pointerimgno";
__EUI_CLASSNAME_POINTERIMGYES = "eui_pointerimgyes";
// figure out the mouse button IDs. IE has them as l=1, m=4, r=2, Mozilla as l=0, m=1, r=2
__EUI_MBUTTON_LEFT = 0;
__EUI_MBUTTON_MIDDLE = 1;
__EUI_MBUTTON_RIGHT = 2;
// some msie/khtml stuff
if ( __EUI_BROWSER_IS_MSIE ) {
	__EUI_MBUTTON_LEFT = 1;
	__EUI_MBUTTON_MIDDLE = 4;
	__EUI_MBUTTON_RIGHT = 2;
}
if ( __EUI_BROWSER_IS_MSIE || __EUI_BROWSER_IS_APPLEWEBKIT ) {
	// MSIE and KHTML don't have these...
	document.ELEMENT_NODE = 1;
	document.ATTRIBUTE_NODE = 2;
	document.TEXT_NODE = 3;
	document.CDATA_SECTION_NODE = 4;
	document.ENTITY_REFERENCE_NODE = 5;
	document.ENTITY_NODE = 6;
	document.PROCESSING_INSTRUCTION_NODE = 7;
	document.COMMENT_NODE = 8;
	document.DOCUMENT_NODE = 9;
	document.DOCUMENT_TYPE_NODE = 10;
	document.DOCUMENT_FRAGMENT_NODE = 11;
	document.NOTATION_NODE = 12;
}
window.__eui_framedone = false;
if ( "<text>__PIPE_NOINIT</text>" != "1" ) {
	window.onload = __eui_init;
}
document.onkeyup = __eui_checkkey;
if ( typeof( top.__eui_selcount ) == "undefined" ) {
	top.__eui_selcount = -1;
	// __eui_fnmousedown() sets this to the object that has been clicked on, in case of a left button click
	top.__eui_clickobj = null;
	// in case of multi-select (via holding the ctrl key down), this gets filled with a list of all selected objects
	top.__eui_dragobjs = new Array( );
	// the object to drop on. there 's no array for this, as you can onyl drop onto one object at a time, obviously!
	top.__eui_dropobj = null;
	top.__eui_multipleselect = false;
	top.__eui_multiple_x_select = false;
	top.__eui_undraggable_item_marked = false;
	top.__eui_x_boundary = null;
	top.__eui_activebutton = null;		// tracks which button is pressed at a given moment
	top.__eui_dragclass = null;
	top.__eui_dragactive = false;
	top.__eui_rootLeft = 0;
	top.__eui_rootTop = 0;
	top.__eui_allselected = false;
	top.__eui_sdisplay = (navigator.appName.indexOf('Netscape')>-1)?"inherit":"inline";
	// check if MouseEvents (DOM 2.0) are available in this browser
	top.__eui_hasmouseev = document.implementation.hasFeature( "MouseEvents" , "2.0" );
	top.__eui_hasuiev = document.implementation.hasFeature( "UIEvents" , "2.0" );
	top.__eui_hasev = document.implementation.hasFeature( "Events" , "2.0" );
	top.__eui_dragclasses = new Array( );
	top.__eui_ctxevent = null;		// when a context menu is opened, this keeps the event that caused the action. 
	top.__eui_ctxtarget = null;	// after a new event has been fired, MSIE can't apply srcElement onto an older event properly, so we need to remember the object separately. 
	var useragent = navigator.userAgent;
	top.__eui_custom_cursor = false;
	top.__eui_layout_changeable = false;
	top.__eui_trackmode = "";
	top.__eui_gridsize = 3;
	if ( ( useragent.indexOf( "Firefox/1.5" ) > -1 ) ) {
//		top.__eui_custom_cursor = true;
	}
}
// callbackfn is the function that should get called when a drop action takes place.
function __eui_init( ) {
	window.loaded = true;
	if ( ! top.window.loaded ) {
		setTimeout( "__eui_init( )", 1000 );
	} else {
		if ( typeof( __EUI_RELOAD_NOSTATUSRESET ) == "undefined" ) {
			// if there's still a marked object left in another frame, unmark it now as long as we have the info about it
			bcanunmark = false;
			try {
				// usually generates an error if the element is already gone, i.e. after a page reload
				if ( top.__eui_dragobjs[0] == "undefined" ) {
					bcanunmark = false;
				} else {
					bcanunmark = true;
				}
			} catch ( err ) {
				bcanunmark = false;
			}
			if ( bcanunmark == true ) {
				__eui_unmark( top.__eui_dragobjs[0] );
			}
			bcanunmark = false;
			try {
				// usually generates an error if the element is already gone, i.e. after a page reload
				if ( top.__eui_nodragobj == "undefined" ) {
					bcanunmark = false;
				} else {
					bcanunmark = true;
				}
			} catch ( err ) {
				bcanunmark = false;
			}
			if ( bcanunmark == true ) {
				__eui_unmark( top.__eui_nodragobj );
			}
			// reinitialize everything in case a page has reloaded...
			top.__eui_selcount = -1;
			// __eui_fnmousedown() sets this to the object that has been clicked on, in case of a left button click
			top.__eui_clickobj = null;
			// in case of multi-select (via holding the ctrl key down), this gets filled with a list of all selected objects
			if ( __EUI_BROWSER_IS_MSIE ) {
				top.__eui_dragobjs = null;
			} else {
				delete( top.__eui_dragobjs );
			}
			top.__eui_dragobjs = new Array( );
			// the object to drop on. there 's no array for this, as you can onyl drop onto one object at a time, obviously!
			top.__eui_dropobj = null;
			top.__eui_multipleselect = false;
			top.__eui_multiple_x_select = false;
			top.__eui_undraggable_item_marked = true;
		}
		__eui_addevent( document, "mousedown", __eui_fnmousedown );
		__eui_addevent( document, "mouseout", __eui_fnmouseout  );
		__eui_addevent( document, "mouseover", __eui_fnmouseover );
		__eui_addevent( document, "mouseup", __eui_fnmouseup );
		__eui_addevent( document, "mousemove", __eui_fnmousemove );
		if ( __EUI_BROWSER_IS_MSIE ) {
			__eui_addevent( document, "dragstart", __eui_fndrag );
		}
		// MG100310 Safari obviously now fires the mousedown event in said case (see below) but for now we leave this check in here.
		// the reason is that Safari doesn't clear the selection otherwise (i.e. marks the word that the cursor was over) and i haven't found out yet why
		if ( __EUI_BROWSER_IS_APPLEWEBKIT ) {
			// Safari doesn't fire any mousedown event in case of pressing the right mouse button, so attach the contextmenu event to the mousedown handler, as well:
			__eui_addevent( document, "contextmenu", __eui_fnmousedown );
		} else {
			// else just disable the standard context menu
			document.oncontextmenu = __eui_catchctxmenu;
			//document.oncontextmenu = new Function( "return false" );
		}
		// if we're in the root (i.e. top level) document, build the contents that we need for drag and drop.
		if ( top.document == document ) {
			if ( ! document.getElementById( __EUI_ID_DRAGPOINTER ) ) {
				var pointerdiv = document.createElement( "div" );
				pointerdiv.id = __EUI_ID_DRAGPOINTER;
				document.body.appendChild( pointerdiv );
			} else {
				pointerdiv = document.getElementById( __EUI_ID_DRAGPOINTER );
			}
			pointerdiv.style.visibility = "hidden";
			pointerdiv.style.position = "absolute";
			pointerdiv.style.zIndex = "5";
			top.__eui_pointerimgno = document.createElement( "div" );
			top.__eui_pointerimgno.id = __EUI_ID_DRAGSYMBOL_NO;
			top.__eui_pointerimgno.className = __EUI_CLASSNAME_POINTERIMGNO;
			top.__eui_pointerimgyes = document.createElement( "div" );
			top.__eui_pointerimgyes.id = __EUI_ID_DRAGSYMBOL_YES;
			top.__eui_pointerimgyes.className = __EUI_CLASSNAME_POINTERIMGYES;
			if ( __EUI_BROWSER_IS_OPERA ) {	// opera needs sth to "blow up" the div, so give it a dummy img of the needed height.
				dummyimg = document.createElement( "img" );
				dummyimg.style.width = "20px";
				dummyimg.style.height = "22px";
				top.__eui_pointerimgno.appendChild( dummyimg );
				dummyimg = document.createElement( "img" );
				dummyimg.style.width = "20px";
				dummyimg.style.height = "22px";
				top.__eui_pointerimgyes.appendChild( dummyimg );
			}
			// if this div is appended dynamically in IE, all but the folder frame get blanked out.
			// happens only when any of the css props except "display" are set. incredible!
			if ( ! document.getElementById( __EUI_ID_ANCHOR ) ) {
				var anchordiv = document.createElement( "div" );
				anchordiv.id = __EUI_ID_ANCHOR;
				anchordiv.style.display = "none";
				anchordiv.style.position = "absolute";
				anchordiv.style.left = "1px";
				anchordiv.style.top = "1px";
				anchordiv.style.width = "1px";
				anchordiv.style.height = "1px";
				document.body.appendChild( anchordiv );
			}
			// MG090519 allow centered layouts how ever senseful that may be....
			if ( top.document.getElementById( "maintable" ) && anchordiv ) {
				anchordiv.style.left = top.document.getElementById( "maintable" ).offsetLeft + "px";
			}
			pointerdiv.appendChild( top.__eui_pointerimgno );
			pointerdiv.appendChild( top.__eui_pointerimgyes );
			__eui_addevent( document.getElementById( __EUI_ID_ANCHOR ), "click", __eui_snapshot );
			if ( document.createEvent ) {
				__eui_addevent( top.window, "resize", __eui_resize );
				if ( typeof( top.senseresize ) != "undefined" ) {settext
					top.senseresize( );
				}
			}
			window.__eui_framedone = true;
		} else {
			if ( typeof( top.senseresize ) != "undefined" ) {
				top.senseresize( );	// create the correct coords for this document
			}
			window.__eui_framedone = true;
		}
		// assign to all elements without an id a pseudo id attribute so that the drag function works on them
		// MG080111 - in "larger" result lists (40 items or so), this gets _AWFULLY_ slow on MSIE7, so...
		if ( false && ( ! __EUI_BROWSER_IS_MSIE ) ) {
			var alldivs = document.getElementsByTagName( "div" );
			for( var i in alldivs ) {
				if ( ! alldivs[i].id ) {
					alldivs[i].id = "#";
				}
			}
			var allas = document.getElementsByTagName( "a" );
			for( var i in allas ) {
				if ( ! allas[i].id ) {
					allas[i].id = "#";
				}
			}
			var allimgs = document.getElementsByTagName( "img" );
			for( var i in allimgs ) {
				if ( ! allimgs[i].id ) {
					allimgs[i].id = "#";
				}
			}
		}
	}
}
function __eui_catchctxmenu( event ) {
	var myev = (event)?event:window.event;
	if ( ! ( myev.ctrlKey && myev.shiftKey && myev.altKey ) ) {
		var etarget = __eui_geteventsrc( myev );
		if ( ! ( etarget && etarget.getAttribute && etarget.getAttribute( "noctx" ) ) ) {
			return false;
		}
	}
}
function __eui_cleardebug( ) {
	if ( top.frames["debug"] ) {
		top.frames["debug"].location = "about:blank";
	}
}
function __eui_writedebug( sstrp, fieldp ) {
	if ( top.frames["debug"] && top.frames["debug"].document.getElementById( "value" + fieldp ) ) {
		top.frames["debug"].document.getElementById( "value" + fieldp ).value = sstrp;
	}
}
// this function generates us some universal anchor coordinates.
// rootLeft and rootTop are the absolute coords of the document in relation to the top left screen (i.e. monitor) corner
// if there's more than one document (e.g. inside iframes etc.), these are different for each of those.
function __eui_snapshot( event ) {
	if ( __EUI_BROWSER_IS_APPLEWEBKIT ) {
		// KHTMLs event dispatcher function doesn't support the sending of coordinates, so we need to remember them in variables to evaluate the correct screen position of the browser window:
		top.__eui_rootLeft = top.__eui_khtml_screenx - top.__eui_khtml_pagex;
		top.__eui_rootTop = top.__eui_khtml_screeny - top.__eui_khtml_pagey;
	} else {
		if ( typeof( event.x ) != "undefined" ) {
			top.__eui_rootLeft = event.screenX - event.x;
			top.__eui_rootTop = event.screenY - event.y;
		} else {
			top.__eui_rootLeft = event.screenX - event.pageX;
			top.__eui_rootTop = event.screenY - event.pageY;
		}
	}
}
function __eui_resize( event ) {
	top.senseresize( );	// callbackfn
}
function __eui_fndrag( event ) {
	event.returnValue = false;
	event.cancelBubble = true;
	return false;
}
/////////////////////////////////////////////////////////////////////////////////
// check if the ESC was pressed. in that case, close the context menu if open.
/////////////////////////////////////////////////////////////////////////////////
function __eui_checkkey( event ) {
	var myev = (event)?event:window.event;
	var mycode = (myev.charCode)?myev.charCode:myev.keyCode;
	if ( mycode == 27 ) {
		__eui_closecontextmenu( );
	}
}
/////////////////////////////////////////////////////////////////////////////////
// this function gets called whenever a mouse click is performed and returns us
// the coordinates of the left top pixel of the active document in relation to
// the top left screen (i.e. monitor) corner.
/////////////////////////////////////////////////////////////////////////////////
function __eui_trackwinpos( event ) {
	if ( __EUI_BROWSER_IS_MSIE ) {
		var pagex = event.x;
		var pagey = event.y;
		top.document.getElementById( __EUI_ID_ANCHOR ).click( );
	} else if ( __EUI_BROWSER_IS_APPLEWEBKIT ) {
		// the event dispatcher function of KHTML is quite botched, so we need to otherwise remember the click coordinates based on which we adjust the coordinates:
		var nPageOffsetX = 0;
		var nPageOffsetY = 0;
		var localedoc = __eui_finddocument( __eui_geteventsrc( event ) );
		if ( localedoc.pageLeft ) {
			nPageOffsetX = localedoc.pageLeft;
		}
		if ( localedoc.pageTop ) {
			nPageOffsetY = localedoc.pageTop;
		}
		top.__eui_khtml_pagex = event.clientX + nPageOffsetX;
		top.__eui_khtml_pagey = event.pageY + nPageOffsetY;
		top.__eui_khtml_screenx = event.screenX;
		top.__eui_khtml_screeny = event.screenY;
		var myev = top.document.createEvent( "MouseEvents" );
		myev.initEvent( "click", true, true );
		if ( top.document.getElementById( __EUI_ID_ANCHOR ) ) {
			top.document.getElementById( __EUI_ID_ANCHOR ).dispatchEvent( myev );
		}
	} else {
		var nPageOffsetX = 0;
		var nPageOffsetY = 0;
		var localedoc = __eui_finddocument( __eui_geteventsrc( event ) );
		if ( localedoc.pageLeft ) {
			nPageOffsetX = localedoc.pageLeft;
		}
		if ( localedoc.pageTop ) {
			nPageOffsetY = localedoc.pageTop;
		}
		var pagex = event.clientX + nPageOffsetX;
		var pagey = event.pageY + nPageOffsetY;
		var myev = top.document.createEvent( "MouseEvents" );
		var myclick = (Event.CLICK)?Event.CLICK:64;	// no such const for Opera
		myev.initMouseEvent(
			'click' // TYPE OF EVENT
			,false // CAN BUBBLE
			,true // CANCELABLE
			,document.defaultView // VIEW
			,myclick // DETAIL
			,event.screenX // SCREEN-X <--- YOUR 'X' GOES HERE
			,event.screenY // SCREEN-Y <--- YOUR 'Y' GOES HERE
			,pagex // CLIENT-X
			,pagey // CLIENT-Y
			,false // CTRL-KEY
			,false // ALT-KEY
			,false // SHIFT-KEY
			,false // META-KEY
			,__EUI_MBUTTON_LEFT // BUTTON (0=LEFT, 1=MIDDLE, 2=RIGHT)
			,null // RELATED TARGET (=NONE)
		);
		if ( top.document.getElementById( __EUI_ID_ANCHOR ) ) {
			top.document.getElementById( __EUI_ID_ANCHOR ).dispatchEvent( myev );
		}
	}
}
/////////////////////////////////////////////////////////////////////////////////
function __eui_fnmousedown( event ) {
	var etarget = __eui_geteventsrc( event );
	// find out the current document, in case there's more than one (frames, iframes...)
	var hdoc = __eui_finddocument( etarget );
	top.__eui_dragsrc = hdoc;
	// find out where (x,y) on the monitor the active document (i.e. the one that we clicked on) resides
	__eui_trackwinpos( event );
	// on each click, hide the contextmenu if it's open
	__eui_closecontextmenu( );
	top.__eui_ctrlkey_pressed = (event.ctrlKey||event.altKey);
	top.__eui_shiftkey_pressed = event.shiftKey;
	top.__eui_activebutton = event.button;
	if ( ( etarget.tagName != "HTML" ) && hdoc && ( ! etarget.getAttribute( "noeui" ) ) ) {	// MG100311 noeui is needed for Safari etc.
		if ( event.button == __EUI_MBUTTON_LEFT ) {
			if ( ( top.__eui_dragobjs.length == 1 ) && ( ! top.__eui_allselected == true ) && ( ! top.__eui_shiftkey_pressed ) && ( ! top.__eui_ctrlkey_pressed ) ) {
				__eui_unmark( top.__eui_dragobjs[0] );
				if ( __EUI_BROWSER_IS_MSIE ) {
					top.__eui_dragobjs = null;
				} else {
					delete ( top.__eui_dragobjs );
				}
				top.__eui_dragobjs = new Array( );
				top.__eui_selcount = -1;
			} else if ( top.__eui_dragobjs.length == 0 ) {
				top.__eui_x_boundary = etarget.id;	// this enables the use of the shift key functionality even after the first item has already been selected
			}
			if ( top.__eui_nodragobj ) {
				__eui_unmark( top.__eui_nodragobj );
				top.__eui_nodragobj = null;
				top.__eui_selcount = -1;
			}
			// if the left mouse button has been clicked, check if it has the attribute that makes it draggable
			var dragclass = etarget.getAttribute( __EUI_ATTRIBUTE_DRAGCLASS );
			if ( dragclass && ( ( top.__eui_dragclass == null ) || ( dragclass == top.__eui_dragclass ) ) ) {
				// if the element we clicked on is draggable (i.e. it has the dragclass attribute set), set the class as active:
				top.__eui_clickobj = etarget;	// the object that has been clicked onto right now
				// remember the class of the object, so that we can compare it to other objects we click on, in case that the ctrl key is pressed
				top.__eui_dragclass = dragclass;
				if ( hdoc.getElementById( "break" ) ) { hdoc.getElementById( "break" ).style.display = top.__eui_sdisplay; }
				if ( hdoc.getElementById( "break2" ) ) { hdoc.getElementById( "break2" ).style.display = top.__eui_sdisplay; }
				top.__eui_removefromdragbag = null;
				var proceed = true;
				var removeindex = null;
				// check if multi-select is requested by the user
				top.__eui_multipleselect = false;
				top.__eui_multiple_x_select = false;
				if ( top.__eui_ctrlkey_pressed ) {
					top.__eui_multipleselect = true;
				} else if ( top.__eui_shiftkey_pressed ) {
					top.__eui_multiple_x_select = true;
				}
				if ( ! top.__eui_shiftkey_pressed ) {
					// see if the item in our list already has been clicked onto. if yes, skip the next step, as we already did it for that element in a previous run.
					for ( var i = 0; i < top.__eui_dragobjs.length; i++ ) {
						if ( top.__eui_dragobjs[i] == top.__eui_clickobj ) {
							top.__eui_removefromdragbag = top.__eui_dragobjs[i];
							proceed = false;
						}
					}
					// if needed, add the element to the list of already clicked-onto objects. this list gets reset when something else
					// than a valid drag element has been clicked onto and the ctrl key is released (actually happens a little bit further down)
					if ( proceed == true ) {
						top.__eui_selcount++;
						top.__eui_dragobjs[top.__eui_selcount] = etarget;
						// mark the element by using a different css style
						__eui_mark( top.__eui_dragobjs[top.__eui_selcount] );
					}
				} else {
					// if the shift key was held down, mark all items between the first and the current one (respectively the current and the last one) and unmark everything else
					if ( top.__eui_selcount == -1 ) {
						top.__eui_x_boundary = etarget.id;
					}
					var mark_x_active = false;	// is true for all the items in the middle of the selection as well as for the first one
					var mark_x_borderobject = false;	// is true for the first and the last item of the selection
					var allobjs = document.getElementsByTagName( etarget.nodeName );
					var workobjs = top.__eui_dragobjs;
					for ( var objix in allobjs ) {
						if ( ( ( typeof( allobjs[objix].getAttribute ) == "function" ) || ( typeof( allobjs[objix].getAttribute ) == "object" ) ) && allobjs[objix].getAttribute( __EUI_ATTRIBUTE_DRAGCLASS ) && ( allobjs[objix].getAttribute( "dragclass" ) != "" ) ) {
							// check if the element at hand is in the selection range. we select by occurrence in the DOM structure
							if ( ( allobjs[objix].id == top.__eui_x_boundary ) || ( allobjs[objix].id == etarget.id ) ) {
								mark_x_active = (mark_x_active==false)?true:false;	// xor- toggles on/off when entering / leaving the selection range
								mark_x_borderobject = true;								// tells us that this is one of the both objects at the border of the selection range
							}
							if ( ( mark_x_active == true ) || ( mark_x_borderobject == true ) ) {
								workobjs[workobjs.length] = allobjs[objix];
								// mark the element by using a different css style
								__eui_mark( allobjs[objix] );
								if ( top.__eui_x_boundary == etarget.id ) {
									mark_x_active = false;
								}
								mark_x_borderobject = false;
							} else {
								// only remove stuff if it was actually in the list of selected items!
								if ( __eui_inarray( allobjs[objix], workobjs ) ) {
									__eui_unmark( allobjs[objix] );
									for ( var i in workobjs ) {
										if ( workobjs[i] == allobjs[objix] ) {
											workobjs = __eui_removefromarray( i, workobjs );
										}
									}
								}
							}
						}
					}
					// "straighten" the array of selected items so as to not have one item in the list more than once!
					if ( __EUI_BROWSER_IS_MSIE ) {
						top.__eui_dragobjs = null;
					} else {
						delete( top.__eui_dragobjs );
					}
					top.__eui_dragobjs = new Array( );
					for ( var i = 0; i < workobjs.length; i++ ) {
						if ( ! __eui_inarray( workobjs[i], top.__eui_dragobjs ) ) {
							top.__eui_dragobjs[top.__eui_dragobjs.length] = workobjs[i];
						}
					}
					top.__eui_selcount = top.__eui_dragobjs.length - 1;
				}
			} else if ( etarget.getAttribute( __EUI_ATTRIBUTE_CTXMODE ) && ( top.__eui_dragclass == null ) && ( ! etarget.getAttribute( __EUI_ATTRIBUTE_CTXOMIT ) ) ) {
				// if the element we clicked on has a context, we at least react to it with marking it and calling __eui_setbuttonstate()
				top.__eui_nodragobj = etarget;	// the object that has been clicked onto right now
				// mark the element by using a different css style
				__eui_mark( top.__eui_nodragobj );
			} else if ( ! top.__eui_shiftkey_pressed ) {
				// if the element we clicked on is not draggable (either not at all or just because it doesnt fit the active drag class),
				// empty the array of active elements and unmark them by re-setting their css style
				if ( ! top.__eui_ctrlkey_pressed ) {
					top.__eui_multipleselect = false;
					// count of selected elements is 0 now, so we need -1 here, as the increment takes place before adding a new item
					top.__eui_selcount = -1;
					// all the deselection of selected objects is done in __eui_fnmouseup( )
				} else if ( ! top.__eui_shiftkey_pressed ) {
					// comments like above, just we do it here for extended multi select.
					top.__eui_multiple_x_select = false;
					top.__eui_selcount = -1;
				}
				// no object is currently clicked on
				top.__eui_clickobj = null;
			}
		}
		// if the right mouse button has been clicked and the element has a ctxclass attribute assigned
		// and there are menu entries defined for the menu via __eui_ctxmenuadd(), show the menu.
		else if ( event.button == __EUI_MBUTTON_RIGHT ) {
			if ( etarget.getAttribute( __EUI_ATTRIBUTE_CTXCLASS ) ) {
				if ( __EUI_BROWSER_IS_APPLEWEBKIT ) {
					window.getSelection( ).collapse( );
				}
				__eui_opencontextmenu( event );
			}
		}
		if ( event.preventDefault ) {
			if ( etarget.tagName != "INPUT" ) {
				event.preventDefault( );	// stops "default" processing by browsers
			}
		} else {
			if ( etarget.tagName != "INPUT" ) {
				event.cancelBubble = true;	// stops "default" processing by browsers
			}
		}
	}
}
function __eui_selectall( hdoc, tagtype, ctxclass ) {
	var allobjs = hdoc.getElementsByTagName( tagtype );
	hdoc.body.style.cursor = "wait";
	for ( var objix in allobjs ) {
		if ( ( ( typeof( allobjs[objix].getAttribute ) == "function" ) || ( typeof( allobjs[objix].getAttribute ) == "object" ) ) && allobjs[objix].getAttribute( __EUI_ATTRIBUTE_DRAGCLASS ) && ( allobjs[objix].getAttribute( "ctxclass" ) == ctxclass ) ) {
			top.__eui_selcount++;
			top.__eui_dragobjs[top.__eui_selcount] = allobjs[objix];
			// mark the element by using a different css style
			__eui_mark( top.__eui_dragobjs[top.__eui_selcount] );
			top.window.status = "";
		}
	}
	// the first mouse up operation after this is from the context menu, so ignore it. otherwise all selected items instantly get deselected again
	hdoc.body.style.cursor = "";
	top.__eui_allselected = true;
}
// this does the same as above, but it's quicker in that it gets passed an array that contains the ids of elements to select,
// so no search has to take place.
function __eui_selectbyarray( hdoc, aarrp ) {
	hdoc.body.style.cursor = "wait";
	for( var objix = 0; objix < aarrp.length; objix++ ) {
		top.__eui_selcount++;
		//top.__eui_dragobjs[top.__eui_selcount] = hdoc.getElementById( aarrp[objix] );
		top.__eui_dragobjs[top.__eui_selcount] = aarrp[objix];
			// mark the element by using a different css style
		__eui_mark( top.__eui_dragobjs[top.__eui_selcount] );
		top.window.status = "";
	}
	// the first mouse up operation after this is from the context menu, so ignore it. otherwise all selected items instantly get deselected again
	hdoc.body.style.cursor = "";
	top.__eui_allselected = true;
}
function __eui_fnmouseout( event ) {
	var etarget = __eui_geteventsrc( event );
	var hdoc = __eui_finddocument( etarget );
	if ( ( etarget.tagName != "HTML" ) && hdoc ) {
		if ( top.__eui_clickobj && etarget.id != __EUI_ID_DRAGPOINTER ) {
			top.__eui_dragactive = true;
			if ( top.__eui_dropobj ) {
				__eui_unmark( top.__eui_dropobj );
			}
			if ( top.__eui_custom_cursor == true ) {
				etarget.style.cursor = "default";
			} else {
				top.__eui_pointerimgyes.style.display = "none";
				top.__eui_pointerimgno.style.display  = top.__eui_sdisplay;
			}
			top.window.status = "no drop permitted";
		}
	}
}
function __eui_fnmouseover( event ) {
	var etarget = __eui_geteventsrc( event );
	if ( top.__eui_custom_cursor == true ) {
		etarget.style.cursor = "url(images/eui/__eui_nodrop.cur), crosshair";
	}
	var hdoc = __eui_finddocument( etarget );
	if ( ( etarget.tagName != "HTML" ) && hdoc ) {
		var dropclass = etarget.getAttribute( __EUI_ATTRIBUTE_DROPCLASS );
		if ( dropclass ) {
			dropclass = dropclass.split( "," );
		}
		// if the current drag class is compatible with the current drop class(es), activate the drop symbol
		// but only if the mouse button is really held down at the moment. if we are here and this is not the case,
		// it means that a multi-select operation is performed and the ctrl key is pressed.
		if ( __eui_inarray( top.__eui_dragclass, dropclass ) && ( top.__eui_activebutton != null ) && ( ! __eui_inarray( etarget, top.__eui_dragobjs ) ) ) {
			top.__eui_dropobj = etarget;
			if ( ( top.__eui_dragobjs.length > 0 ) ) {
				var proceed = ( top.__eui_dropobj.id ) ? true : false;
				for ( var i = 0; i < top.__eui_dragobjs.length; i++ ) {
					if ( top.__eui_dragobjs[i] == top.__eui_dropobj ) {
						proceed = false;
					}
				}
				if ( proceed == true ) {
					if ( hdoc.getElementById( "break" ) ) { hdoc.getElementById( "break" ).style.display = top.__eui_sdisplay; }
					if ( hdoc.getElementById( "break2" ) ) { hdoc.getElementById( "break2" ).style.display = top.__eui_sdisplay; }
					__eui_mark( top.__eui_dropobj );
					if ( top.__eui_custom_cursor == true ) {
						etarget.style.cursor = "url(images/eui/__eui_drop.cur), pointer";
					} else {
						top.__eui_pointerimgno.style.display  = "none";
						top.__eui_pointerimgyes.style.display = top.__eui_sdisplay;
					}
					top.window.status = "drop is permitted";
				}
			}
		}
		// for whatever reason MSIE hovers over the IFRAME _inside_ the HTML tag (which we need to trap to get the event of empty DIV parts), so exclude the IFRAME from the objects that deselect stuff.
		else if ( top.__eui_dropobj && ( top.__eui_dropobj != etarget ) && ( etarget.tagName != "IFRAME" ) ) {
			__eui_unmark( top.__eui_dropobj );
			top.__eui_dropobj = null;
		}
	}
}
function __eui_fnmouseup( event ) {
	// get the element on which the mouse button was released
	var etarget = __eui_geteventsrc( event );
	if ( ( etarget.tagName == "INPUT" ) && ( etarget.type == "text" ) ) {
//rwh100927 without this in IE no textareas could be selected with mouse click
	} else if ( etarget.tagName == "TEXTAREA" ) {
//rwh100927
	} else {
		if ( __EUI_BROWSER_IS_MSIE ) {
			document.selection.empty( );
		}
		etarget.style.cursor = "default";
	}
	// find out in which document that element resides
	var hdoc = __eui_finddocument( etarget );
	if ( ( etarget.tagName != "HTML" ) && hdoc && ( top.__eui_allselected == false ) ) {
		if ( event.button == __EUI_MBUTTON_LEFT ) {
			var dragdone = false;
			// see if we have some elements in our "drag bag" and also see
			// if the mouse release was performed on a valid drop object
			if ( ( top.__eui_dragobjs.length > 0 ) && top.__eui_dropobj && top.__eui_dropobj.id ) {
				//see if the drop object is not part of the selection list. we don't do a drop onto something that we just dragged!
				if ( ! __eui_inarray( top.__eui_dropobj, top.__eui_dragobjs ) ) {
					if ( __eui_dragdropdispatch( top.__eui_dragobjs, event ) ) {
						dragdone = true;
					}
				}
			}
			// if the ctrl key is not pressed at the moment of the mouse release, deselect all selected items.
			// only the item that was actually clicked on stays selected, as does in windows explorer.
			if ( ( ! top.__eui_ctrlkey_pressed ) && ( ! top.__eui_shiftkey_pressed ) ) {
				if ( top.__eui_dragobjs.length > 0 ) {
					// if more than one item was selected, we deselect everything in any case.
					// if the last item stays selected, it feels quite annoying.
					var unmarkall = ( top.__eui_dragobjs.length > 1 ) ? true : false;
					for( var i = top.__eui_dragobjs.length-1; i >= 0; i-- ) {
						if ( top.__eui_dragobjs[i] ) {
							if ( unmarkall || ( top.__eui_dragobjs[i] != top.__eui_clickobj ) ) {
								__eui_unmark( top.__eui_dragobjs[i] );
								top.window.status = "";
							}
						}
					}
					if ( __EUI_BROWSER_IS_MSIE ) {
						top.__eui_dragobjs = null;
					} else {
						delete ( top.__eui_dragobjs );
					}
					top.__eui_dragobjs = new Array( );
					top.__eui_selcount = -1;
					if ( unmarkall == false ) {
						top.__eui_dragobjs[0] = top.__eui_clickobj;
						top.__eui_selcount = 0;
					}
				}
				__eui_unmark( top.__eui_dropobj );
				top.__eui_dragclass = null;
				top.__eui_dropobj = null;
			}
			else if ( top.__eui_ctrlkey_pressed ) {
				for ( var i in top.__eui_dragobjs ) {
					if ( ( top.__eui_dragobjs[i] == top.__eui_removefromdragbag ) && ( top.__eui_removefromdragbag != null ) ) {
						top.__eui_selcount--;
						__eui_unmark( top.__eui_dragobjs[i] );
						top.__eui_dragobjs = __eui_removefromarray( i, top.__eui_dragobjs );
						top.__eui_removefromdragbag = null;
					}
				}
			}
			top.__eui_clickobj = null;
			if ( top.__eui_custom_cursor == true ) {
				etarget.style.cursor = "default";
			}
			top.document.getElementById( __EUI_ID_DRAGPOINTER ).style.visibility = "hidden";
			top.__eui_dragactive = false;
			if ( hdoc.getElementById( "break" ) ) { hdoc.getElementById( "break" ).style.display = "none"; }
			if ( hdoc.getElementById( "break2" ) ) { hdoc.getElementById( "break2" ).style.display = "none"; }
			if ( typeof( __eui_setbuttonstate ) == "function" ) {
				__eui_setbuttonstate( event );
			}
		}
	}
	__eui_endtrack( event );
	top.__eui_allselected = false;
	top.__eui_activebutton = null;
	top.__eui_ctrlkey_pressed = null;
	top.__eui_shiftkey_pressed = null;
	top.__myscroll=0;
}
function __eui_fnmousemove( event ) {
	var etarget = __eui_geteventsrc( event );
	if ( ( __EUI_BROWSER_IS_MSIE ) && ( etarget.tagName != "INPUT" ) && top.__eui_activebutton ) {
		document.selection.empty( );
	}
	var hdoc = __eui_finddocument( etarget );
	if ( top.document.getElementById( __EUI_ID_DRAGPOINTER ) ) {
		top.document.getElementById( __EUI_ID_DRAGPOINTER ).style.visibility = "hidden";
		if ( ( etarget.tagName != "HTML" ) && hdoc ) {
			if ( top.__eui_dragactive ) {
				xy = __eui_getcoords( event );
				top.document.getElementById( __EUI_ID_DRAGPOINTER ).style.left = ( xy[0] + 15 ) + "px" ;
				top.document.getElementById( __EUI_ID_DRAGPOINTER ).style.top = ( xy[1] + 20 ) + "px";
				top.document.getElementById( __EUI_ID_DRAGPOINTER ).style.visibility = "visible";
			}
			else {
				if ( top.__eui_custom_cursor == true ) {
					etarget.style.cursor = "default";
				}
			}
		}
	}
}
function __eui_addevent( obj, evname, callfn ) {
	if ( obj ) {
		if ( __EUI_BROWSER_IS_MSIE ) {	// MSIE
			obj.attachEvent( "on" + evname, callfn );
		}
		else if ( typeof( obj.addEventListener ) != "undefined" ) {	//others
			obj.addEventListener( evname, callfn, false );
		}
	}
}
function __eui_removeevent( obj, evname, callfn ) {
	if ( obj ) {
		if ( __EUI_BROWSER_IS_MSIE ) {	// MSIE
			obj.detachEvent( "on" + evname, callfn );
		}
		else if ( typeof( obj.removeEventListener ) != "undefined" ) {	//others
			obj.removeEventListener( evname, callfn, false );
		}
	}
}
function __eui_geteventsrc( e ) {
// rwh 070420 feature to mask an event's source
	if ( e.__eui_eventsrc ) {
		return e.__eui_eventsrc;
	} else {
// rwh 070420 end
		// get a reference to the IE/windows event object
		if ( ! e ) {
			e = window.event;
		}
		// DOM-compliant name of event source property
		if ( e.target ) {
			var hreturn = e.target;
			if ( ( ! e.target.id ) && ( e.target.nodeType == document.TEXT_NODE ) ) {
				hreturn = e.target.parentNode;
			}
			if ( hreturn && hreturn.getAttribute( "ctxequiv" ) ) {
				var hequiv = __eui_finddocument( hreturn ).getElementById( hreturn.getAttribute( "ctxequiv" ) );
				if ( hequiv ) {
					hreturn = hequiv;
				}
			}
			return hreturn;
		}
		// IE/windows name of event source property
		else if ( e.srcElement ) {
			var hreturn = e.srcElement;
			if ( ( e.srcElement.tagName == "HTML" ) && ( e.srcElement.getAttribute( "msiediv" ) ) ) {
				hreturn = __eui_finddocument( e.srcElement ).getElementById( e.srcElement.getAttribute( "msiediv" ) );
			}
			if ( hreturn && hreturn.getAttribute( "ctxequiv" ) ) {
				var hequiv = __eui_finddocument( hreturn ).getElementById( hreturn.getAttribute( "ctxequiv" ) );
				if ( hequiv ) {
					hreturn = hequiv;
				}
			}
			return hreturn;
		}
	}
}
// parse the csstext property and return an array of props that we can readily apply via eval
function __eui_parsecsstext( stextp ) {
	var thestyle = stextp.toLowerCase( ) + ((__EUI_BROWSER_IS_MSIE)?";":"");
	var stylearr = thestyle.split( ";" );
	var sareturn = new Array( );
	for ( var i = 0; i < stylearr.length; i++ ) {
		var ourstyle = stylearr[i].trim( ).replace( /\-([a-z])/g, function( match, submatch1 ){ return submatch1.toUpperCase( ); } );
		var stylepart = ourstyle.split( ": " );
		if ( stylepart[0] != "" ) {
			sareturn[stylepart[0]] = stylepart[1];
		}
	}
	return sareturn;
}
function __eui_mark( elm ) {
	try {
		if ( elm ) {
			if ( ( ! elm.getAttribute( "ctxstyle" ) ) || ( elm.getAttribute( "ctxstyle" ) != "no-change" ) ) {
				var hstyle = __eui_findstyle( __EUI_CLASSNAME_DRAGSTATE );
				if ( hstyle ) {
					if ( ! elm.getAttribute( "eui_stylebackup" ) ) {
						var elmstyles = __eui_parsecsstext( elm.style.cssText );
						for ( var i in thestyles ) {
							top.document.body.setAttribute( "eui_" + i, thestyles[i] );
						}
						elm.setAttribute( "eui_stylebackup", "set" );
					}
					var thestyles = __eui_parsecsstext( hstyle.style.cssText );
					for ( var i in thestyles ) {
						var seval = "elm.style." + i + " = '" + thestyles[i] + "'";
						eval( seval );
					}
				}
			}
		}
	} catch( e ) { __eui_writedebug( "__eui_mark: " + e.description, 10 );}
}
function __eui_unmark( elm ) {
	try {
		if ( elm ) {
			if ( ( ! elm.getAttribute( "ctxstyle" ) ) || ( elm.getAttribute( "ctxstyle" ) != "no-change" ) ) {
				var hstyle = __eui_findstyle( __EUI_CLASSNAME_DRAGSTATE );
				if ( hstyle ) {
					if ( elm.getAttribute( "eui_stylebackup" ) ) {
						var thestyles = __eui_parsecsstext( hstyle.style.cssText );
						for ( var i in thestyles ) {
							if ( top.document.body.getAttribute( "eui_" + i ) ) {
								var seval = "elm.style." + i + " = top.document.body.getAttribute( 'eui_" + i + "' );";
								eval( seval );
							} else {
								var seval = "test = elm.style." + i;
								eval( seval );
								if ( navigator.userAgent.indexOf( "MSIE" ) > -1 ) {
									if ( ! ( ( test == "true" ) || ( test == "false" ) ) ) {
										seval = "elm.style." + i + " = '';";
										eval( seval );
									}
								} else {
									seval = "elm.style." + i + " = '';";
									eval( seval );
								}
							}
						}
						elm.setAttribute( "eui_stylebackup", null );
					}
				}
			}
		}
	} catch( e ) { __eui_writedebug( "__eui_mark: " + e.description, 10 );}
}
function __eui_getcoords( event ) {
	var nareturn = new Array( );
	// if we drag over a document border, get the relative offset values of the new document
	if ( ( typeof( top.__eui_dragsrc ) != "undefined" ) && ( top.__eui_dragsrc != document ) ) {
		__eui_trackwinpos( event );
		top.__eui_dragsrc = document;
	}
	nareturn[0] = event.screenX - top.__eui_rootLeft - ((window.scrollX)?window.scrollX:document.body.scrollLeft);
	nareturn[1] = event.screenY - top.__eui_rootTop - ((window.scrollY)?window.scrollY:document.body.scrollTop);
	// MG090519 for gecko browsers, we need to add the offset of the main table to the coords, as well to be able to display centered albums.
	if ( __EUI_BROWSER_IS_GECKO && top.document.getElementById( "maintable" ) ) {
		nareturn[0] += top.document.getElementById( "maintable" ).offsetLeft;
	}
	return nareturn;
}
function __eui_inarray( argP, arrayP ) {
	var breturn = false;
	if ( ( typeof( arrayP ) == "object" ) && arrayP ) {
/*		arrayP.unshift( "" );
		arrayP.push( "" );
		breturn = ( arrayP.join( "<cmb>" ).indexOf( "<cmb>" + argP + "<cmb>" ) > -1 );*/
		for ( var i in arrayP ) {
			if ( arrayP[i] == argP ) {
				breturn = true;
			}
		}
	}
	return breturn;
}
function __eui_removefromarray( indexP, arrayP ) {
	var localearr = new Array( );
	for ( var i in arrayP ) {
		if ( i != indexP ) {
			localearr[localearr.length] = arrayP[i];
		}
	}
	return localearr;
}
/////////////////////////////////////////////////////////////////////////////////
// checks which actions on which data modules are compatible and reduces the
// ctxmode pattern accordingly
/////////////////////////////////////////////////////////////////////////////////
function __eui_checkcompatibility( event, ctxmode ) {
	var compatmods = new Array( );	// set up a list of compatible modules for several actions:
	compatmods[__MODULE_PICTURE] = 1;
	compatmods[__MODULE_OTHERFILE] = 1;
	compatmods[__MODULE_AVMEDIA] = 1;
	compatmods[__MODULE_WEBUSER] = 2;
	compatmods[__MODULE_ARTICLE] = 4;
	compatmods[__MODULE_ORDER] = 8;
	var is_compatible = 0;
	if ( top.__eui_dragobjs.length > 0 ) {
		for( var i = 0; i < top.__eui_dragobjs.length; i++ ) {
			if ( top.__eui_dragobjs[i] ) {
				if ( top.__eui_dragobjs[i] ) {
					ctxmode = bitand( ctxmode, parseInt( top.__eui_dragobjs[i].getAttribute( "ctxmode" ) ) );
					var ctxmodule = parseInt( top.__eui_dragobjs[i].getAttribute( "ctxmodule" ) );
					is_compatible |= compatmods[ctxmodule];
				}
			} else {
				if ( event ) {
					var etarget = __eui_geteventsrc( event );
					ctxmode = bitand( ctxmode, parseInt( etarget.getAttribute( "ctxmode" ) ) );
					var ctxmodule = parseInt( etarget.getAttribute( "ctxmodule" ) );
					is_compatible |= compatmods[ctxmodule];
				} else {
					ctxmode = 0;
				}
			}
		}
	} else if ( top.__eui_ctxtarget && ( typeof( top.__eui_ctxtarget.id ) != "unknown" ) ) {	 	// another frantically stoopid IE "feature"....
		ctxmode = parseInt( top.__eui_ctxtarget.getAttribute( "ctxmode" ) );
		var ctxmodule = parseInt( top.__eui_ctxtarget.getAttribute( "ctxmodule" ) );
		is_compatible |= compatmods[ctxmodule];
	} else if ( top.__eui_nodragobj && ( typeof( top.__eui_nodragobj.id != "unknown" ) ) ) {
		ctxmode = parseInt( top.__eui_nodragobj.getAttribute( "ctxmode" ) );
		var ctxmodule = parseInt( top.__eui_nodragobj.getAttribute( "ctxmodule" ) );
		is_compatible |= compatmods[ctxmodule];
	} else {
		ctxmode = 0;
	}
	// check how many bits are set - if more than one, we have incompatible modules selected.
	if ( ! __eui_inarray( is_compatible, compatmods ) ) {
		ctxmodule = __MODULE_PICTURE;	// set a default
		is_compatible = 0;
	}
	if ( ctxmodule != __MODULE_OTHERFILE ) {
		ctxmode = bitand( ctxmode, ( bitnot( bitor( __DATAITEM_MERGEFILES, __DATAITEM_PAGEINDEX ) ) ) );
	}
	return ctxmode;
}
/////////////////////////////////////////////////////////////////////////////////
// this opens the context menu based on the entry that has been right-clicked on
/////////////////////////////////////////////////////////////////////////////////
function __eui_opencontextmenu( event ) {
	// hide all applets. otherwise they are always displayed in front of context menus.
	var allapplets = document.getElementsByTagName( "applet" );
	for ( var i in allapplets ) {
		if ( allapplets[i].id && ( allapplets[i].id != "#" ) ) {
			allapplets[i].style.display = "none";
		}
	}
	etarget = __eui_geteventsrc( event );
	targetframe = __eui_findframe( __eui_finddocument( etarget ) );
	var rootdoc = top.window.document;
	top.__eui_ctxevent = event;
	top.__eui_ctxtarget = etarget;
	if ( ( top.__eui_dragobjs.length > 0 ) && ( ! __eui_inarray( top.__eui_ctxtarget, top.__eui_dragobjs ) ) ) {
		for ( var i = top.__eui_dragobjs.length - 1; i >= 0; i-- ) {
			__eui_unmark( top.__eui_dragobjs[i] );
		}
		if ( __EUI_BROWSER_IS_MSIE ) {
			top.__eui_dragobjs = null;
		} else {
			delete( top.__eui_dragobjs );
		}
		top.__eui_dragobjs = new Array( );
	}
	var menucontainer = rootdoc.getElementById( "menucontainer" );
	// if the menu container isn't yet available, create it
	if ( ! menucontainer ) {
		var menucontainer = rootdoc.createElement( "div" );
		menucontainer.id = "menucontainer";
		rootdoc.body.appendChild( menucontainer );
	}
	// don't change/set the class name for heaven's sake for MSIE8 and its MSIE7 fake mode - it blanks out the whole content pane to no avail
	if ( ! ( __EUI_BROWSER_IS_MSIE75 || __EUI_BROWSER_IS_MSIE8 || __EUI_BROWSER_IS_MSIE9 ) ) {
		menucontainer.className = __EUI_CLASSNAME_FRAME;
	}
	if ( __EUI_BROWSER_IS_MSIE ) {
		menucontainer.style.width = "1%";
	}
	while( menucontainer.hasChildNodes() == true ) {
		menucontainer.removeChild( menucontainer.childNodes[0] );
	}
	var contextmenu = rootdoc.createElement( "div" );
	menucontainer.appendChild( contextmenu );
	contextmenu.id = "contextmenu";
	contextmenu.className = __EUI_CLASSNAME_CTXMENU;
	var decode = new Array( );
	var mentry = null;
	var mtext = null;
	var mwidth = 0;	// the width of the menu. if it gets too wide so that it would get truncated on the right side, we move it to the left a bit.
	var mheight = 0;	// the height of the menu. if it gets too high so that it would get truncated on the bottom, we move it up a bit.
	var sheight = new Array( );
	var ctxclass = etarget.getAttribute( __EUI_ATTRIBUTE_CTXCLASS );
	var ctxmode = etarget.getAttribute( __EUI_ATTRIBUTE_CTXMODE );
	ctxmode = __eui_checkcompatibility( event, ctxmode );
	var ctxid = etarget.getAttribute( __EUI_ATTRIBUTE_CTXID );
	var currentsub = 0;
	var scontainers = new Array( );
	for ( var i in top.ctxres ) {
		if ( top.ctxres[i] ) {
			decode = top.ctxres[i].split( "|" );
			if ( ( decode[0] == ctxclass ) && ( bitand( ctxmode, parseInt( decode[2] ) ) != 0 ) ) {
				var mentry = rootdoc.createElement( "div" );
				//mentry.id = 'ctx_'+ctxclass+'_'+decode[2]+'_'+ctxid;
				mentry.className = __EUI_CLASSNAME_CTXMENU_ENTRY;
				mentry.style.whiteSpace = "nowrap";
				if ( mentry.style.height ) {
					mheight += parseInt( mentry.style.height );
				} else {
					mheight += 20;
				}
				// attach all the given values as attributes to avoid long var parameter lists
				mentry.setAttribute( __EUI_ATTRIBUTE_CTXID, ctxid );
				mentry.setAttribute( __EUI_ATTRIBUTE_CTXINDEX, decode[2] );
				mentry.setAttribute( __EUI_ATTRIBUTE_CTXCLASS, decode[0] );
				mentry.setAttribute( __EUI_ATTRIBUTE_CTXLABEL, decode[3] );
				mentry.setAttribute( __EUI_ATTRIBUTE_CTXDESCRIPTION, decode[4] );
				mentry.setAttribute( __EUI_ATTRIBUTE_FRAMENAME, targetframe.name );
				mtext = rootdoc.createTextNode( decode[3] );
				mwidth = Math.max( mwidth, ( decode[3].length * 5 ) + 20 );
				mentry.appendChild( mtext );
				if ( decode[1] > 0 ) {
					if ( currentsub != decode[1] ) {	// open submenu
						mentry.className += " eui_has_subentries";
						currentsub = decode[1];
						sheight[currentsub] = 0;
						var scontainer = rootdoc.createElement( "div" );
						scontainer.className = __EUI_CLASSNAME_CTXMENU;
						scontainer.style.zIndex = "10";
						if ( __EUI_BROWSER_IS_MSIE ) {
							scontainer.style.marginTop = "-10px";
							scontainer.style.left = "20px";
						} else {
							scontainer.style.marginTop = "-24px";
						}
						scontainer.style.position = "absolute";
						scontainer.style.display = "none";
						scontainer.id = "sentry_" + decode[0] + "_" + decode[1];
						scontainers[scontainers.length] = scontainer;
						mentry.appendChild( scontainer );
						__eui_addevent( mentry, "mouseover", new Function( "__eui_showctxsubmenu('" + scontainer.id + "')" ) );
						appendto = scontainer;
						mentry.onmouseover = new Function ( "this.className='" + __EUI_CLASSNAME_CTXMENU_ENTRY_SELECTED + " " + __EUI_CLASSNAME_CTXMENU_HAS_SUBENTRIES + "';top.window.status='" + decode[4] + "'" );
						mentry.onmouseout = new Function ( "this.className='" + __EUI_CLASSNAME_CTXMENU_ENTRY + " " + __EUI_CLASSNAME_CTXMENU_HAS_SUBENTRIES + "';top.window.status=''" );
						contextmenu.appendChild( mentry );
					} else {	// add entries to the submenu
						__eui_addevent( mentry, "mousedown", __eui_ctxdispatch );
						mentry.onmouseover = new Function ( "this.className='" + __EUI_CLASSNAME_CTXMENU_ENTRY_SELECTED + "';top.window.status='" + decode[4] + "'" );
						mentry.onmouseout = new Function ( "this.className='" + __EUI_CLASSNAME_CTXMENU_ENTRY + "';top.window.status=''" );
						appendto.appendChild( mentry );
					}
				} else {	// stick to 1st level of the menu
					__eui_addevent( mentry, "mousedown", __eui_ctxdispatch );
					__eui_addevent( mentry, "mouseover", __eui_hidectxsubmenu );
					contextmenu.appendChild( mentry );
					mentry.onmouseover = new Function ( "this.className='" + __EUI_CLASSNAME_CTXMENU_ENTRY_SELECTED + "';top.window.status='" + decode[4] + "'" );
					mentry.onmouseout = new Function ( "this.className='" + __EUI_CLASSNAME_CTXMENU_ENTRY + "';top.window.status=''" );
				}
			}
		}
		for ( var i = 0; i < scontainers.length; i++ ) {
			scontainers[i].style.marginLeft = ( mwidth - 20 ) + "px";
		}
	}
// rwh 070416 ensure that all menu items have the same width as the menu itself, othewise the highlighting looks clumsy in ie
	if ( __EUI_BROWSER_IS_MSIE ) {
		for ( var i=0; i < contextmenu.childNodes.length; i++ ) {
			contextmenu.childNodes[i].style.width = ( mwidth + 10 ) + "px";
		}
	}
// rwh 070416 end
	if ( typeof( menucontainer.style.setProperty ) == "function" ) {
		menucontainer.style.setProperty( "z-index", "5", null );	// just left in to remember that syntax ;-)
	} else {
		menucontainer.style.zIndex = 5;
	}
	xy = __eui_getcoords( event );
	var winwidth = screen.width;		// just a start value
	var winheight = screen.height;	// just a start value
	if ( __EUI_BROWSER_IS_MSIE ) {
		var winwidth = top.window.document.body.clientWidth;
		var winheight = top.window.document.body.clientHeight;
	} else {
		var winwidth = top.window.innerWidth;
		var winheight = top.window.innerHeight;
	}
	if ( ( xy[0] + mwidth ) > ( winwidth - 10 ) ) {
		menucontainer.style.left = ( xy[0] - ( mwidth + 10 ) ) + "px";
	} else {
		menucontainer.style.left = xy[0] + "px";
	}
	if ( ( xy[1] + mheight ) > ( winheight - 10 ) ) {
		menucontainer.style.top = ( xy[1] - ( mheight + 10 ) ) + "px";
	} else {
		menucontainer.style.top = xy[1] + "px";
	}
	if ( __EUI_BROWSER_IS_APPLEWEBKIT ) {
		menucontainer.style.left = ( parseInt( menucontainer.style.left ) + 2 ) + "px";
		menucontainer.style.top = ( parseInt( menucontainer.style.top ) + 2 ) + "px";
	}
	menucontainer.style.position = "absolute";
	menucontainer.style.visibility = "visible";
}
/////////////////////////////////////////////////////////////////////////////////
// close the context menu, i.e. hide it
/////////////////////////////////////////////////////////////////////////////////
function __eui_closecontextmenu( ) {
	if ( top.window.document.getElementById( "menucontainer" ) ) {
		top.window.document.getElementById( "menucontainer" ).style.visibility = "hidden";
	}
	// show all applets again. they were hidden for context menus, as they are always displayed in front of them.
	var allapplets = document.getElementsByTagName( "applet" );
	for ( var i in allapplets ) {
		if ( allapplets[i].id && ( allapplets[i].id != "#" ) ) {
			allapplets[i].style.display = top.sdisplay;
		}
	}
	__eui_hidectxsubmenu( );
	top.__eui_ctxevent = null;
	top.__eui_ctxtarget = null;
}
/////////////////////////////////////////////////////////////////////////////////
// this adds menu entries to the global menu entry array.
/////////////////////////////////////////////////////////////////////////////////
function __eui_ctxmenuadd( group, subgroup, priv, label, description ) {
	if ( ! top.ctxres ) {
		top.ctxres = new Array( );
		top.ctxsubmenuopen = null;
	}
	top.ctxres[group+"|"+priv] = group + "|" + ((subgroup)?subgroup:0) + "|" + priv + "|" + label + '|' + description;
}
function __eui_ctxmenuremove( group, priv ) {
	if ( top.ctxres && top.ctxres[group+"|"+priv] ) {
		top.ctxres[group+"|"+priv] = null;
	}
}
function __eui_showctxsubmenu( whichp ) {
	top.document.getElementById( whichp ).style.display = "";
	top.ctxsubmenuopen = whichp;
}
function __eui_hidectxsubmenu( ) {
	if ( top.ctxsubmenuopen && top.document.getElementById( top.ctxsubmenuopen ) ) {
		top.document.getElementById( top.ctxsubmenuopen ).style.display = "none";
		top.ctxsubmenuopen = null;
	}
}
/////////////////////////////////////////////////////////////////////////////////
// the central menu dispatcher function that calls a document-locale function
// called __eui_process_<ctxclass>
/////////////////////////////////////////////////////////////////////////////////
function __eui_ctxdispatch( event ) {
	var proceed = false;
	var etarget = __eui_geteventsrc( event );
	var localedoc = __eui_finddocument( top.__eui_ctxtarget );
	// get the relevant information out of the object that triggered the event to see what we need to dispatch
	var ctxclass = etarget.getAttribute( __EUI_ATTRIBUTE_CTXCLASS );
	// MSIE can't do anything with defaultView, so....
	if ( __EUI_BROWSER_IS_MSIE || __EUI_BROWSER_IS_APPLEWEBKIT ) {
		var seval = "proceed = ( typeof( __eui_process_" + ctxclass + " ) == 'function' ) ? true : false";
		var seval2 = "callfn = __eui_process_" + ctxclass;
	} else {
		var seval = "proceed = ( typeof( localedoc.defaultView.__eui_process_" + ctxclass + " ) == 'function' ) ? true : false";
		var seval2 = "callfn = localedoc.defaultView.__eui_process_" + ctxclass;
	}
	eval( seval );
	if ( proceed == true ) {
		//seval = "callfn = localedoc.defaultView.__eui_process_" + ctxclass;
		eval( seval2 );
		callfn( top.__eui_ctxtarget, event );
	} else {
		alert( "function __eui_process_" + ctxclass + " does not exist!" );
	}
}
/////////////////////////////////////////////////////////////////////////////////
// the central dragdrop dispatch function that calls a document-locale function
// called __eui_process_dragdrop
/////////////////////////////////////////////////////////////////////////////////
function __eui_dragdropdispatch( dragobjs, dropevent ) {
	var proceed = false;
	var localedoc = __eui_finddocument( __eui_geteventsrc( dropevent ) );
	var seval = "proceed = ( typeof( localedoc.defaultView.__eui_process_dragdrop ) == 'function' ) ? true : false";
	if ( __EUI_BROWSER_IS_MSIE ) {
		var seval = "proceed = ( typeof( __eui_process_dragdrop ) == 'function' ) ? true : false";
		var seval2 = "callfn = __eui_process_dragdrop";
	} else {
		var seval = "proceed = ( typeof( localedoc.defaultView.__eui_process_dragdrop ) == 'function' ) ? true : false";
		var seval2 = "callfn = localedoc.defaultView.__eui_process_dragdrop";
	}
	eval( seval );
	if ( proceed == true ) {
		//seval = "callfn = localedoc.defaultView.__eui_process_dragdrop";
		eval( seval2 );
		callfn( dragobjs, dropevent );
	} else {
		alert( "function __eui_process_dragdrop does not exist!" );
	}
	return true;
}
/////////////////////////////////////////////////////////////////////////////////
// finds the container element of a menu or dialog, i.e. the top-most element
// right after the body tag
/////////////////////////////////////////////////////////////////////////////////
function __eui_findcontainer( elm ) {
	while( ( elm.parentNode.nodeName != "BODY" ) ) {
		elm = elm.parentNode;
	}
	var hreturn = elm;
	return hreturn;
}
/////////////////////////////////////////////////////////////////////////////////
// finds the document in which an element resides
/////////////////////////////////////////////////////////////////////////////////
function __eui_finddocument( elm ) {
	if ( elm ) {
		while( elm && ( elm.nodeType != document.DOCUMENT_NODE ) ) {
			elm = elm.parentNode;
		}
	}
	return elm;
}
function __eui_findframe( elm ) {
	var hreturn = null;
	try {
		for ( var i = 0; i < top.frames.length; i++ ) {
			if ( top.frames[i].document == elm ) {
				hreturn = top.frames[i];
			}
		}
	}
	catch ( e ) {
		// nth
	}
	return hreturn;
}
/////////////////////////////////////////////////////////////////////////////////
// find the style for the mark function
/////////////////////////////////////////////////////////////////////////////////
function __eui_findstyle( stylename ) {
	var hreturn = null;
	var hrules = null;
	// MG100127 to avoid cross-domain css access errors (introduced by oddities like foreign "chrome" toolbars etc.)
	// we now check that we only deal with css files from our own domain.
	var ourloc = new String( window.location );
	ourloc = ourloc.substr( ourloc.indexOf( "//" ) + 2, 100 );
	ourloc = ourloc.substr( 0, ourloc.indexOf( "/" ) );
	for ( var i = 0; i < document.styleSheets.length; i++ ) {
		if ( ( document.styleSheets[i].href == null ) || ( document.styleSheets[i].href.indexOf( ourloc ) > -1 ) || ( document.styleSheets[i].href.indexOf( "http://" ) == -1 ) ) {
			if ( typeof( document.styleSheets[i].cssRules ) == "undefined" ) {
				hrules = document.styleSheets[i].rules;
			} else {
				hrules = document.styleSheets[i].cssRules;
			}
			for ( var j = 0; j < hrules.length; j++ ) {
				if ( hrules[j] ) {
					if ( hrules[j].selectorText && ( ( hrules[j].selectorText == stylename ) || ( hrules[j].selectorText.indexOf( '[class~="' + stylename + + '"]' ) > -1 ) ) )  {
						var hreturn = hrules[j];
					}
				}
			}
		}
	}
	return hreturn;
}
/////////////////////////////////////////////////////////////////////////////////
// this opens a dialog to enter some textual data. it's usually called by a
// context menu action via the corresponding __eui_process_<ctxclass> function
/////////////////////////////////////////////////////////////////////////////////
function __eui_opendialog( title, text, value, actionstyle, forceinput, onok, oncancel, id, index, framename ) {
	var rootdoc = top.window.document;
	var dialogcontainer = rootdoc.getElementById( "dialogcontainer" );
	// MSIE is a bunch of ....
	if ( __EUI_BROWSER_IS_MSIE ) {
		var create = rootdoc.getElementById( "dialogcontainer" );
	} else {
		var create = dialogcontainer;
	}
	if ( ! create ) {
		// create the window if it's not alerady there
		var dialogcontainer = rootdoc.createElement( "div" );
		dialogcontainer.id = "dialogcontainer";
		rootdoc.body.appendChild( dialogcontainer );
		dialogcontainer.className = __EUI_CLASSNAME_FRAME;
		//dialogcontainer.style.width = "304px";
	}
	dialogcontainer.style.zIndex = "2";
	var dialogwin = rootdoc.getElementById( "dialogwindow" );
	if ( ! dialogwin ) {
		dialogwin = rootdoc.createElement( "div" );
		dialogwin.id = "dialogwindow";
		dialogwin.className = __EUI_CLASSNAME_DLGWINDOW;
// rwh 070419
		__eui_addevent( dialogwin, "keyup", __eui_checkinput );
// rwh 070419 end
		dialogcontainer.appendChild( dialogwin );
	}
	// first remove all children out of the menu
	while( dialogwin.hasChildNodes( ) == true ) {
		dialogwin.removeChild( dialogwin.childNodes[0] );
	}
	// generate the window title
	var titlebar = rootdoc.createElement( "div" );
	titlebar.id = "titlebar";
	titlebar.className = __EUI_CLASSNAME_DLGTITLE;
	__eui_addevent( titlebar, "mousedown", __eui_dialogdrag_start );
	__eui_addevent( titlebar, "mouseup", __eui_dialogdrag_stop );
	dialogwin.appendChild( titlebar );
	var titlediv = rootdoc.createElement( "div" );
	titlediv.id = "titlediv";
	titlediv.className = __EUI_CLASSNAME_DLGTITLE_DIV;
	__eui_addevent( titlediv, "mousedown", __eui_dialogdrag_start );
	__eui_addevent( titlediv, "mouseup", __eui_dialogdrag_stop );
	var titletext = rootdoc.createTextNode( title );
	titlediv.appendChild( titletext );
	titlebar.appendChild( titlediv );
	// generate the window message
	var msgbox = rootdoc.createElement( "div" );
	msgbox.id = "msgbox";
	msgbox.className = __EUI_CLASSNAME_DLGMESSAGE_BOX;
	var msg = rootdoc.createElement( "div" );
	msg.id = "msg";
	msg.className = __EUI_CLASSNAME_DLGMESSAGE;
	msg.className += " " + actionstyle;
	var msgtext = rootdoc.createTextNode( text );
	msg.appendChild( msgtext );
	msgbox.appendChild( msg );
	dialogwin.appendChild( msgbox );
	// generate an input box
	// a passed value of null means that the text input box should not be displayed at all
// rwh 070416 put the input in a wrapping division with style="overflow:auto" to enable a blinking cursor in the input
	var ddiv = rootdoc.createElement( "div" );
	ddiv.style.overflow = "auto";
	dialogwin.appendChild( ddiv );
// rwh 070416 end
	if ( value != null ) {
		var dinput = rootdoc.createElement( "input" );
		dinput.type = "text";
		dinput.id = __EUI_ID_INPUT_TEXT;
		dinput.name = __EUI_ID_INPUT_TEXT;
		dinput.className = __EUI_CLASSNAME_DLGINPUT_TEXT;
		dinput.style.cursor = "text";
		dinput.value = value;
// rwh 070420 moved to the container to enable it even if there is no dinput		__eui_addevent( dinput, "keyup", __eui_checkinput );
		dinput.setAttribute( __EUI_ATTRIBUTE_CTXRETURN, value );
		dinput.setAttribute( __EUI_ATTRIBUTE_CTXID, id );
		dinput.setAttribute( __EUI_ATTRIBUTE_CTXINDEX, index );
		dinput.setAttribute( __EUI_ATTRIBUTE_FRAMENAME, framename );
		if ( forceinput == true ) {
			dinput.setAttribute( __EUI_ATTRIBUTE_FORCEUI, "yes" );
		} else {
			dinput.setAttribute( __EUI_ATTRIBUTE_FORCEUI, "no" );
		}
// rwh 070416 put the input in a wrapping division instead of the dialog window itself
// rwh 070416		dialogwin.appendChild( dinput );
		ddiv.appendChild( dinput );
// rwh 070416 end
	}
	var brtag = rootdoc.createElement( "br" );
	dialogwin.appendChild( brtag );
	// generate the buttons
	var dok = rootdoc.createElement( "input" );
	dok.id = __EUI_ID_INPUT_OK;
	dok.className = __EUI_CLASSNAME_DLGINPUT_OK;
	if ( "<text>EYEBASE_BUTTON</text>".indexOf( "EYEBASE_BUTTON" ) > -1 ) {
		dok.type = "button";
		dok.style.width = "74px";
	} else {
		dok.type = "image";
		dok.src = "<text>EYEBASE_BUTTON</text>&basefile=e_ok.png&appendix=EDECEC&string=<text>MESSAGE_396</text>";
		dok.style.backgroundImage = "url('<text>EYEBASE_BUTTON_BG</text>&basefile=e_ok.png&appendix=EDECEC&string=<text>MESSAGE_396</text>&htextcolor=ff0000')";
		dok.style.backgroundRepeat = "no-repeat";
		dok.style.backgroundPosition = "0 0";
	}
	dok.setAttribute( __EUI_ATTRIBUTE_CTXRETURN, value );
	dok.setAttribute( __EUI_ATTRIBUTE_CTXID, id );
	dok.setAttribute( __EUI_ATTRIBUTE_CTXINDEX, index );
	dok.setAttribute( __EUI_ATTRIBUTE_FRAMENAME, framename );
	if ( dinput && ( dinput.value == "" ) && ( forceinput == true ) ) {
		dok.disabled = true;
	}
	if ( typeof( onok ) == "function" ) {
		// MG090812 - completely removed the addevent part for MSIE != 6 - it recently also started to fire the event twice under IE7
		dok.onclick = onok;
	} else {
		dok.onclick = null;
	}
	// without this, MSIE won't do anything on the event
	if ( __EUI_BROWSER_IS_MSIE ) {
		__eui_addevent( dok, "mouseup", __eui_closedialog );
	}
	// leave this in to be able to re-assign the function later on.
	// needed when the dialog is closed by pressing return in the input field rather than clicking on the ok button
	// see also comment under __eui_closedialog()
// rwh 070419	dok.onmousedown = __eui_closedialog;
	dok.onmouseup = __eui_closedialog;
	var dcancel = rootdoc.createElement( "input" );
	dcancel.id = __EUI_ID_INPUT_CANCEL;
	dcancel.className = __EUI_CLASSNAME_DLGINPUT_CANCEL;
	if ( "<text>EYEBASE_BUTTON</text>".indexOf( "EYEBASE_BUTTON" ) > -1 ) {
		dcancel.type = "button";
		dcancel.style.width = "94px";
	} else {
		dcancel.type = "image";
		dcancel.src = "<text>EYEBASE_BUTTON</text>&basefile=e_cancel.png&string=<text>MESSAGE_397</text>";
		dcancel.style.backgroundImage = "url('<text>EYEBASE_BUTTON_BG</text>&basefile=e_cancel.png&string=<text>MESSAGE_397</text>&htextcolor=ff0000')";
		dcancel.style.backgroundRepeat = "no-repeat";
		dcancel.style.backgroundPosition = "0 0";
	}
	if ( typeof( oncancel ) == "function" ) {
		__eui_addevent( dcancel, "click", oncancel );
	} else {
		dcancel.onclick = null;
	}
	__eui_addevent( dcancel, "mouseup", __eui_closedialog );
	dialogwin.appendChild( dok );
	dialogwin.appendChild( dcancel );
	dialogcontainer.style.left = "250px";
	dialogcontainer.style.top = "200px";
	dialogcontainer.style.position = "absolute";
	dialogcontainer.style.visibility = "visible";
// rwh 070420: do the focusing with a tiny delay otherwise it fails in IE!
	top.setTimeout("if ( top.document.getElementById(__EUI_ID_INPUT_TEXT) ) { top.document.getElementById(__EUI_ID_INPUT_TEXT).focus( ); } else if (top.document.getElementById(__EUI_ID_INPUT_CANCEL)) { top.document.getElementById(__EUI_ID_INPUT_CANCEL).focus( ); } else if (top.document.getElementById(__EUI_ID_INPUT_OK)) { top.document.getElementById(__EUI_ID_INPUT_OK).focus( ); } else { top.document.getElementById(\"dialogwindow\").focus(); }", 100);
}
function __eui_dialogdrag_start( event ) {
	var etarget = __eui_geteventsrc( event );
	var hdoc = __eui_finddocument( etarget );
	var box = __eui_findcontainer( etarget );
	var boxleft = parseInt( box.style.left );
	var boxtop = parseInt( box.style.top );
	__eui_dialogbox = box;
	// those 2 variables are not declared as var, since we need them in the drag function below, as well
	var eX = (event.pageX)?event.pageX:event.x;
	var eY = (event.pageY)?event.pageY:event.y;
	clickoffsetx = eX - boxleft;
	clickoffsety = eY - boxtop;
	window.status = clickoffsetx + " / " + clickoffsety;
	if ( __EUI_BROWSER_IS_MSIE ) {
		__eui_addevent( hdoc, "mousemove", __eui_dialogdrag_drag );
	} else {
		hdoc.onmousemove = __eui_dialogdrag_drag;
	}
	if ( typeof( event.preventDefault ) == "function" ) {
		event.preventDefault( );
	} else {
		event.cancelBubble = true;
	}
}
function __eui_dialogdrag_stop( event ) {
	var etarget = __eui_geteventsrc( event );
	var hdoc = __eui_finddocument( etarget );
	__eui_removeevent( hdoc, "mousemove", __eui_dialogdrag_drag );
	// those 2 variables are not declared as var, since we need them in the drag function below, as well
	clickoffsetx = -1;
	clickoffsety = -1;
}
function __eui_dialogdrag_drag( event ) {
	// detaching the event in __eui_dialogdrag_stop obviously doesn't do the trick for MSIE (surprise, surprise!)
	if ( clickoffsetx > -1 ) {
		var boxleft = parseInt( __eui_dialogbox.style.left );
		var boxtop = parseInt( __eui_dialogbox.style.top );
		var eX = (event.pageX)?event.pageX:event.x;
		var eY = (event.pageY)?event.pageY:event.y;
		var newleft = eX - clickoffsetx;
		var newtop = eY - clickoffsety;
		window.status = newleft + ' / ' + newtop;
		__eui_dialogbox.style.left = newleft + "px";
		__eui_dialogbox.style.top = newtop + "px";
	}
}
function __eui_closedialog( event ) {
	// MSIE needs to have this function registered through the event listener as well as through "onmouseup" (or what ever event is used)
	// reason: the first one is triggered by the button on which the click is performed. the second is needed to read the
	// function when the return key is pressed in the text box. i've not figured out how to read the function added via attachEvent(), that's why the onmouseup one is needed. crazy!
	if ( event ) {
		var etarget = __eui_geteventsrc( event );
		if ( etarget.id == __EUI_ID_INPUT_CANCEL ) {
// rwh 070420			etarget.onmouseup = null;
			etarget.onclick = null;
		} else {
			var callfn = null;
/* rwh 070320			if ( typeof( etarget.onmouseup ) == "function" ) {
				var callfn = etarget.onmouseup;
				etarget.onmouseup = null; */
			if ( typeof( etarget.onclick ) == "function" ) {
				var callfn = etarget.onclick;
				etarget.onclick = null;
			}
			if ( top.window.document.getElementById( __EUI_ID_INPUT_TEXT ) ) {
				etarget.setAttribute( __EUI_ATTRIBUTE_CTXRETURN, top.window.document.getElementById( __EUI_ID_INPUT_TEXT ).value );
			}
			if ( callfn ) {
				callfn( event );
			}
		}
		// find out the top-most parent node before the body tag and set its visibility to hidden
		var box = top.document.getElementById( "dialogcontainer" );
// rwh 070420
		var dialogwindow = top.document.getElementById( "dialogwindow" );
		dialogwindow.onkeyup = null;
		etarget.blur();
// rwh 070420 end
		box.style.visibility = "hidden";
	}
// mg071203 another "nice" msie feature: no action is taken at all on any click or double click if the window doesn't lose its focus after the dialog window came up...
	if ( __EUI_BROWSER_IS_MSIE6 ) {	// ... then this is anyhow a BIG PILE OF CRAP!
		if ( top.frames["overview"].document.getElementById( "userlang" ) ) {
			top.frames["overview"].document.getElementById( "userlang" ).focus( );
			top.frames["navigation"].focus( );
		}
	}
// rwh 070424 timing problem in IE6 that leeds to frame scroll freeze when clicking Cancel in the dialog; with that little delay it seems to work
	tiny_delay( );
// rwh 070424 end
}
function __eui_settext( container, thetext ) {
	// msie won't accept a node not created by the same doc as where we want to insert it into...
	var crutchformsiedoc = __eui_finddocument( container );
	while( container.hasChildNodes() == true ) {
		container.removeChild( container.childNodes[0] );
	}
	if ( ( container.firstChild ) && ( container.firstChild.nodeType == document.TEXT_NODE ) ) {
		container.firstChild.nodeValue = thetext;
	} else {
		container.appendChild( crutchformsiedoc.createTextNode( thetext ) );
	}
}
function __eui_gettext( container ) {
	var sreturn = "";
	var hanode = container.childNodes;
	for ( var i = 0; i < hanode.length; i++ ) {
		if ( hanode[i].nodeType == document.TEXT_NODE ) {
			sreturn = hanode[i].nodeValue;
		}
	}
	return sreturn;
}
function __eui_checkinput( event ) {
	var etarget = __eui_geteventsrc( event );
	var forceinput = etarget.getAttribute( __EUI_ATTRIBUTE_FORCEUI );
	if ( ( forceinput == "yes" ) && ( etarget.value == "" ) ) {
		top.window.document.getElementById( __EUI_ID_INPUT_OK ).disabled = true;
	} else {
		top.window.document.getElementById( __EUI_ID_INPUT_OK ).disabled = false;
	}
	var mycode = (myev.charCode)?myev.charCode:myev.keyCode;
	if ( mycode == 13 ) {
// rwh 070420 mask eventsource as OK-button
		event.__eui_eventsrc = top.window.document.getElementById( __EUI_ID_INPUT_OK );
		// if we submit the form via the return key and not by pressing ok on the form,
		// "bend over" the mouse events of the ok button to the input field, as the event we pass on is
		// generated by the input field.
// rwh 070420 if no input ignore
//		if ( ( etarget.getAttribute( __EUI_ATTRIBUTE_FORCEUI ) == "no" ) || ( etarget.value != "" ) ) {
		if ( ( etarget.getAttribute( __EUI_ATTRIBUTE_FORCEUI ) == "no" ) || ( etarget.getAttribute( __EUI_ATTRIBUTE_FORCEUI ) === null ) || ( etarget.value != "" ) ) {
// rwh 070420 changed onmousedown to onmouseup and onmouseup to onclick
/*			var callfn = top.window.document.getElementById( __EUI_ID_INPUT_OK ).onmousedown;
			top.window.document.getElementById( __EUI_ID_INPUT_OK ).onmousedown = null;
			etarget.onmouseup = top.window.document.getElementById( __EUI_ID_INPUT_OK ).onmouseup;
			top.window.document.getElementById( __EUI_ID_INPUT_OK ).onmouseup = null;
			etarget.onkeyup = null; */
			var callfn = top.window.document.getElementById( __EUI_ID_INPUT_OK ).onmouseup;
			top.window.document.getElementById( __EUI_ID_INPUT_OK ).onmouseup = null;
			//event.__eui_eventsrc.onclick = top.window.document.getElementById( __EUI_ID_INPUT_OK ).onclick;
			//top.window.document.getElementById( __EUI_ID_INPUT_OK ).onclick = null;
			etarget.onkeyup = null;
			callfn( event );
		}
	} else if ( mycode == 27 ) { // rwh 070420 ESC pressed -> do cancel-action and close dialog
		// if we submit the form via the ESC key and not by pressing CANCEL on the form,
		// "bend over" the mouse events of the CANCEL button to the container, as the event we pass on is
		// generated by the container.
		event.__eui_eventsrc = top.window.document.getElementById( __EUI_ID_INPUT_CANCEL );
		if (top.window.document.getElementById( __EUI_ID_INPUT_TEXT ))
		{
			top.window.document.getElementById( __EUI_ID_INPUT_TEXT ).blur();
		}
		var callfn = top.window.document.getElementById( __EUI_ID_INPUT_CANCEL ).onmouseup;
		top.window.document.getElementById( __EUI_ID_INPUT_CANCEL ).onmouseup = null;
		etarget.onclick = top.window.document.getElementById( __EUI_ID_INPUT_CANCEL ).onclick;
		top.window.document.getElementById( __EUI_ID_INPUT_CANCEL ).onclick = null;
		etarget.onkeyup = null;
		if (callfn)
		{
			callfn( event );
		} else {
			__eui_closedialog( event );
		}
		if (etarget.onclick)
		{
			etarget.onclick( event );
		}
	}
}
function __eui_openinfo( event ) {
	var etarget = __eui_geteventsrc( event );
	var hdoc = __eui_finddocument( etarget );
	__eui_trackwinpos( event );
	var xy = __eui_getcoords( event );
	var rootdoc = top.window.document;
	var infocontainer = rootdoc.getElementById( "infocontainer" );
	// if the menu container isn't yet available, create it
	if ( ! infocontainer ) {
		var infocontainer = rootdoc.createElement( "div" );
		infocontainer.id = "infocontainer";
		rootdoc.body.appendChild( infocontainer );
	}
	// don't change/set the class name for heaven's sake for MSIE8 and its MSIE7 fake mode - it blanks out the whole content pane to no avail
	if ( ! ( __EUI_BROWSER_IS_MSIE75 || __EUI_BROWSER_IS_MSIE8 || __EUI_BROWSER_IS_MSIE9 ) ) {
		infocontainer.className = __EUI_CLASSNAME_FRAME;
	}
	if ( __EUI_BROWSER_IS_MSIE ) {
		infocontainer.style.width = "1%";
	}
	while( infocontainer.hasChildNodes() == true ) {
		infocontainer.removeChild( infocontainer.childNodes[0] );
	}
	var infobox = rootdoc.createElement( "div" );
	infocontainer.appendChild( infobox );
	infobox.id = "infobox";
	infobox.className = __EUI_CLASSNAME_INFO;
	var mwidth = 0;
	var mheight = 0;
	var infodivid = etarget.getAttribute( "openinfo" );
	if ( infodivid ) {
		var infocontent = hdoc.getElementById( infodivid );
		if ( infocontent ) {
			if ( __EUI_BROWSER_IS_MSIE ) {	// MSIE is the most b0rken piece of sh*t that i came across!!!!!
				var infocopy = __eui_cloneienode( rootdoc, infocontent );
			} else {
				var infocopy = infocontent.cloneNode( true );
			}
			infocopy.style.display = "";
			infobox.appendChild( infocopy );
		}
	}
	infocontainer.style.zIndex = "5";
	// get the offset width / height from the final info box so that we get the proper layout data
	mwidth = parseInt( infobox.offsetWidth );
	mheight = parseInt( infobox.offsetHeight );
	var winwidth = screen.width;		// just a start value
	var winheight = screen.height;	// just a start value
	if ( __EUI_BROWSER_IS_MSIE ) {
		var winwidth = top.window.document.body.clientWidth;
		var winheight = top.window.document.body.clientHeight;
	} else {
		var winwidth = top.window.innerWidth;
		var winheight = top.window.innerHeight;
	}
	// make the box not open up too wide on FF in case of long texts
	if ( mwidth > 300 ) {
		mwidth = 300;
		infobox.style.width = "300px";
	}
	if ( ( xy[0] + mwidth ) > ( winwidth - 10 ) ) {
		infocontainer.style.left = ( xy[0] - ( mwidth + 10 ) ) + "px";
	} else {
		infocontainer.style.left = ( xy[0] + 5 ) + "px";
	}
	if ( ( xy[1] + mheight ) > ( winheight - 10 ) ) {
		infocontainer.style.top = ( xy[1] - ( mheight + 10 ) ) + "px";
	} else {
		infocontainer.style.top = ( xy[1] + 5 ) + "px";
	}
	infocontainer.style.position = "absolute";
	infocontainer.style.visibility = "visible";
}
function __eui_closeinfo( ) {
	var rootdoc = top.window.document;
	var infocontainer = rootdoc.getElementById( "infocontainer" );
	if ( infocontainer ) {
		infocontainer.style.visibility = "hidden";
	}
}
function __eui_cloneienode( hdocp, sourcep ) {
	if ( sourcep.nodeType == document.TEXT_NODE ) {
		hreturn = hdocp.createTextNode( sourcep.nodeValue );
	} else {
		hreturn = hdocp.createElement( sourcep.tagName );
		hreturn["innerHTML"] = sourcep["innerHTML"];
	}
	return hreturn;
}
// rwh 070425 
/////////////////////////////////////////////////////////////////////////////////
// sometimes IE seems to have some timing troubles that are solved easily
// by keeping the browser busy for a small delay
/////////////////////////////////////////////////////////////////////////////////
function tiny_delay( )
{
	var j;
	if ( __EUI_BROWSER_IS_MSIE ) {
		for (var i=0; i<100; i++)
		{ j++ }
	}
}
// rwh 070425 end
function __eui_addstyle( styleidp, stylestrp ) {
	if ( styleidp && ( stylestrp.indexOf( "{" ) > -1 ) ) {	// }
		if ( __EUI_BROWSER_IS_MSIE ) {
			styleidp.styleSheet.cssText += stylestrp + "\n";
		} else {
			styleidp.sheet.insertRule( stylestrp, styleidp.sheet.cssRules.length );
		}
	}
}
// read style info out of a sheet. use ":all:" as selector to read the whole style sheet into one string
function __eui_getstyletext( styleidp, selectorp ) {
	var therules = null;
	var sreturn = "";
	var selector = selectorp.toLowerCase( );
	if ( styleidp ) {
		if ( __EUI_BROWSER_IS_MSIE ) {
			if ( selector != ":all:" ) {
				var therules = styleidp.styleSheet.rules;
				if ( therules ) {
					for ( var i = 0; i < therules.length; i++ ) {
						if ( therules[i].selectorText.toLowerCase( ) == selector ) {
							var mystart = styleidp.styleSheet.cssText.toLowerCase( ).indexOf( therules[i].selectorText.toLowerCase( ) ) + therules[i].selectorText.length + 1;
							sreturn = styleidp.styleSheet.cssText.toLowerCase( ).substr( mystart, styleidp.styleSheet.cssText.length );
							sreturn = sreturn.substr( 0, sreturn.indexOf( "}" ) + 1 );	// {
						}
					}
				}
			} else if ( ( selector == ":all:" ) && ( styleidp.styleSheet.cssText != "" ) ) {
				sreturn = styleidp.styleSheet.cssText.replace( /[\x00-\x13]+\}/g, ";\n}" );	// {{
			}
		} else {
			var therules = styleidp.sheet.cssRules;
			if ( therules ) {
				for ( var i = 0; i < therules.length; i++ ) {
					if ( therules[i].cssText.indexOf( "@import" ) == -1 ) {
						if ( therules[i].selectorText.toLowerCase( ) == selector ) {
							sreturn = therules[i].cssText.substr( therules[i].selectorText.length + 1, therules[i].cssText.length );
						} else if ( ( selector == ":all:" ) && ( therules[i].cssText != "" ) ) {
							sreturn += therules[i].cssText + "\n";
						}
					}
				}
			}
		}
	}
	return sreturn;
}
function __eui_getcomputedstyle( etargetp, propp ) {
	var thestyle = "";
	if ( __EUI_BROWSER_IS_MSIE ) {
		thestyle = etargetp.currentStyle[propp];
		if ( thestyle == "auto" ) {
			var theprop = propp.substr( 0, 1 ).toUpperCase( ) + propp.substr( 1, propp.length - 1 );
			var theeval = 'thestyle = ( typeof( etargetp.offset' + theprop + ' ) != "undefined" ) ? etargetp.offset' + theprop + ' : 0;';
			eval( theeval );
		}
	} else {
		var hdoc = __eui_finddocument( etargetp );
		thestyle = hdoc.defaultView.getComputedStyle( etargetp, "" ).getPropertyValue( propp );
		// MG100311 usually this shouldn't be "auto", but in case of Safari it is sometimes. in such cases, get the style out of the offsetXxx prop.
		if ( ( thestyle == "auto" ) && ( propp.indexOf( "-" ) == -1 ) ) {
			var seval = "var effstyle = etargetp.offset" + propp.substr( 0, 1 ).toUpperCase( ) + propp.substr( 1, 100 ) + ";";
			eval( seval );
			if ( effstyle ) {
				thestyle = effstyle;
			}
		}
	}
	return thestyle;
}
// copy the styles from one css sheet to another
function __eui_copystyles( hsourcep, hdestp ) {
	if ( __EUI_BROWSER_IS_MSIE ) {
		if ( ( typeof( hsourcep.styleSheet ) != "undefined" ) && ( typeof( hsourcep.styleSheet.rules ) != "undefined" ) && ( typeof( hdestp.styleSheet ) != "undefined" ) && ( typeof( hdestp.styleSheet.rules ) != "undefined" ) ) {
			hdestp.styleSheet.cssText = hsourcep.styleSheet.cssText;
		}
	} else {
		if ( ( typeof( hsourcep.sheet ) != "undefined" ) && ( typeof( hsourcep.sheet.cssRules ) != "undefined" ) && ( typeof( hdestp.sheet ) != "undefined" ) && ( typeof( hdestp.sheet.cssRules ) != "undefined" ) ) {
			// first clear out the target css to be completely empty:
			for ( var i = hdestp.sheet.cssRules.length - 1; i >= 0; i-- ) {
				hdestp.sheet.deleteRule( i );
			}
			// now copy all the css text from the source to the destination
			for ( var i = 0; i < hsourcep.sheet.cssRules.length; i++ ) {
				hdestp.sheet.insertRule( hsourcep.sheet.cssRules[i].cssText, i );
			}
		}
	}
}
// MG090911 new function to remove a style declaration
function __eui_removestyle( stylenamep ) {
	// MG100127 to avoid cross-domain css access errors (introduced by oddities like foreign "chrome" toolbars etc.)
	// we now check that we only deal with css files from our own domain.
	var ourloc = new String( window.location );
	ourloc = ourloc.substr( ourloc.indexOf( "//" ) + 2, 100 );
	ourloc = ourloc.substr( 0, ourloc.indexOf( "/" ) );
	for ( var i = 0; i < document.styleSheets.length; i++ ) {
		if ( ( document.styleSheets[i].href == null ) || ( document.styleSheets[i].href.indexOf( ourloc ) > -1 ) ) {
			var thesheet = (document.styleSheets[i].cssRules)?document.styleSheets[i].cssRules:document.styleSheets[i].rules;
			for ( var j = thesheet.length - 1; j >= 0; j-- ) {
				if ( thesheet[j].selectorText.toLowerCase( ) == stylenamep.toLowerCase( ) ) { 
					if ( typeof( document.styleSheets[i].deleteRule ) == "function" ) {
						document.styleSheets[i].deleteRule( j );
					} else {
						thesheet[j].style.cssText = "";
					}
				}
			}
		}
	}
}
function __eui_has_children( elmp, typep ) {
	var breturn = false;
	try {
		for ( var i = 0; i < elmp.childNodes.length; i++ ) {
			breturn = breturn || ( elmp.childNodes[i].nodeType == typep );
		}
	}
	catch ( err ) {
		// nth
	}
	return breturn;
}
// containerp indicates that the style need be written to a style sheet (the one passed by containerp) immediately,
// so that not only single controls are placed individually, but a whole bunch of controls sharing the same css_xxx class name
// immediately inherit the properties.
function __eui_makemovable( hdocp, tagnamep, classnamep, containerp ) {
	__eui_addevent( hdocp, "mousemove", __eui_movepos );
	__eui_addevent( hdocp, "mouseup", __eui_endtrack );
	var allelms = hdocp.getElementsByTagName( tagnamep );
	if ( containerp ) {
		var cstyle = new Array( );
	}
	// MG091111 the approach with summing up the width of elements rather than positioning them on their actual position on the display
	// is rather clumsy but the offsetLeft / computedstyle method doesn't come up with a really satisfying result.
	// if this is required to do more than just position a single line of horiz/vert controls, then it may need an overhaul.
	var leftcoords = 0;
	var topcoords = 0;
	for ( var i = 0; i < allelms.length; i++ ) {
		if ( ( allelms[i].className == classnamep ) || ( allelms[i].className.indexOf( classnamep + " " ) > -1 ) || ( allelms[i].className.indexOf( " " + classnamep ) > -1 ) ) {
			if ( allelms[i].getAttribute( "cssoverflow" ) ) {
				allelms[i].className += " draglayout";
			} else {
				allelms[i].className += " movelayout";
			}
			allelms[i].style.width = __eui_grid( parseInt( __eui_getcomputedstyle( allelms[i], "width" ) ) ) + "px";
			allelms[i].style.height = __eui_grid( parseInt( __eui_getcomputedstyle( allelms[i], "height" ) ) ) + "px";
			// check the current left / top style. if anything meaningful is set (i.e. not 0 or auto), do the chaining if needed, otherwise not.
			// need to evaluate this before we set the position to absolute, otherwise it won't work
			var bchain = ( __eui_getcomputedstyle( allelms[i], "position" ) != "absolute" );
			allelms[i].style.position = "absolute";
			// if the elements should initially be chained horizontally (indicated by chained="x"), do it
			if ( bchain && allelms[i].getAttribute( "chained" ) && ( allelms[i].getAttribute( "chained" ) == "x" ) && ( __eui_getcomputedstyle( allelms[i], "visibility" ) != "hidden" ) ) {
				//if ( allelms[i].offsetLeft ) {
				//	allelms[i].style.left = allelms[i].offsetLeft + "px";
				//} else {
				//	allelms[i].style.left = allelms[i].offsetParent.offsetLeft + "px";
				//}
				if ( leftcoords == 0 ) {
					leftcoords = parseInt( __eui_getcomputedstyle( allelms[i], "left" ) );
				}
				allelms[i].style.left = leftcoords + "px";
				leftcoords += __eui_grid( allelms[i].offsetWidth );
			}
			// if the elements should initially be chained vertically (indicated by chained="y"), do it
			if ( bchain && allelms[i].getAttribute( "chained" ) && ( allelms[i].getAttribute( "chained" ) == "y" ) && ( __eui_getcomputedstyle( allelms[i], "visibility" ) != "hidden" ) ) {
				//if ( allelms[i].offsetTop ) {
				//	allelms[i].style.top = allelms[i].offsetTop + "px";
				//} else {
				//	allelms[i].style.top = allelms[i].offsetParent.offsetTop + "px";
				//}
				if ( topcoords == 0 ) {
					topcoords = parseInt( __eui_getcomputedstyle( allelms[i], "top" ) );
				}
				allelms[i].style.top = topcoords + "px";
				topcoords += __eui_grid( allelms[i].offsetTop );
			}
			// if a css container has been passed, write the newly derived style info to it
			if ( containerp ) {
				cstyle[cstyle.length] = "." + allelms[i].className.substring( allelms[i].className.indexOf( "css_" ), 100 ).replace( " movelayout", "" ).replace( " draglayout", "" ) + " { ";
				cstyle[cstyle.length-1] += "position: absolute; ";
				// if the elements are x-chained, write the inital coords to the css
				if ( allelms[i].getAttribute( "chained" ) && ( allelms[i].getAttribute( "chained" ) == "x" ) ) {
					cstyle[cstyle.length-1] += "left: " + allelms[i].style.left + "; ";
				}
				// if the elements are y-chained, write the inital coords to the css
				if ( allelms[i].getAttribute( "chained" ) && ( allelms[i].getAttribute( "chained" ) == "y" ) ) {
					cstyle[cstyle.length-1] += "top: " + allelms[i].style.top + "; ";
				}
				cstyle[cstyle.length-1] += "width: " + allelms[i].style.width + "; ";
				cstyle[cstyle.length-1] += "height: " + allelms[i].style.height + "; ";
				cstyle[cstyle.length-1] += "}";
			}
			allelms[i].setAttribute( "savecss", 1 );
			if ( __eui_has_children( allelms[i], document.ELEMENT_NODE ) ) {
				if ( ! __EUI_BROWSER_IS_MSIE ) {
					var cloakit = hdocp.createElement( "div" );
					cloakit.setAttribute( "cloakit", "cloakit" );
					cloakit.style.position = "absolute";
					cloakit.style.left = "0";
					cloakit.style.top = "0";
					cloakit.style.width = Math.max( allelms[i].offsetWidth - 4, 10 ) + "px";
					cloakit.style.height = Math.max( allelms[i].offsetHeight - 4, 10 ) + "px";
					cloakit.style.zIndex = "100";
					if ( ! allelms[i].getAttribute( "cssoverflow" ) ) {
						allelms[i].style.overflow = "hidden";
					}
				} else {
					// some special treatment for the dull MSIE
					var cloakit = hdocp.createElement( "img" );
					cloakit.setAttribute( "cloakit", "cloakit" );
					cloakit.style.position = "relative";
					cloakit.style.left = "0";
					cloakit.style.top = "0";
					cloakit.style.width = Math.max( allelms[i].clientWidth, 10 ) + "px";
					cloakit.style.height = Math.max( allelms[i].clientHeight, 10 ) + "px";
					allelms[i].style.padding = "0";
					cloakit.src = "/styles/_default/images/1x1_trans.gif";
					if ( __eui_has_children( allelms[i], document.TEXT_NODE ) ) {
						var thecontainer = document.createElement( "div" );
						thecontainer.style.position = "absolute";
						for ( var j = allelms[i].childNodes.length - 1; j >= 0 ; j-- ) {
							try {
								if ( thecontainer.childNodes.length == 0 ) {
									var firstchild = thecontainer.appendChild( allelms[i].childNodes[j] );
								} else {
									thecontainer.insertBefore( allelms[i].childNodes[j], firstchild );
								}
							} catch( err ) {
								// nth
							}
						}
						allelms[i].appendChild( thecontainer );
					} else {
						for ( var j = allelms[i].childNodes.length - 1; j >= 0 ; j-- ) {
							allelms[i].childNodes[j].style.position = "absolute";
						}
					}
					// if the cssoverflow attribute is set, we don't cut the contents of the container div at its borders.
					// this is needed so that we can show all fields in the datatab pane for instance while the pane itself collapses to
					// just a few pixels width.
					if ( ! allelms[i].getAttribute( "cssoverflow" ) ) {
						allelms[i].style.overflow = "hidden";
					} else {
						cloakit.style.border = "1px dotted red";
					}
				}
				__eui_addevent( cloakit, "mousedown", __eui_starttrack );
				__eui_addevent( cloakit, "dblclick", __eui_togglealignment );
				allelms[i].appendChild( cloakit );
			} else {
				__eui_addevent( allelms[i], "mousedown", __eui_starttrack );
				__eui_addevent( allelms[i], "dblclick", __eui_togglealignment );
			}
		}
	}
	if ( containerp ) {
		for ( i = 0; i < cstyle.length; i++ ) {
			__eui_addstyle( containerp, cstyle[i] );
		}
	}
}
function __eui_readpos( hdocp, tagnamep ) {
	var allelms = hdocp.getElementsByTagName( tagnamep );
	var thecss = "";
	var allstored = new Array( );
	for ( var i = 0; i < allelms.length; i++ ) {
		if ( allelms[i].getAttribute( "savecss" ) == 1 ) {
			var theclass = allelms[i].className.replace( " movelayout", "" ).replace( " draglayout", "" );	// remove the drag/move indicators from the css string
			theclass = theclass.substring( theclass.indexOf( "css_" ), 100 );
			if ( theclass.indexOf( " " ) > -1 ) {
				theclass = theclass.substring( 0, theclass.indexOf( " " ) - 1 );
			}
			if ( ! __eui_inarray( theclass, allstored ) ) {
				//thecss += allelms[i].tagName.toLowerCase( ) + "." + theclass + " { ";
				thecss += "." + theclass + " { ";
				thecss += "position: " + __eui_getcomputedstyle( allelms[i], "position" ) + "; ";
				if ( ( ! allelms[i].getAttribute( "fixed" ) ) || ( allelms[i].getAttribute( "fixed" ) != "x" ) ) {
					thecss += "left: " + __eui_getcomputedstyle( allelms[i], "left" ) + "; ";
				}
				if ( ( ! allelms[i].getAttribute( "fixed" ) ) || ( allelms[i].getAttribute( "fixed" ) != "y" ) ) {
					thecss += "top: " + __eui_getcomputedstyle( allelms[i], "top" ) + "; ";
				}
				thecss += "width: " + __eui_getcomputedstyle( allelms[i], "width" ) + "; ";
				thecss += "height: " + __eui_getcomputedstyle( allelms[i], "height" ) + "; ";
				thecss += "text-align: " + __eui_getcomputedstyle( allelms[i], "text-align" ) + "; ";
				thecss += "visibility: " + __eui_getcomputedstyle( allelms[i], "visibility" ) + "; ";
				//thecss += "display: " + __eui_getcomputedstyle( allelms[i], "display" ) + "; ";
				thecss += "} ";
			}
			allstored[allstored.length] = theclass;
		}
	}
	return thecss;
}
function __eui_starttrack( event ) {
	var myev = (event)?event:window.event;
	var etarget = __eui_geteventsrc( myev );
	if ( ( ! etarget.getAttribute( "savecss" ) ) && etarget.parentNode && ( typeof( etarget.parentNode.getAttribute ) != "undefined" ) && etarget.parentNode.getAttribute( "savecss" ) ) {
		etarget = etarget.parentNode;
	}
	// find out the current document, in case there's more than one (frames, iframes...)
	__eui_trackwinpos( myev );
	etarget.setAttribute( "bOpacity", etarget.style.opacity );
	etarget.setAttribute( "bZIndex", etarget.style.zIndex );
	etarget.style.opacity = ".5";
	etarget.style.zIndex = "999";
	xy = __eui_getcoords( myev );
	top.__eui_layout_offset_x = parseInt( __eui_getcomputedstyle( etarget, "left" ) ) - xy[0];
	top.__eui_layout_offset_y = parseInt( __eui_getcomputedstyle( etarget, "top" ) ) - xy[1];
	top.__eui_layout_orig_width = parseInt( __eui_getcomputedstyle( etarget, "width" ) );
	top.__eui_layout_orig_height = parseInt( __eui_getcomputedstyle( etarget, "height" ) );
	top.__eui_layout_changeable = true;
	top.__eui_track_element = etarget;
}
function __eui_endtrack( event ) {
	if ( top.__eui_track_element ) {
		top.__eui_track_element.style.opacity = top.__eui_track_element.getAttribute( "bOpacity" );
		top.__eui_track_element.style.zIndex = top.__eui_track_element.getAttribute( "bZIndex" );
		__eui_updateview( top.__eui_track_element );
	}
	top.__eui_layout_changeable = false;
	top.__eui_track_element = null;
}
function __eui_movepos( event ) {
	// MSIE has the nice behaviour to only update our drag ops every now and then if no additional stuff is dumped onto the screen.
	// so make it happy. this needs to be done at the beginning and at the end of this function...
	if ( __EUI_BROWSER_IS_MSIE && document.getElementById( "layoutguide" ) ) {
		document.getElementById( "layoutguide" ).value = "000";
	}
	var myev = (event)?event:window.event;
	var etarget = __eui_geteventsrc( myev );
	var hovertarget = etarget; // in case of a layover div we need to change the mouse cursor style there and not on the underlying element that we want to move
	if ( ( ! etarget.getAttribute( "savecss" ) ) && etarget.parentNode && ( typeof( etarget.parentNode.getAttribute ) != "undefined" ) && etarget.parentNode.getAttribute( "savecss" ) ) {
		etarget = etarget.parentNode;
	} else if ( ( etarget.childNodes.length > 0 ) && ( typeof( etarget.childNodes[etarget.childNodes.length-1].getAttribute ) != "undefined" ) && etarget.childNodes[etarget.childNodes.length-1].getAttribute( "cloakit" ) ) {
		hovertarget = etarget.childNodes[etarget.childNodes.length-1];
	}
	// find out the current document, in case there's more than one (frames, iframes...)
	__eui_trackwinpos( myev );
	xy = __eui_getcoords( myev );
	var offset_x = (myev.layerX)?myev.layerX:myev.offsetX;
	var offset_y = (myev.layerY)?myev.layerY:myev.offsetY;
	if ( top.__eui_layout_changeable == false ) {
		top.__eui_trackmode = "";
		// fixed="x" or fixed="y" indicates that the control can only be moved in the non-fixed direction
		if ( ( ! etarget.getAttribute( "fixed" ) ) || ( etarget.getAttribute( "fixed" ) != "y" ) ) {
			top.__eui_trackmode += (offset_y>=etarget.offsetHeight/2)?"s":"";
		}
		if ( ( ! etarget.getAttribute( "fixed" ) ) || ( etarget.getAttribute( "fixed" ) != "x" ) ) {
			top.__eui_trackmode += (offset_x>=etarget.offsetWidth/2)?"e":"";
		}
		if ( etarget.getAttribute( "savecss" ) == 1 ) {
			etarget.style.cursor = (top.__eui_trackmode=="")?"move":top.__eui_trackmode+"-resize";
			hovertarget.style.cursor = etarget.style.cursor;
		}
	} else {
		// move the element regardless of the mouse pointer being exactly over it, so set etarget to the element that is just dragged atm
		etarget = top.__eui_track_element;
		x = parseInt( xy[0] ) + top.__eui_layout_offset_x;
		y = parseInt( xy[1] ) + top.__eui_layout_offset_y;
		// put the coordinates onto a grid if ctrl wasn't pressed
		if ( ! myev.ctrlKey ) {
			x = __eui_grid( x );
			y = __eui_grid( y );
		}
		if ( top.__eui_trackmode == "" ) {
			if ( ( ! etarget.getAttribute( "fixed" ) ) || ( etarget.getAttribute( "fixed" ) != "x" ) ) {
				etarget.style.left = x + "px";
			}
			if ( ( ! etarget.getAttribute( "fixed" ) ) || ( etarget.getAttribute( "fixed" ) != "y" ) ) {
				etarget.style.top = y + "px";
			}
		}
		if ( top.__eui_trackmode.indexOf( "e" ) > -1 ) {
			var nx = parseInt( top.__eui_layout_orig_width + parseInt( x ) - parseInt(  __eui_getcomputedstyle( etarget, "left" ) ) );
			// odd MSIE bug the h-resize "jumps" during the first few pixels of mouse movement for ~ 90 pixels and thus looks awful...
			if ( __EUI_BROWSER_IS_MSIE ) {
				var oldnx = ( parseInt( etarget.style.width ) ) ? parseInt( etarget.style.width ) : etarget.offsetWidth;
				if ( Math.abs( oldnx - nx ) > 50 ) {
					nx = -1;
				}
			}
			if ( nx > -1 ) {
				etarget.style.width = nx + "px";
				hovertarget.style.width = etarget.style.width;
			}
		}
		if ( top.__eui_trackmode.indexOf( "s" ) > -1 ) {
			var ny = parseInt( top.__eui_layout_orig_height + parseInt( y ) - parseInt(  __eui_getcomputedstyle( etarget, "top" ) ) );
			// odd MSIE bug the v-resize "jumps" during the first few pixels of mouse movement for ~ 90 pixels and thus collapses the box to be v-resized...
			if ( __EUI_BROWSER_IS_MSIE ) {
				var oldny = ( parseInt( etarget.style.height ) ) ? parseInt( etarget.style.height ) : etarget.offsetHeight;
				if ( Math.abs( oldny - ny ) > 50 ) {
					ny = -1;
				}
			}
			if ( ny > 0 ) {
				etarget.style.height = ny + "px";
				hovertarget.style.height = etarget.style.height;
			}
		}
		// only update referenced items in the column view mode, not the detail views, cos there it's not necessary and IE gets freakingly slow.
		// this behaviour is indicated by the layoutguide input field's attribute "updateview"
		if ( document.getElementById( "layoutguide" ) && ( document.getElementById( "layoutguide" ).getAttribute( "updateview" ) == "update" ) ) {
			__eui_updateview( etarget );
		}
	}
	// MSIE has the nice behaviour to only update our drag ops every now and then if no additional stuff is dumped onto the screen.
	// so make it happy. this needs to be done at the beginning and at the end of this function...
	if ( __EUI_BROWSER_IS_MSIE && document.getElementById( "layoutguide" ) ) {
		document.getElementById( "layoutguide" ).value = offset_x + offset_y;	// just some dummy value that is bound to change on movement
	}
}
function __eui_togglealignment( event ) {
	var myev = (event)?event:window.event;
	var etarget = __eui_geteventsrc( myev );
	if ( ( ! etarget.getAttribute( "savecss" ) ) && etarget.parentNode && ( typeof( etarget.parentNode.getAttribute ) != "undefined" ) && etarget.parentNode.getAttribute( "savecss" ) ) {
		etarget = etarget.parentNode;
	}
	var curralign = __eui_getcomputedstyle( etarget, "text-align" );
	etarget.style.textAlign = (curralign=="right")?"left":"right";
	if ( document.getElementById( "layoutguide" ) && ( document.getElementById( "layoutguide" ).getAttribute( "updateview" ) == "update" ) ) {
		__eui_updateview( etarget );
	}
}
function __eui_updateview( etargetp ) {
	theviewmode = document.getElementById( "viewmode" );
	if ( theviewmode ) {
		var thecss = "." + etargetp.className.substring( etargetp.className.indexOf( "css_" ), 100 ).replace( " movelayout", "" ).replace( " draglayout", "" ) + " { ";
		if ( ( ! etargetp.getAttribute( "fixed" ) ) || ( etargetp.getAttribute( "fixed" ) != "x" ) ) {
			thecss += "left: " + __eui_getcomputedstyle( etargetp, "left" ) + "; ";
		}
		if ( ( ! etargetp.getAttribute( "fixed" ) ) || ( etargetp.getAttribute( "fixed" ) != "y" ) ) {
			thecss += "top: " + __eui_getcomputedstyle( etargetp, "top" ) + "; ";
		}
		thecss += "width: " + __eui_getcomputedstyle( etargetp, "width" ) + "; ";
		thecss += "height: " + __eui_getcomputedstyle( etargetp, "height" ) + "; ";
		thecss += "text-align: " + __eui_getcomputedstyle( etargetp, "text-align" ) + "; ";
		thecss += "visibility: " + __eui_getcomputedstyle( etargetp, "visibility" ) + "; ";
		thecss += "position: " + __eui_getcomputedstyle( etargetp, "position" ) + "; ";
		thecss += "}";
		__eui_addstyle( theviewmode, thecss );
	}
}
function __eui_grid( np ) {
	if ( ! isNaN( np ) ) {
		return parseInt( np / top.__eui_gridsize ) * top.__eui_gridsize;
	} else {
		return np;
	}
}
