/**
 * @author Peter
 * 
 * JS-Compresser that works fine with these Script: http://www.creativyst.com/Prod/3/
 * 
 */
 
// disable rightclick 
window.addEvent('domready', function() {
	if (document.layers){document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;}
	else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;}
	document.oncontextmenu=new Function("return false");
});
function clickIE() {if (document.all) {('');return true;}}
function clickNS(e) {if(document.layers||(document.getElementById&&!document.all)) {if (e.which==2||e.which==3) {('');return true;}}}
//*/

if(window.ie){
	var console = {
		log: function(vari){
			
			console.logRunner(vari);
			console.count = 0;
			console.txt = '';
			
		},
		logRunner: function(vari){
			
			for(var a in vari){
				try{console.addToString(a, vari[a]);
				}catch(e){}
				
				if(typeof vari[a] == 'object'){
					console.lvl++;
					if(console.lvl < 5)
						//console.logRunner(vari[a]);
					console.lvl--;
				}
			}
			
		},
		count:0,
		lvl:0,
		txt : '',
		addToString: function(pf,n,v){
			var maxcount = 50;
			console.txt += n + ' :: ' + v +'\n';
			console.count++;
			if(console.count > maxcount){
				alert(console.txt);
				console.txt = '';
				console.count = 0;
			}
	
		}
	}
}


// init main object for moevenpick
var mp = new Object();

/*
Class: HotelPictures
	Creates a Picture Rondel for Moevenpick
	
Note:

Arguments:
	element - the content container
	options - see Options below

Options:
	images - Array of images. Content hast to be of this stucture {small:[url to small image],big:[url to big image],bigX:[horiz. size of the big image],bigY:[vertical size of the big image]}
	fadedurration - durration of the picture fade.
	fps - frames per second.
	thumbStartOpacity - the opacity of o inactice thumb  
	useScoller : boolean swicht for usingthe scroller
	scrollArea: size of area in wich the scoll function is applied 
	scrollVelocity: velocity for scroll function 
	
Events:
	onChange - a function to fire when the picture changes.
*/
mp.HotelPictures = new Class({
	options: {
		onChange: Class.empty,
		images:new Array(),
		fadedurration:1200,
		fps:50,
		useScoller:false,
		thumbStartOpacity:0.5,
		scrollArea:50,
		scrollVelocity:0.3,
		automaticdelay:6000
	},
	initialize: function(el,options){
		this.setOptions(options);
		this.el = $(el);
		this.selected = 0;
		this.imgCount = this.options.images.length;

		// get DOM Elements
		this.pictureEls = this.el.getElementsBySelector('a.picture');
		this.largeEl = this.el.getElement('div.imglargecont').getFirst();
		
		// run init function
		this.initEls();
		
		if(this.options.automaticdelay){
			this.periodic = this.next.delay(this.options.automaticdelay,this);
		}

	},
	initEls: function(){
		
		// adding Events to the small picturesb
		for(var i = 0; i < this.pictureEls.length; i++){
			if(i > 0)this.pictureEls[i].getFirst().setStyle('opacity',this.options.thumbStartOpacity);
			this.pictureEls[i].onclick = this.changeImage.bindAsEventListener(this,i);
		}
		// adding events to next and prev. button
		this.el.getElement('a.next').onclick = this.next.bindAsEventListener(this);
		this.el.getElement('a.prev').onclick = this.prev.bindAsEventListener(this);
		
		// adding scroller to thumb list
		if(this.options.useScoller){
			this.scroller = new Scroller(this.el.getElement('div.scoller'), {onlyX:true,area: this.options.scrollArea, velocity: this.options.scrollVelocity});
			this.el.getElement('div.scoller').addEvent('mouseover', this.scroller.start.bind(this.scroller));
			this.el.getElement('div.scoller').addEvent('mouseout', this.scroller.stop.bind(this.scroller));
		}
		
		$('StageToolTipText').innerHTML = this.options.images[0].imagealt;
		
		// init scrolling function
		this.scroll = new Fx.Scroll(this.el.getElement('div.scoller'), {
			wait: false,
			duration: 800,
			transition: Fx.Transitions.Quad.easeInOut
		});
	},
	changeImage:function(event,idx){
		// if not the active image is clicked change it
		
		if(idx != this.selected){
			
			this.fireEvent('onChange', this.step);
			
			// init Elements
			var oImgData = this.options.images[idx];
			var elLarge = this.largeEl;
			var fxFade = new Fx.Style(elLarge, 'opacity',{fps:this.options.fps, duration: (this.options.fadedurration/2).toInt()});

			
			// run animation for thumb
			this.pictureEls[this.selected].getFirst().effect('opacity', {transition: Fx.Transitions.Quint.easeIn,fps:this.options.fps, duration: this.options.fadedurration}).start(this.options.thumbStartOpacity);
			this.pictureEls[idx].getFirst().effect('opacity', {transition: Fx.Transitions.Quint.easeIn,fps:this.options.fps, duration: this.options.fadedurration}).start(1);
			
			// scroll to the new thumb
			this.scroll.scrollTo(64*idx-198,0);

			
			// run animation of big image
			fxFade.stop();
			fxFade.start(0.1).chain(function(){
				fxFade.stop();
				
			elLarge.setProperties({
				'src':oImgData.big,
				'width':oImgData.bigX,
				'height':oImgData.bigY
			});	
				fxFade.start(1);
			});

			// Show headline only on first image
			if (idx == 0) {
				$('StageTitle').setStyle('display', 'block');
			} else {
				$('StageTitle').setStyle('display', 'none');
			}
			// Set Tooltip Text above slider
			$('StageToolTipText').innerHTML = this.options.images[idx].imagealt;			
			
			// change the seleched item
			this.selected = idx;
		}
	},
	next:function(event){
		$clear(this.periodic);
		// get the next thumb and change the big image
		if(this.selected+1 >= this.imgCount){
			this.changeImage(new Object(),0);
		}else{
			this.changeImage(new Object(),this.selected+1);
		}
		if(this.options.automaticdelay){
			this.periodic = this.next.delay(this.options.automaticdelay,this);
		}
	},
	prev:function(event){
		$clear(this.periodic);
		// get the previous thumb and change the big image
		if(this.selected-1 < 0){
			this.changeImage(new Object(),this.imgCount-1);
		}else{
			this.changeImage(new Object(),this.selected-1);
		}
		if(this.options.automaticdelay){
			this.periodic = this.next.delay(this.options.automaticdelay,this);
		}
	}
});
mp.HotelPictures.implement(new Options, new Events);


// Reservation Funktions 
mp.reservation = new Object();

mp.reservation.getCalendarDate = function(cDate){
   var dateString = mp.reservation.months[cDate[0].toInt()] + ' ' + cDate[2];
   return dateString;
}
mp.reservation.addMonth = function(cDate,number){
	var newMonth = cDate[0].toInt() + number;
	var number2 = number;
	if(number2 < 0)number2= number2*-1;
	var iYearAdd = (number2/12).toInt()+1;
	
	if(newMonth <= 0){
		cDate[0] = 12;
		cDate[2] = cDate[2].toInt()-iYearAdd;
	}else if(newMonth > 12){
		cDate[0] = 1;
		cDate[2] = cDate[2].toInt()+iYearAdd;
	}else{
		cDate[0] = newMonth;
	}
	return cDate;
}
/*
Class: AvailabilityCalender
	Creates a Picture Rondel for Moevenpick
	
Note:

Arguments:
	element - the content container
	options - see Options below

Options:

Events:

*/




mp.HomepageStage = new Class({
	options: {
		onChange: Class.empty,
		images:new Array(),
		fadedurration:1400,
		fps:50,
		useScoller:false,
		thumbStartOpacity:0.5,
		scrollArea:50,
		scrollVelocity:0.3,
		automaticdelay:3000
	},
	initialize: function(el,options){
		this.setOptions(options);
		this.el = $(el);
		this.selected = 0;
		this.imgCount = this.options.images.length;

		// get DOM Elements
		this.pictureEls = this.el.getElementsBySelector('a.picture');
		this.largeEl = this.el.getElement('div.imglargecont').getFirst();
		

		// run init function
		this.initEls();
		
		if(this.options.automaticdelay){
			this.periodic = this.next.delay(this.options.automaticdelay,this);
		}

	},
	initEls: function(){
		
		// adding Events to the small picturesb
		for(var i = 0; i < this.pictureEls.length; i++){
			if(i > 0)this.pictureEls[i].getFirst().setStyle('opacity',this.options.thumbStartOpacity);
			this.pictureEls[i].onclick = this.changeImage.bindAsEventListener(this,i);
		}
		
		// adding scroller to thumb list
		if(this.options.useScoller){
			this.scroller = new Scroller(this.el.getElement('div.scoller'), {onlyX:true,area: this.options.scrollArea, velocity: this.options.scrollVelocity});
			this.el.getElement('div.scoller').addEvent('mouseover', this.scroller.start.bind(this.scroller));
			this.el.getElement('div.scoller').addEvent('mouseout', this.scroller.stop.bind(this.scroller));
		}
		
		$('StageToolTipText').innerHTML = this.options.images[0].imagealt;
		
		// init scrolling function
		this.scroll = new Fx.Scroll(this.el.getElement('div.scoller'), {
			wait: false,
			duration: 800,
			transition: Fx.Transitions.Quad.easeInOut
		});
	},
	changeImage:function(event,idx){
		// if not the active image is clicked change it
		
		if(idx != this.selected){
			
			this.fireEvent('onChange', this.step);
			
			// init Elements
			var oImgData = this.options.images[idx];
			var elLarge = this.largeEl;
			var fxFade = new Fx.Style(elLarge, 'opacity',{fps:this.options.fps, duration: (this.options.fadedurration/2).toInt()});
			
			// run animation of big image
			fxFade.stop();
			fxFade.start(0.01).chain(function(){
				fxFade.stop();
				elLarge.setProperties({
					'src':oImgData.big,
					'width':oImgData.bigX,
					'height':oImgData.bigY
				});
				fxFade.start(1);
			});

			// Show headline only on first image
			if (idx == 0) {
				$('StageTitle').setStyle('display', 'block');
			} else {
				$('StageTitle').setStyle('display', 'none');
			}
			// Set Tooltip Text above slider
			$('StageToolTipText').innerHTML = this.options.images[idx].imagealt;			
			
			// change the seleched item
			this.selected = idx;
		}
	}
}),
mp.HomepageStage.implement(new Options, new Events);



