$(function(){
	window.initRotator = function(){
		$("IMG.rotator").each(function(idx){
			var $nav = $("<DIV class='rotator'/>")
				.append(
					$("<DIV class='back'/>")
						.css({
							opacity: 0.5
						})
				)
				.append("<div class='text'>Bild <span id='gallery_currentImage'/>/<span id='gallery_imageCount'/></div>")
				
				.append(
					$("<DIV class='front'/>")
						.append(
							$("<img class='next' src='/imgs/frontend/arrows/bigWhiteRight.gif' width='10' height='19' />")
								.bind("click", function(){
									nextImage(1);
								})
						)
						.append(
							$("<img class='prev' src='/imgs/frontend/arrows/bigWhiteLeft.gif' width='10' height='19' />")
								.bind("click", function(){
									nextImage(-1);
								})
						)
				)
				.bind("mouseleave", function(ev){
					if($nav.data("related").not(ev.relatedTarget).size()>0){
						setTimeout(function(){
							$nav.stop().slideUp();
						}, 1);
					}
				})
				.hide()
				.appendTo("BODY")
			;
			

			var $t = $(this);
			var imgs = $t.data("images");
			var current = $t.data("current") || 0;
			var src = $t.attr("src").replace(imgs[current], "{0}");
			var showTimeout;
			var autoSlideInterval;

			if(imgs && imgs.length){
				$t.bind("load", function(){
					var $rel = $nav.data("related");
					if($rel!=null && $t.not($rel).size()===0){
						$("#gallery_currentImage", $nav).text(current+1);
						reposition();
					}
					
					var myi = setInterval(function(){
						var w = $t.width();
						if(w){
							clearInterval(myi);
							$t.css("width", w);
						}
					}, 20);
				}).bind("click", function(){
					nextImage(1);
				}).bind("mouseenter", function(ev){
					
					if($nav.is(":visible") && $t.not($nav.data("related")).size()===0) return;
					$nav.data("related", $t);
					$("#gallery_imageCount", $nav).text(imgs.length);
					$("#gallery_currentImage", $nav).text(current+1);
					
					var p = $t.position();
					showTimeout = setTimeout(function(){
						clearInterval(autoSlideInterval);
						$nav.stop().css({
							left: p.left,
							top: p.top,
							width: $t.width(),
							height: 40
						}).hide().slideDown();
					}, 200);
				}).bind("mouseleave", function(ev){
					clearTimeout(showTimeout);
					if($nav.is(":visible") && $nav.not($(ev.relatedTarget).closest("DIV.rotator")).size()>0){
						setTimeout(function(){
							$nav.stop().slideUp();
						}, 1);
					}
				});
				
				var autoSlide = $t.data("slide") || 0;
				if(autoSlide>0){
					autoSlideInterval = setInterval(function(){
						$t.trigger("click");
					}, autoSlide);
				}
			}
			
			function reposition(){
				setTimeout(function(){
					var p = $t.position();
					$nav.css({
						left: p.left,
						top: p.top,
						width: $t.width()
					});
				}, 10);
			}
			function nextImage(dir){
				current+=dir;
				if(current >= imgs.length){
					current = 0;
				}else if(current < 0) {
					current = imgs.length-1;
				}
				var curr = $t.attr("src");
				var nc = src.replace("{0}", imgs[current]);
				if(curr !== nc){
					$t.attr("src", nc);
				}else{
					$t.trigger("load");
				}
			}
		});
	};

	initRotator();
});

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(var 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){
	return $(o).closest("[selectable='true']").size()>0;
}


//*******************************************
// Hover-Funktion für alle
//*******************************************
function Hover(tagName, childrenFromObjOnly, ev){
	if(!ev) {
		ev = window.event;
	}
	var o;
	if (ev && ev.srcElement) {
		o = ev.srcElement;
	} else if(ev && ev.target) {
		o = ev.target;
	}else{
		return;
	}
	if(o!=null){
		$(o).closest(tagName)
			.filter(":not(.nohover)")
				.addClass("hover").mouseout(function(){
					$(this).removeClass("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;
	var src;
	if(ev.srcElement) {
		src = ev.srcElement;
	} else if(ev.target) {
		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) {
	var cf = "";
	try{
		if(win == null) win = window;
		if (name == null) name = "";
		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.");
	}
}

function MW_WindowName(path) {
	return path.replace(/[?.:;_\/\\+%#&-]/g, "");
}

/*****************************************************************
Ö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 = MW_WindowName(cf);
	}
	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!=null && 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 += p + ";";
	}
	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, hasScroll=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(!hasScroll) doProps += "scrollbars=no,";
	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_HiddenPostback2(action, additional, callbackFunction) {
	var frm = Form_GetDefaultForm(window);
	if (frm != null) {
		var d = $(frm).serializeArray();
		if (additional) {
			additional = $.map(additional, function (val, key) {
				return {
					name: key,
					value: val
				};
			});
			d = $.merge(d, additional);
		}
		$.ajax({
			cache: false,
			url: CorrectPath(action),
			type: "POST",
			data: d,
			dataType: "html",
			success: function (a) {
				$(frm).append($(a).filter("script:not([src])"));
				if (typeof callbackFunction === "function") {
					callbackFunction();
				}
			}
		});
	}
}

function Form_HiddenPostback(action, callbackFunction){
	var frm = Form_GetDefaultForm(window);
	if(frm != null && !frm.disableHidden){
		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){
			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) 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).trigger("click");
			//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: "script"
		}
	];
	*/
	
	//falls Optionen vorhanden sind, dann diese anzeigen
	var po = document.printOptions;
	if( option == null && po != null && po.length > 1 ){
		var d = document.printOptionSelector;
		if( d == null ){
			d = $('<table cellpadding="2" cellspacing="0" border="1" class="printOptions">')
				.css("height", (po.length * 20) + "px")
				.bind("mouseleave", function(){ $(this).hide(); })
				.bind("click", function(ev){
					if(!ev)ev=window.event;
					if(ev != null){
						var src;
						if(ev.srcElement) {
							src = ev.srcElement;
						} else {
							src = ev.target;
						}
						
						$(src).closest("TR").each(function(){
							$(this).closest("TABLE").hide();
							PrintPage(ev, $(this).data("printItem") );
						});
					}
				})
			;
			for( var i=0; i<po.length; i++ ){
				var poi = po[i];
				if( poi.caption != null ){
					d.append(
						$('<TR><TD nowrap="nowrap"></TD></TR>')
							.find("TD")
								.text(poi.caption)
							.end()
							.data("printItem", poi)
					);
				}
			}
			document.printOptionSelector = d;
			$("FORM", document).append( d );
		}
		
		if(!ev) ev = window.event;
		var sx=0, sy=0;
		if( ev != null ){
			var btn = $(ev.srcElement?ev.srcElement:ev.target).closest("div");
			if(btn.is(".globalPrint")){
				sx = btn.offset().left + $(document).scrollLeft();
				sy = $(document).scrollTop();
			}else{
				sx = ev.x - 5;
				sy = ev.y - 5;
			}
		}
		d.css({
			"left": sx + "px",
			"top": sy + "px"
		}).show();
		return;
		
	} else if(option != null || (po!=null && po.length == 1)) {
		if(option == null){
			option = po[0];
		}
		var action = option.action;
		
		if( action == null ){ //aktuelle Seite so drucken, wie sie ist (einfach window.print() aufrufen)
			window.print( );
		}else if(action=="script"){
			var scr=option.script;
			if(scr!=null) scr();
		} 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" );
		}
	} else {
		window.print( );
	}
	
}

/*****************************************************************
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 = [];
			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;
}

