// JavaScript Document

$(document).ready(function () {
	var browserOK = true;
	var browserMsg = '';
	
	// Replace content if browser not compatible
	if ($.browser.msie) {
		var version = $.browser.version.split(".");
		if (version.length > 0) {
			if (Number(version[0]) < 7) {
				// browser not compatible
				browserOK = false;
				browserMsg = 'Je kan deze website best bekijken met Internet Explorer 7 of hoger'
			} else {
				// add element to close dark content
				//$('.content-dark').append('<div style="clear:both;">&nbsp;</div>');
			}
		}
	}
	
	
	if ( ! browserOK) {
		// remove all transparant png's but logo
		$('ul.main li, ul.main li a, ul.main li a:hover, ul.main li.active, ul.sub li a:hover, ul.sub li.active, .crumblepath, .content-body, .content-body-dark, h2, .tab-last, .tab-first').css('background', 'none');
		
		// correction for < IE7
		$('ul.tabs li a').css('display','inline');
		$('.content-body').css('background-color','#b0a598');
		$('.col-first').css('width', '394px');
		$('.content-dark, .content-body-dark').css('background-color', '#272421');
		$('ul.main li, ul.sub li').css('padding-top', '6px');
		
		// apply IE png transparency fix
		$(document).pngFix(); 
	
		$('<div style="position:relative; height: 30px; padding-top:10px; width:950; background-color:#2c2926; color:#fff; font-size:14pt; text-align:center">' + browserMsg + '</div>').insertBefore(".header");
		
		// Remove callouts
		if ($('.callout').size() > 0 ) $(".callout").remove();
		
	} else {
		
		// MAIN NAVIGATION
		// Make sure that the right part of the tab highlights on mouse over
		$("ul.tabs.main li").bind('mouseover', function() {
			if (! $(this).hasClass('active')) $(this).css('background-image','url(/images/tab-main-right-act.png)');
		});
		// Make sure that the right part of the tab is restored on mouse out
		$("ul.tabs.main li").bind('mouseout', function() {
			if (! $(this).hasClass('active')) $(this).css('background-image','url(/images/tab-main-right-def.png)');
		});
		
		// Highlight the right part of the tab for active tabs
		$("ul.tabs.main li.active").css('background-image','url(/images/tab-main-right-act.png)');
		
		// Put callouts on photo
		$('div.callout').callout();
	}
	
	// Format the Rounded blocks in the dark content
	//$(".rounded").wrapInner('<div class="rounded-border pcDropZone"></div>');
	/*
	if ($.browser.msie) {
		DD_roundies.addRule('.rounded-border', '6px');
		DD_roundies.addRule('.rounded', '8px');
	} else {
		$(".rounded").corner('8px');
		$(".rounded-border").corner('6px');
	}
	*/
	
	// Foto slideshow
	$(".main_foto").jqGalScroll({width:493, height:269, speed:750, ease:'easeInOutCubic', direction : 'horizontal'});
	$(".main_foto").each(function () {
		if ($("li", $(this)).size() == 1) {
			$(this).parent().next().remove();
			$("div.jqGSPagination li", $(this)).remove();
		}
	});
	
	// Meer info overlays
	$("a[rel]").overlay({
		mask: {
			maskId: 'maskOne',
			color: '#000000',
			loadSpeed: 0,
			opacity: 0.75,
			zIndex: 400
		},
		close: '#overlay-close',
		top: 40,
		fixed: false
	});
	
	$(window).scroll(function () {
		$.mask.fit();
	});
	
	// Secondary photos slideshow
	$(".scrollable").each(function (n) {
		var $target = $(this);
		if ($target.find(".item").length > 1) {
			$target.scrollable({vertical:true, circular:true, items:'.items'}).autoscroll({ autoplay:true, interval:3000 });
		}
	});
	
	// Apply Cufon to text that needs to be in Century Gothic
	Cufon.replace('ul.tabs.main li a', { fontFamily: 'Century Gothic', fontWeight: 'bold', hover:true });
	Cufon.replace('ul.tabs.sub li a', { fontFamily: 'Century Gothic', fontWeight: 'bold', hover:true });
	Cufon.replace('div.jqGSPagination li a', { fontFamily: 'Century Gothic', hover:true });
});
