// JavaScript Document

self.moveTo(0,0);
self.resizeTo(screen.availWidth,screen.availHeight);;
jQuery(document).ready(function(){
	slideMenu('#block-menu-block-1');
});


function slideMenu(target){
	jQuery(target + ' ul li ul').css('display', 'none');
	
	
	jQuery(target + ' ul li').hover(
		
		function(){
			//mouse over
			jQuery(this).find('>ul').stop(true, true).fadeIn(200);
		},
		
		function(){
			//mouse out
			jQuery(this).find('>ul').show();
			jQuery(this).find('>ul').stop(true, true).fadeOut(500);
		}
	
	);
	
	
	//een pijl toevoegen aan de items die een child hebben
	jQuery.each(jQuery(target + ' ul li ul'), function() {
		jQuery(this)
			.append('<div />')
			.children('div')
			.addClass('popup-arrow');
		/*
 		if ( jQuery(this).children('ul')[0] ) {
 			jQuery(this)
				.append('<span />')
 				.children('span')
 				.addClass('hasChildren')
 			}
			*/
 		}
	);
};
jQuery(document).ready(function(){
	loadDisclamer('#block-menu-block-1 .menu-mlid-2165');
	loadDisclamer('#block-menu-block-1 .menu-mlid-2170');
	loadDisclamer('#block-menu-block-1 .menu-mlid-2171');
	loadDisclamer('#block-menu-block-1 .menu-mlid-2172');
	
	setHeader('#header-inner');
	
	
});


function loadDisclamer(target){
	if (jQuery(target).length != 0){
		var page = '#block-block-2';
		
		//popup in middle of page
		jQuery(page).show();
		var topMargin = (jQuery(window).height() - jQuery(page + ' .content').height())/2;
		jQuery(page).hide();
		jQuery(page + ' .content').css('margin-top', topMargin+'px');
		
		jQuery(target).hover(
			function(){
				//rollover
				jQuery(page).fadeIn(200);
			},
			function(){
				//rollout
			}
		);
		
		jQuery(page).click(
			function(){
				jQuery(page).fadeOut(500);
			}
		);
	}
}

function setHeader(target){
	var dateStart = 20;
	var dateEnd = 8;
	
	var date = new Date();
	if (date.getHours() >= dateStart || date.getHours() < dateEnd){
		jQuery(target).addClass('night');
	}
	
	jQuery(target + ' #header-hotspot').click(
		function(){
			jQuery(target).toggleClass('night');
		}
	);
};

