// jCarouselLite
(function($){$.fn.jCarouselLite=function(o){o=$.extend({btnPrev:null,btnNext:null,btnGo:null,mouseWheel:false,auto:null,speed:200,easing:null,vertical:false,circular:true,visible:3,start:0,scroll:1,beforeStart:null,afterEnd:null},o||{});return this.each(function(){var b=false,animCss=o.vertical?"top":"left",sizeCss=o.vertical?"height":"width";var c=$(this),ul=$("ul",c),tLi=$("li",ul),tl=tLi.size(),v=o.visible;if(o.circular){ul.prepend(tLi.slice(tl-v-1+1).clone()).append(tLi.slice(0,v).clone());o.start+=v}var f=$("li",ul),itemLength=f.size(),curr=o.start;c.css("visibility","visible");f.css({overflow:"hidden",float:o.vertical?"none":"left"});ul.css({margin:"0",padding:"0",position:"relative","list-style-type":"none","z-index":"1"});c.css({overflow:"hidden",position:"relative","z-index":"2",left:"0px"});var g=o.vertical?height(f):width(f);var h=g*itemLength;var j=g*v;f.css({width:f.width(),height:f.height()});ul.css(sizeCss,h+"px").css(animCss,-(curr*g));c.css(sizeCss,j+"px");if(o.btnPrev)$(o.btnPrev).click(function(){return go(curr-o.scroll)});if(o.btnNext)$(o.btnNext).click(function(){return go(curr+o.scroll)});if(o.btnGo)$.each(o.btnGo,function(i,a){$(a).click(function(){return go(o.circular?o.visible+i:i)})});if(o.mouseWheel&&c.mousewheel)c.mousewheel(function(e,d){return d>0?go(curr-o.scroll):go(curr+o.scroll)});if(o.auto)setInterval(function(){go(curr+o.scroll)},o.auto+o.speed);function vis(){return f.slice(curr).slice(0,v)};function go(a){if(!b){if(o.beforeStart)o.beforeStart.call(this,vis());if(o.circular){if(a<=o.start-v-1){ul.css(animCss,-((itemLength-(v*2))*g)+"px");curr=a==o.start-v-1?itemLength-(v*2)-1:itemLength-(v*2)-o.scroll}else if(a>=itemLength-v+1){ul.css(animCss,-((v)*g)+"px");curr=a==itemLength-v+1?v+1:v+o.scroll}else curr=a}else{if(a<0||a>itemLength-v)return;else curr=a}b=true;ul.animate(animCss=="left"?{left:-(curr*g)}:{top:-(curr*g)},o.speed,o.easing,function(){if(o.afterEnd)o.afterEnd.call(this,vis());b=false});if(!o.circular){$(o.btnPrev+","+o.btnNext).removeClass("disabled");$((curr-o.scroll<0&&o.btnPrev)||(curr+o.scroll>itemLength-v&&o.btnNext)||[]).addClass("disabled")}}return false}})};function css(a,b){return parseInt($.css(a[0],b))||0};function width(a){return a[0].offsetWidth+css(a,'marginLeft')+css(a,'marginRight')};function height(a){return a[0].offsetHeight+css(a,'marginTop')+css(a,'marginBottom')}})(jQuery);

// slider
$(function() {
	// Adds a class to the html code so we can target browsers without JS.
	$('html').addClass('JS');
	// Sets the slides width on page load
	var i = $(window).width();
	if (i > 959){ $('#items > div').css({ width: i }); }
			
	// Scrollable and navigator plugin settings.
	// $("#slider").scrollable({ easing: 'easeInOutElastic', speed: 4800, circular: true }).navigator({ navi: '#navigation' }).autoscroll({ autoplay: true, autopause: false, interval: 4800 });
	$("#slider").scrollable({ easing: 'easeInOutElastic', speed: 4800, circular: true }).navigator({ navi: '#navigation' }).autoscroll({ autoplay: true, autopause: true, interval: 10000 });
			
	// Window resize code
	window.api = $("#slider").data("scrollable");
	$(window).resize(function() {
		var a = 1 + window.api.getIndex();
		var w = $(window).width();
		if (w > 959) {
			var l = a * w
				$('#items').css({ left: + - +l });
				$('#items > div').css({ width: w });
					} else {
				$('#items > div').css({ width: 960 });
		}
	});
});
		
