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

/**
 * 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

function dhtmlLoadScript(url)
{
	var e = document.createElement("script");
	e.src = url;
	e.type = "text/javascript";
	document.getElementsByTagName("body")[0].appendChild(e);
}

var ideaObjectsCollection = new Array();
var Booking = 
{
	OpenSite: function(site, params)
	{
    	var addURL = Booking.ToUrl(params);
		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;
		var url = 'http://upper.profitroom.pl/panel/{0}';
		Submodal.showPopWin(url.replace('{0}', site)+'?locale=&channel=134&height='+h+'&'+addURL, 796, h, 'Rezerwacje hotelowe ProfitROOM');
		
		if (typeof pageTracker!="undefined")
		{
			pageTracker._trackPageview('/otwarcie-uppera');    
		}
				
	},
    
    FreezeSite: function()
    {
    	Booking.showObjects('hide');
    	try
        {
        	Booking.FreezeSiteLocal();
        }
        catch(e)
		{
        	//error
        }
    },
    
    RestoreSite: function()
    {
    	Booking.showObjects();
        try
        {
        	Booking.RestoreSiteLocal();
        }
        catch(e){
        	//error
        }
    },
	
    ToUrl: function(data)
    {
			if (typeof(data) == "string") return data;
			var url = "";
			for (var prop in data)
				url += (url.length>0?'&':'') + prop + '=' + data[prop];
			return url;
    },
	
    showObjects: 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';					
					ideaObjectsCollection[ideaObjectsCollection.length] = childs[i]
					
				}	
			}
			for (var i = 0; i < document.embeds.length; i++)
			{
				 document.embeds[i].style.visibility = 'hidden';
				 ideaObjectsCollection[ideaObjectsCollection.length] = document.embeds[i];
			}
			return;
		}
		else
		{
			for (var i=0; i<ideaObjectsCollection.length; i++)
			{
				ideaObjectsCollection[i].style.visibility = 'visible';
			}			
		}	
	}
};
}
else
{
var Booking =
{
	OpenSite: function(site, params)
	{
		alert('chain inactive');
	}
};
}



