$(document).ready(function() {

	//-start correctBackgroundPosition	
	if ($.browser.msie) {	
		correctBackgroundPosition();		
		$(window).resize(function(){
			correctBackgroundPosition();
		});
	}
	
	initSifr();
	
	//-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) {		
		$('#menu .main_menu_box').css('margin-left', '0px')
	} else {		
		$('#menu .main_menu_box').css('margin-left', '0px')		
	}
}


function initSifr() {
    if (typeof(sIFR) == 'function') {
        sIFR.replaceElement(".content h1", named({sFlashSrc: "/swf/fonts/sauna-bold.swf",sColor: "#666666",sWmode: 'transparent'}));
        sIFR.replaceElement("#visual .title", named({sFlashSrc: "/swf/fonts/sauna-bold.swf",sColor: "#666666",sWmode: 'transparent'}));
        sIFR.replaceElement(".main_side h3", named({sFlashSrc: "/swf/fonts/sauna-roman.swf",sColor: "#666666",sWmode: 'transparent'}));
        sIFR.replaceElement(".visual_side .inner h3", named({sFlashSrc: "/swf/fonts/sauna-roman.swf",sColor: "#ffffff",sWmode: 'transparent'}));
        sIFR.replaceElement(".content h4", named({sFlashSrc: "/swf/fonts/sauna-roman.swf",sColor: "#F46E00",sWmode: 'transparent'}));
        sIFR.replaceElement(".visual_side h3", named({sFlashSrc: "/swf/fonts/sauna-roman.swf",sColor: "#ffffff",sWmode: 'transparent'}));
    }	
}

//overall flir
function initFlir() {
	if (typeof(FLIR)!='undefined') {
		FLIR.init( { path: '/js/lib/facelift-1.2/' } );

		/*
			Beschikbare fonts:
			
			sauna-italic
			sauna-bold
			sauna-bolditalic
			sauna-roman
		
		*/

		$('.content h1').each(function() {
			FLIR.replace(this, new FLIRStyle({ cFont: 'sauna-bold', mode: 'wrap'}));
		});
		$('.main_side h3').each(function() {
			FLIR.replace(this, new FLIRStyle({ cFont: 'sauna-italic', mode: 'wrap'}));
		});
		$('.visual_side .inner h3').each(function() {
			FLIR.replace(this, new FLIRStyle({ cFont: 'sauna-italic', mode: 'wrap'}));
		});
		$('.content h4').each(function() {
			FLIR.replace(this, new FLIRStyle({ cFont: 'sauna-italic-swash', mode: 'wrap'}));
		});
		
		$('#visual .title').each(function() {
			FLIR.replace(this, new FLIRStyle({ cFont: 'sauna-bold', mode: 'wrap'}));
		});
		
		$('.visual_side h3').each(function() {
			FLIR.replace(this, new FLIRStyle({ cFont: 'sauna-italic-swash', 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
 	}); 
*/
}

