/*jQuery*/

/***************************************************************
* Created By: Aaron Tennyson @ BT Solutions, LLC             *
* Date:  March 11, 2010                                                                *
* Copyright 2010 BT Solutions, LLC                                          *
* Visit our Website at http://btsolutionsllc.com                        *
***************************************************************/

//set flag to determine if overlay is currently showing
// 0 = false 1 = true
var stateOf = 0;

//starts the overlay 
function startOverlay(){
 
 if(stateOf == 0){
  $("#pageOverlay").css({"opacity": "0.55"});
  $("#pageOverlay").delay(1000).fadeIn("slow");
  $("#promo").delay(1000).fadeIn("slow");
  
  stateOf = 1;
 }
}

//closes the overlay
function exitOverlay(){
 
 if(stateOf == 1){  
  $("#pageOverlay").fadeOut("slow");
  $("#promo").fadeOut("slow");
  
  stateOf = 0;
 }
}

//center the promo box in browser window
function centerPromo(){
 
 var browserWidth = document.documentElement.clientWidth;
 var browserHeight = document.documentElement.clientHeight;
 var promoHeight = $("#promo").height();
 var promoWidth = $("#promo").width();
 
 $("#promo").css({"position": "absolute","top": (browserHeight / 2) - (promoHeight / 2),"left": (browserWidth / 2) - (promoWidth / 2)});
   
}


//events are handled with jQuery awesomeness 
$(document).ready(function(){
 
 //start the overlay when document is loaded
 startOverlay();
 centerPromo();
  
 //start the overlay with a button event
 $("#button").click(function(){
 startOverlay(); // comment out this line
 centerPromo(); //  and this line if you don't want the overlay to begin when the document is ready  
 });
    
 //this function closes the overlay when user clicks "close"
 $("#closeBtn").click(function(){
  exitOverlay();
 });
 
 //this function closes the overlay when user clicks outside the message area
 $("#pageOverlay").click(function(){
  exitOverlay();
 });
 

});
