// resize functie (deel code van supersized.js)
	$.fn.resizenow = function() {
		return this.each(function() {
			var imgH = $(this).height(),
				imgW = $(this).width(),
				biwW = $(window).width(),
				ratio = imgH/imgW;
			
			if((biwW*ratio)>300){
				$(this).height(biwW*ratio);
				$(this).width(biwW);
			} else {
				$(this).height(300);
				$(this).width(300/ratio);
			}

			$(this).css('left', (biwW - $(this).width())/2);
			$(this).css('bottom', 0);
	
			return false;
		});
	};
// footer aan onderkant
	$.fn.footerdrop = function() {
		return this.each(function() {
			var headerH = $('#headerwrap').outerHeight(),
				contentH = $('#mainwrap').outerHeight(),
				footerH = $('#footer').outerHeight(),
				totalH = $(window).height(),
				mainH = headerH+contentH+30;
			
			if((mainH+footerH)>totalH){
				$(this).css('margin-top',0);
			} else {
				$(this).css('margin-top',(totalH-(mainH+footerH)));
			}
	
			return false;
		});
	};

	$(document).ready(function(){

// png voor IE
		$('body').pngFix();
// warning if using IE6
	if (($.browser.msie) && ($.browser.version == "6.0")){
		$('#wrap').prepend('<div style="position:relative;left:0;top:0;height:54px;width:100%;display:block;background: pink ;font-weight:bold;border-bottom:5px solid red;"><p style="padding:10px;">U bekijkt deze site in Internet Explorer 6. Sommige functies werken niet met deze browser. Daarom adviseren wij u de browser te updaten.<br /><a href="http://www.mozilla-europe.org/nl/firefox/">"Firefox"</a>, <a href="http://www.apple.com/safari/">"Safari"</a>, <a href="http://www.microsoft.com/windows/internet-explorer/default.aspx">"Internet Explorer"</a>, <a href="http://www.google.com/chrome">"Google Chrome"</a> en <a href="http://www.opera.com/">"Opera"</a> zijn allemaal uitstekende opties om uw verouderde en onveilige browser te vervangen.</p></div>');
		var logosrc = $('#logo a img').attr('src'),
		splitlogosrc = logosrc.split('/');
		$('#logo a img').attr('src', splitlogosrc[0]+'/bw_'+splitlogosrc[1]);
	}
// enter does submit if IE
	if ($.browser.msie){
		$('input').keydown(function(e){
			if (e.keyCode == 13) {
				$(this).parents('form').submit();
				return false;
			}
		});
	}
// dotted linkline
		$('a').focus(function() {this.blur();});
// focus op input
		$('input[type="text"], textarea').addClass("idleField");
		$('textarea').focus(function() {
			$(this).removeClass("idleField").addClass("focusField");
		});
		$('textarea').blur(function() {
			$(this).removeClass("focusField").addClass("idleField");
		});
		$('input[type="text"]').addClass("idleField");
			$('input[type="text"]').focus(function() {
				$(this).removeClass("idleField").addClass("focusField");
				if (this.value == this.defaultValue){ 
					this.value = '';
				}
				if(this.value != this.defaultValue){
					this.select();
				}
			});
			$('input[type="text"]').blur(function() {
				$(this).removeClass("focusField").addClass("idleField");
				if ($.trim(this.value) == ''){
					this.value = (this.defaultValue ? this.defaultValue : '');
				}
			});
// form als t-shirt
		$('label.hidden').hide();
// printbutton
		$('#printwindow').click(function(){
			window.print();
			return false;
		});
// alleen titels
		$('<a href="#" class="block right titres">Alleen titels</a>').insertBefore('#side:not(.nieuws) .item:first:not(.vast)');
		$('.titres').live('click', function(){
			var tekzd = $('.titres').text();
			//alert(tekzd);
			if (tekzd == 'Alleen titels'){
				$('a.titres').text('Toon alles');
			}
			if (tekzd == 'Toon alles'){
				$('a.titres').text('Alleen titels');
			}
			$('.item:not(.vast)').children('p').slideToggle(200);
		});
// als links niet in markup mogen ivm worst-in-blik.
		$('a.verborgen').each(function(){
			var hiddenLink = $(this).text(),
				splitLink = hiddenLink.split('$'),
				emailLink = splitLink[0]+'@'+splitLink[1]+''+splitLink[2]+'.'+splitLink[3];
			$(this).attr('href', 'mailto:'+emailLink);
			$(this).text(emailLink);
		});
// javascript is on...
		$('.bg-image')
			.css('opacity',0)
			.addClass('wrapped-image')
			.removeClass('bg-image')
			.animate({'opacity':0}, 500, function(){
				$(this).animate({'opacity':1}, 1000);
			});
// ...then we can call the resize function for the .bg-image
		$('.wrapped-image').resizenow();
// footer aan onderkant
		$('#footer').footerdrop();
// a img hover
		$('a img').hover(
			function(){
				$(this).stop().animate({"opacity": .6}, 150);
			}, function(){
				$(this).stop().animate({"opacity": 1}, 300, function(){
				if ( $.browser.msie ){
					this.style.removeAttribute('filter');
				}
			});
		});

// nav
		$('#nav li a').slice(1).addClass('extra');

// fancybox
		$('a.fancy').fancybox({
			'titleShow'     : false,
			'transitionIn'	: 'fade',
			'transitionOut'	: 'fade',
			'easingIn'      : 'easeOutBack',
			'easingOut'     : 'easeInBack',
			'overlayColor'  : '#231f20',
			'overlayOpacity': '0.6'
		});
	});
// na browser resize, afbeelding ook resizen
	$(window).bind("resize", function(){
		$('.wrapped-image').resizenow(); 
		$('#footer').footerdrop();
	});
