
//alert("huhu");


/* Menu Functions */

//---------------------------------------------------------------------------------------
//-- Menu Functions ---------------------------------------------------------------------
//---------------------------------------------------------------------------------------

function Interface () {
	
	this.window = false;
	this.title = 'Local';
	this.phpos_ajax_url = '/ajax';
	
	this.init = function() {
		// quicksearch, submit on return
		/*if(qs = document.getElementById('quicksearch')) {
			this.quicksearchEL = document.getElementById('quicksearch');
			this.addEvent(qs,'keydown',this.quicki = function(event) {this.quicksearch(event);}.bind(this));
		}*/ // done with submit button
		
		//this.setFooter();
		//this.linkExternalLinks();
		
		//if(!this.window) this.buildWindow();
	}
	
	this.quicksearch = function(event) {
		if(event.keyCode != 13) return;
		this.do_search();
	}
	
	this.do_search = function() {
		document.location.href = '/suche/'+this.quicksearchEL.value;
	}
	
	this.donotinterruptsubmits = function() {
		this.coverbackground('visible',0.8);
		// get sid
		PA = new ProgressAnimation();
		PA.viewProgress(this.cover,false,'Bild wird geladen',false,0.5);
	}
	
	//---------------------------------------------------------------------------------------
	this.toggleDisplayAndClass = function(element,cn){
		var obj = document.getElementById(element);
		obj.style.display = obj.style.display == 'none' ? '' : 'none';
		$('tt'+element).hasClassName(cn) ? $('tt'+element).removeClassName(cn) : $('tt'+element).addClassName(cn);
	}
	//---------------------------------------------------------------------------------------
	this.adjustSize = function(r) {
		sizeUnit = "%";
		defaultSize = 100;
		maxSize = 160;
		minSize = 98;	
	}


	//---------------------------------------------------------------------------------------
	this.setFooter = function() {
		
		// wie kann ich das anders machen?
		// ohne javascript, wird man den footer nicht sehen, keine gute sache
		// damit kommt man nicht zum impressum
		if(!document.getElementById('footer')) return;
		ft = document.getElementById('footer');
		if(!document.getElementById('navteaserarea')) {
			ft.style.visibility = 'visible';
			return;
		}
		if(!PAGEdom) return;
		
		if(document.getElementById('navteaserarea')) {			
			nt = document.getElementById('navteaserarea'); // contains left subnav and navboxes
			var nt_dp = PAGEdom.toDocumentPosition(nt); // get document position of navteaserarea
		} else if(document.getElementById('content')) {
			nt = document.getElementById('content'); // contains left subnav and navboxes
			var nt_dp = PAGEdom.toDocumentPosition(nt); // get document position of navteaserarea		
		}
		//DebugDump(nt_dp,'nt_dp.y '+nt_dp.y);
		//DebugDump(scrollTop,'scrollTop '+scrollTop);
		var wHeight = PAGEdom.getWindowHeight();
		var pHeight = document.body.offsetHeight; // Safari needs body.offsetHeight //PAGEdom.getPageHeight();
		//DebugDump(wHeight,'wHeight '+wHeight);
		//DebugDump(pHeight,'pHeight '+pHeight);
		if(pHeight
		&& wHeight
		&& pHeight < wHeight) {
			nt.style.height = (wHeight-ft.offsetHeight-nt_dp.y)+'px'; // window.height - footer - navteaser position
			//DebugDump(nt.style.height,'nt.style.height '+nt.style.height);
		} else { // hmm, weiss nich, wieso das vorher funktioniert hat und jetzt nimmer
			nt.style.height = (wHeight-ft.offsetHeight-nt_dp.y)+'px'; // window.height - footer - navteaser position
			//DebugDump(nt.style.height,'nt.style.height '+nt.style.height);		
		}
		
		//ft.style.visibility = 'visible';
		op = 1;
		ft.style.opacity = op; // set opacity for effect : filter:alpha(opacity=50); -moz-opacity:0.5; opacity:0.5; 
		ft.style.filter = "alpha(opacity:"+Math.round(op*100)+")";
		//var pHeight = PAGEdom.getPageHeight();
		//DebugDump(pHeight,'pHeight '+pHeight);
	}

	//---------------------------------------------------------------------------------------
	this.showMyNav = function(lgel) {
		var mainmenu = $$('div.hauptmenue');
		var ofmain = mainmenu[0].cumulativeOffset();
		var lgnavEl = document.getElementById('lgnav');
		var of = $(lgel).cumulativeOffset();
		if(lgnavEl.style.display == 'none') {
			if(of && of.left > 0) {
				lgnavEl.style.left = (of['left']-ofmain['left'])+'px';
				lgnavEl.style.top = (of['top']+$(lgel).offsetHeight) + 'px';
			}
			//lgnavEl.style.display = '';
			new Effect.Appear(lgnavEl,{duration:0.3});
			//new Effect.SlideDown(lgnavEl,{duration:0.3});
			this.addEvent(document,'mousedown',this.autohidenav = function(event) {this.hideNav(event);}.bind(this));
		} 
	}

	this.hideNav = function(event) {
		
		var el;
		el = this.gettarget(event);
		
		var lgnavEl = document.getElementById('lgnav');
		if (el == lgnavEl) return;

		if (PAGEdom.getContainer(el, lgnavEl) == null) { //(PAGEdom.getContainerByTagAndClass(el, "DIV", "lgnav") == null)
			//lgnavEl.style.display = 'none';
			new Effect.SwitchOff(lgnavEl,{duration:0.3});
			//new Effect.SlideUp(lgnavEl,{duration:0.3});
			this.removeEvent(document,'mousedown',this.autohidenav);
		}
	}
	
	//---------------------------------------------------------------------------------------

	//---------------------------------------------------------------------------------------
	this.loginOperation = function(operation) {
		//alert();
		document.forms['login'].operation.value = operation;
		document.forms['login'].onsubmit(); // workaround browser bugs.
		document.forms['login'].submit();
	}
	//---------------------------------------------------------------------------------------
	this.toggleMode = function() {
		if(mode) mode_value = mode;
		else if (document.getElementById('list_rdbms')) mode_value = "admin";
		else mode_value = "browse";
		//mode_el = document.getElementById("mymode");
		switch (mode_value) {
			case"admin":
				document.getElementById("mymode").value = 'browse';
				//mode_value = document.getElementById("mymode").value;
				break;
			case"browse":
				document.getElementById("mymode").value = 'admin';
				//mode_value = document.getElementById("mymode").value;
				break;			
		}
		//alert(document.getElementById("mymode").value);
		document.forms['login'].submit();
	}
	
	//---------------------------------------------------------------------------------------

	this.linkExternalLinks = function() {
		if(is_phpos_environment) return;
		//return;
		 var links = document.getElementsByTagName('A');
		 for (var i=0; i<links.length; i++) { 
		  // var anchor = anchors[i]; 
		  var v = links[i].getAttribute("href");
		  var c = links[i].getAttribute("onclick");
		  
		   if (!c
		   && v
		   && v.indexOf('http') != -1) {
			 //DebugDump(c,'external link found');
			 //DebugDump(v,'external link found');
			 //this.addEvent(document,'click',function() {return false;}.bind(this));
			 links[i].setAttribute('target',"_blank");
			}
			
			 
		 } 

		/*links = document.getElementsByTagName('A');
		for(i=0;i<links.length;i++) {
			var atts = links[i].attributes;//getAttribute('href');
			DebugDump(atts,'external link found');
			for(p=0;p<atts.length;p++) {
				DebugDump(atts[p],''+p);
			}		
		}*/
	}

	this.jumpToExternalLink = function(myUrl,myName,hitId,hitName) {
	
		var jumpPage = "/link/external";
		var path = myUrl;
		jumpPage = jumpPage+"?path="+path;
		if ((hitName && hitName.length > 0) && (hitName && hitName.length >0)) jumpPage = jumpPage+"&object_id="+hitId+"&object_name="+hitName;
		mywin = window.open(jumpPage,myName);
		mywin.focus();
		
	}

	// browser
	//---------------------------------------------------------------------------------------
	this.browserSubmit = function(v,i,eidb) {
		//alert('huhu'); return;
		document.getElementById(i).value = v;
		document.forms['contentform'].onsubmit(); // workaround browser bugs.
		document.forms['contentform'].submit();
	}

	this.messageSubmit = function(v,i,eidb) {
		//alert('huhu'); return;
		document.getElementById(i).value = v;
		document.forms['messageform'].onsubmit(); // workaround browser bugs.
		document.forms['messageform'].submit();
	}

	this.setDirPath = function(id,order_dir,eidb) {
		document.getElementById(eidb+'order').value = id;
		this.browserSubmit(order_dir,eidb+'order_dir');
	} 
		
	this.changeDirPath = function(id,order_dir,eidb) {
		img_path = '/images_admin/embedded_browser/';
		document.getElementById(eidb+'order').value = id;
		switch(order_dir) {
			case"desc":
				document.getElementById(id+'_order_dir_dot').src = img_path+"asc_blue_dot.gif";
				order_change = 'asc';
			break;
			case"asc":
				document.getElementById(id+'_order_dir_dot').src = img_path+"desc_blue_dot.gif";
				order_change = 'desc';
			break;	
		}	
		this.browserSubmit(order_change,eidb+'order_dir');
	} 
	
	// submit
	this.justSubmit = function(formname) {
		document.forms[formname].onsubmit(); // workaround browser bugs.
		document.forms[formname].submit();	
	}

	// submit
	this.setHiddenAndSubmit = function(hidden_value,hidden_id,formname) {
		document.getElementById(hidden_id).value = hidden_value;
		//alert(document.forms[formname]['triggers'].value)
		document.forms[formname].onsubmit(); // workaround browser bugs.
		document.forms[formname].submit();
	}

	//---------------------------------------------------------------------------------------
	//---------------------------------------------------------------------------------------
	this.magnify = function(m) {
		var mtop, st, ww;
/*
.menuitemGNW {
	position: absolute;
	visibility: hidden;
}

.fllGN {
	background-image: url(/images_admin/icons/kr_hl.png);
	background-repeat: no-repeat;
	background-position: left top;
	width: 36px; 
	height:72px; 
	float:left;
}

.fllGNib {
	background-image: url(/images_admin/icons/kr_hr.png);
	background-repeat: no-repeat;
	background-position: right top;	
	height:72px; 
	width: 36px;
	float:left;
}

.fllGNCT {
	float:left;
	background-color: #000;
	margin: 1px 0 0 0;
	he

*/		
		st = PAGEdom.docScrollTop();
		mtop = (st+160)+'px';
		ww = GetWindowWidth();
		this.mag = document.createElement('div');
		this.mag.style.position = 'absolute';
		this.mag.style.zIndex = 20;
		this.mag.style.left = 60+'px';
		this.mag.style.top = mtop;		
		this.mag.style.width = (ww-120)+'px';	
		this.mag.style.textAlign = 'center';
		//this.mag.style.height = '180px';
		this.mag.style.padding = '1px';
		this.mag.style.fontWeight = 'bold';
		//this.mag.style.fontSize = '400%';
		this.mag.style.fontSize = '60px';
		this.mag.style.lineHeight = '60px';
		this.mag.style.color = '#fff';
		//this.mag.style.border = '1px solid red';
		
		this.mag.innerHTML = m;
		document.getElementsByTagName('body')[0].appendChild(this.mag);
		
		this.mag_bg = document.createElement('div');
		this.mag_bg.style.position = 'absolute';
		this.mag_bg.style.zIndex = 19;
		this.mag_bg.style.left = 60+'px';
		this.mag_bg.style.top = mtop;		
		this.mag_bg.style.width = (this.mag.offsetWidth)+'px';//(ww-60)+'px';
		this.mag_bg.style.height = this.mag.offsetHeight+'px';//'200px';
		
		op = 0.1;
		this.mag_bg.style.opacity = op; // set opacity for effect : filter:alpha(opacity=50); -moz-opacity:0.5; opacity:0.5; 
		this.mag_bg.style.filter = "alpha(opacity:"+Math.round(op*100)+")";
		
		
		rk = document.createElement('div');
		rk.className = 'fllGN';
		this.mag_bg.appendChild(rk);
		
		ct = document.createElement('div');
		ct.style.width = (this.mag.offsetWidth - 72)+'px';
		ct.className = 'fllGNCT';
		this.mag_bg.appendChild(ct);	
		
		lk = document.createElement('div');
		lk.className = 'fllGNib';
		this.mag_bg.appendChild(lk);		
		
		document.getElementsByTagName('body')[0].appendChild(this.mag_bg);
		
		new Effect.Opacity(this.mag_bg, {duration:0.3, from:0.1, to:0.7});
		
		//new Effect.Appear(this.mag_bg,{duration:0.5});
		//new Effect.Appear(this.mag,{duration:0.5});
		//new Effect.SlideDown(menuitems[i],{duration:0.8});
		//new Effect.BlindDown(menuitems[i],{duration:0.8});
		//new Effect.Grow(menuitems[i],{duration:0.8});		

		//this.mag.style.backgroundColor = '#ffffff';
		this.addEvent(document,'mousedown',this.hideme = function(event) {this.hideMagnifier(event);}.bind(this));
	}
	//---------------------------------------------------------------------------------------
	this.hideMagnifier = function(event) {
	
		var el;
		el = this.gettarget(event);
		
		// If the active button was clicked on, exit.
		if (el == this.mag) return;
		if (el == this.mag_bg) return;
	
		// If the element is not part of a menu, reset and clear the active
		// button.
		
		PAGEdom.removeNode(this.mag);
		mag_bg = this.mag_bg;
		new Effect.Opacity(this.mag_bg, {duration:0.3, from:0.7, to:0,afterFinish: this.sau_Effect_rmNode});
		//new Effect.Puff(this.mag_bg, {duration:0.5,afterFinish: rmNode});
		//PAGEdom.removeNode(this.mag_bg);
	}	
	
	this.sau_Effect_rmNode = function(obj) {
		PAGEdom.removeNode(obj.element);
	}
	//---------------------------------------------------------------------------------------
	this.coverbackground = function(vs,op) {
		
		if(!op) op = 0;
		
		if(!this.cover) {
			this.cover = document.createElement('div');
			this.cover.style.position = 'absolute';
			this.cover.style.zIndex = 5;
			this.cover.style.left = 0+'px';
			this.cover.style.top = 0+'px';
			this.cover.style.opacity = op; // set opacity for effect : filter:alpha(opacity=50); -moz-opacity:0.5; opacity:0.5; 
			this.cover.style.filter = "alpha(opacity:"+Math.round(op*100)+")";
			this.cover.style.backgroundColor = "#fff";
			document.getElementsByTagName('body')[0].appendChild(this.cover);
		}
		
		if(!vs) {
			this.cover.style.visibility = 'hidden';
		} else {
			ww = GetWindowWidth();
			wh = GetWindowHeight();
			st = PAGEdom.docScrollTop();
			bodyheight = st+wh;
			bodyheight = document.body.offsetHeight;
			this.cover.style.width = (ww-15)+'px';
			this.cover.style.height = ((bodyheight-15))+'px';
			this.cover.style.visibility =  'visible';			
		}
	}
	
	this.hideFlash = function() {
		var players = document.getElementsByTagName('span');
		for(pdx=0;pdx<players.length;pdx++) {
			if(players[pdx].className == 'swfplayer') players[pdx].style.visibility = 'hidden';
		}
	}

	this.showFlash = function() {
		var players = document.getElementsByTagName('span');
		for(pdx=0;pdx<players.length;pdx++) {
			if(players[pdx].className == 'swfplayer') players[pdx].style.visibility = '';
		}
	}
	
	//---------------------------------------------------------------------------------------
	this.setField = function(sourcefield_id,targetfield_id,value,disable) {

		sourcefield = $(sourcefield_id);
		targetfield = $(targetfield_id);
		//DebugDump(sourcefield.value,'sourcefield.value');
		if(targetfield.value != value) {
			targetfield.value = value;
		}
	
	}
	//---------------------------------------------------------------------------------------
	this.printDonation = function(printform) {
		
		
		var firstformEL = false;
	//if (!def_printversion_available) return alert('Es ist keine Druckansicht f\u00FCr diese Seite verf\u00FCgbar...');
		var contentEL = document.getElementById('content');
		var contentforms = contentEL.getElementsByTagName('FORM');
		for (var i=0; i<contentforms.length; i++) { 
			if(contentforms[i]) { firstformEL = contentforms[i]; break; }
		}	
		
		if(firstformEL) {
			//var o_target = firstformEL.target;
			var o_action = firstformEL.action;
			//firstformEL.target = printform;
			firstformEL.action = printform;
		}
		this.printVersion();
		//window.print();
		if(firstformEL) {
			//firstformEL.target = o_target;
			firstformEL.action = o_action;	
		}
	}

	this.printVersion = function() {
		var firstformEL = false;
	//if (!def_printversion_available) return alert('Es ist keine Druckansicht f\u00FCr diese Seite verf\u00FCgbar...');
		var contentEL = document.getElementById('content');
		var contentforms = contentEL.getElementsByTagName('FORM');
		for (var i=0; i<contentforms.length; i++) { 
			if(contentforms[i]) { firstformEL = contentforms[i]; break; }
		}
		//firstformEL.submit();
		//alert(firstformEL.name);
		if(firstformEL) var Ppath = firstformEL.action;//parent.content.myPlainPagePath;
		else var Ppath = parent.content.myPlainPagePath;
		
		var Pname = "PrintVersion";
		var no_w = '/none';
		var no_w = checkUrl(no_w);
		var WHeight = GetWindowHeight()-100;
		mywin = window.open(no_w,Pname,"top=20,left=30,width=540,height="+WHeight+",scroll=yes,scrollbars=yes,titlebar=no,status=no,toolbar=no,location=no,directories=no,menubar=yes,resizable=yes");
		
		Ppath = Ppath+"?print=true";
		var Ppath = checkUrl(Ppath);		
		//spendenformulardrucken
		if(firstformEL) {
			
			var o_target = firstformEL.target;
			var o_action = firstformEL.action;
			//alert(o_target);
			firstformEL.target = Pname;
			firstformEL.action = Ppath;
			firstformEL.onsubmit(); // workaround browser bugs.
			firstformEL.submit();
			firstformEL.target = o_target;
			firstformEL.action = o_action;			
		} else {
			mywin.location.href =createUrl(Ppath);
		}
		
		
		
		/*if (document.forms[formname]) { // this part will be true from now on
			var createdTempHidden = false;
			if (document.createElement) {
				switch (SmartAgent){
					case "Netscape6":
					case "MSIE5.5":
					case "Opera5":
					case "Khtml":
						try {
							var tempFormObj;
							var tempHiddenObj;
							tempFormObj = parent.content.document.forms[0];
							var tempHidden = 	parent.content.document.createElement('input');
							tempHidden.setAttribute('type','hidden');
							tempHidden.setAttribute('name','print');
							tempHidden.setAttribute('value','true');
							tempHiddenObj = tempFormObj.appendChild(tempHidden);
							var createdTempHidden = true;
						} catch(e) {
							Ppath = Ppath+"?print=true";
						}
						break;
				case "Netscape4":
				case "MSIE5":
				default:
					var Ppath = Ppath+"?print=true";
					var Ppath = createUrl(Ppath);
					break;
				}
			} else {
				var Ppath = Ppath+"?print=true";
				var Ppath = createUrl(Ppath);
			}
			setActionAndSubmit(Pname,Ppath,'parent.content.document.forms[0]');
			if (createdTempHidden) tempFormObj.removeChild(tempHidden);
		} else {
			var Ppath = Ppath+"?print=true"; 
			mywin.location.href =createUrl(Ppath);
		}
		*/
		
		if(mywin) mywin.focus();
	}

	//---------------------------------------------------------------------------------------
	this.buildWindow = function() {
		
		// window
		//bodyroot = document.getElementsByTagName('form')[0];
		if(!document.getElementById('content')) return;
		bodyroot = document.getElementById('content');
		this.w_wrapper = document.createElement("div");	
		

		this.w_wrapper.id = 'window';
		this.w_wrapper.className = 'window';
		this.w_wrapper.style.position = 'absolute';
		//this.w_wrapper.style.display = 'none';
		this.w_wrapper.style.visibility = 'hidden';
		this.w_wrapper.width = 300;
		this.w_wrapper.height = 300;
		this.w_wrapper.style.width = this.w_wrapper.width+'px';
		this.w_wrapper.style.height = this.w_wrapper.height+'px';
		this.w_wrapper.style.overflow = 'auto';
		//this.w_wrapper.style.border = '1px solid black';
		//this.w_wrapper.style.backgroundColor = 'white';
		//this.w_wrapper.style.zIndex = 100000;
		WWidth = GetWindowWidth();
		WHeight = GetWindowHeight();
		dst = PAGEdom.docScrollTop();
		var topheight = (((WHeight+dst)/2)-(this.w_wrapper.height/2));
		if(topheight<133) topheight = 133;
		this.w_wrapper.style.top = topheight+'px';
		var leftwidth = ((WWidth/2)-(this.w_wrapper.width/2));
		if(leftwidth<250) leftwidth = 250;
		this.w_wrapper.style.left = leftwidth+'px';
		bodyroot.appendChild(this.w_wrapper);

		this.makeNewWndow();
				
	}
	
	this.makeNewWndow = function() {
		this.window = new ContentWindow(this.title,this.w_wrapper.id);
		this.window.client_area_id = 'windowclientarea';
		this.window.title_id = 'windowtitlearea';
		this.window.init(this.window);	
	}
	
	//---------------------------------------------------------------------------------------
	this.gettarget = function(event) {

		if(window
		&& (window.event)
		&& (window.event.srcElement)) {
			t = window.event.srcElement;
		} else {
			t = (event.target.tagName ? event.target : event.target.parentNode);
		}
		return t;
	}	
	

	//---------------------------------------------------------------------------------------
	this.addEvent = function(el,evname,func) {
	
		if (el.attachEvent) { // IE
			el.attachEvent("on" + evname, func);
		} else if (el.addEventListener) { // Gecko / W3C
			el.addEventListener(evname, func, true);
		} else {
			el["on" + evname] = func;
		}
	
	}
	
	//---------------------------------------------------------------------------------------
	this.removeEvent = function(el,evname,func) {
	
		if (el.detachEvent) { // IE
			el.detachEvent("on" + evname, func);
		} else if (el.removeEventListener) { // Gecko / W3C
			el.removeEventListener(evname, func, true);
		} else {
			el["on" + evname] = null;
		}
	}

	this.getAllFields = function(el) {
		
		fields = new Array();
		fidx = 0;
		
		// fields[fields[root.ajaxbody.editor][sid]]=
		// fields[root.editor][shortcut]
		
		//URLEncode(field.value);
		
		var inputs = el.getElementsByTagName('INPUT');
		for (var i=0; i<inputs.length; i++) { 
			switch(inputs[i].type) {
				case'checkbox':
					//DebugDump(inputs[i].checked,inputs[i].type);
					if(!inputs[i].checked) continue; 
					break;
				case'radio':
					if(!inputs[i].checked) continue; 
					break;
			}
			
			if(inputs[i].value.indexOf('CustomConfigurationsPath') >= 0) continue;
			//fields[fidx] = inputs[i].name+'='+escape(inputs[i].value);
			fields[fidx] = inputs[i].name+'='+URLEncode(inputs[i].value);
			fidx++;		
		}

		var selects = el.getElementsByTagName('SELECT');
		for (var i=0; i<selects.length; i++) { 
			//fields[inputs[i].name] = 'fields['+inputs[i].name+']='+escape(inputs[i].value);
			//fields[fidx] = selects[i].name+'='+escape(selects[i].value);
			fields[fidx] = selects[i].name+'='+URLEncode(selects[i].value);
			fidx++;		
		}

		var textareas = el.getElementsByTagName('TEXTAREA');
		for (var i=0; i<textareas.length; i++) {
			if(textareas[i].value.indexOf('CustomConfigurationsPath') >= 0) continue;
			// fields_root_ajaxbody_editor_abstract___Frame
			if(document.getElementById(textareas[i].id+'___Frame')) {
				textareas[i].value = FCKEditor_GetInnerHTML(textareas[i].id);
			}
			//fields[fidx] = textareas[i].name+'='+escape(textareas[i].value);
			fields[fidx] = textareas[i].name+'='+URLEncode(textareas[i].value);
			fidx++;		
		}

		var niframes = el.getElementsByTagName('IFRAME');
		for (var i=0; i<niframes.length; i++) { 
			//DebugDump(niframes[i],'iframe? '+niframes[i].id);	
		}
		
		return fields;
	}	
}


