// JavaScript Document
var winHeight = 0;
	var winWidth = 0;
	var docHeight = 0;
	var docWidth = 0;
var flashContainerWidth = 0;
var flashContainerHeight = 0;
var overlayAlpha = .75;
var moduleHTML = '<div id="flash-module">';
moduleHTML += '<a href="#" class="closeBtn">close demo</a>';
	moduleHTML += '<div id="mod-contents">';
	
	moduleHTML += '</div>';
	moduleHTML += '</div>';
	


function getBrowserDims()
{
	winHeight = $(window).height();
	winWidth = $(window).width();
	docHeight = $(document).height();
	docWidth = $(document).width();
	
}

function closeAd()
{
	$('div#overlay').fadeOut('1500',function(e){
			$(this).remove();
											 
		});
	
	$('#flash-module').remove();
}

$(function(){
	
	getBrowserDims();
	$('a.demo-link').click( function(){
		$('body').append('<div id="overlay">&nbsp;</div>');
		$('body').append(moduleHTML);
		$('.closeBtn').live("click",function(){
				closeAd();
				return false;
			});
		flashContainerWidth = $('#flash-module').width();
		flashContainerHeight = $('#flash-module').height();
		$('#flash-module').css({'opacity':0,'left':(winWidth/2-flashContainerWidth/2),'top':(winHeight/2-flashContainerHeight/2)});
		$("div#overlay").css({'opacity' : 0,'top':0,'left':0,'height': docHeight,'width': docWidth}).fadeTo("2000",overlayAlpha,function()
			{
				
				$('#flash-module').css({'opacity':1});
				$('#mod-contents').append('<iframe src="/mm/cov/index.html" frameborder="1" scrolling="no" width="780" height="440"></iframe>');
				
			});
		return false;
	});
	
	// Respond to Resize and Scroll Events
	$(window).resize( function()
		{
			// resize overlay window and move weboffer  to new center
			getBrowserDims();
			$('div#overlay').css({'height':docHeight,'width':docWidth});
			$('#flash-module').css({'left':(winWidth/2-flashContainerWidth/2),'top':(winHeight/2-$('#flash-module').height()/2) });
		});
	$(window).scroll(function()
		{
			$('#flash-module').css({'top': ($(document).scrollTop() + (winHeight/2- flashContainerHeight/2))});
		});
});


