jQuery(document).ready(function() {
	jQuery('#thumb, #start-race, .register, .login').fancybox({
		'autoScale'		: false,
		'transitionIn'	: 'elastic',
		'transitionOut'	: 'elastic',
		'speedIn'		: 600,
		'speedOut'		: 200,
		'width'			: 935,
		'height'		: 606,
		'padding'		: 0
	});
	
	// If we know that a url was passed as a hashtag, go ahead and open the overlay
	var hash = '#snail-race-url=';
	if (location.href.indexOf(hash) >= 0) {
		var loc = location.href.substring(location.href.indexOf(hash)+hash.length);
		jQuery('#snail-race-widget .register').attr('href', loc).trigger('click'); // Reset the url in case it was passed.
	}
	
	jQuery('#snail-race-widget .popup').live('click', function() {
		window.open(this.href, this.title, "location=0,width=600,height=800,scrollbars=yes,resizable=yes")
		return false;
	});
	
	// Try to implement a pngfix.
	try { DD_belatedPNG.fix('#iw, img'); } catch(e) {}
});
