jQuery("html").addClass('enhanced');
jQuery(document).ready(function($) {
	
	$(".wt-show").click(function() {
		// currently closed
		var showTarget = $(this).attr("rel");
		
		$("#"+showTarget).slideToggle();
		
		// toggle open state
		$(this).toggleClass("open");
	});
	
	
	
	$.fn.menuShow = function() {
		
		// only do fades for good browsers
		if (!$.browser.msie) {
			$(this).stop().css({display: "block", opacity: 0}).fadeTo(150, 1);
		}
		else {
			$(this).slideDown(100);
		}
		return this;
	};
	
	$.fn.menuHide = function() {
		// only do fades for good browsers
		if (!$.browser.msie) {
			$(this).stop().fadeOut(400, 0, function(){
				$(this).find("ul").hide();
			});
		}
		else {
			$(this).slideUp(100);
		}
		return this;
	};
	
	// menu show/hide
	$("#menu .nav > li:has(ul)").hover(function() {
		$(this).find("ul").menuShow();
	}, function() {
		$(this).find("ul").menuHide();
	});
	
	
	// double check last-child for menu
	$("#menu .nav>li:last").addClass("last");
	$("#menu .nav>li:first").addClass("first");
	
	if ($.browser.msie && $.browser.version == 8) {
		$("#menu .nav>li:last").css('borderRightWidth', '0px');
	}
	
	
	if ($.browser.msie && $.browser.version == 6) {
		$(".simplepie ol>li:first").addClass("first");
	}

	// clear search field on click
	$("input[type='text']").focus(function() {
		if (!$(this).attr("rel")) {
			$(this).attr("rel", $(this).attr("value"));
		}
		if ($(this).attr("rel") == $(this).attr("value") ) {
			$(this).attr("value", "");
		}
	})
	.blur(function() {
		if ($(this).attr("value") == "") {
			$(this).attr("value", $(this).attr("rel") );
		}
	});

	// main promo cycling
	$("#container").prepend("<div id='main-nav'></div>");
	$("#main").cycle({
			speed: 500,
			timeout: 7000,
			delay: 1000,
			pager: "#main-nav",
			pause: true,
			pauseOnPagerHover: true
			
		});
	
	var roundHTML = '<span class="round tl"></span><span class="round tr"></span><span class="round bl"></span><span class="round br"></span>';
	if ($.browser.msie) {
		$("#main").prepend(roundHTML);
		
		if ($.browser.version == 6 && typeof(DD_roundies) !== 'undefined') {
			DD_roundies.addRule("span.round");
		}
		
	}
	
	//pricing table
	$("#pricing tbody th").each(function(index) {
		
		var th = $(this);
		var tip = th.attr("title");
		
		if (tip && ! ($.browser.msie && $.browser.version == 6 ) ) {
			th
				.removeAttr("title")
				.wrapInner("<div class='context' />")
				.find(".context")
					.append('<div class="tip">'+tip+'<span class="arrow" /></div>')
					.append('<span class="help">?</span>');
		}
	});
	$("#pricing tbody tr").hover(function() {
		$(this).addClass("hover");
	}, function() {
		$(this).removeClass("hover");
	});

});


