$(document).ready(function() {

	var tempImage;
	var bgHeight;
	var bgWidth;
	
	setTimeout(function() {
		$('#header h1 a').ifixpng();	
	}, 40);
	
	$.ifixpng('/i/pixel.gif');
	$('#extranetFormSubmit').ifixpng();
	$('#backstageFeature').ifixpng();
	
	// Set up animation effect for link rollovers
			
	$('.blurbLink2 > .highlighter').each(function(){
		$(this).css({
			display: 'block',
			position: 'absolute',
			top: '2px',
			left: '0px',
			width: '0px',
			height: String($(this).parent().height() - 4)+'px',
			//height: '16px',
			backgroundColor: '#963',
			opacity: 1
		});
	});
	
	$('.blurbLink2 > a').hover(
		function() {
			$(this).css({backgroundPosition: '6px 50%'}).stop().animate({
				paddingLeft: '26px'
			}, 'fast', 'easeOutBounce')
			.parent().find('.highlighter').stop().css({opacity: '1', height: String($(this).parent().height() - 4)+'px'}).animate({
				width: ($(this).width() + 50)+'px',
				height: String($(this).parent().height() - 4)+'px',
				opacity: 0.2
			}, 'medium', 'easeInOutBounce' );
		},
		function() {
			$(this).css({backgroundPosition: '2px 50%'}).stop().animate({
				paddingLeft: '16px',
				paddingRight: '4px'
			}, 'medium', 'easeInOutBack')
			.parent().find('.highlighter').stop().animate({
				width: '0px',
				height: String($(this).parent().height() - 4)+'px',
				opacity: 0
			}, 'fast');
		}
	);
	
	
		
	//
	// Appending div for bg image so we can fade it in
	//
	
	// Determine height to set bg image to
	if (typeof bgURL != 'undefined')
	{
		($(document).height() > $(window).height()) ? bgHeight = $(document).height() : bgHeight = $(window).height();
		($(document).width() > $(window).width()) ? bgWidth = $(document).width() : bgWidth = $(window).width();
		
		//alert('$(document).height() = ' + $(document).height() + ',  $(window).height() = ' + $(window).height() + ', bgHeight = ' + bgHeight );
		//alert('$(document).width() = ' + $(document).width() + ',  $(window).width() = ' + $(window).width() + ', bgWidth = ' + bgWidth );
		
		(typeof bgColor != 'undefined') ? bgColor = bgColor : bgColor = 'transparent';
		
		$('#contentWrapper').append('<div id="bgImage"></div>').find('#bgImage').hide().css({
			position: 'absolute',
			zIndex: '0',
			width: '100%',
			//width: bgWidth + 'px',
			height: bgHeight+'px',
			//backgroundColor: 'transparent',
			backgroundColor: bgColor,
			backgroundImage: 'url('+ bgURL +')',
			backgroundPosition: '50% 0',
			backgroundRepeat: 'no-repeat',
			top: '0px',
			left: '0px'
		}).hide();
		
		// use image object to ensure bg image is loaded before fading in
		tempImg = new Image();
		$(tempImg).load(function () {
			$('#bgImage').css({  }).fadeIn(1000);
		}).error(function () {
			// notify the user that the image could not be loaded
		});
		$(tempImg).attr('src', bgURL);
		
	}
	
	window.onresize = function () {
		$('#bgImage').css({ display: 'none' });
		($(document).height() > $(window).height()) ? bgHeight = $(document).height() : bgHeight = $(window).height();
		($(document).width() > $(window).width()) ? bgWidth = $(document).width() : bgWidth = $(window).width();
		
		$('#bgImage').css({
			height: bgHeight+'px',
			//width: bgWidth+'px',
			display: 'block'
		});
		
	}
	
	
});
