$(document).ready(function() {

	// Map open and close the map

	$("#map").animate({"height": "-=225px"}, "slow");
	$("#map_expand_btn").toggle(
		function () {
		        $("#map").animate({"height": "+=225px"}, "slow");
		},
		function () {
		        $("#map").animate({"height": "-=225px"}, "slow");
		}
	);


	if (typeof gmap != "undefined"){

		//Add the markers
		$.each(events,function(i, objValue ){

			$.each(eventlocations,function(i, objLoc){
				if (objValue.id == objLoc.event_id){
					if (objLoc.latlng != ''){
					html = "<table width=\"100%\" height=\"100%\" border=\"0\"><tr><td><img src=\"/viewimage.php?id='" +objValue.image+ "\"></td><td valign=\"top\"><b>"+ objValue.name+"</b><br></td></tr><tr><td colspan=\"2\" height=\"20px\" align=\"right\"><a href=\"/evenement/"+objValue.id+"\" rel=\""+objValue.latlng+"\" >leesmeer..</a></td></tr></table>";
					gmap.addMarker({"id" : objValue.id,"name" : objValue.name, "latlng" : objLoc.latlng, "type" : "marker", "prop" : "", "markerHTML" : html, "markerIcone" : "/layout/images/kaart_icons/icon_brown.png"});
					}
				}
			});
		});

	}

	$('#events ul').hide();
	$('#events .active').show();
	$('#events li div').click(
	    function() {
	      var checkElement = $(this).next();
	      if((checkElement.is('ul')) && (checkElement.is(':visible'))) {
	        return false;
	      }
	      if((checkElement.is('ul')) && (!checkElement.is(':visible'))) {
	        $('#events ul:visible').slideUp('normal');
	        checkElement.slideDown('normal');
	        return false;
	      }
	});





});
