$(document).ready(function(){
	$('a.openWindow').click(function(){
		// Set Overlay and Holder according to Page Size and Scroll Position
		pageScroll = getPageScroll();
		pageSize = getPageSize();
		$('#overlay').css('width',pageSize[0]);
		$('#overlay').css('height',pageSize[1]);
		$("#overlay").toggle();
		$("#overlay").fadeTo( 400, 0.8 );
		$("#overlay").queue( function(){
			showWindow();
			$(this).dequeue();
		});
	});
	
	$('#closeWindow').click(function(){
		$('#jqWindow').slideUp( 500 );
		$("#jqWindow").queue( function(){
			hideWindow();
			$(this).dequeue();
		});
		
	});
	$('div#overlay').click(function(){
		$('#jqWindow').slideUp( 500 );
		$("#jqWindow").queue( function(){
			hideWindow();
			$(this).dequeue();
		});
		
	});
	
	$('#printPlan').click(function(){
		openWindow();
	});	
});

function showWindow(){
	$('#window_holder').css('top',pageScroll[1]+pageSize[3]/2);
	$('#jqWindow').slideDown({duration:1200,easing:"easeOutExpo"})
}

function hideWindow(){
	$("#overlay").fadeTo( 400 , 0.0 );
	$("#overlay").queue( function(){
		hideOverlay();
		$(this).dequeue();
	});

}

function hideOverlay(){
	$("#overlay").toggle();
}

function openWindow(content) {
	printWindow = window.open("", "Lageplan udpate AG", "width=670,height=600,scrollbars=yes");
	writeContent();

	//printWindow.stop();
	//printWindow.focus();
	printWindow.print();
}
function writeContent(){
	printWindow.document.write('<html><head></head></body>');
	printWindow.document.write('<p>text<p>');
	printWindow.document.write('</html>');
}