/*
* Request Class 
* fn: reqResult('func_name') <- ruft nach onComplete die benannte Function auf
* fn: replaceData('part', 'value') <-- bereich des requestreplace mit der value
*/
var verzRequest = new Class({
	
	Implements: [Options, Events],
	
	options: {
		root: 'http://www.engelberg.ch/images/'
		,uproot: 'http://www.engelberg.ch/upload/'
		,local: 0
		,debug: 1
	}
	
	,initialize: function(options){
		
		this.setOptions(options);
		this.reqData = this.loadData();
	}
	
	,loadData: function(){
		
		return {
			type: 'all'
			,user: 'engelberg'
			,table: {
				listingdatas: 'ld'
				,listingrows: 'lr'
				,listings: 'l'
			}
			,condition: {
				/*
				OR abfrage
				,0: {
					'm.sommer': '1',
					'm.winter':'1'
				}
				*/
			}
			,fields: 'lr.*,ld.*'
			,order: 'ld.id DESC'
			,language: 'de'
		}
	}
	
	,replaceData: function(part, value){
		
		this.reqData[part] = value;
	}
	
	,reqResult: function(onCompletFunc){
		
		if(this.options.debug == 1) debugStr = '&debug=1';
		else debugStr = '';
		
		new Request({
			url: 'index.php'
			,method: 'post'
			,data: 'mode=verzeichnis&local=' + this.options.local + debugStr +'&request=' + encodeURIComponent(JSON.encode(this.reqData))
			,noCache: true
			,onComplete: function(response){
				var req = JSON.decode(response);
				this[onCompletFunc](req);
			}.bind(this)
		}).send();
	}
});