IF = new Interface(); 
OnLoadFunctions[OnLoadFunctions.length] = "IF.init();";
var reg = 'phpos'; 
var is_phpos_environment = document.location.href.match(reg);
//OnLoadFunctions[OnLoadFunctions.length] = "DebugDump(found,'found');";
if(!is_phpos_environment) {
	browserSubmit = IF.browserSubmit;
	setDirPath = IF.setDirPath;
	changeDirPath = IF.changeDirPath;
}
//OnLoadFunctions[OnLoadFunctions.length] = "browserSubmit();";
//---------------------------------------------------------------------------------------
function checkSubmit() { // weiss nich, ob ich das brauche... ist der onsubmit gerade
	return true;
}

//---------------------------------------------------------------------------------------
function quicksearch(event) {
	if(event.keyCode != 13) return;
	IFdo_search();
}
//---------------------------------------------------------------------------------------
function IFdo_search() {

	setHidden('search','triggers');
	setActionAndSubmit('/suche','_self');
}



//---------------------------------------------------------------------------------------
//-- Size Functions -------------------------------------------------------------------
//---------------------------------------------------------------------------------------

function AdjustFontSize() {

	this.sizeUnit = "%";
	this.defaultSize = 100;
	this.maxSize = 125; // Windows 125! / Mac 145
	this.minSize = 90;

	this.init = function() {
		CFS = new CookieManager('fontSize');
		if ( !document.body || !document.getElementById ) return;
		var size = window.location.search? window.location.search.slice(1): CFS.getValue("fontSize");
		size = !isNaN( parseFloat(size) )? parseFloat(size): this.defaultSize;
		// in case default unit changed or size passed in url out of range
		if ( size > this.maxSize || size < this.minSize ) size = this.defaultSize;
		document.body.style.fontSize = size + this.sizeUnit;
	}
  
	this.adjust = function(inc) {
		var size = parseFloat( document.body.style.fontSize );
		/* !!!!! Änderung  Anfang !!!! */
		size = !isNaN( parseFloat(size) )? parseFloat(size): this.defaultSize;
		/* !!!!! Änderung Ende  !!!! */
		size += inc;
		// Test against max and min sizes 
		if (inc > 0) size = Math.min(size, this.maxSize);
		else size = Math.max(size, this.minSize);
		CFS.save( "fontSize", size, 180, "/" );
		document.body.style.fontSize = size + this.sizeUnit;
	}

	this.reset = function() {
		document.body.style.fontSize = this.defaultSize + this.sizeUnit;
		CFS.del("fontSize", "/");
	}
}

