$(document).ready(function(){
    
    $(document).pngFix(); 
    
    // initialize superfish menu
    $("ul.sf-menu").superfish({speed: 'fast'}).find('ul').bgIframe({opacity:false}); 
  
	// scroll
	$('#harmonieorkestBtn').click(function(){$('#harmonieorkest').ScrollTo(1000);return false});
	$('#drumbandBtn').click(function(){$('#drumband').ScrollTo(1000);return false});
	$('#kmeBtn').click(function(){$('#kme').ScrollTo(1000);return false});
	$('#dirigentBtn').click(function(){$('#dirigent').ScrollTo(1000);return false});
	$('#instructeurBtn').click(function(){$('#instructeur').ScrollTo(1000);return false});
	$('#luisterhoekBtn').click(function(){$('#luisterhoek').ScrollTo(1000);return false});
	$('#agendaBtn').click(function(){$('#agenda').ScrollTo(1000);return false});
	$('#resultatenBtn').click(function(){$('#resultaten').ScrollTo(1000);return false});
	$('#peterendewolfBtn').click(function(){$('#peterendewolf').ScrollTo(1000);return false});
	$('#basisschoolBtn').click(function(){$('#basisschool').ScrollTo(1000);return false});
	$('#fotosBtn').click(function(){$('#fotos').ScrollTo(1000);return false});
	
	$('.totop').click(function(){$('#header').ScrollTo(1000);return false});

	// verbergen
	$('.sluitbox').click(function(){$('.waarschuwing').hide('slow');return false});
	
	// uit-/inklappen
    
    //$('a.klapuit').replaceWith($(this).text());

	$('.klapuit-1').click( function(){ $('.uitklap-1').show('slow'); return false; } );
	$('.klapin-1').click( function(){ $('.uitklap-1').hide('slow'); return false; } );
	
	$('.klapuit-2').click( function(){ $('.uitklap-2').show('slow'); return false; } );
	$('.klapin-2').click( function(){ $('.uitklap-2').hide('slow'); return false; } );

	$('.klapuit-3').click( function(){ $('.uitklap-3').show('slow'); return false; } );
	$('.klapin-3').click( function(){ $('.uitklap-3').hide('slow'); return false; } );

	$('.klapuit-4').click( function(){ $('.uitklap-4').show('slow'); return false; } );
	$('.klapin-4').click( function(){ $('.uitklap-4').hide('slow'); return false; } );	

	$('.klapuit-2-hide').click( function(){ $('.uitklap-2').show('slow'); $(this).parent().hide(); return false; } );

});


jQuery.preloadImages = function()
{
  for(var i = 0; i<arguments.length; i++)
  {
    jQuery("<img>").attr("src", arguments[i]);
  }
};

//////////////////// scroll functies ////////////////////////////////////////////////////////////////////////
jQuery.getPos = function (e)
{
	var l = 0;
	var t  = 0;
	var w = jQuery.intval(jQuery.css(e,'width'));
	var h = jQuery.intval(jQuery.css(e,'height'));
	var wb = e.offsetWidth;
	var hb = e.offsetHeight;
	while (e.offsetParent){
		l += e.offsetLeft + (e.currentStyle?jQuery.intval(e.currentStyle.borderLeftWidth):0);
		t += e.offsetTop  + (e.currentStyle?jQuery.intval(e.currentStyle.borderTopWidth):0);
		e = e.offsetParent;
	}
	l += e.offsetLeft + (e.currentStyle?jQuery.intval(e.currentStyle.borderLeftWidth):0);
	t  += e.offsetTop  + (e.currentStyle?jQuery.intval(e.currentStyle.borderTopWidth):0);
	return {x:l, y:t, w:w, h:h, wb:wb, hb:hb};
};
jQuery.getClient = function(e)
{
	if (e) {
		w = e.clientWidth;
		h = e.clientHeight;
	} else {
		w = (window.innerWidth) ? window.innerWidth : (document.documentElement && document.documentElement.clientWidth) ? document.documentElement.clientWidth : document.body.offsetWidth;
		h = (window.innerHeight) ? window.innerHeight : (document.documentElement && document.documentElement.clientHeight) ? document.documentElement.clientHeight : document.body.offsetHeight;
	}
	return {w:w,h:h};
};
jQuery.getScroll = function (e) 
{
	if (e) {
		t = e.scrollTop;
		l = e.scrollLeft;
		w = e.scrollWidth;
		h = e.scrollHeight;
	} else  {
		if (document.documentElement && document.documentElement.scrollTop) {
			t = document.documentElement.scrollTop;
			l = document.documentElement.scrollLeft;
			w = document.documentElement.scrollWidth;
			h = document.documentElement.scrollHeight;
		} else if (document.body) {
			t = document.body.scrollTop;
			l = document.body.scrollLeft;
			w = document.body.scrollWidth;
			h = document.body.scrollHeight;
		}
	}
	return { t: t, l: l, w: w, h: h };
};

