jQuery(document).ready(function($) {

	$(".tab_content").hide(); //Hide all content
		$("ul.tabNav li:first").addClass("active").show(500); //Activate first tab
		$(".tab_content:first").show(); //Show first tab content
	
		//On Click Event
		$("ul.tabNav li").click(function() {
	
			$("ul.tabNav li").removeClass("active"); //Remove any "active" class
			$(this).addClass("active"); //Add "active" class to selected tab
			$(".tab_content").hide(); //Hide all tab content
	
			var activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content
			$(activeTab).fadeIn(500); //Fade in the active ID content
			return false;
		});
	
});


// Functions to show and hide slide navigation controls (for cycle SS)
// -------------------------------------------------------------------

	// show slide navigation
	function showSlideNav($) {
		if ($('#SlideShow-Controls').length > 0) {
			$('#SlideShow-Controls').slideDown('fast');
		}		
	}
	// hide slide navigation
	function hideSlideNav($) {
		if ($('#SlideShow-Controls').length > 0) {
			$('#SlideShow-Controls').slideUp('fast');
		}
	}

/*
/*	Dynamic design functions and onLoad events
/*	----------------------------------------------------------------------
/* 	Creates added dynamic functions and initializes loading.
*/


// ======================================================================
//
//	On document ready functions
//
// ======================================================================


jQuery(document).ready(function($) {

		$("#test_slider").easySlider();
		$(".popout").tooltip({position: "top-right", effect: "slide" });
    	
    	
	// Show/Hide slide show buttons
	// -------------------------------------------------------------------
	// This will show/hide the slide show buttons for Next and Previous
	// on the jQuery Cycle plugin slide show.
	
	if ($('#CyclePlugin #Slides').length > 0) {
		// on mouse over/out functions
		if (typeof $.fn.hoverIntent == 'function') {
			$('#SlideShow').hoverIntent(function() {showSlideNav(jQuery)}, function() {hideSlideNav(jQuery)});
		} else {
			$('#SlideShow').hover(function() {showSlideNav(jQuery)}, function() {hideSlideNav(jQuery)});
		}
		// Hide on page load...
		if ($('#SlideShow-Controls')) {
			var initHideSlideNav = setTimeout("hideSlideNav(jQuery)", 1000);	// delay in milliseconds
		}
	}


	
	
	// FAQ's functionality
	// -------------------------------------------------------------------
	
	if ($('.faqs li').length > 0 ) {
		var faqs = $('.faqs li');
		faqs.each( function() {
			var q = $(this);
			q.children('.question').click( function() {
				q.children('div').toggle(300, function() {
					// Animation complete...
				});
			});
		});
	}


	});





	// show slide navigation
	function showSlideNav($) {
		if ($('#SlideShow-Controls').length > 0) {
			$('#SlideShow-Controls').slideDown('fast');
		}		
	}
	// hide slide navigation
	function hideSlideNav($) {
		if ($('#SlideShow-Controls').length > 0) {
			$('#SlideShow-Controls').slideUp('fast');
		}
	}



// button styling function
// -------------------------------------------------------------------

function buttonStyles($) {
	// Button styles
	
	// This will style buttons to match the theme. If you don't want a button
	// styled, give it the class "noStyle" and it will be skipped.
	$("button:not(:has(span),.noStyle), input[type='submit']:not(.noStyle), input[type='button']:not(.noStyle)").each(function(){
		var	b = $(this),
			tt = b.html() || b.val();
		
		// convert submit inputs into buttons
		if (!b.html()) {
			b = ($(this).attr('type') == 'submit') ? $('<button type="submit">') : $('<button>');
			b.insertAfter(this).addClass(this.className).attr('id',this.id);
			$(this).remove();	// remove input
		}
		b.text('').addClass('btn').append($('<span>').html(tt));	// rebuilds the button
	});
	
	// Get all styled buttons
	var styledButtons = $('.btn');
	
	// Fix minor problem with Mozilla and WebKit rendering (can also be done adding this to CSS, 
	// button::-moz-focus-inner {border: none;}
	// @media screen and (-webkit-min-device-pixel-ratio:0) { button span {margin-top: -1px;} }
	if (jQuery.browser.mozilla || jQuery.browser.webkit) {
		styledButtons.children("span").css("margin-top", "-1px");
	}
	
	// Button hover class (IE 6 needs this)
	styledButtons.hover(
		function(){ $(this).addClass('submitBtnHover'); },		// mouseover
		function(){ $(this).removeClass('submitBtnHover'); }	// mouseout
	);
}


// Image icon overlay (hover shows icon - zoom, play, etc...)
// -------------------------------------------------------------------

function imgIconOverlay($) {

	if (jQuery.browser.msie && parseInt(jQuery.browser.version, 10) < 7) {
		// IE 6 sucks so the effect doesn't work at all and that's why we skip it here
		// we coluld do something different for IE 6 in this area if we wanted 
	} else {
		// This will select the items which should include the image overlays
		$("a.imgSmall:not(.noIcon), a.imgMedium:not(.noIcon), a.imgLarge:not(.noIcon), a.imgTall:not(.noIcon)").each(function(){
			var	ctnr = $(this);
			// insert the overlay image
			if (ctnr.children('img')) {
				if (ctnr.hasClass('iconPlay')) {
					ctnr.children('img').after($('<div class="imgOverlay symbolPlay"></div>'));
				} else if  (ctnr.hasClass('iconDoc')) {
					ctnr.children('img').after($('<div class="imgOverlay symbolDoc"></div>'));
				} else {
					ctnr.children('img').after($('<div class="imgOverlay symbolZoom"></div>'));
				} 
			}
			
			var overImg = ctnr.children('.imgOverlay'); 
			
			if (jQuery.browser.msie && parseInt(jQuery.browser.version, 10) < 9) {
				// IE sucks at fading PNG's with gradients so just use show hide
				overImg.css('visibility','hidden'); // not visible to start 
				
				ctnr.hoverIntent(
					function(){ overImg.css('visibility','visible'); },		// mouseover
					function(){ overImg.css('visibility','hidden'); }		// mouseout
				);
			} else {
				// make sure it's not visible to start 
				overImg.css('opacity',0);
				
				ctnr.hoverIntent(
					function(){ overImg.animate({'opacity':'1'},'fast'); },		// mouseover
					function(){ overImg.animate({'opacity':'0'},'fast'); }		// mouseout
				);
			}
		});
	}
	
}
