function initFades()
{
	if(jQuery.browser.msie && jQuery.browser.version < 7)
	{
		return;
	}

	var $fading_buttons = jQuery('#navigation_bar li a, a.button')

	$fading_buttons.append('<span class="hover"></span>').css('zoom', '1');

	if(jQuery.browser.msie && jQuery.browser.version >= 7)
	{
		$fading_buttons.each(function() {
			if(jQuery(this).hasClass('nav_active'))
			{
				return;
			}

			$hover_element = jQuery('.hover', this);
			$hover_element.stop().animate({'opacity': 0.00001}, 1);
			setTimeout(function() { $hover_element.stop().animate({'opacity': 0}, 1); }, 10);
		});
	}

	jQuery('#navigation_bar li a, a.button').hover(function() {
		if(jQuery(this).hasClass('nav_active'))
		{
			return;
		}
		else
		{
			jQuery('.hover', this).stop().animate(
			{
				'opacity': 1
			}, 300, 'easeOutSine');
		}
	
	},
	function() {
		if(jQuery(this).hasClass('nav_active'))
		{
			return;
		}
		jQuery('.hover', this).stop().animate(
		{
			'opacity': 0
		}, 300, 'easeOutSine')
	});
}

function fixHeader() {
	var document_width = jQuery(document).width();
	var navigation_width = 944;

	var width_of_each_side = ((document_width - navigation_width) / 2);

	if(!((document_width - navigation_width) % 2))
	{
		var width_of_each_side = ((document_width - navigation_width) / 2);
	}

	var $window = $(window);
	if($window.width() <= 980)
	{
		if($window.width() <= 944)
		{
			jQuery('div#navigation_left').css('width', '0px');
		}
		jQuery('div#navigation_right').css('width', '0px');
	}
	else
	{
		jQuery('div#navigation_left, div#navigation_right').css('width', width_of_each_side + 'px');
	}
}

function fixSubmitButtons() {
	var $submit_buttons = jQuery('input[type=submit]');
	$submit_buttons.each(function() {
		var $this = jQuery(this);
		$this.hide();

		var $button = jQuery('<a></a>');
		$button.addClass('button').addClass('submit').click(function() {
			jQuery(this).parent().parent().submit()
		});
		$button.insertAfter($this);
	});
}

jQuery(document).ready(function() {
	fixSubmitButtons();
	initFades();
	fixHeader();

	jQuery(window).resize(fixHeader);
});
