// JavaScript Document

$(document).ready(function() {

	/* VALUE IN FORM TEXT FIELD */
	$('.default-value').each(function() {
    var default_value = this.value;
    $(this).css('color', '#999'); 
    $(this).focus(function() {
        if(this.value == default_value) {
            this.value = '';
            $(this).css('color', '#333');
        }
    });
    $(this).blur(function() {
        if(this.value == '') {
            $(this).css('color', '#999');
            this.value = default_value;
        }
    });
});
	
	/* FANCYBOX POPUP */
	$("a.inline").fancybox({
	'width'	: 740, 
	'height': 'auto' 
	});
	
	/* TABS */
	jQuery(".tab_content").hide(); //Hide all content
	jQuery("ul.tabs li:first").addClass("active").show(); //Activate first tab
	jQuery(".tab_content:first").show(); //Show first tab content
	
	//On Click Event
	jQuery("ul.tabs li a").click(function(e) {
		e.preventDefault();
		e.stopPropagation();
		jQuery("ul.tabs li").removeClass("active"); //Remove any "active" class
		jQuery(this).parents('li').addClass("active"); //Add "active" class to selected tab
		jQuery(".tab_content").hide(); //Hide all tab content
		var activeTab = jQuery(this).attr("href"); //Find the rel attribute value to identify the active tab + content
		jQuery(activeTab).fadeIn(); //Fade in the active content
		return false;
	});
	
	/* Make DIV CLICKABLE */
	 $(".thema").click(function(){
    	window.location=$(this).find("a").attr("href");return false;
	});
	
	/* Initiate TOGGLER ACCORDION*/
	jQuery(".toggler").toggler();
	
    /* TOGGLE MORE-CONTENT */
	jQuery('.toggle').hide().prev().after('<p><a class="open-link" href="javascript:;">Lees meer<\/a><\/p>');
				
	jQuery('.open-link').parent().next().each(function() {
		jQuery(this).append('<a class="close-link" href="javascript:;">Sluiten</a>');
	});
				
	jQuery('.close-link').click(function() {
		jQuery(this).parent().slideToggle('slow').prev().slideToggle('slow');
	});
			
	jQuery('.open-link').click(function() {
		jQuery(this).parent().slideToggle('slow').next().slideToggle('slow');
	});

});


/* PLUGINS */

(function($)
{	

	/* TOGGLER - ACCORDION */
	$.fn.toggler = function(options) {
  
    var defaults = {
      content: '.toggle-content'
    };
    
    var options = $.extend(defaults, options);
    
    var heading = $(this);
    var content = $(options.content);
    
    // Hide Toggle Content
    content.hide();
    
    return this.each(function() {
      // Activate is class "active" is given
      if($(this).is(".active")) {
        if($(this).next(content)) {
          $(this).next(content).show();
        }
      }
      
      $(this).bind('click', function() {
        if($(this).is(".active")) {
          if($(this).next(content)) {
            $(this).removeClass("active").next(content).slideUp();
          }
        }
        else {
          if($(this).is(".close-all")) {
            heading.removeClass("active");
            content.slideUp();
          }
          
          if($(this).next(content)) {
            $(this).addClass("active").next(content).slideDown();
          }
        }
      });
    });
  };


})(jQuery);


/* SMOOTH SCROLL */
/*--------------------------------------------------------------------------
 *  Smooth Scroller Script, version 1.0.1
 *  (c) 2007 Dezinerfolio Inc. <midart@gmail.com>
 *
 *  For details, please check the website : http://dezinerfolio.com/
 *
/*--------------------------------------------------------------------------*/
(function(){
Scroller = {
	// control the speed of the scroller.
	// dont change it here directly, please use Scroller.speed=50;
	speed:10,

	// returns the Y position of the div
	gy: function (d) {
		gy = d.offsetTop
		if (d.offsetParent) while (d = d.offsetParent) gy += d.offsetTop
		return gy
	},

	// returns the current scroll position
	scrollTop: function (){
		body=document.body
	    d=document.documentElement
	    if (body && body.scrollTop) return body.scrollTop
	    if (d && d.scrollTop) return d.scrollTop
	    if (window.pageYOffset) return window.pageYOffset
	    return 0
	},

	// attach an event for an element
	// (element, type, function)
	add: function(event, body, d) {
	    if (event.addEventListener) return event.addEventListener(body, d,false)
	    if (event.attachEvent) return event.attachEvent('on'+body, d)
	},

	// kill an event of an element
	end: function(e){
		if (window.event) {
			window.event.cancelBubble = true
			window.event.returnValue = false
      		return;
    	}
	    if (e.preventDefault && e.stopPropagation) {
	      e.preventDefault()
	      e.stopPropagation()
	    }
	},

	// move the scroll bar to the particular div.
	scroll: function(d){
		i = window.innerHeight || document.documentElement.clientHeight;
		h=document.body.scrollHeight;
		a = Scroller.scrollTop()
		if(d>a)
			if(h-d>i)
				a+=Math.ceil((d-a)/Scroller.speed)
			else
				a+=Math.ceil((d-a-(h-d))/Scroller.speed)
		else
			a = a+(d-a)/Scroller.speed;
		window.scrollTo(0,a)
	  	if(a==d || Scroller.offsetTop==a)clearInterval(Scroller.interval)
	  	Scroller.offsetTop=a
	},
	// initializer that adds the renderer to the onload function of the window
	init: function(){
		Scroller.add(window,'load', Scroller.render)
	},

	// this method extracts all the anchors and validates then as # and attaches the events.
	render: function(){
		a = document.getElementsByTagName('a');
		Scroller.end(this);
	    for (i=0;i<a.length;i++) {
	      l = a[i];
	      if(l.href && l.href.substring(l.href.length-1, l.href.length)!='#' && l.href.indexOf('#') != -1 && ((l.pathname==location.pathname) || ('/'+l.pathname==location.pathname)) ){
				l.onclickByPass = l.onclick;
	      		l.onclick = function(e){
	      			Scroller.end(this);
		        	l=this.hash.substr(1);
		        	 a = document.getElementsByTagName('a');
				     for (i=0;i<a.length;i++) {
				     	if(a[i].name == l){
				     		clearInterval(Scroller.interval);
				     		Scroller.interval=setInterval('Scroller.scroll('+Scroller.gy(a[i])+')',10);
						}
					}
					if (this.onclickByPass)
					{
						this.onclickByPass(e);
					}
					return false;
				}
	      	}
		}
	}
}
// invoke the initializer of the scroller
Scroller.init();
})();

/*------------------------------------------------------------
 *						END OF CODE
/*-----------------------------------------------------------*/
