var InfoBox = {
	
	enabled: false,
	
	init: function() {
		
		if ( this.enabled ) return;
		
		this.enabled = true;
		this.screen = null;
		this.container = null;
		
		this.build();
		
	},
	
	build: function() {
		
		var w = 785;
		var h = 520;
		
		this.screen = new Element( 'div' ).set( { 
			'styles': {
				'position': 'absolute',
				'display': 'none',
				'top': 0,
				'left': 0,
				'width': window.getScrollSize().x,
				'height': window.getScrollSize().y,
				'background': 'black',
				'opacity': 0.7,
				'z-index': 9000
			},
			'events': {
				'click': this.close.bind( this )	
			}
		} ).inject( document.getElement( 'body' ), 'top' );
		
		this.container = new Element( 'div' ).set( {
			'styles': {
				'position': 'absolute',
				'display': 'none',
				'top': ( ( window.getSize().y/2 ) - ( h/2 ) + window.getScroll().y ) - 40,
				'left': ( ( window.getSize().x/2 ) - ( w/2 ) + window.getScroll().x ) - 12,
				'width': w,
				'height': h,
				'background': 'white',
				'z-index': 9010,
				'padding': 8,
				'font-weight': 'bold',
				'font-size': 11,
				'color': '#535353',
				'text-align': 'left',
				'border': 'solid #cccccc 6px'
			}
		} ).inject( document.getElement( 'body' ), 'top' );
		
		this.iframe = new Element( 'iframe' ).set( {
			'src': 'about:blank',
			'width': w,
			'height': h,
			'frameborder': 0,
			'border': 0,
			'marginwidth': 0,
			'marginheight': 0,
			'scrolling': 'no',
			'styles': {
				'width': w,
				'height': h,
				'border': 'none',
				'overflow': 'hidden'
			}
		} ).inject( this.container );
		
		this.button = new Element( 'div' ).set( {
			'html': 'CLOSE',
			'styles': {
				'position': 'absolute',
				'top': 0,
				'right': 0,
				'padding': '0px 6px 4px 10px',
				'background': '#cccccc',
				'font-size': 14,
				'cursor': 'pointer'
			},
			'events': {
				'click': this.close.bind( this )	
			}
		} ).inject( this.container, 'top' );
		
	},
	
	open: function( url ) {
	
		if ( !this.enabled ) this.init();
		
		this.container.setStyle( 'display', 'block' );
		this.iframe.set( 'src', url );
		this.screen.setStyle( 'display', 'block' );
		
	},
	
	close: function() {
	
		this.container.setStyle( 'display', 'none' );
		this.iframe.set( 'src', 'about:blank' );
		this.screen.setStyle( 'display', 'none' );
	
	}
	
};

window.addEvent( 'load', InfoBox.init.bind( InfoBox ) );