function scrollToContent(e) {
	e.preventDefault();
	$.scrollTo(
		$('#content'), 300, {easing: 'linear'}
	);
}

function scrollToTop(e) {
	e.preventDefault();
	$.scrollTo(
		0, 300, {easing: 'linear'}
	);
}

jQuery(function( $ ){
	
	$('#upLeft').click(function(e) {
		scrollToTop(e);
	});
	
	$('#upRight').click(function(e) {
		scrollToTop(e)
	});
	
	var storedText = '';
	$('input, textarea').focus(function() {
		storedText = this.value;
		this.value = '';
	});
	$('input, textarea').blur(function() {
		if (this.value == '') {
			this.value = storedText;
		}
	});

	if ($('#jcWebdesign').length > 0) {
		jQuery('#jcWebdesign').jcarousel({vertical: true, scroll: 2});
	}
	if ($('#jcGraphicdesign').length > 0) {
		jQuery('#jcGraphicdesign').jcarousel({vertical: true, scroll: 2});
	}
	if ($('#jcVisualisations').length > 0) {
		jQuery('#jcVisualisations').jcarousel({vertical: true, scroll: 2});
	}

	if ($('#slideshow').length > 0) {
		$('#slideshow').after('<div id="slideshowNav">').cycle({
			fx:     'fade',
			speed:  'fast',
			timeout: 0,
			easing: 'easeInBack',
			pager:  '#slideshowNav',
			pagerAnchorBuilder: function (index, element) {
				pathParts = element.src.split('/');
				imageName = pathParts[pathParts.length-1];
				imageID = imageName.split('.')[0];

				urlParts = location.href.split('/');
				projectID = urlParts[urlParts.length-1];
				return '<a href="#"><img src="/media/img/projects/thumbnails/'+projectID+'/'+imageID+'.jpg" alt ="" /></a>';
			}
		});
	}

	$('#projectThumbnail').mouseover(function (element) {
		$('#projectLink').addClass('underline');
	});
	$('#projectThumbnail').mouseout(function (element) {
		$('#projectLink').removeClass('underline');
	});

	$('#projectLink').mouseover(function (element) {
		$('#projectThumbnail').addClass('border');
	});
	$('#projectLink').mouseout(function (element) {
		$('#projectThumbnail').removeClass('border');
	});
});