function BlogMessage () {
	
	this.request_url = '/php-os/app_local/scripts/request_message.php';
	this.delete_url = '/php-os/app_local/scripts/delete_message.php';
	this.sid = false;
	this.fieldidprefix = 'fields_root_messageswrapper_newblogmessage_';
	
	this.init = function() {
	
	}
	
	//---------------------------------------------------------------------------------------
	this.answer = function(sid) {
		
		this.postdata = 'sid='+sid;
		this.postdata += '&oncomplete=BS.gotoAnswer';
		//newmessageanc
		
		//fieldset: newmessagefs

		blAjax = new ajax();
		blAjax.initialize(this.request_url, {method:'post',postBody:this.postdata, onComplete: this.getResponse}); // update: $('testrequest'),
		
	}
	
	this.gotoAnswer = function(node) {

		messagefield = node.getElementsByTagName("message");
		this.messageAttr = PHPOSContent.parseAttributes(messagefield[0]);
		
		transfield = node.getElementsByTagName("translations");
		this.transAttr = PHPOSContent.parseAttributes(transfield[0]);
		
		document.getElementById(this.fieldidprefix+'parent_sid').value = this.messageAttr['sid'];
		document.getElementById(this.fieldidprefix+'subject').value = this.transAttr['reply']+this.messageAttr['subject'];
		window.location.href  = '#newmessageanc';
	}

	//---------------------------------------------------------------------------------------
	this.quote = function(sid) {
		this.postdata = 'sid='+sid;
		this.postdata += '&oncomplete=BS.gotoQuote';

		blAjax = new ajax();
		blAjax.initialize(this.request_url, {method:'post',postBody:this.postdata, onComplete: this.getResponse}); // update: $('testrequest'),
		
	}
	
	this.gotoQuote = function(node) {

		messagefield = node.getElementsByTagName("message");
		this.messageAttr = PHPOSContent.parseAttributes(messagefield[0]);
		
		transfield = node.getElementsByTagName("translations");
		this.transAttr = PHPOSContent.parseAttributes(transfield[0]);
		
		document.getElementById(this.fieldidprefix+'parent_sid').value = this.messageAttr['sid'];
		document.getElementById(this.fieldidprefix+'subject').value = this.transAttr['reply']+this.messageAttr['subject'];
		if(messagefield[0]
		&& messagefield[0].firstChild
		&& messagefield[0].firstChild.data) {
			this.messageAttr['body'] = messagefield[0].firstChild.data;
		} else this.messageAttr['body'] = '';
		
		document.getElementById(this.fieldidprefix+'body').value = '[quote='+this.messageAttr['author']+']'+"\n"+this.messageAttr['body']+"\n[/quote]\n";
		window.location.href  = '#newmessageanc';
		
		//this.overwriteFields(node);
	}
	//---------------------------------------------------------------------------------------

	//---------------------------------------------------------------------------------------
/*	this.edit = function(sid) {
		this.postdata = 'sid='+sid;
		this.postdata += '&oncomplete=BS.gotoQuote';

		blAjax = new ajax();
		blAjax.initialize(this.request_url, {method:'post',postBody:this.postdata, onComplete: this.getResponse}); // update: $('testrequest'),
		
	}
	
	this.editQuote = function(node) {

		messagefield = node.getElementsByTagName("message");
		this.messageAttr = PHPOSContent.parseAttributes(messagefield[0]);
		
		transfield = node.getElementsByTagName("translations");
		this.transAttr = PHPOSContent.parseAttributes(transfield[0]);
		
		document.getElementById(this.fieldidprefix+'parent_sid').value = this.messageAttr['sid'];
		document.getElementById(this.fieldidprefix+'subject').value = this.transAttr['reply']+this.messageAttr['subject'];
		if(messagefield[0]
		&& messagefield[0].firstChild
		&& messagefield[0].firstChild.data) {
			this.messageAttr['body'] = messagefield[0].firstChild.data;
		} else this.messageAttr['body'] = '';
		
		document.getElementById(this.fieldidprefix+'body').value = '[quote='+this.messageAttr['author']+']'+"\n"+this.messageAttr['body']+"\n[/quote]\n";
		window.location.href  = '#newmessageanc';
	}*/
	
	//---------------------------------------------------------------------------------------
	this.overwriteFields = function(node,omit) {
		
		if(!omit) omit = new Array();
		fields = node.getElementsByTagName("fields");
		childs = fields[0].childNodes;
		
		for(idx=0;idx<childs.length;idx++) {
			
			
			if(childs[idx].nodeType == 1) {
				DebugDump(childs[idx],childs[idx].nodeName + ' / '+ childs[idx].tagName+' / '+childs[idx].nodeType);
			}
			
		}
		
		/*
		
		idx = 0;
		while(fields[0].childNodes) {
			
			DebugDump(fields[0].childNodes[idx].nodeName, fields[0].childNodes[idx].nodeName);
			idx++;
		}*/
		
	}
	
	//---------------------------------------------------------------------------------------
	
	this.deletemessage = function(sid,confirmmessage) {
		
		if (confirm(confirmmessage)) {
			PAGEdom.removeNode(document.getElementById('commment'+sid)); 	
			this.postdata = 'sid='+sid;
			blAjax = new ajax();
			blAjax.initialize(this.delete_url, {method:'post',postBody:this.postdata}); // update: $('testrequest'),
			
			if($('blogmessagecount')) {
				var num_messages = parseInt($('blogmessagecount').innerHTML);
				$('blogmessagecount').innerHTML = num_messages -1;
			}
			
		} else return false;
	}
	
	
	//---------------------------------------------------------------------------------------
	// just a container for AJAX Response and call to Respond()
	this.getResponse = function(request) {
		PHPOSContent = new Respond(request.responseXML);
		PHPOSContent.interpretResponse();
		//DebugDump(request.responseXML,'request.responseXML');
	}	
	//---------------------------------------------------------------------------------------
	this.gettarget = function(event) {

		if(window
		&& (window.event)
		&& (window.event.srcElement)) {
			t = window.event.srcElement;
		} else {
			t = (event.target.tagName ? event.target : event.target.parentNode);
		}
		return t;
	}	
	

	//---------------------------------------------------------------------------------------
	this.addEvent = function(el,evname,func) {
	
		if (el.attachEvent) { // IE
			el.attachEvent("on" + evname, func);
		} else if (el.addEventListener) { // Gecko / W3C
			el.addEventListener(evname, func, true);
		} else {
			el["on" + evname] = func;
		}
	
	}
	
	//---------------------------------------------------------------------------------------
	this.removeEvent = function(el,evname,func) {
	
		if (el.detachEvent) { // IE
			el.detachEvent("on" + evname, func);
		} else if (el.removeEventListener) { // Gecko / W3C
			el.removeEventListener(evname, func, true);
		} else {
			el["on" + evname] = null;
		}
	
	}	
}

BS = new BlogMessage();


