$(document).ready(function() {
	$("#navbar ul li:first").addClass("top");
	$("#navbar li").hover(function(){
		$(this).addClass("hover");
		$('ul:first',this).css('visibility', 'visible');
    },
	function(){
		$(this).removeClass("hover");
		$('ul:first',this).css('visibility', 'hidden');
	});
	
	$("#navbar > li > ul").each(function() {
		var widest = 0;
		$(this).children("li").each(function() {
			var el_width = $(this).width();
			if(el_width > widest) widest = el_width;
		});
		widest = widest+20;
		$(this).css("width", widest);
		$(this).children("li").children("a").css("width", widest);
	});

	$("#navbar > li > ul > li > ul").each(function() {
		var widest = 0;
		$(this).children("li").each(function() {
			var el_width = $(this).width();
			if(el_width > widest) widest = el_width;
		});
		widest = widest+20;
		$(this).css("width", widest);
		$(this).children("li").children("a").css("width", widest);
	});
	
	
	$("#slider-wrapper").mouseout(function() {
		$(".caption").animate({ height: "29px" }, 200);
	});
	
	$("#carousel").jCarouselLite({
	    btnNext: "#next",
	    btnPrev: "#prev"
	});
	
	$('#banner-image').cycle({ 
	    timeout: 6000, 
	    pager:  '#side-slider' 
	});
	
	setTimeout(function() {
		var i=0;
		$("#banner-image h1").each(function() {
			var text = $(this).html();
			var url  = $(this).attr('rel');
			$("#side-slider a:eq(" + i + ")").html(text);
			$("#side-slider a:eq(" + i + ")").attr('href', url);
			i++;
		});
	}, 50);
	
	$("#tabs li").click(function() {
		var index = $(this).index();
		$(this).children("a").addClass("active").parent().siblings().children("a").removeClass("active");
		$(".teasers").hide();
		$(".teasers:eq(" + index + ")").show();
	});
	
	$(".teasers").not(":eq(0)").hide();
	
	$("#q").inputHint();
	
	$("a.lightbox").lightBox();
	
	$('#utility-nav > li').hover(function() {
		$(this).find('.lvl_1').show();
	}, function() {
		$(this).find('.lvl_1').hide();
	});
	
	$('#utility-nav .lvl_1 li').hover(function() {
		$(this).find('.lvl_2').show();
	}, function() {
		$(this).find('.lvl_2').hide();
	});
	
	
});
