/**
 * Overlay Handler for i-concerts
 * @author Vincent Pouilley, inspired from Matthew Roper code
 */
 function DialogOverlay(content, classadd, container) {
 
	// Manage arguments and assign defaults,
	if (typeof container == 'undefined' ) container = document.body;
	if (null == (this.container = $(container))) throw("container is not valid");
 
	// Assign instance variables
	this.content = content;
//	this.overlay = new Element('div', { 'class': 'overlay' + classadd }).hide();
//	this.dialog = new Element('div', { 'class': 'dialog' + classadd }).hide();
	this.overlay = $('Overlay');
	this.overlay.className = 'overlay' + classadd;
	this.overlay.hide();
	this.dialog = $('ContentOverlay');
	this.NomClass = 'dialog' + classadd;
	this.dialog.hide();
	this.dialog.childElements().each(function(elem){
		elem.hide();
	});
//	this.closediv = new Element('div', { 'align': 'right', id: 'divOvlCloseDiv' });
//	this.closebutton = new Element('div', { 'class': 'overlayimgclose', 'align': 'right', id: 'divOvlCloseBtn' });
	this.closediv = $('divOvlCloseDiv');
	this.closediv.show();
	this.closebutton = $('divOvlCloseBtn');
	this.closebutton.show();
 
	// Hide the overlay when clicked. Ignore clicks on the dialog.
	Event.observe(this.overlay, 'click', this.hide.bindAsEventListener(this));
//	Event.observe(this.dialog, 'click',  function(event) { Event.stop(event) });
//	Event.observe(this.dialog, 'click',  this.hide.bindAsEventListener(this));
	Event.observe(this.closebutton, 'click',  this.hide.bindAsEventListener(this));
 
	// Insert the elements into the DOM
//	this.closediv.insert(this.closebutton);
//	this.dialog.insert(this.closediv);
	this.dialog.insert(this.content);
	this.container.insert(this.overlay);
	this.container.insert(this.dialog);
 
	// Content may have been hidden if it is embedded in the page
//	content.show();
	content.hide();
	this.dialog.hide();
}
 
DialogOverlay.prototype.show = function() {
	new Effect.Appear(this.overlay, { duration: 0.5,  to: 0.5 });
	this.dialog.className = this.NomClass;
	this.content.show();
	this.dialog.show();
//	this.overlay.setStyle({zIndex: '98', height: '1527px', width: '1059px', backgroundColor: 'rgb(255, 255, 255)'});
//	this.overlay.setStyle({zIndex: '98'});
//	this.dialog.setStyle({zIndex: '100', top: '240px', left:'360px'});
	return this;
};
DialogOverlay.prototype.hide = function(event) {
	new Effect.Fade(this.overlay, { duration: 0.5,  from: 0.5 });
	this.dialog.hide();
	this.content.hide();
//	this.overlay.hide();
	return this;
};
