$(document).ready(function() {

	//start correctBackgroundPosition
	if ($.browser.mozilla || $.browser.safari) {	
		correctBackgroundPosition();		
		$(window).resize(function(){
			correctBackgroundPosition();
		});
	}
	
	//start flir
	initFlir();
	//start attachButtonHandling
	attachButtonHandling();
	//start mainMenuHover
	mainMenuHover();


	//validate form
	$("#commentForm").validate({
	  
	});
	


/*
	$('h2.logo').click(function() {
		document.location.href='/';
	});
*/	
	
	
	//$('.persoonlijkeverhalen, .veelgesteldevragen').css('opacity', 0.2); 
	
});  //end ready stuff





//background correction for half pixels
function correctBackgroundPosition(){
	var document_width = $(document).width();
	
	if (document_width % 2 != 0) {
		$('#wrapper').css('width', '981px')
	} else {
		$('#wrapper').css('width', '980px')
	}
}


//overall flir
function initFlir() {
	if (typeof(FLIR)!='undefined') {
		FLIR.init( { path: '/js/lib/facelift-2.0b3-B/' } );

		/*
			Beschikbare fonts:
			
			sauna-italic
			sauna-bold
			sauna-bolditalic
			sauna-roman
		
		*/

		$('.content h1').each(function() {
			FLIR.replace(this, new FLIRStyle({ cFont: 'saunabold', mode: 'wrap'}));
		});
		$('.main_side h3').each(function() {
			FLIR.replace(this, new FLIRStyle({ cFont: 'saunaitalic', mode: 'wrap'}));
		});
		$('.visual_side .inner h3').each(function() {
			FLIR.replace(this, new FLIRStyle({ cFont: 'saunaitalic', mode: 'wrap'}));
		});
		$('.content h4').each(function() {
			FLIR.replace(this, new FLIRStyle({ cFont: 'saunaitalicswash', mode: 'wrap'}));
		});
		
		$('#visual .title').each(function() {
			FLIR.replace(this, new FLIRStyle({ cFont: 'saunabold', mode: 'wrap'}));
		});
		
		$('.visual_side h3 a').each(function() {
			FLIR.replace(this, new FLIRStyle({ cFont: 'saunaitalicswash', mode: 'wrap'}));
		});
	}
}

//side bar buttons
function attachButtonHandling() {
	
	$('.visual_side li').hover(function() {
		$(this).css('cursor','pointer');
		$(this).find('a').css('text-decoration','underline');
		$(this).fadeTo(100, 0.85);
	}, function() {
		$(this).find('a').css('text-decoration','none');
		$(this).fadeTo(100, 1);
	});
	
	$('.visual_side li').hover(function() {
		$(this).css('cursor','pointer');		
	});
	$('.visual_side li').click(function() {
		document.location.href = $(this).find('a').attr('href');
	});	
}

/*
 * main menu - Submenu handling
 */
function mainMenuHover(){

 	$('ul.main_menu li.level1').hover(function() {		
		$(this).addClass('hover');
 	});
 	$('ul.main_menu li.level1').mouseleave(function() {
		$(this).removeClass('hover'); // Hide all answers
 	}); 

	$('ul.main_menu li.level1 ul li.level2').hover(function() {
		$(this).addClass('hover');
 	});
 	$('ul.main_menu li.level1 ul li.level2').mouseleave(function() {
		$(this).removeClass('hover'); // Hide all answers
 	}); 

/*
 	$('.main_menu ul li ul').hover(function() {
		$(this).parent().addClass('hover');
 	});
 	$('.main_menu ul li ul').mouseleave(function() {
		$(this).parent().removeClass('hover'); // Hide all answers
 	}); 
*/
}

