$(document).ready(function(){

    //if($('#indtruktorzuprdiv').hasClass('auto-hide')) $('#indtruktorzuprdiv').hide();

  //fade functions  
    $('#noclegi').click(function() { var checked_status = this.checked; if(checked_status==true)  $('#Iloscnoclegow').fadeIn("slow"); else $('#Iloscnoclegow').fadeOut("slow");});  
    $('#Pensjonatdlakoni').click(function() { var checked_status = this.checked; if(checked_status==true)  $('#Cenapensjonat').fadeIn("slow"); else $('#Cenapensjonat').fadeOut("slow");});  
  	$('#fadein').click(function() { var checked_status = this.checked; if(checked_status==true)  $('#fadeeffect').fadeIn("slow"); else $('#fadeeffect').fadeOut("slow");});  
  	$('#trenerzupr').click(function() { var checked_status = this.checked; if(checked_status==true)  $('#Ilosctrener').fadeIn("slow"); else $('#Ilosctrener').fadeOut("slow");});  
  	$('#Hala1').click(function() { var checked_status = this.checked; if(checked_status==true) { $('#Hala1wymiarod').fadeIn("slow"); $('#Hala1wymiardo').fadeIn("slow");} else { $('#Hala1wymiarod').fadeOut("slow"); $('#Hala1wymiardo').fadeOut("slow");} });  
  	$('#Hala2').click(function() { var checked_status = this.checked; if(checked_status==true) { $('#Hala2wymiarod').fadeIn("slow"); $('#Hala2wymiardo').fadeIn("slow");} else { $('#Hala2wymiarod').fadeOut("slow"); $('#Hala2wymiardo').fadeOut("slow");} });  
  	$('#Ujezdzalnia1').click(function() { var checked_status = this.checked; if(checked_status==true) { $('#Ujezdzalnia1wymiarod').fadeIn("slow"); $('#Ujezdzalnia1wymiardo').fadeIn("slow");} else { $('#Ujezdzalnia1wymiarod').fadeOut("slow"); $('#Ujezdzalnia1wymiardo').fadeOut("slow");} });  
  	$('#Ujezdzalnia2').click(function() { var checked_status = this.checked; if(checked_status==true) { $('#Ujezdzalnia2wymiarod').fadeIn("slow"); $('#Ujezdzalnia2wymiardo').fadeIn("slow");} else { $('#Ujezdzalnia2wymiarod').fadeOut("slow"); $('#Ujezdzalnia2wymiardo').fadeOut("slow");} });
  	$('#NewsletterMail').focus(function() { $(this).val(''); });
	$('#ImieNazwisko').focus(function() { $(this).val(''); });
	$('#EMail').focus(function() { $(this).val(''); });
	$('#UserLogin').focus(function() { $(this).val(''); });
	$('#UserPassword').focus(function() { $(this).val(''); });

});
function ukryj(){
/*
	sprzedam 	-1
	kupie 		 0
	oddam		 1
	zamienie	 2
*/
	if(document.getElementById('Rodzaj').value==-1 || document.getElementById('Rodzaj').value==0) document.getElementById('ukryty3').style.display='block'; else document.getElementById('ukryty3').style.display='none';
	
	if(document.getElementById('Rodzaj').value!=0) { document.getElementById('ukryty').style.display='block';document.getElementById('ukryty1').style.display='block'; document.getElementById('ukryty2').style.display='block'; } else { document.getElementById('ukryty').style.display='none'; document.getElementById('ukryty1').style.display='none'; document.getElementById('ukryty2').style.display='none';}
}

function ukryj1(){
/*
	sprzedam 	-1
	kupie 		 0
	oddam		 1
	zamienie	 2
	
*/  
    var view = document.getElementById('ukrytyw').style.display;
    if(document.getElementById('IDKategorii').value==58 ||  view=="block" ) {document.getElementById('ukrytyw').style.display='none'; }else
    {document.getElementById('ukrytyw').style.display='block';  }
}

$(document).ready(function(){
	var did = $(".tabs-nav li.active a").attr("rel");
	$("div#"+ did).addClass("active");
	$(".tabs-nav a").click(function (){
		$(".tabs-nav li").removeClass("active");
		$(this).parent("li").toggleClass("active");
		var thref=$(this).attr("rel");
		$(".tab").css("display","none");
		$("div#"+thref).fadeIn("slow");
    });

    $('div#create').hide();
    $('div#upload').hide();

	$("a.panele").click(function(e){
		var panel = $(this).attr("href");
		$(".notice-form div.panel").hide();
		$("div"+panel).show();
        e.preventDefault();
	});

	$(".ctabs-nav a").click(function (){
		$(".ctabs-nav li").removeClass("active");
		$(this).parent("li").toggleClass("active");
		var chref=$(this).attr("rel");
		$(".ctab").css("display","none");
		$("div#"+chref).fadeIn("slow");
    });

	var count_elem = $('.carousel img').length;
	var default_items = 3;
	var image_width = 75;
	image_width = image_width + 1; /* image_width + 1px of margin*/
	var move_panel = 0;

	$("a.next").click(function(){
		if (move_panel<=((count_elem-default_items-1)*image_width)){
			move_panel=move_panel+image_width;
			$("div.panel").css("left","-"+move_panel+"px");
		};
		disable_link();
	});

	$("a.previous").click(function(){
		if (move_panel>0){
			move_panel=move_panel-image_width;
			$("div.panel").css("left","-"+move_panel+"px");
		}
		disable_link();
	});

	$('a[rel*=lightbox]').lightBox({
	imageBtnClose: '/images/lightbox/close.gif',
	imageBtnPrev: '/images/lightbox/prev.gif',
	imageBtnNext: '/images/lightbox/next.gif',
	imageLoading: '/images/lightbox/loading.gif'
	});

    $('ul.imagesList li a').click(function() { $('#gallery-photo').attr('src', this.href); return false; });
    
	function disable_link(){
		if (move_panel==0){
			$("a.previous").addClass("disabled");
		}
		else{
			$("a.previous").removeClass("disabled");
		};
		if (move_panel==(count_elem-default_items)*image_width){
			$("a.next").addClass("disabled");
		}
		else{
			$("a.next").removeClass("disabled");
		};
	};
});

$(document).ready(function(){
    $("#color").change(function(){
        var color = '#'+$('#color').val();
        $('#f_opaska').css('background-color', color);
        $('#b_opaska').css('background-color', color);
        if(color == '#FFFFFF') {
            $('#f_tekst').css('color', '#000');
            $('#b_tekst').css('color', '#000');
            $('#f_tbl').css('border', '1px solid #000');
            $('#b_tbl').css('border', '1px solid #000');
        } else {
            $('#f_tbl').css('border', 'none');
            $('#b_tbl').css('border', 'none');
        }
    });

    $("#f_font").change(function(){
        //var font = $('f_font').options[$('f_font').selectedIndex].text;
        var font = $('#f_font option:selected').text();
        $('#f_tekst').css('font-family', font);
    });

    $("#f_text").keyup(function(){
        var text = $('#f_text').val();
        $('#f_tekst').text(text);
    });

    $("#f_text2").keyup(function(){
        var text = $('#f_text2').val();
        $('#f_tekst2').text(text);
    });

    $("#size").change(function(){
        if($("#size").val() == '30') { $("#f_tekst2").hide();$("#f_text2").parent().hide(); } else { $("#f_tekst2").show();$("#f_text2").parent().show(); }
        $('#f_tbl').css('height', $("#size").val()+'px');
    });

});




