$(document).ready(function() {
	
	//initialize localscroll
	$.localScroll({
			hash:false,
			offset: -120,
	});
	
	
	//Switch current class
	$("#navigation ul li a").click(function(e) {
		$(".current").removeClass("current");
			$(this).addClass("current");
	});
	
	
	//Fade in welcome div
	$('#welcome').fadeIn(2000);
	
	
	//Slide/toggle #aboutBox
		//Hide (Collapse) the toggle containers on load
		$("#aboutBox").hide(); 
	
		//Switch the "Open" and "Close" state per click then slide up/down (depending on open/close state)
		$("h2#click-for-more").click(function(){
			$(this).toggleClass("active").next().slideToggle("slow");
			return false; //Prevent the browser jump to the link anchor
		});
	

	/*	CarouFredSel: an infinite, circular jQuery carousel.
		Configuration created by the "Configuration Robot"
		at caroufredsel.frebsite.nl
	*/
	$("#folioWrap ul").carouFredSel({
		width: null,
		items: {
			visible: 3,
			minimum: 1,
			start: 1
		},
		scroll: {
			items: 3,
			easing: "easeInOutBack",
			duration: 1200
		},
		auto: false,
		prev: "#prev-btn",
		next: "#next-btn"
	});	
	
	
	//folio img:hover
	$("#folioWrap ul img.item").hover(
		function() {
			$(this).stop().animate({"opacity": "0"}, "fast");
			},
		function() {
			$(this).stop().animate({"opacity": "1"}, "regular");
	});
	
	
	//Initialize Fancybox
	$("a.folio").fancybox({
		'width'				:	970,
		'height'			:	590,
		'overlayOpacity'	:	0.0,
		'speedIn'			:	1000,
		'speedOut'			:	300,
		'transitionIn'		: 	'fade',
		'transitionOut'		: 	'fade',
		'centerOnScroll'	:	true,
		'type'				:	'iframe'
	});
	
	$("a.photo").fancybox({
		'overlayOpacity'	:	0.0,
		'speedIn'			:	1000,
		'speedOut'			:	300,
		'transitionIn'		: 	'fade',
		'transitionOut'		: 	'fade',
		'centerOnScroll'	:	true,
		'titlePosition'		:	'inside'
	}); 


	//Scroll to Top plugin
	jQuery.fn.topLink = function(settings) {
		settings = jQuery.extend({
			min: 1,
			fadeSpeed: 200
		}, settings);
		return this.each(function() {
			//listen for scroll
			var el = $(this);
			el.hide(); //in case the user forgot
			$(window).scroll(function() {
				if($(window).scrollTop() >= settings.min)
				{
					el.fadeIn(settings.fadeSpeed);
				}
				else
				{
					el.fadeOut(settings.fadeSpeed);
				}
			});
		});
	};
	//set the link
	$('#top-link').topLink({
		min: 400,
		fadeSpeed: 500
	});
	//smoothscroll
	$('#top-link').click(function(e) {
		e.preventDefault();
		$.scrollTo(0,300);
	});
	
	
});
