//////////////////////////////////////////////////////
//
//	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/)
//
//////////////////////////////////////////////////////

$(document).ready(function() {
	//comment this out if you have no png images
	$.ifixpng('cmsimages/pixel.gif');
    $('img[src$=.png]').ifixpng(); 
});

$(window).load(function() {

	$("input.emptytext").focus(function() {
		if ( $(this).val() == $(this)[0].defaultValue ) {
			$(this).val("");
		}
	});

	// put default text back in on blur
	$("input.emptytext").blur(function() {
		if ( $(this).val() == "" ) {
			$(this).val( $(this)[0].defaultValue );
		}
	});

	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").hover(function () {
			$(this).addClass("redraw");
		},
		function () {
			$(this).removeClass("redraw");
		});
	}
	
	$('.jshover').each(function(){
		$(this).hover(function(){
			
			var src = $(this).attr('src');
			var i = src.lastIndexOf('.');
			var ext = src.substring(i, src.length );
			var name = src.substr(0, src.length - (src.length - i));
			$(this).attr('src', name + '-over' + ext);
		},
		function(){
			var src = $(this).attr('src');
			$(this).attr('src', src.replace(/-over/,''));
		});
		
	});
	
	
	
	/*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];
		$(this).click(function(){
			href = this.href;
			$('#imageHolder p').fadeOut('slow', function(){
				$(this).load(href + " #imageHolder img", function(){
						$(this).fadeIn('slow');
				});
			});
			return false;
		});
		//fade screen out for IE
		$(this).children('.screen').fadeTo(0,0);
		$(this).hover(function(){
			
		}, function(){
			
		});
	});*/
});

