//////////////////////////////////////////////////////
//
//	The purpose of this file is to
//	apply a hover class on mouseover
//	on the <li> elements in the nav.
//	This is because IE doesn't put
//	the pseudo class :hover on <li> elements
//
//	This is code that uses the
//	jquery javascript library (http://jquery.com/)
//
//////////////////////////////////////////////////////
$(window).load(function() {
	if (document.all&&document.getElementById) {
		// this is needed for the IE 6 pseudo hover class bug
		$(".navtop > li").hover(function() {
			$(this).addClass("hover");
		},
		function () {
			$(this).removeClass("hover");
		});
		
		$(".navtop > li li ").hover(
		function () {
			$(this).addClass("hover");
		},
		function () {
			$(this).removeClass("hover");
			
		});
		
		
	} else {
		// this is need for safari when nav covers flash
		$(".navtop li ul").mouseover(function () {
			$(this).addClass("redraw");
		});
		$(".navtop li ul").mouseout(function () {
			$(this).removeClass("redraw");
		});
	}
	
	$('#footer li a').each(function(){
		var img = $(this).children('img')[0];
		var w =  img.width;
		var h =  img.height;
		var screen = $(this).append('<div class="screen" style="width: ' + w + 'px;height: ' + h +  'px;"></div>');
		//fade screen out for IE
		$(this).children('.screen').fadeTo(0,0.80);
		$(this).hover(function(){
			$(this).children('.screen').dequeue();
			$(this).children('.screen').fadeTo('slow', 0);
			
		}, function(){
			$(this).children('.screen').dequeue();
			$(this).children('.screen').fadeTo('slow',0.80);
			
		});
	});
	
	$('ul.courseList.navchild li').each(function(){
	     var a = $(this).find('h2 a');
             $(this).append('<a href="'+ a.attr('href') + '" class="viewDetails">View Details&gt;&gt;&gt;</a>');
             
         });
	
	if($('#imageHolder p').length > 0)
	{
		$('#imageHolder p').fadeOut(0);
		$('#imageHolder p').load($('#imageNav li a')[0].href +  ' #imageHolder img', function(){
			$(this).fadeIn('slow');
		});
	}
	
	//$('#footer').append('<div id="testOut"></div>');
	var href = "";
	$('#imageNav li a').each(function(){
		var img = $(this).children('img')[0];
		var w =  img.width;
		var h =  img.height;
		var screen = $(this).append('<div class="screen" style="width: ' + w + 'px;height: ' + h +  'px;"></div>');
		$(this).click(function(){
			return false;
		});
		//fade screen out for IE
		$(this).children('.screen').fadeTo(0,0);
		$(this).hover(function(){
			href = this.href;
			//$('#testOut').append('<p>' + href + '</p>');
			$(this).children('.screen').dequeue();
			$(this).children('.screen').fadeTo('slow',0.80);
			//$('#testOut').append('<p>hover</p>');
			$('#imageHolder p').fadeOut('slow', function(){
				$(this).load(href + " #imageHolder img", function(){
						$(this).fadeIn('slow');
				});
				
			});
			
		}, function(){
			$(this).children('.screen').dequeue();
			$(this).children('.screen').fadeTo('slow', 0);
		});
	});
});
