/*
jQUERY
--------------------------------------------------*/
$(document).ready(function() {
		
	$('a[href=#]').click(function(e) {
		e.preventDefault();
		
		alert('OH NOES!\nThe page where "' + $(this).text() + '" should take you is still in development.');
	});
	
	// FAQ
	$('body#faq dt').wrapInner('<a href="#"></a>');
	$('body#faq dt a').toggle(
		function() {
			$(this).addClass('open');
			$(this).parent().next('dd').fadeIn('fast');
			
			return false;
		},
		function() {
			$(this).removeClass('open');
			$(this).parent().next('dd').fadeOut('fast');
			
			return false;
		}
	);
	
	// IMAGE ZOOM
	$('<div id="expandMe"><img src="/assets/images/UILoader.gif" class="UILoader" height="32" width="32" /></div>').appendTo('body').css({
		left: -9999,
		top: -9999
	});
	
	$('a.zoomImage').click(function() {
		$this = $(this);
		
		$('div#expandMe').css({
			left: '50%',
			top: '50%'
		});
		$.BlockUI();
		
		$('<img class="preload" />').attr('src',$(this).attr('href')).load(function() {
			$img = $(this);
			
			$('div#expandMe').empty().append($img).animate({
				height: $img.height() + 20,
				marginLeft: (($img.width()/2)*-1)-20,
				marginTop: (($img.height()/2)*-1)-30,
				width: $img.width()
			},
			function() {
				$img.removeClass('preload').after('<a href="#" id="expandMe-close">Close Window</a>');
			});
			
			
		});
		
		return false;
	});
	
	$('div#UIBlock,a#expandMe-close').live('click',function() {
		$.unBlockUI();
		$('div#expandMe').empty().css({
			height: 40,
			left: -9999,
			marginLeft: -40,
			marginTop: -40,
			top: -9999,
			width: 40
		});
		
		return false;
	});
		
});

/* BlockUI */
$.BlockUI = function() {
	$('<div id="UIBlock"></div>').css({
		background: '#000',
		height: '100%',
		left: 0,
		opacity: '0.75',
		position: 'fixed',
		top: 0,
		width: '100%',
		zIndex: 900
	}).appendTo('body');
	if ($.browser.msie && ($.browser.version < 7)) {
		$('div#UIBlock').css({
			position: 'absolute',
			top: $(window).scrollTop()
		});
	}
};

/* unBlockUI */
$.unBlockUI = function() {
	$('#UIBlock').fadeOut(100,function() {
		$(this).remove();
	});
};
