
//alert("huhu");


/*****************************************************
*/ function __P___Language() {}
/******************************************************/
 
lang = 'de';
lang_show_failed_keys = '';

if(typeof INT != 'object') INT = new Object();
/*INT['firstname'] = new Object();
INT['firstname']['de'] = 'Vorname';
INT['firstname']['en'] = 'First Name';*/

function $L(key) {
	
	this.lang = lang;
	this.def_lang = 'en';
	
	if(!INT[key]) {
		return key+lang_show_failed_keys;
	} else if(INT[key]) {
		if(INT[key][this.lang]) return INT[key][this.lang];
		else if(INT[key][this.def_lang]) return INT[key][this.def_lang];
		else return key+lang_show_failed_keys;
	} else return key+lang_show_failed_keys;
}


/* Menu Functions */

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

function Interface () {
	
	this.window = false;
	this.title = '';
	
	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.jumpTo = function(path) {
		window.open(path);
	}

	//---------------------------------------------------------------------------------------
	this.adjustSize = function(r) {
		sizeUnit = "%";
		defaultSize = 100;
		maxSize = 160;
		minSize = 98;	
	}


	//---------------------------------------------------------------------------------------
	this.setFooter = function() {
		el_id = 'navteaserarea';
		// 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;
		nt = document.getElementById('navteaserarea'); // contains left subnav and navboxes
		if(document.getElementById(el_id)) {			
			nt = document.getElementById(el_id); // 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		
		}
		/*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(pHeight,'pHeight '+pHeight);
		//DebugDump(wHeight,'wHeight '+wHeight);
		if(pHeight
		&& wHeight
		&& pHeight<wHeight) {
			nt.style.height = (wHeight-ft.offsetHeight-nt_dp.y-1)+'px'; // window.height - footer - navteaser position
		}*/


		var nt_dp_bottom = nt_dp.y + nt.offsetHeight;
		//DebugDump(nt_dp,'nt_dp.y '+nt_dp.y+ ' / ' +nt_dp_bottom);
		// 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,'1 nt.style.height '+nt.style.height);
		} else if(nt_dp_bottom
		&& wHeight
		&& nt_dp_bottom > wHeight) {
			// do nothing
			//DebugDump(nt.style.height,'2 nt.style.height '+nt.style.height);	
		} else { // tja wenn pHeight > wHeight ist muss man doch auch nichts mehr machen
			//nt.style.height = (wHeight-ft.offsetHeight-nt_dp.y)+'px'; // window.height - footer - navteaser position
			//DebugDump(nt.style.height,'3 nt.style.height '+nt.style.height);		
		}


		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)+")";

	}

	//---------------------------------------------------------------------------------------
	this.loginOperation = function(operation,formname) {
		//alert();
		document.forms[0].operation.value = operation;
		document.forms[0].onsubmit(); // workaround browser bugs.
		document.forms[0].submit();
	}
	
	//---------------------------------------------------------------------------------------
	this.logout = function() {
		document.forms['login'].operation.value = '[logout]';
		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'].onsubmit(); // workaround browser bugs.
		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,formname) {
		//alert('huhu'); return;
		if(!formname) formname = 'contentform';
		document.getElementById(i).value = v;
		document.forms[formname].onsubmit(); // workaround browser bugs.
		document.forms[formname].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) {
		if(!formname) formname = 'contentform';
		document.forms[formname].onsubmit(); // workaround browser bugs.
		document.forms[formname].submit();	
	}

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

	// submit
	this.setHiddenAndActionAndSubmit = function(hidden_value,hidden_id,r_action,formname) {
		if(!formname) formname = 'contentform';
		document.getElementById(hidden_id).value = hidden_value;
		document.forms[formname].action = r_action;	
		document.forms[formname].onsubmit(); // workaround browser bugs.
		document.forms[formname].submit();
	}	
	

	// submit
	this.setHidden = function(hidden_value,hidden_id,formname) {
		if(!formname) formname = 'contentform';
		document.getElementById(hidden_id).value = hidden_value;
	}	
	//---------------------------------------------------------------------------------------
	//---------------------------------------------------------------------------------------
	this.magnifier_is_visible = false;
	this.magnify = function(m) {
		var mtop, st, ww;
		
		if(this.magnifier_is_visible == true) {
			setTimeout(function(){ this.magnify(m); }.bind(this), 300);
			return;
		}
		
		
/*
.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 = 10020;
		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 = '3px';
		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 = 10019;
		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,afterFinish: function() {IF.magnifier_is_visible = true;}});
		
		//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);
		IF.magnifier_is_visible = false;
	}
	//---------------------------------------------------------------------------------------
	
	//---------------------------------------------------------------------------------------
	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.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.getPHPOSContent = function(event,sid,conf) { //,{width:200,height:400,autosize:false}
		
		if(typeof conf != 'object') conf = {};
		default_conf = {
			width:400,
			height:600,
			autosize: true,
			topclose: true,
			overflow: 'auto',
			fullscreen: false
		};		
		var conf = Ext.apply(default_conf,conf);
		//DebugDump(conf,'conf');
		if(event) Event.stop(event);
		
		Lightview.show({
			href: '/ajax/getphposcontent/'+sid,
			rel: 'ajax',
			options: {
				autosize: conf.autosize,
				width: conf.width,
				height: conf.height,
				topclose: conf.topclose,
				myOverflow: conf.overflow,
				//overflow:conf.overflow,
				sid:sid,
				ajax: {
					onSuccess: function(transport) {
						//DebugDump(transport.responseText,'transport.responseText');
					},
					onComplete: function(a){
						//DebugDump(this,'onComplete this');
						//DebugDump(a,'onComplete a');
						//DebugDump(Lightview,'Lightview');
					},
					parameters: {sid:sid,noxml:true}
				}
			}
		});		
	}
	
	//---------------------------------------------------------------------------------------
	this.getContent = function(event,context,classname,sid) { // die hier is nich so dolle....
		
		switch(context) {
			case'contactyourcompany':
				this.contactCompanyWindow(event,context,classname,sid);
				break;
			case'contact':
				this.contactWindow(event,context,classname,sid);
				break;
			case'rqp':
				this.requestPasswordWindow(event,context,classname,sid);
				break;
			case'sendarticle':
			case'send':
				this.getAdviseWindow(event,context,classname,sid);
				break;
			default:
				// get ajax content
		}
	}

	this.contactCompanyWindow = function(event,t,c,sid) {
		Event.stop(event);
		Lightview.show({
			href: '/php-os/app_local/scripts/ajax_contactcompany.php',
			rel: 'ajax',
			options: {
				autosize: true,
				topclose: true,
				overflow:'hidden',
				ajax: {
					onSuccess: function(transport) {
						//DebugDump(transport.responseText,'transport.responseText');
					},
					onComplete: function(){
						// once the request is complete we observe the form for a submit
						$('adviseform').observe('submit', IF.submitCompanyContactWindow);
						if($('aam_email') && $('aam_email').value.length == 0) $('aam_email').focus();
						BB.clearOnFocus();
					},
					parameters: {t:t,c:c,sid:sid}
				}
			}
		});	
	}
	
	// lightview submit callback
	this.submitCompanyContactWindow = function(event) {
	  // block default form submit
	  Event.stop(event);
		  
	  Lightview.show({
		href: '/php-os/app_local/scripts/ajax_contactcompany.php',
		rel: 'ajax',
		options: {
		  title: 'results',
		  menubar: false,
		  topclose: true,
		  autosize: true,
		  ajax: {
			parameters: Form.serialize('adviseform'), // the parameters from the form
			onComplete: function(){
				// once the request is complete we observe the form for a submit
				if($('adviseform')) $('adviseform').observe('submit', IF.submitCompanyContactWindow);
				BB.clearOnFocus();
			}	
		  }
		}
	  });
	}		
	
	this.contactWindow = function(event,t,c,sid) {
		Event.stop(event);
		Lightview.show({
			href: '/php-os/app_local/scripts/ajax_contact.php',
			rel: 'ajax',
			options: {
				autosize: true,
				topclose: true,
				overflow:'hidden',
				ajax: {
					onSuccess: function(transport) {
						//DebugDump(transport.responseText,'transport.responseText');
					},
					onComplete: function(){
						// once the request is complete we observe the form for a submit
						$('adviseform').observe('submit', IF.submitContactWindow);
						if($('aam_email') && $('aam_email').value.length == 0) $('aam_email').focus();
						BB.clearOnFocus();
					},
					parameters: {t:t,c:c,sid:sid}
				}
			}
		});	
	}
	
	// lightview submit callback
	this.submitContactWindow = function(event) {
	  // block default form submit
	  Event.stop(event);
		  
	  Lightview.show({
		href: '/php-os/app_local/scripts/ajax_contact.php',
		rel: 'ajax',
		options: {
		  title: 'results',
		  menubar: false,
		  topclose: true,
		  autosize: true,
		  ajax: {
			parameters: Form.serialize('adviseform'), // the parameters from the form
			onComplete: function(){
				// once the request is complete we observe the form for a submit
				if($('adviseform')) $('adviseform').observe('submit', IF.submitContactWindow);
				BB.clearOnFocus();
			}	
		  }
		}
	  });
	}	
	
	this.requestPasswordWindow = function(event,t,c,sid) {
		Event.stop(event);
		Lightview.show({
			href: '/php-os/app_local/scripts/ajax_request_password.php',
			rel: 'ajax',
			options: {
				autosize: true,
				topclose: true,
				overflow:'hidden',
				ajax: {
					onSuccess: function(transport) {
						//DebugDump(transport.responseText,'transport.responseText');
					},
					onComplete: function(){
						// once the request is complete we observe the form for a submit
						$('adviseform').observe('submit', IF.submitAjaxRequestPassword);
						if($('aam_email') && $('aam_email').value.length == 0) $('aam_email').focus();
					},
					parameters: {t:t,c:c,sid:sid}
				}
			}
		});		
	}
	
	// lightview submit callback
	this.submitAjaxRequestPassword = function(event) {
	  // block default form submit
	  Event.stop(event);
		  
	  Lightview.show({
		href: '/php-os/app_local/scripts/ajax_request_password.php',
		rel: 'ajax',
		options: {
		  title: 'results',
		  menubar: false,
		  topclose: true,
		  autosize: true,
		  ajax: {
			parameters: Form.serialize('adviseform'), // the parameters from the form
			onComplete: function(){
				// once the request is complete we observe the form for a submit
				if($('adviseform')) $('adviseform').observe('submit', IF.submitAjaxRequestPassword);
			}	
		  }
		}
	  });
	}	
	
	// lightview submit form
	this.getAdviseWindow = function(event,t,c,sid) {

		Event.stop(event);
		Lightview.show({
			href: '/php-os/app_local/scripts/ajax_advise_mail.php',
			rel: 'ajax',
			options: {
				autosize: true,
				topclose: true,
				overflow:'hidden',
				ajax: {
					onSuccess: function(transport) {
						//DebugDump(transport.responseText,'transport.responseText');
					},
					onComplete: function(){
						// once the request is complete we observe the form for a submit
						$('adviseform').observe('submit', IF.submitAjaxFormDemonstration);
						if($('aam_recipientmail') && $('aam_recipientmail').value.length == 0) $('aam_recipientmail').focus();
					},
					parameters: {t:t,c:c,sid:sid}
				}
			}
		});
	}

	// lightview submit callback
	this.submitAjaxFormDemonstration = function(event) {
	  // block default form submit
	  Event.stop(event);
		  
	  Lightview.show({
		href: '/php-os/app_local/scripts/ajax_advise_mail.php',
		rel: 'ajax',
		options: {
		  title: 'results',
		  menubar: false,
		  topclose: true,
		  autosize: true,
		  ajax: {
			parameters: Form.serialize('adviseform'), // the parameters from the form
			onComplete: function(){
				// once the request is complete we observe the form for a submit
				if($('adviseform')) $('adviseform').observe('submit', IF.submitAjaxFormDemonstration);
			}	
		  }
		}
	  });
	}
	
	
	
	//---------------------------------------------------------------------------------------
	
	this.windowPrint = function() {
		window.print();
	}
	
	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;
		}
	
	}
}

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;
	KSdo_search();
}
//---------------------------------------------------------------------------------------
function KSdo_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 SmartBrowser() {

  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 SMbrowser = new SmartBrowser();

//---------------------------------------------------------------------------------------
//-- 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');
}









function Brautbox () {
	
	this.init = function() {

		/*if($('search-q')) {
			$('search-q').focus();
		}
		*/
		
		if(($('fields_root_editor_membership')) && ($('subcategory0'))) {
			for(i=0;i<7;i++) {
				this.observeMembership(i);
			}
		}
		
		this.clearOnFocus();
		
		// get height of aStore iFrame? how? this is a different namespace
		/*if($('astore')) {
			if(document.getElementById && !(document.all)) {
				var h = document.getElementById('astore').contentDocument.body.scrollHeight;
				if(document.getElementById('astore').contentDocument.body.offsetHeight) 
					var t = document.getElementById('astore').contentDocument.body.offsetHeight;
				else if(document.getElementById('astore').contentDocument.document.documentElement.offsetHeight)
					var t = document.getElementById('astore').contentDocument.document.documentElement.offsetHeight;
					
				//document.body.offsetHeight
				//document.documentElement.offsetHeight
				document.getElementById('astore').style.height = h;
			}
			else if(document.all) {
				var h = document.frames('astore').document.body.scrollHeight;
				document.all.astore.style.height = h;
			}
			DebugDump(t,'t '+t);
			DebugDump(h,'h '+h);
			//alert(document.astore.width)
				
		   //var i = new Ext.ux.ManagedIframePanel("astore");
		   // Replace the iFrames document structure with the response from the requested URL.
		   //src="http://astore.amazon.de/br432t-21"
		 //  i.load("http://astore.amazon.de/br432t-21", "");			
			
		}*/	
		
		

			
		/*
		 * show elements with id
		 */
		 /*$$('.show-container').each(function(input) {
		 		//DebugDump(input,'input '+input.id);
				if(input.checked) {
					$$('.'+input.readAttribute('title')).each(function(hipt) { hipt.setStyle({visibility: 'visible'})});
				}

				input.observe('click', function() {
					DebugDump(input,'input onclick ');
					if(input.checked) {
						$$('.'+input.readAttribute('title')).each(function(hipt) { hipt.setStyle({visibility: 'visible'})});
					}
				});
				
				input.observe('focus', function() {
					DebugDump(input,'input focus');
					if(input.checked) {
						$$('.'+input.readAttribute('title')).each(function(hipt) { hipt.setStyle({visibility: 'visible'})});
					}
				});
				
				input.observe('blur', function() {
					DebugDump(input,'input blur');
					if(!input.checked) {
						$$('.'+input.readAttribute('title')).each(function(hipt) { hipt.setStyle({visibility: 'hidden'})});
					}
				});		 	 
		 });		
		*/
	}
	
	this.clearOnFocus = function() {
		/**
		* Clears all input/textareas with classname "clearonfocus"
		* on focus-Mouseevent.
		*/
		$$('.clearonfocus').each(function(input) {
			input._defaultValue = input.readAttribute('title');
			input.observe('focus', function(ev) {
				if(input.value == input._defaultValue)
				{
					input.value = '';
				}
			});
			input.observe('blur', function(ev) {
				if(input.value == '') {
					input.value = input._defaultValue;
				}
			});
			
		});	
	}
	
	// Statistic
	//---------------------------------------------------------------------------------------
	this.statExtLinks = function(content_key,sid,type) {		
		var postkey = '';
		var saveurl = '/php-os/app_local/scripts/update.php';
		postkey += 'noxml=1';
		postkey += '&fields[customer_sid]=' + URLEncode(sid);
		postkey += '&fields[flag_type]=' + URLEncode(type);
		postkey += '&control[method]=insertObj';
		postkey += '&control[class]=CustomerStatistic';
		
		statAjax = new ajax();
		statAjax.initialize(saveurl, {method:'post', postBody:postkey});
	}

	this.confirmDeleteStatistic = function(customer_sid) {
		//var responseData = Ext.util.JSON.decode(response.responseText);//passed back from server
		var confirmwatchlistmsg = Ext.MessageBox.show({
			//animEl:'watchlist',
			buttons:{yes:$L('yes'),no:$L('no'),cancel:$L('cancel')},//Ext.Msg.YESNOCANCEL,
			scope:this,
			icon:Ext.MessageBox.INFO,
			modal:false,
			msg: $L('delete-statistic?'),
			title:$L('Statistic'),
			minWidth:200,
			maxWidth:350,
			cls:'x-brautbox',
			fn:function(buttonId,text,opt) {
				if(buttonId == 'yes') {
					var postkey = '';
					var saveurl = '/php-os/app_local/scripts/update.php';
					postkey += 'noxml=1';
					postkey += '&fields[customer_sid]=' + URLEncode(customer_sid);
					postkey += '&control[method]=deleteAll';
					postkey += '&control[class]=CustomerStatistic';
					statdelAjax = new ajax();
					statdelAjax.initialize(saveurl, {method:'post', postBody:postkey,onComplete:function(){  } }); //location.href=window.location.href;
					confirmwatchlistmsg.hide();
				}
			}
		});			
	}
	
	// Watchlist
	//---------------------------------------------------------------------------------------
	
	this.addWatchList = function(sid,cat_sid,subcat_sid,searchphrase,flag_type) {
		if(object_login == '1') {
			var postkey = '';
			var saveurl = '/php-os/app_local/scripts/update.php';
			postkey += 'noxml=1';
			postkey += '&fields[rel_sid]=' + URLEncode(sid);
			postkey += '&fields[category_sid]=' + URLEncode(cat_sid);
			postkey += '&fields[subcategory_sid]=' + URLEncode(subcat_sid);
			postkey += '&fields[search_key]=' + URLEncode(searchphrase);
			if(flag_type) postkey += '&fields[flag_type]=' + URLEncode(flag_type);
			postkey += '&control[method]=insertCheckedObj';
			postkey += '&control[class]=UserWatchlist';
			
			statAjax = new ajax();
			statAjax.initialize(saveurl, {method:'post', postBody:postkey,onComplete:BB.showWatchListConfirmation});
		} else {
			
			Ext.MessageBox.show({
				animEl:'watchlist',
				buttons:{yes:$L('yes'),no:$L('no'),cancel:$L('cancel')},//Ext.Msg.YESNOCANCEL,
				scope:this,
				icon:Ext.MessageBox.INFO,
				modal:false,
				msg: $L('watchlist-register'),
				title:$L('Watchlist'),
				minWidth:200,
				maxWidth:350,
				cls:'x-brautbox',
				fn:function(buttonId,text,opt) {
					if(buttonId == 'yes') {
						window.location.href = '/anmelden';
					}
				}
			});			
		}
	}
	
	this.showWatchListConfirmation = function(response) {
		//var responseData = Ext.util.JSON.decode(response.responseText);//passed back from server
		var confirmwatchlistmsg = Ext.MessageBox.show({
			animEl:'watchlist',
			buttons:{yes:$L('yes'),no:$L('no'),cancel:$L('cancel')},//Ext.Msg.YESNOCANCEL,
			scope:this,
			icon:Ext.MessageBox.INFO,
			modal:false,
			msg: $L('watchlist-inserted-article'),
			title:$L('Watchlist'),
			minWidth:200,
			maxWidth:350,
			cls:'x-brautbox',
			fn:function(buttonId,text,opt) {
				if(buttonId == 'yes') {
					window.location.href = '/profil';
				}
			}
		});			
	}
	
	this.deleteWatchListItem = function(sid) {
		
		var postkey = '';
		var saveurl = '/php-os/app_local/scripts/update.php';
		postkey += 'noxml=1';
		postkey += '&fields[sid]=' + URLEncode(sid);
		postkey += '&control[method]=deleteObj';
		postkey += '&control[class]=UserWatchlist';
		statAjax = new ajax();
		statAjax.initialize(saveurl, {method:'post', postBody:postkey});	
		$('watchlistitem'+sid).remove();
	}
	
	// Category Search
	//---------------------------------------------------------------------------------------	
	this.setCategoryPath = function() {
		
		if(!$('field_category')) return false;
		var cv = $('field_category').value;
		if(cv.length>0) {
			document.forms['contentform'].action = cv;
		}
		
	}
	
	// Category Administration
	//---------------------------------------------------------------------------------------
	this.getCustomerSubCategories = function(catidx, sid, cc_sid, customer_sid) {
		
		var f_id = 'category'+catidx;
		var s_id = 'subcategory'+catidx;
		var s_el = Ext.get('subcategory'+catidx);
		if((!sid) || (sid.length == 0)) return false;
		var s_el_size = s_el.getViewSize();
		$('catindi'+catidx).style.visibility = 'visible';
		s_el.slideOut('t',{
			easing: 'easeIn',
			duration: .25,
			useDisplay:true,
			//concurrent:true,
			scope:this,
			callback:function() {
				this.loadSubCategory(catidx, sid, cc_sid, customer_sid);
			}
		});		
	}
	
	this.loadSubCategory = function(catidx, sid, cc_sid, customer_sid) {
		
		var f_id = 'category'+catidx;
		var s_id = 'subcategory'+catidx;
		
		// get categories per ajax
		var params = 'noxml=1&triggers=ajaxgetcustomercategories&category_sid='+sid+'&customer_category_sid='+cc_sid+'&customer_sid='+customer_sid+'&catidx='+catidx;
		Ext.Ajax.request({   
				url: '/ajax/dotrigger',
				method: 'POST', 
				params: params,
				scope:this,
				failure:function(response,options){
					Ext.MessageBox.alert('Warning','Could not load subcategories, please contact the administrator.');
				},      
				success:function(response,options){
					var responseData = Ext.util.JSON.decode(response.responseText);//passed back from server
					this.buildSubcategories(responseData);
			
				}                                   
			 }
		);	
	}
	
	this.buildSubcategories = function(response) {
		
		var meta = response['metaData'];
		var data = response['data'];
		var tmpl = '';
		
		for(i=0;i<data.length;i++) {
			//<div class="spacer-small"></div>
			var tmpl = '<h3 class="nomargin">' + data[i].description + '</h3><div class="categoryCheck"><ul>';
			for(s=0;s<data[0].items.length;s++) {
				tmpl += '<li>';
				tmpl += '<label for="fields_root_editor_addltbftr_'+ meta.catidx +'_customer_subcategories_subcategory_' + data[i].flag_type + '_'+ s +'" class="" title="'+ data[i].items[s].list_label +'">';
				// checked ?
				tmpl += '<input type="checkbox" name="fields[root.editor.addltbftr.'+ meta.catidx +'.customer_subcategories][subcategory_' + data[i].flag_type + '][]"';
				tmpl += ' id="fields_root_editor_addltbftr_'+ meta.catidx +'_customer_subcategories_subcategory_' + data[i].flag_type + '_'+ s +'" value="'+ data[i].items[s].list_value +'" class="checkbox"';
				tmpl += ' '+ data[i].items[s].listextras +'/>';
				tmpl += ''+ data[i].items[s].list_label +'</label></li>';				
			}
			tmpl += '</ul><div class="fixfloat"></div></div><div class="spacer"></div>';
		}		
		$('subcategory'+meta.catidx).innerHTML = tmpl;
		Ext.get('subcategory'+meta.catidx).slideIn('t',{
			easing: 'easeIn',
			duration: .5,
			useDisplay:true,
			scope:this
			//,concurrent:true
		});	
		$('catindi'+meta.catidx).style.visibility = 'hidden';
	}
	
	this.addCustomerCategory = function(catidx) {

		// display select
		$('categorysel'+catidx).style.display = '';
		var categorytitle = $('categorytitle'+catidx);
		categorytitle.innerHTML = $L('choose_cat_title');
		categorytitle.style.cursor = '';
		categorytitle.onClick = function() { return false; };
		var catidx = parseInt(catidx);
		if($('category'+(catidx+1))) {
			$('category'+(catidx+1)).style.display = '';
		}
	}
	
	this.observeMembership = function(catidx) {
		
		if($('fields_root_editor_membership').value != 'premium') {
			if(!$('subcategory'+catidx)) return false;
			checkboxes = $('subcategory'+catidx).select('input');
			if((!checkboxes) || (typeof checkboxes != 'object') || checkboxes.length == 0) return false;
			var countChecks = 0;
			for(i=0;i<checkboxes.length;i++) {
				if(checkboxes[i].checked) countChecks++;
			}
			
			if(countChecks >= 3) {
				for(i=0;i<checkboxes.length;i++) {
					if(checkboxes[i].checked == false) this.disable(checkboxes[i]);
				}
			} else {
				for(i=0;i<checkboxes.length;i++) {
					if(checkboxes[i].checked == false) this.enable(checkboxes[i]);
				}				
			}
		}
		
	}
	
	//---------------------------------------------------------------------------------------
	this.disable = function(obj) {
		for(id in obj) {
			//DebugDump(obj.id,id);
			if($(obj.id)) {
				$(obj.id).addClassName('disabled');
				$(obj.id).disabled = true;
			}
		}			
	}
	
	this.enable = function(obj) {
		for(id in obj) {
			//DebugDump(obj.id,id);
			if($(obj.id)) {
				$(obj.id).removeClassName('disabled');
				$(obj.id).disabled = false;
			}
		}
	}
	
	//---------------------------------------------------------------------------------------
	this.hideContainer = function(obj) {
		for(id in obj) {
			//DebugDump(obj.id,id);
			if($(obj.id)) {
				$(obj.id).addClassName('hidden');
				//$(obj.id).disabled = true;
			}
		}			
	}
	
	this.showContainer = function(obj) {
		for(id in obj) {
			//DebugDump(obj.id,id);
			if($(obj.id)) {
				$(obj.id).removeClassName('hidden');
				//$(obj.id).disabled = false;
			}
		}
	}	
}