function TicketOrder() {
	
	this.dataUrl 		= '/ajax'; // XML-Page
	this.getUrl = '/php-os/app_local/scripts/ajax_get_ordereditor.php';
	this.saveUrl = '/php-os/app_local/scripts/ajax_save_order.php';
	JRESPONSE = new Respond();
	this.cache = new Array();
	this.mode = 'editor'; 
	this.is_initialized = false;
	
	//---------------------------------------------------------------------------------------
	this.init = function() {
		
		Ajax.Responders.register({
		  onCreate: function(){
			Ajax.activeRequestCount++;
		  }, 
		  onComplete: function(){
			Ajax.activeRequestCount--;
			if(Ajax.activeRequestCount == 0) {
				if($('loader')) $('loader').style.visibility = 'hidden';
				if(!AB.is_initialized) {
					AB.is_initialized = true;
				} 			
			}
		  }
		});			
		
	}
	
	//---------------------------------------------------------------------------------------
	this.order = function() {
		
		var context = 'order';
		if(!mode) mode = this.mode;
		var pb = 'c='+context+'&sid='+this.sid+'&mode='+mode;
		this.mode = mode;
		
		// check fields
		fields = IF.getAllFields($('kartenbestellung'));
		pb += '&'+fields.join("&");
		//DebugDump(fields,'fields');
		var error = false; var estr = '';
		
		var mode = $('order_mode').value;
		switch(mode) {
			case'workshop':

				if($('order_familyname').value.length == 0) {
					error = true;
					estr += '- Name'+"\n";
				}
				if($('order_phone').value.length == 0) {
					error = true;
					estr += '- Telefon'+"\n";
				}
		
				if($('order_email').value.length == 0) {
					error = true;
					estr += '- E-Mail'+"\n";
				} /*else {
					var emailok = validateEmail($('order_email').value);
					if(!emailok) {
						error = true;
						estr += '- E-Mail (ung\u00FCltig)'+"\n";			
					}		
				}*/
	
				break;
			default:
				/*if($('order_seats') && $('order_seats').value.length == 0) {
					error = true;
					estr += '- Anzahl'+"\n";
				}*/
				if($('order_familyname').value.length == 0) {
					error = true;
					estr += '- Name'+"\n";
				}
				if($('order_phone').value.length == 0) {
					error = true;
					estr += '- Telefon'+"\n";
				}
		
				if((($('emailkopie')) && ($('emailkopie').value.length > 0 || $('emailkopie').value.length > 0))
				&& $('order_email').value.length == 0) {
					error = true;
					estr += '- E-Mail'+"\n";
				} 
		}
		
		
		if(error) {
			//new Effect.Shake($('kartenbestellung'),3);
			//setTimeout(function(){alert('Fehler! Bitte f\u00FCllen Sie die folgenden Felder aus:'+"\n"+estr);}.bind(this), 500);
			alert('Fehler! Bitte f\u00FCllen Sie die folgenden Felder aus:'+"\n"+estr);
			return;
		}
		
		if($('loader')) $('loader').style.visibility = 'visible';
		new Ajax.Request(this.saveUrl, {
		  method: 'post',
		  postBody: pb,
		  onSuccess: function(transport) {
		  	 TO.showOrder(transport.responseXML);
		  }
		});	
		
		//$('kartenbestellung').innerHTML = 
	}
	
	this.showOrder = function(node) {
		
		response = node.getElementsByTagName("response")[0];
		var atts = JRESPONSE.parseAttributes(response);
		
		// error!
		if(atts
		&& atts['error']
		&& atts['error'].length > 0) {
			alert(atts['error']);
		} else {
			editorcontent = response.getElementsByTagName("field")[0];		
			this.mag.innerHTML = editorcontent.firstChild.data;				
			//this.hideMagnifier(null,true);
		}
		
		// success!
		
	}

	//---------------------------------------------------------------------------------------
	this.openviewer = function() {
	
		this.coverbackground(true,0.8);
		//this.mag.style.backgroundColor = '#ffffff';
		//this.addEvent(document,'mousedown',this.hideme = function(event) {this.hideMagnifier(event);}.bind(this));
		this.addEvent(window,'resize',this.resizer = function(event) {this.coverbackground(true,0.8);}.bind(this));
	}

	this.getEditor = function(sid,mode) {
		
		if(!this.is_initialized) this.init();
		this.openviewer();
		this.sid = sid;
		
		var context = 'event';
		if(!mode) mode = this.mode;
		var pb = 'c='+context+'&sid='+sid+'&mode='+mode;
		this.mode = mode;
		
		if($('loader')) $('loader').style.visibility = 'visible';
		new Ajax.Request(this.getUrl, {
		  method: 'post',
		  postBody: pb,
		  onSuccess: function(transport) {
		  	
		  	 TO.showRecord(transport.responseXML);
		  }
		});		
	}
	
	this.showRecord = function(node) {		
		response = node.getElementsByTagName("response")[0];
		this.atts = JRESPONSE.parseAttributes(response);
		//DebugDump(atts,'atts');
		editorcontent = response.getElementsByTagName("field")[0];		
		this.mag.innerHTML = editorcontent.firstChild.data;		
		if($('kartenbestellung').style.display == 'none') {
			//new Effect.Appear($('kartenbestellung'),{duration:0.3});
			new Effect.BlindDown($('kartenbestellung'),{duration:0.3,
			afterFinish: function() {
				if($('order_seats')) $('order_seats').focus();
			}});
			//new Effect.Grow($('kartenbestellung'),{duration:0.3});
		} else if($('order_seats')) $('order_seats').focus();
		
		var recordsfields = response.getElementsByTagName("field");
		flattendata = new Array();
		for(sidx=0;sidx<recordsfields.length;sidx++) {
			var fieldatts = JRESPONSE.parseAttributes(recordsfields[sidx]);
			if(recordsfields[sidx]
			&& recordsfields[sidx].firstChild
			&& recordsfields[sidx].firstChild.data) flattendata[fieldatts['id']] = recordsfields[sidx].firstChild.data;
			else flattendata[fieldatts['id']] = '';
		}
		var mydrag = new Draggable($('kartenbestellung'),{revert:false,ghosting:false});
		this.record = flattendata;
	}
	
	
	//---------------------------------------------------------------------------------------
	this.plan = false; this.plan_open = false;
	this.getPlan = function() {
		
		if(this.plan_open) return;
		
		this.removeEvent(document,'mousedown',this.hideme);
		this.addEvent(document,'mousedown',this.hideme = function(event) {this.hidePlan(event);}.bind(this));
		// bestellung nach links verschieben?
		
		// raumplan bild anzeigen
		if(!this.plan) {
			this.plan = document.createElement('img');
			this.plan.src = this.record['plan_path'];
			this.plan.width = this.record['plan_width'];
			this.plan.height = this.record['plan_height'];
			this.plan.style.position = 'fixed';
			this.plan.style.zIndex = 701;
			this.plan.style.left = 50+'px';
			this.plan.style.top = (this.sof['top'] + 15)+'px';		

			this.orderpos = $('kartenbestellung').viewportOffset();
			new Effect.Move ($('kartenbestellung'),{ x: -((this.mag.offsetWidth/2)-($('kartenbestellung').offsetWidth/2)), y: 0, mode: 'relative'});
			
			document.getElementsByTagName('body')[0].appendChild(this.plan);
			new Effect.Move (this.plan,{ x: ((this.mag.offsetWidth/2)-(this.plan.width/2)), y: this.orderpos['top'], mode: 'absolute'});

		}		
		
		this.plan_open = true;
		
	}
	

	//---------------------------------------------------------------------------------------
	this.hidePlan = function(event,force) {
		
		PAGEdom.removeNode(this.plan); 
		this.plan = false;
		this.plan_open = false;
		new Effect.Move ($('kartenbestellung'),{ x:((this.mag.offsetWidth/2)-($('kartenbestellung').offsetWidth/2)), y: 0, mode: 'relative'});
		
		this.removeEvent(document,'mousedown',this.hideme);
		//this.addEvent(document,'mousedown',this.hideme = function(event) {this.hideMagnifier(event);}.bind(this));
	}	
	
	//---------------------------------------------------------------------------------------
	this.hideMagnifier = function(event,force) {
		
		
		if(typeof force == 'undefined') force = false;
		//force = false;
		
		var el;
		if(event) {
			el = this.gettarget(event);
		}
		
		if(force !== true) {			
			var fwr = $('kartenbestellung');
			
			// If the active button was clicked on, exit.
			//if (el == this.mag) return;
			if (el == fwr) return;
			//if (el == this.mag_bg) return;
			//if (el == this.nav) return;
			/*if (el.parentNode
			&& el.parentNode == this.nav) return;
			*/
			
			tel = el.parentNode;
			while(tel.parentNode) {
				if (tel == fwr) return;			
				if(tel.parentNode) tel = tel.parentNode;
				else tel = false;
			}
		}
		// If the element is not part of a menu, reset and clear the active
		// button.

		
		new Effect.BlindUp($('kartenbestellung'),{duration:0.3,
		afterFinish: function() {
			TO.cover.style.display = 'none';
			PAGEdom.removeNode(TO.mag); 
			TO.nav = false;
			TO.mag = false;
			TO.mag_bg = false;
			IF.showFlash();			
		}});
		/*
		this.cover.style.display = 'none';
		PAGEdom.removeNode(this.mag); 
		//PAGEdom.removeNode(this.mag_bg);
		this.nav = false;
		this.mag = false;
		this.mag_bg = false;
		IF.showFlash();
		*/
		this.removeEvent(window,'resize',this.resizer);
		//this.removeEvent(document,'mousedown',this.hideme);
		
		//document.getElementsByTagName('body')[0].style.overflow = 'auto';
		//this.mag.style.display = 'none';
		//this.mag_bg.style.display = 'none';
	}	
	
	//---------------------------------------------------------------------------------------
	this.coverbackground = function(vs,op) {
		
		//if(this.viewer_loaded == false) 
		if(!op) op = 0;
		IF.hideFlash();
		
		if(!this.cover) {
			this.cover = document.createElement('div');
			this.cover.style.position = 'absolute';
			this.cover.style.zIndex = 500;
			this.cover.style.left = 0+'px';
			this.cover.style.top = 0+'px';
			this.cover.style.opacity = op; // set opacity for effect : filter:alpha(opacity=50); -moz-opacity:0.5; opacity:0.5; 
			this.cover.style.filter = "alpha(opacity:"+Math.round(op*100)+")";
			this.cover.style.backgroundColor = "#000";
			document.getElementsByTagName('body')[0].appendChild(this.cover);
		}
		
		if(!vs) {
			this.cover.style.display = 'none';
		} else {
			this.cover.style.display = '';
			//document.getElementsByTagName('body')[0].style.overflow = 'hidden';		
			bh = PAGEdom.getPageHeight();
			
			if(!this.mag) {
				var st, ww, wh;
				ww = GetWindowWidth();
				wh = GetWindowHeight();			
				st = PAGEdom.docScrollTop();
				
				//DebugDump(bh,'st '+bh+' / '+st);
				bodyheight = st+wh;
				//DebugDump(bodyheight,'st '+wh+' / '+st);
				//alert(wh+', '+st);
				
				//this.cover.style.width = (ww)+'px';
				//this.cover.style.height = ((bh))+'px';
				//this.cover.style.visibility =  'visible';	
			
				this.mtop = (st+50)+'px'; 
				this.mag = document.createElement('div');
				this.mag.style.position = 'absolute';
				this.mag.style.zIndex = 601;

				//this.mag.style.border = '1px solid white';
				this.mag.style.textAlign = 'center';
				//this.mag.style.height = '180px';
				//this.mag.style.padding = '5px';
				//this.mag.style.fontWeight = 'bold';
				//this.mag.style.color = 'white';
				//this.mag.style.fontSize = '100%';
				//this.mag.innerHTML = this.m;
	
				document.getElementsByTagName('body')[0].appendChild(this.mag);
			}
			
			this.dem = document.viewport.getDimensions();
			//DebugDump(dem,'dem');
			this.sof = document.viewport.getScrollOffsets();
			//DebugDump(sof,'sof');			
			//this.cover.appendChild(this.mag);
			if(bh < this.dem['height']) bh = this.dem['height'];
			this.cover.style.height = bh+'px';//this.dem['height']+'px';
			this.cover.style.width = '100%';//this.dem['width']+'px';
			
			this.mag.style.left = 50+'px';
			this.mag.style.top = (this.sof['top'] + 15)+'px';		
			this.mag.style.width = (this.dem['width']-430)+'px';	
			this.mag.style.width = (this.dem['width']-200)+'px';	
			
		}
	}

	//---------------------------------------------------------------------------------------
	this.gettarget = function(event) {

		if(window
		&& (window.event)
		&& (window.event.srcElement)) {
			t = window.event.srcElement;
		} else {
			t = (event.target.tagName ? event.target : event.target.parentNode);
		}
		return t;
	}	
	

	//---------------------------------------------------------------------------------------
	this.addEvent = function(el,evname,func) {
	
		if (el.attachEvent) { // IE
			el.attachEvent("on" + evname, func);
		} else if (el.addEventListener) { // Gecko / W3C
			el.addEventListener(evname, func, true);
		} else {
			el["on" + evname] = func;
		}
	
	}
	
	//---------------------------------------------------------------------------------------
	this.removeEvent = function(el,evname,func) {
	
		if (el.detachEvent) { // IE
			el.detachEvent("on" + evname, func);
		} else if (el.removeEventListener) { // Gecko / W3C
			el.removeEventListener(evname, func, true);
		} else {
			el["on" + evname] = null;
		}
	
	}
}

