

//centering popup  
function centerPopup(){  
//request data for centering  
var windowWidth = document.documentElement.clientWidth;  
var windowHeight = document.documentElement.clientHeight;  
var popupHeight = $("#msgbox").height();  
var popupWidth = $("#msgbox").width();  
//centering  
$("#msgbox").css({  
"position": "absolute",  
"top": windowHeight/2-popupHeight/2,  
"left": windowWidth/2-popupWidth/2  
});  
 
  
} 










$(document).ready(function(){
    
        $(document).bind("touchmove",function(event){
    event.preventDefault();
    });
	/*
		adjust's top position of message box when browser is being scrolled 
		better if default_position is equal to the msgbox style default top position
		anyway you can modify it accordding what your site needs
	*/
	var default_position = 250;
	$(window).scroll(function(){
		$('#msgbox').animate({top:$(window).scrollTop()+default_position+"px" },{queue: false, duration: 350});  
	});							
									
	$("#DimBackground").css("height", $(document).height());
	
	//When the link that triggers the message is clicked, display DimBackground and fadeIn msgbox...
	$(".show").click(function(){
		$("#DimBackground").css({'display':'block'});                
		$("#msgbox").fadeIn();
                centerPopup();
		return false;
	});
	
	//When the message box is closed, hide DimBackground and fadeOut msgbox...
	$(".close").click(function(){
		$("#DimBackground").css({'display':'none'});
		$("#msgbox").fadeOut();
		return false;
	});

});

//adjust's height of overlay to fill screen when browser gets resized  
$(window).bind("resize", function(){
	$("#DimBackground").css("height", $(window).height());
});