mp.reservation.AvailabilityCalender = new Class({
	options: {
		availDates:new Object(),
		startDate:'01/01/2008',
		calStartDate:'01/01/2008',
		fadedurration:600,
		fps:50,
		srcBttCalClose:'',
		srcBttCalOpen:'',
		calMonthLength:17,
		isOpen:false
	},
	initialize: function(el,options){
		this.setOptions(options);
		this.el = $(el);
		this.calScrollWidth = 239;
		
		this.isOpen = this.options.isOpen;
		
		this.options.startDate = this.options.startDate.split('/');
		this.options.startDate[0] = this.options.startDate[0].toInt();
		this.options.startDate[1] = this.options.startDate[1].toInt();
		this.options.startDate[2] = this.options.startDate[2].toInt();
		
		this.options.calStartDate = this.options.calStartDate.split('/');
		this.options.calStartDate[0] = this.options.calStartDate[0].toInt();
		this.options.calStartDate[1] = this.options.calStartDate[1].toInt();
		this.options.calStartDate[2] = this.options.calStartDate[2].toInt();
		
		this.currCalPos = this.options.startDate[0] - this.options.calStartDate[0] + 12*(this.options.startDate[2]-this.options.calStartDate[2]);
		
		this.toggleEventRunning = false; 

		this.init();
	},
	init: function(){
		this.scroller = new Fx.Scroll(this.el.getElement('div.table_cont'), {
			wait: false,
			duration: 1200,
			transition: Fx.Transitions.Bounce.easeOut
		});
		
		this.el.getElement('.table_cont').scrollLeft = this.calScrollWidth*(this.currCalPos);
		if(!this.isOpen)this.el.getElement('#selector').setStyle('display','none');
		this.el.getElement('a.next').onclick = this.next.bindAsEventListener(this);
		this.el.getElement('a.prev').onclick = this.prev.bindAsEventListener(this);
		this.el.getElement('.mp_month_view').setHTML(mp.reservation.getCalendarDate(this.options.startDate));
		
		this.el.getElement('img#bttCalendar').onclick = this.toggleCalender.bindAsEventListener(this);
		
	},
	next: function(event){
		if(this.currCalPos <= this.options.calMonthLength){
			++this.currCalPos;
			this.scroller.scrollTo(this.calScrollWidth*this.currCalPos,0);
			//this.options.startDate = mp.reservation.addMonth(this.options.startDate,1);
			this.el.getElement('.mp_month_view').setHTML(mp.reservation.getCalendarDate(mp.reservation.addMonth(this.options.startDate,1)));
			//$('mp_form_calPos').value=this.currCalPos;
		}
	},
	prev: function(event){
		if(this.currCalPos > 0){
			--this.currCalPos;
			this.scroller.scrollTo(this.calScrollWidth*this.currCalPos,0);
			//this.options.startDate = mp.reservation.addMonth(this.options.startDate,-1);
			this.el.getElement('.mp_month_view').setHTML(mp.reservation.getCalendarDate( mp.reservation.addMonth(this.options.startDate,-1)));
			//$('mp_form_calPos').value=this.currCalPos;
		}
	},
	toggleCalender: function(event){
		if(this.isOpen ){
			this.close();
		}else{
			this.open();
		}
	},
	open: function(){
		var that = this;
		if(!this.toggleEventRunning && !this.isOpen){
			
			this.toggleEventRunning = true;

			this.initEffects();
			
			// open calender
			if($defined(oToolBookWhish))oToolBookWhish.closeTab(1);
			
			this.fxLegFade.set(0);
			this.fxCalFade.set(0);
			this.fxBttFade.set(0);
			this.el.getElement('#bttCalendar').setProperty('src',this.options.srcBttCalOpen);
			
			var fxCalFade= this.fxCalFade;
			var fxLegFade= this.fxLegFade;
			var fxBttFade= this.fxBttFade;
			this.fxCalHeight.element.setStyle('display','block');
			
			$('legend').setStyles({'display':'block','visibility':'hidden'});
			$('mp_form_reload_button').setStyles({'display':'block','visibility':'hidden'});3
			
			$('guests_form').setStyle('display','inline');
			$('guests_vis').setStyle('display','none');
			
			$('rooms_form').setStyle('display','inline');
			$('rooms_vis').setStyle('display','none');
			
			$('nights_form').setStyle('display','inline');
			$('nights_vis').setStyle('display','none');
			
			this.fxCalHeight.start(258).chain(function(){
				fxCalFade.start(1);
				fxLegFade.start(1);
				fxBttFade.start(1);
			});
			this.isOpen = true;
		}
	},
	close: function(){
		var that = this;
		if(!this.toggleEventRunning && this.isOpen){
				
			this.toggleEventRunning = true;
			
			this.initEffects();
			
			// close calender
			if($defined(oToolBookWhish)){
				if(oToolBookWhish.openTabNr == -1)oToolBookWhish.setTabContent({},1);
			}
			
			this.el.getElement('#bttCalendar').setProperty('src',this.options.srcBttCalClose);
			var fxCalHeight= this.fxCalHeight;
			
			$('guests_vis').setHTML(' ' + $('mp_form_iAdults').value + ' Adults / ' + $('mp_form_iChildren').value + ' Children');
			$('guests_form').setStyle('display','none');
			$('guests_vis').setStyle('display','inline');
			
			$('rooms_vis').setHTML($('mp_form_iRooms').value);
			$('rooms_form').setStyle('display','none');
			$('rooms_vis').setStyle('display','inline');
			
			$('nights_vis').setHTML($('mp_form_iNights').value);
			$('nights_form').setStyle('display','none');
			$('nights_vis').setStyle('display','inline');
			
			$('mp_form_reload_info').setStyle('display','none');
			$('legend').setStyles({'display':'none','visibility':'visible'});
			$('mp_form_reload_button').setStyles({'display':'none','visibility':'visible'});
			this.fxLegFade.start(0);
			this.fxBttFade.start(0);
			this.fxCalFade.start(0).chain(function(){
				fxCalHeight.start(1).chain(function(){
					fxCalHeight.element.setStyle('display','none');
				});
		});
		this.isOpen = false;
		}
	},
	initEffects: function(){
		var that = this;
		// init effects
		if(!$defined(this.fxLegFade))
			this.fxLegFade = new Fx.Style($('legend'), 'opacity',{fps:this.options.fps, duration: this.options.fadedurration});
		if(!$defined(this.fxCalFade))
			this.fxCalFade = new Fx.Style($('selector'), 'opacity', {onComplete:function(){if(this.to == 1)that.toggleEventRunning = false;},fps:this.options.fps, duration: this.options.fadedurration});
		if(!$defined(this.fxCalHeight))
			this.fxCalHeight = new Fx.Style($('selector'), 'height',{onComplete:function(){if(this.to < 10)that.toggleEventRunning = false;},fps:this.options.fps, duration: (this.options.fadedurration/2).toInt()});
		if(!$defined(this.fxBttFade))
			this.fxBttFade = new Fx.Style($('mp_form_reload_button'), 'opacity',{fps:this.options.fps, duration: this.options.fadedurration});
		
	}
});
mp.reservation.AvailabilityCalender.implement(new Options, new Events);

mp.reservation.DateSetter = new Class({
	initialize: function(el,datelist,startdate,enddate,minstay){
		this.el = $(el);
		
		this.startsetted = false;
		this.startdate = startdate;
		this.enddate = enddate;
		this.datelist = datelist;
		this.minstay = minstay.toInt();
		
		this.nights = 0;
		
		this.newstartdate = '';

	},
	setDate: function(sdate){
		var iTemp;
		if(!$('mp_cal_el'+sdate).hasClass('disabled')){
			if(!this.startsetted){
				// start selection
				this.el.getElements('td').each(function(el,idx){
					el.removeClass('selected');
				});
				$('mp_cal_el'+sdate).addClass('selected');
				this.newstartdate = sdate;
				this.startsetted = true;
			}else{

				// end selection
				istart = this.datelist.indexOf(this.newstartdate);
				iend = this.datelist.indexOf(sdate);
				
				// switch date if end is before start
				if(iend < istart){
					iTemp = iend;
					iend = istart;
					istart = iTemp;
				}
				// add days if datediff lower than minstay
				if(iend-istart < this.minstay){
					iend = istart+this.minstay;
				}
				sdate = this.datelist[iend];
				
				this.printDate(istart,iend,sdate);
				
				if(istart <= iend){
					this.nights = iend-istart;
				}else{
					this.nights = istart-iend;
				}
				mp.setOptionByValue($('mp_form_iNights'),this.nights);
			}
		}
	},
	setDateByNights: function(iNights){
		this.el.getElements('td').each(function(el,idx){
			el.removeClass('selected');
		});
		this.newstartdate = this.startdate;

		istart = this.datelist.indexOf(this.startdate);
		iend = this.datelist.indexOf(this.newstartdate).toInt()+iNights.toInt();
		sdate = this.datelist[iend];
		this.printDate(istart,iend,sdate);
	},
	printDate: function(istart,iend,sdate){
		if(istart <= iend){
			for(i=istart;i<=iend;i++){
				$('mp_cal_el'+this.datelist[i]).addClass('selected');
			}
			this.startdate = this.newstartdate;
			this.enddate = sdate;
		}else{
			for(i=iend;i<=istart;i++){
				$('mp_cal_el'+this.datelist[i]).addClass('selected');
			}
			this.enddate = this.newstartdate;
			this.startdate = sdate;
		}
		
		this.newstartdate = '';
		this.startsetted = false;
		$('mp_form_arrival_vis').setHTML(this.startdate.split('/')[1] + '.' + this.startdate.split('/')[0] + '.' +  this.startdate.split('/')[2]);
		$('mp_form_departure_vis').setHTML(this.enddate.split('/')[1] + '.' + this.enddate.split('/')[0] + '.' +  this.enddate.split('/')[2]);
		$('mp_form_arrival_form').value = this.startdate;
		$('mp_form_departure_form').value = this.enddate;
		$('nights_vis').setHTML(this.nights);
		
		mp.reservation.showReloadInfo();
		
	}
	
});
mp.reservation.AvailabilityCalender.implement(new Options, new Events);


mp.reservation.toggleRoomDetail = function(elRow,elDetail){
	if($(elDetail).getStyle('display') == 'none'){
		// show detail
		
		if(window.ie){
			$(elDetail).setStyle('display','block');
		}else{
			$(elDetail).setStyle('display','table-row');
		}
		
		$(elRow).addClass('detail');
		$(elRow).getFirst().setProperty('rowspan',2);
		$(elRow).getElements('.additionalImg').each(function(elImg){
			elImg.setStyle('display','block');
		});
		
		
	}else{
		// hide detail	
		$(elRow).removeClass('detail');
		$(elRow).getFirst().setProperty('rowspan',1);
		$(elRow).getElements('.additionalImg').each(function(elImg){
			elImg.setStyle('display','none');
		});
		$(elDetail).setStyle('display','none');
	}
}

mp.reservation.showReloadInfo = function(){
	var fx = new Fx.Style($('mp_form_reload_info'), 'opacity',{fps:25, duration: 500});
	if($('mp_form_reload_info').getStyle('visibility') == 'hidden'){
		$('mp_form_reload_info').setStyle('opacity',0);
		$('mp_form_reload_info').setStyle('display','block');
		fx.start(1).chain(function(){fx.start(0.1)}).chain(function(){fx.start(1)});
	}else{
		fx.start(0.1).chain(function(){fx.start(1)});
	}
	
}

mp.extendedRadiobox = new Class({
	options: {
	},
	initialize: function(el,options){
		this.setOptions(options);

		// check data
		if($type(el) == 'collection'){
			this.el = el;
		}else{
			// exit quietly 
			return false;
		}
		
		// add events
		for(var i = 0; i<this.el.length ; i++){
			this.el[i].onclick = this.setRadio.bindAsEventListener(this);
		}
		
		// get selected item
		this.iSelected = -1;
		for(var i = 0; i<this.el.length; i++){
			if(this.el[i].checked){
				this.iSelected = i;
			}
		}
	},
	setRadio:function(event){

		var iSelectedOld = this.iSelected;
		if(window.ie){
			var sCurrVal = event.srcElement.value;
		}else{
			var sCurrVal = event.target.value;
		}
		
		// check index of clicked item
		for(var i = 0; i<this.el.length; i++){
			if(this.el[i].value == sCurrVal){
				this.iSelected = i;
			}
		}
		// reset if it's the same as checked before
		if(iSelectedOld == this.iSelected)
			this.resetRadio.delay(20,this);

	},
	resetRadio:function(){
		for(var i = 0; i<this.el.length ; i++){
			this.el[i].checked = false;
		}
		this.iSelected = -1;
	}
});
mp.extendedRadiobox.implement(new Options, new Events);


mp.reservation.loadSection = function(section,args){
	
	switch (section){
		case 0:
			$('mp_form_fuseaction').value="reservation.cancel";
			if($defined($('mp_form_load')))$('mp_form_load').value = 0;
			$('mp_form_section').value="0";
			$('mp_form_reservation').action = $('mp_form_reservation').action + '&step' + section + '=1';
			$('mp_form_reservation').submit();
		break;
		case 1:
			$('mp_form_fuseaction').value="reservation.start";
			if($defined($('mp_form_load')))$('mp_form_load').value = 0;
			if($defined($('mp_form_calisopen')) && $defined(args.calisopen))$('mp_form_calisopen').value = args.calisopen;
			$('mp_form_section').value="1";
			$('mp_form_reservation').action = $('mp_form_reservation').action + '&step' + section + '=1';
			$('mp_form_reservation').submit();
		break;
		case 2:
			if($defined($('mp_form_roomrate')) && $defined(args.roomrate) && args.roomrate.length)$('mp_form_roomrate').value = args.roomrate;
			$('mp_form_fuseaction').value="reservation.step2";
			if($defined($('mp_form_load')))$('mp_form_load').value = 0;
			$('mp_form_section').value="2";
			$('mp_form_reservation').action = $('mp_form_reservation').action + '&step' + section + '=1';
			$('mp_form_reservation').submit();
		break;
		case 3:
			if($defined($('enhancements'))){
				oEnhancements.ids.each(function(el,idx){
					$('mp_form_reservation')[el].disabled = false;
				});
			}
			$('mp_form_fuseaction').value="reservation.step3";
			$('mp_form_load').value = 0;
			$('mp_form_section').value="3";
			$('mp_form_reservation').action = $('mp_form_reservation').action + '&step' + section + '=1';
			$('mp_form_reservation').submit();
		break;
		case 4:
			$('mp_form_fuseaction').value="reservation.step4";
			$('mp_form_load').value = 0;
			$('mp_form_section').value="4";
			$('mp_form_reservation').action = $('mp_form_reservation').action + '&step' + section + '=1';
			if($defined(args.formvalidator) && args.formvalidator.manualSubmit()) $('mp_form_reservation').submit();
		break;
		case 5:
			$('mp_form_fuseaction').value="reservation.step5";
			$('mp_form_load').value = 0;
			$('mp_form_section').value="5";
			$('mp_form_reservation').action = $('mp_form_reservation').action + '&step' + section + '=1';
			if($defined(args.formvalidator) && args.formvalidator.manualSubmit()) $('mp_form_reservation').submit();
		break;
	}
}

