var expanded;
var animated = 0;
$(function() 
		{
			expanded = $("#accordion a:first-child");

			jQuery('header nav li').hover(function()
			{
				jQuery(this).children("ul").stop(true, true).fadeIn('slow');
			}, function()
			{
				jQuery(this).children("ul").stop(true, true).fadeOut('slow');
			}); 

			$("#accordion a").click(function(e) 
			{
				if(!expanded.equals($(this))) {e.preventDefault();}
				if(animated == 0)
				{
					if(expanded != undefined) {expanded.stop().animate({width: '149px'}, 500);}
					animated = 1;
					$(this).stop().animate({width: '461px'}, 500, function() {animated = 0; expanded = $(this)});
				}
			});


		});

$.fn.equals = function(compareTo) {
  if (!compareTo || this.length != compareTo.length) {
    return false;
  }
  for (var i = 0; i < this.length; ++i) {
    if (this[i] !== compareTo[i]) {
      return false;
    }
  }
  return true;
};
























