// What is $(document).ready ? See: http://flowplayer.org/tools/documentation/basics.html#document_ready

	function initOverlay(){
// select the overlay element - and "make it an overlay"
		
		
		
		
		
		$("#mie1").overlay({

	// custom top position
	top: 260,

	// some mask tweaks suitable for facebox-looking dialogs
	mask: {

		// you might also consider a "transparent" color for the mask
		color: '#fff',

		// load mask a little faster
		loadSpeed: 200,

		// very transparent
		opacity: 0.5
	},

	// disable this for modal dialog-type of overlays
	closeOnClick: false,

	// load it immediately after the construction
	load: false

});
		
};

function loadOverlay(){
	
	$("#mies1").overlay().load();
}
function closeOverlay(){

	$("#mies1").overlay().close();
}

$(document).ready(function(){initOverlay();if (pingInterval>0){checkNotifications();setInterval( "checkNotifications()", pingInterval );}});

function checkNotifications(){
		
	jQuery.ajax({
			url: "/notification/check/",
			success: function(html){
				showNotification(html);
			}
		});
};
/**
 * Wyświetla okienko z informacją dla użytkownika
 * 
 * @param newHtml wiadomosc do wyswietlenia
 */
function showNotification(newHtml) {
	var oldHtml = jQuery("#mess").html()
	if (newHtml != "" && newHtml != oldHtml){
			closeOverlay();
			setTimeout(function(){ jQuery("#mess").html(newHtml); loadOverlay();}, 2000)
	}
}



