$(document).ready(function() {
	pytanieUsun();
	zwinZakwaterowanieDane();
	rozwinZakwaterowanieInformacje();
	rozwinAdminWiecej();
	datePicker();
	dateWrite();
	dateWrite1();
	dateWrite2();
	dateWrite3();
	dateWystawienia();
	dateSprzedazy();
	dateRozpoczecia();
	onSelectChange();
	$(".uwagaAreaUser").markItUp(mySettingsUser);
	$(".tekstAreaUser").markItUp(mySettingsUser);
	$("#tekstAreaUser").markItUp(mySettingsUser);
	$("#tekstArea").markItUp(mySettings);
	$(".tekstArea").markItUp(mySettings);
	$("#commentForm").validate();
	$("input#miniMiejscowosc").autocomplete("http://www.eurowypoczynek.pl/miasta.php",{width: 130, max: 20, minChars: 1, selectFirst: false, cacheLength: 1, matchContains: false});
	$("input#glownaMiejscowosc").autocomplete("http://www.eurowypoczynek.pl/miasta.php",{width: 150, max: 20, minChars: 1, selectFirst: false, cacheLength: 1, matchContains: false});
	$("input#zaawansowaneMiejscowosc").autocomplete("http://www.eurowypoczynek.pl/miasta.php",{width: 250, max: 20, minChars: 1, selectFirst: false, cacheLength: 1, matchContains: false});
	$('#textBar>div>a').show();
	$('#textBarH').hide();
	$("#textBar div a").click(function() {
   		var hidden = $(this).parents("div").children("p").is(":hidden");
		$("#textBar>div>p").hide()        
	   	$("#textBar>div>a").removeClass();
	   	if (hidden) {
	   		$(this)
		   		.parents("div").children("p").toggle()
		   		.parents("div").children("a").addClass("aText");
		   	} 
	   });


});

var timeout    = 500;
var closetimer = 0;
var ddmenuitem = 0;

function jsddm_open()
{  jsddm_canceltimer();
   jsddm_close();
   ddmenuitem = $(this).find('ul').css('visibility', 'visible');}

function jsddm_close()
{  if(ddmenuitem) ddmenuitem.css('visibility', 'hidden');}

function jsddm_timer()
{  closetimer = window.setTimeout(jsddm_close, timeout);}

function jsddm_canceltimer()
{  if(closetimer)
   {  window.clearTimeout(closetimer);
      closetimer = null;}}

$(document).ready(function()
{  $('#jsddm > li').bind('mouseover', jsddm_open)
   $('#jsddm > li').bind('mouseout',  jsddm_timer)});

document.onclick = jsddm_close;


function pytanieUsun()
{	
	$(".Usun").click(
	function()
	{
		var sprawdz = confirm(wpis);
		if (sprawdz == true) {
		return true;
		}
		else if (sprawdz == false) {
		return false;
		}
	});
}	

function zwinZakwaterowanieDane()
	{
		$("ul#zakwaterowanie li").children("a.dane").click(
		function()
		{
			$(this).next(".zakwaterowanieDane").toggle();
		}).toggle(function() { $(this).text(zwin); }, function() { $(this).text(rozwin); });
	}	

function rozwinZakwaterowanieInformacje()
	{
		$("ul#zakwaterowanie li").children("a.informacje").click(
		function()
		{
			$(this).next(".zakwaterowanieDaneInformacje").toggle();
		}).toggle(function() { $(this).text(zwin); }, function() { $(this).text(rozwin); });
	}

function rozwinAdminWiecej()
	{
		$(".boxAdminMenu").children("a.wiecej").click(
		function()
		{
			$(this).next(".boxAdminLink").toggle();
		}).toggle(function() { $(this).text(zwin); }, function() { $(this).text(rozwin); });
	}
function datePicker()
{
	$("#restricting").datepicker({ 
	dateFormat: "dd.mm.y",
    firstDay: 1, 
    changeFirstDay: false, 
    showOn: "both", 
    buttonImage: "http://www.eurowypoczynek.pl/images/calendar.gif", 
    buttonImageOnly: true 
	});
}

function dateWrite()
{
	$("#dateselect").datepicker({ 
	dateFormat: "yy-mm-dd",
    firstDay: 1, 
    changeFirstDay: false, 
    showOn: "both", 
    buttonImage: "http://www.eurowypoczynek.pl/images/calendar.gif", 
    buttonImageOnly: true 
	});
}
	
function dateWrite1()
{
	$("#dateselect1").datepicker({ 
	dateFormat: "yy-mm-dd",
    firstDay: 1, 
    changeFirstDay: false,
    showOn: "both", 
    buttonImage: "http://www.eurowypoczynek.pl/images/calendar.gif", 
    buttonImageOnly: true 
	});
}
function dateWrite2()
{
	$("#dateselect2").datepicker({ 
	dateFormat: "yy-mm-dd",
    firstDay: 1, 
    changeFirstDay: false,
    showOn: "both", 
    buttonImage: "http://www.eurowypoczynek.pl/images/calendar.gif", 
    buttonImageOnly: true 
	});
}

function dateWrite3()
{
	$("#dateselect3").datepicker({ 
	dateFormat: "yy-mm-dd",
	firstDay: 1, 
	changeFirstDay: false,
	showOn: "both", 
	buttonImage: "http://www.eurowypoczynek.pl/images/calendar.gif", 
	buttonImageOnly: true 
	});
}

function dateWystawienia()
{
	$("#data_wystawienia").datepicker({ 
	dateFormat: "yy-mm-dd",
	firstDay: 1, 
	changeFirstDay: false,
	showOn: "both", 
	buttonImage: "http://www.eurowypoczynek.pl/images/calendar.gif", 
	buttonImageOnly: true 
	});
}


function dateSprzedazy()
{
	$("#data_sprzedazy").datepicker({ 
	dateFormat: "yy-mm-dd",
	firstDay: 1, 
	changeFirstDay: false,
	showOn: "both", 
	buttonImage: "http://www.eurowypoczynek.pl/images/calendar.gif", 
	buttonImageOnly: true 
	});
}

function dateRozpoczecia()
{
	$("#data_rozpoczecia").datepicker({ 
	dateFormat: "yy-mm-dd",
	firstDay: 1, 
	changeFirstDay: false,
	showOn: "both", 
	buttonImage: "http://www.eurowypoczynek.pl/images/calendar.gif", 
	buttonImageOnly: true 
	});
}
	
function profil(x)
	{
	document.location='/zakwaterowanie/'+x;
	}

function onSelectChange() {
	$("#pokazZakres").change(function () {
    $("#pokazZakres option:selected").each(function ()
    		{
             	if($(this).attr("class") == "pokazDaty")
    			{
    				$(".pokazPolaDaty").show();
    			}
    			else
    			{
    				$(".pokazPolaDaty").hide();
    			}
            });
        }).change();
}
