curr_offset = 0;
vars = {
	scroll_duration:750,
	covers_width: function() {
		return $('#coverscroller').width()-50;
	},
	covers_count: function() {
		return $('#albums>*').size()/6;
	}
};

nudge_pic = function(dir){
	if(dir=='next'){
		offset = curr_offset+vars.covers_width();
	}else if(dir=='prev'){
		offset = curr_offset-vars.covers_width();
	}else if(typeof dir == 'number'){
		offset = (dir-1)*pic_width;
	}
	if(offset >= vars.covers_width()*vars.covers_count()||offset<0){
		offset = 0;
	}
	$('#albums').animate(
		{
			left: (-1)*offset,
		},
		vars.scroll_duration,
		function(){}
	);
	curr_offset = offset;
}

randomiseCovers = function(){
	cover_arr = new Array();
	$('#albums>*').each(function(i,e){
		cover_arr[i] = '<a href="'+$(e).attr('href')+'">'+e.innerHTML+'</a>';
	});
	
	var rnds = new Array(cover_arr.length);
	var crnds = new Array(cover_arr.length);

	for(var i=0 ; i < cover_arr.length ; i++) {
		do  {
			var rnd = parseInt(Math.random()*(cover_arr.length)); //min+parseInt(Math.random()*(max-min));
		}
		while(rnds[rnd]);
		rnds[rnd] = true;
		crnds[i] = rnd;
	}
	
	$('#albums').html('');
	newhtml = '';
	for(i=0;i<cover_arr.length;i++){
		newhtml += cover_arr[crnds[i]];
	}
	$('#albums').html(newhtml);
}

/* reflection fallback */
reflection_fallback = function(){
	$('.no-cssreflections #coverscroller img').each(function(i,obj){
		$(obj).clone().insertAfter(obj).addClass('clone');
	});
}
