//delay plugin //
jQuery.fn.delay = function(time, callback)
{
    // Empty function:
    jQuery.fx.step.delay = function(){};
    // Return meaningless animation, (will be added to queue)
    return this.animate({delay:1}, time, callback);
}

// this array stores the frameHeight values for each menu item //
var menuHeights = [360, 485, 315, 475, 250];
var menuWidths = [325, 325, 325, 325, 400];
			
// am I loggeg in? //
var loggedIn = false;

jQuery(function()
{			
	loggedIn = jQuery('body').hasClass('logged-in');
	
	// set up menus //
	jQuery('.menu-bar a.mnu').each(function(i)
	{
		if (loggedIn && i == 3) { return;}
		var el = jQuery(this);
		var left = Math.round(el.offset().left - 150);
		if (i == 4) left -= 130; // share this is bumped over a bit //
		el.fancybox({left:left, frameHeight:menuHeights[i], frameWidth:menuWidths[i] , top:-20, callbackOnClose:fancybox_onclose});
	});
	
	// thumb overlays //
	jQuery('.post-thumb').mouseenter(function(){ jQuery(this).find('span').css('visibility','visible'); }); 
	jQuery('.post-thumb').mouseleave(function(){ jQuery(this).find('span').css('visibility','hidden'); } );
	
	// login requested?? //
	if (window.location.search.match(/^\?login$/)) try{jQuery('.menu-bar a.mnu').eq(3).click();} catch(ignore){}
});

// close a fancybox window via code //
function closeMenuWindow(js)
{
	if (js) jQuery('#fancy_outer').data('js', js);
	jQuery.fn.fancybox.close();
}

// called from the IFRAMEs to dynamically adjust their
// height based on content. //
function setMenuHeight(h)
{
	jQuery('#fancy_outer').animate({height:h + 5}, 200);
}

function fancybox_onclose()
{
	var el = jQuery('#fancy_outer'); 
	if (el.data('js'))
	{
		var js = el.data('js');
		el.removeData('js');
		eval(js);
	}
	window.focus();
}