var engelberg = new Class({
	
	Extends: verzRequest
	
	,options: {
		navID: ['unterkunft','gastronomie','aktivitaet','kultur_tradition','info','mice','pack','shop','planner']
		
		,dbArr: ['','gastro','info','kultur_tradition','mice','prospekte','unterkunft', 'news']
		,titelArr_de: ['AKTIVITÄTEN','GASTRONOMIE','ENGELBERG INFO','EVENTS & KULTUR','SEMINARE','PROSPEKTE','UNTERKÜNFTE / PACKAGES','NEWS']
		,titelArr_en: ['ACTIVITIES','GASTRONOMY','ENGELBERG INFO','EVENTS & CULTURE','MEETING/INCENTIVE','BROCHURES','ACCOMMODATIONS / PACKAGE DEALS','NEWS']
		
		,language: 'de'
	}
	
	,initialize: function(options){
		
		this.parent(options);
		
		// this.options.root = options.root;
		
		// this.showMainContent.bind(options);
		// this.reqResult('showMainContent');
		
		if(this.options.mode == 'home' && !directL) this.requestNews();
		
		this.buildSlidebox();
	}
	
	// Request der Startseite
	,requestNews: function(){
		
		this.reqData = {
			type: 'all'
			,user: 'engelberg'
			,table: {
				listingdatas_news: 'ld'
				,listingrows_news: 'lr'
				,listings_news: 'l'
			}
			,condition: {
				
			}
			,fields: 'lr.rubrikname, ld.*'
			,order: 'ld.datum DESC'
			,language: this.options.language
		}
		
		this.reqResult('buildNews');
	}
	
	// Aufba News der Startseite
	,buildNews: function(req){
		
		if(req != ''){
			this.options.req = req;
			
			
			count = 0;
			var newList = [];
			this.options.req.result.each(function(items, key){
				
				if(items.lr.rubrikname == 'Box'){
					newList[1] = items;
				}else{
					
					if(count > 0 && count < 3) newC = count + 1;
					else newC = count;
					
					newList[newC] = items;
				}
				count++;
			});
			
			this.options.req.result = newList;
		}
		
		count = 0;
		txt = '<table cellpadding="0" cellspacing="0" border="0"><tr>';
		this.options.req.result.each(function(items, key){
			
			var title = '', text = '', bild = '';
			
			if(items.lr.rubrikname == 'Box'){
				
				// titel
				if(items.ld.title) title = '<h2 class="title" style="color: #ffffff;">' + items.ld.title + '</h2>';
				
				// text
				tmp_text = items.ld.text;
				
				txt += '<td><div id="news_' + items.ld.id + '" class="newsboxbg"><div style="margin: 58px 6px 6px 10px; color: #ffffff;">' + title + tmp_text.text[0] + '</div></div></td>';
			}else{
				
				// titel
				if(items.ld.title) title = '<h2 class="title" style="color: #024595;">' + items.ld.title + '</h2><img id="newsline_' + items.ld.id + '" style="padding-bottom: 4px;" src="' + this.options.root + 'news_line.jpg" /><br />';
				
				// text
				if($defined(items.ld.text)){
					tmp_text = items.ld.text;
					if(tmp_text && tmp_text.text[0].indexOf('<hr>') != -1){
						newtxt = tmp_text.text[0].split('<hr>');
						text = newtxt[0];
					}else{
						text = tmp_text.text[0];
					}
				}else{
					text = '';
				}
				
				// bilder
				tmp_bild = items.ld.pictures;
				if(tmp_bild){
					pic = this.options.uproot + '218_verz_' + tmp_bild.media[0]["name"];
					bild = '<img src="' + pic + '" width="218">';
				}else{
					bild = ''; // <img src="' + this.options.root + 'x.gif" width="218" height="56">';
				}
				
				txt += '<td><div id="news_' + items.ld.id + '" class="newsbg"><div style="height:56px; overflow:hidden;">' + bild + '</div><div style="margin:6px;">' + title + text + '</div></div></td>';
			}
			
			if(key % 2 == 0) txt += '<td width="24"></td>';
			else txt += '</tr><tr><td colspan="3" height="24"></td></tr><tr>';
			
			/*
			count++;
			if(count == 2 && key != (req.result.length - 1)) {
				txt += '</tr><tr><td colspan="3" height="24"></td></tr><tr>';
				count = 0;
			}
			*/
		}, this);
		txt += '</tr></table>';
		
		$('c_main').set('html', txt);
		
		this.options.req.result.each(function(items, key){
			
			if(items.lr.rubrikname != 'Box'){
				
				newsEntry = $('news_' + items.ld.id);
				
				newsEntry.set('styles', {
					'cursor': 'pointer'
				});
				
				var addClick = function(){
					this.showDetailContent(items.ld.id, key, 'news');
				};
				var boundaddClick = addClick.bind(this);
				
				var addHover = function(){
					$('news_' + items.ld.id).getElements('h2').setStyle('color', '#b2241b');
					$('newsline_' + items.ld.id).set('src', this.options.root + 'news_line_a.jpg');
				};
				var boundaddHover = addHover.bind(this);
				
				var addOut = function(){
					$('news_' + items.ld.id).getElements('h2').setStyle('color', '#024595');
					$('newsline_' + items.ld.id).set('src', this.options.root + 'news_line.jpg');
				};
				var boundaddOut = addOut.bind(this);
				
				newsEntry.addEvent('click', boundaddClick);
				newsEntry.addEvent('mouseover', boundaddHover);
				newsEntry.addEvent('mouseout', boundaddOut);
			}
		}, this);
	}
	
	// textreload
	,textLoader: function(id){
		
		new Request.JSON({
			url: 'index.php',
			method: 'post',
			data: 'mode=ajax&id=' + id + '&reqCol=text, title',
			onComplete: function(response){
				
				if(response != undefined){
					/*
					response.text = 
					
					if(items.href.contains('ch.concentrator.net')){
						items.target = '_self';
						items.href = 'javascript: new Fx.Scroll(window).toTop(); showWin(\'\', \'' + items.href + '\')';
					}else if(items.href.contains('ch-engelberg.concentrator.net')){
						items.target = '_self';
						items.href = 'javascript: new Fx.Scroll(window).toTop(); showWin(\'\', \'' + items.href + '\')';
					}
					*/
					$('c_head').empty();
					/*
					if (response.title) {
						
						new Element('div', {
							'html': '<div style="padding: 7px 0 0 9px; color: #ffffff; font-weight: bold; font-size: 12px;">' + response.title + '</div>'
							,'styles': {
								'background': 'url(' + this.options.root + 'detail_titelbg.jpg) no-repeat'
								,'height': '44px'
							}
						}).inject($('c_head'));
					}
					*/
					if(response["text"]){
						new Element('div', {
							'html': response.text
							,'styles': {
								'padding-bottom': '15px'
							}
						}).inject($('c_head'));
					}
					
					mainTxtLink = $$('#c_head a');
					mainTxtLink.each(function(items, key){
						this.repButton(items, 'link');
					}, this);
				}
			}.bind(this)
		}).send();
	}
	
	,mainLoader: function(part, main, add, subadd){
		
		if(main == 'uebersichtsseiten' || main == 'topnavigation') return;
		
		// return bei reload naviclick
		if($('loadImg') && part != 'sub') return;
		
		if(part == 'main') this.resetSiteAnch(1);
		
		if(directL && part != 'sub') main = this.replaceUml(main);
		
		new Fx.Morph($('c_main'), {
			duration: 800
			,transition: Fx.Transitions.Sine.easeOut
			,onComplete: function(){
				
				$('c_main').setStyle('height', '');
				$('c_main').empty();
				
				if(this.options.language == 'de') loadTxt = 'Bitte warten';
				else loadTxt = 'Please wait';
				
				// Loader
				new Element('div', {
					'html': loadTxt + ' <img src="' + this.options.root + 'loader_b.gif">'
					,'styles': {
						'color': '#024595'
						,'text-align': 'center'
					}
				}).inject($('c_main'));
				
				if(part != 'main' && part != 'pack') $('c_head').empty();
				
				if(part == 'main'){
					
					if($type(add.toInt()) == 'number'){
						this.options.entryID = add;
						this.textLoader(add);
					}
					
					if(main == 'planner'){
						
						this.options.entryID = add;
						
						this.showSubNav(main, '');
						
						mySel.setOptions(this.options);
						mySel.loadResult();
					}else if(main == 'pack'){
						
						if(this.options.language == 'de') packid = 8;
						else packid = 17;
						
						this.showSubNav(main, '');
						this.mainLoader('pack', 'unterkunft', packid);
					}else{
						this.reloadContent(main, '');
					}
				}else if(part == 'matrix'){
					
					this.engelReq(main)
				}else if(part == 'info'){
					
					$('c_head').empty();
					$('c_main').empty();
					
					if(main == 'wetter' || main == 'weather' || main == 'cams'){
						
						this.showSubNav(main, '');
						this.options.activDB = main
						
						if(main == 'wetter' || main == 'weather') this.buildWeather();
						else if(main == 'cams') this.buildCams();
					}
				}else{
					this.options.activSubN = add;
					this.buildMainAcc(main, add, subadd);
				}
			}.bind(this)
		}).start({
			'height': [0]
		});
	}
	
	,buildWeather: function(){
		
		var w = this.options.wetter;
		var r = this.options.root;
		var l = this.options.language;
		
		if(this.options.language == 'de'){
			
			var wTitel = 'Die Wetterprognosen für Engelberg';
			var wVorm = 'Vormittag';
			var wMitt = 'Nachmittag';
			var wNachm = 'Abend';
			var wAus = 'Weitere Aussichten';
		}else{
			
			var wTitel = 'The weather forecast for Engelberg';
			var wVorm = 'Morning';
			var wMitt = 'Afternoon';
			var wNachm = 'Evening';
			var wAus = 'More Forecast';
		}
		
		var detailT = new Element('div', {
			'html': '<div style="padding: 7px 0 0 9px; color: #ffffff; font-weight: bold; font-size: 12px;">' + wTitel + '</div>'
			,'styles': {
				'background': 'url(' + this.options.root + 'detail_titelbg.jpg) no-repeat'
				,'padding-bottom': '20px'
			}
		}).inject($('c_main'));
		
		// Zwischentitel
		new Element('div', {
			'html': '<b>' + eval('w.heute.tag_' + l) + '</b>, ' + eval('w.heute.datum_' + l) + '<br /><br />'
		}).inject($('c_main'));
		
		// Tagesaussicht
		new Element('div', {
			'html': '<img src="' + r + 'icons/' + w.heute.picV + '.png" style="padding: 0 10px 5px 0; float: left;"><br /><b>' + wVorm + '</b><br />' + w.heute.tempV + '°'
			,'styles': {
				'float': 'left'
				,'width': '165px'
			}
		}).inject($('c_main'));
		new Element('div', {
			'html': '<img src="' + r + 'icons/' + w.heute.picN + '.png" style="padding: 0 10px 5px 0; float: left;"><br /><b>' + wMitt + '</b><br />' + w.heute.tempN + '°'
			,'styles': {
				'float': 'left'
				,'width': '165px'
			}
		}).inject($('c_main'));
		new Element('div', {
			'html': '<img src="' + r + 'icons/' + w.heute.picA + '.png" style="padding: 0 10px 5px 0; float: left;"><br /><b>' + wNachm + '</b><br />' + w.heute.tempA + '°'
			,'styles': {
				'float': 'left'
				,'width': '165px'
			}
		}).inject($('c_main'));
		
		new Element('br', {
			'styles': {
				'clear': 'left'
			}
		}).inject($('c_main'));
		
		// Zwischentitel
		var detailT = new Element('div', {
			'html': '<div style="padding: 7px 0 0 9px; margin-top: 15px; color: #ffffff; font-weight: bold; font-size: 12px;">' + wAus + '</div>'
			,'styles': {
				'background': 'url(' + this.options.root + 'detail_titelbg.jpg) no-repeat'
				,'padding-bottom': '20px'
			}
		}).inject($('c_main'));
		
		// beschriftung
		new Element('div', {
			'html': '<br /><br /><br /><br /><b>' + wVorm + '</b><br /><br /><br /><br /><b>' + wMitt + '</b>'
			,'styles': {
				'float': 'left'
				,'width': '110px'
			}
		}).inject($('c_main'));
		
		// Wochenaussicht
		new Element('div', {
			'html': '<b>' + eval('w.morgen.tag_' + l) + '</b><br />' + eval('w.morgen.datum_' + l) +
				'<img src="' + r + 'icons/' + w.morgen.picV + '.png" style="padding: 10px 10px 5px 0; float: left;"><br /><br />' + w.morgen.tempV + '°<br style="clear: left;" />' +
				'<img src="' + r + 'icons/' + w.morgen.picN + '.png" style="padding: 0 10px 5px 0; float: left;"><br /><br />' + w.morgen.tempN + '°<br />'
			,'styles': {
				'float': 'left'
				,'width': '110px'
			}
		}).inject($('c_main'));
		new Element('div', {
			'html': '<b>' + eval('w.umorgen.tag_' + l) + '</b><br />' + eval('w.umorgen.datum_' + l) +
				'<img src="' + r + 'icons/' + w.umorgen.picV + '.png" style="padding: 10px 10px 5px 0; float: left;"><br /><br />' + w.umorgen.tempV + '°<br style="clear: left;" />' +
				'<img src="' + r + 'icons/' + w.umorgen.picN + '.png" style="padding: 0 10px 5px 0; float: left;"><br /><br />' + w.umorgen.tempN + '°<br />'
			,'styles': {
				'float': 'left'
				,'width': '110px'
			}
		}).inject($('c_main'));
		new Element('div', {
			'html': '<b>' + eval('w.uumorgen.tag_' + l) + '</b><br />' + eval('w.uumorgen.datum_' + l) +
				'<img src="' + r + 'icons/' + w.uumorgen.picV + '.png" style="padding: 10px 10px 5px 0; float: left;"><br /><br />' + w.uumorgen.tempV + '°<br style="clear: left;" />' +
				'<img src="' + r + 'icons/' + w.uumorgen.picN + '.png" style="padding: 0 10px 5px 0; float: left;"><br /><br />' + w.uumorgen.tempN + '°<br />'
			,'styles': {
				'float': 'left'
				,'width': '110px'
			}
		}).inject($('c_main'));
	}
	
	,buildCams: function(){
		
		// if(this.options.language == 'de'){
			var camArr = [
				['Titlis Talstation (1\'000 m ü.M.)', '', '<img height="240" border="0" width="320" src="http://www.titlis.ch/webcam/live/talstationengelberg/talstationengelberg.jpg" />'],
				['Talstation Brunnibahn Dorf Engelberg (1\'000 m ü.M.)', 'Kamera-Standort: Talstation Engelberg Brunnibahn, Blick übers Dorf Engelberg zum Titlis', '<img height="240" border="0" width="320" src="http://www.brunni.ch/images/webcam/webcam02.jpg" />'],
				['Engelberg 1 (1\'050 m ü.M.)', 'Blick auf den Hahnen (2\'606 m ü.M.)', '<img height="240" border="0" width="320" src="http://www.tep.ch/cam3.jpg" />'],
				['Engelberg 2 (1\'050 m ü.M.)','', '<img height="240" border="0" width="320" src="http://www.tep.ch/cam1.jpg" />'],
				['Gerschnialp (1\'300 m ü.M.)', '', '<img height="240" border="0" width="320" src="http://www.titlis.ch/webcam/live/gerschnialp/gerschnialp.jpg" />'],
				['Trübsee (1\'800 m ü.M.)', '', '<img height="240" border="0" width="320" src="http://www.titlis.ch/webcam/live/berghoteltruebsee/berghoteltruebsee.jpg" />'],
				['Härzlisee Brunnihütte (1\'860 m ü.M.)', '', '<img height="240" border="0" width="320" src="http://www.brunni.ch/images/webcam/webcam05.jpg" />'],
				['Brunnistöckli (1\'860 m ü.M.)', 'Blick zum Klettersteig Brunnistöckli und den neuen Klettersteig "Zittergrat" (Grat auf der  linker Seite vom Brunnistöckli)', '<img height="240" border="0" width="320" src="http://www.brunni.ch/images/webcam/webcam03-d.jpg" />'],
				['Jochpass (2\'207 m ü.M.)', '', '<img height="240" border="0" width="320" src="http://www.titlis.ch/webcam/live/berghausjochpass/berghausjochpass.jpg" />'],
				['Stand (2\'450 m ü.M.)', 'Blick Richtung Trübsee', '<img height="240" border="0" width="320" src="http://www.titlis.ch/webcam/live/stationstand/stationstand.jpg" />'],
				['Skihütte Stand (2\'450 m ü.M.)', '', '<img height="240" border="0" width="320" src="http://www.titlis.ch/webcam/live/skihuettestand/skihuettestand.jpg" />'],
				['Jochstock (2\'556 m ü.M.)', 'Blick Richtung Trübsee', '<img height="240" border="0" width="320" src="http://www.titlis.ch/webcam/live/jochstock/jochstock.jpg" />'],
				['Titlis (3\'030 m ü.M.)', 'Blick auf Panorama. Aktuelles Wetterbild, täglich von 05.30 - 17 Uhr', '<img height="240" border="0" width="320" src="http://www.titlis.ch/webcam/live/titlis/titlis.jpg" />']
			];
		// }
		
		var detailT = new Element('div', {
			'html': 'LiveCams von Engelberg und Umgebung<br /><br />'
		}).inject($('c_main'));
		
		camArr.each(function(items, key){
			
			
			var toggler = new Element('div', {
				'id': 'toggler_' + key
				,'html': items[0]
				,'class': 'toggler'
			}).inject($('c_main'));
			
			camTxt = items[1];
			camPic = items[2].replace('/>', 'style="margin-bottom: 5px;" /><br />');
			
			var element = new Element('div', {
				'id': 'togglermain_' + key
				,'html': '<div style="padding: 5px 0 5px 0;">' + camPic + camTxt + '</div>'
				,'class': 'element'
			}).inject($('c_main'));
		});
		
		new Accordion($$('div.toggler'), $$('div.element'), {
			display: 0
			,opacity: 0
			,alwaysHide: true
			,onActive: function(toggler, element){
				
				toggler.removeClass('close');
				toggler.addClass('open');
				
			}
			,onBackground: function(toggler, element){
				
				toggler.removeClass('open');
				toggler.addClass('close');
				
			}
		});
	}
	
	,buildSlidebox: function(){
		
		wetterSlide = new BoxSlider({
			openButton: 'showW'
			,closeButton: 'hideW'
			,overBox: 'showWbox'
			,boxSize: [158, 694]
			,correction: [0, -60]
		});
		
		indoSlide = new BoxSlider({
			openButton: 'showWOne'
			,closeButton: 'hideWOne'
			,overBox: 'showWboxOne'
			,boxSize: [158, 694]
			,correction: [0, -60]
		});
		/*
		buchSlide = new BoxSlider({
			openButton: 'showWTwo'
			,closeButton: 'hideWTwo'
			,overBox: 'showWboxTwo'
			,boxSize: [158, 694]
			,correction: [0, -60]
		});
		*/
	}
	
	,closeAllBox: function(){
		
		wetterSlide.closeSlide($('showWbox'));
		indoSlide.closeSlide($('showWboxOne'));
		// buchSlide.closeSlide($('showWboxTwo'));
	}
	
	// Request für Subnavi -> Rubrik
	,buildSubnav: function(parentID){
		
		$(parentID + '_m').removeClass('mnavs');
		$$('#' + parentID + '_m ul').destroy();
		
		// Loader
		new Element('img', {
			'src': this.options.root + 'loader.gif'
			,'id': 'loadImg'
			,'width': 25
			,'height': 10
			,'border': 0
		}).inject($(parentID + '_m'));
		
		if(parentID != 'aktivitaet') parentID = '_' + parentID;
		else parentID = '';
		
		this.reqData = {
			type: 'all'
			,user: 'engelberg'
			,table: {}
			,condition: {
				'lr.language': this.options.language
			}
			,fields: 'lr.*'
			,order: 'lr.parentrID, position ASC'
		}
		this.reqData.table['listingrows' + parentID] = 'lr';
		
		this.reqResult('buildSubnavEnd');
	}
	
	// Bau der Subnavi aus dem Request
	,buildSubnavEnd: function(req){
		
		liPar = $('loadImg').getParent();
		liPar.addClass('mnavs');
		
		dbname = liPar.id.replace('_m','');
		ulEl = new Element('ul', {
			'id': dbname
			,'styles': {
				'display': 'block'
			}
		}).inject(liPar);
		
		var mainArr = [];
		var subArr = [];
		var mParent;
		count = 0;
		req.result.each(function(items, key){
			if(items.lr.parentrID == 0 && count == 0){
				mParent = items.lr.id;
			}else if(items.lr.parentrID == mParent){
				mainArr[count] = items.lr;
				count++;
			}else{
				if(!subArr[items.lr.parentrID]) subArr[items.lr.parentrID] = [];
				subArr[items.lr.parentrID].include(items.lr);
			}
		});
				
		// Adden von Hotels Ferienwohnungen / Formular MICE
		if(dbname == 'unterkunft'){
			
			
			if(this.options.language == 'de'){
				
				langCode = 1;
				langNameH = 'Hotelliste';
				langNameF = 'Ferienwohnungliste';
				langTxtH = 'Buchen - ' + langNameH;
				langTxtF = 'Buchen - ' + langNameF;
				
				langNameHs = 'Hotelsuche';
				langNameFs = 'Ferienwohnungsuche';
				langTxtHs = langNameHs;
				langTxtFs = langNameFs;
			}else{
				
				langCode = 2;
				
				langNameH = 'Hotellist';
				langNameF = 'Apartmentlist';
				langTxtH = 'Book - ' + langNameH;
				langTxtF = 'Book - ' + langNameF;
				
				langNameHs = 'Hotel search';
				langNameFs = 'Apartement search';
				langTxtHs = langNameHs;
				langTxtFs = langNameFs;
			}
			
			// hotel
			new Element('li', {
				'html': '<a href="javascript: showWin(\'' + langTxtHs + '\', \'http://ch-engelberg.concentrator.net/tosc.asp?OC=Engelberg&RG=OG&ID=1000005&FN=SRCH&FC=HO&TOSCNEW=TRUE&PLANNER=TRUE&LG=' + langCode + '\');" class="nav">' + langNameHs + '</a>'
			}).inject(ulEl);
			new Element('li', {
				'html': '<a href="javascript: showWin(\'' + langTxtH + '\', \'http://ch-engelberg.concentrator.net/tosc.asp?OC=Engelberg&RG=OG&ID=1000005&FN=LIST&FC=HO&TOSCNEW=TRUE&PLANNER=TRUE&LG=' + langCode + '\');" class="nav">' + langNameH + '</a>'
			}).inject(ulEl);
			
			// appart
			new Element('li', {
				'html': '<a href="javascript: showWin(\'' + langTxtFs + '\', \'http://ch-engelberg.concentrator.net/tosc.asp?OC=Engelberg&RG=OG&ID=1000005&FN=SRCH&FC=AP&TOSCNEW=TRUE&PLANNER=TRUE&LG=' + langCode + '\');" class="nav">' + langNameFs + '</a>'
			}).inject(ulEl);
			new Element('li', {
				'html': '<a href="javascript: showWin(\'' + langTxtF + '\', \'http://ch-engelberg.concentrator.net/tosc.asp?OC=Engelberg&RG=OG&ID=1000005&FN=LIST&FC=AP&TOSCNEW=TRUE&PLANNER=TRUE&LG=' + langCode + '\');" class="nav">' + langNameF + '</a>'
			}).inject(ulEl);
			
		}else if(dbname == 'mice'){
			
			if(this.options.language == 'de'){
				siteID = 311;
				langBuch = 'Anfrageformular';
			}else{
				siteID = 330;
				langBuch = 'Inquiry Form';
			}
			
			new Element('li', {
				'html': '<a href="javascript: $(\'c_main\').empty(); engelberg.textLoader(' + siteID + ')" class="nav">' + langBuch + '</a>'
			}).inject(ulEl);
		}else if(dbname == 'kultur_tradition'){
			
			if(this.options.language == 'de') langReq = 1;
			else langReq = 2;
			
			new Element('li', {
				'html': '<a href="javascript: showWin(\'Events\', \'http://ch.concentrator.net/tosc2/tosc.asp?OC=Engelberg&RG=OG&ID=1000005&CF=*ROOT2*&FC=EV&FN=LIST&LG=' + langReq + '\');" class="nav">Events</a>'
			}).inject(ulEl);
		}
		
		mainArr.each(function(items, key){
			
			var activID = items.id;
			var addAnch = new Element('a', {
			    'href': '#'
			    ,'class': 'nav'
			    ,'html': items.rubrikname
			    
			}, this);
			
			var liEl = new Element('li', {
				'id': 'subli_' + items.id
				,'events': {
					'click': function(e){
						
						this.options.entryID = '';
						
						liList = $$('li.snav');
						liList.each(function(classObj, ckey){
							classObj.removeClass('snav');
						});
						$('subli_' + items.id).set('class', 'snav');
						
						// activeDB für cookie (DB / subnavpos)
						this.options.activDB = dbname;
						this.options.activSubN = activID;
						
						this.options.subNav = this.replaceUml(addAnch.text);
						this.resetSiteAnch(2);
						
						this.mainLoader('sub', dbname, activID, subArr[activID]);
						
						$('c_head').setStyle('display', 'block');
						
					}.bind(this, activID, dbname, addAnch)
				}
			}).inject(ulEl);
			addAnch.inject(liEl);
			
			// Direktlink unternavigation
			if(directL){
				
				checkStr = this.replaceUml(items.rubrikname);
				if(checkStr == directL[1]){
					
					$('subli_' + items.id).set('class', 'snav');
					
					this.options.subNav = checkStr;
					this.resetSiteAnch(2);
					
					this.mainLoader('sub', dbname, activID, subArr[activID]);
				}
			}
			
		}, this);
		
		(function(){
			$('loadImg').destroy();
		}.delay(500));
	}
	
	,buildMainAcc: function(dbname, id, sublevel){
		
		if(dbname != 'aktivitaet') dbname = '_' + dbname;
		else dbname = '';
		
		this.options.mainAccord = sublevel;
		
		this.reqData = {
			type: 'all'
			,user: 'engelberg'
			,table: {
				
			}
			,condition: {}
			,fields: 'lr.*,ld.*'
			,language: this.options.language
		}
		
		this.reqData.table['listingdatas' + dbname] = 'ld';
		this.reqData.table['listingrows' + dbname] = 'lr';
		this.reqData.table['listings' + dbname] = 'l';
		
		if(dbname == '_info') this.reqData['order'] = 'ld.prioritaet, ld.firma ASC';
		else this.reqData['order'] = 'ld.prioritaet, ld.titel ASC';
		
		if(sublevel != undefined){
			idArr = []
			sublevel.each(function(items, key){
				idArr.include(items.id);
			});
			this.reqData.condition['lr.id'] = idArr;
		}else{
			this.reqData.condition['lr.id'] = id;
		}
		
		this.reqResult('showMainContent');
	}
		
	// Matrixrequest
	,matrixReq: function(reqPart){
		
		// zurücksetzten des Acc
		$('c_head').empty();
		this.options.mainAccord = false;
		this.showSubNav('');
		
		this.reqData = [];
		var condCount = 0;
		this.options.dbArr.each(function(item, key){
			
			this.reqData[key] = {
				type: 'all'
				,user: 'engelberg'
				,table:{
					'matrix': 'm'
				}
				,condition: {
					'ld.matrix =': 'm.id'
				}
				,fields: 'ld.*'
			};
			
			// tablestr
			if(item == '') ldDB = 'listingdatas';
			else ldDB = 'listingdatas_' + item;
			
			// table
			this.reqData[key].table[ldDB] = 'ld';
			// this.reqData[key].table[lDB] = 'l';
			
			// Sortierung
			if(item == 'info')this.reqData[key]['order'] = 'ld.prioritaet, ld.firma ASC';
			else if(item == 'gastro') this.reqData[key]['order'] = 'ld.prioritaet, ld.gastgeber ASC';
			else if(item == 'news') this.reqData[key]['order'] = 'ld.prioritaet, ld.title ASC';
			else this.reqData[key]['order'] = 'ld.prioritaet, ld.titel ASC';
			
			// matrix
			reqPart.each(function(reqItem, reqKey){
				
				if(reqItem.is_array){
					
					count = 0;
					itemArr = {};
					reqItem.each(function(keyItem, keyKey){
						
						itemArr["m." + keyItem] = 1;
						count++;
					}, this);
					
					this.reqData[key].condition["ld.language"] = this.options.language;
					this.reqData[key].condition[condCount] = itemArr;
					condCount++;
				}else{
					this.reqData[key].condition["ld.language"] = this.options.language;
					this.reqData[key].condition["m." + reqItem] = 1;
				}
			}, this);
			
		}, this);
		
		this.reqResult('showMainContent');
	}
	
	// Matrix auslesen -> matrixReq
	,engelReq: function(fields){
		
		var engelArr = [];
		var wann = [];
		var wer = [];
		var was = [];
		var wo = [];
		fields.each(function(item, key){
			
			if(item.checked){
				
				// Jahreszeit-Check
				if(item.name.contains('wann')) wann.include(item.value);
				else if(item.name.contains('wer')) wer.include(item.value);
				else if(item.name.contains('was')) was.include(item.value);
				else if(item.name.contains('wo')) wo.include(item.value);
			}
		}, this);
		
		if(wann.length > 1) engelArr.include(wann);
		else if(wann.length == 1) engelArr.include(wann[0]);
		if(wer.length > 1) engelArr.include(wer);
		else if(wer.length == 1) engelArr.include(wer[0]);
		if(was.length > 1) engelArr.include(was);
		else if(was.length == 1) engelArr.include(was[0]);
		if(wo.length > 1) engelArr.include(wo);
		else if(wo.length == 1) engelArr.include(wo[0]);
		
		// active Matrix req
		this.options.activDB = engelArr;
		
		this.matrixReq(engelArr);
	}
		
	,reloadContent: function(dbname, part){
		
		this.options.mainAccord = false;
		/*
		// Jahreszeit
		var j = new Date();
		var m = j.getMonth()+1;
		var d = j.getDate();
		if((m < 3) || ( (m == 3) && (d < 20) ) || ((m==12) && ( d > 20))){
			part = 'w';
		}else if ((m < 6) || ( (m == 6) && (d < 21))){
			part = 'f';
		}else if ((m < 9) || ((m==9) && (d < 23))){
			part = 's';
		}else{
			part = 'h';
		}
		
		var subNr = '';
		var value = {};
		var reqPart = [];
		switch(part){
			case "s":
				subNr = 1;
				reqPart = ["sommer"];
				break;
			case "w":
				subNr = 2;
				reqPart = ["winter"];
				break;
			case "g":
				subNr = 3;
				reqPart = [["fruehling", "sommer", "herbst", "winter"]];
				break;
			case "sw":
				subNr = 4;
				reqPart = [["sommer", "winter"]];
				break;
			case "f":
				subNr = 5;
				reqPart = ["familie"];
				break;
		}
		*/
		subNr = false;
		
		// activeDB für cookie
		this.options.activDB = dbname;
		
		// Navigationstatus
		this.showSubNav(dbname, subNr);
		
		if(dbname == "gastronomie"){
			
			// Gastrofinder
			gastro.initialize(this.options);
			gastro.loadFinder();
			return;
		}else if(dbname == 'prospekte'){
			
			this.reqData = {
				type: 'all'
				,user: 'engelberg'
				,table: {}
				,condition: {
					'lr.language': this.options.language
				}
				,fields: 'lr.*'
				,order: 'lr.parentrID, position ASC'
			}
			this.reqData.table['listingrows_prospekte'] = 'lr';
			
			this.reqResult('prospektMain');
			
		}else if(dbname == 'info' || dbname == 'unterkunft' || dbname == 'aktivitaet' || dbname == 'mice' || dbname == 'kultur_tradition'){
			
			// Unternavloading
			this.buildSubnav(dbname);
		}
		
		/*
		// Matrixrequest
		if(dbname == 'info'){
			
			reqPart.include('support');
		}else if(dbname == 'mice'){
			
			reqPart.include('business');
		}else{
			if(dbname == 'aktivitaet' || dbname == 'event'){
				//if(reqPart.is_array()) reqPart[0].include('unterhaltung');
			}
			reqPart.include(dbname);
		}
		this.matrixReq(reqPart);
		*/
		
		$('c_main').empty();
	}
	
	,prospektMain: function(req){
		
		var subC = 0;
		var mainEntry;
		var subEntry =[];
		req.result.each(function(items, key){
			
			if(key == 0){
				mainEntry = items.lr;				
			}else{
				subEntry[subC] = items.lr;
				subC++;
			}
		});
		
		this.buildMainAcc('prospekte', mainEntry.id, subEntry);
	}
	
	// Result von Stand. - Matrixrequest
	,showMainContent: function(req){
				
		var accordeon, mainAcc;
		if(this.options.mainAccord){
			accordeon = true;
		}
		
		// Einzelner Ausgabe-Array
		if(req.count && req.count.length > 1){
			
			var newReq = {};
			newReq["result"] = [];
			counter = 1;
			req.result.each(function(item, key){
				
				//newReq.count = newReq.count + req.count[key];
				if(item){
					item.each(function(sitem, skey){
						
						// Titel Bereich
						if(skey == 0){
														
							if(this.options.language == 'de') getMainT = this.options.titelArr_de[key];
							else getMainT = this.options.titelArr_en[key];
							
							newReq.result.include({
								maintitel: getMainT
								,dbpart: this.options.dbArr[key]
							});
						}
						
						if(sitem.ld.news_from){
							
							sitem.ld.bilder = sitem.ld.pictures;
							sitem.ld.pdf = sitem.ld.files;
							sitem.ld.titel = sitem.ld.title;
						}
						
						newReq.result.include(sitem);
						counter++;
					}, this);
				}
			}, this);
			
			// newReq.shuffle()
			this.options.req = newReq;
		}else{
			this.options.req = req;
		}
		
		// Bereinigung Contentbereich
		if (this.options.req.length == undefined && !accordeon) this.options.req = this.options.req;
		// else $('c_head').empty();
					
		$('c_main').empty();
		// $('main_content').setStyle('padding-top', '32px');
		
		// Auflistung
		if(accordeon){
			
			var aktivAcc;
			this.options.mainAccord.each(function(items, key){
				
				if (this.options.activAccord == 'toggler_' + items.id){
					
					aktivAcc = key;
					
					this.options.ssubNav = this.replaceUml(items.rubrikname);
					this.resetSiteAnch(3);
					
				} else if(directL && $type(directL[2].toInt()) != 'numeric'){
					
					checkStr = this.replaceUml(items.rubrikname);
					if(directL[2] == checkStr){
						aktivAcc = key;
						this.options.ssubNav = this.replaceUml(items.rubrikname);
						this.resetSiteAnch(3);
					}
				}
				
				var toggler = new Element('div', {
					'id': 'toggler_' + items.id
					,'html': items.rubrikname
					,'class': 'toggler'
				});
				toggler.inject($('c_main'));
				
				var element = new Element('div', {
					'id': 'togglermain_' + items.id
					,'html': '<br />'
					,'class': 'element'
				});
				
				if(ie6 != 1) element.setStyle('cursor', 'pointer');
				
				element.inject($('c_main'));
			}, this);
			
			if(ie6 != 1){
				
				mainAcc = new Accordion($$('div.toggler'), $$('div.element'), {
					display: -1
					,opacity: 1
					,onActive: function(toggler, element){
						
						(function(){
							tPos = toggler.getPosition();
							new Fx.Scroll(window, {
								offset: {
									'x': 0
									,'y': tPos["y"]
								}
							}
						).toTop()}).delay(650);
						
						this.options.activAccord = toggler.id;
						
						this.options.ssubNav = this.replaceUml(toggler.innerHTML);
						this.resetSiteAnch(3);
						
						toggler.removeClass('close');
						toggler.addClass('open');
						
					}.bind(this)
					,onBackground: function(toggler, element){
						
						toggler.removeClass('open');
						toggler.addClass('close');
						
						if(this.options.ssubNav == this.replaceUml(toggler.innerHTML)) this.resetSiteAnch(2);
					}.bind(this)
				});
			}
		}
		
		// Rücksetzung der Headerbilder
		this.options.headArr = [];
		
		// Contentadding
		var lastpart;
		var idLinkKey;
		if(directL){
				
				if($type(directL[2].toInt()) == 'number') var activD = directL[2].toInt();
				else if($type(directL[3].toInt())) var activD = directL[3].toInt();
		}
		this.options.req.result.each(function(items, key){
			
			var main;
			if(items.lr != undefined && $('toggler_' + items.lr.id)) addEl = $('togglermain_' + items.lr.id);
			else addEl = $('c_main');
			
			// Main Bereichstitel
			if(items.maintitel){
				
				main = new Element('div', {
					'html': '<div style="padding: 7px 0 0 9px; color: #ffffff; font-weight: bold; font-size: 12px;">' + items.maintitel + '</div>'
					,'styles': {
						'background': 'url(' + this.options.root + 'detail_titelbg.jpg) no-repeat'
						,'padding-bottom': '14px'
						,'height': '44px'
					}
				});
				lastpart = items.dbpart;
			
			// Einträge
			}else{
				if(lastpart == '') lastpart = 'aktivitaet'
				else if(lastpart == 'gastro') lastpart = 'gastronomie'
				main = this.outputMainContent(items, key, lastpart);
			}
			
			// Directlink Key
			if($defined(activD) && activD == items.ld.id) idLinkKey = key;
			
			main.inject(addEl);
		}, this);
		
		// Anzeige des Letzen activen Accordion
		if(!isNaN(aktivAcc) && ie6 != 1) mainAcc.display(aktivAcc);
		
		// activate after display bug
		if(accordeon && ie6 != 1){
			mainAcc.setOptions({alwaysHide: true});
		}
		
		// Directlink auf Haupteintrag
		if(idLinkKey) this.showDetailContent(activD, idLinkKey, lastpart);
		
		this.headPicSelect();
		
		// Zurücksetzten des Direktlink
		if(directL && aktivAcc){
			directL = false;
		}
		
		this.setSiteAnch();
		
		if(this.options.activDB == 'planner' && !$('planner2pdf') && $('travelCount').innerHTML > 0){
			
			var cHead = $('c_head');
			
			var addcHead = new Element('div', {
				'id': 'plannerButtons'
			}).inject(cHead);
			
			// PDF-Writer
			var plannerlink = new Element('div', {
				'class': 'button bdown'
			}).inject(addcHead);
			
			if(this.options.language == 'de') persTxt = 'Persönlicher Reiseführer';
			else persTxt = 'Individual travel guide';
			
			var cookieStr;
			new Element('a', {
				'id': 'planner2pdf'
				,'href': '#'
				,'target': '_blank'
				,'html': persTxt + ' (PDF)'
				,'styles': {
					'text-decoration': 'none'
					,'color': '#000000'
				}
				,'events': {
					'click': function(e){
						cookieStr = mySel.getCookieContent();
						$('planner2pdf').href = this.options.root + '../pdfgen/engelberg.php?request=' + cookieStr + '&pdf=1&language=' + this.options.language;
					}.bind(this, mySel, cookieStr)
				}
			}).inject(plannerlink);
			
			new Element('div', {
				'class': 'bend'
			}).inject(addcHead);
			
			// Delete all Cookies
			if($('travelCount').innerHTML > 0){
				
				var headInc = new Element('div', {
					'styles': {
						'margin': '0 0 0 370px'
					}
				}).inject(addcHead);
				
				if(this.options.language == 'de') var delStr = 'Alle Einträge löschen';
				else var delStr = 'Deleting all entries';
				
				new Element('a', {
					'id': 'delplanner'
					,'html': delStr
					,'styles': {
						'text-decoration': 'underline'
						,'color': '#000000'
						,'cursor': 'pointer'
					}
					,'events': {
						'click': function(e){
							mySel.delCookieContent();
							this.loadResult();
							
							$('plannerButtons').empty();
							if($defined($('travelCount'))) $('travelCount').set('text', '');
							new Fx.Scroll(window).toTop();
						}.bind(this, mySel)
					}
				}).inject(headInc);
			}
			
			new Element('br', {
				'styles': {
					'clear': 'both'
				}
			}).inject($('c_head'));
			
			new Element('br').inject($('c_head'));
		}
	}
	
	,outputMainContent: function(items, key, lastpart){
		
		// Entrydiv
		if(items.ld.bilder != ''){
			bj = items.ld.bilder;
			picbg = this.options.uproot + '171_verz_' + bj.media[0]["name"];
			
			// Headpic in der Übersicht
			this.options.headArr.include(bj.media[0]["name"]);
		}else{
			picbg = ''; //this.options.root + 'x.gif';
		}
		
		var main = new Element('div', {
			'id': 'main_' + key
			,'class': 'maindiv'
			,'html': ''
			,'styles': {
				'position': 'relative' 
				,'cursor': 'pointer'
				,'margin': '0 0 30px 0'
				,'background': 'url(' + picbg + ') no-repeat'
			}
		});
		
		// Text
		text = '<!-- ' + items.ld.id + ' //-->';
		if(items.ld.titel) text += '<h2 class="title" style="color: #024595;">' + items.ld.titel + '</h2><img id="title_' + key + '" src="' + this.options.root + 'title_line.jpg" style="padding-bottom: 6px;" /><br />';
		else if(items.ld.name) text += '<h2 class="title" style="color: #024595;">' + items.ld.name + '</h2><img id="title_' + key + '" src="' + this.options.root + 'title_line.jpg" style="padding-bottom: 6px;" /><br />';
		else text += '<h2 class="title" style="color: #024595;">' + items.ld.firma + '</h2><img id="title_' + key + '" src="' + this.options.root + 'title_line.jpg" style="padding-bottom: 6px;" /><br />';
		
		if(this.options.language == 'de') anzBett = 'Anzahl Betten: ';
		else anzBett = 'Number of beds: ';
		
		if(items.ld.betten) text += anzBett + items.ld.betten + '<br />';
		
		if(items.ld.firma){
			if(items.ld.firma && items.ld.name) text += items.ld.firma + '<br />';
			if(items.ld.firma && items.ld.adresse) text += items.ld.adresse + '<br />';
			if(items.ld.telefon) text += '<div class="button btel">' + items.ld.telefon + '</div><div class="bend"></div><br style="clear:both;" />';
			if(items.ld.mobile) text += '<div class="button bmob">' + items.ld.mobile + '</div><div class="bend"></div><br style="clear:both;" />';
			if(items.ld.email) text += '<div class="button bmail"><a href="mailto:' + items.ld.email + '">' + items.ld.email + '</a></div><div class="bend"></div><br style="clear:both;" />';
		}else if(items.ld.text){
			tj = items.ld.text;
			if(tj.text[0] != '') text += this.splitText(tj.text[0], 200) + ' ...';
			
			if(text.indexOf('<hr>') != -1) text = this.splitText(text, text.indexOf('<hr>')) + ' ...';
		}
		
		
		
		var addEntry = new Element('div', {
			'id': 'text_' + key
			,'class': 'maintxtclass'
			,'html': text
			,'styles': {
				'height': '103px'
				,'padding-left': '190px'
			}
			,'events': {
				'mouseover': function(){
					$('title_' + key).src = "http://www.weltcup-engelberg.ch/images/title_line_a.jpg";
					$('text_' + key).getElements('h2').setStyle('color', '#b2241b');
					
				}
				,'mouseout': function(){
					$('title_' + key).src = "http://www.weltcup-engelberg.ch/images/title_line.jpg";
					$('text_' + key).getElements('h2').setStyle('color', '#024595');
				}
				,'click': function(){
					this.showDetailContent(items.ld.id, key, lastpart);
				}.bind(this)
			}
		}).inject(main);
		
		return main;
	}
	
	,showDetailContent: function(detID, key, lastpart){
		
		$('c_main').empty();
				
		new Fx.Scroll(window, {
			offset: {
				'x': 0
				,'y': 0
			}
		}).toTop();
		
		var items = this.options.req.result[key];
		
		// Newsumwandung für Newsdetails
		if(items.ld.news_from != undefined){
			
			items.ld.titel = items.ld.title;
			items.ld.bilder = items.ld.pictures;
			items.ld.pdfs = items.ld.files;
		}
		
		this.options.entryID = detID;
		this.resetSiteAnch(4);
		
		var backLink = new Element('a', {
			'href': '#'
			,'html': '<img src="' + this.options.root + 'back.gif" style="padding-right: 2px; vertical-align: middle" border="0"/><b>Zurück zur Übersicht</b><br />'
			,'styles': {
				'color': '#024595'
				,'text-decoration': 'none'
			}
			,'events': {
				'click': function(){
					
					this.options.entryID = '';
					
					$('c_head').setStyle('display', 'block');
					
					if($defined(items.ld.news_from) && this.options.activDB != 'planner') this.buildNews('');
					else this.showMainContent(this.options.req);
					
				}.bind(this, items)
			}
		}).inject($('c_main'));
		
		// Titel
		if(items.ld.titel) titel = items.ld.titel;
		else if(items.ld.name) titel = items.ld.name;
		else titel = items.ld.firma;
		
		var detailT = new Element('div', {
			'html': '<div style="padding: 7px 0 0 9px; color: #ffffff; font-weight: bold; font-size: 12px;">' + titel + '</div>'
			,'styles': {
				'background': 'url(' + this.options.root + 'detail_titelbg.jpg) no-repeat'
				,'padding-bottom': '14px'
				,'height': '44px'
			}
		}).inject($('c_main'));
		
		// Bild
		var picstr = '';
		if(items.ld.bilder != ''){
			
			bj = items.ld.bilder;
			if(!$defined(this.options.headArr)){
				this.options.activDB = 'news';
				if(bj.media.length > 0) picCount = 1;
				else picCount = bj.media.length;
			}else{
				picCount = this.options.headArr.length;
			}
			bj.media.each(function(items, key){
				
				fbreak = false;
				
				if(!$defined(this.options.activDB) && !$defined(this.options.activSubN)) this.options.activDB = 'pack';
				var toDB = this.options.activDB;
				var aSN = this.options.activSubN;
				if(toDB == 'planner' || toDB == 'pack' || toDB == 'info' || (toDB == 'unterkunft' && (aSN == '1' || aSN == '10' || aSN == '18' || aSN == '29' || aSN == '8' || aSN == '17')) || (toDB == 'mice' && (aSN == '8' || aSN == '9'))) randPic = 1;
				else randPic = 0;
				
				// Erstes Headpic im Detail
				if(key == 0 && (picCount == 0 || randPic)){
					if(toDB == 'planner' || toDB == 'pack' || toDB == 'gastronomie') picPart = 'head';
					else picPart = toDB;
					$$('#main_top_pic img')[0].set('src', this.options.root + 'head/' + picPart + '_' + $random(1, 6) + '.jpg')
				}else if(key == 0){
					$$('#main_top_pic img')[0].set('src', this.options.uproot + '518_verz_' + items["name"]);
				}
				
				if(key >= 1 || randPic){
					picbg = this.options.uproot + '171_verz_' + items["name"];
					picstr += '<img id="photo-' + key + '" src="' + picbg + '" name="' + this.options.uproot + '518_verz_' + items["name"] + '" class="remooz-element" style="padding-bottom: 14px;" /><script type="text/javascript"> ReMooz.assign(\'#photo-' + key + '\', {\'origin\': \'img\'}); </script><br />';
				}
			}, this);
		}
		
		var text = '', tj = '';
		var newstxt;
		if(items.ld.text){
			tj = items.ld.text;
			if(items.ld.news_from != undefined) newstxt = tj.text[0].replace(/<hr>/g, '');
		}
		if(!items.ld.gastgeber && !items.ld.firma){
			
			if($defined(items.ld.zeit) && items.ld.zeit){
				if(this.options.language == 'de') text += '<b>Zeitaufwand:</b> ' + items.ld.zeit + '<br /><br />';
				else text += '<b>Time:</b> ' + items.ld.zeit + '<br /><br />';
			}
			
			if(newstxt) text += newstxt;
			else if(tj) text += tj.text[0];
			
			// url
			if(items.ld.url != '' && items.ld.url != undefined){
				text += '<div class="button bwww"><a href="' + items.ld.url + '" target="_blank">' + items.ld.url.replace('http://', '') + '</a></div><div class="bend"></div><br style="clear:both;" />';
			}
		}else{
			if(items.ld.gastgeber) text += items.ld.gastgeber + '<br />'; 
			if(items.ld.adresse) text += items.ld.adresse + '<br />'; 
			if(items.ld.plz) text += items.ld.plz + ' ';
			if(items.ld.ort) text += items.ld.ort + '<br /><br />';
			
			if(items.ld.telefon) text += '<div class="button btel">' + items.ld.telefon + '</div><div class="bend"></div><br style="clear:both;" />';
			if(items.ld.mobile) text += '<div class="button bmob">' + items.ld.mobile + '</div><div class="bend"></div><br style="clear:both;" />';
			if(items.ld.fax) text += '<div class="button bfax">' + items.ld.fax + '</div><div class="bend"></div><br style="clear:both;" />';
			if(items.ld.email) text += '<div class="button bmail"><a href="mailto:' + items.ld.email + '">' + items.ld.email + '</a></div><div class="bend"></div><br style="clear:both;" />';
			
			// url
			if(items.ld.url != '' && items.ld.url != undefined){
				text += '<div class="button bwww"><a href="' + items.ld.url + '" target="_blank">' + items.ld.url.replace('http://', '') + '</a></div><div class="bend"></div><br style="clear:both;" />';
			}
			
			if(items.ld.telefon || items.ld.mobile || items.ld.fax || items.ld.email)  text += '<br />';
			
			if(newstxt) text += newstxt;
			else if(tj) text += tj.text[0];
		}
		
		// pdf
		if(items.ld.pdfs != ''){
			pj = items.ld.pdfs;
			pj.media.each(function(items, key){
				
				if(items.name != '') linktext = items["linktext"];
				else linktext = items["name"];
				text += '<br /><div class="button bdown"><a href="' + this.options.uproot + items["name"] + '" target="_blank" style="text-decoration: none; color: #000000;">' + linktext + '</a></div><div class="bend"></div><br style="clear:both;" />';
			}, this);
		}
		
		ctable = '<table cellpadding="0" cellspacing="0" border="0"><tr><td width="190" valign="top">' + picstr + '</td><td width="290" valign="top" id="mainTxt">' + text + '<br /><br /></td></tr></table>';
		
		var main = new Element('div', {
			'id': 'main_' + key
			,'html': ctable
			,'styles': {
				'padding-bottom': '15px'
			}
		}).inject($('c_main'));
		
		if(!lastpart) lastpart = this.options.activDB;
		
		// buttonreplace
		newText = $('mainTxt').innerHTML.split("Tel.");
		if(newText.length > 1){
			
			var newStr = '';
			newText.each(function(items, key){
				
				if(key > 0){
					if(!Browser.Engine.gecko) srchStr = "<BR";
					else srchStr = "<br";
					newStr += '<div class="button btel">' + items.substr(0, items.indexOf(srchStr)) + '</div><div class="bend"></div><br style="clear: both"';
					newStr += items.substr(items.indexOf(srchStr) + 3);
				}else{
					newStr += items;
				}
			});
			$('mainTxt').innerHTML = newStr;
		}
		
		mainTxtLink = $$('#mainTxt a');
		mainTxtLink.each(function(items, key){
			
			if(items.getParent().tagName != "DIV"){
				this.repButton(items);
			}
		}, this);
		
		// Travelplanner
		if(this.options.language == 'de'){
			var travelTxt_a = 'Angebot in den Travel Planner';
			var travelTxt_o = 'Aus dem Travel Planner entfernen';
		}else{
			var travelTxt_a = 'Add to Travel Planner';
			var travelTxt_o = 'Remove from the Travel Planner';
		}
		
		inPlanner = mySel.checkResult('travel', items.ld.id, lastpart);
		
		if(inPlanner) var travelTxt = travelTxt_o;
		else var travelTxt = travelTxt_a;
		
		var travelPic = new Element('div', {
			'id': 'button_bplanner'
			,'class': 'button bplanner'
			,'html': travelTxt
			,'styles': {
				'cursor': 'pointer'
			},'events': {
				'click': function(){
					
					if($('button_bplanner').get('text') != travelTxt_o){
						
						$('button_bplanner').set('text', travelTxt_o);
						
						// hinzufügen
						mySel.saveResult('travel', detID, lastpart);
						
					}else{
						
						$('button_bplanner').set('text', travelTxt_a);
						
						// entfernen
						mySel.removeResult('travel', detID, lastpart);
					}
					
				}.bind(this)
			}
		}, this).inject($('mainTxt'));
		
		var travelEnd = new Element('div', {
			'class': 'bend'
		}).inject($('mainTxt'));
		
		var travelEndAdd = new Element('br', {
			'styles': {
				'clear': 'both'
			}
		}).inject($('mainTxt'));
		
		
		if(!Browser.Engine.gecko) $('main_content').innerHTML.stripScripts(true);
	}
	
	,repButton: function(items, only){
				
		if(items.href.test('mailto:') && only != 'link'){
			
			var addObj = new Element('div', {
				'class': 'bend'
			}).inject(new Element('div', {
				'class': 'button bmail'
				,'styles': {
					'cursor': 'pointer'
				}
			}).wraps(items),'after');
			
			new Element('br', {
				'styles': {
					'clear': 'both'
				}
			}).inject(addObj, 'after');
			
		}else if(items.target.test('_blank')){
			
			if(items.text) items.innerHTML = items.text.replace('http://', '');
			
			if(items.href.contains('ch.concentrator.net')){
				items.target = '_self';
				items.href = 'javascript: new Fx.Scroll(window).toTop(); showWin(\'\', \'' + items.href + '\')';
			}else if(items.href.contains('ch-engelberg.concentrator.net')){
				items.target = '_self';
				items.href = 'javascript: new Fx.Scroll(window).toTop(); showWin(\'\', \'' + items.href + '\')';
			}
			
			var addObj = new Element('div', {
				'class': 'bend'
			}).inject(new Element('div', {
				'class': 'button bwww'
				,'styles': {
					'cursor': 'pointer'
				}
			}).wraps(items),'after');
			
			new Element('br', {
				'styles': {
					'clear': 'both'
				}
			}).inject(addObj, 'after');
		}
	}
	
	,headPicSelect: function(){
		
		picCount = this.options.headArr.length;
		randNr = parseInt(Math.random() * picCount);
		
		var toDB = this.options.activDB;
		var aSN = this.options.activSubN;
		
		// Randompics im bereich unterkünfte / private apartements
		if(!$defined(toDB) && !$defined(aSN)) toDB = 'pack';
		if(toDB == 'planner' || toDB == 'pack' || toDB == 'info' || (toDB == 'unterkunft' && (aSN == '18' || aSN == '29' || aSN == '8' || aSN == '17')) || (toDB == 'mice' && (aSN == '8' || aSN == '9'))) randPic = 1;
		else randPic = 0;
		
		if(picCount == 0 || randPic){
			if(toDB == 'planner' || toDB == 'pack' || toDB == 'gastronomie') picPart = 'head';
			else picPart = toDB;
			
			$$('#main_top_pic img')[0].set('src', this.options.root + 'head/' + picPart + '_' + $random(1, 6) + '.jpg')
		}else{
			$$('#main_top_pic img')[0].set('src', this.options.uproot + '518_verz_' + this.options.headArr[randNr]);
		}
	}
	
	,showSubNav: function(idName, subNr){
				
		// Aktiv Haupt / Div show
		this.options.navID.each(function(item, key){
			
			if($(item + '_m')) $(item + '_m').set('class', '');
			
			if($(item)){
				
				$(item).setStyle('display', 'none');
				
				// Subnavigation zurücksetzten
				if(subNr){
					subArr = $(idName).getElements('li');
					subArr.each(function(items, key){
						items.set('class', '');
					});
				}
			}
		});
		
		if(idName == 'prospekte' || idName == '') return;
		
		if($(idName)){
			
			$(idName + '_m').set('class', 'mnavs');
			$(idName).setStyle('display', 'block');
			
			// Subnavigation aktivieren
			if(subNr){
				subArr = $(idName).getElements('li');
				subArr[subNr - 1].set('class', 'snav');
			}
		}else if($(idName + '_m')){
			$(idName + '_m').set('class', 'mnav_nosub');
		}
	}
	
	,showWeather: function(){
		
		/*
		var myEffects = new Fx.Morph('horizontal_slide', {
				duration: 1000,
				transition: Fx.Transitions.Sine.easeOut
		});
		*/
		
		$('test').addEvent('click', function(e){
			gP = $('test').getPosition();
			/*
			e.stop();
			myEffects.start({
				'height': [10, 100],
				'width': [10, 300],
				'opacity': [0, 100]
			});
			*/
		});
	}
	
	,menuDrag: function(){
		
		var fx = [];
		new Drag.Move($('dragmenu'), {
			droppables: $$('#droppables div')
		});
		
		$('dragmenu').addEvent('emptydrop', function(){
			this.setStyle('background-color', '#faec8f');
		});
	}
	
	,resetSiteAnch: function(level){
		
		anchLink = '';
		
		/*
		de/
		aktivitaet/	<-- level 0;
		sommer/		<-- level 1;
		Biken/		<-- level 2;
		ID		<-- level 3;
		*/
		
		if(level <= 1) this.options.subNav = '';
		if(level <= 2) this.options.ssubNav = '';
		
		this.setSiteAnch();
	}
	
	,setSiteAnch: function(){
		
		bAnch = [this.options.language, this.options.activDB, this.options.subNav, this.options.ssubNav, this.options.entryID];
		
		var lstr = '';
		bAnch.each(function(items, key){
			
			if(items){
				
				// Anchor auf EN
				if(key == 1 && this.options.language == 'en'){
					if(items == 'unterkunft') items = 'accommodations';
					else if(items == 'gastronomie') items = 'gastronomy';
					else if(items == 'aktivitaet') items = 'activities';
					else if(items == 'kultur_tradition') items = 'culture_tradition';
				}
				
				lstr += items;
				if(key != (bAnch.length - 1)) lstr += '/';
			}
		}, this);
				
		$('anchLink').value = domain + lstr;
	}
	
	,splitText: function(str, length){
		
		tmpText = str.substring(0, length);
		pos = tmpText.lastIndexOf(' ');
		text = tmpText.substring(0, pos);
		
		return text;
	}
	
	,replaceUml: function(str){
		
		if(str){
			str = str.toLowerCase();
			str = str.replace(/ & /g, ' ');
			str = str.replace(/&/g, ' ');
			str = str.replace(/, /g, ' ');
			str = str.replace(/\//g, ' ');
			str = str.replace(/â/g, 'a');
			str = str.replace(/ä/g, 'ae');
			str = str.replace(/ö/g, 'oe');
			str = str.replace(/ü/g, 'ue');
			str = str.replace(/è/g, 'e');
			str = str.replace(/é/g, 'e');
			str = str.replace(/à/g, 'a');
		}
		
		return str;
	}
});

// Slidebox
var BoxSlider = new Class({
	
	Extends: verzRequest
	
	,options:{
		openButton:''
		,closeButton:''
		,overBox:''
		,boxSize:[0, 0]
		,correction:[0, 0]
	}
	
	,initialize: function(options){
		this.setOptions(options);
		
		var bEl = $(this.options.openButton);
		if(bEl){
			bEl.set('styles',{
				'cursor': 'pointer'
			});
			
			this.buildSlide(bEl, $(this.options.closeButton), $(this.options.overBox));
		}
	}
	
	,buildFade: function(){
		
		if(!$('BoxOverlay')){
			
			new Element('div', {
				'id': 'BoxOverlay'
				,'styles': {
					'display': 'block'
					,'z-index': 500
					,'position': 'absolute'
					,'top': 0
					,'left': 0
					,'background-color': '#000'
					,'opacity': 0
					,'width' : window.getScrollWidth()
					,'height' : window.getScrollHeight()
					,'cursor': 'pointer'
				}
				,'events': {
					'click': function(){
						engelberg.closeAllBox();
					}.bind(this)
				}
			}).inject(document.body);
		}
	}
	
	,buildSlide: function(bEl, cEl, boxEl){
		
		var actEvent = function(e){
			
			e.stop();
			
			// nachladen der Events
			if(bEl.get('id') == 'showWOne'){
				
				var test = new Request({
					url: mainroot + 'includes/parse_events.php'
					,data: 'language=' + lang
					,method: 'post'
					,onComplete: function(response){
						$('eventTxt').set('html', response);
					}.bind(this)
				}).send();
			}
			
			this.buildFade();
			this.startFade();
			
			boxpos = bEl.getPosition();
			boxEl.set('styles', {
				'position': 'absolute'
				,'top': boxpos.y + this.options.correction[1]
				,'left': this.options.correction[0]
			});
			
			this.openSlide(bEl, cEl, boxEl);
		};
		
		bEl.addEvent('click', actEvent.bind(this));
		
		// classreplace fü¼r den click
		if($(bEl.id + '_link')) $(bEl.id + '_link').addEvent('click', actEvent.bind(this));
	}
	
	,openSlide: function(bEl, cEl, boxEl){
		
		boxpos = bEl.getPosition();
		
		boxEl.set('styles', {
			'display': 'block'
			,'z-index': 502
		});
		
		// 168px
		new Fx.Morph(boxEl, {
			duration: 'long'
			,transition: Fx.Transitions.Sine.easeOut
			//,fps: 60
			,onComplete: function(){
				
			}.bind(this)
		}).start({
			'width': this.options.boxSize[1]
			,'left': '-' + (this.options.boxSize[1] - this.options.boxSize[0]) //boxpos.x - ( - this.options.boxSize[0])
		});
		
		// Remove new Add
		cEl.set('styles',{
			'cursor': 'pointer'
		});
		cEl.removeEvent('click');
		cEl.addEvent('click', function(e){
			
			e.stop();
			this.closeSlide(boxEl);
			
		}.bind(this));
	}
	
	,closeSlide: function(boxEl){
		
		new Fx.Morph(boxEl, {
			duration: 'long'
			,transition: Fx.Transitions.Sine.easeOut
			//,fps: 60
			,onComplete: function(){
				
				boxEl.set('styles', {
					'display': 'none'
					,'z-index': 501
				});
									
				this.fadeOut();
				
			}.bind(this)
		}).start({
			'width': this.options.boxSize[0]
			,'left': 0
		});
	}
	
	,startFade: function(){
		
		//Overlay
		if($('BoxOverlay').get('opacity') != 0.7){
			new Fx.Tween($('BoxOverlay'), {
				duration: 500
			}).start('opacity', '0', '0.7');
		}
	}
	
	,fadeOut: function(){
		
		var stopOut = 0;
		infoBox = $$('.infobox_open');
		infoBox.each(function(items, key){
			if(items.getStyle('display') == 'block'){
				stopOut = 1;
			}
		});
		
		if($('BoxOverlay') && $('BoxOverlay').get('opacity') == 0.7 && stopOut == 0){
			
			new Fx.Tween($('BoxOverlay'), {
				duration: 500
				,fps :35
				,onComplete: function(){
					
					if($('BoxOverlay')){
						$('BoxOverlay').setStyle('opacity', 0);
						$('BoxOverlay').destroy();
					}
				}
			}).start('opacity', '0.7', '0');
		}
	}
});

// Gastrobereich
var gastroFinder = new Class({
	
	Extends: engelberg
	
	,options:{}
	
	,initialize: function(options){
		this.setOptions(options);
	}
	
	,loadFinder: function(){
		
		this.reqData = {
			type: 'all'
			,user: 'engelberg'
			,table: {
				listingrows_gastro: 'lr'
			}
			,condition: {
				'lr.language': this.options.language
			}
			,fields: 'lr.*'
			,order: 'lr.parentrID,lr.position ASC'
		}
		
		this.reqResult('buildFinder');
	}
	
	,buildFinder: function(req){
		
		// Gastropart
		selEl = '<div style="width:200px; float:left;"><select id="gastrotyp" style="color:#024595;">';
		req.result.each(function(items, key){
			
			if(key == 0) val = '';
			else val = items.lr.rubrikname;
			selEl += '<option value="' + val + '">' + items.lr.rubrikname +'</option>';
		});
		selEl += '</select></div>';
		
		if(this.options.language == 'de'){
			smoketyp = 'Ganz oder teilweise rauchfrei';
			rolltyp = 'Rollstuhlgängig';
		}else{
			smoketyp = 'Totally or partially smoke-free';
			rolltyp = 'Wheelchair-accessible';
		}
		
		// Rauchbereich & Rollstuhl
		selEl += '<div style="width:200px; float:left;">'+
			'<input type="checkbox" id="smoketyp"> ' + smoketyp + '<br>'+
			'<input type="checkbox" id="rolltyp"> 100% '+ rolltyp +
			'</div><br /><br /><br /><br /><br /><hr /><br />';
		
		$('c_head').set('html', $('c_head').get('text') + '<br /><br />' + selEl);
		
		// Events
		$('gastrotyp').addEvent('change', function(e){
			e.stop();
			this.refSelect();
		}.bind(this));
		$('smoketyp').addEvent('change', function(e){
			e.stop();
			this.refSelect();
		}.bind(this));
		$('rolltyp').addEvent('change', function(e){
			e.stop();
			this.refSelect();
		}.bind(this));
		
		this.refSelect();
	}
	
	,refSelect: function(){
		
		this.reqData = {
			type: 'all'
			,user: 'engelberg'
			,table: {
				listingdatas_gastro: 'ld'
			}
			,condition:{
				'ld.language': this.options.language
			}
			,fields: 'ld.*'
			,order: 'ld.name ASC'
		};
		
		// Selektierung
		if($('gastrotyp').value != ''){
			
			this.reqData.condition['lr.rubrikname'] = $('gastrotyp').value
			this.reqData.table['listingrows_gastro'] = 'lr';
			this.reqData.table['listings_gastro'] = 'l';
		}
		
		// Rauchfrei
		if($('smoketyp').checked) this.reqData.condition['ld.rauchfrei'] = '1';
		
		// Rollstuhl
		if($('rolltyp').checked) this.reqData.condition['ld.rollstuhl'] = '1';
		
		this.reqResult('showMainContent');
	}
});

//PopUp - Class by GO4WEB
var popUp = new Class({
	
	Implements: engelberg,
	
	options: {
		pWidth : 800,
		pHeight : 580,
		pTop : 52,
		pTitle : '',
		pText : 'text'
	},
	
	initialize: function(options){
		
		this.setOptions(options);
		
		this.buildFade();
		this.openWindow();
	},
	
	buildFade: function(){
		
		// overlaycheck
		if($('BoxOverlay')) this.options.noOverlayRem = 1;
		else this.options.noOverlayRem = 0;
		
		if(this.options.noOverlayRem != 1){
			new Element('div', {
				'id': 'BoxOverlay',
				'styles': {
					'display': 'block',
					'z-index': 990,
					'position': 'absolute',
					'top': 0,
					'left': 0,
					'background-color': '#000',
					'opacity': 0,
					'width': window.getScrollWidth(),
					'height': window.getScrollHeight()
				}
			}).injectInside(document.body);
		}
	},
	
	openWindow : function(){
		
		pcenter = this.options.pWidth / 2;
		pcenter = '-'+parseInt(pcenter)+'px';
		
		//Aufbau Fenster
		pWin = new Element('div', {
			'id': 'pWin',
			'styles': {
				'position': 'absolute',
				'margin-left': pcenter,
				'z-index': 995,
				'top': this.options.pTop,
				'left': '50%',
				'width' : this.options.pWidth,
				'height': this.options.pHeight,
				'text-align': 'left',
				'overflow': 'hidden',
				'display': 'block',
				'opacity': 0
			}
		}).injectInside(document.body);
		
		//pWin.makeDraggable();
		c_tl = new Element('div', {
			'styles': {
				'position' : 'absolute',
				'top' : 10,
				'left' : 9,
				'z-index' : 999,
				'width': 23,
				'height': 23,
				'background-image' : 'url(' + this.options.root + 'c_tl.png)'
			}
		}).injectInside(pWin);
		
		c_tr = new Element('div', {
			'styles': {
				'position' : 'absolute',
				'top' : 10,
				'right' : 9,
				'z-index' : 999,
				'width': 23,
				'height': 23,
				'background-image' : 'url(' + this.options.root + 'c_tr.png)'
			}
		}).injectInside(pWin);
		
		c_br = new Element('div', {
			'styles': {
				'position' : 'absolute',
				'bottom' : 10,
				'right' : 9,
				'z-index' : 999,
				'width': 23,
				'height': 23,
				'background-image' : 'url(' + this.options.root + 'c_br.png)'
			}		
		}).injectInside(pWin);
		
		c_bl = new Element('div', {
			'styles': {
				'position' : 'absolute',
				'bottom' : 10,
				'left' : 9,
				'z-index' : 999,
				'width': 23,
				'height': 23,
				'background-image' : 'url(' + this.options.root + 'c_bl.png)'
			}		
		}).injectInside(pWin);
		
		btm = new Element('div', {
			'styles': {
				'position' : 'absolute',
				'bottom' : 10,
				'left' : 32,
				'z-index' : 999,
				'width': this.options.pWidth-64,
				'height': 23,
				'background-image' : 'url(' + this.options.root + 'btm.png)',
				'background-repeat' : 'repeat-x'
			}
		}).injectInside(pWin);
		
		tp = new Element('div', {
			'styles': {
				'position' : 'absolute',
				'top' : 10,
				'left' : 32,
				'z-index' : 999,
				'width': this.options.pWidth-62,
				'height': 23,
				'background-image' : 'url(' + this.options.root + 'top.png)',
				'background-repeat' : 'repeat-x'
			}
		}).injectInside(pWin);

		lft = new Element('div', {
			'styles': {
				'position' : 'absolute',
				'bottom' : 33,
				'left' : 9,
				'z-index' : 999,
				'height': this.options.pHeight-66,
				'width': 23,
				'background-image' : 'url(' + this.options.root + 'lft.png)',
				'background-repeat' : 'repeat-y'
			}
		}).injectInside(pWin);
		
		rgt = new Element('div', {
		        'styles': {
				'position' : 'absolute',
				'bottom' : 33,
				'right' : 9,
				'z-index' : 999,
				'height': this.options.pHeight-66,
				'width': 23,
				'background-image' : 'url(' + this.options.root + 'rgt.png)',
				'background-repeat' : 'repeat-y'
		        }
    		}).injectInside(pWin);
		
		
		cont = new Element('div', {
		        'id': 'wincont',
		        'styles': {
				'position' : 'absolute',
				'margin' : '30px 30px 30px 30px',
				'color' : 'red',
				'z-index' : 999,
				'overflow': 'hidden',
				'width': this.options.pWidth - 60,
				'height': this.options.pHeight - 60,
				'background-color' : '#fff'
			}
		}).injectInside(pWin);
		
		if(this.options.pTitle){
			titlebar = new Element('div', {
				'id': 'titlebar',
				'html': '<h2 class="title" style="color: #024595;">' + this.options.pTitle + '</h2>',
				'styles': {
					'position': 'absolute',
					'top': 0,
					'left': 0,
					'height': '20px',
					'width': this.options.pWidth-30
				}
	   		}).inject(cont);
		}
		
   		if(this.options.pText.substr(0, 7) == 'http://' || this.options.pText.substr(0, 7) == 'https:/'){
   			this.options.pText = '<iframe name="searchResult" scrolling="yes" height="' + (this.options.pHeight - 80) + '" frameborder="0" width="' + (this.options.pWidth - 60) + '" src="' + this.options.pText + '" style="overflow-x: hidden;" />';
   		}
   		
		pTxt = new Element('div', {
			'id': 'pTxt'
			,'html': this.options.pText
			,'styles': {
				'position': 'absolute'
				,'top': 0
				,'left': 0
				,'padding' : '20px 0 0 0'
			}
		}).injectInside(cont);
	    
		
		// Fade
		if (this.options.noOverlayRem != 1) this.startFade();
		
		// Mainfade
		var delayFunc = function(){
			
			// Einblenden Fenster
			var fadein = new Fx.Tween($(pWin), {
	        		duration: 50
				,onComplete : function(){
					 closer = new Element('div', {
				        'id': 'closer',
				        'styles': {
				            'position': 'absolute',
							'cursor' : 'pointer',
							'top' : 6,
							'right' : 3,
							'width' : 30,
							'height' : 30,
				            'margin-top': '0',
				            'margin-left': '0',
							'z-index' : 999,
							'background-image' : 'url(' + this.options.root + 'closebox.png)'
				        },'events' : {
							'click' : function(){
								this.closeWindow();
							}.bind(this)
						}
		   			 }).injectInside(pWin);
				}.bind(this)
			});
			
			fadein.start('opacity', '0', '1');
			
		}.delay(1300, this);
	},
	
	startFade: function(){
		
		//Overlay
		new Fx.Tween($('BoxOverlay'), {
			duration: 500
		}).start('opacity', '0', '0.7');
	},
	
	fadeOut: function(){
		
		new Fx.Tween($('BoxOverlay'), {
			duration: 500,
			fps: 35,
			onComplete: function(){
				$('BoxOverlay').setStyle('opacity', 0);
				$('BoxOverlay').destroy();
			}
		}).start('opacity', '0.7', '0');
	},
	
	closeWindow: function(){
		
		$('closer').destroy();
		
		var fadeout = new Fx.Tween($(pWin), {
			duration: 50,
			fps :35,
			onComplete: function(){ 
				$(pWin).destroy();
			}
		}).start('opacity', '1', '0');
		
		if (this.options.noOverlayRem != 1) this.fadeOut();
	}
});

var myAngel = new Class({
	
	Extends: engelberg
	
	,options: {}
	
	,initialize: function(options){
				
		this.setOptions(options);
		
		this.buildAngel();
		this.dragEvent();
		
		// plannercount
		this.countResult();
	}
	
	,getMainPos: function(){
		
		winW = window.getScrollWidth()
		this.options.dockPos = {
			top: 40
			,left: (winW/2 + 105).round()
		}
	}
	
	,buildAngel: function(){
		
		if(this.options.language == 'en') var addLang = '_en';
		else var addLang = '';
		
		this.getMainPos();
		
		// dock
		var dock = new Element('div', {
			'id': 'myDock'
			,'class': 'myDock'
			,'styles': {
				'position': 'absolute'
				,'top': this.options.dockPos.top
				,'left': this.options.dockPos.left
			}
		}).injectInside(document.body);
		
		if (!this.options.nofly){
			angCtop = '150px';
			angCleft = '-180px';
		}else{
			angCtop = this.options.dockPos.top;
			angCleft = this.options.dockPos.left;
		}
		
		// finder
		var angelC = new Element('div', {
			'id': 'mySelectC'
			,'class': 'mySelectC'
			,'styles': {
				'position': 'absolute'
				,'top': angCtop
				,'left': angCleft
			}
		}).injectInside(document.body);
		
// DEBUG
		
		// Nofly
		if (!this.options.nofly){
			var morphFun = function(){
				this.flyBack(2);
			}.bind(this);
			
			(function(){
				morphFun();
			}.delay(2000));
		}
		
		new Element('div', {
			'id': 'mySelectFly'
			,'html': '<img src="' + this.options.root + 'engel/fluegel.png">'
			,'styles': {
				'position': 'absolute'
				,'top': '-24px'
				,'left': '-42px'
			}
		}).injectInside(angelC);
		
		if(this.options.nofly){
			
			$('mySelectFly').setStyle('display', 'none');
			$('mySelectFly').getFirst().set('morph', {
				duration: 1
				,transition: Fx.Transitions.Sine.easeOut
			}).morph({
				'width': '1px'
			});
			$('mySelectFly').set('morph', {
				duration: 1
				,transition: Fx.Transitions.Sine.easeOut
			}).morph({
				'left': '67px'
				,'top': '45px'
			});
			$('mySelectFly').setStyle('display', 'block');
		}
		
		var angel = new Element('div', {
			'id': 'mySelect'
			,'class': 'mySelect'
		}).injectInside(angelC);
		
		new Element('div', {
			'id': 'mySelect_handle'
			,'html': '&nbsp;'
			,'styles': {
				'display': 'block'
				,'cursor': 'pointer'
			}
			,'events':{
				'mouseover': function(){
					if(!this.options.flyOut && ie6 != 1) $('i_raus').setStyle('display', 'block');
				}.bind(this)
				,'mouseout': function(){
					if(!this.options.flyOut && ie6 != 1) $('i_raus').setStyle('display', 'none');
				}.bind(this)
			}
		}).injectInside(angel);
		
		// download
		var mySave = new Element('img', {
			'id': 'mySave'
			,'class': 'mySave'
			,'src': this.options.root + '0.gif'
			,'events': {
				'click': function(){
					
					// save_dock
					this.newSelAngel('mySave');
				}.bind(this)
				,'mouseover': function(){
					$('i_save').setStyle('display', 'block');
					$('mySave').set('src', this.options.root + 'engel/save' + addLang + '.png');
				}.bind(this)
				,'mouseout': function(){
					$('i_save').setStyle('display', 'none');
					if(!$('mySave_dock')) $('mySave').set('src', this.options.root + '0.gif');
				}.bind(this)
			}
		}).injectInside(angel);
		
		// Refresh
		var myMatrix = new Element('img', {
			'id': 'myMatrix'
			,'class': 'myMatrix'
			,'src': this.options.root + '0.gif'
			,'events': {
				'click': function(){
					
					// matrix_dock
					this.newSelAngel('myMatrix');
				}.bind(this)
				,'mouseover': function(){
					$('i_matrix').setStyle('display', 'block');
					$('myMatrix').set('src', this.options.root + 'engel/matrix.png');
				}.bind(this)
				,'mouseout': function(){
					$('i_matrix').setStyle('display', 'none');
					if(!$('myMatrix_dock')) $('myMatrix').set('src', this.options.root + '0.gif');
				}.bind(this)
			}
		}).injectInside(angel);
		
		// Info
		var myInfo = new Element('img', {
			'id': 'myInfo'
			,'class': 'myInfo'
			,'src': this.options.root + '0.gif'
			,'events': {
				'click': function(){
					
					// Info_dock
					this.newSelAngel('myInfo');
					
				}.bind(this)
				,'mouseover': function(){
					$('i_info').setStyle('display', 'block');
					$('myInfo').set('src', this.options.root + 'engel/info' + addLang + '.png');
				}.bind(this)
				,'mouseout': function(){
					$('i_info').setStyle('display', 'none');
					$('myInfo').set('src', this.options.root + '0.gif');
				}.bind(this)
			}
		}).injectInside(angel);
		
		// TOOLTIPS
		// raus
		new Element('div', {
			'id': 'i_raus'
			,'html': '<img src="' + this.options.root + 'engel/i_raus' + addLang + '.png">'
			,'styles': {
				'display': 'none'
				,'position': 'absolute'
				,'top': '-20px'
				,'left': '25px'
			}
		}).injectInside(angel);
		
		// matrix
		new Element('div', {
			'id': 'i_matrix'
			,'html': '<img src="' + this.options.root + 'engel/i_matrix' + addLang + '.png">'
			,'styles': {
				'display': 'none'
				,'position': 'absolute'
				,'top': '-20px'
				,'left': '25px'
			}
		}).injectInside(angel);
		
		// info
		new Element('div', {
			'id': 'i_info'
			,'html': '<img src="' + this.options.root + 'engel/i_info' + addLang + '.png">'
			,'styles': {
				'display': 'none'
				,'position': 'absolute'
				,'top': '-20px'
				,'left': '25px'
			}
		}).injectInside(angel);
		
		// save
		new Element('div', {
			'id': 'i_save'
			,'html': '<img src="' + this.options.root + 'engel/i_save' + addLang + '.png">'
			,'styles': {
				'display': 'none'
				,'position': 'absolute'
				,'top': '-20px'
				,'left': '25px'
			}
		}).injectInside(angel);
		
		// save
		new Element('div', {
			'id': 'i_back'
			,'html': '<img src="' + this.options.root + 'engel/i_back' + addLang + '.png">'
			,'styles': {
				'display': 'none'
				,'position': 'absolute'
				,'top': '-20px'
				,'left': '25px'
			}
		}).injectInside(angel);
	}
	
	,newSelAngel: function(active){
		
		$(active).set('src', this.options.root + 'engel/' + active.replace('my', '').toLowerCase() + '.png');
		
		checkArr = ['mySave', 'myMatrix', 'myInfo'];
		checkArr.each(function(items, key){
			
			if($(items + '_dock')){
				
				$(items + '_dock').destroy();
				$(items).set('src', this.options.root + '0.gif');
			}else if(items == active){
				
				var showBox = new Element('div', {
					'id': active + '_dock'
					,'class': active + '_dock'
					,'html': '&nbsp;'
				}).injectInside($('mySelectC'));
				
				if(items == 'myInfo'){
					showBox.addEvents({
						'click': function(){
							$(items + '_dock').destroy();
							$(items).set('src', this.options.root + '0.gif');
						}.bind(this)
					})
				}else{
					showBox.removeEvents('click');
				}
				
				this.buildSubC(active);
			}
		}, this);
	}
	
	,buildSubC: function(active){
		
		if(active == 'mySave'){
			
			var main = new Element('div', {
				'styles': {
					'padding': '10px 0 10px 20px'
				}
			}).inject($(active + '_dock'));
			
			/*
			var save = new Element('a', {
				'href': '#'
				,'html': 'Speichern'
				,'styles':{
					'text-decoration': 'none'
					,'color': '#ffffff'
				}
				,'events': {
					'click': function(){
						this.saveResult();
					}.bind(this)
				}
			}).inject(main);
			var planner = new Element('a', {
				'href': '#'
				,'html': '<img src="' + this.options.root + 'boxpfeil.png" border="0">Travel Planner'
				,'styles':{
					'text-decoration': 'none'
					,'color': '#ffffff'
				}
			})
			planner.cloneEvents($('mNav_planner'));
			planner.inject(main);
			
			new Element('br').inject(main);
			*/
			if(this.options.language == 'de') printTxt = 'Drucken';
			else printTxt = 'Print';
			new Element('a', {
				'href': 'index.php?id=1&print=1'
				,'target': '_blank'
				,'html': '<img src="' + this.options.root + 'boxpfeil.png" border="0">' + printTxt
				,'styles':{
					'text-decoration': 'none'
					,'color': '#ffffff'
				}
			}).inject(main);
			
		}else if(active == 'myMatrix'){
			
			if(this.options.language == 'de'){
				
				var matrixC = '<div style="float: left; width: 84px; color: #ffffff;">'+
					'	<input type="radio" name="wann" value="sommer"> Sommer<br />'+
					// '	<input type="radio" name="wann" value="herbst"> Herbst<br />'+
					'	<input type="radio" name="wann" value="winter" checked> Winter<br />'+
					// '	<input type="radio" name="wann" value="fruehling"> Frühling<br />'+
					'	<br />'+
					'	<br />'+
					'	<br />'+
					'	<br />'+
					'	<br />'+
					'	<a href="javascript: engelberg.mainLoader(\'matrix\', $$(\'#dragmenu input\'));"><img src="' + this.options.root + 'engel/auswahl.png" border="0"></a>'+
					'</div>'+
					'<div style="float: left; width: 86px; color: #ffffff;">'+
					'	<input type="radio" name="wer" value="erwachsene" checked> Erwachsene<br />'+
					'	<input type="radio" name="wer" value="kinder"> Kinder<br />'+
					'	<input type="radio" name="wer" value="familie"> Familie<br />'+
					'	<input type="radio" name="wer" value="gruppe"> Gruppe<br />'+
					'	<input type="radio" name="wer" value="business"> Business<br />'+
					'</div>'+
					'<div style="float: left; width: 87px; color: #ffffff;">'+
					'	<input type="checkbox" name="was[0]" value="aktivitaet"> Aktivität<br />'+
					'	<input type="checkbox" name="was[1]" value="gastronomie"> Gastronomie<br />'+
					'	<input type="checkbox" name="was[2]" value="support"> Support<br />'+
					'	<input type="checkbox" name="was[3]" value="unterkunft"> Unterkunft<br />'+
					'	<input type="checkbox" name="was[5]" value="kultur"> Kultur<br />'+
					'	<input type="checkbox" name="was[6]" value="unterhaltung"> Unterhaltung<br />'+
					'</div>'+
					'<div style="float: left; width: 80px; color: #ffffff;">'+
					'	<input type="checkbox" name="wo[0]" value="indoor"> Indoor<br />'+
					'	<input type="checkbox" name="wo[1]" value="outdoor"> Outdoor<br />'+
					'	<input type="checkbox" name="wo[2]" value="berg"> Berg<br />'+
					'	<input type="checkbox" name="wo[3]" value="tal"> Tal<br />'+
					'</div>';
			}else{
				
				var matrixC = '<div style="float: left; width: 69px; color: #ffffff;">'+
					'	<input type="radio" name="wann" value="sommer"> Summer<br />'+
					// '	<input type="radio" name="wann" value="herbst"> Herbst<br />'+
					'	<input type="radio" name="wann" value="winter" checked> Winter<br />'+
					// '	<input type="radio" name="wann" value="fruehling"> Frühling<br />'+
					'	<br />'+
					'	<br />'+
					'	<br />'+
					'	<br />'+
					'	<br />'+
					'	<a href="javascript: engelberg.mainLoader(\'matrix\', $$(\'#dragmenu input\'));"><img src="' + this.options.root + 'engel/auswahl_en.png" border="0"></a>'+
					'</div>'+
					'<div style="float: left; width: 81px; color: #ffffff;">'+
					'	<input type="radio" name="wer" value="erwachsene" checked> Adults<br />'+
					'	<input type="radio" name="wer" value="kinder"> Children<br />'+
					'	<input type="radio" name="wer" value="familie"> Family<br />'+
					'	<input type="radio" name="wer" value="gruppe"> Group<br />'+
					'	<input type="radio" name="wer" value="business"> Business<br />'+
					'</div>'+
					'<div style="float: left; width: 107px; color: #ffffff;">'+
					'	<input type="checkbox" name="was[0]" value="aktivitaet"> Activities<br />'+
					'	<input type="checkbox" name="was[1]" value="gastronomie"> Gastronomy<br />'+
					'	<input type="checkbox" name="was[2]" value="support"> Support<br />'+
					'	<input type="checkbox" name="was[3]" value="unterkunft"> Accommodations<br />'+
					'	<input type="checkbox" name="was[5]" value="kultur"> Culture<br />'+
					'	<input type="checkbox" name="was[6]" value="unterhaltung"> Entertainment<br />'+
					'</div>'+
					'<div style="float: left; width: 80px; color: #ffffff;">'+
					'	<input type="checkbox" name="wo[0]" value="indoor"> Indoor<br />'+
					'	<input type="checkbox" name="wo[1]" value="outdoor"> Outdoor<br />'+
					'	<input type="checkbox" name="wo[2]" value="berg"> Mountain<br />'+
					'	<input type="checkbox" name="wo[3]" value="tal"> Valley<br />'+
					'</div>';
			}
			
			var main = new Element('div', {
				'id': 'dragmenu'
				,'html': matrixC
				,'styles': {
					'padding': '55px 0 10px 20px'
				}
			}).inject($(active + '_dock'));
			
		}else if(active == 'myInfo'){
			
			if(this.options.language == 'de') infotxt = 'Finden statt suchen!<br />Mit dieser Funktion wird das Zusammenstellen Ihrer Reise zum Kinderspiel. Wählen Sie die gewünschten Rubriken und Sie erhalten automatisch die passenden Angebote.';
			else infotxt = 'Don’t just search - find!<br />Planning a vacation stay to individually suit you is super easy. Just choose the fields that interest you and attractive corresponding offers will appear.';
			
			var main = new Element('div', {
				'id': 'dragmenu'
				,'html': '<span style="font-size: 0.86em; color: #ffffff;">' + infotxt + '</span>'
				,'styles': {
					'padding': '20px 15px 10px 15px'
				}
			}).inject($(active + '_dock'));
		}
	}
	
	,reposAngel: function(){
		
		this.getMainPos();
		
		// dock
		$('myDock').set('styles', {
			'position': 'absolute'
			,'top': this.options.dockPos.top
			,'left': this.options.dockPos.left
		});
	}
	
	,flyBack: function(sec){
		
		// flugabbruch
		this.options.flyOut = 0;
		this.options.stopFly = 1;
		
		if(sec) var duration = sec * 1000;
		else var duration = 500;
		
		var myFx = new Fx.Scroll(window, {
			offset: {
				'x': 0
				,'y': 0
			}
		}).toTop();
		
		$('mySelectC').set('morph', {
			duration: duration,
			transition: Fx.Transitions.Sine.easeOut,
			// link: 'chain'
			onComplete: function(){
				$('mySelectC').setStyle('position', 'absolute');
				if ($('flyback')) $('flyback').destroy();
				if ($('mySelectFly')){
					$('mySelectFly').getFirst().set('morph', {
						duration: duration
						,transition: Fx.Transitions.Sine.easeOut
					}).morph({
						'width': 1
					});
					$('mySelectFly').set('morph', {
						duration: duration
						,transition: Fx.Transitions.Sine.easeOut
					}).morph({
						'left': '67px'
						,'top': '45px'
					});
				}
			}.bind(this)
		}).morph({
			'top': this.options.dockPos.top
			,'left': this.options.dockPos.left
			,'z-index': 1
		});
		
		$('mySelectC').set('styles', {
			'z-index': 499
		});
	}
	
	,flyStart: function(){
		
		$('mySelectFly').getFirst().set('morph', {
			duration: 300
			,transition: Fx.Transitions.Sine.easeOut
		}).morph({
			'width': 219
		});
		$('mySelectFly').set('morph', {
			duration: 300
			,transition: Fx.Transitions.Sine.easeOut
		}).morph({
			'top': '-24px'
			,'left': '-42px'
		});
	}
	
	,flynow: function(){
		
		if(this.options.stopFly) return;
		
		mySelPos = $('mySelectC').getPosition();
		$('mySelectC').set('morph', {
			duration: 200
			,transition: Fx.Transitions.Sine.easeOut
		}).morph({
			'top': mySelPos.y + 2
		});
		$('mySelectFly').set('morph', {
			duration: 200
			,transition: Fx.Transitions.Sine.easeOut
			,onComplete: function(){
				this.flynowAni();
			}.bind(this)
		}).morph({
			'top': '-19px'
		});
	}
	
	,flynowAni: function(){
		
		if(this.options.stopFly) return;
		
		mySelPos = $('mySelectC').getPosition();
		$('mySelectC').set('morph', {
			duration: 200
			,transition: Fx.Transitions.Sine.easeOut
		}).morph({
			'top': mySelPos.y - 2
		});
		$('mySelectFly').set('morph', {
			duration: 200
			,transition: Fx.Transitions.Sine.easeOut
			,onComplete: function(){
				this.flynow();
			}.bind(this)
		}).morph({
			'top': '-24px'
		});
	}
	
	,dragEvent: function(){
		
		var dragElement = $('mySelectC');
		var dragContainer = window.body;
		var dragInner = $('mySelect');
		var dragHandle = $('mySelect_handle');
		var dropElement = $$('.myDock');
		
		// Debugging
		var startEl = $('start');
		var completeEl = $('complete');
		var dragIndicatorEl = $('drag_ind');
		var enterDrop = $('enter');
		var leaveDrop = $('leave');
		var dropDrop = $('drop_in_droppable'); 
		
		if(ie6 != 1){
			var myDrag = new Drag.Move(dragElement, {
				
			   	// Drag.Move options
				droppables: dropElement
				
				,container: dragContainer
				
				// Drag options
				,handle: dragHandle
				
				// Drag.Move Events
				,onDrop: function(el, dr) {
					
					
					if(!dr){
		 				
						dragElement.setStyle('position', 'fixed');
						if (!$('flyback')) {
							
							new Element('div', {
								'id': 'flyback'
								,'class': 'flyback'
								,'styles': {
									'position': 'absolute'
									,'top': -5
									,'left': -5
								}
								,'events': {
									'click': function(event){
										$('i_back').setStyle('display', 'none')
										this.flyBack()
									}.bind(this, scroll)
									,'mouseover': function(){
										if(this.options.flyOut) $('i_back').setStyle('display', 'block');
									}.bind(this)
									,'mouseout': function(){
										if(this.options.flyOut) $('i_back').setStyle('display', 'none');
									}.bind(this)
								}
							}).injectInside(dragInner);
						}
						
		        	       }else{
				       	
					
				       		dragElement.setStyle('position', 'absolute');
						this.flyBack();
						/*
						dropDrop.highlight('#FB911C'); //flashes orange
						el.highlight('#fff'); //flashes white
						dr.highlight('#667C4A'); //flashes green
						*/
					};
				}.bind(this)
				
				,onLeave: function(el, dr) {
					
					$('i_raus').setStyle('display', 'none');
					// leaveDrop.highlight('#FB911C'); //flashes orange
				}.bind(this)
				
				,onEnter: function(el, dr) {
					
					this.options.flyOut = 0;
					// enterDrop.highlight('#FB911C'); //flashes orange
				}.bind(this)
				
				// Drag Events
				,onStart: function(el) {
					
					this.options.stopFly = 1;
					
					dragElement.set('styles', {
						'z-index': 900
					});
					
					if($('mySelectFly').getFirst().width < 100){
						this.flyStart();
					}
					// startEl.highlight('#FB911C'); //flashes orange
				}.bind(this)
				
				,onDrag: function(el) {
					
					this.options.flyOut = 1;
					// dragIndicatorEl.highlight('#FB911C'); //flashes orange
				}.bind(this)
				
				,onComplete: function(el) {
									
					$('mySelectFly').set('styles', {
						'position': 'absolute'
						,'top': '-24px'
						,'left': '-42px'
					});
					
					if(this.options.flyOut == 1) this.options.stopFly = 0;
					
					this.flynow();
					
					// completeEl.highlight('#FB911C'); //flashes orange
				}.bind(this)
			});
		}
	}
	
	// Cookiesaving
	,saveResult: function(mode, travID, lastpart){
		
		var decodeCookie = Cookie.read('engelberg');
		
		if (decodeCookie) {
			// Travelplanner und Matrixsaver
			var cookieStr = JSON.decode(decodeCookie);
		}else{
			
			var cookieStr = {
				active: []
				,saved: []
				
				,travel: {
					'unterkunft': []
					,'gastronomie': []
					,'aktivitaet': []
					,'kultur_tradition': []
					,'info': []
					,'mice': []
					,'prospekte': []
					,'news': []
				}
			};
		}
		
		if(!$defined(lastpart)) lastpart = 'unterkunft';
		else if(lastpart == '') lastpart = 'aktivitaet';
		
		if(mode == 'travel'){
			eval('cookieStr.travel.' + lastpart + '.include(' + travID + ')');
		}else{
			cookieStr["saved"].include(lastpart);
		}
		
		var myCookie = Cookie.write('engelberg', JSON.encode(cookieStr), {duration: 120});
		
		this.countResult();
	}
	
	// Cookiesaving
	,removeResult: function(mode, travID, lastpart){
		
		var decodeCookie = Cookie.read('engelberg');
		
		// Travelplanner und Matrixsaver
		var cookieStr = JSON.decode(decodeCookie);
		
		if(mode == 'travel'){
			eval('cookieStr.travel.' + lastpart + '.erase(' + travID + ')');
		}else{
			cookieStr["saved"].include(lastpart);
		}
		
		var myCookie = Cookie.write('engelberg', JSON.encode(cookieStr), {duration: 120});
		
		if(this.options.activDB == 'planner') this.loadResult();
		else this.countResult();
	}
	
	,delCookieContent: function(){
		
		Cookie.dispose('engelberg');
	}
	
	,getCookieContent: function(){
		
		var decodeCookie = Cookie.read('engelberg');
		return decodeCookie;
	}
	
	,checkResult: function(mode, travID, lastpart){
		
		var decodeCookie = Cookie.read('engelberg');
		
		if(decodeCookie){
			
			// Travelplanner und Matrixsaver
			var cookieStr = JSON.decode(decodeCookie);
			if($defined(eval('cookieStr.' + mode + '.' + lastpart))) return eval('cookieStr.' + mode + '.' + lastpart + '.contains(' + travID + ')');
		}
		
		return false;
	}
	
	// Travelplanner Count
	,countResult: function(){
				
		var cookieStr = JSON.decode(Cookie.read('engelberg'));
		
		if(cookieStr){
			var travelCount = 0;
			engelberg.options.dbArr.each(function(items, key){
				
				if (items == '') items = 'aktivitaet'
				else if (items == 'gastro') items = 'gastronomie'
				
				var objReq = eval('cookieStr.travel.' + items);
				if(objReq) travelCount += objReq.length;
			});
			
			$('travelCount').set('html', travelCount);
		}
	}
	
	// LoadCookioverview
	,loadResult: function(){
		
		var cookieStr = JSON.decode(Cookie.read('engelberg'));
		
		$('c_main').empty();
		var main = new Element('div', {
			'html': ''
			,'styles': {
				'padding': '10px 0 10px 20px'
			}
		}).inject($('c_main'));
		
		// Save-Auflistung
		if(cookieStr){
			
			/*
			cookieStr.saved.each(function(items, key){
				
				new Element('a', {
					'href': '#'
					,'text': items
					,'events': {
						'click': function(){
							
							// Loader
							engelberg.reloadContent(items, '');
							engelberg.buildMainAcc(items);
						}.bind(this)
					}
				}).injectInside(main);
				new Element('br').inject(main);
			});
			*/
			
			// Rücksetzen des Accordion
			this.options.mainAccord = false;
			
			this.reqData = [];
			
			var knr = 0;
			engelberg.options.dbArr.each(function(items, key){
				
				if (items == '') items = 'aktivitaet'
				
				this.reqData[knr] = {
					type: 'all',
					user: 'engelberg',
					table: {},
					condition: {},
					fields: 'ld.*',
					order: 'ld.id ASC',
					language: 'de'
				}
				
				if(items == 'aktivitaet') this.reqData[knr].table['listingdatas'] = 'ld';
				else this.reqData[knr].table['listingdatas_' + items] = 'ld';
				
				if(items == 'gastro') items = 'gastronomie';
				
				this.reqData[knr].condition['ld.id'] = eval('cookieStr.travel.' + items);
				
				knr++;
			}, this);
			
			this.reqResult('showMainContent');
		}else{
			new Element('div', {
				'html': 'Es wurden keine Einträge gespeichert.'
			}).inject(main);
		}
		
		this.options.activDB = 'planner';
		this.resetSiteAnch(1);
		
		this.countResult();
		new Fx.Scroll(window).toTop();
	}
});

// Expand Arrayfunctions
Array.implement({
	shuffle: function() {
		
		for(var j, x, i = this.length; i; j = parseInt(Math.random() * i), x = this[--i], this[i] = this[j], this[j] = x);
		return this;
	},
	is_array: function(input){
		return typeof(input)=='object'&&(input instanceof Array);
	}
});

function googlemap(){
	
	if(GBrowserIsCompatible()){
		
		var map = new GMap2(document.getElementById("map"));
		map.addControl(new GSmallZoomControl());
		map.addControl(new GMapTypeControl());
		map.setCenter(new GLatLng(46.82079599411774, 8.405485153198242), 15);
		var point = new GLatLng(46.82079599411774, 8.405485153198242, 15);
		
		// online -> ABQIAAAAEegLeZTF_fcAGTByO50ReRSPNK_KOtrhSaxmki2NQfD_20Bq_BRd6lt5rtEKcjEdg0wgxpFhEIlVvw
		// local -> ABQIAAAAQO7vjAZDK3KEoA9w4ZoZyxTsR5Iqrv5sl_TP-VtzFEl2TmyEYRQfcSRXZ-GEKmBjeJog6l94As31OA
		
		var blueIcon = new GIcon(G_DEFAULT_ICON);
		
        	blueIcon.image = "";
        	blueIcon.iconSize = new GSize(46, 19);
        	markerOptions = { icon:blueIcon };
        	langRoute = "Route berechnen";
        	langlink = "de";
        	
        	marker = new GMarker(point);
		map.addOverlay(marker);
		var html = '<div style="float:left;"><b>Engelberg-Titlis Tourismus AG</b><br>Tourist Center<br>CH-6390 Engelberg<br><br><a href="http://maps.google.com/maps?f=d&source=s_d&saddr=&daddr=Tourist+Center,+6390+Engelberg,+Switzerland&hl=de&geocode=%3BFU_HzwIdKPSBACFUB8O_sKt3Og&mra=ls&sll=46.82079599411774,8.405485153198242&sspn=0.055676,0.125656&ie=UTF8&ll=46.82079599411774,8.405485153198242&spn=0.055676,0.125656&z=50" target="_blank">' + langRoute + '</a>&nbsp;&nbsp;&nbsp;</div>';
		
		marker.openInfoWindowHtml(html);
	}
}

function showWin(titel, text, width, height){
		
	var options = {};
	
	// Einstellungen
	if(titel) options['pTitle'] = titel;
	if(text) options['pText'] = text;
	if(width) options['pWidth'] = width;
	if(height) options['pHeight'] = height;
	
	// classgen
	new popUp(options);
}

function favorit(){
	
	favAnch = $('anchLink').value;
	
	if (window.sidebar){
		
		// firefox
		window.sidebar.addPanel(document.title, favAnch, '');
	}else if(window.opera && window.print){
		
		// opera
		var elem = document.createElement('a');
		elem.setAttribute('href', favAnch);
		elem.setAttribute('title', document.title);
		elem.setAttribute('rel', 'sidebar');
		elem.click();
	}else if(document.all){
		
		// ie
		window.external.AddFavorite(favAnch, document.title);
	}
}