$(document).ready(function()
{
	if($('ul#nav li a').length > 0)
	{
		$('ul#nav li a').css('opacity','0.9');
	}
	
	if($('ul#nav li.subnav ul').length > 0)
	{
		$('ul#nav li.subnav ul').css('opacity','0.9');
	}
	
	if($('input#mailing_list_email_address').length > 0)
	{
		$('input#mailing_list_email_address').focus(function()
		{
			if($(this).val() == 'Email Address')
			{
				$(this).val('');
			}
		});
		
		$('input#mailing_list_email_address').blur(function()
		{
			if($(this).val() == '')
			{
				$(this).val('Email Address');
			}
		});
	}
	
	if($("ul#subnav").length > 0)
	{
		if(!$.browser.msie || $.browser.version != 5.5)
		{
			$("ul#subnav").css("display","none");
		}
	}
	
	$(function()
	{  
		if ($.browser.msie && parseInt($.browser.version)< 7)
		{
			$("ul#nav li.subnav").hover(function()
			{  
				$(this).addClass("active");  
            },
			function()
			{
				$(this).removeClass("active");  
            });
			
			$("ul#nav li.subnav ul li.subsubnav").hover(function()
			{  
				$(this).addClass("active");  
            },
			function()
			{
				$(this).removeClass("active");  
            });
		}
	});
	
	$('a[rel*="external"]').click(function()
	{
		open($(this).attr('href'));
		return false;
	});
	
	var nav_timeout = 'undefined';
	
	$("li.subnav").bind("mouseenter",function()
	{
		if(nav_timeout != 'undefined')
		{
			clearTimeout(nav_timeout);
		}
		
		$("li.subnav.active").removeClass("active");
		$(this).addClass("active");
	}).bind("mouseleave",function()
	{
		nav_timeout = setTimeout(function()
		{
			$("li.subnav.active").removeClass("active");
		},2000);
	});
	
	$("ul.thumbs li a img").each(function()
	{
		$.preloadImages.add($(this).attr("src").replace("thumb", "mid"));
	});
	
	$("ul.thumbs li a").mouseover(function()
	{
		$("img#full").attr("src", ($(this).attr('href')).replace("full", "mid"));
		$("img#full").attr("alt", ($(this).attr('alt')));
		$("a#enlarge").attr("href", ($(this).attr('href')).replace("thumb", "full"));
		$("a#enlarge").attr("title", ($(this).attr('title')));
	});
	
	$("ul.thumbs li:first a").click(function()
	{
		$("a#enlarge").click();
	});
	
	$("ul.thumbs li a").click(function()
	{
		$("img#full").attr("src", ($(this).attr('href')).replace("full", "mid"));
		$("img#full").attr("alt", ($(this).attr('alt')));
		$("a#enlarge").attr("href", ($(this).attr('href')).replace("thumb", "full"));
		$("a#enlarge").attr("title", ($(this).attr('title')));
		return false;
	});
	
	if($("li.help a").length > 0)
	{
		$("li.help a").click(function()
		{
			return false;
		});
		
		var help_timeout = 'undefined';
		
		$("li.help a").bind("mouseenter",function()
		{
			if(help_timeout != 'undefined')
			{
				clearTimeout(help_timeout);
			}
			$("li.help div").fadeOut();
			$(this).next().addClass('active').fadeIn();
		}).bind("mouseleave",function()
		{
			help_timeout = setTimeout(function()
			{
				$('li.help div.active').removeClass('active').fadeOut();
			},2000);
		});
		
		$('input').focus(function()
		{
			$('li.help div.active').removeClass('active').fadeOut();
		});
		
		$('select').focus(function()
		{
			$('li.help div.active').removeClass('active').fadeOut();
		});
		
		$('textarea').focus(function()
		{
			$('li.help div.active').removeClass('active').fadeOut();
		});
	}
});