// #PLib::PLoad('PLib.Dom.Client.LightWindow.lightwindow');

var LightWindowInit = Class.create();

LightWindowInit.prototype = {
	initialize: function() {
		this.hideGalleryTab = true;
		Event.observe(window, 'load', this.bindToDocument.bindAsEventListener(this));
	},

	bindToDocument: function(event){
		this.lightWindow = new lightwindow({
			overlay : {
				opacity : 0.7,
				image : this.blackImage,
				presetImage : this.black70Image
			},
			ajaxLoadingImage: this.ajaxLoadingImage,
			hideGalleryTab: true
		});
		
		var myThis = this;
		var popups = $$('div.lightwindow_popup');

		popups.each(function(popup) {
			var form = popup.up('form');
			var show = form.select('[name=' + popup.id + '_show]').first().value;

			if(show)
			{
				myThis.lightWindow.activateWindow({
					id: popup.id
				});
			}
		});
	},
	
	openPopup: function(element) {
		var popup = $(element);
		this.lightWindow.activateWindow({
			href: '#' + popup.id
		});		
	},
	
	setAjaxLoadingImage: function(ajaxLoadingImage){
		this.ajaxLoadingImage = ajaxLoadingImage;
	},
	
	setBlackImage: function(blackImage){
		this.blackImage = blackImage;
	},
	
	setBlack70Image: function(black70Image){
		this.black70Image = black70Image;
	},
	
	setShowGalleryTab: function(){
		this.hideGalleryTab = false;
	}
}

var lightWindowInit = new LightWindowInit();