function initGenericNavigation(){

  $$('#nav-generic-meersites ul').addEvent('mouseover', function(){
    $$('#nav-generic-meersites ul').addClass('over');
  });

  $$('#nav-generic-meersites ul').addEvent('mouseout', function(){
    $$('#nav-generic-meersites ul').removeClass('over');
  });

}

function initFlash(){

  if ($('homepage')){
    new Swiff('http://www.okki.nl/app_okkiversum/hotspotworld_home.swf?hotspotworldXML=http://www.okki.nl/app_okkiversum/hotspotworld/thuisplaneet.xml', {
      width:  '100%',
      height: '100%',
      container: $('flash-container'),
      params: {
          wmode: 'transparent'
      }
    });
  }
/*
  if ($('okkiversum')){
    new Swiff('http://www.okki.nl/app_okkiversum/okkiversum.swf?configXML=http://www.okki.nl/app_okkiversum/okkiversum_config.xml', {
      width:  '100%',
      height: '100%',
      id:     'flashshizzle',
      container: $('flash-container'),
      params: {
          wmode: 'transparent'
      }
    });
    $('flashshizzle').focus();
  }
*/
}

//code buttons voor op de homepage
function initCodeButtons(){
  if ($('usercode')){
    $('usercode').value = '';
  }

  $$('.code li').addEvent('click', function(el){
    this.addClass('active');
    var arrayHref = this.getFirst('a').getAttribute('href').split('#');
    if (arrayHref[1] && $('usercode')){
      $('usercode').value += arrayHref[1];
    }
  });
}


function clickclear(thisfield, defaulttext) {
  if (thisfield.value == defaulttext) {
    thisfield.value = "";
  }
}

function clickrecall(thisfield, defaulttext) {
  if (thisfield.value == "") {
    thisfield.value = defaulttext;
  }
}

function scaleForIE6(){
  // If IE6: scale the Flash-container
  if (Browser.Engine.trident && (Browser.Engine.version < 5) && $('flash-container')){
    var windowSize = $(window).getSize();
    if (windowSize.x < 1600){
      $('flash-container').setStyle('width', windowSize.x);
    }else {
      $('flash-container').setStyle('width', 1600);
    }
  }
}

function scaleFlashContainer(){
  var windowSize = $(window).getSize();
  if ($('flash-container')){
    var paddingTop = $('flash-container').getStyle('padding-top');
    var flashHeight = (windowSize.y - paddingTop.toInt()) - 40;
    $('flash-container').setStyle('height', flashHeight);
  }
}

function fixBanner(){
  $$('#banner-box embed').each(function(el) {
    $(el).set('wmode','opaque');
  });
}

window.addEvent('domready', function(){
  initGenericNavigation();
  scaleFlashContainer();
  initFlash();
  initCodeButtons();
  scaleForIE6();
  fixBanner();
  SWFAddress.addEventListener(SWFAddressEvent.CHANGE, setupBannerController);
});

window.addEvent('resize', function(){
  scaleForIE6();
  scaleFlashContainer();
});


function setupBannerController(event){
	var box = $('banner-box');
	if (!box){
		return;
	}
	if(event.path == "/werelden/thuisplaneet" 
		|| event.path.indexOf("planetenbrowser") != -1){
		box.setStyle('display','block');
    }
	else {
		box.setStyle('display','none');
	}
}

