// album slider object
if(typeof(DM) == "undefined") { DM={}; }
DM.slider = {

	// the current page
	p: 0,


	// set some defaults
	init: function(wdth) {
		this.c = 924; // visible width of slider area
		this.n = Math.ceil(wdth / this.c) -1; // number of 'pages'
	},

	// animate one page up or down
	animate:function(dir){

		// requested page
		r = this.p + dir;

		// prevent out of range
		if(r < 0 || r > this.n) {
			return;
		}

		// confirm next page
		this.p = r;

		// animate element to new position
		$("#scroll-wrap ul").animate( {left:(this.p * this.c) * -1+"px"}, 1000, 'swing' );
	},

	// go directly to a given page
	jumpto:function(page) {

		// reset current page
		this.p = page;

		// jump element into view
		$("#scroll-wrap ul").css( {left:(this.p * this.c) * -1+"px"} );
	}
};

// global stuff
$(function() {

	// handle external Links
	$("a[rel='external']").click(function(){
		window.open($(this).attr("href"));
		return false;
	})

	// album thumbnail interactions
	$("#scroll-wrap li").hover(

		// mouseover/out
		function(){ $(this).addClass("a-image-hover")},
		function(){ $(this).removeClass("a-image-hover")}

	).click(function(){

		// allow click anywhere on li
		window.location = $(this).find("a").attr("href");
	})

	// album scroller handlers
	$("#scroll-left").click(function(){	DM.slider.animate(-1) })
	$("#scroll-right").click(function(){DM.slider.animate(1) })

	// add the shadow to the footer
	$("#content").after('<div id="content-foot"></div>');

	// top menu interaction
	$("#header ul li a").hover(
		function(){ $("#header ul").attr("class",$(this).attr("id")) },
		function(){ $("#header ul").attr("class", " " ) }
	)

});