var BB = new Brautbox();



function NavAccordion(conf) {
	this.gConf = conf;
	this.baseConf={
		parentId:'navLeft', // any parent to search in for header and elements
		headClass:'toggler', // header for elements
		elementClass:'element', // hide these elements
		startIdx:0,
		ev:'click'
	};
	
	this.init = function() {
	
		this.conf = Ext.apply(this.baseConf,this.gConf); 
		var toggler = Ext.DomQuery.select('.'+this.conf.headClass,'#'+this.conf.parentId);
		var items = Ext.DomQuery.select('.'+this.conf.elementClass,'#'+this.conf.parentId);
		
		if(typeof navstartidx == 'undefined') navstartidx = 0;
		
		if(navstartidx && navstartidx < 0) this.aNav = -1; 
		else if(navstartidx && navstartidx > 0) this.aNav = navstartidx;
		else this.aNav = this.conf.startIdx;
		this.mainnavitems = new Object();
		
		for(i=0;i<toggler.length;i++) {
			var h3 = Ext.DomQuery.selectNode('h3',toggler[i]);
			var span = Ext.DomQuery.selectNode('span',h3);
			this.mainnavitems[i] = {
				head:Ext.get(h3),
				item:Ext.get(items[i]),
				arrow:Ext.get(span),
				vis:false,
				idx:i
			}
			
			if(this.mainnavitems[i].head && this.mainnavitems[i].head.hasClass('active')){
				this.aNav = i;
			}
			this.mainnavitems[i].item.setVisibilityMode(Ext.Element.DISPLAY);
			this.mainnavitems[i].item.setVisible(false,false); // mit animation?
			
			if(this.mainnavitems[i].head) {
				this.mainnavitems[i].head.addListener(this.conf.ev,function(ev,t,o) { 
					this.toggle(this.mainnavitems[this.aNav],o.tObj);
				},this,{tObj:this.mainnavitems[i]}); //,delay:500
			}
		}
		
		if(this.aNav >= 0 && this.mainnavitems[this.aNav]) {
			this.mainnavitems[this.aNav].arrow.setStyle('background', 'url("/images/icons/arrow-white-down.png") no-repeat 10px 3px');
			this.mainnavitems[this.aNav].item.setVisible(true,false);
			this.mainnavitems[this.aNav].vis = true;
		}
		
		this.initialANav = this.aNav;
		
		Ext.getBody().addListener('mousemove',function(ev,t,o) { 
			var tEl = Ext.get(ev);
			var tEl = ev.getTarget();
			while(tEl) {
				if(tEl.id && tEl.id == 'left') tEl = false;
				else if(tEl.parentNode) tEl = tEl.parentNode;
				else tEl = null;
			}
			
			if(tEl === null) {
				//DebugDump(tEl,'tEl')
				if(this.aNav != this.initialANav)
					this.toggle(this.mainnavitems[this.aNav],this.mainnavitems[this.initialANav]);			
			}
		},this,{
			buffer:3000
			//delegate:'left',
			//,stopPropagation:true
		});
		
	}

	this.toggle = function(s,t) {
	
		if(/*(this.aNav)
		&& (t) && (t.idx)
		&& */(t && this.aNav == t.idx)) return false;
		
		if(s) {
			s.arrow.setStyle('background', 'url("/images/icons/arrow-white-right.png") no-repeat 10px 1px');
			s.vis = false;				
			s.item.slideOut('t',{
				easing: 'easeIn',
				duration: .5,
				useDisplay:true,
				concurrent:true
			});
			s.item.fadeOut({endOpacity:0,duration:.5,concurrent:true});
		}

		if(t) {
			t.arrow.setStyle('background', 'url("/images/icons/arrow-white-down.png") no-repeat 10px 3px');
			t.item.slideIn('t',{
				easing: 'easeIn',
				duration: .5,
				useDisplay:true,
				concurrent:true
			});
			t.item.fadeIn({endOpacity:1,duration:.5,concurrent:true});
			t.vis = true;
			
			this.aNav = t.idx;
		}
	}
	
}

