// $Id: custom.js 109 2010-02-09 14:54:53Z svn $

/**
 * @file
 * General setup for various theme related jQuery.
 */

$(function(){
  $('#header-menu').each(function () {
    $(this).find('ul').each(function() {
      var paddingLeft = parseInt($(this).css('padding-left')),
          paddingRight = parseInt($(this).css('padding-right')),

          marginLeft = parseInt($(this).css('margin-left')),
          marginRight = parseInt($(this).css('margin-right')),

          fullRowWidth = paddingLeft + paddingRight;

      $(this).children('li').each(function(){
        var liWidth = $(this).outerWidth(true);
        fullRowWidth += liWidth;
      });


      fullRowWidth = fullRowWidth - marginLeft - marginRight > 610 ? 610 - marginLeft - marginRight : fullRowWidth+15;

      $(this).css('width', fullRowWidth);

      if ($(this).parent('li').css('position') == 'relative') {
        $(this).css({'left': - fullRowWidth / 2, 'margin-left' : '85%'});
      }
    }).end().superfish({
      dropShadows: false,
      autoArrows:  false
    });
  });

	var banner = $('#banner-content');

	if (banner.length) {
		var bannerHeight = banner.height();
		var bodyHeight = $(window).height();
		$.extend($.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;
				}
			 }
			});
		banner.css({position: 'absolute', left: '50%', top: '-446px', marginLeft: '-300px' }).animate({top: bodyHeight/2 - bannerHeight/2}, 2000, 'easeOutBounce');
	}
});

