// JavaScript Document
var winHeight = 0;
	var winWidth = 0;
	var docHeight = 0;
	var docWidth = 0;
var flashContainerWidth = 0;
var flashContainerHeight = 0;
var overlayAlpha = .95;
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').outerWidth();
		flashContainerHeight = $('#flash-module').outerHeight();
		
		$("div#overlay").css({'opacity' : 0,'top':0,'left':0,'height': $(document).height(),'width': $(window).width()}).fadeTo("2000",overlayAlpha,function()
			{
				
				$('#flash-module').css({'display':'block','left':($(window).width()/2-flashContainerWidth/2),'top':($(window).height()/2-flashContainerHeight/2)});
				$('#flash-module').css({'opacity':1});
				$('#mod-contents').append('<iframe src="/Products/User_demo/User_demo.htm" frameborder="1" scrolling="no" width="800" height="498"></iframe>');
				
			});
		return false;
	});
	
	// Respond to Resize and Scroll Events
	$(window).resize( function()
		{
			// resize overlay window and move weboffer  to new center
			$('div#overlay').css({'height': $(document).height(),'width': $(window).width()});
			$('#flash-module').css({'left':($(window).width()/2-$('#flash-module').outerWidth()/2),'top':($(window).height/2-$('#flash-module').height()/2) });
		});
	$(window).scroll(function()
		{
			$('#flash-module').css({'top': ($(document).scrollTop() + ($(window).height/2- $('#flash-module').outerHeight()/2))});
		});
});

