/* ###################### */
/* # Loading JS Styles  # */
/* ###################### */
var jsCss = '<link href="' + PATH + '/inc/css/js-user.css" rel="stylesheet" media="screen, projection" />\n';
document.writeln(jsCss);

/* ###################### */
/* # Searchbox Features # */
/* ###################### */
var KQ = new Class ({
	initialize: function(name,searchBoxState,loggedIn) {
		// javascript on/off übermitteln	
		this.setSessionVar("javaScriptUser", "true");
        this.name = name;
		this.loggedIn = loggedIn;
		this.searchBoxState = searchBoxState;
		this.searchBox = $('searchBox');
		this.btnSavedSearches = $('btnSavedSearches');
		this.formSearchType = $('searchType');
		this.elContentMain = $('contentMain');
		this.elHelpPopup = $('helpPopup');
		this.elSearchNote = $('searchNote');
		
		// this kapseln
		var thisObj = this;
		
		// Inactive Buttons disablen
		$ES('BUTTON.inactive',$('searchBox')).setProperty('disabled','disabled');
		
		// Erweiterte Suche: Felder ein/ausblenden
		this.btnExtendedSearch = $('btnExtendedSearch');
		this.linkExtendedSearch = $$('.linkExtendedSearch');
		this.objSearchExtended = $('extendedSearch');
		this.objSearchNormal = $('normalSearch');
		this.btnTxtNormalSearch = "Normale Suche";
		this.btnTxtExtendedSearch = "Erweiterte Suche";
		if (this.btnExtendedSearch) {
			this.btnExtendedSearch.addEvent('click', function(e) {
				var ev = new Event(e).stop();
				thisObj.toggleSearchBox(); 
			});
		}
		$$('.linkExtendedSearch').addEvent('click', function(e) {
			var ev = new Event(e).stop();
			thisObj.toggleSearchBox(); 
		});
		// Gespeicherte Suchanfragen: Login ein/ausblenden
		this.btnSavedSearches = $('btnSavedSearches');
		if (this.btnSavedSearches) {
			this.btnSavedSearches.addEvent('click', function(e) {
				var ev = new Event(e).stop();
				thisObj.toggleLoginBox();
			});
		}
		
		// Suche speichern unter | Login ein/ausblenden
		this.objSearchSaveInput = $('iSearchSave');
		if (this.objSearchSaveInput) {
			this.objSearchSaveInput.addEvent('focus', function() { thisObj.toggleLoginBox(); });
			this.objSearchSaveInput.addEvent('keyup', function() { thisObj.toggleSaveBtn(); });
		};
		
		// Elements die onLoad versteckt werden sollen
		$$('.hideOnLoad').setStyle('display','none');
		
		// Buttons die onclick den SearchHinweis einblenden sollen
		$$('.btnSearch').addEvent('click',function() {
			thisObj.showSearchNote();									   
		});
		
		// Suchform bei Return-drücken submitten
		if ($('Suchformular')) {
			var submitSearch = function (event) {
				event = new Event(event);
				if (event.key == 'enter') {
					$('Suchformular').submit();
					thisObj.showSearchNote();
					//alert('submitted');
				}
			};
			$('Suchformular').addEvent('keypress', submitSearch);
		}
		
		// Contenthöhe checken, wg. Footer 
		this.resizeContent();
		
		// Felder die onFocus geleert werden sollen
		this.inputsToClearOnFocus = $ES('INPUT.clearItOnFocus');
		if (this.inputsToClearOnFocus) {
			this.inputsToClearOnFocus.addEvent('focus', function() { 
				if (!this.alt) this.alt = this.value;
				if (this.value == this.alt) this.value = '';
			});
			this.inputsToClearOnFocus.addEvent('blur', function() { 
				if (this.value == '') {
					this.value = this.alt;
				};
			});
		};
		
		// Felder die onFocus hintergrundbild gelöscht werden sollen
		this.inputsToResetOnFocus = $ES('INPUT.resetItOnFocus');
		if (this.inputsToResetOnFocus) {
			this.inputsToResetOnFocus.addEvent('focus', function() {
				if (typeof this.bgImg == 'undefined') {
					this.bgImg = this.style.backgroundImage;
				}
				this.setStyle('background-image','none');
			});
			this.inputsToResetOnFocus.addEvent('blur', function() { 
				if (this.value == '') {
					this.setStyle('background-image',this.bgImg);
				};
			});
		};
		
		$ES('.alertTitleOnClick').addEvents({
			'click':function(){
				alert(this.title);
			}							   
		})
		
		// TextAreas die onFocus gecountet werden sollen
		this.textareasToCountOnFocus = $ES('TEXTAREA.countItOnFocus');
		if (this.textareasToCountOnFocus) {
			this.countItTextLen = 200;
			this.countItText1 = "Noch";
			this.countItText2 = "Zeichen übrig";
			this.textareasToCountOnFocus.addEvents({
				'focus':   function() { thisObj.inputCounter(this); },
				'change':  function() { thisObj.inputCounter(this); },
				'keydown': function() { thisObj.inputCounter(this); },
				'keyup':   function() { thisObj.inputCounter(this); }
			});
		};
		
		// TextAreas die onFocus vergrößert werden sollen
		this.textareasToExpandOnFocus = $ES('TEXTAREA.expandItOnFocus');
		this.textareasToExpandOnFocus.addEvents({
			'focus': function() {
				this.removeClass('minimized');
			},
			'blur': function() {
				this.addClass('minimized');
			}
		})
		
		// Wenn Searchlist angezeigt wird, delete button aktivieren
		this.objSearchList = $('iSearchList');
		this.searchList = $('searchList');
		
		this.btnSaveSearch = $('btnSaveSearch');
		this.btnDelSearch = $('btnDelSearch');
		this.btnSQLSearch = $('btnSQLSearch');
		if (this.objSearchList) {
			this.objSearchList.addEvent('change', function() {
				thisObj.toggleDeleteBtn();
				thisObj.toggleSQLSearchBtn();
			});
		};
		
		// Login ein/ausblenden
		this.btnSearchLogin = $('btnSearchLogin');
		this.searchLogin = $('searchLogin');
		if (this.loggedIn) {
			if (this.searchLogin) this.searchLogin.remove();
			if (this.searchList) {
				this.searchList.removeClass('extendedSearch');
			}
		} else {
			if (this.searchList) this.searchList.remove();
		};
		
		// Autocompleter dranhängen
		this.inputsToAutocomplete = $ES('INPUT.autocomplete');
		if (this.inputsToAutocomplete) {
			this.inputsToAutocomplete.each( function (item, index) {
				var el = item;
				var indicator = new Element('div', {
						'class': 'autocompleter-loading', 
						'styles': {'display': 'none' }
				}).setHTML('').injectAfter(el);
				var completer = new Autocompleter.Ajax.Json(el, PATH  + '/inc/lib/ajax.autocomplete.php?id='+el.id, {
					'onRequest': function(el) {
						indicator.setStyle('display', 'block');
					},
					'onComplete': function(el) {
						indicator.setStyle('display', 'none');
					}
				});
			});
		};

		// ResultItems Select onChange-action anhängen;
		this.objResultSort = $$('SELECT.resultSort');
		if (this.objResultSort) {
			var thisSelect = this.objResultSort;
			this.objResultSort.addEvent('change', function() {
				if (this.selectedIndex != 0)
					eval("parent.location='"+this.options[this.selectedIndex].value+"'");
			});
		};
		
		// Bot-Schutz: alle SPAN.emil mailto: attachen
		this.objMailAdressen = $$('SPAN.emil');
		if (this.objMailAdressen) {
			this.objMailAdressen.each(function(item,index) {
				var email = item.getText().split("").reverse().join("");
				var newMail = new Element('a',{
					'href': 'mailto:' + email
				});
				newMail.innerHTML = email;
				item.replaceWith(newMail);
			});	
		};
		
		// allen el.openHelp einen open-Help-Event anhängen
		$$('A.openHelp').addEvent('click', function(e) {
			var ev = new Event(e).stop();
			thisObj.openHelp(this);
		});
		
		// allen el.openWin einen window.open-Event anhängen
		$$('A.openWin').addEvent('click', function(e) {
			var ev = new Event(e).stop();
			thisObj.openWindow(this);
		});
		
		// allen el.confirmOnClick einen Confirm-Event geben
		$$('A.confirmOnClick').addEvent('click', function(e) {							   
			return confirm(this.title);
		});
		
		// allen INPUT.pwCheck einen Passwort-Checker mitgeben
		$$('INPUT.pwCheck').addEvent('keyup', function() {
			thisObj.rateThisPw(this,'pwCheck');										   
		});
		
		
		$$('A.openSubNavi').each(function(item,index) {
			var parentLi = item.getParent();
			var childUl = parentLi.getElement('ul');
			// highlight setzen und subnavi offenlassen
			item.addEvent('click',function() {
				this.addClass('selected');						   
			});
			parentLi.addEvent('click',function() {
				parentLi.addClass('open');
			});
			if (window.ie6) {
				// ie bekommt Subnavi-Event hinzufügen (ie6 versteht ja kein LI:hover)
				parentLi.addEvents({
					'mouseover':function(){
						childUl.setStyle('display','block');
					},
					'mouseout':function(){
						childUl.setStyle('display','none');
					}
				});
			};
		});
		
		$$('INPUT.fillItWith').each(function(item,index) {
			var thisItem = item;
			var sourceEl = item.className.indexOf('el-');
			if (sourceEl != -1) {
				var sourceElId = item.className.substr(sourceEl+3,item.className.length);
				var sourceEl = $(sourceElId);
				var elTag = sourceEl.tagName.toLowerCase();
				if (elTag == 'input') {
					sourceEl.addEvents({
						// input element - onchange
						'keydown': function() {	
							thisItem.value = this.value; 
						},
						'keyup': function() {
							thisItem.value = this.value;
						}
					});
				} else if (elTag == 'select') {
					// VORWAHLEN aus functions.inc.php
					// wirft Fehler deshalb erstmal raus
					// ---
					/*
					if(typeof VORWAHLEN[sourceEl.value] != 'undefined') {
						thisItem.value = VORWAHLEN[sourceEl.value];	// aktuelle Vorwahl setzen
					}
					sourceEl.addEvent('change',function() {
						if (typeof VORWAHLEN[this.value] != 'undefined') {
							thisItem.value = VORWAHLEN[this.value];	// onchange setzen	
						} else {
							thisItem.value = '';
						} 
					});
					---/
					*/
				}
			};
		});
		
		// Diverse FormPreview-Events attachen
		this.elFormPreview = $('formPreview');
		if (this.elFormPreview) {
			var el = $E('BUTTON.btnPreviewForm');
			if(el) el.addEvent('click',function(e) {
				var ev = new Event(e).stop();
				thisObj.formPreviewGenerate();
			});
		}
		this.toggleSearchBox(this.searchBoxState);
				
		// Länder Select onChange-action anhängen;
		this.objLaender = $$('SELECT.updateProvinzen');
		this.elProvinzen = $('iProvinzen');
		//this.elLandVorwahl = $('lLandVorwahl');
		this.elLandVorwahl = $('iLandVorwahlTel');
		this.elLandVorwahlFax = $('iLandVorwahlFax');
		if (this.elProvinzen || this.elLandVorwahl || this.elLandVorwahlFax) {
			thisObj.formLandVorwahlGenerate();
			if(this.objLaender){
				this.objLaender.addEvent('change',function (e){		
						//var ev = new Event(e).stop();
						thisObj.formLandVorwahlGenerate();
						thisObj.formProvinzenGenerate();
				});
			}
		};
		
		// öffnungszeiten speichern
		this.elSaveOpenTimes= $('btnSaveTime');
		if (this.elSaveOpenTimes) {
			this.elSaveOpenTimes.addEvent('click',function (){
				$('cmdField').value='save_ot';
			});
		};
		
		// öffnungszeiten löschen
		this.elDelOpenTimes= $('btnDelOeffnungszeit');
		if (this.elDelOpenTimes) {
			this.elDelOpenTimes.addEvent('click',function (){
				$('cmdField').value='del_ot';
			});
		};
		
		// Ansprechpartner bearbeiten
		this.elEditAnsp= $$('BUTTON.btnEditAnsp');
		this.thisForm = $('formAddAnsp');
		if (this.elEditAnsp) {
			//alert(this.elEditAnsp.length);
			for (var x = 0; x < this.elEditAnsp.length; x++) {
		  		 this.elEditAnsp[x].addEvent('click',function (){
					$('cmdField').value='edit_Ansp';
					//document.getElementById("formAddAnsp").id =this.value;
					thisObj.setSessionVarSubmit('id',this.value);
					//document.getElementById("formAddAnsp").id =this.value;
					//thisObj.thisForm.submit();
					
					//$('formAddAnsp').id=this.value;
					//$('formAddAnsp').submit();
					//alert("EditAnsp3");
				});
		   }
	   };
	   
		// Ansprechpartner löschen
		this.elDelAnsp= $$('a.btnDelAnsp');
		if (this.elDelAnsp) {
			for (var x = 0; x < this.elDelAnsp.length; x++)
		   {
				this.elDelAnsp[x].addEvent('click',function (){
					//alert("löschen");
					$('cmdField').value='del_Ansp';
					thisObj.setSessionVarSubmit('id',this.id.substr(10));
				});
			}
		};
		
		// Veranstaltung bearbeiten
		this.elEditAus= $$('BUTTON.btnEditAus');
		this.thisForm = $('formAddAnsp');
		if (this.elEditAus) {
			for (var x = 0; x < this.elEditAus.length; x++)
		   {
		  		 this.elEditAus[x].addEvent('click',function (){
					$('cmdField').value='edit_Aus';
					$('FormAusList').action='ausstellungsmeldung.php';
					$('AusID').value=this.id.substr(10);
					//thisObj.setSessionVarSubmit('id',this.id.substr(10));
				});
		   }
	   };
	   
		// Veranstaltung löschen
		this.elDelAus= $$('a.btnDelAus');
		if (this.elDelAus) {
			for (var x = 0; x < this.elDelAus.length; x++)
		   {
				this.elDelAus[x].addEvent('click',function (){
					$('cmdField').value='del_Aus';
					thisObj.setSessionVarSubmit('id',this.id.substr(9));
				});
			}
		};
		
		// Ausstellungsliste
		this.pAusListShort = $$('p.ausstellung_short');
		if(this.pAusListShort){
			for(var x = 0; x < this.pAusListShort.length; x++){
				this.pAusListShort[x].addEvent('click',function(){
					if($('ausstellung_'+this.id.substr(18))){
						thisObj.AusList_detail(this); 
					}else{
						thisObj.AusListShort_expand(this); 
					}
				});
			}
		};
		
		//this.pAusList = $$('h2.ausstellung');
		if(this.pAusList){
			for(var x = 0; x < this.pAusList.length; x++){
				this.pAusList[x].addEvent('click',function(e){
					//var ev = new Event(e).stop(); // Event nicht ausführen
					thisObj.AusList_detail(this); // "ausstellung_"+id
				});
			}
		}
		
		/*
		* Versteckt Elemente mit class .hideElementInTime nach 5Sec
		*/
		
		this.elementsToHide = $$('.hideElementInTime');
		this.elementsToHide.each(function(item,index){
			var newFx =  new Fx.Style(item, 'opacity', {
				'onComplete': function() {
					item.remove();
				}
			});
			
			var newFxFnc = function() {
				newFx.start(1,0);
			}
			var fxTimer = newFxFnc.delay(5000);
		});
		
		
		/*
		// Weblinks Orte
		this.weblinkorte = $$('div.weblink_orte');
		if(this.weblinkorte){
			for(var x = 0; x < this.weblinkorte.length; x++){
				this.weblinkorte[x].addEvent('click',function(){
						thisObj.weblinkorte_expand(this); // letzter Buchstabe der ID ist der Ortsanfangsbuchstabe
				});
			}
		}
		*/
    },
	clearField: function() {
		this.value = '';	
	},
	resetSearchBox: function() {
		if (!this.searchBox) return;
		// Reset der Searchbox - exclusive der noReset-Fields
		var noReset    = new Array('iSearchSave','iSearchLogin','iSearchPasswort','searchType');
		var now        = new Date();
		var day		   = now.getDate();
		var month	   = now.getMonth()+1;
		var year	   = now.getFullYear();
		var dateString = year+'-'+month+'-'+day;
		
		// Reset input text fields
		var fields = this.searchBox.getElements('INPUT[type=text]');
		fields.each(function(item,index){
			if (item.value != '' && noReset.contains(item.id) == false) {
				item.value = '';
				if (item.id == 'i_js_Zeit_Year_ID') item.value = year;
				if (item.id == 'i_js_ZeitVon_Year_ID') item.value = year;
				if (item.id == 'i_js_ZeitBis_Year_ID') item.value = year;
			}
		});
		
		// Reset Select fields
		var selects = this.searchBox.getElements('SELECT');
		selects.each(function(item,index){
			item.selectedIndex = 0;
		});
		
		/* Reset input checkbox fields
		var fields = this.searchBox.getElements('INPUT[type=checkbox]');
		fields.each(function(item,index){
			if (item.value != '' && noReset.contains(item.id) == false) {
				if (item.id == 'chk_datum') item.checked = false;
			}
		});
		*/
		
		// Reset input hidden fields
		var fields = this.searchBox.getElements('INPUT[type=hidden]');
		fields.each(function(item,index){
			if (item.name == 'i_js_Zeit') {
				//item.value = dateString;
				item.value = '';
				//i_js_Zeit_Object.hideElements(1);
				//i_js_Zeit_Object.setPicked(Today.getFullYear(),Today.getMonth(),Today.getDate());
			}
			if (item.name == 'i_js_ZeitVon'){
					//item.value = dateString;
					item.value = '';
					//i_js_ZeitVon_Object.hideElements(1);
			}
			if (item.name == 'i_js_ZeitBis'){
					//item.value = dateString;
					item.value = '';
					//i_js_ZeitBis_Object.hideElements(1);
			}
		});
		var selects = this.searchBox.getElements('SELECT');
		selects.setProperty('value','');
	},
	toggleSearchBox: function(toState) {
		if (!this.searchBox || !this.objSearchExtended) return;
		if (!toState && this.searchBoxState == 'normal')
			toState = 'extended';
		else if (!toState && this.searchBoxState == 'extended')
			toState = 'normal';
		
		// alert('toState: ' + toState + ' | this.searchBoxState: ' + this.searchBoxState) ;
		if (toState == 'normal') {
			this.objSearchExtended.setStyle('display','none');
			this.objSearchNormal.setStyle('display','block');
			var btnTxt = (typeof TXT_EXTENDED_SEARCH != "undefined") ? TXT_EXTENDED_SEARCH : 'Erweiterte Suche';
			this.btnExtendedSearch.setText(btnTxt);
			if (this.btnSavedSearches) this.btnSavedSearches.setStyle('display','none');
			this.searchBoxState = 'normal';
			$('sCmd').value = 'QuickSearch';
			//btnSavedSearches
		} else if (toState == 'extended') {
			this.objSearchExtended.setStyle('display','block');
			this.objSearchNormal.setStyle('display','none');
			var btnTxt = (typeof TXT_NORMAL_SEARCH != "undefined") ? TXT_NORMAL_SEARCH : 'Normale Suche';
			this.btnExtendedSearch.setText(btnTxt);
			if (this.btnSavedSearches) this.btnSavedSearches.setStyle('display','block');
			this.searchBoxState = 'extended';
			$('sCmd').value = 'Search';
		}
		this.formSearchType.value = this.searchBoxState;
		this.setSessionVar("searchType", this.searchBoxState);
		this.resizeContent();
	},
	toggleLoginBox: function() {
		if (this.searchLogin) this.searchLogin.setStyle('display','block');
		if (this.searchList) this.searchList.setStyle('display','block');
	},
	toggleinfoZahlungsweise: function() {
		if (this.infoZahlungsweise.getStyle('display') == 'block') {
			this.infoZahlungsweise.setStyle('display','none')
		}else{
			this.infoZahlungsweise.setStyle('display','block')		
		}
	},
	toggleDeleteBtn: function() {
		if (this.objSearchList.selectedIndex != 0 && this.loggedIn) {
			this.setBtnEnabled(this.btnDelSearch);
		} else {
			this.setBtnDisabled(this.btnDelSearch);
		}
	},
	toggleSQLSearchBtn: function() {
		if (this.objSearchList.selectedIndex != 0 && this.loggedIn) {
			this.setBtnEnabled(this.btnSQLSearch);
		} else {
			this.setBtnDisabled(this.btnSQLSearch);
		}
	},
	toggleSaveBtn: function() {
		if (this.objSearchSaveInput.value.length && this.loggedIn) {
			this.setBtnEnabled(this.btnSaveSearch);
		} else {
			this.setBtnDisabled(this.btnSaveSearch);
		}
	},
	toggleSortBtn: function() {
		if (this.objSortList.selectedIndex != 0) {
			this.setBtnEnabled(this.btnSortSearch);
		} else {
			this.setBtnDisabled(this.btnSortSearch);
		}
	},
	setBtnDisabled: function(btn) {
		btn.setProperty('disabled','disabled');
		btn.addClass('inactive');
	},
	setBtnEnabled: function(btn) {
		btn.removeProperty('disabled');
		btn.removeClass('inactive');
	},
	openWindow: function(el,winFeatures) {
		var winTarget = (el.target) ? el.target : 'Veranstaltung';
		if (!winFeatures) {
			var winH = screen.height - 200;
			var winW = screen.width - 50;
			var winF = "location=yes,menubar=yes,resizable=yes,scrollbars=yes,toolbar=yes,status=yes,width="+winW+",height="+winH+",left=25,top=50";
		}
		//alert(winH);
		var newWin = window.open(el.href, winTarget, winF);
  		newWin.focus();
	},
	openHelp: function(el) {
		var thisObj = this;
		var url = PATH  + "/inc/lib/ajax.getHelpTopic.php?topic="+el.rel;
		var set = new Ajax(url, { 
			method: 'get',
			update: thisObj.elHelpPopup,
			onComplete: function() { 
				thisObj.initHelp() 
			}
		}).request();
	},
	toggleHelp: function() {
		this.elHelpBody.toggleClass('hidden');
		if (window.ie6) this.ie6HelpCheck();
	},
	ie6HelpCheck: function() {
		// allen selects visible:hidden
		var setVisibility = (this.elHelpPopup.getStyle('display') == 'block') ? 'hidden' : 'visible';
		$$('select').setStyle('visibility',setVisibility);
	},
	initHelp: function() {
		var thisObj = this;
		this.elHelpPopup.setStyle('display','block');
		this.elHelpHead = $('helpHeader');
		this.elHelpPopup.makeDraggable({'handle': thisObj.elHelpHead});
		this.elHelpBody = $('helpContent');
		this.elHelpBody.setStyle('max-height',Window.getHeight() - 200);
		this.elHelpBtnClose = $('helpClose');
		this.elHelpBtnToggle = $('helpToggle');
		this.elHelpBtnClose.addEvent('click',function(e){		
			var ev = new Event(e).stop();
			thisObj.elHelpPopup.setStyle('display','none');
			if (window.ie6) thisObj.ie6HelpCheck();
		});
		this.elHelpBtnToggle.addEvent('click',function(e){		
			var ev = new Event(e).stop();
			thisObj.toggleHelp();
		});
		this.elHelpHead.addEvent('dblclick',function(e){		
			var ev = new Event(e).stop();
			thisObj.toggleHelp();
		});
		if (window.ie6) this.ie6HelpCheck();
	},
	setSessionVar: function(name, value) {
		if (!name || !value) return;
		var url = PATH  + "/inc/lib/ajax.setSessionValue.php?var="+name+"&val="+value;
		var set = new Ajax(url, { method: 'get' }).request();
		// console.log('setSessionVar:'+name+'='+value);
	},
	setSessionVarSubmit: function(name, value) {
		if (!name || !value) return;
		var url = PATH  + "/inc/lib/ajax.setSessionValue.php?var="+name+"&val="+value;
		var set = new Ajax(url, { 
				method: 'get', 
				onComplete: function() {
					// console.log('setSessionVarSubmit-onComplete');
					//alert(document.forms.length);
					document.forms[0].submit();
				}
		}).request();
	
		// console.log('setSessionVar:'+name+'='+value);
	},
	toggleExhibitionDetails: function(id) {
		var elh = $('ausstellung_h_'+id);
		var elc = $('ausstellung_c_'+id);
		if (elc.getStyle('display') != 'block') {
			// zeigen
			elc.setStyle('display','block');
			elh.setStyle('display','none');
			if ($('ausstellung_tipp_'+id)) $('ausstellung_tipp_'+id).setStyle('display','block');
		} else {
			elc.setStyle('display','none');
			elh.setStyle('display','block');
			if ($('ausstellung_tipp_'+id)) $('ausstellung_tipp_'+id).setStyle('display','none');
		}
	},
	AusListShort_expand: function(obj){
		if(!obj)return;
		var AusListShort = obj;
		//var contentalt = AusListShort.firstChild;
		//foo=AusListShort.removeChild(contentalt);
		var id = AusListShort.id.substr(18); //ausstellung_short_
		var url = PATH  + "/inc/lib/ajax.generateAusListShort_expand.php?id="+id+"#ausa_"+id;
		var set = new Ajax(url, { 
				method: 'post', 
				update: AusListShort,
				onComplete: function() {
					// console.log('AusListShort_expand-onComplete');
				},
				evalScripts: true
		}).request();
	},
	AusList_detail: function(obj){
		if(!obj)return;
		var AusList = obj;
		var id = AusList.id.substr(12); // ausstellung_
		var url = PATH  + "/inc/lib/ajax.generateAusList_detail.php?id="+id;
		var set = new Ajax(url, { 
				method: 'get',
				update: AusList,
				onComplete: function() {
					// console.log('AusListShort_expand-onComplete');
				},
				evalScripts: true
		}).request();
	},
	inputCounter: function(el) {
		var strLen = el.value.length;
		if (strLen == 1 && el.value.substring(0,1) == " ") {
			el.value = "";
			strLen = 0;
		}
		if (strLen > this.countItTextLen) {
			el.value = el.value.substring(0,this.countItTextLen);
			charsLeft = 0;
		} else {
			charsLeft = this.countItTextLen - strLen;
		}
		$(el.id + 'Counter').setHTML(this.countItText1 + " " + charsLeft + "<br />" + this.countItText2 );
		// console.log('el.id:' + el.id + ' | strLen:'+strLen);	
	},
	addFormPreviewEvents: function() {
		var thisObj = this;
		var thisPrintBtn = $E('BUTTON.btnPrintPreview');
		if (thisPrintBtn) {
			thisPrintBtn.addEvent('click',function(e) {
				var ev = new Event(e).stop();
				thisObj.formPreviewPrint();
			});
		}
		var thisCloseBtn = $('btnCloseFormPreview');
		if (thisCloseBtn) {
			thisCloseBtn.addEvent('click',function(e) {
				var ev = new Event(e).stop();
				thisObj.formPreviewClose();
			});
		}
	},
	formPreviewGenerate: function() {
		// console.log('formPreviewGenerate');
		var thisObj = this;
		var thisForm = $('formAddEvent');
		var thisPreview = this.elFormPreview;
		if (!thisForm) return;
		var url = PATH  + "/inc/lib/ajax.generatePreview.php";
		var set = new Ajax(url, { 
			method: 'post',
			data: thisForm,
			update: thisPreview,
			onComplete: function() {
				// console.log('formPreviewGenerate-onComplete');
				thisPreview.setStyle('display','block');
				thisObj.addFormPreviewEvents();
			},
			evalScripts: true
		}).request();
		// console.log('formPreviewGenerate:'+thisForm);
	},
	formPreviewPrint: function() {
		var url = PATH  + "/inc/lib/html.printPreview.php";
		var previewWin = window.open(url, 'Preview');
	},
	formPreviewClose: function() {
		this.elFormPreview.empty();
		this.elFormPreview.setStyle('display','none');
	},
	stringContains: function(strText, strPattern) {
		for (i = 0; i < strText.length; i++) {
			if (strPattern.indexOf(strText.charAt(i)) > -1) return true;
		}
		return false;
	},
	ratePw: function() {
		var thisClassName = 'pwCheck';
		var el = $E('input.'+className);
		var thisObj = this;
		el.addEvent('keyup', function() {
			thisObj.rateThisPw(this,thisClassName);										   
		});
	},
	rateThisPw: function(el,className) {
		pwSting = el.value;
		pwClass = className;
		nSteps= 5;
		nCombi = 0;
		if (this.stringContains(pwSting, "0123456789")) nCombi++;
		if (this.stringContains(pwSting, "abcdefghijklmnopqrstuvwxyz")) nCombi++;
		if (this.stringContains(pwSting, "ABCDEFGHIJKLMNOPQRSTUVWXYZ")) nCombi++;
		if (this.stringContains(pwSting, ",;:-_=+|//?^&!.@$£#*()%~<>{}[]")) nCombi++;
		
		nStrongness = nCombi;		
		if (nCombi >= 3) {
			// mindest Kombination von 3, dann zählt auch die Textlänge /6
			nStrongness += Math.round(pwSting.length/6);
			if (nStrongness > nSteps) nStrongness = nSteps;
		} else if (nCombi >= 2) {
			// mindest Kombination von 2, dann zählt auch die Textlänge /7
			nStrongness += Math.round(pwSting.length/7);
			if (nStrongness > nSteps) nStrongness = nSteps;
		} else if (nCombi >= 1) {
			// mindest Kombination von 1, dann zählt auch die Textlänge /8
			nStrongness += Math.round(pwSting.length/8);
			if (nStrongness > nSteps) nStrongness = nSteps;
		}
		$(pwClass+'Bar').className = pwClass + nStrongness;
		// console.log(nStrongness);
	},
	formProvinzenGenerate: function() {
		// console.log('formProvinzenGenerate');
		var thisObj = this;
		var thisForm = $$('FORM')[0]; //Ausstellung eintragen
		var thisProvinzen = this.elProvinzen;
		var thisLaender = this.objLaender;
		if (!thisForm) return;
		var url =PATH  + "/inc/lib/ajax.generateProvinzen.php";
					//parameters: thisLaender.value,
		var set = new Ajax(url, { 
			method: 'post',
			data: thisForm,
			update: thisProvinzen,
			onComplete: function() {
				// console.log('formProvinzenGenerate-onComplete');
				//thisPreview.setStyle('display','block');
				//thisObj.addFormPreviewEvents();
			},
			evalScripts: true
		}).request();
		// console.log('formProvinzenGenerate:'+thisForm);
	},
	formLandVorwahlGenerate: function() {
		// console.log('formLandVorwahlGenerate');
		var thisObj = this;
		//var thisForm = $('formAddEvent'); //Ausstellung eintragen
		var thisForm = $$('FORM')[0]; //Ausstellung eintragen
		var thisLandVorwahl = this.elLandVorwahl;
		var thisLandVorwahlFax = this.elLandVorwahlFax;
		var thisLaender = this.objLaender;
		if (!thisForm) return;
		var url =PATH  + "/inc/lib/ajax.generateLandVorwahl.php";
					//parameters: thisLaender.value,
		var set = new Ajax(url, { 
			method: 'post',
			data: thisForm,
			update: thisLandVorwahl,
			onComplete: function() {
				// console.log('formLandVorwahlGenerate-onComplete');
				//thisPreview.setStyle('display','block');
				//thisObj.addFormPreviewEvents();
			},
			evalScripts: true
		}).request();
		var set = new Ajax(url, { 
			method: 'post',
			data: thisForm,
			update: thisLandVorwahlFax,
			onComplete: function() {
				// console.log('formLandVorwahlGenerate-onComplete');
				//thisPreview.setStyle('display','block');
				//thisObj.addFormPreviewEvents();
			},
			evalScripts: true
		}).request();
		
		// console.log('formLandVorwahlGenerate:'+thisForm);
	},
	showSearchNote: function() {
		if (this.elSearchNote != null) {
			this.elSearchNote.setStyle('display','block');
		}
	},
	resizeContent: function() {
		if (this.elContentMain) {
			var elSize = this.elContentMain.getCoordinates().height;
			var adSize = $('marginal').getCoordinates().height;
			if (adSize > elSize) {
				// ads sind höher als der content
				//console.log('elContentMain'+adSize);
				$('footer').setStyle('top',adSize-elSize);
			} else if (elSize < window.getHeight()) {
				var topVal = window.getHeight() - elSize;
				$('footer').setStyle('top',topVal);
			}
		};	
	}
});


