// resize functie (deel code van supersized.js)
	$.fn.resizenow = function() {
		return this.each(function() {
			var imgH = $(this).children().height(),
				imgW = $(this).children().width(),
				biwH = $(window).height(),
				biwW = $(window).width(),
				ratio = imgH/imgW;
	
			if ((biwH/biwW) > ratio){
				$(this).height(biwH);
				$(this).width(biwH / ratio);
				$(this).children().height(biwH);
				$(this).children().width(biwH / ratio);
			} else {
				$(this).width(biwW);
				$(this).height(biwW * ratio);
				$(this).children().width(biwW);
				$(this).children().height(biwW * ratio);
			}
			$(this).children().css('left', (biwW - $(this).width())/2);
			$(this).children().css('top', (biwH - $(this).height())/2);
	
			return false;
		});
	};
// form-value
	jQuery.fn.toggleVal = function(focusClass) {
		this.each(function() {
			$(this).live('focus blur', function(event) {
				if (event.type == 'focus') {
					// clear value if current value is the default
					if($(this).val() == this.defaultValue) { $(this).val(""); }
				
					// if focusClass is set, add the class
					if(focusClass) { $(this).addClass(focusClass); }
				} else {
					// restore to the default value if current value is empty
					if($(this).val() == "") { $(this).val(this.defaultValue); }
				
					// if focusClass is set, remove class
					if(focusClass) { $(this).removeClass(focusClass); }
				}
			});
		});
	};

	$(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>');
	}
// 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();});
// 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);
			$(this).removeClass('verborgen');
		});
// values van label in input
// form als t-shirt
		$('label.hidden').each(function(){
			var tekst = $(this).text();
			$(this).next('input').val(tekst);
			$(this).hide();
		});

$('body.start #header h3').css('display','none');
		
		window.setTimeout(function() {
		$('body.start #header h3').fadeIn(800, function() {
			if ($.browser.msie)
			this.style.removeAttribute('filter');
		});
		}, 400);
// focus op input
		$('textarea, input[type="text"]').addClass("idleField");
		// textarea
		$('textarea').focus(function() {
			$(this).removeClass("idleField").addClass("focusField");
		});
		$('textarea').blur(function() {
			$(this).removeClass("focusField").addClass("idleField");
		});
		//input type=text
		$('input[type="text"]').live('focus', function() {
			$(this).removeClass("idleField").addClass("focusField");
			var defVal = $(this).prev('label').text();
			if (this.value == this.defaultValue){ 
				this.value = '';
			}
			if(this.value != this.defaultValue){
				this.select();
			}
		});
		$('input[type="text"]').live('blur', function() {
			$(this).removeClass("focusField").addClass("idleField");
			if ($.trim(this.value) == ''){
				this.value = (this.defaultValue ? this.defaultValue : '');
			}
		});
// table dingen
		$('table tr td:last').css({'text-align':'right'});
// styled select
			$('form select').styledSelect();
			var zIndex = 1000;
			$('.styledSelect').each(function(){
				$(this).children('ul').css({'z-index':zIndex});
				zIndex--;
			});
// contact hide/show
		$('.contactwrap').hide();
		$('.contacthide').live('click',function(){
			var welks = $(this).attr('rel');
			$('.contactwrap[rel="'+welks+'"]').slideToggle(300);
			$('.algemeenwrap[rel="'+welks+'"]').slideToggle(300);
		});
// printbutton
		$('#printwindow').click(function(){
			window.print();
			return false;
		});
// javascript is on...
		$('.bg-image')
			.addClass('wrapped-image')
			.removeClass('bg-image')
			.wrap('<div class="bg-image-wrap" />');
// ...then we can call the resize function for the .bg-image
		$('.bg-image-wrap').resizenow();
// bg animatie
		$('.bg-image-wrap')
			.css('opacity',0)
			.animate({'opacity':0}, 100, function() {
				$(this).animate({'opacity':.4}, 800, function() {
					if ($.browser.msie)
					this.style.removeAttribute('filter');
				});
			});
