//------------------------------------
//	LANDING.JS
//	Author: 	Engage Interactive
//	Requires:	jquery 1.4.4
//------------------------------------

$(function(){
//BEGIN jQuery

	// Select boxes
	$('.drop_down .top').live('click', function(e) {
		e.preventDefault();
		
		var $parent = $(this).closest('.drop_down');
		var $dropDownList = $parent.find('ul');
		var parentSelected = $parent.hasClass('active');

		if($dropDownList.find('a').length > 9) $dropDownList.css({height: 150});

		$('.drop_down.active').removeClass('active');
		
		if(!parentSelected) $parent.addClass('active');
	});
	
	$('.drop_down').mouseleave(function() {
		$(this).removeClass('active');
	});
	
	// Region / Language Chooser
	$('ul li a').live('click', function(e) {
		
		e.preventDefault();

		$this = $(this);
		$list = $this.parents('ul');
		
		$list.parents('div.drop_down').removeClass('active').find('a.top').html($this.text()+' <span></span>');

		$('input#input_'+$list.attr('id')).val($this.attr('rel'));
	
		if($('input#input_region').val() && $('input#input_language').val()) $('div.buttons').fadeIn();
		else $('div.buttons').fadeOut();
	})

});

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;
	}
});