TO = new TicketOrder();

/******************************************************************************
* PHPOSMenu, by chris, 11.07.2006
* useing draft by Mike Hall, thanks to your great mental work, 
* designing the structure of this menu
******************************************************************************/

function KSMenu() {

	// settings
	this.menu_zindex = 10; // start with z-index
	this.phposmainmenu_id = 'mainnav'; // 'phposmainmenu'; // id of menubar
	this.menuButtonAktiveClassname = 'active'; //'Active';
	this.submenuwidth = 'dynamic'; // just fit menuitems into menu 
	this.submenuwidth = 200; // remember, this is the width + additional padding in your style definition
	this.submenumaxwidth = 300; // remember, this is the width + additional padding in your style definition
	this.usesubmenuwidthMin = true; // try to fit menuitems into menu, but use this.submenuwidth as minimum
	// fade?
	this.fadesubmenus = false;
	this.fadeduration = 100; 
	this.fadesteps = 5; 
	// define vars (private)
	this.activeButton = null; 
	this.phposmainmenu_initialized = false; 
	this.menurunning = false;
	this.hidesubmenu = false; // set opacity of submenu to o.5
	this.menubordertop = '4px solid #e1b300;';
	this.checkbuttons = new Array(); // 
	
	//---------------------------------------------------------------------------------------
	this.buttonClick = function(button, menuId, img_src) {
		
		//var button;
		//button = this.gettarget(event);
		
		// Blur focus from the link to remove that annoying outline.
		if(button.tagName == 'A') button.blur();
	
		// Associate the named menu to this button if not already done.
		// Additionally, initialize menu display.
		if(!button.menu || button.menu == null) { //  if(button.menu == null) {
			button.menu = document.getElementById(menuId);

			if (button.menu.isInitialized == null) {
				initialisation = this.menuInit(button.menu);
			} 

			if(button.tagName == 'IMG') {
				button.imgDefaultSrc = button.src; // Save image source and swap image if exists
				button.imgOverSrc = img_src;
			}
		} 
		
		// Reset the currently active button, if any.
		if ((this.activeButton != null)) this.resetButton(this.activeButton);
		//&& (button != this.activeButton)
		// Activate this button, unless it was the currently active one.
		if (button.menu.isInitialized && button && button != this.activeButton) {
			this.depressButton(button);
			this.activeButton = button;
		}
		else this.activeButton = null;
		return false;
	}
	
	this.depressButton = function(button) {
		// DebugDump('depressButton: '+button);
		var x, y;
		
		// Update the button's style class to make it look like it's
		// depressed.
		/*if(button.className) button.ActiveClassName = button.className+this.menuButtonAktiveClassname;
		else */button.ActiveClassName = this.menuButtonAktiveClassname;//button.className+this.menuButtonAktiveClassname; // menuButtonActive / menuButtonImageActive
		button.className += " "+button.ActiveClassName;// 'active'; //
		//DebugDump(button.className,'button.className');
		// Set image source to its depressed look
		if(button.imgDefaultSrc) {
			button.src = button.imgOverSrc;
		}
	
		// Position the associated drop down menu under the button and
		// show it.
		pos = PAGEdom.toDocumentPosition(button);
		pos.y += button.offsetHeight;
		x = getPageOffsetLeft(button);
		y = getPageOffsetTop(button) + button.offsetHeight;
		
		// main menu bar position
		menupos = PAGEdom.toDocumentPosition(this.phposmainmenu);
		menupos.y += this.phposmainmenu.offsetHeight;

		if(document.getElementById('main')) {
			mmain = document.getElementById('main');
			posmain = PAGEdom.toDocumentPosition(mmain);
			//DebugDump(posmain,'posmain.x '+posmain.x);
			pos.x = pos.x - posmain.x;
		}

		// lookup right positioned elements
		px = PAGEdom.getWindowWidth();
		if((button.menu.offsetWidth+pos.x)>px) {
			pos.x = (pos.x+button.offsetWidth) - (button.menu.offsetWidth);
			menu_button_pos = 'right';
		} else menu_button_pos = 'left';
		
		// set position
		button.menu.style.left = pos.x + "px";
		button.menu.style.top  = menupos.y + "px";
		
		// effect?
		if(this.fadesubmenus) {
			op = 0;
			button.menu.style.opacity = op; // set opacity for effect : filter:alpha(opacity=50); -moz-opacity:0.5; opacity:0.5; 
			button.menu.style.filter = "alpha(opacity:"+Math.round(op*100)+")";
		}
		button.menu.style.visibility = "visible";
		if(this.fadesubmenus) {
			F1 = new FadeTo();
			F1.initialize(button.menu, 1, this.fadeduration, this.fadesteps ); // fade in 
		}
	}
	
	//---------------------------------------------------------------------------------------
	this.resetButton = function(button) {
	
		// Restore the button's style class.
		PAGEdom.removeClassName(button,button.ActiveClassName);
	
		// Reset image source to normal look
		if(button.imgDefaultSrc) {
			button.src = button.imgDefaultSrc;
		}
	
		// Hide the button's menu, first closing any sub menus.
		if (button.menu != null) {
			this.closeSubMenu(button.menu);
			if(this.fadesubmenus) {
				F1 = new FadeTo();
				F1.initialize(button.menu, 0, this.fadeduration, this.fadesteps ); // fade out 
			} else button.menu.style.visibility = "hidden";
		}
	}
	
	//---------------------------------------------------------------------------------------
	this.buttonMouseover = function(event, menuId, img_src) {
		var button;
		button = this.gettarget(event);
		//DebugDump(this.menurunning,'buttonMouseover.menurunning '+menuId);
		this.checkbuttons[menuId] = true;
		if(!this.menurunning) { // wenn das menü noch nicht geöffnet ist
								// verzögere das öffnen, um das öffnen ausversehen, zu vermeiden
			setTimeout(function(){this.waitButtonMouseover(button, menuId, img_src);}.bind(this), 500);
		} else { // ansonsten sofort weitermachen
			this.ebuttonMouseover(button, menuId, img_src);
		}
	}
	//---------------------------------------------------------------------------------------
	// das offnen eines menüpunktes wird verzögert
	// damit sich das menü nicht ständig öffnet, wenn man mal mit der maus drüber fährt
	// siehe auch: this.buttonMouseout, die die variable this.checkbuttons[menuId] mit verwaltet
	this.waitButtonMouseover = function(button, menuId, img_src) {
		//DebugDump(this.checkbuttons[menuId],'waitButtonMouseover.this.checkbuttons[menuId] '+menuId);
		//DebugDump(menuId,'menuId ' +menuId);
		
		if(this.checkbuttons
		&& this.checkbuttons[menuId]) {

			//alert(button);
			//DebugDump(this.checkbuttons[menuId],'buttonMouseout.this.checkbuttons[menuId] '+menuId);
			this.ebuttonMouseover(button, menuId, img_src);
		}
	}
	
	//---------------------------------------------------------------------------------------
	this.ebuttonMouseover = function(button, menuId, img_src) {
		
		//var button;
		//button = this.gettarget(event);
		this.startMenu();
		
		// If any other button menu is active, make this one active instead.
		if(this.activeButton != null && this.activeButton != button)
			this.buttonClick(button, menuId, img_src);
		else if(this.activeButton == null) // new
			this.buttonClick(button, menuId, img_src);
	
	}
	
	//---------------------------------------------------------------------------------------
	// diese function ist dafür da nachzuhalten, ob ich in der zeitspanne in der
	// this.waitButtonMouseover aufgerufen wird, den menüpunkt wieder verlasse
	this.buttonMouseout = function(event, menuId, img_src) {
		this.checkbuttons[menuId] = false;
		//DebugDump(this.checkbuttons[menuId],'buttonMouseout.this.checkbuttons[menuId] '+menuId);
	}

	this.menuMouseover = function(event) {
		
		var item, menu;
		item = this.gettarget(event);
		
		// get menu
		menu = PAGEdom.getContainerByTagAndClass(item, "DIV", "menu"); // suche das menu
		if(menu.activeItem != null && menu.activeItem == item) return;
		
		// Close any active sub menu.
		if (menu.activeItem != null) this.closeSubMenu(menu);
	}

	this.menuItemMouseover = function(event, menuId) {
		
		var item, menu, x, y;
	
	  	// Find the target item element and its parent menu element.
		item = this.gettarget(event);
		if(item.tagName != 'A'
		|| (item.tagName == 'A' && item.className != "menuItem")) {
			item = PAGEdom.getContainerByTagAndClass(item, "A", "menuItem");
		}
		
		// get menu of item
		menu = PAGEdom.getContainerByTagAndClass(item, "DIV", "menu");
		
	  	// Close any active sub menu and mark this one as active.
		if (menu.activeItem != null && menu.activeItem == item) return;
		if (menu.activeItem != null) this.closeSubMenu(menu);
		menu.activeItem = item;

		// Highlight the item element.
		item.className += " menuItemHighlight";
		
		// Initialize the sub menu, if not already done.
		if (!item.subMenu || item.subMenu == null) { //if(item.subMenu == null) {
			item.subMenu = document.getElementById(menuId);
			if (item.subMenu.isInitialized == null) this.menuInit(item.subMenu);
		}
	
	  	// Get position for submenu based on the menu item.
		pos = PAGEdom.toDocumentPosition(item);
		pos.x += item.offsetWidth;
		
		// Adjust position to fit in view.
		var maxX, maxY;

		maxX = PAGEdom.docScrollLeft() + PAGEdom.getWindowWidth();
		maxY = PAGEdom.docScrollTop() + PAGEdom.getWindowHeight();
		
		maxX -= item.subMenu.offsetWidth;
		maxY -= item.subMenu.offsetHeight;
		x = pos.x;
		if (x > maxX)
			x = Math.max(0, pos.x - item.offsetWidth - item.subMenu.offsetWidth + (menu.offsetWidth - item.offsetWidth));
		y = Math.max(0, Math.min(pos.y, maxY));
		
		// get border top
		btw = 0;
		//btw = PAGEdom.getStyle(item.subMenu,'border-top-width');
		//if(btw) btw = parseInt(btw);

	  	// Position and show it.
		item.subMenu.style.left = x + "px";
		item.subMenu.style.top = y + btw + "px";

		// effect?
		if(this.fadesubmenus) {
			op = 0;
			item.subMenu.style.opacity = op; // set opacity for effect : filter:alpha(opacity=50); -moz-opacity:0.5; opacity:0.5; 
			item.subMenu.style.filter = "alpha(opacity:"+Math.round(op*100)+")";
		}
		item.subMenu.style.visibility = "visible";
		if(this.fadesubmenus) {
			F1 = new FadeTo();
			F1.initialize(item.subMenu, 1, this.fadeduration, this.fadesteps ); // fade in 
		}

		
		// Stop the event from bubbling.
		if(window && window.event) {
			window.event.cancelBubble = true;
		} else event.stopPropagation();

		
	}

	this.closeSubMenu = function(menu) {

		 if (menu == null || menu.activeItem == null)
		 return;
	
		// Recursively close any sub menus.
		if (menu.activeItem.subMenu != null) {
			this.closeSubMenu(menu.activeItem.subMenu);
			
			if(this.fadesubmenus) {
				F1 = new FadeTo();
				F1.initialize(menu.activeItem.subMenu, 0, this.fadeduration, this.fadesteps ); // fade out 
			} else menu.activeItem.subMenu.style.visibility = "hidden";
			menu.activeItem.subMenu = null;
		}
		
		PAGEdom.removeClassName(menu.activeItem, "menuItemHighlight");
		menu.activeItem = null;
		
	}

	this.menuInit = function(menu) {
		
		var itemList, spanList;
		var textEl, arrowEl;
		var itemWidth;
		var w, dw;
		var i, j;
		
		// init main menubar on first load
		if(!this.phposmainmenu_initialized) this.initPHPOSMainMenu();
	
	 	// For IE, replace arrow characters.
	 	// do we really need this? I don´t think so, "&#9654;" will be an arrow even on windows
		this.changearrowfont = true;
		if (this.changearrowfont && browser.isIE) {
		// menu.style.lineHeight = "2.5ex";
		
			spanList = menu.getElementsByTagName("SPAN");
			for (i = 0; i < spanList.length; i++) {
				if (PAGEdom.hasClassName(spanList[i], "menuItemArrow")) {
					//DebugDump(spanList[i].style.fontFamily,'spanList[i].style.fontFamily');
					spanList[i].style.fontFamily = "Webdings";
					spanList[i].firstChild.nodeValue = "4";
				}
			}
		}
		
		// to fix the z-index, cause of recursiv loading the menu (instead of hierachically) 
		this.menu_zindex++;
		menu.style.zIndex = this.menu_zindex;
		
		// get all menu items
		itemList = menu.getElementsByTagName("A");
		
		var itemWidth = new Number(); 
		var temp_itemWidth = new Number();
		
		if (itemList.length > 0) { 
			// if this.submenuwidth = dynamic, we try to find the correct width every menuitem fits in
			if(this.submenuwidth == 'dynamic') {
				// Find the width of a menu item.
				for (s = 0; s < itemList.length; s++) {
					temp_itemWidth = itemList[s].offsetWidth;
					if(temp_itemWidth > itemWidth) itemWidth = temp_itemWidth;
				}
			} else {
				itemWidth = this.submenuwidth;
				if(this.usesubmenuwidthMin) {
					for (s = 0; s < itemList.length; s++) {
						temp_itemWidth = itemList[s].offsetWidth;
						if(temp_itemWidth > this.submenuwidth) itemWidth = temp_itemWidth;
					}
				}
			}
			if(itemWidth > this.submenumaxwidth) itemWidth = this.submenumaxwidth;
		} else {
			return false;
		}
		
		// we don´t want padding right, arrow should be on the right edge
		ispR = parseInt(PAGEdom.getStyle(itemList[0],'padding-right'));
		ispL = parseInt(PAGEdom.getStyle(itemList[0],'padding-left'));

		// fix input size
		inputList = menu.getElementsByTagName("INPUT");
		for (il = 0; il < inputList.length; il++) {
			//DebugDump(inputList[il].type,'inputList[il].type '+inputList[il].type);
			if(inputList[il].type == 'text' || inputList[il].type == 'password' || inputList[il].type == 'select') {
				inputList[il].style.width = (itemWidth-ispR-20) +'px';
			}
		}
		selectList = menu.getElementsByTagName("SELECT");
		for (il = 0; il < selectList.length; il++) {
			selectList[il].style.width = (itemWidth-ispR-20) +'px';
		}		
		
		// For items with arrows, add padding to item text to make the
		// arrows flush right.
		var ct = 0;
		for (i = 0; i < itemList.length; i++) {
			spanList = itemList[i].getElementsByTagName("SPAN");
			textEl  = null;
			arrowEl = null;
			for (j = 0; j < spanList.length; j++) {
				if (PAGEdom.hasClassName(spanList[j], "menuItemText")) {
					textEl = spanList[j];
					if(textEl.id) { // get id of submenu of this menu
						var submenu_id = textEl.id.substring(3);
						//DebugDump(submenu_id,'submenu_id '+submenu_id);
						//DebugDump(document.getElementById(submenu_id),'submenu_id '+submenu_id);
						if(document.getElementById(submenu_id)) { //check if exits
							//check if there are any childs or hide menu
							var submenu_ahrefs = 0;
							submenu_ahrefs = document.getElementById(submenu_id).getElementsByTagName("A");
							//DebugDump(submenu_ahrefs.length,'submenu_ahrefs.length'+submenu_ahrefs.length);
							if(submenu_ahrefs.length==0) itemList[i].style.display = 'none';
						}
					}
				}
				if (PAGEdom.hasClassName(spanList[j], "menuItemArrow")) {
					arrowEl = spanList[j];
				}
			}
			if (textEl != null && arrowEl != null) {
				textEl.style.paddingRight = (itemWidth - (textEl.offsetWidth + arrowEl.offsetWidth + ispR + ispL)) + "px";
				if(this.submenuwidth == 'dynamic') itemWidth = itemWidth + arrowEl.offsetWidth;
				ct++;
			}
		}	
		

		
		// Fix IE hover problem by setting an explicit width on first item of
		// the menu.
		if (SmartAgent.indexOf('MSIE')>=0) {
			//w = itemList[0].offsetWidth;
			w = itemWidth; // das dürfte eigentlich nicht korrekt sein... hier ist das padding nicht mit drin
			itemList[0].style.width = w + "px";
			dw = itemList[0].offsetWidth - w;
			w -= dw;
			itemList[0].style.width = w + "px";
		}
		
		
		
		menu.style.width = itemWidth +'px';
		menu.isInitialized = true;
		return true;
	}
	
	this.initPHPOSMainMenu = function() {
		this.phposmainmenu = document.getElementById(this.phposmainmenu_id);
		this.phposmainmenu_initialized = true;
		this.addEvent(document,'mousedown',this.hideme = function(event) {this.hideMenu(event);}.bind(this));
	}
	
	//---------------------------------------------------------------------------------------
	this.hideMenu = function(event) {
	
		var el;
		// If there is no active button, exit.
		if (this.activeButton == null) return;
		el = this.gettarget(event);
		
		// If the active button was clicked on, exit.
		if (el == this.activeButton) return;
	
		// If the element is not part of a menu, reset and clear the active
		// button.
		if (PAGEdom.getContainerByTagAndClass(el, "DIV", "menu") == null) {
			this.resetButton(this.activeButton);
			this.activeButton = null;
			this.stopMenu();
		}
	}
	
	this.startMenu = function() {
		if(this.menurunning == true) return;
		if(this.hidesubmenu && document.getElementById('subnav')) {
			op = 0.5;
			subnavEL = document.getElementById('subnav');
			subnavEL.style.opacity = op; // set opacity for effect : filter:alpha(opacity=50); -moz-opacity:0.5; opacity:0.5; 
			subnavEL.style.filter = "alpha(opacity:"+Math.round(op*100)+")";
		}
		this.menurunning = true;
	}
	
	this.stopMenu = function() {
		//DebugDump(this.menurunning,'this.menurunning');
		if(this.menurunning == false) return;
		if(this.hidesubmenu && document.getElementById('subnav')) {
			op = 1;
			subnavEL = document.getElementById('subnav');
			subnavEL.style.opacity = op; // set opacity for effect : filter:alpha(opacity=50); -moz-opacity:0.5; opacity:0.5; 
			subnavEL.style.filter = "alpha(opacity:"+Math.round(op*100)+")";		
		}
		this.menurunning = false;
	}
	
	//---------------------------------------------------------------------------------------
	this.delayCloseMenu = function(event) {
	
		//menuBar / menu
	
	}
	
	//---------------------------------------------------------------------------------------
	this.gettarget = function(event) {

	/*if (browser.isIE) {
		button = window.event.srcElement;
	} else {
		button = event.currentTarget;
	}*/

		if(window
		&& (window.event)
		&& (window.event.srcElement)) {
			t = window.event.srcElement;
		} else {
			t = (event.target.tagName ? event.target : event.target.parentNode);
		}
		return t;
	}	
	
	
	//---------------------------------------------------------------------------------------
	this.findRelativeTopPosition = function(parent_el,el,searchfor,context) {
		var itemHeight = new Number();
		
		// find the relative position to the given el
		itemList = parent_el.childNodes;
		
		switch(context) {
			case"node":
				for(var i=0;i<itemList.length;i++) { 
					if(itemList[i].tagName != 'A') continue;
					if(itemList[i] != searchfor) { 
						itemHeight += itemList[i].offsetHeight;
						//DebugDump(itemList[i],'itemHeight of '+itemList[i].innerHTML);
						if(itemList[i].className == 'menuItemSep') { // fixme
							itemHeight += 8;
						}
					} else {
						return itemHeight;
					}
				} 		
				break;
			case"id":
				for(var i=0;i<itemList.length;i++) { 
					if(itemList[i].id != searchfor) { 
						itemHeight += itemList[i].offsetHeight;
						if(itemList[i].className == 'menuItemSep') { // fixme
							itemHeight += 8;
						}
					} else {
						return itemHeight
					}
				} 		
				break;
			case"className":
				for(var i=0;i<itemList.length;i++) { 
					if(!hasClassName(itemList[i], className)) itemHeight += itemList[i].offsetHeight;
					else return itemHeight+itemList[i].offsetHeight;
				} 		
				break;
		
		}
	}

	//---------------------------------------------------------------------------------------
	this.addEvent = function(el,evname,func) {
	
		if (el.attachEvent) { // IE
			el.attachEvent("on" + evname, func);
		} else if (el.addEventListener) { // Gecko / W3C
			el.addEventListener(evname, func, true);
		} else {
			el["on" + evname] = func;
		}
	
	}
	
	//---------------------------------------------------------------------------------------
	this.removeEvent = function(el,evname,func) {
	
		if (el.detachEvent) { // IE
			el.detachEvent("on" + evname, func);
		} else if (el.removeEventListener) { // Gecko / W3C
			el.removeEventListener(evname, func, true);
		} else {
			el["on" + evname] = null;
		}
	
	}

}


