function dn(){}

// This Creates the Popup, setting size/location
// It is triggered by clicking a thumbnail in the popup
function DialogOverlay(content, 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' }).hide();
	this.dialog = new Element('div', { 'class': 'popup' }).hide();
	new Ajax.Updater(this.content, '/content/themes/marksteelephoto/popup.php');


	// 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) });
	
	// Insert the elements into the DOM
	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();
	this.dialog.hide();
}

// This Initially Creates the Popup, setting size/location
// It is triggered by clicking a thumbnail in the popup
DialogOverlay.prototype.show = function(filename, filenum, IMGwidth, IMGheight) {
	urlTotal = '/content/themes/marksteelephoto/popup.php?filename=' + filename + '&filenum=' + filenum + '&width=' + IMGwidth + '&height=' + IMGheight;
	new Ajax.Updater(this.dialog, urlTotal);
	
		var DIVwidth = (IMGwidth / 2) + 14;
		var DIVheight = (IMGheight / 2) + 14;
		var newEffect2 = new Effect.Morph(this.dialog, {style:'background-position:'+DIVwidth+'px '+DIVheight+'px', duration:0});
	
		var TOTwidth = IMGwidth + 328;
			var TOTheight = IMGheight + 54;
			var TOTmarg = TOTwidth / 2;
			var newEffect = new Effect.Morph(this.dialog, {style:'width:'+TOTwidth+'px; height:'+TOTheight +'px; margin-left:-'+TOTmarg +'px;', duration:1.0});
			
	new Effect.Appear(this.overlay, { duration: 0.5,  to: 0.85 });
	new Effect.Appear(this.dialog, { duration: 1.5,  to: 1 });
	
	this.overlay.setStyle({ height: document.body.getHeight() + 'px' });
	
	return this;
};

// This Updates the Main Image & Size of the Popup
// It is triggered by clicking a thumbnail in the popup
DialogOverlay.prototype.Update = function(fileSrc, IMGwidth, IMGheight) {
		
		var DIVwidth = (IMGwidth / 2) + 14;
		var DIVheight = (IMGheight / 2) + 14;
			var newEffect2 = new Effect.Morph(this.dialog, {style:'background-position:'+DIVwidth+'px '+DIVheight+'px', duration:0, delay:1.5});
		
		new Effect.Fade("popupImage", {duration: 1.0, afterFinish: function(effect){
			d = effect.element;
			d.src = fileSrc;
			d.style.width = IMGwidth + "px";
			d.style.height = IMGheight + "px";
			new Effect.Appear('popupImage', { duration: 1.0, queue: 'end', delay:1.0 });
			var TOTwidth = IMGwidth + 328;
			var TOTheight = IMGheight + 54;
			var TOTmarg = TOTwidth / 2;
			var newEffect = new Effect.Morph(this.dialog, {style:'width:'+TOTwidth+'px; height:'+TOTheight +'px; margin-left:-'+TOTmarg +'px;', duration:1.0});
			
		}.bind(this)
	});
	return this;
};

// This Hides the Popup
DialogOverlay.prototype.hide = function(event) {
	this.dialog.hide();
	this.overlay.hide();
	return this;
};

