//////////////////////////////////////////////////////
//
//	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");
		});
	} else {
		// this is need for safari when nav covers flash
		$(".navtop li ul").hover(function () {
			$(this).addClass("redraw");
		},function () {
			$(this).removeClass("redraw");
		});
	}
	
	//gallery pages
	
	if($('#imageHolder p').length > 0)
	{
		$('#imageHolder p').fadeOut(0);
		$('#imageHolder p').load($('#navchild li a')[0].href +  ' #pageContentHolder img', function(){
			$(this).fadeIn('slow');
		});
	}
	
	var href = "";
	$('#navchild 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(){
			$('#imageHolder p').fadeOut('slow', function(){
				$(this).load(href + " #pageContentHolder img", function(){
						$(this).fadeIn('slow');
				});
				
			});
			return false;
		});
		//fade screen out for IE
		$(this).children('.screen').fadeTo(0,0.5);
		$(this).hover(function(){
			href = this.href;
			//$('#testOut').append('<p>' + href + '</p>');
			$(this).children('.screen').dequeue();
			$(this).children('.screen').fadeTo('slow',0);
			//$('#testOut').append('<p>hover</p>');
		/*	$('#imageHolder p').fadeOut('slow', function(){
				$(this).load(href + " #pageContentHolder img", function(){
						$(this).fadeIn('slow');
				});
				
			}); */
			
		}, function(){
			$(this).children('.screen').dequeue();
			$(this).children('.screen').fadeTo('slow', 0.5);
		});
	});


	//location pages
	
	
	if($('#contentHolder div').length > 0)
	{
		$('#contentHolder div').fadeOut(0);
		$('#contentHolder div').load($('#nav_level3 li a')[0].href +  ' #pageBigContentHolder div', function(){
			$(this).fadeIn('slow');
		});
	}
	
	var href = "";
	$('#nav_level3 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"></div>');
		$(this).click(function(){
			$('#contentHolder div').fadeOut('slow', function(){
				$(this).load(href + " #pageBigContentHolder div", function(){
						$(this).fadeIn('slow');
				});
				
			});
			return false;
		});
		//fade screen out for IE
		$(this).children('.screen').fadeTo(0,0.5);
		$(this).hover(function(){
			href = this.href;
			//$('#testOut').append('<p>' + href + '</p>');
			$(this).children('.screen').dequeue();
			$(this).children('.screen').fadeTo('slow',0);
			//$('#testOut').append('<p>hover</p>');
		/*	$('#imageHolder p').fadeOut('slow', function(){
				$(this).load(href + " #pageContentHolder img", function(){
						$(this).fadeIn('slow');
				});
				
			}); */
			
		}, function(){
			$(this).children('.screen').dequeue();
			$(this).children('.screen').fadeTo('slow', 0.5);
		});
	});
	
	
});
