/*
HoverWin
Coded by Nathan Fitzgerald
www.altiventure.com
*/

jQuery(document).ready(function() {	
	
	// only show the hoverad if cookie is not set
	if ( !jQuery.cookie("hover") ) {
		
		// put in the #id of the div to display, and the delay in milliseconds
		setTimeout( function() { launchModalWindow('#hover-dialog') }, 2000 ); 
		
		// show hoverad only once this session
		jQuery.cookie( "hover", "1" ); 
		
		// show hoverad only once every 7 days
		//jQuery.cookie("hover", "1", { expires: 7 });
	}
	
	//if close button is clicked
	jQuery('.hover-window .hover-close').click(function (e) {
		e.preventDefault();
		jQuery('#hover-mask, .hover-window').hide();
	});
});

function launchModalWindow(id) {	

		//Get the screen height and width
		//var maskHeight = $(document).height();
		//var maskWidth = $(window).width();
	
		//Set height and width to mask to fill up the whole screen
		// Use this to make the rest of the page fade out
		//$('#mask').css({'width':maskWidth,'height':maskHeight});

		//transition effect for the mask
		jQuery('#hover-mask').fadeIn(0);	
		jQuery('#hover-mask').fadeTo("slow",0.8);	
	
		//Get the window height and width
		var winH = jQuery(window).height();
		var winW = jQuery(window).width();
              
		//Set the popup window to center
		jQuery(id).css('top',  winH/2-jQuery(id).height());
		jQuery(id).css('left', winW/2-jQuery(id).width()/2);

		// Override popup window to user-defined placement
		jQuery(id).css('top', 44);
		jQuery(id).css('left', winW/2-jQuery(id).width()/2 - 60);
		
		//transition effect for the hover window
		jQuery(id).fadeIn(1000); 
}