
 var reloadpage=0;
 function reloadthepage () {
   reloadpage=1;
 }
jQuery(function ($) {
	$("input.paper, a.paper").click(function (e) {
		e.preventDefault();	
	  openpaper();
  });  
});    
    
function openpaper ()  {

	var PAPER = {
		container: null,
		open: function (d) {
			var self = this;
			self.container = d.container[0];
			d.overlay.fadeIn('slow', function () {
			  d.container.animate({top: "-800px"},1); 
				$("#paper-modal-content", self.container).show();
				d.container.animate(
				{top: "0px" , height: ['toggle','swing']},
				1000,	function () {
						$("div.close", self.container).show();
					}
				);
			})
		},
		close: function (d) {
			var self = this;
			d.container.animate(
				{top:"-" + (d.container.height() + 20)},
				500,
				function () {
				  d.overlay.fadeOut('slow', function () {
  					self.close(); // or $.modal.close();
  					$.get('askreload.php?sec='+securecode,function(data){
  					  window.clearInterval(globalinterval);  
              if (typeof repeat != 'undefined') {
                window.clearInterval(repeat);
                repeat = 0;
              }
              if (managetoilete == true) {
                opendoor(activetoiletenum);
                activetoiletenum="";
              } 
              if (data=="1") {
                window.location.href=rebuildurl(window.location.href);
              } else if (data=="2") {
                updatescreen();
              }
            });
  				})
				}
			);
		}
	};
  $("#paper-modal-content").modal({
			overlayId: 'paper-overlay',
			containerId: 'paper-container',
			closeHTML: '<div class="close"><a href="#" class="simplemodal-close"><img src="images/x.png" width="25" height="29" border="0" /></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</div>',
			minHeight:80,   
			opacity:65, 
			position:['0',],
			overlayClose:true,
			onOpen:PAPER.open,
			onClose:PAPER.close
		}); 
 
}

