if(!Idea)
	var Idea = {}
if(!Idea.Booking)
	Idea.Booking = {}

Idea.Booking.BookNowWrapper = function(config)
{
	if(!config.monthsNames)
		config.monthsNames = ['sty','lut','mar','kwi','maj','cze','lip','sie','wrz','paz','lis','gru']
	if(!config.daysNames)
		config.daysNames = ['nie','pon','wto','sro','czw','pia','sob']
	if(config.Checkin)
	{
		switch(config.Checkin.Mode)
		{
			case 'dropdowns':
				this.checkinDS = new Idea.DateSelector('dropdowns');
				this.checkinDS.dayDropdown = this.$(config.Checkin.DayID);
				this.checkinDS.yearMonthDropdown = this.$(config.Checkin.YearMonthID);
			break;
			case 'datepicker+dropdowns':
				this.checkinDS = new Idea.DateSelector('datepicker+dropdowns');
				this.checkinDS.dayDropdown = this.$(config.Checkin.DayID);
				this.checkinDS.yearMonthDropdown = this.$(config.Checkin.YearMonthID);
				this.checkinDS.datePickerID = config.Checkin.DatePickerID;
				this.checkinDS.datePickerOpener = this.$(config.Checkin.DatePickerOpenerID);
			break;
			case 'datepicker+txt':
				this.checkinDS = new Idea.DateSelector('datepicker+txt');
				this.checkinDS.textInput = this.$(config.Checkin.TextID);
				this.checkinDS.datePickerID = config.Checkin.DatePickerID;
				this.checkinDS.datePickerOpener = this.$(config.Checkin.DatePickerOpenerID);
			break;
		}
		this.checkinDS.monthsNames = config.monthsNames;
		this.checkinDS.daysNames = config.daysNames;
		if(config.yearFormat)
			this.checkinDS.yearFormat = config.yearFormat;
		this.checkinDS.init();
		this.checkinMode = config.Checkin.Mode;
	}
	if(config.Checkout)
	{
		switch(config.Checkout.Mode)
		{
			case 'dropdowns':
				this.checkoutDS = new Idea.DateSelector('dropdowns');
				this.checkoutDS.dayDropdown = this.$(config.Checkout.DayID);
				this.checkoutDS.yearMonthDropdown = this.$(config.Checkout.YearMonthID);
			break;
			case 'datepicker+dropdowns':
				this.checkoutDS = new Idea.DateSelector('datepicker+dropdowns');
				this.checkoutDS.dayDropdown = this.$(config.Checkout.DayID);
				this.checkoutDS.yearMonthDropdown = this.$(config.Checkout.YearMonthID);
				this.checkoutDS.datePickerID = config.Checkout.DatePickerID;
				this.checkoutDS.datePickerOpener = this.$(config.Checkout.DatePickerOpenerID);
			break;
			case 'datepicker+txt':
				this.checkoutDS = new Idea.DateSelector('datepicker+txt');
				this.checkoutDS.textInput = this.$(config.Checkout.TextID);
				this.checkoutDS.datePickerID = config.Checkout.DatePickerID;
				this.checkoutDS.datePickerOpener = this.$(config.Checkout.DatePickerOpenerID);
			break;
		}
		this.checkoutDS.monthsNames = config.monthsNames;
		this.checkoutDS.daysNames = config.daysNames;
		if(config.yearFormat)
			this.checkinDS.yearFormat = config.yearFormat;
		this.checkoutDS.init();
		this.checkoutMode = config.Checkout.Mode;
	}
	if(config.Checkin&&config.Nights)
	{
		this.nights = this.$(config.Nights.NightsID);
		this.mode = 'checkInNights';
	}
	if(config.Checkin&&config.Checkout)
	{
		this.mode = 'checkInOut';
		this.checkinDS.setSynchronized(this.checkoutDS);
	}	
	else 
		this.mode = 'mixed';
}

Idea.Booking.BookNowWrapper.prototype = 
{
	getURLParams:function()
	{
		if(this.mode == 'checkInOut')
		{
			var checkinDate = this.checkinDS.getURLDate();
			var checkoutDate = this.checkoutDS.getURLDate();
			return '&Checkin='+checkinDate+'&Checkout='+checkoutDate;
		}
		if(this.mode == 'checkInNights')
		{
			var checkinDate = this.checkinDS.getURLDate();
			var nights = this.nights.options[this.nights.selectedIndex].value;
			return '&Checkin='+checkinDate+'&Nights='+nights;
		}
		else 
		{
			var retURL = '';
			try{
				var checkinDate = this.checkinDS.getURLDate();
				retURL+='&Checkin='+checkinDate+'';
			}catch(e){}
			try{
				var checkoutDate = this.checkoutDS.getURLDate();
				retURL+='&Checkout='+checkoutDate;
			}catch(e){}
			try{
				var nights = this.nights.options[this.nights.selectedIndex].value;
				retURL+='&Nights='+nights;
			}catch(e){}
			return retURL;
		}
	},
	$:function(id)
	{
		return document.getElementById(id);
	}
}