/*
    DROP DOWN
*/

var hide= false;
    function show_dropdown(){
		if(!hide) document.getElementById("dd_list").style.visibility="visible";
		hide= false;
		//document.getElementById("dd_text").value=121;
	}

	function downkey(){

	}

	function setText(val){
		hide=true;
		hide_list();
		document.getElementById("dd_text").value=val;
	}
	function hide_list(){
		document.getElementById("dd_list").style.visibility="hidden";
	}

/*
    GALERIA
    www.zdzislowicz.pl
*/

jQuery(document).ready(function()
{

    var nr_wybrany = 0;
    var str_wybrana = 0;

    zmieniaczPrzerwa = 4000;
    // zmieniaczPokaz = 0;
    // zmieniaczUkryj = 0;
    timeoutIDzmieniacz = null;;
    zmieniaczBlokada = true;
    // zmieniaczBlokadaLinkow = false;
    blokujPierwsze = 0;

    function start()
    {
        jQuery('.slajdy_stop').css('display', 'inline');
        jQuery('.slajdy_start').css('display', 'none');
        zmieniaczBlokada = false;
        refreshZmieniacz();
    }

    function stop()
    {
        jQuery('.slajdy_stop').css('display', 'none');
        jQuery('.slajdy_start').css('display', 'inline');
        zmieniaczBlokada = true;
        blokujPierwsze = 0;
        clearTimeout(timeoutIDzmieniacz);
    }

    function refreshZmieniacz() {
        if(!zmieniaczBlokada)
        {
            timeoutIDzmieniacz = setTimeout(refreshZmieniacz, zmieniaczPrzerwa);
            if(blokujPierwsze > 1)
                pokazNastepne();
        }

        blokujPierwsze++;
    }

  	jQuery('.slajdy_stop').click(function()
    {
        stop();
  	}
    );

  	jQuery('.slajdy_start').click(function()
    {
        start();
  	}
    );

  	jQuery('#pokaz_galerie').click(function()
    {
        jQuery('#galeria_slajdy').css('display', 'none');
        jQuery('#galeria_slajdy_box').css('display', 'none');
        jQuery('#galeria_zdjec').css('display', 'block');
        jQuery('#galeria_zdjec_box').css('display', 'block');

        stop();
  	}
    );

  	jQuery('#pokaz_slajdy').click(function()
    {
        jQuery('#galeria_slajdy').css('display', 'block');
        jQuery('#galeria_slajdy_box').css('display', 'block');
        jQuery('#galeria_zdjec').css('display', 'none');
        jQuery('#galeria_zdjec_box').css('display', 'none');

        start();
  	}
    );

  	jQuery('.zdjecie').click(function()
    {
        nr = jQuery(this).attr('class');
        nr = nr.replace("zdjecie nr_", "");

        src = jQuery('.nr_' + nr + ' img').attr('id');
        // alert(jQuery('.nr_' + nr + ' img').attr('src'));

        // odnzacz obecny obrazek
        jQuery('.nr_' + nr_wybrany + ' img').attr('class', '');

        // zaznacz nowy obrazek
        jQuery('.nr_' + nr + ' img').attr('class', 'wybrane');

        jQuery('.nr_big_' + nr_wybrany).css("display", "none");
        jQuery('.nr_big_' + nr).css("display", "block");

        nr_wybrany = nr;

        // pokaz slajdy
        jQuery('#galeria_slajdy').css('display', 'block');

        jQuery('#galeria_zdjec').css('display', 'none');

        // pokaz zdjecie
        /*
        jQuery('#zdjecie_zmien').attr('src', '');
        jQuery('#zdjecie_zmien').attr('src', '/upload/_min/hotele/' + src);
        */

        jQuery('#galeria_zdjec_box').fadeOut("fast", function() {
            jQuery('#galeria_slajdy_box').fadeIn("slow");
        });

        jQuery('.licznik_zdjec').text(parseInt(nr_wybrany)+1);

        start();
    }
    );

  	jQuery('.strona_nastepna').click(function()
    {
        nastepnaStrona();
   	}
    );

    function nastepnaStrona()
    {   
        jQuery('.strona_' + str_wybrana).css('display', 'none');
        str = str_wybrana + 1;
        if(str == porcja_stron)
            str = 0;

        jQuery('.strona_' + str).css('display', 'block');

        str_wybrana = str;

        jQuery('.licznik_stron').text(parseInt(str_wybrana)+1);
    }

  	jQuery('.strona_poprzednia').click(function()
    {
        poprzedniaStrona();
   	}
    );

    function poprzedniaStrona()
    {
        jQuery('.strona_' + str_wybrana).css('display', 'none');
        str = str_wybrana - 1;
        if(str < 0)
            str = porcja_stron-1;

        jQuery('.strona_' + str).css('display', 'block');

        str_wybrana = str;

        jQuery('.licznik_stron').text(parseInt(str_wybrana)+1);
    }

    function sprawdzStrone()
    {
        str = Math.floor(nr_wybrany / porcja_zdjec);
        jQuery('.strona_' + str_wybrana).css('display', 'none');
        jQuery('.strona_' + str).css('display', 'block');

        str_wybrana = str;

        jQuery('.licznik_stron').text(parseInt(str_wybrana)+1);
    }

    function blokada()
    {
        zmieniaczBlokada = false;
    }

  	jQuery('.zdjecie_nastepne').click(function()
    {
        if(!zmieniaczBlokada)
        {
            pokazNastepne();
            zmieniaczBlokada = true;
            setTimeout(blokada, 1000)
        }
   	}
    );

    function pokazNastepne()
    {
        stop();
        start();

        nr = parseInt(nr_wybrany) + parseInt(1);

        if(parseInt(nr) >= parseInt(zdjec))
        {
            nr = 0;
        }
        // src = jQuery('.nr_' + nr + ' img').attr('id');

        // zmien obramowanie
        jQuery('.nr_' + nr_wybrany + ' img').attr('class', '');

        // zaznacz nowy obrazek
        jQuery('.nr_' + nr + ' img').attr('class', 'wybrane');

        jQuery('.nr_big_' + nr_wybrany).fadeOut("slow", function() {
            jQuery('.nr_big_' + nr).fadeIn("slow");
        });

        nr_wybrany = nr;

        // pokaz licznik w span
        jQuery('.licznik_zdjec').text(nr_wybrany+1);

        sprawdzStrone();
    }

  	jQuery('.zdjecie_poprzednie').click(function()
    {
        if(!zmieniaczBlokada)
        {
            pokazPoprzednie();
            zmieniaczBlokada = true;
            setTimeout(blokada, 1000)
        }
   	}
    );

    function pokazPoprzednie()
    {
        stop();
        start();

        nr = parseInt(nr_wybrany) - parseInt(1);

        if(parseInt(nr) < 0)
        {
            nr = parseInt(zdjec)-1;
        }
        src = jQuery('.nr_' + nr + ' img').attr('id');

        // zmien obramowanie
        jQuery('.nr_' + nr_wybrany + ' img').attr('class', '');

        // zaznacz nowy obrazek
        jQuery('.nr_' + nr + ' img').attr('class', 'wybrane');

        jQuery('.nr_big_' + nr_wybrany).fadeOut("slow", function() {
            jQuery('.nr_big_' + nr).fadeIn("slow");
        });

        nr_wybrany = nr;

        // pokaz licznik w span
        jQuery('.licznik_zdjec').text(nr_wybrany+1);

        sprawdzStrone();
    }

});

