	var debug = 0;
	var timerSet = 0;
	var subNavTimer;

	$(document).ready(function () {
		$('div.fadeto').each(function() {
			if($(this).hasClass('selected')) $(this).css({ opacity:1, visibility:'visible' });
			else $(this).css({ opacity:0, visibility:'visible' });
		});
	
		$('.fadeto').mouseover(function() {
			if($(this).hasClass('selected') == false) {
				$(this).stop(true);
				$(this).animate({ opacity:1 }, 300);
			}
		});
		$('.fadeto').mouseout(function() {
			if($(this).hasClass('selected') == false) {
				$(this).stop(true);
				$(this).animate({ opacity:0 }, 300);
			}
		});
		
		$('.thumbContainer').mouseover(function() {
			var thisId = $(this).attr('id');
			thisId = thisId.replace('Container', '');
			
			$('#'+thisId+'BoxOne').stop().animate({ borderTopColor:'#0f84b5', borderLeftColor:'#0f84b5', borderRightColor:'#0f84b5', borderBottomColor:'#0f84b5' }, 400);
			$('#'+thisId+'BoxTwo').stop().animate({ borderTopColor:'#0f84b5', borderLeftColor:'#0f84b5', borderRightColor:'#0f84b5', borderBottomColor:'#0f84b5', backgroundColor:'#ffffff' }, 400);
			$('#'+thisId+'Link').stop().animate({ color:'#0f84b5' }, 400);
		});
		$('.thumbContainer').mouseout(function() {
			var thisId = $(this).attr('id');
			thisId = thisId.replace('Container', '');
			
			$('#'+thisId+'BoxOne').stop().animate({ borderTopColor:'#acacac', borderLeftColor:'#acacac', borderRightColor:'#acacac', borderBottomColor:'#acacac' }, 400);
			$('#'+thisId+'BoxTwo').stop().animate({ borderTopColor:'#e5e5e5', borderLeftColor:'#e5e5e5', borderRightColor:'#e5e5e5', borderBottomColor:'#e5e5e5', backgroundColor:'#e5e5e5' }, 400);
			$('#'+thisId+'Link').stop().animate({ color:'#282828' }, 400);
		});
		$('.thumbContainer').click(function() {
			var thisId = $(this).attr('id');
			thisId = thisId.replace('Container', '');
			var thisLink = $('#'+thisId+'Link').attr('href');
			
			window.location.href = thisLink;
		});
		
		$('.sidebarNav a').mouseover(function() {
			$(this).stop().animate({ color:'#0f84b5' }, 400);
		});
		$('.sidebarNav a').mouseout(function() {
			if($(this).parent().hasClass('current') == false && $(this).parent().hasClass('selected') == false) $(this).stop().animate({ color:'#282828' }, 400);
		});
		
		if(debug == 1) $('#debug').show();
		
		$('.subMenu a').mouseover(function() {
			$(this).stop().animate({ color:'#0f84b5' }, 400);
		});
		$('.subMenu a').mouseout(function() {
			$(this).stop().animate({ color:'#555555' }, 400);
		});
		
		$('#habermanLink').mouseover(function() {
			// Cancel the timer.
			clearTimer();
			
			// Hide the other subnavs.
			$('#aboutSubNav').fadeOut('fast', function() {
				$('#habermanSubNav').fadeIn('fast');
			});
		});
		
		$('#habermanLink').mouseout(function() {
			setTimer('habermanSubNav');
		});

		$('#habermanSubNav').mouseenter(function() {
			// Cancel the timer.
			clearTimer();
		});

		$('#habermanSubNav').mouseleave(function() {
			setTimer('habermanSubNav');
		});

		$('#aboutLink').mouseover(function() {
			// Cancel the timer.
			clearTimer();
			
			// Hide the other subnavs.
			$('#habermanSubNav').fadeOut('fast', function() {
				$('#aboutSubNav').fadeIn('fast');
			});
		});
		
		$('#aboutLink').mouseout(function() {
			setTimer('aboutSubNav');
		});
		
		$('#aboutSubNav').mouseenter(function() {
			// Cancel the timer.
			clearTimer();
		});

		$('#aboutSubNav').mouseleave(function() {
			setTimer('aboutSubNav');
		});
	});
	
	function setTimer(subNavId) {
		timerSet = 1;
		subNavTimer = setTimeout("hideSubNav('"+subNavId+"')", 500);
		if(debug == 1) $('#debug').append('Timer Set: '+subNavId+'<br />');
	}
	
	function clearTimer() {
		if(timerSet == 1) {
			timerSet = 0;
			clearTimeout(subNavTimer);
			if(debug == 1) $('#debug').append('Timer Cleared<br />');
		}
	}
	
	function hideSubNav(subNavId) {
		timerSet = 0;
		$('#'+subNavId).fadeOut('fast');
	}