$(document).ready(function(){


	// redefine Cycle's updateActivePagerLink function - http://www.malsup.com/jquery/cycle/pager7.html
/*	$.fn.cycle.updateActivePagerLink = function(pager, currSlideIndex) { 
	    $(pager).find('li').removeClass('activeLI') 
	        .filter('li:eq('+currSlideIndex+')').addClass('activeLI'); 
	};*/

	
	// external links
  $('a[rel="external"]').click(function(){
    $(this).attr('target','_blank');
  });

		
	
	$("table#TLA tr:nth-child(even)").addClass("striped");
	
	/* Rollovers for the left nav */
	$("#leftNavList > li").mouseover(
		function(){
			$(".leftnavTop", this).removeClass("leftnavTop").addClass("leftnavTopHover");
			$(".leftnavFiller > a", this).addClass("hovered");
			$(".leftnavFiller", this).removeClass("leftnavFiller").addClass("leftnavFillerHover");
			$(".leftnavBottom", this).removeClass("leftnavBottom").addClass("leftnavBottomHover");
		}
	);
	$("#leftNavList > li").mouseout(
		function(){
			$(".leftnavTopHover", this).removeClass("leftnavTopHover").addClass("leftnavTop");
			$(".leftnavFillerHover", this).removeClass("leftnavFillerHover").addClass("leftnavFiller");
			$(".leftnavBottomHover", this).removeClass("leftnavBottomHover").addClass("leftnavBottom");
			$(".leftnavFiller > a", this).removeClass("hovered");
		}
	);
	
	//preload the glossary definitions
	$(".glossaryTerm").each( function ()
	{
		$(this).attr("rel", glossaryURL + jQuery(this).attr("title"));
		$(this).attr("displayTitle", $(this).html());
	});
	
	$(".glossaryTerm").mouseover( function ()
	{
		var thisTitle = $.ajax(
		{
			url: glossaryURL + jQuery(this).attr("title"),	async: false
		}).responseText;
		$(this).attr("displayTitle", "test|this is a test");
	});
	
	$(".glossaryTerm").cluetip(
	{
		titleAttribute: "displayTitle",
		//sticky: true,
		clickThrough: true,
		showTitle: false
		//sticky: false, 
		//closePosition: 'title',
		//arrows: true,
		//attribute: "title",
		//splitTitle: "|",
		//dropShadow: true,
	});

	/* Create tabs for product types */
	//$('#productTabs').tabs({ fxFade: true, fxSpeed: 'fast' });
	
	/* Hide TLA details by default */
	$(".topicDetails").hide();
	
	/* TLA show/hide logic */
	$(".hideDetailsLink").click(
		function()
		{
			if($(this).html() == "less")
			{
				$(".topicDetails", $(this).parent()).hide();
				$(".topicDetailsPreview", $(this).parent()).show();
				$(this).html("more");
			}
			else
			{
				$(".topicDetails", $(this).parent()).show();
				$(".topicDetailsPreview", $(this).parent()).hide();
				$(this).html("less");
			}
		}
	);
	/* $(".showDetailsLink").click(
		function()
		{
			$(".topicDetails", $(this).parent()).show();
		}
	); */
	
	$("#hideAll").click(
		function()
		{
			$(".topicDetails").hide();
			$(".topicDetailsPreview").show();
			$(".hideDetailsLink").html("more");
		}
	);
	
	$("#showAll").click(
		function()
		{
			$(".topicDetails").show();
			$(".topicDetailsPreview").hide();
			$(".hideDetailsLink").html("less");
		}
	);

 $('.btn').each(function(){
 	var b = $(this);
 	var tt = b.text() || b.val();
 	if ($(':submit,:button',this)) {
 		b = $('<a>').insertAfter(this). addClass(this.className).attr('id',this.id);
 		$(this).remove();
	 }
  b.text('').css({cursor:'pointer'}). prepend('<i></i>').append($('<span>').text(tt).append('<i></i><span></span>'));
 });

});



   