/*
    CZCIONKA
    www.zdzislowicz.pl
*/
jQuery(document).ready(function()
{
    var czcionkaWczesniej = "";
	jQuery('.czcionka a').click(rozmiarCzcionki);
	if ( getCookie('czcionka') )
	{
		rozmiarCzcionki(getCookie('czcionka'));
	}
    else
        jQuery('.small').css('text-decoration', 'underline');
    var element = "";

    // jezyki
  	jQuery('.jezyki a').mouseover(function(){
  	    jQuery(this).css('background-position', 'bottom');
  	});
  	jQuery('.jezyki a').mouseout(function(){
    if(jQuery(this).attr('class').indexOf('wybrane') <= 0)
      	    jQuery(this).css('background-position', 'top');
  	});


    // dzialy
  	jQuery('.dzial').mouseover(function(){
        jQuery('body').css('cursor', 'pointer');
  	    element = jQuery(this).attr('id');
        jQuery('#' + element + '_o').attr('class', 'dzial_o_s');
        jQuery('#' + element + '_s').attr('class', 'dzial_s_s');
        jQuery('#' + element + '_z').attr('class', 'dzial_z_s');
  	});

  	jQuery('.dzial').mouseout(function(){
        jQuery('body').css('cursor', 'default');
  	    element = jQuery(this).attr('id');
        jQuery('#' + element + '_o').attr('class', 'dzial_o');
        jQuery('#' + element + '_s').attr('class', 'dzial_s');
        jQuery('#' + element + '_z').attr('class', 'dzial_z');
  	});

    // zakladki
  	jQuery('.zakladka').mouseover(function(){
        jQuery('body').css('cursor', 'pointer');
  	    element = jQuery(this).attr('id');
        jQuery('#' + element + '_o').attr('class', 'zakladka_o_s');
        jQuery('#' + element + '_s').attr('class', 'zakladka_s_s');
        jQuery('#' + element + '_z').attr('class', 'zakladka_z_s');
  	});

  	jQuery('.zakladka').mouseout(function(){
        jQuery('body').css('cursor', 'default');
  	    element = jQuery(this).attr('id');
        jQuery('#' + element + '_o').attr('class', 'zakladka_o');
        jQuery('#' + element + '_s').attr('class', 'zakladka_s');
        jQuery('#' + element + '_z').attr('class', 'zakladka_z');
  	});
});

