$(document).ready(function(){

	var visible;
	var thumbwidth;
	var totalwidth;
	var maxwidth = $('#wrapper').width();
	
	function getWidth(){
		thumbwidth = 240;
		visible = Math.floor(($(window).width() - 20) / thumbwidth);
		totalwidth = thumbwidth * visible;
	}
	
	function setWidth() {
		
		getWidth();
		
		if(totalwidth > maxwidth){
			$('.wrapper').width(totalwidth);
    		$('#carousel').width(totalwidth);

		}else
		{
			$('.wrapper').width(maxwidth - 20);
    		$('#carousel').width(maxwidth - 20);
		}
		if($(window).width() <= 1220){
		
			$('#header').css({'backgroundImage' : 'url(/site2012/gfx/nu2.png)'});
    	}else
		{
    		$('#header').css({'backgroundImage' : 'url(/site2012/gfx/nu.png)'});
		}	
	}
	setWidth();
	
	$(window).resize(function(){
	
		setWidth();
		
	});


	$('#carousel a').mouseenter(function(){
    	$(this).parent().addClass('hovering');
    });
	$('#carousel a').mouseleave(function(){
    	$(this).parent().removeClass('hovering');
    });
	$('#carousel a').click(function(){
    	$(this).parent().addClass('visited');
    });
    
    $('#carousel a').colorbox({width : '940px', height: '515px'}, function(){
    	// make link visited
    	$('#carousel #' + $('#colorbox .author').attr('title')).addClass('visited');
    	IN.parse(document.body);
	   	FB.XFBML.parse();
    });
     $('#credits a.popup').colorbox({width : '770px', height: '515px'}, function(){
    });

	 $("#contactform").validate({
		rules: {
		email: {
			required: true,
			email: true
			}
		}
	});  
});