mp.reservation.upselling = new Class({
	options: {
		fadedurration:600,  	// time for animation
		fps:50,					// farmes per second
		oPriceCalc:'oPriceTotal',
		txtExt:'Extension!',	// langtext for extension
		currency:'EUR',			// current currency	
		relPath:'',				// relPath to Images
		sPrevSelectionBtt:'previous selection', // text for Button "previous selection"
		bBrutto:false,
		txtIncluded:'included',
		elId2Scoll2afterSelect:''
	},
	initialize: function(sEl,data,options){
		this.setOptions(options);
		// init vars

		this.sEl = sEl;
		
		this.data = data;
		
		// init params
		this.selectedUpSelling = 0;
		
		this.elRoomCont = 'roomcont';
		this.elRoomName1 = 'roominfo1';
		this.elRoomName2 = 'roominfo2';
		
		this.elRoomPrice = 'mp_uppselling_priceBreakd';
		this.elRoomPriceDesc = 'mp_uppselling_pricedescBreakd';
		this.elRoomPriceTotal = 'roominfo3';
		
		this.elVisRateCost = 'mp_vis_ratecost';
		this.elVisTotalCost = 'mp_vis_totalcost';
		this.elVisTaxCost = 'mp_vis_taxcost';
		this.elRoomDesc = 'roomdesc';
		this.elRoomImg = 'roomimg';
		this.elChangeBtt = 'mp_form_roomChangeBtt';
		
		this.oldData = new Object();
		this.oldData.RoomName1 = $(this.elRoomName1).getText();
		if($defined($(this.elRoomName2))){
			this.oldData.RoomName2 = $(this.elRoomName2).getText();
		}else{
			this.oldData.RoomName2 = '';
		}
		this.oldData.RoomPrice = $(this.elRoomPrice).innerHTML;
		this.oldData.RoomPriceDesc = $(this.elRoomPriceDesc).innerHTML;
		this.oldData.RoomPriceTotal = $(this.elRoomPriceTotal).getText();
		this.oldData.Descr = $(this.elRoomDesc).innerHTML;
		this.oldData.Img = $(this.elRoomImg).getProperty('src');

		this.oldData.RoomRate = $('mp_form_roomrate').value;
		this.oldData.TotalCost = $('mp_vis_totalcost').getText();
		this.oldData.TaxCost = $('mp_vis_taxcost').getText();
		

		this.elBttDel = new Element('div',{'class':'formbutton bg_white gray right','id':'prevselbtt',styles:{'display':'none'}});
		this.elBttDelInput = new Element('input',{'value':this.options.sPrevSelectionBtt,'type':'button'});
		this.elBttDel.adopt(new Element('div').adopt(new Element('div').adopt(new Element('div').adopt(new Element('div').adopt(this.elBttDelInput)))));
		this.elBttDelInput.onclick = this.resetUpselling.bindAsEventListener(this);
		
	},
	setUpselling: function(id){
		if(this.selectedUpSelling != id){
			this.selectedUpSelling = 0;
			this.data.each(function(el,idx){
				
				// for IE6
				var sShadowId = this.sEl + '_shadow' + el.ID;
				
				if(el.ID == id){
					$(this.elChangeBtt).setStyle('display','none');
					
					// select Upselling
					var sJSPrice = this.data[idx].PRICEF + ' ' + this.options.currency;
					
					eval(this.options.oPriceCalc).setValue(this.data[idx].PRICETOTAL,'_upsell');
					
					var sJSPriceTotalPretax = this.data[idx].ROOMDATA.COSTTOTALPRETAX + ' ' + this.options.currency;
					var sJSTax = this.data[idx].ROOMDATA.TAX + ' ' + this.options.currency;
					
					if(sJSPrice.indexOf(".") < 0)sJSPrice = this.data[idx].PRICEF + '.00 ' + this.options.currency;
					//if(sJSPriceTotal.indexOf(".") < 0)sJSPriceTotal = this.data[idx].ROOMDATA.COSTTOTAL + '.00 ' + this.options.currency;
					if(sJSPriceTotalPretax.indexOf(".") < 0)sJSPriceTotalPretax = this.data[idx].ROOMDATA.COSTTOTALPRETAX + '.00 ' + this.options.currency;
					if(sJSTax.indexOf(".") < 0)sJSTax = this.data[idx].ROOMDATA.TAX + '.00 ' + this.options.currency;
					
					// set Room Data i
					$(this.elRoomName1).setHTML(this.data[idx].ROOMDATA.NAME1);		
					if(this.data[idx].ROOMDATA.HASNAME2 && $defined($(this.elRoomName2)))$(this.elRoomName2).setHTML(this.data[idx].ROOMDATA.NAME2);
					//$(this.elRoomPrice).setHTML(sJSPriceTotal);
					$(this.elRoomDesc).setHTML('<strong>' + this.data[idx].ROOMDATA.DESCNAME + '</strong><br/>' + this.data[idx].ROOMDATA.RATEDESC);
					if(this.data[idx].ROOMDATA.IMG1.DEFINED)$(this.elRoomImg).setProperty('src',this.options.relPath + this.data[idx].ROOMDATA.IMG1.PATH + '/' + this.data[idx].ROOMDATA.IMG1.NAME);
					$(this.elRoomName1).addClass('upgrade');
					if($defined($(this.elRoomName2)))$(this.elRoomName2).addClass('upgrade');
					
					if(this.options.bBrutto){
						$(this.elRoomPrice).setHTML(this.data[idx].ROOMDATA.PRERENDER.COSTSBRUTTO);
						$(this.elRoomPriceDesc).setHTML(this.data[idx].ROOMDATA.PRERENDER.DAYSBRUTTO);
						$(this.elVisTaxCost).setHTML(sJSTax);
					}else{
						$(this.elRoomPrice).setHTML(this.data[idx].ROOMDATA.PRERENDER.COSTSNETTO);
						$(this.elRoomPriceDesc).setHTML(this.data[idx].ROOMDATA.PRERENDER.DAYSNETTO);
						$(this.elVisTaxCost).setHTML(this.options.txtIncluded);
					}
					$(this.elRoomPriceTotal).addClass('upgrade');
					
					//$('mp_form_cost').value = this.data[idx].ROOMDATA.COSTTOTAL;
					$('mp_form_roomrate').value = this.data[idx].ROOMRATE;
					$(this.elVisRateCost).setHTML(sJSPriceTotalPretax);
					//$(this.elVisTotalCost).setHTML(sJSPriceTotal);

					
					
					// set Upselling visualisation
					var sExt = this.options.txtExt + ' ( +' + sJSPrice + ')';
					if($defined($('roominfoext'))){
						elExt = $('roominfoext');
					}else{
						var elExt = new Element('h6',{'id':'roominfoext','class':'upgrade'});
						elExt.injectBefore($(this.elRoomName1));
					}
					
					if(window.ie6)$(sShadowId).removeClass('shadow');
					$(this.sEl + el.ID).effect('opacity',{onComplete:function(){},fps:this.options.fps, duration: this.options.fadedurration}).start(0.3);
					
					this.selectedUpSelling = el.ID;
					
					// add delete bullet
					elExt.setHTML(sExt);
					$(this.elRoomCont).adopt(this.elBttDel);
					$(this.elBttDel).setStyle('display','block');
					
					mp.reservationTracker.track({'upsellingID':this.data[idx].ROOMRATE,'upsellingSet':1});
					
					// scroll to top
					if($defined(mp.windowScroller) && $defined($(this.options.elId2Scoll2afterSelect))){
						mp.windowScroller.toElement(this.options.elId2Scoll2afterSelect);
					}
					
				}else{
					// deselect Upselling
					$(this.sEl + el.ID).effect('opacity',{onComplete:function(){if(window.ie6)$(sShadowId).addClass('shadow');},fps:this.options.fps, duration: this.options.fadedurration}).start(1);
					
				}
			},this);
		}
	},
	resetUpselling: function(){
		this.selectedUpSelling = 0;
		$(this.elRoomName1).setHTML(this.oldData.RoomName1);
		if($defined($(this.elRoomName2)))$(this.elRoomName2).setHTML(this.oldData.RoomName2);
		
		$(this.elRoomPrice).setHTML(this.oldData.RoomPrice);
		$(this.elRoomPriceDesc).setHTML(this.oldData.RoomPriceDesc);
		
		$(this.elVisRateCost).setHTML(this.oldData.RoomPriceTotal);
		eval(this.options.oPriceCalc).removeValue('_upsell');
		$(this.elVisTaxCost).setHTML(this.oldData.TaxCost);
		$(this.elRoomDesc).setHTML(this.oldData.Descr);
		$(this.elRoomImg).setProperty('src',this.oldData.Img);
		$(this.elRoomName1).removeClass('upgrade');
		if($defined($(this.elRoomName2)))$(this.elRoomName2).removeClass('upgrade');
		$('mp_form_roomrate').value = this.oldData.RoomRate;
		if($defined('roominfoext'))$('roominfoext').remove();
		if($defined('prevselbtt'))$('prevselbtt').remove();
		$(this.elChangeBtt).setStyle('display','block');
		this.data.each(function(el,idx){
			if(window.ie6)$(this.sEl + '_shadow' + el.ID).addClass('shadow');
			$(this.sEl + el.ID).effect('opacity',{fps:this.options.fps, duration: this.options.fadedurration}).start(1);
		},this);
		
		mp.reservationTracker.track({'upsellingID':0,'upsellingCancel':1});
	}
	
	
});
mp.reservation.upselling.implement(new Options, new Events);

mp.reservation.priceTotalStep2 = new Class({
	options: {
		currency:'EUR',			// current currency
		elInputCost:'mp_form_cost'
	},
	initialize: function(priceTotal,oVis,options){
		this.setOptions(options);
		// init vars
		
		this.priceTotal = priceTotal;
		this.oVis = oVis;
		
		this.values = new Hash();
	},
	setValue: function(value,key){
		this.values.set(key,value.toFloat());
		this.printPrice();
	},
	removeValue: function(key){
		this.values.remove(key);
		this.printPrice();
	},
	reset: function(){
		this.values.empty();
	},
	printPrice: function(){
		var iPrice = this.priceTotal.toFloat();
		this.values.each(function(_val,_key){
			iPrice = iPrice + _val.toFloat();
		},this);
		$(this.options.elInputCost).value = iPrice;
		this.oVis.setHTML(number_format(iPrice,2,'.','`')+ ' ' + this.options.currency);
	}
});
mp.reservation.priceTotalStep2.implement(new Options, new Events);

mp.reservation.enhancement = new Class({
	options: {
		fadedurration:600,  	// time for animation
		fps:50,					// farmes per second
		currency:'EUR',			// current currency	
		sFornFieldSelectesPackages:'enhancements',
		oPriceCalc:'oPriceTotal',
		txt:{
			Add:'add',
			Remove:'remove',
			errorDate:'Please select a Date!',
			p:'Persons %count%',
			c:'Childs %count%',
			a:'Adults %count%'
		}
	},
	initialize: function(oEnh,oCost,oForm,data,nights,options){

		this.setOptions(options);
		// init vars

		this.oEnh = $(oEnh);
		this.oCost = $(oCost);
		this.oForm = $(oForm);
		
		this.data = data;
		this.nights = nights;
		
		this.added = new Array();
		this.ids = new Array();

	},
	addEnhancement: function(packagecode){
		if($defined(this.data[packagecode])){
			
			var data = this.data[packagecode];

			if(this.added.indexOf(packagecode) == -1){
			// add Enhancement
				
				
				// calc Price
				var priceCalculated = 0;
				if(data.CHARGETYPE == 1){
					priceCalculated = parseFloat(data.MULTIPLICATORPRICE[0]);
				}
				if(data.CHARGETYPE == 2){
					priceCalculated = parseInt(this.oForm[data.MULTIPLICATORSELECT[0]].value,10) * parseFloat(data.MULTIPLICATORPRICE[0]);
				}
				if(data.CHARGETYPE == 3){
					var priceCalculated = "";
					for(var i=0; i<data.MULTIPLICATORPRICE.length;i++){
						priceCalculated += parseInt(this.oForm[data.MULTIPLICATORSELECT[i]].value,10) * parseFloat(data.MULTIPLICATORPRICE[i]);
						priceCalculated = parseFloat(priceCalculated);
					}
				}
				
				// multiply with nights
				if(data.PERNIGHT && data.NODATE){
					priceCalculated = priceCalculated*this.nights;
				}
				if(!data.NODATE){
					iDateMulti = mp.getSelectedValues(this.oForm[data.DATEEL]).length.toInt();
					priceCalculated = priceCalculated*iDateMulti;
				}else{
					iDateMulti = 1;
				}
				
				// exit if no date is selected
				if(iDateMulti == 0){
					if(!$defined($(data.ELEMENT).getElement('.error')))
						new Element('div',{'class':'error'}).setHTML(this.options.txt.errorDate).injectAfter(this.oForm[data.DATEEL]);
					return;
				}else{
					if($defined($(data.ELEMENT).getElement('.error')))
						$(data.ELEMENT).getElement('.error').remove();
				}
				
				// change Button
				$(data.ELEMENT).addClass('selected');
				$(data.ELEMENT).getElement('.button a span span span').setHTML(this.options.txt.Remove);
				
				// add enhancement to cost-list
				var elP = new Element('p',{id:packagecode});
				elP.adopt(new Element('span').setHTML(data.TITLE));
				elP.adopt(new Element('span',{'class':'price'}).setHTML(number_format(priceCalculated,2,'.','`') + ' ' + this.options.currency));
				
				if(data.MULTIPLICATORSELECT.length){
					if(data.CHARGETYPE == 2){
						elP.adopt(new Element('span').setHTML(this.options.txt.p.replace(/%count%/,this.oForm[data.MULTIPLICATORSELECT[0]].value)));
					}
					if(data.CHARGETYPE == 3){
						var txt = "";
						for(var i=0; i<data.MULTIPLICATORSELECT.length;i++){
							txt += this.options.txt[data.MULTIPLICATORPRICETYPE[i]].replace(/%count%/,this.oForm[data.MULTIPLICATORSELECT[i]].value);
							if(i<data.MULTIPLICATORSELECT.length-1){
								txt += ' / '
							}
						}
						elP.adopt(new Element('span').setHTML(txt));
					}
				}
				elP.injectBefore(this.oCost.getElement('p.total'));
				
				$(data.ELEMENT).getElements('select').setProperty('disabled','disabled');
				
				this.added.push(packagecode);
				$(data.ELEMENT).getElements('select').each(function(el,idx){
					this.ids.push(el.name);
				},this);
				
				eval(this.options.oPriceCalc).setValue(priceCalculated,packagecode);
				
				mp.reservationTracker.track({'crosssellingID':packagecode,'crosssellingSet':1});
				
			}else{
			// remove Enhancement
				
				$(data.ELEMENT).getElements('select').removeProperty('disabled');
				
				
				// change Button
				$(data.ELEMENT).removeClass('selected');
				$(data.ELEMENT).getElement('.button a span span span').setHTML(this.options.txt.Add);
				 
				// remove enhancement from cost-list
				this.oCost.getElement('p#' + packagecode).remove();
				
				this.added.remove(packagecode);
				$(data.ELEMENT).getElements('select').each(function(el,idx){
					this.ids.remove(el.name);
				},this);
				
				eval(this.options.oPriceCalc).removeValue(packagecode);
				
				mp.reservationTracker.track({'crosssellingID':packagecode,'crosssellingCancel':1});
			}
			this.oForm[this.options.sFornFieldSelectesPackages].value = this.added;
		}
	}
});
mp.reservation.enhancement.implement(new Options, new Events);