KSMENU = new KSMenu();
LOADER = new Loader();
test = LOADER.include_once('/javascripts/dom.js');
test = LOADER.include_once('/javascripts/ajax.js');

function KSMenuQuicksearch(content_key) {
	this.content_key = content_key;
	this.displayEl = document.getElementById('display_'+this.content_key);
	this.searchEl = document.getElementById('search_'+this.content_key);
	KSMENU.addEvent(this.searchEl,'keydown',this.quicki = function(event) {this.quicksearch(event);}.bind(this));
	this.dataUrl = '/php-os/app_kinderschutz/scripts/menu_search.php';
	
	// quicksearch, submit on return
	this.quicksearch = function(event) {
		//DebugDump(event.keyCode,'event.keyCode');
		if(event.keyCode != 13) return;
		this.search();
	}

	this.search = function() {

		myAjax = new ajax();
		var postit = 'content_key='+this.content_key+'&search='+this.searchEl.value;
		myAjax.initialize(this.dataUrl, {method:'post',postBody:postit, onComplete: this.getResponse}); // update: $('testrequest'),


	}

	//---------------------------------------------------------------------------------------
	// just a container for AJAX Response and call to Respond()
	this.getResponse = function(request) {
		JRESPONSE = new Respond(request.responseXML);
		JRESPONSE.interpretResponse();

	}
	
	this.viewData = function(node) {
		//DebugDump(null,'hey we are here @ viewData');

		editorfield = node.getElementsByTagName("editor");
		this.editorAttr = JRESPONSE.parseAttributes(editorfield[0]);
		this.editorData = editorfield[0].firstChild.data; //unescape(nodes[fidx].firstChild.data);

		this.displayEl.innerHTML = this.editorData;
		
	
	}
	//---------------------------------------------------------------------------------------
	this.error = function(node) {
		// node from XMLResponse
		errorfield = node.getElementsByTagName("error");
		// get attributes of this node
		this.errorAttr = new Array(); 
		this.errorAttr = JRESPONSE.parseAttributes(errorfield[0]);
		this.errorData = errorfield[0].firstChild.data;
		this.displayEl.innerHTML = this.errorData;
		//alert(this.errorAttr['value']);
	}
}

