if (/*IsLive=*/true || /*upper=temp/test/live*/false || window.location.href.search(/upper=(temp|test|live)/) > 0)
{
document.write("<link rel='stylesheet' href='http://upper.profitroom.pl/booking/styles/submodal.css' />");
//INCLUDE submodal.js START
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;
		this.checkinDS.todayText = config.todayText;
		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;
		this.checkoutDS.todayText = config.todayText;
		if(config.yearFormat)
			this.checkoutDS.yearFormat = config.yearFormat;
		this.checkoutDS.init();
		this.checkoutMode = config.Checkout.Mode;
	}
	if (config.RoomCategory)
	{
		this.RoomCategory = this.$(config.RoomCategory.ID);
	}
	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()
	{
		var params = '';
		if (this.RoomCategory)
		{
			params += '&RoomCategoryID=' + this.RoomCategory.options[this.RoomCategory.selectedIndex].value; 
		}
		if(this.mode == 'checkInOut')
		{
			var checkinDate = this.checkinDS.getURLDate();
			var checkoutDate = this.checkoutDS.getURLDate();
			params += '&Checkin='+checkinDate+'&Checkout='+checkoutDate;
		}
		else if(this.mode == 'checkInNights')
		{
			var checkinDate = this.checkinDS.getURLDate();
			var nights = this.nights.options[this.nights.selectedIndex].value;
			params += '&Checkin='+checkinDate+'&Nights='+nights;
		}
		else 
		{
			try{
				var checkinDate = this.checkinDS.getURLDate();
				params += '&Checkin='+checkinDate+'';
			}catch(e){}
			try{
				var checkoutDate = this.checkoutDS.getURLDate();
				params += '&Checkout='+checkoutDate;
			}catch(e){}
			try{
				var nights = this.nights.options[this.nights.selectedIndex].value;
				params += '&Nights='+nights;
			}catch(e){}
		}
		return params;
	},
	$:function(id)
	{
		return document.getElementById(id);
	}
}// JavaScript Document

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

Idea.DateSelector = function(type)
{
	this.currentDate = new Date();
	this.dayDropdown = null;
	this.yearMonthDropdown = null;
	this.textInput = null;
	this.datePicker = null;
	this.datePickerID = null;
	this.datePickerOpener = null;
	this.yearFormat = 'yyyy';
	this.monthsNames = ['sty','lut','mar','kwi','maj','cze','lip','sie','wrz','paz','lis','gru'];
	this.daysNames = ['nie','pon','wto','sro','czw','pia','sob'];
	this.todayText = 'Dzisiaj';
	this.daysNamesAvailable = true;
	this.MonthsNamesAvailable = true;
	this.synchronizedChildren = false;
	this.synchronizedParent = false;
	this.dateType = type;				// dropdowns / datepicker+dropdowns / datepicker+txt 
}

