$(document).ready(function() {

	var new_pos;
	var win_height;
	var min_height = 500;
	var max_height = 800;
	var offset = 225;
	var speed = 500;
	var repos_timer;
	var img;
	var video;
	
	// replace headers with bitmaps
	$('#news h1').html('<img src="/img/header_news.png" alt="News" />');
	$('#photos h1').html('<img src="/img/header_photos.png" alt="News" />');
	$('#videos h1').html('<img src="/img/header_videos.png" alt="News" />');
	
	// drop opacity for content containers and icons
	$('#news,#videos,#photos,#footer_social ul li,#footer_sponsors ul li').fadeTo(1,.5, function() {
		$(this).mouseenter(function() {
			$(this).stop(true,false).fadeTo(250,1);
		});
		$(this).mouseleave(function() {
			$(this).stop(true,false).fadeTo(250,.5);
		});
	});
	
	// drop opacity for header
	$('#header div').fadeTo(1,.5);
	$('#header').mouseenter(function() {
		$('#header div').stop(true,false).fadeTo(250,1);
	});
	$('#header').mouseleave(function() {
		$('#header div').stop(true,false).fadeTo(250,.5);
	});
	
	// image and video thumb events
	$('#photos img, #videos img').fadeTo(1,.5);
	$('#photos img, #videos img').mouseover(function() {
		$(this).fadeTo(100,1);
	});
	$('#photos img, #videos img').mouseout(function() {
		$(this).fadeTo(100,.5);
	});
	
	// photo click action
	$('#photos a').lightBox({
		overlayBgColor: '#101013',
		overlayOpacity: 0.85,
		imageLoading: '/img/loading.gif',
		containerResizeSpeed: 200
	});
	

	// video click action (via DOMWindow jquery plugin)
	$('#videos a').openDOMWindow({ 
		height:360, 
		width:640, 
		positionType:'centered', 
		positionTop:300,
		borderColor:'#202023',
		windowBGColor:'#101013',
		eventType:'click',
		windowSource:'ajax'
	});
	
			
	// position content div on page load
	repos();
		
	// position content div when window is resized
	$(window).resize(function() {
		if (repos_timer) {
			clearTimeout(repos_timer);
		}
		repos_timer = setTimeout(repos,250);
	});
	
	// methdos
	
	function repos() {
		win_height = $(window).height();
		if ((win_height < max_height) && (win_height > min_height)) {
			new_pos = win_height - offset;
		} 
		else if (win_height < min_height) {
			new_pos = min_height - offset;
		}
		else if (win_height > max_height) {
			new_pos = max_height - offset;
		}
		$('#content').animate({top:new_pos},speed,'swing');
	};
	

});
