$(document).ready(function(){
		
	//CSS
	$('.list_item:last').css('padding-bottom','0');
	$('#mainNav ul li:has(ul)').css('padding-bottom','0');
	$('#footerLogos ul li img:last').css('margin-right','0');

	//Back to top
	$('.backToTop, #toTop').click(function(){
		$('html, body').animate({scrollTop:0}, 'slow'); 
		return false;
	});	
	
	//Menu
	$('#mainNav a').click(function(){
		targetId = $(this).attr('class');
		if ($('#'+targetId).length) {
			$.scrollTo( '#'+targetId, 700 );
			target = $(this).parent('li');
			$('#mainNav ul li').removeClass('active');
			target.addClass('active');
				
			( ($(this).parents().filter('ul').length) > 1 ) ? $(this).parents().find('li:has(li.active)').addClass('active') : '';
			return false;
		} else {
			return true;
		}
	});
	//Menu Corners
	$('#mainNav ul li a').corner('left');
	$('#mainNav ul li ul, #toTop').corner('left');	
	
	
}); //Close document.ready


$(window).scroll(function() {	
	pos = $(window).scrollTop();
	mH = $('#mainNav').height()
	h = (pos < 200) ?  '0' : parseFloat( mH - (mH - 200));
	$('#mainNav').animate({ top: parseFloat( $(window).scrollTop() - h) + "px" }, { queue: false, duration: 1100, easing: 'custom' });
});


$(window).bind("load", function() {	
});

/*------- Equal hights ---------------------------------------------------------*/
jQuery.fn.equalHeights = function() {
	var maxHeight=0;
	this.each( function() {
		if (this.offsetHeight>maxHeight) {maxHeight=this.offsetHeight;}
	});
	this.each( function() {
		$(this).height(maxHeight + "px");
		if (this.offsetHeight>maxHeight) {
			$(this).height((maxHeight-(this.offsetHeight-maxHeight))+"px");
		}
	});
};
/*------ Easing animations -----------------------------------------------------*/
(function($) {
	$.easing.custom = function (x, t, b, c, d) { 
		var s = 1.70158;  
		if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b; 
		return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b; 
	}
	$.easing.easeOutExpo = function (x, t, b, c, d) {
		return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
	};
	$.easing.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;
		}
	};
})(jQuery);
(function($) {
	$.fn.animPanel = function(options) {
		var opts = $.extend({}, $.fn.animPanel.defaults, options);
		return this.each(function() {
			$this = $(this);
			var o = $.meta ? $.extend({}, opts, $this.data()) : opts;				
			$this.toggle(function() {
				$(o.target).animate({ top: o.topStart }, 300, "easeOutBounce", function() { 
					$(o.target).find('#searchBtn').text(o.textClose);	
				});						   
			},function() {
				$(o.target).animate({ top: o.topEnd }, 300, "easeOutBounce", function() { 
					$(o.target).find('#searchBtn').text(o.textOpen);
				});						   	
			})	
			
		});
	};
})(jQuery);

