/* PAGE SPECIFIC FUNCTIONS */

function homeBehaviors() {
	$('#contact-info div').hover(function() {
		$(this).stop().animate({marginTop: '-5px'}, 250, 'swing');
	}, function() {
		$(this).stop().animate({marginTop: 0}, 250, 'swing');
	});
	$('#contact-info a').each(function(){
		$(this).closest('div').css('cursor', 'pointer').click(function(){
			window.location.href = $(this).find('a').attr('href');
		});
	});
}

function projectsBehaviors() {
	// add prettyprint class to all <pre><code></code></pre> blocks
	var prettify = false;
	$("pre code").parent().each(function() {
		$(this).addClass('prettyprint');
		prettify = true;
	});
	
	// if code blocks were found, bring in the prettifier ...
	if ( prettify ) {
		$.getScript("/workspace/js/prettify.js", function() {
			prettyPrint()
		});
	};
}

function musicBehaviors() {
	$('#previous').hide();
	$('#next').click(function() {
		$('#top-artists-slider').animate({top: '-=630px'}, 500, 'swing');
		var newTop = $('#top-artists-slider').css('top').replace('-', '').replace('px', '');
		var sliderHeight = $('#top-artists-slider').height();
		console.log(sliderHeight - newTop);
		if ((sliderHeight - newTop - 630) <= 630) {
			$(this).fadeOut(500);
		}
		if (newTop == 0) {
			$('#previous').fadeIn();
		}
	});
	$('#previous').click(function() {
		$('#top-artists-slider').animate({top: '+=630px'}, 500, 'swing');
		var newTop = $('#top-artists-slider').css('top').replace('-', '').replace('px', '');
		var sliderHeight = $('#top-artists-slider').height();
		console.log(sliderHeight - newTop);
		if (newTop == 630) {
			$(this).fadeOut();
		}
		$('#next').fadeIn();
	});
}

/* FIRE OFF FUNCTIONS */
$(document).ready(function() {
	var body_id = $('body').attr('id');
	if (body_id === 'Home') {
		homeBehaviors();
	} else if (body_id === 'Projects') {
		projectsBehaviors();
	} else if (body_id === 'Music') {
		musicBehaviors();
	}
});

