//$(function(){
//	positionFooter(); 
//	function positionFooter(){
//		var totalHeight = Number($(window).scrollTop()+$(window).height());
//		var bodyHeight = Number($(document.body).height());
//		var imageHeight = Number($("#background").height());
//		if(imageHeight < totalHeight){
//			$("#background").css({top:(totalHeight-imageHeight)+"px"});
//		}
//	} 
//	$(window).scroll(positionFooter).resize(positionFooter)
//});

// ===========================
//  Active Nav
// ===========================
var pathArray = window.location.pathname.toString().split("/");
$(function(){
	// Make current page active
	$('a[href='+window.location.pathname+']').addClass('current_page');
	// Keep top nav active if in sub directory
	if (pathArray.length > 2) {
		$('#nav a[href*=/'+pathArray[1]+'/]').addClass('current_page');
	}
});

// ===========================
//  Cycle
// ===========================
$(function(){
	// Create div to place labels
	$('.cycle').after('<div class="label"></div>');
	// Cycle code
	$('.cycle').cycle({
		fx: 'fade',
		pager: '#artbox .label',
	    pagerAnchorBuilder: function(index, slide) {
        	return "<a href='javascript:setSlide("+index+")'>"+$(slide).find('img').attr('alt')+"</a>"; 
    	} 
	});
});
function setSlide(index) {
	// When link pressed go to index
	$('.cycle').cycle(index);
}

// ===========================
//  Tiles
// ===========================
$(function(){
	$('#tiles li a').each(function() {
		// Create a label for each of the tiles
		$(this).append('<div class="label">' + $(this).find('img').attr('alt') + '</div>');
		// Roll over/out states
		$(this).hover(
		function() { $(this).find('.label').stop().animate({ backgroundColor: "black" }, 300); },
		function() { $(this).find('.label').stop().animate({ backgroundColor: '#999999' }, 800); }
		);
		// Reset on click
		$(this).click(function() {
			$(this).find('.label').css("background-color","#999999");
		});
	});
});