Idea.DateSelector.prototype = { 
	init:function()
	{
		this.setDate(this.currentDate);
		this.attachEvents();
	},
	renderDays:function(startDate)
	{
		var curDate = new Date(startDate);
		var daysTab = new Array();
		var daysIndexTab = new Array();
		for(var i=curDate.getDate(); i<=this.chckDaysInMonth(curDate.getFullYear(),curDate.getMonth()); i++)
		{
			if(i<10)
				index = 0;
		    else 
				index = '';
			daysTab.push(index+''+i);
			curDate.setDate(i);
			daysIndexTab.push(curDate.getDay());	
		}
		return [daysTab,daysIndexTab];
	},
	populateMonths:function(year,startIndex,lastIndex)
	{
		var monthTab = new Array();
		if(!lastIndex)
			var lastIndex = 11;
		for(var i=startIndex; i<=lastIndex; i++)
		{			
			if(i<9)
				index = 0;
		    else 
				index = '';
			monthTab.push(year+'-'+index+''+(i+1));
		}
		return monthTab;
	},
	renderYearMonths:function(startDate)
	{
		var parseDate = new Date(startDate);
		var monthTab = this.populateMonths(this.formatYear(parseDate.getFullYear()),parseDate.getMonth());
		if(monthTab.length<12)
		{
			parseDate.setFullYear((parseDate.getFullYear()+1));
			var monthTab1 = this.populateMonths(this.formatYear(parseDate.getFullYear()),0,(11-monthTab.length));
			monthTab = (monthTab+','+monthTab1).split(',');
		}
		return monthTab;
	},
	clearDropdown:function(dropdown)
	{
		for(var i=0; i<dropdown.options.length; i++)
			{
				dropdown.remove(i);
			}
	},
	formatYear:function(fullYear)
	{
		var yr = fullYear.toString();
		if(this.yearFormat.toLowerCase() == 'yy')
		{
			
			return yr.substring(2,4)
		}
		if(this.yearFormat.toLowerCase() == 'yyyy')
		{
			return yr;
		}
	},	
	populateDateDropDown:function(date)
	{
		this.clearDropdown(this.dayDropdown);
		var d = this.renderDays(date);
		var days = d[0];	
		var daysIndex = d[1];
		for (var i=0; i<days.length; i++)
		{
			this.dayDropdown.options[i] = new Option();
			this.dayDropdown.options[i].value = days[i];
			if(this.daysNamesAvailable)
				this.dayDropdown.options[i].text = this.translateDays(days[i],daysIndex[i]);
			else
				this.dayDropdown.options[i].text = days[i];
		}
	},
	populateDropdowns:function(date)
	{
		this.populateDateDropDown(date);
		var monthsYears = this.renderYearMonths(date);
		for (var i=0; i<monthsYears.length; i++)
		{
			this.yearMonthDropdown.options[i] = new Option();
			this.yearMonthDropdown.options[i].value = monthsYears[i];
			if(this.MonthsNamesAvailable)
				this.yearMonthDropdown.options[i].text = this.translateMonths(monthsYears[i])
			else
				this.yearMonthDropdown.options[i].text = monthsYears[i];
		}
	},
	populateInput:function(date)
	{
		var date = new Date(date);
		var m = date.getMonth()+1;
		var d = date.getDate();
		if(m<10)
			m = '0'+m;
		if(d<10)
			d = '0'+d;
		
		this.textInput.currentDate = date;
		if(this.MonthsNamesAvailable)
		{
			this.textInput.value = d+' '+this.translateMonths(this.formatYear(date.getFullYear())+'-'+m);
		}
		else
			this.textInput.value = this.formatYear(date.getFullYear())+'-'+m+'-'+d;
	},
	translateDays:function(day,index)
	{
		return day+' '+this.daysNames[index];
	},
	translateMonths:function(date)
	{
		var year = date.split('-')[0];
		var month = date.split('-')[1];
		return this.monthsNames[(parseFloat(month)-1)]+' '+year;
	},
	zeroDate:function(date)
	{
		return date.setDate(1);
	},
	createDatePicker:function()
	{
		this.datePicker = new CalendarPopup(this.datePickerID);
		this.datePicker.setTodayText(this.todayText);
		this.datePicker.setMonthNames(this.monthsNames);
		this.datePicker.setDayHeaders(this.daysNames);
		var $this = this;
		this.datePickerOpener.onclick = function()
			{
				var didi = $this.formatDate($this.currentDate);
				$this.datePicker.select($this,this.name,'yyyy-MM-dd',didi); return false;
			}
	},
	attachEvents:function()
	{
		var $this = this;
		if(this.dateType == 'dropdowns' || this.dateType == 'datepicker+dropdowns')
		{
			this.yearMonthDropdown.onchange = function()
			{
				var v = this.options[this.selectedIndex].value.split('-');
				if(v[0].length < 4)
					v[0] = '20'+v[0];
				var date = new Date(v[0],(parseFloat(v[1])-1),1);
				$this.populateDateDropDown(date);
				$this.upadteCurrentDate();
				$this.synchronize();
			}
			this.dayDropdown.onchange = function()
			{
				$this.upadteCurrentDate();
				$this.synchronize();
			}
			if(this.datePickerID && this.datePickerOpener)
			{
				this.createDatePicker();
			}
		}
		if(this.dateType == 'datepicker+txt')
		{
			this.textInput.onchange = function()
			{
				$this.upadteCurrentDate();
				if($this.synchronizedObj)
					$this.synchronize()
			}
			if(this.datePickerID && this.datePickerOpener)
			{
				this.createDatePicker();
				this.textInput.onclick = function()
				{
					var didi = $this.formatDate($this.currentDate);
					$this.datePicker.select($this,$this.datePickerOpener.name,'yyyy-MM-dd',didi); return false;
				}
			}
		}
	},
	upadteCurrentDate:function(){
		this.currentDate = this.getDate();
	},
	getDate:function()
	{
		var date = this.getURLDate().split('-');	
		return new Date(date[0],(parseFloat(date[1])-1),date[2])
	},
	getURLDate:function()
	{
		switch(this.dateType)
		{
			case 'dropdowns':
				var d = this.dayDropdown.options[this.dayDropdown.selectedIndex].value;
				var my = this.yearMonthDropdown[this.yearMonthDropdown.selectedIndex].value.split('-');
				if(my[0].length < 3)
					my[0] = '20'+my[0];
				return my[0]+'-'+my[1]+'-'+d;
			break;
			case 'datepicker+dropdowns':
				var d = this.dayDropdown.options[this.dayDropdown.selectedIndex].value;
				var my = this.yearMonthDropdown[this.yearMonthDropdown.selectedIndex].value.split('-');
				if(my[0].length < 3)
					my[0] = '20'+my[0];
				return my[0]+'-'+my[1]+'-'+d;
			break;
			case 'datepicker+txt':
				var date = this.textInput.currentDate;
				var m = date.getMonth()+1;
				var d = date.getDate();
				if(m<10)
					m = '0'+m;
				if(d<10)
					d = '0'+d;
				return date.getFullYear()+'-'+m+'-'+d;
			break;
		}
	},
	setDate:function(date)
	{
		switch(this.dateType)
		{
			case 'dropdowns':
				this.populateDropdowns(date);
			break;
			case 'datepicker+dropdowns':
				this.populateDropdowns(date);
			break;
			case 'datepicker+txt':
				this.populateInput(date);
			break;
		}
		this.currentDate = date;
	},
	setSynchronized:function(selector)
	{
		this.synchronizedChildren = selector;
		this.synchronizedChildren.synchronizedParent = this;
		this.synchronize();
	},
	synchronize:function()
	{
		if(this.synchronizedChildren)
			{
				var syncDate = new Date(this.currentDate)
				var syncChildren = this.synchronizedChildren;
				var dd = (this.currentDate.getDate()+1);
				syncChildren.setDate(syncDate.setDate(dd));
				if(syncChildren.datePicker!=null)
				{
					var d = this.formatDate(syncDate);
					syncChildren.datePicker.addDisabledDates(d);
				}
					
			}
		if(this.synchronizedParent)
		{
			var sp = this.synchronizedParent;
			if(this.currentDate<=sp.currentDate)
			{
				var sd = new Date(sp.currentDate);
				if(this.datePicker!=null)
				{
					var d = this.formatDate(sd);
					this.datePicker.addDisabledDates(d);
				}
					
				this.setDate(sd.setDate(sp.currentDate.getDate()+1))
			}
		}
	},
	setDPDate:function(date)
	{
		this.setDate(date);
		this.synchronize();	
	},
	formatDate: function(date,splitter)
	{
		date = new Date(date);
		d = date.getDate();
		m = date.getMonth()+1;
		y = date.getFullYear();
		var sp = '-';
		if(splitter)
		{
			sp = splitter;
		}
		if(d<10)
			d='0'+d;
		if(m<10)
			m='0'+m;
		var formatedDate = y+sp+m+sp+d;
		return formatedDate;
	},
	chckDaysInMonth:function(year,month){
		var intMonth = month;
		var intYear = year;
		
		var dteMonth = new Date(intYear,intMonth);//
		var intDaysInMonth = 28;
		var blnDateFound = false;
		
		while (!blnDateFound)
		{
			dteMonth.setDate(intDaysInMonth+1);
			var intNewMonth = dteMonth.getMonth();
			
			if (intNewMonth != intMonth)
			  blnDateFound = true;
			else
			  intDaysInMonth++;
		}
		return intDaysInMonth;
	}
}