function Browser() {

  var ua, s, i;

  this.isIE    = false;  // Internet Explorer
  this.isOP    = false;  // Opera
  this.isNS    = false;  // Netscape
  this.version = null;

  ua = navigator.userAgent;

  s = "Opera";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isOP = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  s = "Netscape6/";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  // Treat any other "Gecko" browser as Netscape 6.1.

  s = "Gecko";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = 6.1;
    return;
  }

  s = "MSIE";
  if ((i = ua.indexOf(s))) {
    this.isIE = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }
}

var browser = new Browser();

//---------------------------------------------------------------------------------------
//-- Menu Functions ---------------------------------------------------------------------
//---------------------------------------------------------------------------------------

function Mailto () {
	this.ajax_path = '/php-os/app_kinderschutz/scripts/ajax_email.php';
	this.mail = false;
	this.linkid = false;
	this.emaillinks = new Object();
	this.changeVeMail = false;
	
	this.loadM = function(pclass,sid,emailfield,searchfield,elid) {
		//DebugDump(elid,'elid');
		if(!document.getElementById(elid)) return false;
		
		if(!this.emaillinks[elid]) {
			this.emaillinks[elid] = new Object();
			this.emaillinks[elid].linkid = elid;
		}
		
		
		
		if(document.getElementById(elid)) {
			
			this.emaillinks[elid].link = document.getElementById(elid);
		
			//if(this.emaillinks[elid].loaded === true 
			//&& this.emaillinks[elid].link.href.indexOf('mailto') >= 0) return true;
			
			if(this.emaillinks[elid].loaded === true) {
				this.emaillinks[elid].link.href = 'mailto:' + this.emaillinks[elid].mail;
				if(this.changeVeMail) {
					this.emaillinks[elid].link.innerHTML = this.emaillinks[elid].lvemail;
				}
				setTimeout(function(){this.emaillinks[elid].link.href = '#/spamschutz';}.bind(this), 500);
				return true;
			}
			this.getEmail(pclass,sid,emailfield,searchfield,elid);
		}
		
	}
	//---------------------------------------------------------------------------------------
	this.getEmail = function(pclass,sid,emailfield,searchfield,elid) {
		
		var postit = 'class='+pclass;
		postit += '&sid='+sid;
		postit += '&emailfield='+emailfield;
		postit += '&searchfield='+searchfield;
		postit += '&oncomplete=viewEmail';
		postit += '&elid='+elid;

		mAjax = new ajax();
		mAjax.initialize(this.ajax_path, {method:'post',postBody:postit, onComplete: this.getResponse}); 		
	}

	//---------------------------------------------------------------------------------------	
	this.viewEmail = function(node) {
		editorfield = node.getElementsByTagName("editor");
		this.editorAttr = JRESPONSE.parseAttributes(editorfield[0]);
		this.editorData = editorfield[0].firstChild.data; //unescape(nodes[fidx].firstChild.data);
		this.emaillinks[this.editorAttr['elid']].mail = this.editorData;
		this.setLink(this.editorAttr['elid'],this.editorAttr['vemail']);
	}	
	
	this.setLink = function(elid,vemail) {
		if(document.getElementById(this.emaillinks[elid].linkid)) {
			this.emaillinks[elid].loaded = true;
			this.emaillinks[elid].vemail = vemail;
			//this.emaillinks[elid].link.href = 'mailto:'+this.emaillinks[elid].mail;
			if(this.changeVeMail) {
				document.getElementById(this.emaillinks[elid].linkid+'_v').style.display = 'none';
				this.emaillinks[elid].link.innerHTML = this.emaillinks[elid].link.innerHTML + this.emaillinks[elid].vemail;
				this.emaillinks[elid].lvemail = this.emaillinks[elid].link.innerHTML;
			}
			//this.emaillinks[elid].href = 'mailto:'+this.mail;
		}
	}
	
	//---------------------------------------------------------------------------------------
	// just a container for AJAX Response and call to Respond()
	this.getResponse = function(request) {
		JRESPONSE = new Respond(request.responseXML);
		JRESPONSE.interpretResponse();
	}
	
	this.error = function(node) {
		alert('Fehler! Es wurde keine eMail-Adresse gefunden.');
	}
	
	this.loadAlleMails = function() {
		 var links = document.getElementsByTagName('A');
		 for (var i=0; i<links.length; i++) { 	
		 	if(links[i].id.indexOf('elink') >= 0) {
		 		//DebugDump(links[i].getAttribute('onclick'),'getAttr');
		 		//DebugDump(links[i].onclick,'onclick');
		 		//DebugDump(links[i].lang,'lang');
		 		//DebugDump(links[i].getAttribute('lang'),'getAtrr. lang');
		 		eval(links[i].getAttribute('lang'));
		 	}
		 }
	}
	
}

MT = new Mailto();






function getHelp(key) {
	
	help_path = '/phpos/help';

	if(key) help_path += key;
	//else if(content_key)  help_path += '/content/'+content_key;
	else help_path += myPlainPagePath;
	
	FensterOeffnen(help_path,'help',800,500,'yes');
}



OnLoadFunctions[OnLoadFunctions.length] = "ARTICLE = new Article(); ARTICLE.init();";

function Article() {
	
	// privat vars
	this.header = false;
	this.title = 'Artikel';
	this.content = false;
	this.id = false;
	this.dataUrl 		= '/php-os/app_kinderschutz/scripts/ajax_request_calendar.php'; // XML-Page of calendar entry
	this.editorUrl 		= '/php-os/app_kinderschutz/scripts/ajax_request_editor_article.php'; // XML-Page of calendar entry
	//this.window = false;
	
	//---------------------------------------------------------------------------------------
	this.init = function(sid) {
		
		//if(!this.window) this.buildWindow();
		
		
	}


	//---------------------------------------------------------------------------------------
	// loads an XML-Page through XHTTP-Object
	this.getData = function(sid) {
		
		// get sid
		if(!sid) return false;

		myAjax = new ajax();
		myAjax.initialize(this.dataUrl, {method:'post',postBody: 'sid='+sid+'&colorsuffix='+active_color_set, onComplete: ARTICLE.getResponse}); // update: $('testrequest'),

	}

	//---------------------------------------------------------------------------------------
	// loads an XML-Page through XHTTP-Object
	this.getEditor = function(event,sid,context) {
		IF.window.clear();
		// get sid
		if(!sid) return false;
		
		myAjax = new ajax();
		myAjax.initialize(this.editorUrl, {method:'post',postBody: 'context='+context+'&sid='+sid+'&colorsuffix='+active_color_set, onComplete: ARTICLE.getResponse}); // update: $('testrequest'),

	}
	
	//---------------------------------------------------------------------------------------
	// just a container for AJAX Response and call to Respond()
	this.getResponse = function(request) {
		JRESPONSE = new Respond(request.responseXML);
		JRESPONSE.interpretResponse();
	}
	//---------------------------------------------------------------------------------------



	//---------------------------------------------------------------------------------------
	// is called via Respond() through type of XML-node evaluatetype
	this.viewEditorData = function(node) {

		//DebugDump('huhu','huhu');
		// node from XMLResponse
		editorfield = node.getElementsByTagName("editor");
		this.editorAttr = JRESPONSE.parseAttributes(editorfield[0]);
		//DebugDump(this.editorAttr,'this.editorAttr');
		this.editorData = editorfield[0].firstChild.data; //unescape(nodes[fidx].firstChild.data);
		//DebugDump(this.editorData,'this.editorData');
		//this.updateWindow();
		IF.window.updateWindow(this.editorAttr['title'],this.editorData);
		//this.window.updateWindow(this.editorAttr['title'],this.editorData);
	}
	
	//---------------------------------------------------------------------------------------
	this.error = function(node) {
		// node from XMLResponse
		this.XMLerror = node.getElementsByTagName("error")[0];
		// get attributes of this node
		this.errorAttr = new Array(); 
		this.errorAttr = JRESPONSE.parseAttributes(this.XMLerror);
		alert(this.errorAttr['value']);
	}
	

}






























































function Dropdown() {
	
	this.window = false;
	this.title = 'Field';
	//---------------------------------------------------------------------------------------
	this.init = function(field_id,filepath) {
	
		//return true;
	
		this.dataUrl = filepath;
		this.field_id = field_id;
		this.field = document.getElementById(this.field_id);
		if(!this.window) this.buildWindow();
		else this.pos();
		this.getData();
	}
	
	this.pos = function() {
		this.window.updateWindow('loading...','');
		pos = 'left-middle';
		switch(pos) {
			case'top':
			var position = PAGEdom.toDocumentPosition(this.field);
			this.w_wrapper.style.top = (position['y']-this.w_wrapper.height)+'px';
			this.w_wrapper.style.left = position['x']+'px';			
			break;
			case'left-middle':
			var position = PAGEdom.toDocumentPosition(this.field);
			this.w_wrapper.style.top = (position['y']- (this.w_wrapper.height/2))+'px';
			this.w_wrapper.style.left = (position['x'] -10 - this.w_wrapper.width)+'px';			
			break;		
		}	
	}
	
	//---------------------------------------------------------------------------------------
	this.buildWindow = function() {
		
		// window
		bodyroot = document.getElementsByTagName('body')[0];
		this.w_wrapper = document.createElement("div");	
		

		this.w_wrapper.id = 'journalwindow'+active_color_set;
		this.w_wrapper.className = 'journalwindow'+active_color_set;
		this.w_wrapper.style.position = 'absolute';
		//this.w_wrapper.style.display = 'none';
		this.w_wrapper.style.visibility = 'hidden';
		this.w_wrapper.width = 200;
		this.w_wrapper.height = 200;
		this.w_wrapper.style.width = this.w_wrapper.width+'px';
		this.w_wrapper.style.height = this.w_wrapper.height+'px';
		this.w_wrapper.style.overflow = 'auto';
		//this.w_wrapper.style.border = '1px solid black';
		//this.w_wrapper.style.backgroundColor = 'white';
		//this.w_wrapper.style.zIndex = 100000;
		/*WWidth = GetWindowWidth();
		WHeight = GetWindowHeight();
		dst = PAGEdom.docScrollTop();
		this.w_wrapper.style.top = (((WHeight+dst)/2)-(this.w_wrapper.height/2))+'px';
		this.w_wrapper.style.left = ((WWidth/2)-(this.w_wrapper.width/2))+'px';
		*/
		

		
		pos = 'left-middle';
		switch(pos) {
			case'top':
			var position = PAGEdom.toDocumentPosition(this.field);
			this.w_wrapper.style.top = (position['y']-this.w_wrapper.height)+'px';
			this.w_wrapper.style.left = position['x']+'px';			
			break;
			case'left-middle':
			var position = PAGEdom.toDocumentPosition(this.field);
			this.w_wrapper.style.top = (position['y']- (this.w_wrapper.height/2))+'px';
			this.w_wrapper.style.left = (position['x'] -10 - this.w_wrapper.width)+'px';			
			break;		
		}
		
		bodyroot.appendChild(this.w_wrapper);
		this.makeNewWndow();
				
	}
	
	this.makeNewWndow = function() {
		this.window = new ContentWindow(this.title,this.w_wrapper.id);
		this.window.client_area_id = 'journalwindowclientarea';
		this.window.title_id = 'journalwindowtitlearea';
		this.window.init(this.window);	
		//this.window.updateWindow('huhu','text');
	}


	//---------------------------------------------------------------------------------------
	// loadimage loads an XML-Page through XHTTP-Object
	this.getData = function() {
		
		myAjax = new ajax();
		myAjax.initialize(this.dataUrl, {method:'post',postBody:'colorsuffix='+active_color_set, onComplete: DROPDOWN.getResponse}); // update: $('testrequest'),

	}
	
	//---------------------------------------------------------------------------------------
	// just a container for AJAX Response and call to Respond()
	this.getResponse = function(request) {
		JRESPONSE = new Respond(request.responseXML);
		JRESPONSE.interpretResponse();
	}
	
	this.viewData = function(node) {

		editorfield = node.getElementsByTagName("editor");
		this.editorAttr = JRESPONSE.parseAttributes(editorfield[0]);
		//DebugDump(this.editorAttr,'this.editorAttr');
		this.editorData = editorfield[0].firstChild.data; //unescape(nodes[fidx].firstChild.data);
		//DebugDump(this.editorData,'this.editorData');
		//this.updateWindow();
		this.window.updateWindow(this.editorAttr['name'],this.editorData);
	
	}
	
	this.add = function(item) {
		
		if(this.field.value.length == 0) {
			this.field.value += item;
		} else {
			this.field.value += ', '+item;
		}
	}
	
}