function Accordion(conf) {
	this.gConf = conf;
	this.baseConf={
		parentId:'navLeft', // any parent to search in for header and elements
		headClass:'toggler', // header for elements
		elementClass:'element', // hide these elements
		startIdx:0,
		ev:'click'
	};
	
	this.init = function() {
	
		this.conf = Ext.apply(this.baseConf,this.gConf); 
		var toggler = Ext.DomQuery.select('.'+this.conf.headClass,'#'+this.conf.parentId);
		var items = Ext.DomQuery.select('.'+this.conf.elementClass,'#'+this.conf.parentId);
		
		if(typeof accstartidx == 'undefined') accstartidx = 0;
		
		if(accstartidx >= 0) this.aNav = accstartidx;
		else this.aNav = this.conf.startIdx;
		this.mainnavitems = new Object();
		
		for(i=0;i<toggler.length;i++) {

			this.mainnavitems[i] = {
				head:Ext.get(toggler[i]),
				item:Ext.get(items[i]),
				vis:false,
				idx:i
			}
			
			if(this.mainnavitems[i].head.hasClass('active')){
				this.aNav = i;
			}
			this.mainnavitems[i].item.setVisibilityMode(Ext.Element.DISPLAY);
			this.mainnavitems[i].item.setVisible(false,false);
			
			this.mainnavitems[i].head.addListener(this.conf.ev,function(ev,t,o) { 
				this.toggle(this.mainnavitems[this.aNav],o.tObj);
			},this,{tObj:this.mainnavitems[i]}); //,delay:500
		}
		
		if(this.mainnavitems[this.aNav]) {
			this.mainnavitems[this.aNav].item.setVisible(true,false);
			this.mainnavitems[this.aNav].vis = true;
		}
		
		this.initialANav = this.aNav;
		
	}

	this.toggle = function(s,t) {
		
		if(/*(this.aNav)
		&& (t) && (t.idx)
		&& */(this.aNav == t.idx)) return false;

		s.vis = false;				
		s.item.slideOut('t',{
			easing: 'easeIn',// 'easeOut',
			duration: .5,
			useDisplay:true,
			concurrent:true
		});
		s.item.fadeOut({endOpacity:0,duration:.5,concurrent:true});
		
		t.item.slideIn('t',{
			easing:'easeIn',// 'easeIn',
			duration: .5,
			useDisplay:true,
			concurrent:true
		});
		t.item.fadeIn({endOpacity:1,duration:.5,concurrent:true});
		t.vis = true;

		this.aNav = t.idx;
	
	}
	
}

