/*
 *	--- stadshuset.js ---
 *
 *	Author: Alexander Velander
 *
 *	Javascriptgrejer för stadshuset.
 */
	/*
******	För JQuery  ******
	 */
	$(document).ready(function() {
		// Sätt opacitet för cover till noll
		$('#cover').fadeTo(0, 0);
		// Sätt opacitet för popups till noll
		$('.popup').fadeTo(0, 0);
	});
	/*
******	Bra funktioner  ******
	 *
	 *	Visa/dölj popup
	 */
	function showPopup(page) {
		// Hämta storlek
		var height = $(document).height();
		// Sätt storlek för cover
		$('#cover').height($(document).height());
		// Fixa position
		$('#popup').css('top', $(window).scrollTop() + 20);
		// Sätt display till block för cover och popup
		$('#cover').css('display', 'block');
		$('#popup').css('display', 'block');
		// Tona först in cover, sedan hämta innehåll, sedan popup
		$('#cover').fadeTo(500, 0.7, function() {
			$('#popup').load('/ajax/', { 'page': page }, function() {
				$('#popup').fadeTo(500, 1, function() {
					// Sätt storlek igen för cover
					if ( $(document).height() > height )
						$('#cover').height($(document).height() + 20);
				});
			});
		});
		// Returnera false (hindrar länken från att fungera)
		return false;
	}
	function hidePopup() {
		// Tona först ut popup, sedan cover
		$('#popup').fadeTo(500, 0, function() {
			$('#cover').fadeTo(500, 0, function() {
				// Sätt display till none för popup och cover
				$('#popup').css('display', 'none');
				$('#cover').css('display', 'none');
			});
		});
	}
	/*
	 *	Visa popup för panorama
	 */
	function showPanorama(page) {
		// Sätt popupklass till panorama
		$('#popup').addClass('panorama');
		// Kör vanliga showPopup
		showPopup(page);
	}