$(document).ready(function(){
	// This function is executed once the document is loaded
	
	// Caching the jQuery selectors:
	var snpanel = $('#newSpot .panel');
	var snloadwhat = $("#newSpot p:first").text();
	var sntimeout;
	
	$('#newSpot').hover(
		function(){
			// Setting a custom 'open' event on the sliding panel:
			
			clearTimeout(sntimeout);
			sntimeout = setTimeout(function(){snpanel.trigger('open');},500);
		},
		function(){
			// Custom 'close' event:
			
			clearTimeout(sntimeout);
			sntimeout = setTimeout(function(){snpanel.trigger('close');},500);
		}
	);
	
	var sloaded=false;	// A flag which prevents multiple ajax calls to geodata.php;
	
	// Binding functions to custom events:
	
	snpanel.bind('open',function(){
		snpanel.slideDown(function(){
			if(!sloaded)
			{
				// Loading the countries and the flags once the sliding panel is shown:
				snpanel.load(jakCMS.jakcms_url+'plugin/new_stuff/ajax.php?what='+snloadwhat+'&url='+jakCMS.jakcms_url);
				sloaded=true;
			}
		});
	}).bind('close',function(){
		snpanel.slideUp();
	});
	
	// Caching the jQuery selectors:
	var cnpanel = $('#newSchool .panel');
	var cnloadwhat = $("#newSchool p:first").text();
	var cntimeout;
	
	$('#newSchool').hover(
		function(){
			// Setting a custom 'open' event on the sliding panel:
			
			clearTimeout(cntimeout);
			cntimeout = setTimeout(function(){cnpanel.trigger('open');},500);
		},
		function(){
			// Custom 'close' event:
			
			clearTimeout(cntimeout);
			cntimeout = setTimeout(function(){cnpanel.trigger('close');},500);
		}
	);
	
	var cloaded=false;	// A flag which prevents multiple ajax calls to geodata.php;
	
	// Binding functions to custom events:
	
	cnpanel.bind('open',function(){
		cnpanel.slideDown(function(){
			if(!cloaded)
			{
				// Loading the countries and the flags once the sliding panel is shown:
				cnpanel.load(jakCMS.jakcms_url+'plugin/new_stuff/ajax.php?what='+cnloadwhat+'&url='+jakCMS.jakcms_url);
				cloaded=true;
			}
		});
	}).bind('close',function(){
		cnpanel.slideUp();
	});
	
	// Caching the jQuery selectors:
	var anpanel = $('#newAccomm .panel');
	var anloadwhat = $("#newAccomm p:first").text();
	var antimeout;
	
	$('#newAccomm').hover(
		function(){
			// Setting a custom 'open' event on the sliding panel:
			
			clearTimeout(antimeout);
			antimeout = setTimeout(function(){anpanel.trigger('open');},500);
		},
		function(){
			// Custom 'close' event:
			
			clearTimeout(antimeout);
			antimeout = setTimeout(function(){anpanel.trigger('close');},500);
		}
	);
	
	var aloaded=false;	// A flag which prevents multiple ajax calls to geodata.php;
	
	// Binding functions to custom events:
	
	anpanel.bind('open',function(){
		anpanel.slideDown(function(){
			if(!aloaded)
			{
				// Loading the countries and the flags once the sliding panel is shown:
				anpanel.load(jakCMS.jakcms_url+'plugin/new_stuff/ajax.php?what='+anloadwhat+'&url='+jakCMS.jakcms_url);
				aloaded=true;
			}
		});
	}).bind('close',function(){
		anpanel.slideUp();
	});
	
	// Caching the jQuery selectors:
	var npanel = $('#newShop .panel');
	var nloadwhat = $("#newShop p:first").text();
	var ntimeout;
	
	$('#newShop').hover(
		function(){
			// Setting a custom 'open' event on the sliding panel:
			
			clearTimeout(ntimeout);
			ntimeout = setTimeout(function(){npanel.trigger('open');},500);
		},
		function(){
			// Custom 'close' event:
			
			clearTimeout(ntimeout);
			ntimeout = setTimeout(function(){npanel.trigger('close');},500);
		}
	);
	
	var nloaded=false;	// A flag which prevents multiple ajax calls to geodata.php;
	
	// Binding functions to custom events:
	
	npanel.bind('open',function(){
		npanel.slideDown(function(){
			if(!nloaded)
			{
				// Loading the countries and the flags once the sliding panel is shown:
				npanel.load(jakCMS.jakcms_url+'plugin/new_stuff/ajax.php?what='+nloadwhat+'&url='+jakCMS.jakcms_url);
				nloaded=true;
			}
		});
	}).bind('close',function(){
		npanel.slideUp();
	});
	
});