//console.log('x typeof Ext: %o',typeof Ext);

if(typeof Ext == 'object') {

// application main entry point
Ext.onReady(function() {
 
    //Ext.QuickTips.init();

	/*Ext.menu.RangeMenu.prototype.icons = {
	  gt: '/javascripts/ext/plugins/img/greater_then.png', 
	  lt: '/javascripts/ext/plugins/img/less_then.png',
	  eq: '/javascripts/ext/plugins/img/equals.png'
	};
	Ext.grid.filter.StringFilter.prototype.icon = '/javascripts/ext/plugins/img/find.png';
	
	//Ext.layout.BorderLayout.SplitRegion.prototype.useSplitTips = true;
	
	Ext.state.Manager.setProvider(new Ext.ux.HttpProvider({
		 url:'/php-os/app_ajaxmanager/scripts/ext.state.manager.session.php'
		//,user:'1'
		//,session:'session'
		//,id:'1'
		,readBaseParams:{cmd:'readState'}
		,saveBaseParams:{cmd:'saveState'}
		,autoRead:true
		,initFN:function() {
			 CES.initViewport();
		}		
	//	,logFailure:true
	//	,logSuccess:true
	}));
	*/
	//Ext.state.Manager.getProvider().initState([{"name":"theme","value":"s%3Axtheme-default.css"}]);
	
	
	BB.init();
	//DebugDump(BB,'BB');
	var NAC = new NavAccordion({
		title:'Menu'
	});
	NAC.init();

	if($('faqac')) {
		var FAC = new Accordion({
			title:'Menu',
			parentId:'faqac',
			headClass:'faqtoggler', // header for elements
			elementClass:'faqelement', // hide these elements
			startIdx:0,
			ev:'click'			
		});
		FAC.init();	
	}
	
	
	
	//Ext.state.Manager.setProvider(new Ext.state.SessionProvider({state: Ext.appState}));
	// on success of state manager load --> load the rest
	//var choose_timer = setTimeout(function(){ CES.initViewport(); }, 2000);
    
}); // eo function onReady

}

// Google search
function SearchHelper() {
	// called on form submit
	this.newSearch = function(form) {
	  if (form.input.value) {
		
		if(document.getElementById('cse')) {
			//this.execute(form.input.value);
		} else {
			// get form 
			document.getElementById('search-q').value = form.input.value;
			IF.justSubmit('gsearch');
		}
	  }
	  return false;
	}	
	
	this.fixCSS = function() {
		$$('input.gsc-search-button').each(function(input) {
			input.value = '';
		});	
		$$('input.gsc-input').each(function(input) {
			//input.value = 'Volltextsuche';
			//input.title = 'Volltextsuche';
			//input.style.width = '19.6em';
			//input.addClassName('clearonfocus');
			//input.style.backgroundColor = 'green';
		});			
	}
}

SH = new SearchHelper();



