//////////////////////////////////////////////////////
//
//	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() {
	if ($.browser.msie && $.browser.version <= 6) {
		// this is needed for the IE 6 pseudo hover class bug
		$(".navtop > li").hover(function() {
			$(this).addClass("hover");
		},
		function () {
			$(this).removeClass("hover");
		});
		// this adds flyout support for IE 6
		$(".navtop > li li ").hover(function () {
			$(this).addClass("hover");
		},
		function () {
			$(this).removeClass("hover");
		});
		
	}

	// Remove default search text on focus
	$(".clearField").focus( function(){
		if ( $(this).val() == $(this)[0].defaultValue ) {
			$(this).val("");
		}
	});

	// Replace default search text on blur if input is empty
	$(".clearField").blur( function(){
		if ( $(this).val() == "" ) {
			$(this).val( $(this)[0].defaultValue );
		}
	});

	// home page image rotation
	if ($('body').hasClass('home') && location.host.indexOf('cms') === -1) {
		$('#container').cycle({
			timeout: 6000
		});
	}

	$('#features-nav li a').click(function(){
		if (!$(this).parent().hasClass('selected')) {
			// deselect current nav item and select new one
			$('#features-nav li.selected').removeClass('selected');
			$(this).parent().addClass('selected');

			// hide current item and show new one
			$('#features-wrapper .selected').removeClass('selected');
			$($(this).attr('href')).addClass('selected');
		}

		return false;
	});
});

