
/* Searchbox Script */

$(function()
{

$("#searchshow").click(function(event) {
event.preventDefault();
$("#searchbox").slideToggle('slow', function() {
    if(this.style.display == "block") {
        document.cookie = "searchBoxState=open;path=/";
    }else{
        document.cookie = "searchBoxState=closed;path=/";
        searchBoxClosed();
    }
});
});

$("#searchbox a.closelink").click(function(event) {
event.preventDefault();
$("#searchbox").slideUp();
document.cookie = "searchBoxState=closed;path=/";
searchBoxClosed();
});
});

function searchBoxClosed() {
    $("#searchForm").clearForm();
}

$.fn.clearForm = function() {
  return this.each(function() {
    var type = this.type, tag = this.tagName.toLowerCase();
    if (tag == 'form')
      return $(':input',this).clearForm();
    if (type == 'text' || type == 'password' || tag == 'textarea')
      this.value = '';
    else if (type == 'checkbox' || type == 'radio')
      this.checked = false;
    else if (tag == 'select')
      this.selectedIndex = -1;
  });
};


/* Fancybox config */

$(document).ready(function() {

	$("a.fancyscreen").fancybox({
		'overlayColor'	 : '#000000',
		'overlayOpacity' : 0.7,
		'transitionIn'	 :	'elastic',
		'transitionOut'	 :	'elastic',
		'speedIn'		 :	600, 
		'speedOut'		 :	200, 
		'titlePosition'	 : 'outside',
		'titleFormat'	 : function(title, currentArray, currentIndex, currentOpts) {
			return '<p class="screenshottxt"><strong>Schermafbeelding ' + (currentIndex + 1) + ' van ' + currentArray.length + '</strong>' + (title.length ? '&nbsp;:&nbsp;' + title : '') + '</p>';
		}	
	});
	
});


/* Follow Scroll */

var el = $('.follow-scroll');
var elpos_original = el.offset().top;
$(window).scroll(function(){
    var elpos = el.offset().top;
    var windowpos = $(window).scrollTop();
    var finaldestination = windowpos;
    if(windowpos<elpos_original) {
        finaldestination = elpos_original;
        el.stop().css({'top':10});
    } else {
        el.stop().animate({'top':finaldestination-elpos_original+10},500);
    }
});

