/*******************************************************************************
On page load.
*******************************************************************************/

$(function()
{	
	// LightBox		
	var imgPath = '/images/layout/lightbox/';
	$('.lightBox a').lightBox({
		imageLoading: imgPath + 'loading.gif',
		imageBtnClose: imgPath + 'close.gif',
		imageBtnPrev: imgPath + 'prev.gif',
		imageBtnNext: imgPath + 'next.gif',
		imageBlank: imgPath + 'blank.gif',
		txtImage: '',
		txtOf: ' / '
	});	
		
	// IE 6 specific...
	if ($.browser.msie && parseInt($.browser.version) <= 7)
	{		
		$('[src$=.png], div').ifixpng();
		$('.sectionNav').css({'float': 'none'});
	}
	
	
	// Popup
	$('#popup-mask')
		.css({'opacity': 0.7})
		.click(closePopup);
		
	// Bind popup function to href
	$('.popup-link').each(function()
	{
		var $t = $(this);
		$t.attr('href', "javascript:popup('"+ $t.attr('href') +"');"); 
	});	
});

// Popup for notifications
var popup = function(url)
{	
	var $p = $('#popup'),
		$w = $(window);	 
	
	// Show mask
	$('#popup-mask')
		.css({'opacity': 0})
		.show()
		.fadeTo(250, 0.7);
	
	// Bind url
	$('.accept', $p).attr('href', url);
		
	// Position popup	
	$p.css({
		'left': $w.width() / 2 - $p.width() / 2,
		'top': $w.height() / 2 - $p.height() / 2,
		'opacity': 0
	}).show().fadeTo(250, 1);
};

var closePopup = function()
{
	$('#popup, #popup-mask').fadeTo(250, 0, function()
	{
		$('#popup, #popup-mask').hide();
	});		
};