mp.reservation.tracker = new Class({
	initialize: function(pid,fid,hcode){
		this.pid = pid;
		this.fid = fid;
		this.hcode = hcode;
		this.uri = encodeURIComponent(document.URL);
		this.res = encodeURIComponent(screen.width+"X"+screen.height);
		this.depth = encodeURIComponent(screen.colorDepth);
		this.java = encodeURIComponent(navigator.javaEnabled());
		this.plat = encodeURIComponent(navigator.platform);
		this.ref = encodeURIComponent(document.referrer);
		this.iSessID = 0;
	},
	
	createCookie : function(name,value,minutes) {
		if (minutes) {
			var date = new Date();
			date.setTime(date.getTime()+(minutes*60*1000));
			var expires = "; expires="+date.toGMTString();
		}
		else var expires = "";
		document.cookie = name+"="+value+expires+"; path=/";
	},
	
	readCookie : function(name) {
		var nameEQ = name + "=";
		var ca = document.cookie.split(';');
		for(var i=0;i < ca.length;i++) {
			var c = ca[i];
			while (c.charAt(0)==' ') c = c.substring(1,c.length);
			if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
		}
		return null;
	},
	
	track : function(params){
		// read or write cookie (for 1 days)
		this.iSessID = this.readCookie('cSessID');
		if (!this.iSessID){
			var dSess = new Date();
			this.iSessID = dSess.getTime() * 1000 + Math.round(Math.random() * 1000);
			this.createCookie('cSessID',this.iSessID,20);
		}
		
		var urlTrack = mp.appPath + "tracker/tracker.cfm?uri="+this.uri+"&pid="+this.pid+"&fid="+this.fid+"&hcode="+this.hcode+"&res="+this.res+"&cat="+0+"&col="+this.depth+"&jav="+this.java+"&pla="+this.plat+"&ref="+this.ref+"&sid="+this.iSessID+"&";
		var urlTrackExt = Object.toQueryString(params);
		
		var oAjaxTracker = new Ajax(urlTrack + urlTrackExt, {
			method: 'get'
		}).request();
	}
});
mp.reservation.tracker.implement(new Options, new Events);

mp.reservation.checkSatForm = function(elForm,oTxt){
	this.bReturn = true;
	
	// set start & end date
	this.aSdMY = elForm.fStartdateMY.value.split('/');
	this.aEdMY = elForm.fEnddateMY.value.split('/');
	
	this.sSd = this.aSdMY[0] + '/' + elForm.fStartdateDay.value + '/' + this.aSdMY[1];
	this.sEd = this.aEdMY[0] + '/' + elForm.fEnddateDay.value + '/' + this.aEdMY[1];
	
	elForm.sStartdate.value = this.sSd;
	elForm.sEnddate.value = this.sEd;
	this.test = elForm.iAdults.value;
	this.test1 = elForm.iChildren.value;

	// validate dates
	if(!mp.reservation.checkSatFormDate(elForm.fStartdateMY,"start",oTxt.date)){
		this.bReturn = false;
	}
	if(!mp.reservation.checkDate(elForm.fStartdateMY,oTxt.date)){
		this.bReturn = false;
	}
	
	// validate persons
	if(elForm.iAdults.value == '0' && elForm.iChildren.value == '0'){
		alert(oTxt.persons);
		this.bReturn = false;
	}
	return this.bReturn;
}
mp.reservation.checkDate = function(elForm, type, txtError){
	//alert("checkDate");
	//mp.reservation.pause(2000);
	var sFalseDateErrorID = 'mp_form_ressat_dateerror';
	
	this.aSdMY = elForm.form.fStartdateMY.value.split('/');
	this.aSd = new Array();
	this.aSd[0] = elForm.form.fStartdateDay.value.toInt();
	this.aSd[1] = this.aSdMY[0].toInt();
	this.aSd[2] = this.aSdMY[1].toInt();
	
	this.aEdMY = elForm.form.fEnddateMY.value.split('/');
	this.aEd = new Array();
	this.aEd[0] = elForm.form.fEnddateDay.value.toInt();
	this.aEd[1] = this.aEdMY[0].toInt();
	this.aEd[2] = this.aEdMY[1].toInt();
	/*
	 alert(this.aSd[0]);
	 alert(this.aSd[1]);
	 alert(this.aSd[2]);
	 */
	if (type == "start") {
		var myYearStr = this.aSd[2];
		var myMonthStr = this.aSd[1];
		var myDayStr = this.aSd[0];
	}
	else {
		var myYearStr = this.aEd[2];
		var myMonthStr = this.aEd[1];
		var myDayStr = this.aEd[0];
	}
	
	var myDateStr = myDayStr + '.' + myMonthStr + '.' + myYearStr;
	if (type == "start") {
		var myMonthStr = this.aSd[1] - 1;
	}
	else {
		var myMonthStr = this.aEd[1] - 1;
	}
	
	var myDate = new Date();
	myDate.setFullYear(myYearStr, myMonthStr, myDayStr);
	
	if (myDate.getMonth() != myMonthStr) 
	{
	
		var display = $defined($(sFalseDateErrorID));
		//var display = false;
		if (display) {
		
			var oDateErrorInfo = $(sFalseDateErrorID);
			oDateErrorInfo.setStyle('opacity', 0.2);
		}
		else {
			var oDateErrorInfo = new Element('DIV', {id: sFalseDateErrorID,'class': 'date_error'});
			oDateErrorInfo.innerHTML = txtError;			
			oDateErrorInfo.adopt(new Element('DIV', {'class': 'clear'}));
			oDateErrorInfo.setStyle('opacity', 0);
		}
		oDateErrorInfo.injectTop(elForm.form.fStartdateMY.parentNode.parentNode);
		oDateErrorInfo.effects({duration: 500,transition: Fx.Transitions.Sine.easeInOut}).start({'height': 14,'opacity': 0.5,'padding': 3});
	
		return false;
	}
	else
	{
		
		if($defined($(sFalseDateErrorID)))
		{
			$(sFalseDateErrorID).effects({onComplete:function(){$(sFalseDateErrorID).remove();},duration: 500,transition: Fx.Transitions.Sine.easeInOut}).start({'height': 1, 'opacity': 0, 'padding': 0});
		}
		return true;
	}
	
}

mp.reservation.pause = function(millis)
{
	var date = new Date();
	var curDate = null;
	
	do { curDate = new Date(); }
	while(curDate-date < millis);
	
}
mp.reservation.checkSatFormDate = function(elForm,type,txtError){
	
	var sDateErrorID = 'mp_form_ressat_dateerror';
	//Validation 1
	// set start & end date
	this.aSdMY = elForm.form.fStartdateMY.value.split('/');
	this.aSd = new Array();
	this.aSd[0] = elForm.form.fStartdateDay.value.toInt();
	this.aSd[1] = this.aSdMY[0].toInt();
	this.aSd[2] = this.aSdMY[1].toInt();

	this.aEdMY = elForm.form.fEnddateMY.value.split('/');
	this.aEd = new Array();
	this.aEd[0] = elForm.form.fEnddateDay.value.toInt();
	this.aEd[1] = this.aEdMY[0].toInt();
	this.aEd[2] = this.aEdMY[1].toInt();
	
	this.dSd = new Date(this.aSd[2],this.aSd[1]-1,this.aSd[0]);
	this.dEd = new Date(this.aEd[2],this.aEd[1]-1,this.aEd[0]);
	
	this.diffNow = dateDiff('d',Date(),this.dSd);

	// set end date if startdate is after enddate
	if(type == 'start' && dateDiff('d',this.dSd,this.dEd) <= 0){
		this.dEd = dateAdd('d',1,this.dSd);
		mp.setOptionByValue(elForm.form.fEnddateMY,datePart('m',this.dEd) + '/' + datePart('yyyy',this.dEd));
		mp.setOptionByValue(elForm.form.fEnddateDay,datePart('d',this.dEd));
	}
	
	//Validation 2
	if (type == "start") {
		var myYearStr = this.aSd[2];
		var myMonthStr = this.aSd[1];
		var myDayStr = this.aSd[0];
	}
	else {
		var myYearStr = this.aEd[2];
		var myMonthStr = this.aEd[1];
		var myDayStr = this.aEd[0];
	}
	
	var myDateStr = myDayStr + '.' + myMonthStr + '.' + myYearStr;
	if (type == "start") {
		var myMonthStr = this.aSd[1] - 1;
	}
	else 
	{var myMonthStr = this.aEd[1] - 1;}
	
	var myDate = new Date();
	myDate.setFullYear(myYearStr, myMonthStr, myDayStr);
	
	
	if(this.dEd-this.dSd <= 0 || this.diffNow < 0){
		
		if($defined($(sDateErrorID))){
			var oDateErrorInfo = $(sDateErrorID);
			oDateErrorInfo.setStyle('opacity',0.2);
		}else{
			var oDateErrorInfo = new Element('DIV',{id:sDateErrorID,'class':'date_error'});
			oDateErrorInfo.innerHTML = txtError;
			oDateErrorInfo.adopt(new Element('DIV',{'class':'clear'}));
			oDateErrorInfo.setStyle('opacity',0);
		}
		oDateErrorInfo.injectTop(elForm.form.fStartdateMY.parentNode.parentNode);
		oDateErrorInfo.effects({duration: 500, transition: Fx.Transitions.Sine.easeInOut}).start({'height': 14, 'opacity': 0.5,'padding': 3});
		
		
		/*if(type == 'start'){
			
			var dNewEnd = dateAdd('d',1,this.dSd);
			mp.setOptionByValue(elForm.form.fEnddateMY,datePart('m',dNewEnd) + '/' + datePart('yyyy',dNewEnd));
			mp.setOptionByValue(elForm.form.fEnddateDay,datePart('d',dNewEnd));
		}else{
			var dNewSart = dateAdd('d',-1,this.dEd);
			mp.setOptionByValue(elForm.form.fStartdateMY,datePart('m',dNewSart) + '/' + datePart('yyyy',dNewSart));
			mp.setOptionByValue(elForm.form.fStartdateDay,datePart('d',dNewSart));
		}*/
		return false;
	}
	
	
	else if (myDate.getMonth() != myMonthStr) 
	{
		if ($defined($(sDateErrorID))) {
			var oDateErrorInfo = $(sDateErrorID);
			oDateErrorInfo.setStyle('opacity', 0.2);
		}
		else {
			var oDateErrorInfo = new Element('DIV', {id: sDateErrorID,'class': 'date_error'});
			oDateErrorInfo.innerHTML = txtError;			
			oDateErrorInfo.adopt(new Element('DIV', {'class': 'clear'}));
			oDateErrorInfo.setStyle('opacity', 0);
		}
		oDateErrorInfo.injectTop(elForm.form.fStartdateMY.parentNode.parentNode);
		oDateErrorInfo.effects({duration: 500,transition: Fx.Transitions.Sine.easeInOut}).start({'height': 14,'opacity': 0.5,'padding': 3});
		
	}
	else
	{
		if($defined($(sDateErrorID)))
		{
			$(sDateErrorID).effects({onComplete:function(){$(sDateErrorID).remove();},duration: 500,transition: Fx.Transitions.Sine.easeInOut}).start({'height': 1, 'opacity': 0, 'padding': 0});
		}
		return true;
	}
}
mp.setOptionByValue = function(elOpt,val){
	for(var iOpt = 0; iOpt< elOpt.options.length; iOpt++){
		if(elOpt.options[iOpt].value == val){
			elOpt.options.selectedIndex = iOpt;
			break;
		}
	}
}
mp.getSelectedValues = function(elOpt){
	var aReturn = new Array();
	if(elOpt.tagName == "SELECT"){
		for(var iOpt = 0; iOpt< elOpt.options.length; iOpt++){
			if(elOpt.options[iOpt].selected){
				aReturn.push(elOpt.options[iOpt].value);
			}
		}
	}
	if(elOpt.tagName == "INPUT"){
		aReturn.push(elOpt.value);
	}
	return aReturn;
}

