function initPortfoliolist(){
	$('body').append('<div id="pitem-info"></div>');
	$('.portfoliolist .item').each( function(){
		var title = $(this).find('a img').attr('alt');
		var url = $(this).find('a').attr('href');
		$(this).append('<div class="overlay"></div>');
		$(this).find('.overlay').click( function(){
			window.location = url;
		}).hover(
			function(e){
				$('#pitem-info').html(title).show();
				$(this).stop();
				$(this).fadeTo("100",0);
			},function(){
				$('#pitem-info').html(title).hide();
				$(this).stop();
				$(this).fadeTo("100",0.6);
			}
		 );

	});	
	$('.portfoliolist .item .overlay').fadeTo("0",0.6);
	$(document).mousemove(function(e){
		$('#pitem-info').css({
			'left':e.pageX+10,
			'top':e.pageY+20
		})
	}); 
	
}


function initNavigation(){
	$('#navigation > ul > li').hover(
		function(){
			cnt = $( this ).children().size(); 
			if( cnt > 1 ){
				$(this).addClass('hover');	
				$('embed, object').hide();
			}	
		}, function (){
			$(this).removeClass('hover');	
			$('embed, object').show();
		}
	)

	$('ul.regions a').mouseover( function(){
		$('ul.regions a').removeClass('active');
		$(this).addClass('active');
	})

}

function initLinks ( sel ) {
	$(sel).each( function(){

		
			var href = $(this).attr('href');
			if(href){
				if( href.substring(0,7) == 'http://' ){
					$(this).addClass('external');
					if( $(this).find('img').length == 0 ){
						$(this).after('&nbsp;<img src="lib/images/external_link.gif" alt="Pagina opent in nieuw venster"/>');
					} else {
						$(this).after('<span class="access">Pagina opent in nieuw venster</span>');
					}
					$(this).click( function(){
						window.open(href);	
						return false;
					});
				}
			}
		
	});

}




$().ready( function(){
	initLinks('.mod_article a');
	initPortfoliolist();
	initNavigation();
    $('.gallery').cycle({
		fx: 'fade',
		timeout:  2000 
	});
	
	
});
