var prevCityId;
function setSelectedCityId(cityId)
{
	if($('city_shows_' + prevCityId))
	{
		$('city_shows_' + prevCityId).hide();
	}	
	
	prevCityId = cityId;
	
	if($('city_shows_' + cityId))
	{
		$('city_shows_' + cityId).show();
		Cookies.create('cinema_schedule_city_id', cityId, 365);
	}
}

function togglePanel(panelId)
{
	if($(panelId))
	{
		var linkId = panelId + "_link";
		if($(panelId).visible())
		{
			Effect.SlideUp($(panelId));
			if($(linkId).hasClassName('displayed'))
			{
				$(linkId).removeClassName('displayed');
			}
			Cookies.create(panelId, 'false', 365);
		}
		else 
		{
			Effect.SlideDown($(panelId));
			$(linkId).addClassName('displayed');
			Cookies.create(panelId, 'true', 365);
		}
	}
}

function showPanel(panelId)
{
	if($(panelId))
	{
		$(panelId).show();
	}
	
	var linkId = panelId + "_link";
	if($(linkId))
	{
		$(linkId).addClassName('displayed');
	}
}

function initCookies()
{
	if(Cookies['top_new_post'] == "true")
	{
		showPanel('top_new_post');
	}
	
	if(Cookies['bottom_new_post'] == "true")
	{
		showPanel('bottom_new_post');
	}
	
	if(Cookies['expired_monopol'] == "true")
	{
		showPanel('expired_monopol');
	}
	
	if(Cookies['extended_monopol'] == "true")
	{
		showPanel('extended_monopol');
	}
}


function observerSearchString()
{
	$$('html').first().observe('click', checkSearchString);
}


function checkSearchString(event)
{
	var id = "searchStringInput";
	var originalString = "Vyhľadávanie";
	
	var element = Event.element(event);
	if(element.id == id)
	{
		if(element.value == originalString)
		{
			originalString = element.value;
			element.value = '';
		}
	}
	else if(!$F(id))
	{
		$(id).value = originalString;
	}
}