function load_maps() {
  if (GBrowserIsCompatible()) {
  	 $('maps').hide();
  
    window.map = new GMap2($('maps'), { size:new GSize(450,590)} );
    window.map.setCenter(new GLatLng(53.21892,6.56987), 16);

    var customUI = window.map.getDefaultUI();
	customUI.controls.maptypecontrol = false;
	window.map.setUI(customUI);
	
	var icon = new GIcon();
	icon.image = "../style/parking.jpg";
	icon.iconSize = new GSize(20,20);
	icon.iconAnchor = new GPoint(10,10);

	var bbb = new GLatLng(53.21917, 6.57202);
	window.map.addOverlay(new GMarker(bbb));
  	
  	var parking1 = new GLatLng(53.21736,6.57223);
  	window.map.addOverlay(new GMarker(parking1, icon));
  	
  	var parking2 = new GLatLng(53.21892,6.56987);
  	window.map.addOverlay(new GMarker(parking2, icon));   
  }
}

function load_calendars() {
	new Ajax.Request('./calendars.php', {
		onComplete: function(transport) {
			$('calendars').innerHTML = transport.responseText;
		}
	});
}

var Slider = Class.create({
  initialize: function() {
    this.current = 0;
    this.flag = 0;
    this.pictures = $$("ul#pictures li.slide");
    this.total = $$("ul#pictures li.slide").size();
    
    this.start();
  },
  start: function() {
  	if (this.total > 1) {
    	this.timer = new PeriodicalExecuter(this.show_next.bind(this), 7);
    	this.flag = 1;
    } else {
    	this.pictures[0].appear();
    }
  },
  show_next: function() {
  	this.pictures[this.current].fade();
  	this.current++;
    if (this.current == this.total) {
    	this.current = 0;
    }
	this.pictures[this.current].appear();
  },
  show: function(id) {
  	if($(id) && Effect.Queues.get('slider').size() == 0) {
  		if(this.flag == 1) {
  			this.timer.stop();
  			this.flag = 0;

  			if(!$(id).visible()) {				
				new Effect.Parallel([
					new Effect.Appear($(id), { sync: true }), 
					new Effect.Fade(this.pictures[this.current], { sync: true }) 
				], { 
					queue: { position: 'end', scope: 'slider', limit: 1 }
				});
			}
		} else {
			if($(id).visible()) {
				if($(id).id != this.pictures[this.current].id) {
					new Effect.Parallel([
						new Effect.Appear(this.pictures[this.current], { sync: true }), 
						new Effect.Fade($(id), { sync: true }) 
					], { 
						queue: { position: 'end', scope: 'slider', limit: 1 }
					});
				}
				this.start();
			} else {
				this.pictures.each(function(s) {
					if(s.visible()) {
						s.fade();
					}
				});
				$(id).appear();
			}
		} 				
	}
  }
});

document.observe("dom:loaded", function() {
  	$("pictures").childElements().each(function(s, index) {
  		if (index != 0) {
  			s.hide();
  		}
  	});
 });

Event.observe(window, 'load', function() {
	window.slider = new Slider();
});
