//WAIT FOR THE PAGE TO BE READY
$(document).ready(function(){

	$('#buttons li a:first').addClass('first');
	$('#buttons li a:last').addClass('last');
	
	$('div#global_header').append('<span class="highlight"></span>');
	$('div#global_header span.highlight').css({opacity:0.14});
	
	ddBusy = false;
	ddOpen = false;
	
	if(ddBusy==false){
		$('div#bars_dropdown a.top').click(function(){
			if(ddOpen==false){
				ddBusy = true;
				ddOpen = true;
				$(this).addClass('active');
				$('div#bars_dropdown ul').show().stop([]).animate({height:178}, 178, function(){
					ddBusy = false;
				});
			}else{
				ddBusy = true;
				$('div#bars_dropdown ul').stop([]).animate({height:0}, 178, function(){
					$('div#bars_dropdown a.top').removeClass('active');
					$(this).hide();
					ddBusy = false;
					ddOpen = false;
				});
			}
			return false;
		});
	}
	
	$('div#bars_dropdown ul').mouseleave(function(){
		$(this).stop([]).animate({height:0}, 178, function(){
			$('div#bars_dropdown a.top').removeClass('active');
			ddBusy = false;
			ddOpen = false;
		});
	});
	
	$('div#bars_dropdown ul li:lt(3)').addClass('first_row');
	
	$('div#bars_dropdown ul li').hover(function(){
		title = $(this).children('a').attr('title');
		$(this).children('a').removeAttr('title').children('img').removeAttr('alt');
		$(this).stop([]).animate({opacity:1}, 150);
		$(this).siblings().stop([]).animate({opacity:0.5}, 400);
	},function(){
		$(this).children('a').attr('title', title).children('a').attr('alt', title);
		$(this).animate({opacity:1}, 150);
		$(this).siblings().animate({opacity:1}, 150);
	});

	

	jQuery.extend( jQuery.easing,{
		easeInOutExpo: function (x, t, b, c, d) {
			if (t==0) return b;
			if (t==d) return b+c;
			if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;
			return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
		},
		easeInExpo: function (x, t, b, c, d) {
			return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b;
		},
		easeOutExpo: function (x, t, b, c, d) {
			return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
		},
		easeInBounce: function (x, t, b, c, d) {
			return c - jQuery.easing.easeOutBounce (x, d-t, 0, c, d) + b;
		},
		easeOutBounce: function (x, t, b, c, d) {
			if ((t/=d) < (1/2.75)) {
				return c*(7.5625*t*t) + b;
			} else if (t < (2/2.75)) {
				return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
			} else if (t < (2.5/2.75)) {
				return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
			} else {
				return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
			}
		}

	});

// End jQuery goodness
});
