function nav_overs(id,h,spd){
	$('#'+id+' li').hover(function() {
 		$(this).children('.link a').animate({ marginTop: -h }, spd);	
	}, function() {
		$(this).children('.link a').animate({ marginTop: -0 }, spd);          
	});	
}

function scrollToLink(id){
	$('html, body').animate({
	scrollTop: $(id).offset().top
	}, 1000);
}

function getAllHeights(){
	tptm = $('#tristanperotti').height() * 30;
	hotm = $('#harlanotter').height() * 30;
	jmtm = $('#jasonmcchristian').height() * 30;
	amtm = $('#amandamikaelsson').height() * 30;
	
	var times = [100,tptm,hotm,jmtm,amtm];
	return times;
}

//var timeouts = getAllHeights();

function getTimeout(currElement, nextElement, opts, isForward) {
    var index = opts.currSlide;
    var timeouts = getAllHeights();
    return timeouts[index] * 10;
} 


function gallery_jump(nm){
	$('#pieces').cycle(nm);
	$('#pieces').cycle('pause');
}

function setHeight(){
	var hgt = $(this).css('height');
	var nm = $(this).attr('id');
	$('#pieces').css('height', hgt );
	$('#composerlinks li a').removeClass('act');
	$('#'+nm+'_link').addClass('act');
}

$(document).ready(function(){
	nav_overs('nav','24',0);
	
	var ssld=Math.floor(Math.random()*6);
	if(ssld == 0){ ssld = 1 }

	$('#pieces').cycle({ 
    	fx:     'scrollUp', 
    	speed:  100,
    	timeout: 1,
    	timeoutFn: getTimeout,
    	after: setHeight
	});
	
	$('#pieces').cycle(ssld);
	getAllHeights();
});