// detect FlashPlayer Width by width of Parent
function detectSWFWidth(id,w) {
	//return w;
	var w = parseInt(w);
	var playerEl = $(id);
	var wdt = playerEl;
	while(wdt) {
		var wdtWidth = wdt.getStyle('width');
		wdtWidth = parseInt(wdtWidth);
		if(wdtWidth 
		&& typeof wdtWidth == 'number'
		&& wdtWidth > 0) {
			if(wdtWidth < w) {
				//DebugDump(wdtWidth,'Found wdtWidth: '+ wdt.tagName+' / '+w +' / '+wdtWidth);
				w = parseInt(wdtWidth);
			}
			wdt = null;
		} else {
			//wdt = null;
			if(wdt.parentNode) wdt = wdt.parentNode;
			else wdt = null;
		}
	}

	return w;
	
}



/**
 * SWFObject v1.5: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
 *
 * SWFObject is (c) 2007 Geoff Stearns and is released under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 */
if(typeof deconcept == "undefined") var deconcept = new Object();
if(typeof deconcept.util == "undefined") deconcept.util = new Object();
if(typeof deconcept.SWFObjectUtil == "undefined") deconcept.SWFObjectUtil = new Object();
deconcept.SWFObject = function(swf, id, w, h, ver, c, quality, xiRedirectUrl, redirectUrl, detectKey) {
	if (!document.getElementById) { return; }
	this.DETECT_KEY = detectKey ? detectKey : 'detectflash';
	this.skipDetect = deconcept.util.getRequestParameter(this.DETECT_KEY);
	this.params = new Object();
	this.variables = new Object();
	this.attributes = new Array();
	var dtw = w;
	dtw = detectSWFWidth(id,w);
	if(dtw != w) {
		w = dtw;
		h = parseInt((w / 4) *3); // 4/3
		//DebugDump(dtw,'New Size w: '+ w+' / h: '+h);
	}
	if(swf) { this.setAttribute('swf', swf); }
	if(id) { this.setAttribute('id', id); }
	if(w) { this.setAttribute('width', w); }
	if(h) { this.setAttribute('height', h); }
	if(ver) { this.setAttribute('version', new deconcept.PlayerVersion(ver.toString().split("."))); }
	this.installedVer = deconcept.SWFObjectUtil.getPlayerVersion();
	if (!window.opera && document.all && this.installedVer.major > 7) {
		// only add the onunload cleanup if the Flash Player version supports External Interface and we are in IE
		deconcept.SWFObject.doPrepUnload = true;
	}
	if(c) { this.addParam('bgcolor', c); }
	var q = quality ? quality : 'high';
	this.addParam('quality', q);
	this.setAttribute('useExpressInstall', false);
	this.setAttribute('doExpressInstall', false);
	var xir = (xiRedirectUrl) ? xiRedirectUrl : window.location;
	this.setAttribute('xiRedirectUrl', xir);
	this.setAttribute('redirectUrl', '');
	if(redirectUrl) { this.setAttribute('redirectUrl', redirectUrl); }
}
deconcept.SWFObject.prototype = {
	useExpressInstall: function(path) {
		this.xiSWFPath = !path ? "expressinstall.swf" : path;
		this.setAttribute('useExpressInstall', true);
	},
	setAttribute: function(name, value){
		this.attributes[name] = value;
	},
	getAttribute: function(name){
		return this.attributes[name];
	},
	addParam: function(name, value){
		this.params[name] = value;
	},
	getParams: function(){
		return this.params;
	},
	addVariable: function(name, value){
		this.variables[name] = value;
	},
	getVariable: function(name){
		return this.variables[name];
	},
	getVariables: function(){
		return this.variables;
	},
	getVariablePairs: function(){
		var variablePairs = new Array();
		var key;
		var variables = this.getVariables();
		for(key in variables){
			variablePairs[variablePairs.length] = key +"="+ variables[key];
		}
		return variablePairs;
	},
	getSWFHTML: function() {
		var swfNode = "";
		if (navigator.plugins && navigator.mimeTypes && navigator.mimeTypes.length) { // netscape plugin architecture
			if (this.getAttribute("doExpressInstall")) {
				this.addVariable("MMplayerType", "PlugIn");
				this.setAttribute('swf', this.xiSWFPath);
			}
			swfNode = '<embed type="application/x-shockwave-flash" src="'+ this.getAttribute('swf') +'" width="'+ this.getAttribute('width') +'" height="'+ this.getAttribute('height') +'" style="'+ this.getAttribute('style') +'"';
			swfNode += ' id="'+ this.getAttribute('id') +'" name="'+ this.getAttribute('id') +'" ';
			var params = this.getParams();
			//DebugDump(params,'params');
			 for(var key in params){ swfNode += [key] +'="'+ params[key] +'" '; }
			var pairs = this.getVariablePairs().join("&");
			 if (pairs.length > 0){ swfNode += 'flashvars="'+ pairs +'"'; }
			swfNode += '/>';
		} else { // PC IE
			if (this.getAttribute("doExpressInstall")) {
				this.addVariable("MMplayerType", "ActiveX");
				this.setAttribute('swf', this.xiSWFPath);
			}
			swfNode = '<object id="'+ this.getAttribute('id') +'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+ this.getAttribute('width') +'" height="'+ this.getAttribute('height') +'" style="'+ this.getAttribute('style') +'">';
			swfNode += '<param name="movie" value="'+ this.getAttribute('swf') +'" />';
			var params = this.getParams();
			for(var key in params) {
			 swfNode += '<param name="'+ key +'" value="'+ params[key] +'" />';
			}
			var pairs = this.getVariablePairs().join("&");
			if(pairs.length > 0) {swfNode += '<param name="flashvars" value="'+ pairs +'" />';}
			swfNode += "</object>";
		}
		return swfNode;
	},
	write: function(elementId){
		if(this.getAttribute('useExpressInstall')) {
			// check to see if we need to do an express install
			var expressInstallReqVer = new deconcept.PlayerVersion([6,0,65]);
			if (this.installedVer.versionIsValid(expressInstallReqVer) && !this.installedVer.versionIsValid(this.getAttribute('version'))) {
				this.setAttribute('doExpressInstall', true);
				this.addVariable("MMredirectURL", escape(this.getAttribute('xiRedirectUrl')));
				document.title = document.title.slice(0, 47) + " - Flash Player Installation";
				this.addVariable("MMdoctitle", document.title);
			}
		}
		if(this.skipDetect || this.getAttribute('doExpressInstall') || this.installedVer.versionIsValid(this.getAttribute('version'))){
			var n = (typeof elementId == 'string') ? document.getElementById(elementId) : elementId;
			n.innerHTML = this.getSWFHTML();
			//alert(n.innerHTML);
			return true;
		}else{
			if(this.getAttribute('redirectUrl') != "") {
				document.location.replace(this.getAttribute('redirectUrl'));
			}
		}
		return false;
	}
}

/* ---- detection functions ---- */
deconcept.SWFObjectUtil.getPlayerVersion = function(){
	var PlayerVersion = new deconcept.PlayerVersion([0,0,0]);
	if(navigator.plugins && navigator.mimeTypes.length){
		var x = navigator.plugins["Shockwave Flash"];
		if(x && x.description) {
			PlayerVersion = new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/, "").replace(/(\s+r|\s+b[0-9]+)/, ".").split("."));
		}
	}else if (navigator.userAgent && navigator.userAgent.indexOf("Windows CE") >= 0){ // if Windows CE
		var axo = 1;
		var counter = 3;
		while(axo) {
			try {
				counter++;
				axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+ counter);
//				document.write("player v: "+ counter);
				PlayerVersion = new deconcept.PlayerVersion([counter,0,0]);
			} catch (e) {
				axo = null;
			}
		}
	} else { // Win IE (non mobile)
		// do minor version lookup in IE, but avoid fp6 crashing issues
		// see http://blog.deconcept.com/2006/01/11/getvariable-setvariable-crash-internet-explorer-flash-6/
		try{
			var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
		}catch(e){
			try {
				var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
				PlayerVersion = new deconcept.PlayerVersion([6,0,21]);
				axo.AllowScriptAccess = "always"; // error if player version < 6.0.47 (thanks to Michael Williams @ Adobe for this code)
			} catch(e) {
				if (PlayerVersion.major == 6) {
					return PlayerVersion;
				}
			}
			try {
				axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
			} catch(e) {}
		}
		if (axo != null) {
			PlayerVersion = new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));
		}
	}
	return PlayerVersion;
}
deconcept.PlayerVersion = function(arrVersion){
	this.major = arrVersion[0] != null ? parseInt(arrVersion[0]) : 0;
	this.minor = arrVersion[1] != null ? parseInt(arrVersion[1]) : 0;
	this.rev = arrVersion[2] != null ? parseInt(arrVersion[2]) : 0;
}
deconcept.PlayerVersion.prototype.versionIsValid = function(fv){
	if(this.major < fv.major) return false;
	if(this.major > fv.major) return true;
	if(this.minor < fv.minor) return false;
	if(this.minor > fv.minor) return true;
	if(this.rev < fv.rev) return false;
	return true;
}
/* ---- get value of query string param ---- */
deconcept.util = {
	getRequestParameter: function(param) {
		var q = document.location.search || document.location.hash;
		if (param == null) { return q; }
		if(q) {
			var pairs = q.substring(1).split("&");
			for (var i=0; i < pairs.length; i++) {
				if (pairs[i].substring(0, pairs[i].indexOf("=")) == param) {
					return pairs[i].substring((pairs[i].indexOf("=")+1));
				}
			}
		}
		return "";
	}
}
/* fix for video streaming bug */
deconcept.SWFObjectUtil.cleanupSWFs = function() {
	var objects = document.getElementsByTagName("OBJECT");
	for (var i = objects.length - 1; i >= 0; i--) {
		objects[i].style.display = 'none';
		for (var x in objects[i]) {
			if (typeof objects[i][x] == 'function') {
				objects[i][x] = function(){};
			}
		}
	}
}
// fixes bug in some fp9 versions see http://blog.deconcept.com/2006/07/28/swfobject-143-released/
if (deconcept.SWFObject.doPrepUnload) {
	if (!deconcept.unloadSet) {
		deconcept.SWFObjectUtil.prepUnload = function() {
			__flash_unloadHandler = function(){};
			__flash_savedUnloadHandler = function(){};
			window.attachEvent("onunload", deconcept.SWFObjectUtil.cleanupSWFs);
		}
		window.attachEvent("onbeforeunload", deconcept.SWFObjectUtil.prepUnload);
		deconcept.unloadSet = true;
	}
}
/* add document.getElementById if needed (mobile IE < 5) */
if (!document.getElementById && document.all) { document.getElementById = function(id) { return document.all[id]; }}

/* add some aliases for ease of use/backwards compatibility */
var getQueryParamValue = deconcept.util.getRequestParameter;
var FlashObject = deconcept.SWFObject; // for legacy support
var SWFObject = deconcept.SWFObject;