// menu item animatie	
$(document).ready(function(){  
	$(".menu_item").hover(function() {
	$(this).switchClass( "menu_item", "menu_item_hover", 1000 );
	$(this).switchClass( "menu_item_hover", "menu_item", 1000 );
	return false;	
});
$("#column2 ul li img").hover(function(){
	$(this).effect( "shake", 
	{times:1,distance:2}, 100 );
	}, function() {
        $(this).stop();
    });
});
	
// fancybox	
$(document).ready(function() {
	jQuery('p a:has(img)').addClass('fancybox').attr('rel','alternate');
	jQuery('.gallery-icon a').addClass('fancybox').attr('rel','alternate');
	$("a.fancybox").fancybox({
	'titleShow'	    : false,
	'autoScale'     : true
	});
});

// cufon footer
$(document).ready(function() {
	jQuery('#menu-footermenu li a').addClass('titel');
	jQuery('.sub-menu li a').removeClass('titel');
});

// de slider
$(document).ready(function() {
$('.referenties').jwSlider({
	transition : 'fade',
	speed : 3000,
	pause : 6000
});});

// slider code
(function($){$.fn.jwSlider=function(b){var c={speed:1000,pause:2000,transition:'fade'},b=$.extend(c,b);if(b.pause<=b.speed)b.pause=b.speed+100;return this.each(function(){var a=$(this);a.wrap('<div class="slider-wrap" />');a.css({'width':'99999px','position':'relative','padding':0});if(b.transition==='slide'){a.children().css({'float':'left','list-style':'none'});$('.slider-wrap').css({'width':a.children().width(),'overflow':'hidden'})}if(b.transition==='fade'){a.children().css({'width':a.children().width(),'position':'absolute','left':0});for(var i=a.children().length,y=0;i>0;i--,y++){a.children().eq(y).css('zIndex',i+999)}fade()}if(b.transition==='slide')slide();function slide(){setInterval(function(){a.animate({'left':'-'+a.parent().width()},b.speed,function(){a.css('left',0).children(':first').appendTo(a)})},b.pause)}function fade(){setInterval(function(){a.children(':first').animate({'opacity':0},b.speed,function(){a.children(':first').css('opacity',1).css('zIndex',a.children(':last').css('zIndex')-1).appendTo(a)})},b.pause)}})}})(jQuery);

// tabs
// $(document).ready(function() {
	// $(".post").hide(); //Hide all content
	// $("ul#submenu li:first").addClass("active").show(); //Activate first tab
	// $(".post:first").show(); //Show first tab content

	//$("ul#submenu li").mouseover(function() {
		//$("ul#submenu li").removeClass("active"); //Remove any "active" class
		//$(this).addClass("active"); //Add "active" class to selected tab
		//$(".post").hide(); //Hide all tab content
		//var activeTab = $(this).find("a").attr("href"); //Find the rel attribute value to identify the active tab + content
		//$(activeTab).fadeIn(100,""); //Fade in the active content
		//return false;
	//});
//});

// Tabs methode met click en verwijzing naar 'echte' URL 
$("#submenu li a").click(function() {
	$('.active').removeClass('active');
	$('.post').fadeOut(100);
	$('#submenu li').removeClass('active');
	$(this.parentNode).addClass('active');
	var myUrl = $(this).attr("href") + " .post";
	$(".post").load(myUrl, function() { 
		$('.post').fadeIn(100); 
		$(window).contactformajax();
		$(window).contactformajax2(); 
	});
	return false;
});

// Tabs methode met click en verwijzing naar 'echte' URL 
$("#submenu_2 li a").click(function() {
	$('.active').removeClass('active');
	$('.post').fadeOut(100);
	$('#submenu_2 li').removeClass('active');
	$(this.parentNode).addClass('active');
	var myUrl = $(this).attr("href") + " .post";
	$(".post").load(myUrl, function() { 
		$('.post').fadeIn(100); 
		$(window).contactformajax();
		$(window).contactformajax2(); 
	});
	return false;
});

//jCarousel 
$("#galerij").jCarouselLite({
	btnNext: ".next",
	btnPrev: ".prev",
	visible: 3
});

//zoekbox
$(document).ready(function(){
	$(".zoek_actief").click(function(){
		$(".zoekbox").slideToggle("medium");
		$(this).toggleClass("active"); return false;
	});
}); 