function rozmiarCzcionki(typ) {
	if (typeof typ == 'string')
		var tekst = typ;
	else
		var tekst = jQuery(this).attr('class');
	var rozmiar = '100%';
	switch(tekst)
	{
		case 'small': rozmiar = '100%'; break;
		case 'big': rozmiar = '110%'; break;
        case 'bigger': rozmiar = '120%';
        break;
	}
    /*
	jQuery('.tresc p').css('font-size', rozmiar);
	jQuery('.tresc li').css('font-size', rozmiar);
	jQuery('.tresc td').css('font-size', rozmiar);
    */
	jQuery('.tresc').css('font-size', rozmiar);

	setCookie('czcionka', tekst, '', '/', '', '');

    jQuery('.small').css('text-decoration', 'none');
    jQuery('.big').css('text-decoration', 'none');
    jQuery('.bigger').css('text-decoration', 'none');
    jQuery('.' + tekst).css('text-decoration', 'underline');
	return false;
}

function getCookie(name)
{
	var a_all_cookies = document.cookie.split( ';' );
	var a_temp_cookie = '';
	var cookie_name = '';
	var cookie_value = '';
	var b_cookie_found = false;

	for ( i = 0; i < a_all_cookies.length; i++ ) {
		a_temp_cookie = a_all_cookies[i].split( '=' );
		cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');
		if ( cookie_name == name )
		{
			b_cookie_found = true;
			if ( a_temp_cookie.length > 1 )
				cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') );
			return cookie_value;
			break;
		}
		a_temp_cookie = null;
		cookie_name = '';
	}
	if ( !b_cookie_found )
		return null;
}

function setCookie( name, value, expires, path, domain, secure )
{
    var today = new Date();
    today.setTime( today.getTime() );
    if ( expires )
        expires = expires * 1000 * 60 * 60 * 24;
    var expires_date = new Date( today.getTime() + (expires) );
    document.cookie = name + "=" +escape( value ) +
    ( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) +
    ( ( path ) ? ";path=" + path : "" ) +
    ( ( domain ) ? ";domain=" + domain : "" ) +
    ( ( secure ) ? ";secure" : "" );
}


