

var menuHighlighting = {
	
	/* Menu over status: departement menu */
	locationOver : function(event){
		var locationLI = Event.element(event).up(0);
		locationLI.setStyle({
			borderBottom: '3px solid #00407C'
		});
	},
	
	/* Menu out status: departement menu */
	locationOut : function(event){
		var locationLI = Event.element(event).up(0);
		locationLI.setStyle({
			borderBottom: 'none'
		});
	},
	
	/* Menu over status: mainmenu */
	mainOver : function(event){
		var mainLI = Event.element(event).up(0);
		mainLI.setStyle({
			backgroundColor: '#00407C'
		});
	},
	
	/* Menu out status: mainmenu */
	mainOut : function(event){
		var mainLI = Event.element(event).up(0);
		mainLI.setStyle({
			backgroundColor: 'transparent'
		});
	}
	
};

var hkSlideshow = Class.create();
Object.extend(hkSlideshow.prototype, {
  initialize: function(ident) {
    this.ident = ident;
    
    // options
    var options = Object.extend({
      appearDuration: 2,
      fadeDuration: 1,
      fadeAfter: 3
    }, arguments[1] || {});
    
    this.appearDuration = options.appearDuration;
    this.fadeDuration   = options.fadeDuration;
    this.fadeAfter      = options.fadeAfter;
  },
  start: function(){
    var self = this;
    var showFirst = arguments[0] || false; // show the first item, for loop

    var items = $$('.'+this.ident);
    items.each(function(el, index) {
      if (showFirst || index > 0)
        new Effect.Appear(el, {duration: self.appearDuration, queue: {position: 'end', scope: self.ident}});
    
      var fade = new Effect.Fade(el, {duration: self.fadeDuration, delay: self.fadeAfter, queue: {position: 'end', scope: self.ident}});
      
      if (items.length == index+1) {
        Object.extend(fade.options, {
          afterFinish: function(){
            self.start(true);
          }
        });
      }
    });
  }
});

Event.observe(window, 'load', function(){
	
	/* Bind location mouseovers */	
	var locations = $('department_menu').childElements();
	locations.each(function(li){
		if(li.hasClassName('active')){
			li.setStyle({
				borderBottom: '3px solid #00407C'
			});
		}else{
			Event.observe($(li).down(0), 'mouseover', menuHighlighting.locationOver.bindAsEventListener(menuHighlighting));
			Event.observe($(li).down(0), 'mouseout', menuHighlighting.locationOut.bindAsEventListener(menuHighlighting));
		}
	});
	
	/* Bind mainmenu mousovers */
	var mainItems = $('main_menu').childElements();
	mainItems.each(function(li){
		var isActive = false;
		$w(li.className).each(function(class_name){
			if(class_name.strip() == 'active'){
				isActive = true;
			}
		})
		if(!isActive){
			Event.observe($(li).down(0), 'mouseover', menuHighlighting.mainOver.bindAsEventListener(menuHighlighting));
			Event.observe($(li).down(0), 'mouseout', menuHighlighting.mainOut.bindAsEventListener(menuHighlighting));
		}
	});
	
	/* Firefox height fix */
	if (!Prototype.Browser.IE) {
		var containerHeight = document.viewport.getHeight();
		$('content_container').setStyle({
			minHeight: containerHeight +'px'
		});
	}
	
	/* Start slideshow */
	var slider = new hkSlideshow('bc_slideshow', {
		appearDuration: 2,
	    fadeDuration: 1,
	    fadeAfter: 3
	});
	slider.start();
});




