var loadListeners = new Array();
var unloadListeners = new Array();

function fireLoadEvent() {
	for (var i=0; i<loadListeners.length; ++i)
		loadListeners[i]();
}

function fireUnloadEvent() {
	for (var i=0; i<unloadListeners.length; ++i)
		unloadListeners[i]();
}

function addLoadListener(f) {
	loadListeners.push(f);
}

function addUnloadListener(f) {
	unloadListeners.push(f);
}


$('document').ready(function(){
	fireLoadEvent();
});



currentModuleUrl = '/map';

var reloadMediaContent = function() {
	if(currentModuleUrl.indexOf('/map') != -1) {
		Map.loadCurrentMediaItems();
	}
	else {
		$.ajax({
			url: currentModuleUrl,
			success: function(data) {
			   $('#content').html(data);
			},
			cache: false
		})
	}
}


var mediaFilterYearSliderMovedCallback = function(min, max) {
}

var mediaFilterYearSliderChangedCallback = function(min, max) {
	// update filter & view
	$.ajax({
		url: 'filter/setYearRange?from='+min+'&to='+max,
		success: function(data) {
			reloadMediaContent();
		},
		cache: false
	});
}



// FIX IE problem: IE caches ALLL frickin' AJAX requests!! -.-
$('document').ready(function(){
	$.ajaxSetup({
		cache: false
	});
});


