$(document).ready(function() {
    	    
    var tabContainers = $(".module-downloads-container");
    
    $(".module-downloads-nav a").click(function () {
        tabContainers.hide().filter(this.hash).show();
        
        $(".module-downloads-nav a").removeClass("selected");
        $(this).addClass("selected");
        
        return false;
    }).filter(":first").click();
    
   	var tabContainers2 = $(".module-videos-container");
   	
   	$(".module-videos-nav a").click(function () {
   	    tabContainers2.hide().filter(this.hash).show();
   	    
   	    $(".module-videos-nav a").removeClass("selected");
   	    $(this).addClass("selected");
   	    
   	    return false;
   	}).filter(":first").click();

	$('.thumb-round').corner();



	// activate overlay
	var overlay = $(".overlay");
	var overlayContent = $(".overlay-content");
	var overlayContainer = $(".overlay-container");
	var overlayModuleWidth = overlayContainer.width();
	var overlayMargin = ($(window).width() - overlayModuleWidth)/2 +"px";
	$(".overlay-trigger").click(function() {
		var getTarget = $(this).attr("href");
		overlay.fadeIn(200);
		overlayContainer.fadeIn(200);
		overlayContainer.css({"left":overlayMargin});
		overlayContent.empty().load(getTarget);
		function handleClick(myID) {
			document.getElementById("flashContent").dcPlayerChangeVideo(myID);	
		}
		return false;
	});		
	
	// redo functions on window resize (so the bg still covers the screen & the overlay module is positioned correctly)
	$(window).resize(function() {
		var overlay = $(".overlay");
		var overlayContainer = $(".overlay-container");
		var overlayModuleWidth = overlayContainer.width();
		var overlayMargin = ($(window).width() - overlayModuleWidth)/2 +"px";
		overlayContainer.css({"left":overlayMargin});
		return false;
	});

	// close overlay module when the user clicks the "close" button or anywhere on the body...
	$(".overlay-close").click(function() {
		overlay.fadeOut(200);
		overlayContainer.fadeOut(200);
		return false;
	});
	overlayContainer.click(function(event){
	    event.stopPropagation();
	});

    
});