//** jQuery Scroll to Top Control script- (c) Dynamic Drive DHTML code library: http://www.dynamicdrive.com.
//** Available/ usage terms at http://www.dynamicdrive.com (March 30th, 09')
//** v1.1 (April 7th, 09'):
//** 1) Adds ability to scroll to an absolute position (from top of page) or specific element on the page instead.
//** 2) Fixes scroll animation not working in Opera.


var scrolltotop={
	//startline: Integer. Number of pixels from top of doc scrollbar is scrolled before showing control
	//scrollto: Keyword (Integer, or "Scroll_to_Element_ID"). How far to scroll document up when control is clicked on (0=top).
	setting: {startline:100, scrollto: 0, scrollduration:500, fadeduration:[500, 100]},
	controlHTML: '', //HTML for control, which is auto wrapped in DIV w/ ID="topcontrol"
	controlattrs: {offsetx:5, offsety:5}, //offset of control relative to right/ bottom of window corner
	anchorkeyword: '#top', //Enter href value of HTML anchors on the page that should also act as "Scroll Up" links

	state: {isvisible:false, shouldvisible:false},

	scrollup:function(){
		if (!this.cssfixedsupport) //if control is positioned using JavaScript
			this.$control.css({opacity:0}) //hide control immediately after clicking it
		var dest=isNaN(this.setting.scrollto)? this.setting.scrollto : parseInt(this.setting.scrollto)
		if (typeof dest=="string" && jQuery('#'+dest).length==1) //check element set by string exists
			dest=jQuery('#'+dest).offset().top
		else
			dest=0
		this.$body.animate({scrollTop: dest}, this.setting.scrollduration);
	},

	keepfixed:function(){
		var $window=jQuery(window)
		var controlx=$window.scrollLeft() + $window.width() - this.$control.width() - this.controlattrs.offsetx
		var controly=$window.scrollTop() + $window.height() - this.$control.height() - this.controlattrs.offsety
		this.$control.css({left:controlx+'px', top:controly+'px'})
	},

	togglecontrol:function(){
		var scrolltop=jQuery(window).scrollTop()
		if (!this.cssfixedsupport)
			this.keepfixed()
		this.state.shouldvisible=(scrolltop>=this.setting.startline)? true : false
		if (this.state.shouldvisible && !this.state.isvisible){
			this.$control.stop().animate({opacity:1}, this.setting.fadeduration[0])
			this.state.isvisible=true
		}
		else if (this.state.shouldvisible==false && this.state.isvisible){
			this.$control.stop().animate({opacity:0}, this.setting.fadeduration[1])
			this.state.isvisible=false
		}
	},

	init:function(){
		jQuery(document).ready(function($){
			var mainobj=scrolltotop
			var iebrws=document.all
			mainobj.cssfixedsupport=!iebrws || iebrws && document.compatMode=="CSS1Compat" && window.XMLHttpRequest //not IE or IE7+ browsers in standards mode
			mainobj.$body=(window.opera)? (document.compatMode=="CSS1Compat"? $('html') : $('body')) : $('html,body')
			mainobj.$control=$('<div id="topcontrol">'+mainobj.controlHTML+'</div>')
				.css({position:mainobj.cssfixedsupport? 'fixed' : 'absolute', bottom:mainobj.controlattrs.offsety, right:mainobj.controlattrs.offsetx, opacity:0, cursor:'pointer'})
				.attr({title:'Scroll Back to Top'})
				.click(function(){mainobj.scrollup(); return false})
				.appendTo('body')
			if (document.all && !window.XMLHttpRequest && mainobj.$control.text()!='') //loose check for IE6 and below, plus whether control contains any text
				mainobj.$control.css({width:mainobj.$control.width()}) //IE6- seems to require an explicit width on a DIV containing text
			mainobj.togglecontrol()
			$('a[href="' + mainobj.anchorkeyword +'"]').click(function(){
				mainobj.scrollup()
				return false
			})
			$(window).bind('scroll resize', function(e){
				mainobj.togglecontrol()
			})
		})
	}
}
scrolltotop.init()
