function wysz(prefix) {
    var rodz = document.getElementById("ctl00_lstRodzaje");

    rodz.onclick = function() {
       var pok = document.getElementById("ctl00_trpokoje");
            
       if (this.value == "2") {
           pok.style.visibility = "hidden";
           pok.style.display = "none";
       } else {
           pok.style.visibility = "visible";
           pok.style.display = "table-row";
       }
    };
}

var a=0;

function step2(){
	var b = new Browser;
	a+=1;
	if (a>9) {a=1;}
	var grafika=document.getElementById("grafika");
	grafika.src="img/foto"+String(a)+".jpg";
}
function skrol(){
	var kol=document.getElementById("kol");
	if (kol) {
		if (document.body.scrollTop>40) {kol.style.marginTop=document.body.scrollTop-40;} else {
			kol.style.marginTop=0;
		}
	}
}
var dfggty=window.setInterval("skrol()",100);

function start() {
}

var scroll=0;
var scrollValue = 0;
var scrollrodzaj=1;
var gal=document.getElementById("galeria");

function scrolldown(i){
	scroll=1;
	scrollrodzaj=i;	
}
function scrollout(){
	scroll=0;	
}
function startscroll(){
	gal=document.getElementById("galeria");
	var dcx=window.setInterval("step()",50); 
	
	scrollValue = 0;
}
function step(){
	if (scroll==1){
	    gal=document.getElementById("galeria");
	    
	    scrollValue += scrollrodzaj;
	    
	    if (scrollValue < 0) scrollValue = 0;
	    gal.style.marginLeft = -scrollValue*20 + "px"	 
	}
}

function Taba(i,prefix){
	if (!prefix)prefix="";
	var x=document.getElementById(prefix+"tab"+String(i));
	if (x.style.display!="block"){x.style.display="block"} else {x.style.display="none"};
}
function Pokaz(o){
	var x=document.getElementById(o);
	if (x.style.display!="block"){x.style.display="block"} else {x.style.display="none"};
}
function Big(i){
	window.open("virgobig.ashx?"+String(i));

}
function OpenMap(i){
    var de = window.open("mapa.aspx?id=" + i, "", "width=740,height=580")
}
function OpenInwMap(i){
	var de=window.open("mapa.aspx?id="+i+"&inw=1","","width=600,height=400")
}
function ShowPrint(i){
	var w=window.open("wydruk.aspx?id="+i,"","width=700,scrollbars=yes,resizable=yes,menubar=yes ");
}

function ShowNotatnikPrint(){
	var w=window.open("wydruk_notatnik.aspx","","width=700,scrollbars=yes,resizable=yes,menubar=yes ");
}

function hideTab($tabId) {
    document.getElementById('ctl00_cntMain_div' + $tabId).style.display = "none";
    document.getElementById('ctl00_cntMain_div' + $tabId).className = "";
}
function hideTabs() {
    hideTab('Brief');
    //hideTab('Main');
    //hideTab('Description');
    //hideTab('Rooms');
    //hideTab('Map');
    hideTab('Form');
}
function showTab($tabId) {
    hideTabs();
    document.getElementById('ctl00_cntMain_div' + $tabId).style.display = "block";
    document.getElementById('ctl00_cntMain_div' + $tabId).attributes["class"] = "selected";
}


function zmien(nazwaObrazka,naJakiSrc, naJakiHref, naJakiTitle) 
{
    if (document.images)
     {
        window.document.images[nazwaObrazka].src=naJakiSrc;
     }             
  try
  {
    window.document.getElementById("OfertaPokaz").setAttribute('href', naJakiHref);
    window.document.getElementById("OfertaPokaz").setAttribute('title', naJakiTitle);
    if (window.document.getElementsByClassName('pomLight')[0] != null) {
        window.document.getElementsByClassName('pomLight')[0].setAttribute('rel', 'lightbox[gallery]');
    }
  }
  catch(e){
    alert(e);      
  }
}

