
function IsIE(){
	return $.browser.msie;
}

//*******************************************
// Für Firefox, kennt insertAdjacentElement nicht... 
//*******************************************
if(typeof HTMLElement!="undefined" && !HTMLElement.prototype.insertAdjacentElement) { 
	HTMLElement.prototype.insertAdjacentElement = function (where,parsedNode) {
		switch (where){
			case "beforeBegin":
				this.parentNode.insertBefore(parsedNode,this);
				break;
			case "afterBegin":
				this.insertBefore(parsedNode,this.firstChild);
				break;
			case "beforeEnd":
				this.appendChild(parsedNode);
				break;
			case "afterEnd":
				if (this.nextSibling)
					this.parentNode.insertBefore(parsedNode,this.nextSibling);
				else 
					this.parentNode.appendChild(parsedNode);
			break;
		}
	}
	//nameProp kennt Firefox auch nicht...
	HTMLElement.prototype.__defineGetter__("nameProp", function() {
		if (this.src) {
			return ( this.src.substring( this.src.lastIndexOf("/") + 1 , this.src.length) ).toString();
		} else {
			return ("");
		}
	});
	
	XMLDocument.prototype.selectNodes = function(sExpr, contextNode)
	{
		var oResult = this.evaluate(sExpr, (contextNode?contextNode:this), 
							this.createNSResolver(this.documentElement),
							XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
		var nodeList = new Array(oResult.snapshotLength);
		nodeList.expr = sExpr;
		for(i=0;i<nodeList.length;i++)
			nodeList[i] = oResult.snapshotItem(i);
		return nodeList;
	};
	Element.prototype.selectNodes = function(sExpr)
	{
		var doc = this.ownerDocument;
		if(doc.selectNodes)
			return doc.selectNodes(sExpr, this);
		else
			throw "Method selectNodes is only supported by XML Nodes";
	};

}


//*******************************************
// Gibt ein Objekt zurück, dass anhand des Namens gefunden werden kann
// Am schnellsten ist die Funktion, wenn der Container mit angegeben wird.
// das entsprechende Fenster kann mit angegeben werden(object)
// NULL, wenn Element nicht gefunden wird
//*******************************************
function ElementByID(id, win){
	if(win == null) win = window;
	
	var ret;
	var frm = Form_GetDefaultForm(win);
	if(frm != null){
		if( (ret = frm[id]) != null) return ret;
	}
	if( (ret = win[id]) != null) return ret;
	if( (ret = win.document.getElementById(id)) != null) return ret;
	
	if(id.substr(0, 2) != "c_" && id.substr(0, 2) != "c$"){
		ret = ElementByID("c_" + id, win);
	}else if (id.substr(0, 2) == "c_"){
		ret = ElementByID("c$" + id.substr(2), win);
	}
	if(ret == null){
		var rets = document.getElementsByName(id);
		if(rets!=null && rets.length==1) ret = rets[0];
	}
	return ret;
}

//*******************************************
// Gibt den Hauptordner der Seite zurück
// Falls Cookieless-Session, dann wird die
// Session-Variable mitgenommen
//*******************************************
function RootPath(){
	if(document.pathModifier == null){
		var m = window.location.pathname;
		var startAt = 1;
		
		if(m.substr(0, 1) != "/") m = "/" + m; //in Dialogues
		if(m.substr(startAt, 8).toLowerCase() == "logonas/") startAt += 8;
		if(m.substr(startAt, 3) == "(S("){
			document.pathModifier = m.substring(0, m.indexOf("/", startAt) + 1);
		}else{
			document.pathModifier = "/";
		}
	}else{
		if(document.pathModifier.substr(0, 1) != "/"){
			//old Behavior...
			document.pathModifier = "/" + document.pathModifier;
		}
	}
	return document.pathModifier;
}


//*******************************************
// Gibt an, ob das Objekt ausgewählt werden
// kann (attribut selectable im Tree vorhanden)
//*******************************************
function isSelectable(o){
	var ret = false;
	
	while(o!=null){
		if( o.selectable ) return true;
		o = o.parentElement;
	}
	
	return ret;
}


//*******************************************
// Hover-Funktion für alle
//*******************************************
function Hover(tagName, childrenFromObjOnly, ev){
	if(!ev) {
		ev = window.event;	
	}
	if (ev && window.event) {
		var o = ev.srcElement;
	} else if(ev && ev.target) {
		o = ev.target;
	}else{
		return;
	}

	while(o != null && o.tagName != tagName){
		var op = o.parentNode;
		if((childrenFromObjOnly != null) && op==childrenFromObjOnly) return; // ? - sollte hier nicht ein break stehen, statt einem return?
		o = op;
	}
	if(o != null){
		if(!o.className.hasClassName("nohover")){
			o.className = o.className.addClassName("hover");
			o.onmouseout = function(){
				this.className = this.className.removeClassName("hover");
			}
		}
	}
}

//*******************************************
// HoverOut-Funktion für alle (obsolete)
//*******************************************
function HoverOut(tagName){
return;
	var o = window.event.srcElement;
	while(o != null && o.tagName != tagName){
		o = o.parentElement;
	}
	if(o != null){
		o.className = o.className.removeClassName("hover");
	}
}

//*******************************************
// Focus-Funktion für alle
//*******************************************
function FocusIn(ev){
	if(!ev) ev = window.event;
	if(ev.srcElement) {
		var src = ev.srcElement;
	} else if(ev.target) {
		var src = ev.target;
	}
	
	if( src!=null && src.tagName=="SPAN" ){
		src.className = src.className.addClassName("focus");
		src.onfocusout = function(){
			this.className = this.className.removeClassName("focus");
		}
	}
}




//*******************************************
// A-Title-Funktion
//*******************************************
function AHI(){
	if(window.event) {
		document.sdsd++;
		var o = window.event.srcElement;
		if(o!=null && o.tagName=="A"){
			var stat = o.title;
			if(stat == "") stat = o.innerText;
			
			if(stat != "") {
				top.window.status = stat;
				
				if(o.onmouseleave == null){
					o.onmouseleave = function(){ top.window.status = ""; return true; }
				}
				window.event.cancleBubble = true;
			}
		}
	}
	return true;
}

/*****************************************************************
Öffnet ein Fenster
res		= Arguments
props	= DialogProperties
name	= name des Fensters, mit dem es erkannt werden soll
		  wenn null, dann automatisch, wenn "", dann wird kein
		  Name verwendet (und kann daher auch nicht aktiviert werden
win		= Aufrufendens Fenster (Standard = window). Achtung, dass ändert relative Pfade!
*****************************************************************/
function Window_OpenOrShow(file, name, props, win, dontShowErrMsg) {
	try{
		if(win == null) win = window;
		if (name == null) name = "";
		var cf = CorrectPath(file);
		if(name == ""){
			var d = win.open(cf, name, props);
			d.document.topFrame = document.topFrame == null ? top : document.topFrame;
		}else{
			var obj = win["win__" + name];
			if(obj != null && !obj.closed){
				obj.document.focus();
			}else{
				win["win__" + name] = win.open(cf, name, props);
				win["win__" + name].document.topFrame = document.topFrame == null ? top : document.topFrame;
			}
		}
	} catch(e) {
		if(cf.toLowerCase().indexOf("/content/products/voting.aspx?guid=")!=-1){
			window.open(cf, "GfghMain");
			return;
		}
		if(!dontShowErrMsg) alert("Ein aktivierter Popup-Blocker hat die Anzeige des gewünschten Dialogs nicht zugelassen.\nBitte deaktivieren Sie den Popupblocker für diese Seite.\n\nAlternativ können Sie bei vielen Popup-Blockern auch die Strg-Taste während des Vorgangs gedrückt halten.");
	}
}


/*****************************************************************
Öffnet ein Modeless-Window oder setzt den Focus, wenn dieses
bereits offen ist
res		= Arguments
props	= DialogProperties
name	= name des Fensters, mit dem es erkannt werden soll
		  wenn null, dann automatisch, wenn "", dann wird kein
		  Name verwendet (und kann daher auch nicht aktiviert werden
win		= Aufrufendens Fenster (Standard = TOP). Achtung, dass ändert relative Pfade!
*****************************************************************/
function ModelessWindow_OpenOrShow(file, res, props, name, win, dontShowErrMsg){
	//automatische Abhandlung ist zwar langsamer und umständlicher, aber dafür in der weiteren Anwendung einfacher und immer gleich
	
	var cf=CorrectPath(file);
	if(name == null){
		name = cf.replace(/[?.:;_/\\+%#&-]/g, "");
	}
		
	var doProps = DialogWindowProperties(props);
	try{
		if(win == null) win = top;
		
		if(!window.showModelessDialog) { // in FF vorerst einfach über window.open abhandeln...besser als garnichts...
			Window_OpenOrShow(file,name,DialogWindowPropertiesFF(props),win,dontShowErrMsg);
			return;
		}

		if(name == ""){
				win.showModelessDialog(cf, {value: res, topFrame: top}, doProps);
		}else{
			var obj = win["win__" + name];
			if(obj != null && !obj.closed){
				obj.document.focus();
			}else{
				win["win__" + name] = win.showModelessDialog(cf, {value: res, topFrame: top}, doProps);
			}
		}
	} catch(e) {
		if(cf.toLowerCase().indexOf("/content/products/voting.aspx?guid=")!=-1){
			window.open(cf, "GfghMain");
			return;
		}
		if(!dontShowErrMsg) alert("Ein aktivierter Popup-Blocker hat die Anzeige des gewünschten Dialogs nicht zugelassen.\nBitte deaktivieren Sie den Popupblocker für diese Seite.\n\nAlternativ können Sie bei vielen Popup-Blockern auch die Strg-Taste während des Vorgangs gedrückt halten.");
	}
}

/*****************************************************************
Ersetzt ~ am Anfang durch den entsprechenden Pfad
*****************************************************************/
function CorrectPath(f){
	if(f.substr(0, 2) == "~/"){
		f = RootPath() + f.substr(2);
	}
	return f;
}


/*****************************************************************
Öffnet ein Modal-Window
res		= Arguments
props	= DialogProperties
*****************************************************************/
function ModalWindow_Open(file, res, props, dontShowErrMsg){
	var ret = null;
	var doProps = DialogWindowProperties(props);
	
	//alert(CorrectPath(file) + "\n" + res + "\n" + doProps);
	try{
		ret = window.showModalDialog(CorrectPath(file), {value: res, topFrame: top}, doProps);
	}catch(e){
		if(!dontShowErrMsg) alert("Ein aktivierter Popup-Blocker hat die Anzeige des gewünschten Dialogs nicht zugelassen.\nBitte deaktivieren Sie den Popupblocker für diese Seite.\n\nAlternativ können Sie bei vielen Popup-Blockern auch die Strg-Taste während des Vorgangs gedrückt halten.");
	}
	return ret;
}

/*****************************************************************
Gibt Standard - Eigenschaften eines Fensters zurück
Wird intern von ModalWindow_Open und ModelessWindow_OpenOrShow aufgerufen
*****************************************************************/
function DialogWindowProperties(props){
	var doProps = "";
	var hasStatus=false, hasHelp=false, hasScroll=false, hasCenter=false;
	var ps = (props!=null?props:"").toLowerCase().split(/;/g);
	for(var i=0; i<ps.length; i++){
		var p = ps[i].trim();
		if(p.substr(0, 6)==('status')) hasStatus = true;
		if(p.substr(0, 4)==('help')) hasHelp = true;
		if(p.substr(0, 6)==('scroll')) hasScroll = true;
		if(p.substr(0, 6)==('center')) hasCenter = true;
		
		doProps += ps[i] + ";";
	}
	if(!hasStatus) doProps += "status:no;"
	if(!hasHelp) doProps += "help:no;"
	if(!hasScroll) doProps += "scroll:no;"
	if(!hasCenter) doProps += "center:yes;"
	
	return doProps;
}

// DilaogProperties-Funktion für Standardkonforme Browser:
function DialogWindowPropertiesFF(props){
	var doProps ="dialog=yes,";
	props = props.replace(/;/g,",").replace(/:/g,"=").replace(/dialogWidth=/i,"width=").replace(/dialogHeight=/i,"height=").replace(/scroll=/i,"scrollbars=");
	var hasStatus=false, hasHelp=false, hasScroll=false, hasCenter=false, isResizable = false, hasToolbar = false, hasMenuBar = false;
	var ps = (props!=null?props:"").toLowerCase().split(/,/g);
	for(var i=0; i<ps.length; i++){
		var p = ps[i].trim();
		if(p.substr(0, 6)==('status')) hasStatus = true;
		//if(p.substr(0, 4)==('help')) hasHelp = true;
		if(p.substr(0, 6)==('scrollbars')) hasScroll = true;
		//if(p.substr(0, 6)==('center')) hasCenter = true;
		if(p.substr(0, 9)==('resizable')) isResizable = true;
		if(p.substr(0, 7)==('toolbar')) hasToolbar = true;
		if(p.substr(0, 7)==('menubar')) hasMenuBar = true;
		
		doProps += ps[i] + ",";
	}
	if(!hasStatus) doProps += "status=no,";
	//if(!hasHelp) doProps += "help:no,"
	if(!hasScroll) doProps += "scrollbars=no,";
	//if(!hasCenter) doProps += "center:yes,"
	if(!isResizable) doProps += "resizable=no,";
	if(!hasToolbar) doProps += "toolbar=no,";
	if(!hasMenuBar) doProps += "menubar=no,";
	
	return doProps.replace(/,,/g,',');
}


/*****************************************************************
Asynchroner und unbemerkter PostBack
*****************************************************************/
function Form_HiddenPostback(action, callbackFunction){
	var frm = Form_GetDefaultForm(window);
	if(frm != null && !frm.disableHidden){
		var defAction = frm.action;
		var defTarget = frm.target;
		frm.oldAction = frm.action;
		frm.oldTarget = frm.target;
		
		frm.target = "GfghHidden";
		frm.action = action;
		
		if(callbackFunction != null){
			switch(typeof(callbackFunction)){
				case "string": break;
				case "function":
					callbackFunction = callbackFunction.toString().substr(9);
					callbackFunction = callbackFunction.substr(0, callbackFunction.indexOf("("));
					callbackFunction = callbackFunction.trim();
					break;
				default:
					callbackFunction = callbackFunction.toString();
					break;
			}
			callbackFunction = "parent.frames['" + this.frames.name + "']." + callbackFunction;
			if(callbackFunction.indexOf("(") == -1) callbackFunction += "()";
			if(callbackFunction.substr(callbackFunction.length-1, 1) != ";") callbackFunction += ";";
		}else{
			callbackFunction = "";
		}
		callbackFunction = "parent.frames['" + this.frames.name + "'].Form_EnableHiddenPostbackForm();" + callbackFunction;
		
		var inp = frm.elements.__Callback;
		if(inp == null){
			var inp = document.createElement("INPUT");
			inp.name = "__Callback";
			inp.id = "__Callback";
			inp.type = "hidden";
			frm.insertAdjacentElement("beforeEnd", inp);
		}
		inp.value = callbackFunction;
		
		
		frm.submit();
		
		//Zurücksetzen der Form
		frm.target = frm.oldTarget;
		frm.action = CorrectPath(frm.oldAction);
		frm.disableHidden = true;
	}
}

/*****************************************************************
Wird nach PostBack wieder aufgerufen
*****************************************************************/
function Form_EnableHiddenPostbackForm(){
	var o;
	if( (o = Form_GetDefaultForm(window)) != null){
		o.disableHidden = null;
	}
}


/*****************************************************************
Gibt das Form-Objekt der Seite zurück
Das dazugehörige Fenster kann mit angegeben werden
*****************************************************************/
function Form_GetDefaultForm(win){
	if(win == null) win = window;
	var ret = win.aspnetForm;
	if(ret == null){
		ret = document.getElementById("aspnetForm");
		if(ret == null){
			ret = win.document.forms["aspnetForm"];
			if(ret == null){
				ret = win.document.forms[0];
			}
		}
	}
	return ret;
}

/*****************************************************************
Feuert alle onsubmit-statements innerhalb der form-Elemente
//TODO: wird noch nicht verwendet, weil Fehler bei fireEvent
*****************************************************************/
function Form_FireOnSubmit(ev){
	//if(!ev) { alert("Alter Aufruf an Form_FireOnSubmit.\nneu: Form_FireOnSubmit(event);"); return false;}
	if(!ev) ev = window.event;
	var frm = Form_GetDefaultForm();
	if(!frm) return;
	var o = frm.elements;
	if(!o) return;
	var l = o.length;
	for(var i=0; i<l; i++){
		o[i].fireEvent("onsubmit");
	}
	
	if(ev.returnValue) {
		ev.returnValue = false;
	} else if (ev.preventDefault) {
		ev.preventDefault();
		ev.stopPropagation();
	}
	return false;
}


/*****************************************************************
Gibt das value eines Nicht-Standard-HTML-attributs zu einem 
bestimmten Element Browserunabhänig zurück
*****************************************************************/
function getExpando(element, name){
	var o = element.attributes[name];
	if(o == null) return element[name];
	return o.value;
}

/*****************************************************************
Feuert den default-Button einer Form
*****************************************************************/
var Form_FireDefault_Clicked = false;
function Form_FireDefault(ev,target){
	if(!ev) ev = window.event;
	if(!ev) return true;
	
	var keycode = ev.which != null ? ev.which : ev.keyCode;
	if(!Form_FireDefault_Clicked && keycode == 13) {
		//var defaultButton = document.all[target];
		if($(ev.srcElement!=null?ev.srcElement:ev.target).is("TextArea,input.Submit")) return true;
		var defaultButton = document.getElementById(target);
		
		if (defaultButton.click != "undefined") {
			Form_FireDefault_Clicked = true;
			defaultButton.click();
			// firefox/IE unterscheidung.
			if(ev.cancelBubble) {
				ev.cancelBubble = true;
			} else if(ev.stopPropagation) {
				ev.stopPropagation();
			}
			return false;
		}
	}
	return true;
}




/*****************************************************************
Druckt das aktuelle Dokument

für optionen muss in document.printOptions ein Array
mit dem Objekt
id = {
	caption	:	anzuzeigender name,
	action	:	auszuführende Aktion (kann null sein)
				bei string gelten folgende Formatierungsoptionen
				{0} = Pfad der aktuellen Datei (ohne Searchstring)
				{1} = Name der aktuellen Datei (ohne Searchstring)
				{2} = Searchstring der aktuellen Datei
}

*****************************************************************/
function PrintPage(ev, option ){
	/*document.printOptions = [
		x = {
			caption: "fkljhdf",
			action: ""
		},
		y = {
			caption: "fkljhdf",
			action: ""
		}
	];
	*/
	
	//falls Optionen vorhanden sind, dann diese anzeigen
	var po = document.printOptions;
	if( option == null && po != null && po.length > 1 ){
		//var e = window.event;
		if(!ev)ev =window.event;
		
		if( ev != null){
			var d = document.printOptionSelector;
			if( d == null ){
				d = document.createElement("table");
				d.cellPadding = "2";
				d.cellSpacing = "0";
				d.border = "1";
				d.className = "printOptions";
				
				d.style.height = (/*20 +*/ po.length * 20) + "px";
				d.onmouseleave = function(){ this.style.display = "none"; };
				d.onmouseover = function(){ Hover("TR"); }
				d.onclick = function(e){
					if(!e)e=window.event;
					if(e != null){
						if(e.srcElement) {
							var src = e.srcElement;
						} else {
							var src = e.target;
						}
						while(src != null && src.tagName != "TR"){
							src = src.parentNode;
						}
						if( src != null ){
							this.style.display = "none";
							PrintPage(e, src.rowIndex );
						}
					}
				};
				
				
				var c;
				/*c = d.insertRow().insertCell();
				c.className = "caption";
				c.innerText = "Druckoptionen";
				*/
				for( var i=0; i<po.length; i++ ){
					if( po[i].caption != null ){
						c = d.insertRow().insertCell();
						c.innerText = po[i].caption;
						c.noWrap = "nowrap";
					}
				}
				
				
				document.printOptionSelector = document.body.appendChild( d );
			}
			
			d.style.display = "";
			d.style.left = (ev.x - 5) + "px";
			d.style.top = (ev.y - 5) + "px";
			
			return;
		}
	} else {
		var optID = 0;
		if( option != null) optID = option;
		
		var action = null;
		
		if( po != null ){
			if( po.length >= optID ){
				action = po[ optID ].action;
			} else {
				alert("Fehler in Druckoptionen");
			}
		}
		
		if( action == null ){ //aktuelle Seite so drucken, wie sie ist (einfach window.print() aufrufen
			window.print( );
		} else {
			
			var dlp = document.location.pathname;
			
			action = action.replace("{0}", dlp );
			action = action.replace("{1}", dlp.substr( dlp.lastIndexOf("/") + 1 ) );
			var s = document.location.search;
			if( s != null && s.length > 0 && s.charAt(0) == "?" ) s = s.substr(1);
			action = action.replace("{2}", s );
			
			window.open( action, "_blank" );
		}
	}
	
}

/*****************************************************************
Initialisiert die Session-Fehlermeldung, sollte bei window.onload 
der index-Seiten aufgeruffen werden. 
*****************************************************************/
function initWindowTimeout () {
			
			if(top != window){
				//kommt vor, wenn a) Session ungütig wurde oder b) Direkter Zugriff auf Datei
				try{
					try{
						document.body.style.display = "none";
					}catch(e){}
					try{
						//if(top.loadIndex) return;
						if(! top.loadIndex) {
							top.loadIndex = true;	
							alert("Sie sind momentan nicht angemeldet.\nSie werden nun automatisch zur Anmeldeseite weitergeleitet.");
							try{
								top.location.replace(document.location);
							}catch(e){}
						}
					}catch(e){}
				}catch(e){}
			}

}


//*******************************************
//
//          Prototype-Funktionen
//
//*******************************************


//*******************************************
// urlEscape-Funktion (+ wird zu %20), ersetz Zeichen für URLs
//*******************************************
String.prototype.urlEscape = function() {
	return escape(this ? this.replace(/\+/g, '%2B') : '')
		.replace(/\%u20ac/gi, '€').replace(/\+/g, '%20').replace(/%28/g, '(').replace(/%29/g, ')').replace(/%7E/g, '~').replace(/%21/g, '!').replace(/%3b/gi, ';').replace(/%2c/gi, ',');
}
//*******************************************
// xmlEscape-Funktion, ersetzt Zeichen für XML-Attribute
//*******************************************
String.prototype.xmlEscape = function() {
	return this ? this.replace(/&/g, '&amp;').replace(/\"/g, '&quot;').replace(/>/g, '&gt;').replace(/</g, '&lt;') : '';
}
//*******************************************
// Trim-Funktion (real schneidet auch &nbsp;'s weg.
//*******************************************
String.prototype.trim = function(real) {
	return real ? this.replace(/(^[\s\xA0]*)|([\s\xA0]*$)/g, '') : this.replace(/(^\s*)|(\s*$)/g, '');
}
//*******************************************
// Prüft, ob ein bestimmter Text in einer Leerzeichen-getrennten Liste vorhanden ist
//*******************************************
String.prototype.hasClassName = function(className){
	return new RegExp("\\b" + className + "\\b", "gi").test(this);
}
//*******************************************
// Fügt einen bestimmten Text aus einer Leerzeichen-getrennten Liste
//*******************************************
String.prototype.addClassName = function(className){
	var ret;
	if(this.length==0){
		ret = className;
	}else{
		if(!this.hasClassName(className)){ //nur hinzufügen, wenn dieses Tag noch nicht vorhanden ist
			ret = this.trim() + " " + className;
		}else{
			ret = this;
		}
	}
	return ret;
}
//*******************************************
// Fügt einen bestimmten Text aus einer Leerzeichen-getrennten Liste
//*******************************************
String.prototype.removeClassName = function(className){
	return this.replace(new RegExp(" *\\b" + className + "\\b *", "gi"), ' ').trim();
}

//*******************************************
// isValidEmail-Funktion. Prüft auf Gültigkeit einer Email-Adresse
//*******************************************
String.prototype.isValidEmail = function() {
	var eTest = /^[a-z0-9._-]*[a-z0-9_]+@[a-zäöü0-9_][a-zäöü0-9._-]*\.[a-z0-9]+$/i;
	return (eTest.test(this));
}

function getFirstChildElement(parent) {
///<summary>Firstchild mit Berücksichtigung der nodeType, gibt das erste gefundene ChildElement zurück.</summary>
	var ret = null;
	if(parent != null) {
		if(parent.childNodes){
			for(var i=0;i<parent.childNodes.length;i++) {
				if(parent.childNodes[i].nodeType == 1) {
					ret = parent.childNodes[i];
					break;								// Abbruch nachdem das erste nodeType==1 - Child gefunden wurde.
				}
			} 
		}
	}
	return ret;
}

function getLastChildElement(parent) {
///<summary>Firstchild mit Berücksichtigung der nodeType, gibt das letzte gefundene ChildElement zurück.</summary>
	var ret = null;
	if(parent != null) {
		if(parent.childNodes){
			for(var i=(parent.childNodes.length -1); i >=0; i--) {
				if(parent.childNodes[i].nodeType == 1) {
					ret = parent.childNodes[i];
					break;								// Abbruch nachdem das erste nodeType==1 - Child von hinten gefunden wurde.
				}
			} 
		}
	}
	return ret;
}




function getChildren(parent) {
///<summary>Ersatz für X.children (gibts im FF nicht). Gibt ein Array aller Kind-Elementknoten zurück</summary>
	var ret = null;
	if(parent != null) {
		if(parent.childNodes){
			var arr = new Array();
			for(var i=0;i<parent.childNodes.length;i++) {
				if(parent.childNodes[i].nodeType == 1) {
					arr.push(parent.childNodes[i]);
				}
			} 
			if(arr.length > 0) {
				ret = arr;
			}
		}
	}
	return ret;
}

function getPosition( obj ){	
	///<summary>Gibt die tatsächlich Position eines Objekts innerhalb der Seite zurück</summary>
	///<param name="obj" type="Object" mayBeNull="true"></param>
	var x=0, y=0;
	while( obj != null ){
		x += obj.offsetLeft;
		y += obj.offsetTop;
		obj = obj.offsetParent;
	}
	return [x, y];
}

function cancelEventBubble(ev) {
	if(!ev && window.event != null) {
		ev = window.event;
	}
	if(ev != null) {
		if(ev.stopPropagation) {
			ev.stopPropagation();
		} else if(ev.cancelBubble) {
			ev.cancelBubble = true;
		}
	}
}

// Diese Hilfsfunktion kapselt das "verbiegen" der locatiuon innerhlab eines iframes.
// der IE hatte das mit iframe.location gemacht, FF wollte iframe.src haben und keiner der beiden hat das des anderen verstanden, daher kapseln wir das hier.
// durch die Prüfung auf frame.contentDocument, sollte der IE das auch im Doctype-Modus raffen.
function setIframeLocation(iframename, loc) {
	if(iframename != null && iframename != '' && loc != null) {
		var frame = ElementByID(iframename);
		if(frame != null) {
			var innerDoc = null;
			if (frame != null) {
				innerDoc = (frame.contentDocument) ? frame.contentDocument : frame.window.document;
			}
			if(innerDoc != null) {
				innerDoc.location.href = loc;
			}
		}
	}
}


function getIframeDocument(iframename) {
	if(iframename != null && iframename != '') {
		var frame = ElementByID(iframename);
		if(frame != null) {
			var innerDoc = null;
			if (frame != null) {
				innerDoc = (frame.contentDocument) ? frame.contentDocument : frame.window.document;
			}
			return innerDoc;
		}
	}
	return null;
}

function getDocumentParentWindow(doc) {
	if(!doc && document) {doc = document;}
	var retwin = null;
	if (doc) {
		if (doc.defaultView) {
			retwin = doc.defaultView;
		} else if(doc.parentWindow) {
			retwin = doc.parentWindow;
		}
	}
	return retwin;
}

function getIframeOwnerDocument(actIframeWin) {
	if(!actIframeWin) { actIframeWin = window; }
	if(actIframeWin && actIframeWin.frameElement && actIframeWin.frameElement.ownerDocument) {
		return actIframeWin.frameElement.ownerDocument;
	} else { return null; }
}

function getIframeOwnerWindow(iframewin) {
	if(!iframewin) { iframewin = window; }
	var retwin = null;
	if(iframewin) {
		var doc = getIframeOwnerDocument(iframewin);
		if(doc) {
			retwin = getDocumentParentWindow(doc);
		}
	}
	return retwin;
}

function getPathPrefix() { // gibt protokoll//domain/ zurück, gut um absolute Pfade zu bauen ohne session-identifier
	var p = window.location.host;
	var prot = window.location.protocol;
	var ret = prot + '//' + p + '/';
	return ret;
}