/**
 * Base class, extended by specialised JS objects that may or may not be included
 * 
 * Namespace "Base"
 * @class Base
 * @desc Base class of this project
 */
var Base = function() {
	// VARIABLES DEFINED HERE ARE PRIVATE
	var arr_init = []; // Array containing all registered init-functions of subclasses
	var subnavInterval;
	function navigation() {
		// hoofdnav met sub niet klikbaar
		$('#nav a.gotsubs').bind('click', function(e){
			e.preventDefault();
			$(this).blur();
		});
		
		$('#nav li').bind('mouseenter', function() {
			removeSubNav();
			if ($(this).find('ul').length > 0) {
				var nav_pos = $(this).position();
				$('<div id="subnav"><ul>' + $(this).find('>ul').html() + '</ul></div>').css({left:nav_pos.left+26}).appendTo('#page');
				
				$('#subnav').bind('mouseenter', function(){
					clearInterval(subnavInterval);
				}).bind('mouseleave', function(e){
					subnavInterval = setInterval(removeSubNav, 250);
				})
			}
		}).bind('mouseleave', function() {
			$('#subnav').trigger('mouseleave');
		});
	}
	
	function removeSubNav() {
		clearInterval(subnavInterval);
		$('#subnav').unbind('mouseout').remove();
	}
	
	function openNewBrowser() {
		$('a.blank').live('click',function(){
			window.open($(this).attr('href'));
			return false;
		});
	}
	
	
	function banners() {
		//swfobject.embedSWF("static/swf/banner.swf", "banner1", "202", "350", "9.0.0", "static/swf/expressInstall.swf", {}, {wmode:'transparent'});	
		/*$('#banner1').flash({
			swf: 'static/swf/banner.swf',
			height: 350,
			width: 202,
			wmode: 'transparent',
			hasVersion: 9,
			hasVersionFail: function (options) {	
				return false;
			}

		});*/
		
		$('#slides').cycle({ 
			delay: 2000, 
			speed: 500,
			pause: 1,
			random:1
		}); 

	}
	
	
	// FUNCTIONS DEFINED HERE ARE PRIVATE
	
	/**
	 * Check and execute registered subclass functions
	 */
	function check_register() {
		for (var i=0; i<arr_init.length; i++) {
			arr_init[i]();
		}
	}
	
	function copyright() {
		var alpha = .5;
		$('.ibt a').attr('title', $('.ibt a').text()).css({opacity:alpha}).bind('mouseover',function(){
			$(this).css({opacity:1});									  
		}).bind('mouseout',function(){
			$(this).css({opacity:alpha});									  
		});
	}
	
	return { // Public area
		// VARIABLES DEFINED HERE ARE PUBLIC
		ie6	: ($.browser.msie && ( parseInt($.browser.version)==6 ) ) ? true : false,
		
		// FUNCTIONS DEFINED HERE ARE PUBLIC
		
		/**
		* Register (initialization) calls from subclasses
		* @param (obj_function) Function to initialize subclass
		*/
		register: function(obj_function) {
			arr_init.push(obj_function);
		},
		
		
		/**
		* Initialize this class
		*/
		init: function() {
			check_register();
			banners();
			navigation();
			openNewBrowser();
			copyright();
		}
	}
}();

$(document).ready(function(){
	Base.init();
});