/**
 * This derivative version of subModal can be downloaded from http://gabrito.com/files/subModal/
 * Original By Seth Banks (webmaster at subimage dot com)  http://www.subimage.com/
 * Contributions by Eric Angel (tab index code), Scott (hiding/showing selects for IE users), Todd Huss (submodal class on hrefs, moving div containers into javascript, phark method for putting close.gif into CSS), Thomas Risberg (safari fixes for scroll amount), Dave Campbell (improved parsing of submodal-width-height class)
 */
var gSubmodalInitialized = false;
var gPopupMask = null;
var gPopupContainer = null;
var gPopFrame = null;
var gReturnFunc;
var gPopupIsShown = false;
var gHideSelects = false;
var gLoading = "about:blank";

/**
 * Override the loading page from loading.html to something else
 */
function setPopUpLoadingPage(loading)
{
    gLoading = loading;
}

var Submodal = {
    initPopUp: function()
    {
    	if (gSubmodalInitialized) return;
    	
        // Add the HTML to the body
        var body = document.getElementsByTagName('body')[0];
        var popmask = document.createElement('div');
        popmask.id = 'popupMask';
        var popcont = document.createElement('div');
        popcont.id = 'popupContainer';
        popcont.innerHTML = '' +
        '<div id="popupInner">' +
        '<div id="popupTitleBar">' +
        '<div id="popupTitle"></div>' +
        '<div id="popupControls">' +
        '<a onclick="Submodal.hidePopWin(false);"><span>Close</span></a>' +
        '</div>' +
        '</div>' +
        '<iframe src="' +
        gLoading +
        '" style="width:100%;height:100%;background-color:transparent;" scrolling="no" frameborder="0" allowtransparency="true" id="popupFrame" name="popupFrame" width="100%" height="100%"></iframe>' +
        '</div>';
        body.appendChild(popmask);
        body.appendChild(popcont);
        
        gPopupMask = document.getElementById("popupMask");
        gPopupContainer = document.getElementById("popupContainer");
        gPopFrame = document.getElementById("popupFrame");
        
        // check to see if this is IE version 6 or lower. hide select boxes if so
        // maybe they'll fix this in version 7?
        var brsVersion = parseInt(window.navigator.appVersion.charAt(0), 10);
        if (brsVersion <= 6 && window.navigator.userAgent.indexOf("MSIE") > -1) 
        {
            gHideSelects = true;
        }
        
        gSubmodalInitialized = true;
    },
    showPopWin: function(url, width, height, returnFunc)
    {
    	this.initPopUp();
        gPopupIsShown = true;
        Submodal.disableTabIndexes();
        gPopupMask.style.display = "block";
        gPopupContainer.style.display = "block";
        Submodal.centerPopWin(width, height);
        var titleBarHeight = Math.max(parseInt(gPopupContainer.offsetHeight, 10) - 2, 0);
        gPopupContainer.style.width = width +2 + "px";
        gPopupContainer.style.height = (height + titleBarHeight) + "px";
        //ja	
        //document.getElementById("popupTitleBar").offsetWidth
        //ja
        gPopFrame.style.width = Math.max(parseInt(gPopupContainer.offsetWidth, 10) - 4, 0) + "px";
        gPopFrame.style.height = (height) + "px";
        gPopFrame.src = url;
        gReturnFunc = returnFunc;
        //KK remove scroll from body
        var html = document.documentElement;
        html.style.overflow = 'hidden';
        document.body.style.overflow = 'hidden';
        html.tabIndex = -1;
        // for IE
        if (gHideSelects == true) 
        {
            Submodal.hideSelectBoxes();
        }
        //KK causing browser errors
        //window.setTimeout("setPopTitleAndRewriteTargets();", 100);
        Submodal.ResizeModal();
    },
    centerPopWin: function(width, height)
    {
        if (gPopupIsShown == true) 
        {
            if (width == null || isNaN(width)) 
            {
                width = gPopupContainer.offsetWidth;
            }
            if (height == null) 
            {
                height = gPopupContainer.offsetHeight;
            }
            var fullHeight = Submodal.getViewportHeight();
            var fullWidth = Submodal.getViewportWidth();
            // scLeft and scTop changes by Thomas Risberg
            var scLeft, scTop;
            if (self.pageYOffset) 
            {
                scLeft = self.pageXOffset;
                scTop = self.pageYOffset;
            }
            else 
                if (document.documentElement && document.documentElement.scrollTop) 
                {
                    scLeft = document.documentElement.scrollLeft;
                    scTop = document.documentElement.scrollTop;
                }
                else 
                    if (document.body) 
                    {
                        scLeft = document.body.scrollLeft;
                        scTop = document.body.scrollTop;
                    }
            gPopupMask.style.height = fullHeight + "px";
            gPopupMask.style.width = fullWidth + "px";
            gPopupMask.style.top = scTop + "px";
            gPopupMask.style.left = scLeft + "px";
            //window.status = " gPopupContainer: "+gPopupContainer.style.height + " gPopupFrame: " + gPopupFrame.style.height;
            var titleBarHeight = parseInt(document.getElementById("popupTitleBar").offsetHeight, 10);
            var topMargin = scTop + ((fullHeight - (height + titleBarHeight)) / 2);
            if (topMargin < 0) 
            {
                topMargin = 0;
            }
            gPopupContainer.style.top = scTop + 28 + "px";
            gPopupContainer.style.left = (scLeft + ((fullWidth - width) / 2)) + "px";
        }
    },
    hidePopWin: function(callReturnFunc)
    {
        stopScripts = false;
        gPopupIsShown = false;
        Submodal.restoreTabIndexes();
        if (gPopupMask == null) 
        {
            return;
        }
        gPopupMask.style.display = "none";
		gPopupMask.style.height = "0px";
        gPopupContainer.style.display = "none";
		gPopupContainer.style.height = "0px";
        if (callReturnFunc == true && gReturnFunc != null) 
        {
            gReturnFunc(window.frames["popupFrame"].returnVal);
        }
        gPopFrame.src = gLoading;
        //KK restore body scrolling
        var html = document.documentElement;
        html.style.overflow = '';
        document.body.style.overflow = '';
        html.tabIndex = 0;
        
        // display all select boxes
        if (gHideSelects == true) 
        {
            Submodal.displaySelectBoxes();
        }
        Booking.RestoreSite();
    },
    setPopTitleAndRewriteTargets: function()
    {
        if (window.frames["popupFrame"].document.title == null) 
        {
            window.setTimeout("Submodal.setPopTitleAndRewriteTargets();", 10);
        }
        else 
        {
            var popupDocument = window.frames["popupFrame"].document;
            document.getElementById("popupTitle").innerHTML = popupDocument.title;
            if (popupDocument.getElementsByTagName('base').length < 1) 
            {
                var aList = window.frames["popupFrame"].document.getElementsByTagName('a');
                for (var i = 0; i < aList.length; i++) 
                {
                    if (aList.target == null) 
                        aList[i].target = '_parent';
                }
                var fList = window.frames["popupFrame"].document.getElementsByTagName('form');
                for (i = 0; i < fList.length; i++) 
                {
                    if (fList.target == null) 
                        fList[i].target = '_parent';
                }
            }
        }
    },
    keyDownHandler: function(e)
    {
        if (gPopupIsShown && e.keyCode == 9) 
            return false;
    },
    disableTabIndexes: function()
    {
        if (document.all) 
        {
            var i = 0;
            for (var j = 0; j < gTabbableTags.length; j++) 
            {
                var tagElements = document.getElementsByTagName(gTabbableTags[j]);
                for (var k = 0; k < tagElements.length; k++) 
                {
                    gTabIndexes[i] = tagElements[k].tabIndex;
                    tagElements[k].tabIndex = "-1";
                    i++;
                }
            }
        }
    },
    restoreTabIndexes: function()
    {
        if (document.all) 
        {
            var i = 0;
            for (var j = 0; j < gTabbableTags.length; j++) 
            {
                var tagElements = document.getElementsByTagName(gTabbableTags[j]);
                for (var k = 0; k < tagElements.length; k++) 
                {
                    tagElements[k].tabIndex = gTabIndexes[i];
                    tagElements[k].tabEnabled = true;
                    i++;
                }
            }
        }
    },
    hideSelectBoxes: function()
    {
        for (var i = 0; i < document.forms.length; i++) 
        {
            for (var e = 0; e < document.forms[i].length; e++) 
            {
                if (document.forms[i].elements[e].tagName == "SELECT") 
                {
                    document.forms[i].elements[e].style.visibility = "hidden";
                }
            }
        }
    },
    displaySelectBoxes: function()
    {
        for (var i = 0; i < document.forms.length; i++) 
        {
            for (var e = 0; e < document.forms[i].length; e++) 
            {
                if (document.forms[i].elements[e].tagName == "SELECT") 
                {
                    document.forms[i].elements[e].style.visibility = "visible";
                }
            }
        }
    },
    addEvent: function(obj, evType, fn)
    {
        if (obj.addEventListener) 
        {
            obj.addEventListener(evType, fn, false);
            return true;
        }
        else 
            if (obj.attachEvent) 
            {
                var r = obj.attachEvent("on" + evType, fn);
                return r;
            }
            else 
            {
                return false;
            }
    },
    getViewportHeight: function()
    {
        if (window.innerHeight != window.undefined) 
            return window.innerHeight;
        if (document.compatMode == 'CSS1Compat') 
            return document.documentElement.clientHeight;
        if (document.body) 
            return document.body.clientHeight;
        return window.undefined;
    },
    getViewportWidth: function()
    {
        if (window.innerWidth != window.undefined) 
            return window.innerWidth;
        if (document.compatMode == 'CSS1Compat') 
            return document.documentElement.clientWidth;
        if (document.body) 
            return document.body.clientWidth;
        return window.undefined;
    },
    ResizeModal: function()
    {
        if (gPopupContainer == null) return;
        //gPopupMask.style.top = parseInt(gPopupMask.style.top)+'px';
        var height = Submodal.getViewportHeight() - 50;
        Submodal.centerPopWin(796, height);
        var titleBarHeight = Math.max(parseInt(gPopupContainer.offsetHeight, 10) - 2, 0);
        gPopupContainer.style.width = 796 + "px";
        gPopupContainer.style.height = (height/* + titleBarHeight*/) + "px";
        gPopFrame.style.width = Math.max(parseInt(gPopupContainer.offsetWidth, 10) - 4, 0) + "px";
        gPopFrame.style.height = (height) + "px";
    }
    
}

