$(document).ready(function() {
	
	//Show/hide 'moreless...' sections
	$('span.moreless').removeClass('hide');
	$('div.moreless').hide();

	$('span.moreless').toggle(
		function () {
			$(this).html('less').addClass('less');
			$(this).next('div.moreless').slideDown('fast');
		},
		function () {
			$(this).html('more').removeClass('less');
			$(this).next('div.moreless').slideUp('fast');
		}
	);
	
	//ScrollTo named anchors
	$('.contact_me, .backtotop').click(function(){
		if($(this).attr('class') == 'contact_me') $.scrollTo('#contact', 1500, {easing:'easeInOutSine'});
		else $.scrollTo('#header', 1500, {easing:'easeInOutSine'});
	});
	
	//Portfolio slider
	if($('#slider').length > 0){
		//Style slider elements
		$('#slider').css('overflow','hidden');
		$('.prev, .next').removeClass('hide');
		
		var $items = $('#slider ul li');
		var $slider = $('#slider ul');
	
		//Make slider wide enough to contain all portfolio items
		$slider.css('width', $items[0].offsetWidth * $items.length);
	
		$('#slider_sleeve').serialScroll({
			target:'#slider',
			items:'li',
			prev:'.prev',
			next:'.next',
			axis:'x',
			duration:300,
			lock:false,
			easing:'easeInOutCubic'
		});
	}
	
	//Portfolio thumbnails --> launch modal window with jQuery.fancybox
	if($('a.fancybox').length > 0){
		$('.portfolio').css('display','none');
		$('a.fancybox').fancybox({
			'autoDimensions':false,
			'width':800,
			'height':'90%',
			'titleShow':false,
			'transitionIn':'elastic',
			'transitionOut':'elastic',
			'speedIn':'fast',
			'speedOut':'fast',
			'overlayColor':'#000',
			'overlayOpacity':'0.5'
		});
	}
});