var Lightbox = Class.create({
	open : function (content) {
		this._fade('open', this.container, content);
		this._centerWindow(this.container);
	},
	
	close : function () {
		this._fade('close', this.container, this._current);
	},
	
	_resize : function () {
		
	},
	
	_fade : function fadeBg(userAction,elem,content){
		if(userAction=='close'){
			$(elem).style.display="none";
			$("lbbg").style.visibility="hidden";
			$$(".lb_content").each(function(elmt) { elmt.hide(); });
			
			//Show page elements
            $$("object").each(function(elmt) { elmt.show(); });
			$$("embed").each(function(elmt) { elmt.show(); });
			$$("select").each(function(elmt) { elmt.show(); });
		}else{
			$(elem).style.display="block";
			$("lbbg").style.visibility="visible";
			$$(".lb_content").each(function(elmt) { elmt.hide(); });
			$(content).show();
			
			//Hide page elements
			$$("object").each(function(elmt) { elmt.hide(); });
			$$("embed").each(function(elmt) { elmt.hide(); });
			$$("select").each(function(elmt) { elmt.hide(); });
		}
	},
	

	_centerWindow : function centerWindow(element) {
	    
		if(typeof window.innerHeight != 'undefined' && typeof document.body.clientWidth == 'undefined'){
    		//Non-IE
    		myWidth = window.innerWidth;
    		myHeight = window.innerHeight;
		} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight )) {
    		//IE 6+ in 'standards compliant mode'
			myWidth = document.documentElement.clientWidth;
    		myHeight = document.documentElement.clientHeight;
  		} else if( document.body.clientWidth && typeof window.innerHeight == 'undefined' ) {
    		//IE 4 compatible
    		myWidth = document.body.clientWidth;
    		myHeight = document.body.clientHeight;
  		}  
  		$("lbbg").style.width=myWidth;
		$("lbbg").style.height=myHeight;
		
		var windowHeight = parseFloat($(element).getHeight())/2; 
		var windowWidth = parseFloat($(element).getWidth())/2;
		
		if(typeof window.innerHeight != 'undefined'){
			$(element).style.top = Math.round(document.body.offsetTop + ((window.innerHeight - $(element).getHeight()))/2)+'px';
			$(element).style.left = Math.round(document.body.offsetLeft + ((window.innerWidth - $(element).getWidth()))/2)+'px';
		} else {
			$(element).style.top = Math.round(document.body.offsetTop + ((document.documentElement.offsetHeight - $(element).getHeight()))/2)+'px';
			$(element).style.left = Math.round(document.body.offsetLeft + ((document.documentElement.offsetWidth - $(element).getWidth()))/2)+'px';
		}
		if(parseFloat($(element).style.top)<=36){$(element).style.top='36px';}
		if(parseFloat($(element).style.left)<=36){$(element).style.left='36px';}
		
		
	},
	
	initialize : function(containerDiv) {
		this.container = containerDiv;
		if($('lbbg') == null) {
			var screen = new Element('div', {'id': 'lbbg'});
			document.body.appendChild(screen);
			this._centerWindow(containerDiv);
		}
		this._fade("close", this.container);
	}
	
	

});

