$(document).ready( function()
{
	if ( $.browser.msie && $.browser.version.number() < 7 )
	{
		// IE6 Menu Issues
		$('ul.adxm li[ul]') // Find all li elements in ul.adxm menus that have ul elements inside them
			.bind('mouseenter', function()
			{
				$('ul:first', this).css('visibility', 'visible');
			} )
			.bind('mouseleave', function()
			{
				$('ul:first', this).css('visibility', 'hidden');
			} );

		// IE6 PNG Issues
		$('img[@src*=".png"]').addClass('png');

		$('.pngbg').each( function()
		{
			var bg = this.currentStyle.backgroundImage;
			if(bg && bg.length > 0)
			{
				this.runtimeStyle.backgroundImage = 'none'; // Remove background
				var bgurl = bg.substring(5,(bg.length-2)); // Strip the url("")
				this.runtimeStyle.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src="' + bgurl + '", sizingMethod="scale")';
			}
		} );
		$('.gifbg').each( function()
		{
			var bg = this.currentStyle.backgroundImage;
			if(bg && bg.length > 0)
			{
				this.runtimeStyle.backgroundImage = bg.replace(/\.png/img, "\.gif"); // Replace the .png for the .gif
			}
		} );
	}

	// Color
	var fc3bright = (fc3.toUpperCase() == '#FFFFFF') ? mix(fc3, bc1) : mix(fc3, '#FFFFFF'); // If fc3 is already white, mix it with bc1 instead of white
	var fc1bright = (fc1.toUpperCase() == '#FFFFFF') ? mix(fc1, bc3) : mix(fc1, '#FFFFFF'); // If fc1 is already white, mix it with bc3 instead of white

	$('#Content a, #SubFooter a').not('.Current').hover(
		function(){ $(this).css('color', fc3bright); },
		function(){ $(this).css('color', fc3); }
	);
	$('#FooterMenu a, #SideMenu a').not('.Current').hover(
		function(){ $(this).css('color', fc1bright); },
		function(){ $(this).css('color', fc1); }
	);

} );

// We need the images to be loaded when working with their sizes
$(window).load( function()
{
	$('div.AlbumImage').each( function()
	{
		var width = $('img:first', this).width();
		$(this).width(width + 'px');
	} );
} ); 

function mix(c1, c2)
{
	var r1 = parseInt(c1.substring(1,3),16);
	var g1 = parseInt(c1.substring(3,5),16);
	var b1 = parseInt(c1.substring(5,7),16);
	var r2 = parseInt(c2.substring(1,3),16);
	var g2 = parseInt(c2.substring(3,5),16);
	var b2 = parseInt(c2.substring(5,7),16);
	return 'rgb(' + parseInt((r1+r2)/2) + ',' + parseInt((g1+g2)/2) + ',' + parseInt((b1+b2)/2) + ')';
}