mp.roomsDiningObject = new Class({
	options: {
		fadedurration:300,
		fps:50,
		instanceID:0,
		popupPadding:20,
		removeSWFlink:false,
		flashOffset:0,
		reservationLink:''
	},
	initialize: function(elSlider,elContent,data,options){

		this.elSlider = $(elSlider);
		this.elContent = $(elContent);
		this.data = data;
		this.visGallery = false;
		this.visTabs = false;
		this.visDetails = true;
		this.iCurrentTab = 0;
		this.iTabStatus = 0;
		
		this.currData = 0;
		
		this.setOptions(options);
		
		this.iID = this.options.instanceID;
		
		if (elSlider.length) {
			this.elSlider.getElements('li').each(function(el, idx, ar){
				el.onclick = this.setRoomType.bindAsEventListener(this, idx);
			}, this);
			
			this.elSlider.getElement('a.next').onclick = this.nextSlider.bindAsEventListener(this);
			this.elSlider.getElement('a.prev').onclick = this.prevSlider.bindAsEventListener(this);
			
			this.scroller = new Fx.Scroll(this.elSlider.getElement('div.mp_scroller_cont'), {
				wait: false,
				duration: 600,
				transition: Fx.Transitions.Cubic.easeInOut
			});
			// init opacity
			this.elSlider.getElements('li').each(function(el, index, ar){
				if (index) {
					el.getElement('img').setStyle('opacity', 0.3);
				}
				else {
					el.getElement('img').setStyle('opacity', 1);
				}
			});
		}
		
		this.setRoomType(new Object(),0);
		
	},
	setRoomType:function(event,idx){
		var data = this.data[idx];
		this.currData = idx;
		
		if(!this.visDetails){
			this.hideTabDetail();
		}

		// set slider
		if ($defined(this.elSlider)) {
			this.elSlider.getElements('li').each(function(el, index, ar){
				var opacityFx = new Fx.Style(el.getElement('img'), 'opacity', {
					fps: this.options.fps,
					duration: (this.options.fadedurration).toInt()
				});
				if (idx == index) {
					el.addClass('active');
					opacityFx.start(1);
				}
				else {
					el.removeClass('active');
					opacityFx.start(0.3);
				}
			}, this);
			var newScroll = idx * 150 - 150;
			this.scroller.scrollTo(newScroll, 0);
		}
		
		// set bookbutton
		
		if($defined(data.GCLINK) && data.GCLINK.length){
			this.elContent.getElement('#mp_rds_' + this.iID + 'bttbook').setStyle('display','block');
			this.elContent.getElement('#mp_rds_' + this.iID + 'bttbook a').setProperty('href',this.options.reservationLink + '&detailLink=' + data.GCLINK);
		}else if($defined(data.BOOKBUTTON) && this.options.reservationLink.length){
			this.elContent.getElement('#mp_rds_' + this.iID + 'bttbook').setStyle('display','block');
			this.elContent.getElement('#mp_rds_' + this.iID + 'bttbook a').setProperty('href',this.options.reservationLink + data.BOOKBUTTON.ID);
		}else{
			this.elContent.getElement('#mp_rds_' + this.iID + 'bttbook').setStyle('display','none');
		}
		
		// clear tabs
		this.elContent.getElement('.tabnav').empty();
		
		// add tabs
		for(var i = 0; i<data.TABS.length;i++){
			if(i == 0){
				li = new Element('li',{'class':''}).adopt( new Element('div').setHTML(data.TABS[i].NAME)); //class = active to highlight tab after page loading
				if($defined(data.TABS[i].CLASSADD) && data.TABS[i].CLASSADD.length)
					this.elContent.getElement('.tabcontent').addClass(data.TABS[i].CLASSADD);
				$('mp_rds_' + this.iID + 'tabcontent').setHTML(data.TABS[i].CONTENT);
			}
			else{
				li = new Element('li').adopt( new Element('div').setHTML(data.TABS[i].NAME));
			}
			// link tab
			classAdd = "";
			if($defined(data.TABS[i].CLASSADD) && data.TABS[i].CLASSADD.length)classAdd = data.TABS[i].CLASSADD;
			showGallery = true;
			if($defined(data.TABS[i].SHOWGALLERY) && data.TABS[i].SHOWGALLERY == false)showGallery = false;

			li.onclick = this.setTabDetail.bindAsEventListener(this,{index:i,content:data.TABS[i].CONTENT,showGallery:showGallery,classAdd:classAdd});
			this.elContent.getElement('.tabnav').adopt(li);
		}
		
		// clear images
		$('mp_rds_' + this.iID + 'gallery').empty();
		
		$('mp_rds_' + this.iID + 'gallery').adopt(new Element('div'));
		// add smallImages
		data.SMALLIMGS.each(function(sImg,i){
			aEl = new Element('a',{href:'javascript: void(0);'}).adopt( new Element('img',{src:sImg.TEASER.SRC,height:sImg.TEASER.HEIGHT,width:sImg.TEASER.WIDTH}));
			aEl.onclick = this.setBigImg.bindAsEventListener(this,{index:i,content:sImg.NORMAL});
			$('mp_rds_' + this.iID + 'gallery').getElement('div').adopt(aEl);
		},this);
		
		// set first big Img
		$('mp_rds_' + this.iID + 'gallery').adopt(new Element('div',{'id':'imageClipperBig'}).adopt(new Element('img',{'class':'enlarged',src:data.SMALLIMGS[0].NORMAL.SRC,height:data.SMALLIMGS[0].NORMAL.HEIGHT,width:data.SMALLIMGS[0].NORMAL.WIDTH})));
		
		// set Flash Popup
		if($defined(data.FLASH.LINK) && mp.hasFlash){

			$('mp_rds_' + this.iID + 'bttflash').setStyle('display','block');
			$('mp_rds_' + this.iID + 'bttflash').onclick = this.show360Flash.bindAsEventListener(this);
			
		}else{
			$('mp_rds_' + this.iID + 'bttflash').setStyle('display','none');
			$('mp_rds_' + this.iID + 'links').setStyle('display','none');
		}
		
		if(this.visDetails){
			this.showTabDetail();
		}
	},
	nextSlider:function(){
		var newScroll = this.elSlider.getElement('div.mp_scroller_cont').scrollLeft + 150;
		this.scroller.scrollTo(newScroll,0);
	},
	prevSlider:function(){
		var newScroll = this.elSlider.getElement('div.mp_scroller_cont').scrollLeft - 150;
		this.scroller.scrollTo(newScroll,0);
	},
	setTabDetail:function(event,args){
		//close tab if same tab is clicked twice (not yet completely implemented)
		if(this.iCurrentTab == args.index)
		{
			if(this.iTabStatus == 1) {
				this.hideTabDetail();
				this.iTabStatus = 0;
				$('mp_contentblock_rds' + this.iID).setStyle('display','none');
			} else {
				$('mp_contentblock_rds' + this.iID).setStyle('display','block');
				this.showTabDetail();
				this.iTabStatus = 1;
			}
		} else {
				$('mp_contentblock_rds' + this.iID).setStyle('display','block');		
				this.showTabDetail();
				this.iTabStatus = 1;	
		}
		
		if(!args.showGallery && this.visGallery){
			this.hideGallery();
		}
		if(args.showGallery && !this.visGallery){
			this.showGallery();
		}
		
		this.elContent.getElements('.tabnav li').each(function(el,idx){
			if(args.index == idx){
				if (this.iTabStatus == 1) {
					el.addClass('active');
				} else {
					el.removeClass('active');
				}
				
			}else{
				el.removeClass('active');
			}
		},this);
		$('mp_rds_' + this.iID + 'tabcontent').setHTML(args.content);
		if(args.classAdd.length)this.elContent.getElement('.tabcontent').addClass(args.classAdd);
		this.iCurrentTab = args.index;
		
	},
	hideTabDetail:function(){
		//this.elContent.getElement('.tabnav').setStyle('display','none');
		$('mp_rds_' + this.iID + 'tabcontent').setStyle('display','none');
		if($defined(this.data[this.currData].FLASH.LINK) && mp.hasFlash){
			$('mp_rds_' + this.iID + 'links').setStyle('display','block');
		}else{
			$('mp_rds_' + this.iID + 'links').setStyle('display','none');
		}
		$('mp_rds_' + this.iID + 'link_twocol').setStyle('display','none');
			
		this.visTabs = false;
	},
	showTabDetail:function(){
		showGallery = true;
		if($defined(this.data[this.currData].TABS[0].SHOWGALLERY) && this.data[this.currData].TABS[0].SHOWGALLERY == false)showGallery = false;

		if(!showGallery && this.visGallery){
			this.hideGallery();
		}
		if(showGallery && !this.visGallery){
			this.showGallery();
		}
		
		if(!this.visDetails){
			var elCont = $$('.detail_other .content');
			$$('.detail_other .content img.visual').setStyle('display','none');
			var aPEl = $$('.detail_other .content p');
			for(i = 0; i<aPEl.length; i++){
				if(aPEl[i].parentNode == elCont[0]){
					aPEl[i].remove();
				}
			}
			this.visDetails = true;
		}
		
		this.elContent.getElement('.tabnav').setStyle('display','block');
		$('mp_rds_' + this.iID + 'tabcontent').setStyle('display','block');
		$('mp_rds_' + this.iID + 'links').setStyle('display','none');
		
		if($defined(this.data[this.currData].FLASH.LINK) && mp.hasFlash){
			if(!this.options.removeSWFlink){
				
				$('mp_rds_' + this.iID + 'link_twocol').setStyle('display','block');
				$('mp_rds_' + this.iID + 'link_twocol').onclick = this.show360Flash.bindAsEventListener(this);
			}
		}else{
			$('mp_rds_' + this.iID + 'link_twocol').setStyle('display','none');
		}
		
		this.visTabs = true;
	},
	setBigImg:function(event,args){
		if($('mp_rds_' + this.iID + 'gallery').getElement('img.enlarged').getProperty('src') != args.content.SRC){
			var fxFade = new Fx.Style($('mp_rds_' + this.iID + 'gallery').getElement('img.enlarged'), 'opacity',{fps:this.options.fps, duration: (this.options.fadedurration/2).toInt()});
			
			// run animation of big image
			fxFade.stop();
			fxFade.start(0.01).chain(function(){
				fxFade.stop();
				fxFade.element.setProperties({
					'src':args.content.SRC,
					'height':args.content.HEIGHT,
					'width':args.content.WIDTH
				});
				fxFade.start(1);
			});
		}
	},
	hideGallery:function(){
		if(!$defined(this.fxGalFade))
			this.fxGalFade = new Fx.Style(this.elContent.getElement('.gallery'), 'opacity',{fps:this.options.fps, duration: (this.options.fadedurration/2).toInt()});
		if(!$defined(this.fxGalHeight))
			this.fxGalHeight = new Fx.Style(this.elContent.getElement('.gallery'), 'height',{fps:this.options.fps, duration: (this.options.fadedurration/2).toInt()});
		var fxGalHeight= this.fxGalHeight;
		this.fxGalFade.stop();
		this.fxGalFade.start(0.01).chain(function(){
			fxGalHeight.stop();
			fxGalHeight.start(1);
		});
		this.elContent.getElement('.gallery').setStyle("display", "none");
		this.visGallery = false;
	},
	showGallery:function(){
		this.elContent.getElement('.gallery').setStyle("display", "block");
		if(!$defined(this.fxGalFade))
			this.fxGalFade = new Fx.Style(this.elContent.getElement('.gallery'), 'opacity',{fps:this.options.fps, duration: (this.options.fadedurration/2).toInt()});
		if(!$defined(this.fxGalHeight))
			this.fxGalHeight = new Fx.Style(this.elContent.getElement('.gallery'), 'height',{fps:this.options.fps, duration: (this.options.fadedurration/2).toInt()});
		var fxGalFade= this.fxGalFade;
		this.fxGalHeight.stop();
		this.fxGalHeight.start(275).chain(function(){
			fxGalFade.stop();
			fxGalFade.start(1);
		});
		this.visGallery = true;
	},
	show360Flash:function(){
		var link = this.data[this.currData].FLASH.LINK;
		var offset = this.options.flashOffset.toInt();

		var popoptions = 'top=' + offset + ',left=' + offset + ',height='+ (screen.height - offset*2) +',width=' + (screen.width - offset*2);

		mp_flash360_popup=window.open(link,'360_Flash',popoptions);
		if (window.focus) {mp_flash360_popup.focus()}
	}
	
});
mp.roomsDiningObject.implement(new Options, new Events);


