var Globals = {
	
	CreateOverlay : function ( overlayId ) {
		if ( $( overlayId ) == null ) {
			
			div = new Element ( 'div', {
					'id' : overlayId
				}
			);
			
			$('doc_body').insert(div).down();
		}
	},

	ShowOverlay : function() {
		var overlayId = 'overlay';
		
		this.CreateOverlay( overlayId );
		
		$(overlayId).style.display = 'block';
		$(overlayId).style.position = 'fixed';
	},
	
	HideOverlay : function() {
		var overlayId = 'overlay';
		if ( $( overlayId ) != null ) {
			$(overlayId).style.display = 'none';
		}
	},
	
	CreateHiddenDiv : function () {
		id = "divhidden"
		if  ( $(id) == null ) {
			div = new Element ( 'div' );
			div.id =id;
			
			$('doc_body').insert(div).down();
		}
		
		return id;
	},
	
	CreateOverlayBox : function ( boxId ) {
		this.ShowOverlay();
		
		if  ( $(boxId) == null ) {
			div = new Element ( 'div' );
			div.className = "overlaybox";
			div.id = boxId+'-box';
			
			divBody = new Element ( 'div' );
			divBody.id = boxId;
			divBody.className = "body";
			
			div.insert( divBody ).down();
			
			/*drag = new Draggable( div ,{
				'handle': 'move',
				'starteffect': false,
				'endeffect': false
			});*/
			
			document.body.insert(div).down();
		}
		
		return div;
	},
	
	PosOverlayBox : function ( boxId ) {
		//$(boxId+'-box').style.left = (Element.getDimensions( document.body ).width/2 - Element.getDimensions( boxId+'-box' ).width/2)+'px';
		
		//$(boxId+'-box').style.top = (Element.getDimensions( document.body ).height/2 - Element.getDimensions( boxId+'-box' ).height/2-100)+'px';
		if ( $(boxId+'-box') ) {
			if(typeof window.innerHeight != 'undefined') {
				$(boxId+'-box').style.top = 
	                 Math.round(document.viewport.getScrollOffsets().top + 
	                 ((window.innerHeight - $(boxId+'-box').getHeight()))/2)+'px';
				$(boxId+'-box').style.left = 
	                 Math.round(document.viewport.getScrollOffsets().left + 
	                 ((window.innerWidth - $(boxId+'-box').getWidth()))/2)+'px';
	       } else {
	    	  
	    	   $(boxId+'-box').style.top = 
	                 Math.round(document.viewport.getScrollOffsets().top + 
	                 (($$('body')[0].clientHeight - $(boxId+'-box').getHeight()))/2)+'px';
	            $(boxId+'-box').style.left = 
	                 Math.round(document.viewport.getScrollOffsets().left + 
	                 (($$('body')[0].clientWidth - $(boxId+'-box').getWidth()))/2)+'px';
	       }
		}
	},
	
	HideOverlayBox : function ( boxId ) {
		this.HideOverlay();
		
		Event.stopObserving( document, 'scroll' );

		$(boxId+'-box').style.display = "none";
	},
	
	ShowOverlayBox : function ( boxId ) {
		Event.observe(document, 'scroll', function() {
			Globals.PosOverlayBox( boxId );
		});

		
		$(boxId+'-box').style.display = "block";
	}
	
}