/* JS-Verschluesselung */
var UnCryptMailto = function(s) {
	var n=0;
	var r="";
	for(var i=0;i<s.length;i++) {
		n=s.charCodeAt(i);
		if (n>=8364) {n = 128;}
		r += String.fromCharCode(n-3);
	}
	return r;
}

/* JS-Verschluesselung init*/
var CryptMailto = function(s) {
	var n=0;
	var r="";
	for(var i=0;i<s.length;i++) {
		n=s.charCodeAt(i);
		if (n>=8364) {n = 128;}
		r += String.fromCharCode(n+3);
	}
	return r;
}

var linkTo_UnCryptMailto = function(s)	{
	location.href=UnCryptMailto(s);
}

/* Window-Events */
var Win = {
	onDomReady: function() {
		// do nothing
	},
	onLoad: function() {
		// Splashlayer ausfaden wenn vorhanden
		if ($('splash') != null) {
			var splashFx = new Fx.Style('splash', 'opacity', {
				onComplete: function() {
					// ausgeblendete Selects wieder einblenden.
					if(window.ie) $$('select').setStyle('visibility','visible');
				}							
			});
			$('splash').addEvents({
				'click': function(){
					splashFx.start(0);
				}		  
			});
			var splashDo = function() {
				splashFx.start(0);
			};
			splashDo.delay(2000);
		}
	},
	onResize: function() {
		// do nothing
	},
	onUnload: function() {
		// do nothing
	},
	getPrintLink: function(lang) {
		document.writeln('<a href="#" onclick="Win.printThis();return false">'+lang+'</a>');
	},
	getBackLink: function(lang) {
		document.writeln('<a href="#" onclick="history.back();return false">'+lang+'</a> | ');
	},
	printThis: function() {
		window.print();	
	},
	toogleDisplay: function(id) {
		var el = $(id);
		if (el) {
			el.style.display = (el.style.display != 'block') ? 'block' : 'none';	
		}
	}
}
window.addEvent('domready', Win.onDomReady);
window.onload = Win.onLoad;

/* ############## */
/* ##  js redirect      ## */
/* ############## */

function rd_location(url){
 	window.location.href=url;
}
 