Submodal.addEvent(window, "load", Submodal.initPopUp);
Submodal.addEvent(window, "resize", Submodal.ResizeModal);
Submodal.addEvent(window, "scroll", Submodal.centerPopWin);

var gi = 0;
var gTabIndexes = new Array();
// Pre-defined list of tags we want to disable/enable tabbing into
var gTabbableTags = new Array("A", "BUTTON", "TEXTAREA", "INPUT", "IFRAME");

// If using Mozilla or Firefox, use Tab-key trap.
if (!document.all) 
{
    document.onkeypress = Submodal.keyDownHandler;
}
//INCLUDE submodal.js END


Submodal.addEvent(window, "load", function() {
	Booking.DHtmlLoadScript('http://res.profitroom.pl/thebonerowskipalace/scripts/site.js');
});


var Booking = 
{
	ObjectsCollection : new Array(),
	DHtmlLoadScript : function(url)
	{
		var e = document.createElement("script");
		e.src = url;
		e.type = "text/javascript";
		document.getElementsByTagName("body")[0].appendChild(e);
	},

	Open : function(form)
	{
    	var addURL = Booking.GetFormOpts(form); 
		var upper = /upper=(temp|test|live)/.exec(window.location.href);
		if (upper != null)
		{
			addURL += '&upper=' + upper[1];
		}
		else if (false)
		{
			addURL += '&upper=';
		}
		addURL += '&url=' + escape(window.location.href);
    	Booking.FreezeSite();
		var h = Submodal.getViewportHeight()-50; 
		Submodal.showPopWin('http://upper.profitroom.pl/panel/thebonerowskipalace?locale=en&height='+h+'&'+addURL+'', 796, h, 'Rezerwacje hotelowe ProfitROOM');
		
		if (typeof(pageTracker)!="undefined")
		{
			pageTracker._trackPageview('/otwarcie-uppera');
		} 
	},
    
    FreezeSite : function()
    {
    	Booking.showObejcts('hide');
    	try
        {
        	Booking.FreezeSiteLocal();
        }
        catch(e){
        	//error
        }
    },
    
    RestoreSite : function()
    {
    	Booking.showObejcts();
        try
        {
        	Booking.RestoreSiteLocal();
        }
        catch(e)
		{
        	//error
        }
    },
    GetFormOpts:function(data, mode)
    {
		var params = '';
    	if (!data) return "";
		if (data.tagName == "FORM")
		{
			if(data.bookNow)
				params = data.bookNow.getURLParams();
			else
			{
				try
				{
					switch(mode) 
					{
						case 2:
							params = Booking.getDM2params(data);
							break;
						case 3:
							params = Booking.getDM3params(data);
							break;
						case 4:
							params = Booking.getDM4params(data);
							break;
						default:
							params = Booking.getDM1params(data);
							break;
					}
				}
				catch(e)
				{
				}
			}
		}
		else
		{
			for (var prop in data)
				params += (params.length>0?'&':'') + prop + '=' + data[prop];
		}

		return params;
    },
    getDM1params:function(f)
    {
    	day = f.elements[0].options[f.elements[0].selectedIndex].value;
        month = f.elements[1].options[f.elements[1].selectedIndex].value.split(',');
        nights = f.elements[2].options[f.elements[2].selectedIndex].value;
        return url = '&Checkin='+month[1]+'-'+month[0]+'-'+day+'&Nights='+nights;
    },
    getDM2params:function(f)
    {
    		day1 = f.elements[0].options[f.elements[0].selectedIndex].value;
        	month1 = f.elements[1].options[f.elements[1].selectedIndex].value.split(',');
        
        	day2 = f.elements[2].options[f.elements[2].selectedIndex].value;
       		month2 = f.elements[3].options[f.elements[3].selectedIndex].value.split(',');
 
        	return url = '&Checkin='+month1[1]+'-'+month1[0]+'-'+day1+'&Checkout='+month2[1]+'-'+month2[0]+'-'+day2;
    },
    getDM3params:function(f)
    {
    	date = f.elements[0].value;
        nights = f.elements[1].options[f.elements[1].selectedIndex].value;
        
        return url = '&Checkin='+date+'&Nights='+nights;
    },
    getDM4params:function(f)
    {
    	date1 = f.elements[0].value;
        date2 = f.elements[0].value;
        
        return url = '&Checkin='+date1+'&Checkout='+date2;
    },
    showObejcts:function(sh){
		if(sh=='hide'){
        	var childs;
            if(document.all)
				childs = document.all;
            else 
            	childs = document.getElementsByTagName("body")[0].getElementsByTagName("*");
			for(var i=0; i<childs.length; i++)
				{
					if(childs[i].tagName == 'OBJECT')
					{
						childs[i].style.visibility = 'hidden';					
						Booking.ObjectsCollection[Booking.ObjectsCollection.length] = childs[i]
						
					}	
				}
				for (var i = 0; i < document.embeds.length; i++)
				{
					 document.embeds[i].style.visibility = 'hidden';
					 Booking.ObjectsCollection[Booking.ObjectsCollection.length] = document.embeds[i];
				}
			return;
		}
		else{
			for (var i=0; i<Booking.ObjectsCollection.length; i++)
			{
				Booking.ObjectsCollection[i].style.visibility = 'visible';
			}			
		}	
	}
}

document.write("<link rel='stylesheet' href='http://res.profitroom.pl/thebonerowskipalace/styles/BookNow.css' />");

}
else
{	
	var Booking = 
	{
		Open : function(form)
		{
			alert('Online booking will be available soon.');
		}
	};
}

Booking.TrackingImage = new Image();
Booking.TrackingImage.src = 'http://tracking2.profitroom.pl/trackerimg.php?ts='+((new Date()).getTime())+'&SiteID=1308&url='+escape(window.location.href)+'&ref='+escape(document.referrer)+'&PHPSESSID=e05978c19ac80b2f0170f2088a97d822';