mp.hotelFinderSlider = new Class({
	options: {
		fadedurration:600,  // time for animation
		fps:50,				// farmes per second
		langID:1,			// language ID
		sFlashName:'main'		// name of the Flash Obj
	},
	initialize: function(elSlider,data,options){
		// init vars
		this.elSlider = $(elSlider);
		this.data = data;
		this.setOptions(options);
		//this.init();
		
		this.hasTipHotel = false;
		
		this.currRegion = -1;// current region
	},
	init:function(iRegion,iPos){
		
		// add events to slider objects
		var args;
		this.elSlider.getElements('li').each(function(el,idx,ar){
			args = new Array();
			args[0] = idx;
			args[1] = el.getProperty('rel');
			args[2] = 'js';
			el.onclick = this.setSlider.bindAsEventListener(this,args);
		},this);
		
		// add events to arrow buttons
		this.elSlider.getElement('a.next').onclick = this.nextSlider.bindAsEventListener(this);
		this.elSlider.getElement('a.prev').onclick = this.prevSlider.bindAsEventListener(this);
		
		// init scroller
		this.scroller = new Fx.Scroll(this.elSlider.getElement('div.mp_hfscroller_cont'), {
			wait: false,
			duration: 600,
			transition: Fx.Transitions.Cubic.easeInOut
		});
		
		// set first scroller on init
		if(!this.hasTipHotel){
			this.setSlider(new Object(),0,this.elSlider.getElement('li').getProperty('rel'),'js');
		}else{
			if($defined(iRegion) && $defined(iPos)){
				this.setSlider(new Object(),iRegion,iPos,'flash');
			}
			this.hasTipHotel = false;
		}
		
		// init opacity
		this.elSlider.getElements('li').each(function(el,index,ar){
			if(index){
				el.getElement('img').setStyle('opacity',0.3);
			}else{
				el.getElement('img').setStyle('opacity',1);
			}
		});

		
	},
	setSlider:function(event,idx,hotelid,typ){

		var ipos = this.getPosByHotelcode(hotelid);
		var data = this.data;
		// set slider
		this.elSlider.getElements('li').each(function(el,index,ar){
			// generate FX
			var opacityFx = new Fx.Style(el.getElement('img'), 'opacity',{fps:this.options.fps, duration: (this.options.fadedurration).toInt()});
			// set active or inactive
			if(idx == index){
				el.addClass('active');
				opacityFx.start(1);
			}else{
				el.removeClass('active');
				opacityFx.start(0.3);
			}
		},this);
		
		// scroll to new position
		var newScroll = idx*150-150;
		this.scroller.scrollTo(newScroll,0);
		
		var urlRelated = mp.appPath + 'mp_hotelfinder/view_related.cfm?id=' + hotelid + '&langid=' + this.options.langID;
		var urlContact = mp.appPath + 'mp_hotelfinder/view_contact.cfm?id=' + hotelid + '&langid=' + this.options.langID;
		var urlDesc = mp.appPath + 'mp_hotelfinder/view_desc.cfm?id=' + hotelid + '&langid=' + this.options.langID;
		var urlDist = mp.appPath + 'mp_hotelfinder/view_distances.cfm?id=' + hotelid + '&langid=' + this.options.langID;
		
		var oAjaxSlider = new Ajax(urlRelated, {
			method: 'get',
			update:$('mp_hfrelated')
		}).request();
				
		var oAjaxContact = new Ajax(urlContact, {
			method: 'get',
			update:$('mp_hfcontact')
		}).request();
		
		/*var oAjaxContact = new Ajax(urlDist, {
			method: 'get',
			update:$('mp_hfdistances')
		}).request();*/
		
		var oAjaxContact = new Ajax(urlDesc, {
			method: 'get',
			update:$('mp_hfdesc'),
			onComplete:function(){
				if(ipos >= 0)
				$('mp_hf_detailBtt').setProperty('href',data[ipos].link);
			}
		}).request();
		
		if(typ == 'js')
			this.setFlashPos(hotelid);
		
	},
	nextSlider:function(){
		// scroll to next slider element
		var newScroll = this.elSlider.getElement('div.mp_hfscroller_cont').scrollLeft + 150;
		this.scroller.scrollTo(newScroll,0);
	},
	prevSlider:function(){
		// scroll to prev slider element
		var newScroll = this.elSlider.getElement('div.mp_hfscroller_cont').scrollLeft - 150;
		this.scroller.scrollTo(newScroll,0);
	},
	refreshContent:function(iRegion,iSlPos,iPos){
		var urlSlider = mp.appPath + 'mp_hotelfinder/view_slider.cfm?countryid=' + iRegion + '&langid=' + this.options.langID;
		
		var oAjaxSlider = new Ajax(urlSlider, {
			method: 'get',
			update:$('mp_hfscroller'),
			onComplete:(function(){
				if($defined(iSlPos) && $defined(iPos)){
					this.init(iSlPos,iPos);
				}else{
					this.init();
				}
				$('dyncontent').setStyle('display', 'block');
				$('related').setStyle('display', 'block');
				}).bind(this)
		}).request();
	},
	getFlashObj:function(){
		if (window.ie) {
			return document[this.options.sFlashName];
		} else {
			return document[this.options.sFlashName];
		}
	},
	setFlashPos:function(hotelid){
		iPos = this.getPosByHotelcode(hotelid);
		if(iPos >= 0){
			this.setFlashVar(iPos);
		}
	},
	setFlashVar:function(iPos){
		objSWF = this.getFlashObj();
		if($defined(objSWF)){
			objSWF.sendToActionScript(iPos);
		}
	},
	setTipHotel:function(hotelid,showFlash){
		this.hasTipHotel = true;
		var oHotel = this.getHotelDataByCode(hotelid);
		this.refreshContent(oHotel.iregion,oHotel.iSlPos,oHotel.id);
	},
	getHotelDataByCode:function(hotelid){

		for(idx = 0;idx < this.data.length; idx++){
			if(this.data[idx].id == hotelid){
				return this.data[idx];
			}
		}
		return null;
	},
	getPosByHotelcode:function(hotelid){

		for(idx = 0;idx < this.data.length; idx++){
			if(this.data[idx].id == hotelid){
				return idx;
			}
		}
		return -1;
	},
	proxy4Flash:function(ireg,idest){
		if(this.currRegion==ireg && !isNaN(idest)){
			if($defined(oHotelSlider.scroller)){
				this.setSlider(null,this.data[idest].iSlPos,this.data[idest].id,'flash');
			}
		} else {
			if($type(ireg.toInt()) == "number" && !isNaN(ireg.toInt())){
				this.refreshContent(ireg);
			}
		}
		this.currRegion = ireg;
	}
	
});
mp.hotelFinderSlider.implement(new Options, new Events);

mp.ToolBox = new Class({
	options: {
		fadedurration:600,  // time for animation
		fps:24,				// farmes per second
		disabledTabs:'',	// Komma seperated List of Tabs which are disabled
		mininizeActive:true,	// disables the close function 
		heightAddOfTabs:29,	// tab height for calculation
		permanentadd:null,	// selector with element to add to the permanent height
		aTabNrsNotToClose:[],	// tab nr's with disabled close function
		aTabsRelatedToAvailCal:[], // tab nr's with a relation to the availibility calendar
		useAnimation:false,
		classes:{
			tab:'.tooltab_nav',
			content:'.ToolBoxContent'
		}
	},
	initialize: function(elBox,openTabNr,options){
		var oPermAdd;
		
		this.setOptions(options);
		
		this.openTabNr = openTabNr.toInt()-1;
		this.elBox = elBox;
		this.disabledTabs = this.options.disabledTabs.split(',');
		
		this.changeRunning = false;
		
		this.tabNavHeight = this.options.heightAddOfTabs.toInt();
		if(oPermAdd = this.elBox.getElement(this.options.permanentadd)){
			this.tabNavHeight += oPermAdd.getCoordinates().height;
		}
		if(this.options.useanimation){
			this.heightFx = new Fx.Style(this.elBox.getElement('.content'), 'height',{transition:Fx.Transitions.Expo.easeIn,fps:this.options.fps, duration: (this.options.fadedurration).toInt()});
		}
		// init tab buttons
		this.tabs = new Array();
		this.elBox.getElements( this.options.classes.tab + ' .tab').each(function(el,idx){
			this.tabs[idx] = {
				id: el.getProperty('id')
			};
			
			if(this.disabledTabs.indexOf(idx.toString()) < 0)
				el.onclick = this.setTabContent.bindAsEventListener(this,idx);
		},this);
		
		// init tab buttons
		this.contens = new Array();
		this.elBox.getElements(this.options.classes.content).each(function(el,idx){
			this.contens[idx] = {
				id: el.getProperty('id'),
				height: (el.offsetHeight + this.tabNavHeight).toInt()
			};
		},this);
		// open initial Tab
		this.contens.each(function(el,idx){
			if(this.openTabNr == idx){
				$(el.id).setStyle('display','block');
			}else{
				$(el.id).setStyle('display','none');
			}
		},this);
	},
	setTabContent: function(event,iNr){
		if(!this.changeRunning){
			if(iNr != this.openTabNr){
				this.changeRunning = true;
				// change Tab
				
				if(this.openTabNr >= 0)
					$(this.tabs[this.openTabNr].id).getElement('div').removeClass('active');
				
				if(this.options.useanimation){
					if(this.openTabNr >= 0)$(this.contens[this.openTabNr].id).effect('opacity',{onComplete:function(fxEl){fxEl.setStyle('display','none')},fps:this.options.fps, duration: (this.options.fadedurration/2).toInt()}).start(0);
					var fxFadeIn = new Fx.Style($(this.contens[iNr].id),'opacity',{fps:this.options.fps,onComplete:(function(){this.changeRunning = false;}).bind(this), duration: (this.options.fadedurration/2).toInt()});

					this.heightFx.start(this.contens[iNr].height).chain(function(){
						fxFadeIn.element.setStyles({'opacity':0,'display':'block'});
						fxFadeIn.start(1);
					},this);
				}else{
					this.elBox.getElement('.content').setStyle('height',this.contens[iNr].height);
					$(this.contens[iNr].id).setStyles({'opacity':1,'display':'block'});
					if(this.openTabNr >= 0)$(this.contens[this.openTabNr].id).setStyles({'opacity':0,'display':'none'});
					this.changeRunning = false;
				}
				
				$(this.tabs[iNr].id).getElement('div').addClass('active');
				
				if(this.options.aTabsRelatedToAvailCal.indexOf(iNr) != -1){
					if($defined(window.oCal))oCal.close();
				}
				
				this.openTabNr = iNr;
				
			}else{
				if(this.options.mininizeActive && this.options.aTabNrsNotToClose.indexOf(iNr) == -1){
					// close box
					if(this.options.useanimation){
						$(this.contens[this.openTabNr].id).effect('opacity',{onComplete:function(fxEl){fxEl.setStyle('display','none')},fps:this.options.fps, duration: (this.options.fadedurration/2).toInt()}).start(0);
						this.heightFx.start(this.tabNavHeight);
					}else{
						$(this.contens[this.openTabNr].id).setStyles({'opacity':0,'display':'none'});
						this.elBox.getElement('.content').setStyle('height',this.tabNavHeight);
					}
					$(this.tabs[this.openTabNr].id).getElement('div').removeClass('active');
					
					if(this.options.aTabsRelatedToAvailCal.indexOf(iNr) != -1){
						if($defined(window.oCal))oCal.open();
					}
					
					this.openTabNr = -1;
				}
			}
		}
	},
	closeTab: function(iNr){
		if(!this.changeRunning){
			if(iNr == this.openTabNr){
				if(this.options.mininizeActive && this.options.aTabNrsNotToClose.indexOf(iNr) == -1){
					// close box
					if(this.options.useanimation){
						$(this.contens[this.openTabNr].id).effect('opacity',{onComplete:function(fxEl){fxEl.setStyle('display','none')},fps:this.options.fps, duration: (this.options.fadedurration/2).toInt()}).start(0);
						this.heightFx.start(this.tabNavHeight);
					}else{
						$(this.contens[this.openTabNr].id).setStyles({'opacity':0,'display':'none'});
						this.elBox.getElement('.content').setStyle('height',this.tabNavHeight);
					}
					
					if(this.options.aTabsRelatedToAvailCal.indexOf(iNr) != -1){
						if($defined(window.oCal))oCal.open();
					}
					
					this.openTabNr = -1;
				}
			}
		}
	}
	
});
mp.ToolBox.implement(new Options, new Events);

mp.searchAsYouType = new Class({
	options: {
		fadedurration:600,  					// time for animation
		fps:50,									// frames per second
		urlAjaxSearch:'search/index.cfm',		// URL to search with JSON display 
		startAtChar:3,							// count of chars when the first search hat so start
		maxRows:8,								// count of max entrys to display
		delayToHideBox:7000,					// time in ms to hide box after a search 
		delayToHideBoxAfterMouseOut:1000,		// time in ms to hide box after leaving the Box with the mouse 
		delayToSearch:300,						// delay to start a new search while typing
		
		// -- filled by page-vars
		relPath:'',								// relPath to generate the links
		relPathHotel:'',						// relPath to generate the links
		lang_ID:1,								// lang_ID to seach for
		targetgroup_ID:1,						// targetgroup_ID to seach for
		channel_ID:1							// channel_ID to seach for
	},
	initialize: function(elInput,elBox,elList,options){
		this.setOptions(options);

		// check data
		if($type(elInput) == 'element'){
			this.elInput = elInput;
		}else{
			// exit quietly 
			return false;
		}
		if($type(elBox) == 'element'){
			this.elBox = elBox;
		}else{
			// exit quietly 
			return false;
		}
		if($type(elList) == 'element'){
			this.elList = elList;
		}else{
			// exit quietly 
			return false;
		}
		
		this.oAjaxSearch = new XHR({
			method: 'GET',
			onSuccess:this.displayResult.bind(this)
		});
		
		this.bBoxVisible = false; 
		
		this.elBox.setStyle('opacity',0);
		this.fxHideBox = new Fx.Style(this.elBox,'opacity',{fps:this.options.fps, duration: this.options.fadedurration});
		
		this.hideboxDelay = 0;
		this.bHideBox = false;
		
		this.searchDelay = 0;
		this.bStartSearch = false;
		
		this.data = new Array();
		
		elInput.onkeyup = this.checkForSearch.bindAsEventListener(this);
		elBox.addEvent('mouseleave', this.outBox.bind(this));
		elBox.addEvent('mouseenter', this.overBox.bind(this));
		
		document.addEvent('click', this.hideBox.bind(this,true));
	},
	checkForSearch:function(evnt){
		switch(evnt.keyCode){
			case 38:
				// onKey cursor up
				this.hideboxDelay = $clear(this.hideboxDelay);
			break;
			case 40:
				// onKey cursor down

				this.hideboxDelay = $clear(this.hideboxDelay);
			break;
			case 27:
				// onKey Esc
				this.bHideBox = true;
				this.hideBox(false);
			break;
			default:
				this.searchDelay = $clear(this.searchDelay);
				if(this.elInput.value.length >= this.options.startAtChar){
					this.searchDelay = this.startSearch.delay(this.options.delayToSearch,this,this.elInput.value);
				}
		}
	},
	startSearch:function(criteria){
		
		var oSearchParams = new Object();
		// add params
		oSearchParams.criteria = criteria; 
		oSearchParams.lang_ID = this.options.lang_ID;
		oSearchParams.targetgroup_ID = this.options.targetgroup_ID;
		oSearchParams.channel_ID = this.options.channel_ID;
		oSearchParams.relpath = this.options.relPath;
		oSearchParams.relpathHotel = this.options.relPathHotel;
		oSearchParams.maxRows = this.options.maxRows;
		
		this.fxHideBox.stop();
		this.oAjaxSearch.send(mp.appPath + this.options.urlAjaxSearch + '?' + Object.toQueryString(oSearchParams));
	},
	displayResult:function(content){
		this.data = eval(content);
		
		this.elList.empty();
		
		// generate HTMLElements
		var eLI = 0;
		var eA = 0;
		var eSPAN = 0;
		for(var i = 0; i< this.data.length; i++){
			eLI = 0;
			eA = 0;
			eSPAN = 0;	
			
			if(i == 0){
				eLI = new Element('LI',{'class':'first'});
			}else{
				eLI = new Element('LI');
			}
			eA = new Element('a',{'href':this.data[i].URL}).setHTML(this.data[i].TITEL);
			/*
			if(this.data[i].METADESC.length){
				eSPAN = new Element('SPAN').setHTML(this.data[i].METADESC);
			}else{
				eSPAN = new Element('SPAN').setHTML(this.data[i].SUMMARY);
			}*/
			eA.injectInside(eLI);
			//eSPAN.injectInside(eLI);
			
			this.elList.adopt(eLI);
		}
		
		if(window.ie6){
			$$('.tool .booknow fieldset div select').setStyle('display','none');
		}
		
		this.bBoxVisible = true; 
		this.elBox.setStyle('display','block');
		this.fxHideBox.start(1).chain(function(){
			this.bBoxVisible = true;
		},this);
		
		this.hideboxDelay = $clear(this.hideboxDelay); 
		this.bHideBox = true;
		this.hideboxDelay = this.hideBox.delay(this.options.delayToHideBox,this,false);
	},
	outBox:function(){
		this.hideboxDelay = $clear(this.hideboxDelay); 
		this.bHideBox = true;
		this.hideBox.delay(this.options.delayToHideBoxAfterMouseOut,this,false);
	},
	overBox:function(){
		this.hideboxDelay = $clear(this.hideboxDelay); 
		this.bHideBox = false;
	},
	hideBox:function(force){
		if(window.ie6){
			$$('.tool .booknow fieldset div select').setStyle('display','block');
		}
		if(this.bHideBox || force){
			this.fxHideBox.start(0).chain(function(){
				this.bBoxVisible = false;
				this.element.setStyle('display','block');
			},this);
		}
	}
});
mp.searchAsYouType.implement(new Options, new Events);





