$(document).ready(function(){	

	$('.tab').hover(function(){
		if (SECTION == $(this).attr("id")) return;
		var src = $("#" + $(this).attr("id") + " img").attr("src");
		var newSrc = URL + "/images/tab_" + $(this).attr("id") + "_hover.gif";
		$("#" + $(this).attr("id") + " img").attr("src", newSrc);
		$("#" + $(this).attr("id") + " img").attr("oldsrc", src);
	}, function(){
		if (SECTION == $(this).attr("id")) return;
		$("#" + $(this).attr("id") + " img").attr("src", $("#" + $(this).attr("id") + " img").attr("oldsrc"));
	});
	
	// draw subnav
	var i = 0;
	$(".subnav-list").children().each(function(){
		$(this).delay(i++ * $(".subnav-list").children().length * 100).fadeIn("fast");
	});
	
	$(".subnav-list li a").hover(function(){
		$(this).addClass("hover");
	}, function(){
		$(this).removeClass("hover");
	});
	
	if (HAS_SHOW) {

		$("#navigation-container").hover(function(){
			$("#top-scrim").fadeIn(500);
			// $("#bottom-scrim").fadeIn(500);
		},function(){
			$("#top-scrim").fadeOut(500);
			//$("#bottom-scrim").fadeOut(500);
		});
	

		$.get(URL + "/ajax-slide-helper/" + SECTION + "/" + SHOW, function(html){ 
			var options = {
				continuous: true,
				controlsShow: true,
				speed: 200, 
				auto: true,
				pause: 5000,
				numeric: true,
				numericId: "slide-controls"
			};
			$("#slider ul").append(html);
			$("#slider ul").removeClass("first-image");
			$("#slider").easySlider(options);
			$("#slide-controls-container").fadeIn(500);
		});
	} else {
		$("#bg-prev-btn, #bg-btn-container, #bg-next-btn").remove();
	}
	
});

	



/*
	$("#slider").easySlider({
//		auto: true, 
		continuous: true,
		controlsShow: false,
		speed: 200, 
		pause: 5000,
//		numeric: true,
//		numericId: "slide-controls"
	});
});

*/	


var slideshow = function(){
	return {
		"test" : function(){
			alert("yo");
		}
	}
}();


/**
 * plugin for determining position that fixes incompatabilities with Chrome and Safari 
 */
jQuery.fn.aPosition = function() {
	thisLeft = this.offset().left;
	thisTop = this.offset().top;
	thisParent = this.parent();
	parentLeft = thisParent.offset().left;
	parentTop = thisParent.offset().top;
	return {
		left: thisLeft-parentLeft,
		top: thisTop-parentTop
	}
};

