
function reloadSorting(mapElement, sort_id) {
	var debug = false;
	if (debug) {console.info("[FlagsTools.js] Starting reloadFlags");}
	
	if (getZoom(mapElement) > 4) {
		if (debug) { console.info("[MapTools.js] [reloadMarkers] Searching square []"); }
		
		default_sorter = sort_id;
		
		for( var i=0; i< 4; i++)
		{
			$('sort_'+i).setStyle('font-weight', 'normal');
			$('sort_'+i).setStyle('text-decoration', 'none');
		}
		
		$('sort_'+sort_id).setStyle('font-weight', 'bold');
		$('sort_'+sort_id).setStyle('text-decoration', 'underline');		
		
		latLngBounds = getMap(mapElement).getBounds();
		
	    getEventListAjaxWithCoordSortingBy(
			mapElement,
			searchValues, 
			latLngBounds.getNorthEast().lat(), 
			latLngBounds.getNorthEast().lng(),
			latLngBounds.getSouthWest().lat(), 
			latLngBounds.getSouthWest().lng(),
			sort_id);
	}else{
		getMap( mapElement).clearOverlays();
		
		if( $('liste_resultat'))	
			$('liste_resultat').empty().setStyle('display', 'none');
	
			
		if( $('selectCtl'))	
			$('selectCtl').options.length =0;
	}

	if( debug) {console.info("[FlagsTools.js] End of reloadFlags");}
}

function getEventListAjaxWithCoordSortingBy( mapElement, mySearchValues, neLat, neLng, swLat, swLng, sort_id){

	mode = 'search';
	
	searchValues = mySearchValues;
	
	if( $('maploading'))
		$('maploading').setStyle('display', 'block');
	
	new Request.JSON(
	{
		url:contextPath+modulePath+'search/'+mode+'/'+mySearchValues+'/'+neLat+'/'+neLng+'/'+swLat+'/'+swLng+'/-1/'+sort_id+'/0/false/'+user_map_id,
		method: 'get',
		encoding:'ISO-8859-1',
		onComplete:function(jsonObj) {
				processEventList(mapElement, jsonObj);
			}
	}).send();
	
}
