

	$(document).ready(function(){
	
		if(isiPad())
		{
			
			$("div.content").css(
				{
					'overflow' 	: 'auto',
					'width' 	: '484px'
				}
			);
			$("div.scrollbar").hide();

			$("div.nieuws_content").css(
				{
					'overflow' 	: 'auto',
					'width' 	: '834px'
				}
			);
			$("div.scrollbar").hide();

			$("div.nieuws_scrollblok").css(
				{
					'overflow' 	: 'auto',
					'width' 	: '203px'
				}
			);
			$("div.nieuws_scrollbar").hide();
			
			$("div.views_scrollblok").css(
				{
					'overflow' 	: 'auto',
					'width' 	: '203px'
				}
			);
			$("div.views_scrollbar").hide();

			$("div.media_scrollblok").css(
				{
					'overflow' 	: 'auto',
					'width' 	: '203px'
				}
			);
			$("div.media_scrollbar").hide();


		}

		// FANCYBOX
		
		if($("a.readmore").length>0){
			
			$("a.readmore, .popup_link, .contact a, a.videolink").fancybox({
				'padding'		: 0,
				'overlayOpacity': 0.3,
				'overlayColor'  : '#000',
				'width'         : 900,
				'height'        : 510,
				'autoScale'     : false,
				'centerOnScroll': true,
				'transitionIn'	: 'elastic',
				'transitionOut'	: 'elastic',
				'scrolling' 	: 'no',
				'onComplete'    : function(){
					if($.browser.msie && $.browser.version.substr(0,1)<7){
						DD_belatedPNG.fix("#fancybox-content");
					}
				}
			});
		}
					
		if($(".scroller").length>0){
		$(".scroller").draggable({ 
			axis: "y", 
			containment: "parent",
			drag: function(event, ui) { 
				var position = $(".scroller").position();
				var sbh = $(".scrollbar").height();
				var eh = $(".scrollpanel").height();
				var sh = $(".scroller").height();
				if(eh>430)
					$(".scrollpanel").css({top: -(position.top/sbh) * (eh-sbh+sh)});
				
			}
		});
		}
		if($(".nieuws_scroller").length>0){
		$(".nieuws_scroller").draggable({ 
			axis: "y", 
			containment: "parent",
			drag: function(event, ui) { 
				var position = $(".nieuws_scroller").position();
				var sbh = $(".nieuws_scrollbar").height();
				var eh = $(".nieuws_scrollpanel").height();
				var sh = $(".nieuws_scroller").height();
				if(eh>200)
					$(".nieuws_scrollpanel").css({top: -(position.top/sbh) * (eh-sbh+sh)});
				
			}
		});
		}
		
		if($(".views_scroller").length>0){
		$(".views_scroller").draggable({ 
			axis: "y", 
			containment: "parent",
			drag: function(event, ui) { 
				var position = $(".views_scroller").position();
				var sbh = $(".views_scrollbar").height();
				var eh = $(".views_scrollpanel").height();
				var sh = $(".views_scroller").height();
				if(eh>200)
					$(".views_scrollpanel").css({top: -(position.top/sbh) * (eh-sbh+sh)});
				
			}
		});
		}

		if($(".media_scroller").length>0){
		$(".media_scroller").draggable({ 
			axis: "y", 
			containment: "parent",
			drag: function(event, ui) { 
				var position = $(".media_scroller").position();
				var sbh = $(".media_scrollbar").height();
				var eh = $(".media_scrollpanel").height();
				var sh = $(".media_scroller").height();
				if(eh>200)
					$(".media_scrollpanel").css({top: -(position.top/sbh) * (eh-sbh+sh)});
				
			}
		});
		}
				
		if($(".iframe").length>0){
		$(".iframe").mousewheel(function(event, delta) {
				
			var position = $(".scroller").position();
			var sbh = $(".scrollbar").height();
			var eh = $(".scrollpanel").height();
			var sh = $(".scroller").height();
			
			if(position)
				var scrollTo = Math.max(0 , Math.min(position.top + (-delta * 50) , sbh-sh));
			else
				var scrollTo = Math.max(0 , Math.min(0 + (-delta * 50) , sbh-sh));
			
			if(eh>430){
				$(".scroller").css({top: scrollTo});
				$(".scrollpanel").css({top: -(scrollTo/sbh) * (eh-sbh+sh)});
			}
			 
		});
		}


		if($(".nieuws_scrollblok").length>0){
		$(".nieuws_scrollblok").mousewheel(function(event, delta) {
				
			var position = $(".nieuws_scroller").position();
			var sbh = $(".nieuws_scrollbar").height();
			var eh = $(".nieuws_scrollpanel").height();
			var sh = $(".nieuws_scroller").height();
			
			if(position)
				var scrollTo = Math.max(0 , Math.min(position.top + (-delta * 50) , sbh-sh));
			else
				var scrollTo = Math.max(0 , Math.min(0 + (-delta * 50) , sbh-sh));
			
			if(eh>200){
				$(".nieuws_scroller").css({top: scrollTo});
				$(".nieuws_scrollpanel").css({top: -(scrollTo/sbh) * (eh-sbh+sh)});
			}
			 
		});
		}

		if($(".views_scrollblok").length>0){
		$(".views_scrollblok").mousewheel(function(event, delta) {
				
			var position = $(".views_scroller").position();
			var sbh = $(".views_scrollbar").height();
			var eh = $(".views_scrollpanel").height();
			var sh = $(".views_scroller").height();
			
			if(position)
				var scrollTo = Math.max(0 , Math.min(position.top + (-delta * 50) , sbh-sh));
			else
				var scrollTo = Math.max(0 , Math.min(0 + (-delta * 50) , sbh-sh));
			
			if(eh>200){
				$(".views_scroller").css({top: scrollTo});
				$(".views_scrollpanel").css({top: -(scrollTo/sbh) * (eh-sbh+sh)});
			}
			 
		});
		}

		if($(".media_scrollblok").length>0){
		$(".media_scrollblok").mousewheel(function(event, delta) {
				
			var position = $(".media_scroller").position();
			var sbh = $(".media_scrollbar").height();
			var eh = $(".media_scrollpanel").height();
			var sh = $(".media_scroller").height();
			
			if(position)
				var scrollTo = Math.max(0 , Math.min(position.top + (-delta * 50) , sbh-sh));
			else
				var scrollTo = Math.max(0 , Math.min(0 + (-delta * 50) , sbh-sh));
			
			if(eh>200){
				$(".media_scroller").css({top: scrollTo});
				$(".media_scrollpanel").css({top: -(scrollTo/sbh) * (eh-sbh+sh)});
			}
			 
		});
		}
						
		$(window).resize(resize);
		
		resize();
		
	});
		
	function isiPad(){
		return (navigator.platform.indexOf("iPad") != -1);
	}
	
	function resize(){
	
		var mTop = (($(window).height()-$("#container").height())/2)-($("#footer").height()/2);
	
		if($(window).height()>720+$("#footer").height()) $("#container").css({marginTop: mTop+"px"});
		
	}
	
	// GOOGLE ANALYTICS
	
	var _gaq = _gaq || [];
	_gaq.push(['_setAccount', 'UA-24345133-1']);
	_gaq.push(['_trackPageview']);

	(function() {
		var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
		ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
		var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
	})();
