window.$mega = { 'over': false, 'timer': false };

$( function () {

		window.$mega.el = $('#shop-mega');

// 		$('#shop-categories a').mouseover ( function() {
// 				megaShow ( $(this).attr('href') );

// 				var s = '';
// 				s +=  '<div id="shop-mega-content">';
// 				s += '<h1>' +  $(this).find('span').html() + '</h1>';
// 				s += '</div>';

// 				window.$mega.el.html(s);
// 				megaOver();
// 			});

		$('#shop-categories a').mouseout ( function() {
				megaOut();
			});

		window.$mega.el.mouseover ( function() {
				megaOver();
			});

		window.$mega.el.mouseout ( function() {
				megaOut();
			});

	});

function megaShow( uri ) {
	// load in html for this mega.

	// cache for redisplay
	window.$mega.el.show();

	megaOver();
}

function megaOut() {
	window.$mega.over = false;
}

function megaOver() {
	window.$mega.over = true;
	clearInterval ( window.$mega.timer );
	window.$mega.timer = setInterval ( 'megaClear();', 1000 );
}

function megaClear() {
	if ( ! window.$mega.over ) {
		clearInterval ( window.$mega.timer );
		window.$mega.el.fadeOut( 250 );
	}
}