function zmienLight() {
    if (window.document.getElementsByClassName('pomLight')[0] != null) {
        window.document.getElementsByClassName('pomLight')[0].setAttribute('rel', 'lightbox');
    }
}

function DodajDoNotatnika(Id, msg) {
    var c = readCookie("notatnik");
    
    if (c === null) c = "";
    
    if (c.indexOf(","+Id+",") == -1) c += Id+",";
    
    eraseCookie("notatnik");
    
    createCookie("notatnik", c, 31);
    
    if (msg != "") alert(msg);
}

function UsunZNotatnika(Id, msg, reload) {
    var c = readCookie("notatnik");
    
    if (c === null) c = "";
    
    if (c.indexOf(Id+",") > -1) {
        c = c.replace(Id+",", "");
    }
    
    eraseCookie("notatnik");
    
    createCookie("notatnik", c, 31);

    if (msg != "") alert(msg);
    
    if (reload) {
        document.location.reload(false);
    }
}



//----------------------- funkcje do formularza zgłoszeniowego (pobieranie zawartości wszystkich selectów i inputów) -------------------------//
function pobierz_select() {
    var selectedValue = "";

    $$('#domaila select').each(function (elem) {
        var span = new Element('span');
        span.innerHTML = elem[elem.selectedIndex].text;
        elem.replace(span);
    });
}

function pobierz_input() {
    var selectedValue = "";

    $$('#domaila input').each(function (elem) {
        var span = new Element('span');
        span.innerHTML = elem.value
        elem.replace(span);
    });
}
//------------------------------------------------------------ KONIEC --------------------------------------------------------------------------//

// ----- smooth scrolling ---------------- //
function currentYPosition() {
    if (self.pageYOffset) return self.pageYOffset;
    if (document.documentElement && document.documentElement.scrollTop)
        return document.documentElement.scrollTop;
    if (document.body.scrollTop) return document.body.scrollTop;
    return 0;
}

function elmYPosition(eID) {
    var elm = document.getElementById(eID);
    var y = elm.offsetTop;
    var node = elm;
    while (node.offsetParent && node.offsetParent != document.body) {
        node = node.offsetParent;
        y += node.offsetTop;
    } return y;
}

function smoothScroll(eID) {
    var startY = currentYPosition();
    var stopY = elmYPosition(eID);
    var distance = stopY > startY ? stopY - startY : startY - stopY;
    if (distance < 100) {
        scrollTo(0, stopY); return;
    }
    var speed = Math.round(distance / 100);
    if (speed >= 20) speed = 20;
    var step = Math.round(distance / 25);
    var leapY = stopY > startY ? startY + step : startY - step;
    var timer = 0;
    if (stopY > startY) {
        for (var i = startY; i < stopY; i += step) {
            setTimeout("window.scrollTo(0, " + leapY + ")", timer * speed);
            leapY += step; if (leapY > stopY) leapY = stopY; timer++;
        } return;
    }
    for (var i = startY; i > stopY; i -= step) {
        setTimeout("window.scrollTo(0, " + leapY + ")", timer * speed);
        leapY -= step; if (leapY < stopY) leapY = stopY; timer++;
    }
}

var textsize = 1;

function settextsize(newsize) {
    textsize = newsize;
}

function selectActive() {
    var textSizeIds = ["normalText", "mediumText", "largeText"];
    var arrayPos;
    for (i = 0; i < textSizeIds.length; i++) {
        document.getElementById(textSizeIds[i]).className = "";
    }
    if (textsize == "12") {
        arrayPos = 0;
    } else if (textsize == "14") {
        arrayPos = 1;
    } else if (textsize == "16") {
        arrayPos = 2;
    }
    document.getElementById(textSizeIds[arrayPos]).className = 'activeTextSize';
}

function fsize(size, unit, id) {
    var vfontsize = $(id);
    if (vfontsize) {
        var childrens = $$("#"+id+" *");
        vfontsize.style.fontSize = size + unit;
        childrens.each(function (s) {
            s.style.fontSize = size + unit;
        });
        createCookie("textsizestyle", textsize, 365);
        selectActive();
    }
}
