/**
* Lightbox
*
* This libary is used to create a lightbox in a web application.  This library
* requires the Prototype 1.6 library and Script.aculo.us core, effects, and dragdrop
* libraries.  To use, add a div containing the content to be displayed anywhere on 
* the page.  To create the lightbox, add the following code:
*
*	var test;
*	
*	Event.observe(window, 'load', function () {
*		test = new Lightbox('idOfMyDiv');
*	});
*	
*	Event.observe('lightboxLink', 'click', function () {
*		test.open();
*	});
*
*	Event.observe('closeLink', 'click', function () {
*		test.close();
*	});
*     
*/

var state = 0;
var Lightbox = Class.create({
	open : function () {
		if (state == 0) {
			
			this._fade('open', $("bg_fade"));
			state=1;
		}
		
	},
	
	close : function () {
			
		if (state == 1) {
			
			this._fade('close', $("bg_fade"));
			state = 0;
		}
		
	},
	
	_fade : function fadeBg(userAction,whichDiv){
		var d = document.getElementById('bg_fade');
		if(userAction=='close'){
			
			
			
			
			d.style.visibility = "hidden";
			d.style.block ="none";
			
			
		}else{
			d.style.block ="display";
			d.style.visibility = "visible";
			
		}
	},
	
	_makeVisible : function makeVisible(){
		$("bg_fade").style.visibility="visible";
	},

	_makeInvisible : function makeInvisible() {
		$("bg_fade").style.visibility="hidden";
	},

	_showLayer : function showLayer(userAction){
		$(userAction).style.display="block";
	},
	
	_hideLayer : function hideLayer(userAction){
		$(userAction).style.display="none";
	},
	
	
	
	initialize : function() {
		
		if($('bg_fade') == null) {
			alert("bg_fade is null");
			var screen = new Element('div', {'id': 'bg_fade'});
			document.body.appendChild(screen);
		}
		
	}
});

