function deleteItem(event, anchor, link)
{
	if(confirm('Jesteś pewny, że chcesz usunąć wybrany element?'))
	{
		return true;
	}
	else
	{
		event.cancelBubble = true;
		if(event.preventDefault) event.preventDefault();
		if(event.returnValue) event.returnValue = false;
		if(event.stopPropagation) event.stopPropagation();
		if(!event.stopPropagation) anchor.href = link;
		return false;
	}
}
function showTab(tabId)
{
	hideAllTabs();
	$("#" + tabId + "").css("display", "block");
	$("#tab_" + tabId + "").addClass("selected");
}
function hideAllTabs()
{
	$("#miejscowosci").hide();
	$("#tab_miejscowosci").removeClass("selected");
	$("#przepisy").hide();
	$("#tab_przepisy").removeClass("selected");
	$("#noclegi").hide();
	$("#tab_noclegi").removeClass("selected");
	$("#atrakcje").hide();
	$("#tab_atrakcje").removeClass("selected");
	$("#imprezy").hide();
	$("#tab_imprezy").removeClass("selected");
}
$(document).ready(function() {
	init_box_login();
	$("#miejscowosciDodatkoweRodzajeWypoczynku").hide();
	$("#miejscowosciDodatkoweAtrakcje").hide();
	$("#miejscowosciRozwijacz").find("span").removeClass("searchNormal").addClass("searchExtended");
	$("#miejscowosciRozwijacz").click(function(e) {
		if($("#miejscowosciDodatkoweRodzajeWypoczynku").css("display") != "block")
		{
			$("#miejscowosciDodatkoweRodzajeWypoczynku").show();
			$("#miejscowosciDodatkoweAtrakcje").show();
			$(this).find("span").removeClass("searchExtended").addClass("searchNormal");
		}
		else
		{
			$("#miejscowosciDodatkoweRodzajeWypoczynku").hide();
			$("#miejscowosciDodatkoweAtrakcje").hide();
			$(this).find("span").removeClass("searchNormal").addClass("searchExtended");
		}
		e.preventDefault();
	});

	$("#przepisyDodatkoweRodzajeWypoczynku").hide();
	$("#przepisyKategorieAtrakcji").hide();
	$("#przepisyKategorieImprez").hide();
	$("#przepisyRozwijacz").find("span").removeClass("searchNormal").addClass("searchExtended");
	$("#przepisyRozwijacz").click(function(e) {
		if($("#przepisyDodatkoweRodzajeWypoczynku").css("display") != "block")
		{
			$("#przepisyDodatkoweRodzajeWypoczynku").show();
			$("#przepisyKategorieAtrakcji").show();
			$("#przepisyKategorieImprez").show();
			$(this).find("span").removeClass("searchExtended").addClass("searchNormal");
		}
		else
		{
			$("#przepisyDodatkoweRodzajeWypoczynku").hide();
			$("#przepisyKategorieAtrakcji").hide();
			$("#przepisyKategorieImprez").hide();
			$(this).find("span").removeClass("searchNormal").addClass("searchExtended");
		}
		e.preventDefault();
	});

	$("#noclegiDodatkoweWyposazenie").hide();
	$("#noclegiRozwijacz").find("span").removeClass("searchNormal").addClass("searchExtended");
	$("#noclegiRozwijacz").click(function(e) {
		if($("#noclegiDodatkoweWyposazenie").css("display") != "block")
		{
			$("#noclegiDodatkoweWyposazenie").show();;
			$(this).find("span").removeClass("searchExtended").addClass("searchNormal");
		}
		else
		{
			$("#noclegiDodatkoweWyposazenie").hide();
			$(this).find("span").removeClass("searchNormal").addClass("searchExtended");
		}
		e.preventDefault();
	});

	$("#atrakcjeDodatkoweKategorie").hide();
	$("#atrakcjeRozwijacz").find("span").removeClass("searchNormal").addClass("searchExtended");
	$("#atrakcjeRozwijacz").click(function(e) {
		if($("#atrakcjeDodatkoweKategorie").css("display") != "block")
		{
			$("#atrakcjeDodatkoweKategorie").show();;
			$(this).find("span").removeClass("searchExtended").addClass("searchNormal");
		}
		else
		{
			$("#atrakcjeDodatkoweKategorie").hide();
			$(this).find("span").removeClass("searchNormal").addClass("searchExtended");
		}
		e.preventDefault();
	});

	$("#imprezyDodatkoweKategorie").hide();
	$("#imprezyCzasRozpoczeciaOd").hide();
	$("#imprezyCzasRozpoczeciaDo").hide();
	$("#imprezyAktualnoscImprezy").hide();
	$("#imprezyRozwijacz").find("span").removeClass("searchNormal").addClass("searchExtended");
	$("#imprezyRozwijacz").click(function(e) {
		if($("#imprezyDodatkoweKategorie").css("display") != "block")
		{
			$("#imprezyDodatkoweKategorie").show();;
			$("#imprezyCzasRozpoczeciaOd").show();;
			$("#imprezyCzasRozpoczeciaDo").show();;
			$("#imprezyAktualnoscImprezy").show();
			$(this).find("span").removeClass("searchExtended").addClass("searchNormal");
		}
		else
		{
			$("#imprezyDodatkoweKategorie").hide();
			$("#imprezyCzasRozpoczeciaOd").hide();;
			$("#imprezyCzasRozpoczeciaDo").hide();;
			$("#imprezyAktualnoscImprezy").hide();
			$(this).find("span").removeClass("searchNormal").addClass("searchExtended");
		}
		e.preventDefault();
	});

	$("#tab_miejscowosci").click(function(e) {
		showTab('miejscowosci');
		e.preventDefault();
	});
	$("#tab_przepisy").click(function(e) {
		showTab('przepisy');
		e.preventDefault();
	});
	$("#tab_noclegi").click(function(e) {
		showTab('noclegi');
		e.preventDefault();
	});
	$("#tab_atrakcje").click(function(e) {
		showTab('atrakcje');
		e.preventDefault();
	});
	$("#tab_imprezy").click(function(e) {
		showTab('imprezy');
		e.preventDefault();
	});
	
	$("#hp_region").change(function(e) {
		var regionId = document.getElementById("hp_region").options[document.getElementById("hp_region").selectedIndex].value;
		$("#hp_city").find("option").each(function() {
			if(regionId != "-1")
			{
				if($(this).attr("id") == "hp_" + regionId || $(this).attr("id") == "hp_0")
				{
					$(this).show();
				}
				else
				{
					$(this).hide();
				}
			}
			else
			{
				$(this).show();
			}
		});
	}).each(function() {
		var regionId = document.getElementById("hp_region").options[document.getElementById("hp_region").selectedIndex].value;
		$("#hp_city").find("option").each(function() {
			if(regionId != "-1")
			{
				if($(this).attr("id") == "hp_" + regionId || $(this).attr("id") == "hp_0")
				{
					$(this).show();
				}
				else
				{
					$(this).hide();
				}
			}
			else
			{
				$(this).show();
			}
		});
	});

	$("#h_region").change(function(e) {
		var regionId = document.getElementById("h_region").options[document.getElementById("h_region").selectedIndex].value;
		$("#h_city").find("option").each(function() {
			if(regionId != "-1")
			{
				if($(this).attr("id") == "h_" + regionId || $(this).attr("id") == "h_0")
				{
					$(this).show();
				}
				else
				{
					$(this).hide();
				}
			}
			else
			{
				$(this).show();
			}
		});
	}).each(function() {
		var regionId = document.getElementById("h_region").options[document.getElementById("h_region").selectedIndex].value;
		$("#h_city").find("option").each(function() {
			if(regionId != "-1")
			{
				if($(this).attr("id") == "h_" + regionId || $(this).attr("id") == "h_0")
				{
					$(this).show();
				}
				else
				{
					$(this).hide();
				}
			}
			else
			{
				$(this).show();
			}
		});
	});

	$("#a_region").change(function(e) {
		var regionId = document.getElementById("a_region").options[document.getElementById("a_region").selectedIndex].value;
		$("#a_city").find("option").each(function() {
			if(regionId != "-1")
			{
				if($(this).attr("id") == "a_" + regionId || $(this).attr("id") == "a_0")
				{
					$(this).show();
				}
				else
				{
					$(this).hide();
				}
			}
			else
			{
				$(this).show();
			}
		});
	}).each(function() {
		var regionId = document.getElementById("a_region").options[document.getElementById("a_region").selectedIndex].value;
		$("#a_city").find("option").each(function() {
			if(regionId != "-1")
			{
				if($(this).attr("id") == "a_" + regionId || $(this).attr("id") == "a_0")
				{
					$(this).show();
				}
				else
				{
					$(this).hide();
				}
			}
			else
			{
				$(this).show();
			}
		});
	});

	$("#e_region").change(function(e) {
		var regionId = document.getElementById("e_region").options[document.getElementById("e_region").selectedIndex].value;
		$("#e_city").find("option").each(function() {
			if(regionId != "-1")
			{
				if($(this).attr("id") == "e_" + regionId || $(this).attr("id") == "e_0")
				{
					$(this).show();
				}
				else
				{
					$(this).hide();
				}
			}
			else
			{
				$(this).show();
			}
		});
	}).each(function() {
		var regionId = document.getElementById("e_region").options[document.getElementById("e_region").selectedIndex].value;
		$("#e_city").find("option").each(function() {
			if(regionId != "-1")
			{
				if($(this).attr("id") == "e_" + regionId || $(this).attr("id") == "e_0")
				{
					$(this).show();
				}
				else
				{
					$(this).hide();
				}
			}
			else
			{
				$(this).show();
			}
		});
	});
	
	$(".deleteButton").click(function(e) {
		if(confirm('Jesteś pewny, że chcesz usunąć wybrany element?'))
		{
		}
		else
		{
			e.preventDefault();
		}
	});
});

