function restbreedte() {
	var $wrapperwidth = $('#wrapper').css('width').replace('px','');
	var $bodywidth = $('body').css('width').replace('px','');
	$footertopwidth = $bodywidth-20; 
	$restwidth = $bodywidth-$wrapperwidth;
	$restwidth2 = $restwidth/2;
    //$("#footertop_r2").html($bodywidth);
    if($bodywidth > 980 ) {
    	$("#footertop_l").css( { width:$restwidth2 } );
    	$("#footertop_r2").css( { width:960 } );
    } else { 
    	$("#footertop_l").css( { width:0 } );
    	$("#footertop_r2").css( { width:$footertopwidth } );
    }
   
    //$("#footertop_r").css( { width:$restwidth2 } );
}

function lightbox_iframe() {
	$('#lightbox').fadeIn('fast');
}

$(window).resize(function() {
	restbreedte();
});

$(document).ready(function() {

// Icoontje voor externe links

/*
$("a").not("#twitterkader a, .socialicon_link").filter(function() {
	if ( $(this).text() != '' ) {
    	return this.hostname && this.hostname !== location.hostname;
    }
}).addClass('external');
*/


// alert( $('.innerfade').length );

if($('.innerfade').length != '0') {
	// alert('innerfade');
	$innerfadewidth = $('.innerfade').find('img').width();
	$innerfadeheight = $('.innerfade').find('img').height();
	// alert($innerfadeheight);
	$('.innerfade').animate({ 'height' : $innerfadeheight, 'width' : $innerfadewidth  }, {duration:1} );
	
	$('.innerfade').innerfade({ speed: 'slow', timeout: 3000, type: 'sequence' });
}

$('#lightbox').click(function(){
	$('#lightbox').fadeOut('fast');
});
	
	var $defaultpath = $('#defaultpath').text();
	// alert($defaultpath);

	restbreedte();
	
	///
	/// TOPMENU
	///

	$('#topmenu a').mouseover(function(){ 
		if( $(this).siblings('ul').css("height") == "0px" || !$(this).parent().children('ul').length ) {
			$(this).stop().animate({ 'color' : '#222222'}, 100);
		}
	});
	$('#topmenu a').mouseout(function(){ 
		if( $(this).siblings('ul').css("height") == "0px" || !$(this).parent().children('ul').length ) {
			$(this).stop().animate({ 'color' : '#f64f16'}, 250);
		}
	});
	$('#topmenu a').not('#topmenu ul a').click(function(){ 
	
		//INDIEN BETREFFEND SUBMENU ONZICHTBAAR
    	if ( $(this).parent().children('ul').length == '1' && $(this).siblings('ul').css("height") == "0px") {
			//INDIEN ANDER SUBMENU ZICHTBAAR *EN* AANWEZIG
			if( $('#topmenu a').not(this).siblings('ul').css("height") != "0px" && $('#topmenu a').not(this).siblings('ul').length != '0' ) {
				$('#topmenu a').not(this).siblings('ul').stop().animate({ 'height' : '0px'}, {duration:250, easing:"easeInOutQuad"});
			}
			//INDIEN OOK GEEN ANDER SUBMENU ZICHTBAAR *OF* GEEN ANDER SUBMENU AANWEZIG
			else {
				$('#submenubg').stop().animate({ 'height' : '103px'}, {duration:250, easing:"easeInOutQuad"});
				$('#menulijn').stop().animate({ 'top':'136px'}, {duration:250, easing:"easeInOutQuad"});
			}
			$(this).siblings('ul').stop().animate({ 'height' : '88px'}, {duration:250, easing:"easeInOutQuad"});
			$(this).stop().animate({ 'color' : '#222222'}, 100);
			$('#topmenu a').not(this).stop().animate250;
		}
		//INDIEN BETREFFEND SUBMENU ZICHTBAAR
		else if( $(this).parent().children('ul').length == '1' && $(this).siblings('ul').css("height") != "0px") {
			$(this).stop().animate({ 'color' : '#f64f16'}, 1000);
			$(this).siblings('ul').stop().animate({ 'height' : '0px'}, {duration:250, easing:"easeInOutQuad"});
			$('#submenubg').stop().animate({ 'height' : '15px'}, {duration:250, easing:"easeInOutQuad"});
			$('#menulijn').stop().animate({ 'top':'48px'}, {duration:250, easing:"easeInOutQuad"});
		}
		//INDIEN ER HELEMAAL GEEN SUBMENU BIJ HET MENUITEM BESTAAT
		else if ( $(this).parent().children('ul').length == '0') {
			$('#topmenu ul').stop().animate({ 'height' : '0px'}, {duration:250, easing:"easeInOutQuad"});
			$('#topmenu a').not(this).stop().animate({ 'color' : '#f64f16'}, 500);
			$('#submenubg').stop().animate({ 'height' : '15px'}, {duration:250, easing:"easeInOutQuad"});
			$('#menulijn').stop().animate({ 'top':'48px'}, {duration:250, easing:"easeInOutQuad"});
		}
	});

	///
	/// FOOTER
	///
	
	$('#footer').hover(function(){ 
		$('#footer').stop().animate({ 'height':'170px'}, 250);
		$('#footer').queue(function() {
			$('#footer li').stop().animate({ opacity: 1 }, 250);
			$(this).dequeue();
		});
	}, function(){ 
		$('#footer li').stop().animate({ opacity: 0.5 }, 250); 
		$('#footer li').queue(function() {
			$('#footer').stop().animate({ 'height':'50px'}, 250);
			$(this).dequeue();
		});
	});
	
	$('.socialicon_link').mouseover(function(){ 
		$(this).children('.socialicon_off').stop().animate({ 'width' : '0px', 'margin-left':'21px', 'background-position':'-21px'}, 100);		
		$(this).children('.socialicon_on').stop().animate({ 'width' : '21px'}, 100);		
	});
	$('.socialicon_link').mouseout(function(){ 
		$(this).children('.socialicon_off').stop().animate({ 'width' : '21px', 'margin-left':'0px', 'background-position':'0px'}, 250);			
		$(this).children('.socialicon_on').stop().animate({ 'width' : '0px'}, 250);			
	});
	
	$('#newsletter_intro').css('display','none');
	$('#newsletter_header').css('display','none');
	$('#newsletter_radio').css('display','none');

});