mp.LightFace = new Class({
	
	Implements: [Options,Events],
	
	options: {
		width: 'auto',
		height: 'auto',
		draggable: false,
		title: '',
		buttons: [],
		fadeDelay: 400,
		fadeDuration: 400,
		keys: { 
			esc: function() { this.close(); } 
		},
		content: '<p>Message not specified.</p>',
		zIndex: 9001,
		pad: 100,
		overlayAll: false,
		constrain: false,
		resetOnScroll: true,
		baseClass: 'lightface',
		errorMessage: '<p>The requested file could not be found.</p>'/*,
		onOpen: $empty,
		onClose: $empty,
		onFade: $empty,
		onUnfade: $empty,
		onComplete: $empty,
		onRequest: $empty,
		onSuccess: $empty,
		onFailure: $empty
		*/
	},
	
	
	initialize: function(options) {
		this.setOptions(options);
		this.state = false;
		this.buttons = {};
		this.resizeOnOpen = true;
		this.ie6 = typeof document.body.style.maxHeight == "undefined";
		this.draw();
	},
	
	draw: function() {
		//create main box
		this.box = new Element('table',{
			'class': this.options.baseClass,
			styles: {
				
				opacity: 0
			}, // 'z-index': this.options.zIndex,
			tween: {
				duration: this.options.fadeDuration,
				onComplete: function() {
					if(this.box.getStyle('opacity') == 0) {
						this.box.setStyles({ top: -9000, left: -9000 });
					}
				}.bind(this)
			}
		}).inject(document.body,'bottom');

		//draw rows and cells;  use native JS to avoid IE7 and I6 offsetWidth and offsetHeight issues
		var verts = ['top','center','bottom'], hors = ['Left','Center','Right'], len = verts.length;
		for(var x = 0; x < len; x++) {
			var row = this.box.insertRow(x);
			for(var y = 0; y < len; y++) {
				var cssClass = verts[x] + hors[y], cell = row.insertCell(y);
				cell.className = cssClass;
				if (cssClass == 'centerCenter') {
					this.contentBox = new Element('div',{
						'class': 'lightfaceContent',
						styles: {
							width: this.options.width
						}
					});
					cell.appendChild(this.contentBox);
				}
				else {
					//document.id(cell).setStyle('opacity',0.4);
				}
			}
		}
		
		//draw title
		if(this.options.title) {
			this.title = new Element('h2',{
				'class': 'lightfaceTitle',
				html: this.options.title
			}).inject(this.contentBox);
			if(this.options.draggable && window['Drag'] != null) {
				this.draggable = true;
				new Drag(this.box,{ handle: this.title });
				this.title.addClass('lightfaceDraggable');
			}
		}
		
		//draw message box
		this.messageBox = new Element('div',{
			'class': 'lightfaceMessageBox',
			html: this.options.content || '',
			styles: {
				height: this.options.height
			}
		}).inject(this.contentBox);
		
		//button container
		this.footer = new Element('div',{
			'class': 'lightfaceFooter',
			styles: {
				display: 'none'
			}
		}).inject(this.contentBox);
		
		//draw overlay
		this.overlay = new Element('div',{
			html: '&nbsp;',
			styles: {
				opacity: 0
			},
			'class': 'lightfaceOverlay',
			tween: {
				link: 'chain',
				duration: this.options.fadeDuration,
				onComplete: function() {
					if(this.overlay.getStyle('opacity') == 0) this.box.focus();
				}.bind(this)
			}
		}).inject(this.contentBox);
		if(!this.options.overlayAll) {
			this.overlay.setStyle('top',(this.title ? this.title.getSize().y - 1: 0));
		}
		
		//create initial buttons
		this.buttons = [];
		if(this.options.buttons.length) {
			this.options.buttons.each(function(button) {
				this.addButton(button.title,button.event,button.color);
			},this);
		}
		
		$('overlay').setStyles({display:'block', opacity:0.8, visibility: 'visible'});
		
		//focus node
		this.focusNode = this.box;
		
		return this;
	},
	
	// Manage buttons
	addButton: function(title,clickEvent,color) {
		this.footer.setStyle('display','block');
		var focusClass = 'lightfacefocus' + color;
		var label = new Element('label',{
			'class': color ? 'lightface' + color : '',
			events: {
				mousedown: function() {
					if(color) {
						label.addClass(focusClass);
						var ev = function() {
							label.removeClass(focusClass);
							//document.id(document.body).removeEvent('mouseup',ev);
						};
						//document.id(document.body).addEvent('mouseup',ev);
					}
				}
			}
		});
		this.buttons[title] = (new Element('input',{
			type: 'button',
			value: title,
			events: {
				click: (clickEvent || this.close).bind(this)
			}
		}).inject(label));
		label.inject(this.footer);
		return this;
	},
	showButton: function(title) {
		if(this.buttons[title]) this.buttons[title].removeClass('hiddenButton');
		return this.buttons[title];
	},
	hideButton: function(title) {
		if(this.buttons[title]) this.buttons[title].addClass('hiddenButton');
		return this.buttons[title];
	},
	
	// Open and close box
	close: function(fast) {
		if(this.isOpen) {
			//this.box[fast ? 'setStyles' : 'tween']('opacity',0);
			this.box.setStyles({display:'none', opacity:0, visibility: 'hidden'});
			this.fireEvent('close');
			this._detachEvents();
			this.isOpen = false;
			$('overlay').setStyles({display:'none', opacity:0, visibility: 'hidden'});
		}
		return this;
	},
	
	open: function(fast) {
		if(!this.isOpen) {
			//this.box[fast ? 'setStyles' : 'tween']('opacity',1);
			this.box.setStyles({display:'block', opacity:1, visibility: 'visible'});
			if(this.resizeOnOpen) this._resize();
			this.fireEvent('open');
			this._attachEvents();
			(function() {
				this._setFocus();
			}).bind(this).delay(this.options.fadeDuration + 10);
			this.isOpen = true;
			$('overlay').setStyles({display:'block', opacity:0.8, visibility: 'visible'});
		}
		return this;
	},
	
	_setFocus: function() {
		this.focusNode.setAttribute('tabIndex',0);
		this.focusNode.focus();
	},
	
	// Show and hide overlay
	fade: function(fade,delay) {
		this._ie6Size();
		(function() {
			this.overlay.setStyle('opacity',fade || 1);
		}.bind(this)).delay(delay || 0);
		this.fireEvent('fade');
		return this;
	},
	unfade: function(delay) {
		(function() {
			this.overlay.fade(0);
		}.bind(this)).delay(delay || this.options.fadeDelay);
		this.fireEvent('unfade');
		return this;
	},
	_ie6Size: function() {
		if(this.ie6) {
			var size = this.contentBox.getSize();
			var titleHeight = (this.options.overlayAll || !this.title) ? 0 : this.title.getSize().y;
			this.overlay.setStyles({
				height: size.y - titleHeight,
				width: size.x
			});
		}
	},
	
	// Loads content
	load: function(content,title) {
		if(content) this.messageBox.set('html',content);
		if(title && this.title) this.title.set('html',title);
		this.fireEvent('complete');
		return this;
	},
	
	// Attaches events when opened
	_attachEvents: function() {
		this.keyEvent = function(e){
			if(this.options.keys[e.key]) this.options.keys[e.key].call(this);
		}.bind(this);
		this.focusNode.addEvent('keyup',this.keyEvent);
		
		this.resizeEvent = this.options.constrain ? function(e) { 
			this._resize(); 
		}.bind(this) : function() { 
			this._position(); 
		}.bind(this);
		window.addEvent('resize',this.resizeEvent);
		
		if(this.options.resetOnScroll) {
			this.scrollEvent = function() {
				this._position();
			}.bind(this);
			window.addEvent('scroll',this.scrollEvent);
		}
		
		return this;
	},
	
	// Detaches events upon close
	_detachEvents: function() {
		this.focusNode.removeEvent('keyup',this.keyEvent);
		window.removeEvent('resize',this.resizeEvent);
		if(this.scrollEvent) window.removeEvent('scroll',this.scrollEvent);
		return this;
	},
	
	// Repositions the box
	_position: function() {
		var windowSize = window.getSize(), 
			scrollSize = { x:0, y:0}, //window.getScroll() 
			boxSize = this.box.getSize();
			//console.log(windowSize);
			//console.log(boxSize.size.x);
		this.box.setStyles({
			left: 100, //scrollSize.x + ((windowSize.x - boxSize.x) / 2)
			top: 100 //scrollSize.y + ((windowSize.y - boxSize.y) / 2)
		});
		this._ie6Size();
		return this;
	},
	
	// Resizes the box, then positions it
	_resize: function() {
		var height = this.options.height;
		if(height == 'auto') {
			//get the height of the content box
			var max = window.getSize().y - this.options.pad;
			if(this.contentBox.getSize().y > max) height = max;
		}
		this.messageBox.setStyle('height',height);
		this._position();
	},
	
	// Expose message box
	toElement: function () {
		return this.messageBox;
	},
	
	// Expose entire modal box
	getBox: function() {
		return this.box;
	},
	
	// Cleanup
	destroy: function() {
		this._detachEvents();
		this.buttons.each(function(button) {
			button.removeEvents('click');
		});
		this.box.dispose();
		delete this.box;
	}
});

mp.LightFace.implement(new Options, new Events);





















mp.changeFontSize = function(typ){

	var iCurrFontSizeIdx = mp.aFontSizes.indexOf(mp.iCurrFontSize);
	var bInCr = false;
	var bdeCr = false;
	
	if(typ == '+' && iCurrFontSizeIdx < mp.aFontSizes.length-1){
		iCurrFontSizeIdx = iCurrFontSizeIdx+1;
		bInCr = true;
	}
	if(typ == '-' && iCurrFontSizeIdx > 0){
		iCurrFontSizeIdx = iCurrFontSizeIdx-1;
		bdeCr = true;
	}
	if(bInCr || bdeCr){
		$E('body').setStyle('font-size',mp.aFontSizes[iCurrFontSizeIdx] + '%');
		// save setting to session
		var url = mp.appPath + 'mp_fontsize/index.cfm?iFontsize=' + (iCurrFontSizeIdx+1) + '&' + mp.sessionToken;
		var oAjax = new Ajax(url, {method: 'get'}).request();
		mp.iCurrFontSize = mp.aFontSizes[iCurrFontSizeIdx];
	}
	
	if(iCurrFontSizeIdx <= 0){
		$('mp_fontsize_switch_incr').getElement('img').setStyle('opacity',1);
		$('mp_fontsize_switch_decr').getElement('img').setStyle('opacity',0.3);
	}else if(iCurrFontSizeIdx >= mp.aFontSizes.length-1){
		$('mp_fontsize_switch_incr').getElement('img').setStyle('opacity',0.3);
		$('mp_fontsize_switch_decr').getElement('img').setStyle('opacity',1);
	}else{
		$('mp_fontsize_switch_incr').getElement('img').setStyle('opacity',1);
		$('mp_fontsize_switch_decr').getElement('img').setStyle('opacity',1);
	}
}

