
function HideImprint() 
{
	$('#imprint').hide(0);
	return false;
}

function HideMessage() {
	$('#message').hide(0);
	return false;
}

function HideAllWindows()
{
	HideImprint();
	HideMessage();
}

function ShowImprint()
{
	HideAllWindows();
	$('#imprint_content').load('http://www.automatensuche.de/include/docs/imprint.php', function() {			
		$('#imprint').show(200);
	});
	
	return false;
}

function ShowMessage(headline, text)
{
	HideAllWindows();
	$('#message_headline').html(headline);
	$('#message_content').html(text);
	$('#message').show(200);
}

$(document).ready(function() 
{
	$('#inf'+'orma'+'tion').hide(0);
	$('#filter_options').hide(0);
	
	$('#ShowHidePnlRight').click(function()
	{
		$(this).slideToggle("slow");
		return false;
	});
	
	$('#btnShowHideFilterOptions').click(function() 
	{
		$('#filter_options').slideToggle("slow");
		return false;
	});
	
	$('#btnShowHideInformation').click(function() 
	{
		$('#information').slideToggle("slow");
		return false;
	});
	
	$('.automat_filter_cbx').click(function()
	{
		AutomatSearch.loadAutomats();
	});
	
	$('#btnAddNewAutomat').click(function()
	{
		if(($('#new_automat_lat').val() != "") && ($('#new_automat_lng').val() != ""))
		{
			var lat     = parseFloat($('#new_automat_lat').val());
			var lng     = parseFloat($('#new_automat_lng').val());
			var type    = $('#id_selAutomatType option:selected').val();
			var ec_card = ($('#pay_with_ec_card:checked').val() != undefined) ? 1 : 0;

			$(document.createElement("div")).load(AutomatSearch.domain + "javascript/ajax/addAutomat.php?lang=de&lat=" + lat + "&lng=" + lng + "&type=" + type + "&ec_card=" + ec_card, function() {
				ShowMessage('Automaten eintragen', $(this).html());
			});
			
			$("#new_automat_lat").val("");
			$("#new_automat_lng").val("");
			AutomatSearch.loadAutomats();
		}
		else
		{
			ShowMessage('Automaten eintragen', '<span style=\"color:red;\">Du musst den Standort, wo sich der Automat befindet, auf der Karte anklicken.</span>');
		}
		
		return false;
	});
	
	function adjust()
	{
		$('#map').css('height', $(document).height() + "px");
		$('#pnlRight').css('left', ($(document).width() - $('#pnlRight').outerWidth()) + "px");
	}
	adjust();
	
	function centerElement(element)
	{
		$(element).css('left', ($(document).width() / 2) - ($(element).width() / 2));
	}
});