// heelhome slidert
		if($('.heelhome .slide').length > 1){
			$('.heelhome .slide').css('cursor','pointer');
			$('.heelhome .slide').slice(1).css({'opacity':0});
			$('.heelhome .slide').slice(0,1).addClass('activeslide').css({'z-index':'9'});
	// animatie door tijd
			var tijd = 1;
			var update = setInterval(function() {
				if(tijd== 5){
					tijd = 1;
					$('.slide:eq(0)').animate({'opacity':0}, 500, function(){
					$(this).detach().insertAfter('.slide:last').css({'opacity':0,'z-index':'8'});
				});
				$('.slide:eq(1)').css('z-index', 9).animate({'opacity':1}, 500).addClass('activeslide');
			} else {
				tijd++;
			}
		}, 1000);
	// animatie door klik - reset meteen de tijd
			$('.heelhome .slide').live('click', function(){
				$(this).removeClass('activeslide').animate({'opacity':0}, 500, function(){
					$(this).detach().insertAfter('.slide:last').css({'opacity':0,'z-index':'8'});
				});
				$(this).next('img.slide').css('z-index', 9).animate({'opacity':1}, 500).addClass('activeslide');
				tijd = 0;
				tijd++;
			});
		}
// caption hover
		$('.caption').hover(function(){
			$(this).children('p').css('color','#000');
		}, function(){
			$(this).children('p').css('color','#648ac7');
		});
// heel zebra
		$('.collapse').css({'margin-bottom':0});
		/*
$('.heel:odd').css({
			'background-color':'transparent', 
			'background-image':'url(images/wit70.png)', 
			'background-repeat':'repeat', 
			'background-position':'left top'
		});
*/
// collapse click
		$('.collapse').append('<h3 class="button">offerte <span>&rsaquo;</span></h3>');
		$('.collapse').css({'height':95, 'overflow':'hidden'});
		$('.collapse h3.button').live('click', function(){
			if($(this).parent('div').height() == 95){
				var tHeight = ($(this).parent('div').children('form').height())+105;
				$(this).text('X');
				$(this).parent('div').animate({'height':tHeight}, 300);
			} else {
				$(this).parent('div').animate({'height':95}, 300);
				$(this).html('offerte <span>&rsaquo;</span>');
			}
		});
// .een3e hover
		$('.een3e').hover(function(){
			$(this).find('a>img').stop().animate({'opacity':.7}, 200);
			$(this).children('.kaption').stop().animate({'top':105}, 200);
		}, function(){
			$(this).find('a>img').stop().animate({'opacity':1}, 350);
			$(this).children('.kaption').stop().animate({'top':175}, 350);
		});

// slider
		$('.slides').cycle({
			fx: 'scrollDown',
			timeout: 5000,
			delay:  -1000
		});

// fancybox 
		$('.fancy').fancybox({
                        'titlePosition'  : 'outside',
                        'overlayOpacity' : 0.5,
                        'overlayColor'   : '#000',
			'padding'	 : 0,
			'margin'	 : 0,
			'titleShow'	 : true
		});

// fancybox vimeo
	$("a.video").click(function() {
		$.fancybox({
                        'overlayOpacity' : 0.5,
                        'overlayColor'   : '#000',
                        'titlePosition'  : 'outside',
			'titleShow'	 : true,
			'padding'	 : 0,
			'margin'	 : 0,
			'autoScale'	 : false,
			'transitionIn'	 : 'none',
			'transitionOut'	 : 'none',
			'width'		 : 600,
			'height'	 : 339,
			'href'		 : this.href.replace(new RegExp("([0-9])","i"),'moogaloop.swf?clip_id=$1'),
			'type'		 : 'swf'
		});
		return false;
	});

// tooltip
		$('.een3e a, .grad a, #logo a, .tooltip').tooltip({opacity: 0.5, track: true, delay: 0, showURL: false, fade: 150, extraClass: "list"});
// link to parent div{
		$('.caption, .kaption').css('cursor','pointer')
		$('.caption').click(function(){
			var h2link = $(this).find('h2 a').attr('href');
			window.location=h2link;
		});
		$('.kaption').click(function(){
			var plink = $(this).find('p>a').attr('href');
			window.location=plink;
		});
// footer @ bottom of page
		  
		var docH = $(document).height(),
			mainH = $('#content').height();
		if((210+34+mainH+63) < docH){
			$('#footer').css({
				'margin-top': (docH - (210+34+mainH+63))
			});
		} else {
			$('#footer').css({
				'margin-top':0
			});
		}
	});
// na browser resize, afbeelding ook resizen
	$(window).bind("resize", function(){
		$('.bg-image-wrap').resizenow();  
		var docH = $(window).height(),
			mainH = $('#content').height();
		if((210+34+mainH+63) < docH){
			$('#footer').css({
				'margin-top': (docH - (210+34+mainH+63))
			});
		} else {
			$('#footer').css({
				'margin-top':0
			});
		}
	});
