﻿jQuery(document).ready(
	function()
	{
		
		// for links with rel="external", set 'target' attribute to "_blank" and append 'title' attribute
		$("a[@rel*=external]").attr(
		{
			target: "_blank",
			title: function() 
			{
				var titleStr = ($(this).attr('title') != undefined) ? $(this).attr('title') + " [External link, opens in new window]" : "[External link, opens in new window]";
				return titleStr;
			}
		});
		
		// Print page function
		$("#a-print-page").click(
			function()
			{
				window.print();
			}
		);
		
		// Textbox focus
		$('input:text').add('.page-order select').focus(
			function()
			{
				$(this).addClass('focus');
			}
		);
		$('input:text').add('.page-order select').blur(
			function()
			{
				$(this).removeClass('focus');
			}
		);
		$('.page-order input:text').add('.page-order select').focus(
			function()
			{
				$(this).parent().css('background-color','#eee').children('label').css('font-weight','bold');
			}
		);
		$('.page-order input:text').add('.page-order select').blur(
			function()
			{
				$(this).parent().css('background-color','transparent').children('label').css('font-weight','normal');
			}
		);
		
		// Tooltips
		$("ul.nav-article > li > span").add("ul.nav-foot > li > span").css("bottom", 
			function()
			{
				return $(this).parent().height();
			}
			).prev("a").removeAttr("title");
		
		if(!$.browser.msie || ($.browser.msie &&  $.browser.version >= 7)) 
		{
			
			$("ul.nav-article > li > a").add("ul.nav-foot > li > a").hover(
			function()
			{
				$(this).next("span").animate({opacity: "show", height: "+=18px"}, { duration: 350, easing: "easeOutBack" }).css("display","block");
			},
			function()
			{
				$(this).next("span").animate({opacity: "hide", height: "-=18px"}, { duration: 85, easing: "easeOutQuad" });
			});
		}
		else
		{
			
			$("ul.nav-article > li > a").add("ul.nav-foot > li > a").hover(
			function()
			{
				$(this).next("span").toggle();
			},
			function()
			{
				$(this).next("span").toggle();
			});
			$("ul.nav-article > li").wrapInner(document.createElement("span"));
			$("ul.nav-article > li > span").css("position","relative");
		}
		
		// Question & answer list
		$("dl.qa-list dd").hide();
		$("dl.qa-list dd a").attr("rel","external");
		$("dl.qa-list dt").wrapInner("<a></a>").click(
			function()
			{
				$(this).next().toggle();
			}
		);
	}
);