  function getPageSize() { //as seen in so many api's
			var xScroll, yScroll;
			if (window.innerHeight && window.scrollMaxY) {	
				xScroll = window.innerWidth + window.scrollMaxX;
				yScroll = window.innerHeight + window.scrollMaxY;
			} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
				xScroll = document.body.scrollWidth;
				yScroll = document.body.scrollHeight;
			} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
				xScroll = document.body.offsetWidth;
				yScroll = document.body.offsetHeight;
			}
			var windowWidth, windowHeight;
			if (self.innerHeight) {	// all except Explorer
				if(document.documentElement.clientWidth){
					windowWidth = document.documentElement.clientWidth; 
				} else {
					windowWidth = self.innerWidth;
				}
				windowHeight = self.innerHeight;
			} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
				windowWidth = document.documentElement.clientWidth;
				windowHeight = document.documentElement.clientHeight;
			} else if (document.body) { // other Explorers
				windowWidth = document.body.clientWidth;
				windowHeight = document.body.clientHeight;
			}	
			// for small pages with total height less then height of the viewport
			if(yScroll < windowHeight){
				pageHeight = windowHeight;
			} else { 
				pageHeight = yScroll;
			}
			// for small pages with total width less then width of the viewport
			if(xScroll < windowWidth){	
				pageWidth = xScroll;		
			} else {
				pageWidth = windowWidth;
			}
			arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight);
			return arrayPageSize;
		};

  function setoverlay(timeOut){    
      setTimeout(function() {
        var arrPageSizes = getPageSize();
        $('#overlay').width(arrPageSizes[0]);
		    $('#overlay').height(arrPageSizes[1]);
      }, timeOut);		
  }

  function showpopup(){
    stopjwplayers();
    $('#overlay').show();
    $('#popup').show();
  }
  
  function hidepopup(){
    $('#overlay').hide();
    $('#popup').hide();
  }
  
  function stopjwplayers(){
    try{
      player1 = document.getElementById('videoplayer');            
      player1.sendEvent("PLAY","false");      
    }catch(e){}
    try{
      player2 = document.getElementById('audioplayer');
      player2.sendEvent("PLAY","false");
    }catch(e){}   
  }
  
//resize overlay on window resize
  $(window).resize(function() {
    setoverlay(0);
  });
  $(function(){
    //delay 1000ms to give flash content enough time to size itself 
    setoverlay(1000);
    $('#overlay').hide();
  });
  
  
