/**
 * Created by William Khoe
 * Date: Jan 9, 2010
 */

(function($, window, undefined){
	
$(document).ready(function(e)
{
	$('#main-nav').click(function(e)
	{
		e.preventDefault();
	});
	$('#selected-works a.description, #link-contact').overlay({
		fixed:false,
		top:0,
		mask:
		{
			color:'#000',
			loadSpeed:100,
			opacity:0.9
		},
		closeOnClick:false,
		onBeforeLoad:onOverlayBeforeLoad,
		onLoad:onOverlayLoad
	});
	
	$('.overlay .close').live('click', function(e)
	{
		e.preventDefault();
	});
});

function onOverlayBeforeLoad(e)
{
	$('html,body').animate({scrollTop : 0}, 100);
}

function onOverlayLoad(e)
{
	var $overlay = this.getOverlay();
	var $img = $overlay.find('.screenshot img[rel]');
	$img.each(function(i)
	{
		var $this = $(this);
		$this.attr('src', $this.attr('rel'));
		$this.removeAttr('rel');
	});
	
}
	
})(jQuery, this);
