window.doReload = false;
window.callBack = null;
jQuery(document).ready(function(){
	$("#saturnLogo,#adventures_powered").hover(
	      function () {
	        $('#build_learn').css('display','block');
			$("#build_learn").hover(
			   function () {}, 
			      function () {
					$('#build_learn').css('display','none');
			      }
			    );
	      },function () {}
	    );
	
	jQuery('.modal').livequery('click',function(event){	
		var h = $(this).metadata('class','params').h;
		var w = $(this).metadata('class','params').w;
		modalCall($(this).attr('href'),h,w);
		return false;
	});	
	$(window).load(function() {
		
		if (window.location.hash!='') window.location.hash = window.location.hash;
	});
});
function closeModalCallBack() {
	$.modal.close();
	$('object,embed').css('visibility','visible');
	if (window.doReload == true) reloadPage();
}
function reloadPage() {
	window.location.reload();
}
function modalCall(url,h,w) {
	//iframe.id = new Date().getTime();
	var iframe = document.createElement('iframe'); 
	$(iframe).css('border','0');
	$(iframe).attr('frameborder','no').attr('id',new Date().getTime()).attr('src',url).css({width:(w+'px'),height:(h+'px'),border:'0',margin:'0 auto 0 auto',display:'block'});
	$(iframe).modal({containerCss:{ background:'#fae38c',width:(w)+'px',height:(h)+'px',marginLeft:(Math.round(w/2*-1))+'px'}, overlay:60,
	onClose:function(){
		$(iframe).remove();
		$('object,embed').css('visibility','visible');
		$.modal.close();
	},onShow:function(){
		$('object,embed').css('visibility','hidden');
		$(iframe).load(function() {
		     this.contentWindow.callBack = reloadPage;
			 this.contentWindow.cancelCallBack = closeModalCallBack;
		 });
		$('#modalOverlay').bind('click',function(){
			if (window.doReload == true) reloadPage();	
			$('object,embed').css('visibility','visible');		
			$(iframe).remove();
			$.modal.close();
		})
	}});
}