// Aaron Newton (aaron [dot] newton [at] cnet [dot] com)
var simpleTemplateParser = {
		STP: {},
/*	Property: parseTemplate
		Parses a template with the values of an object, substituting those values for all instances of the keys in the object found within the template.

		Arguments: 
		template - a string to parse
		object - the object with your key/value pairs
		regexOptions - the options for the regex replace; defaults to 'ig' (ignore case, global replace)
		wrappers - an object with the before and after strings that are on either side of your keys (see example);
			defaults to {before: "%", after: "%"}

		Example:
(start code)
<textarea id="myTemplate">
	<p>This is some html that lets me subsitute things.</p>
	<ul>
		<li>%firstThing%</li>
		<li>%secondThing%</li>
		<li>%thirdThing%</li>
	</ul>
</textarea>
<script>
	var myTemplate = $('myTemplate').innerHTML;
	var myObject = {
		firstThing: 'hi there',
		secondThing: 'howzit goin?',
		thirdThing: 'really? me too!'
	}
	var parsed = simpleTemplateParser.parseTemplate(myTemplate, myObject);
</script>(end)
	*/
	parseTemplate: function(template, object, regexOptions, wrappers) {
		var STP = this.STP;
		STP.template = template;
		STP.object = object;
		STP.regexOptions = $pick(regexOptions, 'ig');
		STP.wrappers = $pick(wrappers, {before:'%', after:'%'});
		return STP.result = this.runParser(STP.object, STP.template, STP.regexOptions);
	},
	runParser: function(object, string, regexOptions){
		for(value in object){
			switch($type(object[value])){
				case 'string':
					string = this.tmplSubst(value, object[value], string, regexOptions);
					break;
				case 'number':
					string = this.tmplSubst(value, object[value], string, regexOptions);
					break;
				case 'object':
					string = this.runParser(object[value]);
					break;
				case 'array':
					string = this.tmplSubst(value, object[value].toString(), string, regexOptions);
					break;
			}
		}
		return string;
	},
	tmplSubst: function(key, value, string, regexOptions){
		return string.replace(new RegExp(this.STP.wrappers.before+key+this.STP.wrappers.after, 'gi'), value);
	}
};

function /*out: String*/ number_format( /* in: float   */ number,
                                        /* in: integer */ laenge,
                                        /* in: String  */ sep,
                                        /* in: String  */ th_sep ) {

  number = Math.round( number * Math.pow(10, laenge) ) / Math.pow(10, laenge);
  str_number = number+"";
  arr_int = str_number.split(".");
  if(!arr_int[0]) arr_int[0] = "0";
  if(!arr_int[1]) arr_int[1] = "";
  if(arr_int[1].length < laenge){
    nachkomma = arr_int[1];
    for(i=arr_int[1].length+1; i <= laenge; i++){  nachkomma += "0";  }
    arr_int[1] = nachkomma;
  }
  if(th_sep != "" && arr_int[0].length > 3){
    Begriff = arr_int[0];
    arr_int[0] = "";
    for(j = 3; j < Begriff.length ; j+=3){
      Extrakt = Begriff.slice(Begriff.length - j, Begriff.length - j + 3);
      arr_int[0] = th_sep + Extrakt +  arr_int[0] + "";
    }
    str_first = Begriff.substr(0, (Begriff.length % 3 == 0)?3:(Begriff.length % 3));
    arr_int[0] = str_first + arr_int[0];
  }
  return arr_int[0]+sep+arr_int[1];
}

function clearsearchbox(txt) {
	if (document.searchsat.criteria.value==txt) 
		document.searchsat.criteria.value="";
}

var popupWindow;
mp.openWindow = function (url,width,height,scrollb) {
	
	var padding;
	(navigator.appName == "Microsoft Internet Explorer") ? (padding = 10) : (padding = 0);
	var screenWidth = screen.width;
	var screenHeight = screen.height;
	var windowWidth = (width + 15 + padding);
	var windowHeight = (height + 15 + padding);
	var posX = ((screenWidth / 2) - (windowWidth / 2)).toInt();
	var posY = ((screenHeight / 2) - (windowHeight / 2)).toInt();
	scrollbar = '0'; if($defined(scrollb))scrollbar = '1'; 
	var sPopOptions = 'top=' + posY + ',left=' + posX + ',height='+ windowHeight +',width=' + windowWidth+',resizable=1,status=1,scrollbars=' + scrollbar;
	popupWindow = window.open(url,'Terms',sPopOptions);
	if (window.focus) { popupWindow.focus(); }
}


/*

Name: jsDate
Desc: VBScript native Date functions emulated for Javascript
Author: Rob Eberhardt, Slingshot Solutions - http://slingfive.com/
History:
	2005-08-04	v0.94		scrapped new dateDiff approach to better match VBScript's simplistic Y/M/Q
	2005-08-03	v0.93		fixed dateDiff/leapyear bug with yyyy/m/q intervals
	2004-11-26	v0.91		fixed datePart/ww bug, added weekdayName() & monthName()
	2004-08-30	v0.9		brand new
	
*/

// used by dateAdd, dateDiff, datePart, weekdayName, and monthName
// note: less strict than VBScript's isDate, since JS allows invalid dates to overflow (e.g. Jan 32 transparently becomes Feb 1)
function isDate(p_Expression){
	return !isNaN(new Date(p_Expression));		// <<--- this needs checking
}


// REQUIRES: isDate()
function dateAdd(p_Interval, p_Number, p_Date){
	if(!isDate(p_Date)){return "invalid date: '" + p_Date + "'";}
	if(isNaN(p_Number)){return "invalid number: '" + p_Number + "'";}	

	p_Number = new Number(p_Number);
	var dt = new Date(p_Date);
	switch(p_Interval.toLowerCase()){
		case "yyyy": {// year
			dt.setFullYear(dt.getFullYear() + p_Number);
			break;
		}
		case "q": {		// quarter
			dt.setMonth(dt.getMonth() + (p_Number*3));
			break;
		}
		case "m": {		// month
			dt.setMonth(dt.getMonth() + p_Number);
			break;
		}
		case "y":		// day of year
		case "d":		// day
		case "w": {		// weekday
			dt.setDate(dt.getDate() + p_Number);
			break;
		}
		case "ww": {	// week of year
			dt.setDate(dt.getDate() + (p_Number*7));
			break;
		}
		case "h": {		// hour
			dt.setHours(dt.getHours() + p_Number);
			break;
		}
		case "n": {		// minute
			dt.setMinutes(dt.getMinutes() + p_Number);
			break;
		}
		case "s": {		// second
			dt.setSeconds(dt.getSeconds() + p_Number);
			break;
		}
		case "ms": {		// second
			dt.setMilliseconds(dt.getMilliseconds() + p_Number);
			break;
		}
		default: {
			return "invalid interval: '" + p_Interval + "'";
		}
	}
	return dt;
}
function dateDiff(p_Interval, p_Date1, p_Date2, p_firstdayofweek, p_firstweekofyear){
	if(!isDate(p_Date1)){return "invalid date: '" + p_Date1 + "'";}
	if(!isDate(p_Date2)){return "invalid date: '" + p_Date2 + "'";}
	var dt1 = new Date(p_Date1);
	var dt2 = new Date(p_Date2);

	// get ms between dates (UTC) and make into "difference" date
	var iDiffMS = dt2.valueOf() - dt1.valueOf();
	var dtDiff = new Date(iDiffMS);

	// calc various diffs
	var nYears  = dt2.getUTCFullYear() - dt1.getUTCFullYear();
	var nMonths = dt2.getUTCMonth() - dt1.getUTCMonth() + (nYears!=0 ? nYears*12 : 0);
	var nQuarters = parseInt(nMonths/3);	//<<-- different than VBScript, which watches rollover not completion
	
	var nMilliseconds = iDiffMS;
	var nSeconds = parseInt(iDiffMS/1000);
	var nMinutes = parseInt(nSeconds/60);
	var nHours = parseInt(nMinutes/60);
	var nDays  = parseInt(nHours/24);
	var nWeeks = parseInt(nDays/7);


	// return requested difference
	var iDiff = 0;		
	switch(p_Interval.toLowerCase()){
		case "yyyy": return nYears;
		case "q": return nQuarters;
		case "m": return nMonths;
		case "y": 		// day of year
		case "d": return nDays;
		case "w": return nDays;
		case "ww":return nWeeks;		// week of year	// <-- inaccurate, WW should count calendar weeks (# of sundays) between
		case "h": return nHours;
		case "n": return nMinutes;
		case "s": return nSeconds;
		case "ms":return nMilliseconds;	// millisecond	// <-- extension for JS, NOT available in VBScript
		default: return "invalid interval: '" + p_Interval + "'";
	}
}



// REQUIRES: isDate(), dateDiff()
// NOT SUPPORTED: firstdayofweek and firstweekofyear (does system default for both)
function datePart(p_Interval, p_Date, p_firstdayofweek, p_firstweekofyear){
	if(!isDate(p_Date)){return "invalid date: '" + p_Date + "'";}

	var dtPart = new Date(p_Date);
	switch(p_Interval.toLowerCase()){
		case "yyyy": return dtPart.getFullYear();
		case "q": return parseInt(dtPart.getMonth()/3)+1;
		case "m": return dtPart.getMonth()+1;
		case "y": return dateDiff("y", "1/1/" + dtPart.getFullYear(), dtPart);			// day of year
		case "d": return dtPart.getDate();
		case "w": return dtPart.getDay();	// weekday
		case "ww":return dateDiff("ww", "1/1/" + dtPart.getFullYear(), dtPart);		// week of year
		case "h": return dtPart.getHours();
		case "n": return dtPart.getMinutes();
		case "s": return dtPart.getSeconds();
		case "ms":return dtPart.getMilliseconds();	// millisecond	// <-- extension for JS, NOT available in VBScript
		default: return "invalid interval: '" + p_Interval + "'";
	}
}


function checkWishes() {
	if(!wishes_checked){
		if (document.getElementById && document.getElementsByTagName) {
			if (document.getElementById('options_tool')) {
				var options = document.getElementById('options_tool');
				var links = options.getElementsByTagName('a');
				for (var i=0; i < links.length; i++) {
					links[i].onclick = function() {
						toggleElement(this, "tool");
	   					return false;
					}
				}
			}
			if (document.getElementById('options_finder')) {
				var options = document.getElementById('options_finder');
				var links = options.getElementsByTagName('a');
				for (var i=0; i < links.length; i++) {
					links[i].onclick = function() {
						toggleElement(this, "finder");
	   					return false;
					}
				}
			}
		}
		wishes_checked = true;
	}
}

var wishes_tool = new Array();
var wishes_finder = new Array();
var wishes_checked = false;
	
function toggleElement(element,area) {
	var elementExists = false;
	var elementPosition = -1;
	
	if (element.className == "selected") {
		element.className = "dim";
	}
	else {
		element.className = "selected";
	}

	for (i=0; i < eval("wishes_"+area+".length"); i++) {
		if (eval("wishes_"+area+"[i]==element.name")) {
			elementExists = true;
			elementPosition = i;
		}
	}

	if (elementExists == true) {
		eval("wishes_"+area+".splice(elementPosition,1)");
	}
	else {	
		eval("wishes_"+area+"[wishes_"+area+".length] = element.name");
	}
	
	var selectedOptions = eval("wishes_"+area+".join()");
	
	$('mp_form_hotelfinder_thematic_'+area).leisureIDs.value= eval("wishes_"+area+".join()");
}

mp.windowScroller = new Fx.Scroll(Window, {
	wait: false,
	duration: 800,
	offset: {'x': 0, 'y': 0},
	transition: Fx.Transitions.Quad.easeInOut
});

mp.show360Flash = function(link,offset){
	if(this.hasFlash){
		var popoptions = 'top=' + offset + ',left=' + offset + ',height='+ (screen.height - offset*2) +',width=' + (screen.width - offset*2);
		var mp_flash360_popup=window.open(link,'360_Flash',popoptions);
		if (window.focus) {mp_flash360_popup.focus()}
	}
	return void(0);
}

mp.popup = function(link,options,name){
	var popname = name ? name : 'popup' + Math.floor(Math.random()*1100);
	var poplink = link ? link : alert('no link defined');
	var defaultOptions = {
		width:200,
		height:400,
		top:null,
		left:null,
		resizable:1,
		status:1,
		scrollbars:1,
		screenoffset:null
	};
	var opt = $merge(defaultOptions,options);
	var popoptions = '';
	
	if(opt.screenoffset){
		popoptions += ',top=' + opt.screenoffset;
		popoptions += ',left=' + opt.screenoffset;
		popoptions += ',height=' + (screen.height - opt.screenoffset*2);
		popoptions += ',width=' + (screen.width - opt.screenoffset*2);
	}else{
		if(opt.top){
			popoptions += ',top=' + opt.top;
		}
		if(opt.left){
			popoptions += ',left=' + opt.left;
		}
		if(opt.height){
			popoptions += ',height=' + opt.height;
		}
		if(opt.width){
			popoptions += ',width=' + opt.width;
		}
	}
	if(opt.resizable){
		popoptions += ',resizable=' + opt.resizable;
	}
	if(opt.status){
		popoptions += ',status=' + opt.status;
	}
	if(opt.scrollbars){
		popoptions += ',scrollbars=' + opt.scrollbars;
	}
	
	return window.open(poplink,popname,popoptions);
}