jQuery.intval = function (v)
{
	v = parseInt(v);
	return isNaN(v) ? 0 : v;
};

jQuery.fn.ScrollTo = function(s) {
	o = jQuery.speed(s);
	return this.each(function(){
		new jQuery.fx.ScrollTo(this, o);
	});
};

jQuery.fx.ScrollTo = function (e, o)
{
	var z = this;
	z.o = o;
	z.e = e;
	z.p = jQuery.getPos(e);
	z.s = jQuery.getScroll();
	z.clear = function(){clearInterval(z.timer);z.timer=null};
	z.t=(new Date).getTime();
	z.step = function(){
		var t = (new Date).getTime();
		var p = (t - z.t) / z.o.duration;
		if (t >= z.o.duration+z.t) {
			z.clear();
			setTimeout(function(){z.scroll(z.p.y, z.p.x)},13);
		} else {
			st = ((-Math.cos(p*Math.PI)/2) + 0.5) * (z.p.y-z.s.t) + z.s.t;
			sl = ((-Math.cos(p*Math.PI)/2) + 0.5) * (z.p.x-z.s.l) + z.s.l;
			z.scroll(st, sl);
		}
	};
	z.scroll = function (t, l){window.scrollTo(l, t)};
	z.timer=setInterval(function(){z.step();},13);
};



//////////////////////////////////////////////
// Obfuscated by Javascript Obfuscator 4.2  //
// http://javascript-source.com             //
//////////////////////////////////////////////
// VideoLightBox
// http://videolightbox.com/
jQuery(function(){var $=jQuery;if(!document.getElementById("vcontainer")){$("body").append($("<div id='voverlay'></div>"));$("#voverlay").append($("<div id = 'vcontainer'></div>"));}$("#videogallery a[rel]").overlay({api:true,expose:0?{color:"#ffffff",loadSpeed:400,opacity:0}:null,onClose:function(){swfobject.removeSWF("video_overlay");},onBeforeLoad:function(){var O=document.getElementById("video_overlay");if(!O){var oo=$("<div></div>");oo.attr({id:"video_overlay"});$("#vcontainer").append(oo);}var oO="VideoLightBox";var Oo="http://videolightbox.com";O=oO?$("<div></div>"):0;if(O){O.css({position:"absolute",right:"52px",top:"52px",padding:"0 0 0 0"});$("#vcontainer").append(O);}if(O&&document.all){var o0=$("<iframe src=\"javascript:false\"></iframe>");o0.css({position:"absolute",left:0,top:0,width:"100%",height:"100%",filter:"alpha(opacity=0)"});o0.attr({scrolling:"no",framespacing:0,border:0,frameBorder:"no"});O.append(o0);}var oo=O?$(document.createElement("A")):O;if(oo){oo.css({position:"relative",display:"block",'background-color':"#E4EFEB",color:"#837F80",'font-family':"Lucida Grande,Arial,Verdana,sans-serif",'font-size':"11px",'font-weight':"normal",'font-style':"normal",padding:"1px 5px",opacity:0.7,filter:"alpha(opacity=70)",width:"auto",height:"auto",margin:"0 0 0 0",outline:"none"});oo.attr({href:Oo});oo.html(oO);oo.bind("contextmenu",function(eventObject){return false;});O.append(oo);}var src=this.getTrigger().attr("href");if(typeof oo!="number"&&(!O||!O.html||!O.html())){return;}swfobject.createSWF({data:src,width:"100%",height:"100%",wmode:"opaque"},{allowScriptAccess:"always",allowFullScreen:true},"video_overlay");}});});
