$(document).ready(function(){
	$('h1.topText').textShadow();
	$('.PrintMe').click(function(){
		window.print();
		return false;
	})
	$('.candidateOpen').click(function(){
		if ($(this).hasClass('candidateClose'))
		{
			$('[rel='+$(this).attr('id')+']').addClass('hidden');
			$(this).removeClass('candidateClose');
		}
		else {
			$('[rel='+$(this).attr('id')+']').removeClass('hidden');
			$(this).addClass('candidateClose');
		}
	});
	$('#bedrijfs-opdrachten tr').click(function(){
		window.location.href = $(this).find('a').attr('href');
	});
	
});

function newsscoller(prev) {
	//Get the current selected item (with selected class), if none was found, get the first item
	var current_image = $('#gallery li.selected').length ? $('#gallery li.selected') : $('#gallery li:first');
	var current_excerpt = $('#excerpt li.selected').length ? $('#excerpt li.selected') : $('#excerpt li:first');

	//if prev is set to 1 (previous item)
	if (prev) {
		
		//Get previous sibling
		var next_image = (current_image.prev().length) ? current_image.prev() : $('#gallery li:last');
		var next_excerpt = (current_excerpt.prev().length) ? current_excerpt.prev() : $('#excerpt li:last');
	
	//if prev is set to 0 (next item)
	} else {
		
		//Get next sibling
		var next_image = (current_image.next().length) ? current_image.next() : $('#gallery li:first');
		var next_excerpt = (current_excerpt.next().length) ? current_excerpt.next() : $('#excerpt li:first');
	}

	//clear the selected class
	$('#excerpt li, #gallery li').removeClass('selected');
	
	//reassign the selected class to current items
	next_image.addClass('selected');
	next_excerpt.addClass('selected');

	//Scroll the items
	$('#mask-gallery').scrollTo(next_image, 800,{onAfter:function(){_runAnimation = setTimeout(function(){newsscoller(0);}, _runAnimationSpeed);}});		
	$('#mask-excerpt').scrollTo(next_excerpt, 800);					
	/*$('#mask-excerpt')
		.css({opacity:0})
		.animate({opacity:1,},1000,function(){
			$('#mask-excerpt')
		});*/
}