var feature_timer = setTimeout("feature_change()", 5000);
var where_to = 1;
function feature_change() {
	$(".landing-features-nav ul li a:eq("+where_to+")").click();
	var how_many = $(".landing-features-nav ul li a");
	where_to++;
	if(where_to>=how_many.length){
		where_to = 0;
	}
}

$(document).ready(function(){ 
	var switching = 0;
	$(".landing-features li:gt(0), .landing-features-links li:gt(0)").hide().removeClass("preload");
	$(".landing-features-nav ul li a").click(function(event){
		event.preventDefault();
		if(switching==0){
			clearTimeout(feature_timer);
			switching=1;
			var newFeat = $(this).text() - 1;
			$(".landing-features-nav ul li a").removeClass("active");
			$(this).addClass("active");
			$(".landing-features-links li.active").removeClass("active").fadeOut(500);
			$(".landing-features li.active").removeClass("active").fadeOut(500, function(){
				$(".landing-features-links li:eq("+newFeat+")").addClass("active").fadeIn(500);
				$(".landing-features li:eq("+newFeat+")").addClass("active").fadeIn(500,function(){
					var how_many = $(".landing-features-nav ul li a");
					where_to = newFeat+1;
					if(where_to>=how_many.length){
						where_to = 0;
					}
					feature_timer = setTimeout("feature_change()", 5000);
					switching=0;
				});
			});
		}
	});
	$(".ham-tips dd:gt(0)").css({"position":"absolute","left":"-999em"});
	$(".ham-tips dt:gt(0)").addClass("script");
	$(".ham-tips dt").click(function(){
		if($(this).next().css("position")=="absolute"){
			$(this).removeClass("script");
			$("dt.active").removeClass("active").next().slideUp(600, function() {
				$(this).prev().addClass("script");
				$(this).css({"position":"absolute","left":"-999em"}).show();
			 });
			$(this).addClass("active");
			$(this).next().hide().css({"position":"relative","left":"auto"}).slideDown(600);
		} else {
			$(this).removeClass("active");
			$(this).next().slideUp(600, function() {
				$(this).prev().addClass("script");
				$(this).css({"position":"absolute","left":"-999em"}).show();
			 });
		}
	});

});

