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': 'dialog' }).hide();

    this.overlay.style.height= document.body.scrollHeight + "px";
    
	// 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.style.display="block";
	this.dialog.hide();
}

DialogOverlay.prototype.show = function() {
	new Effect.Appear(this.overlay, { duration: 0.7,  to: 0.8 });
	this.dialog.show();
	this.dialog.style.top = getScrollY() + "px";
	return this;
};
DialogOverlay.prototype.hide = function() {
	this.dialog.hide();
	this.overlay.hide();
	return this;
};

function getScrollY() {
  scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    //scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    //scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    //scrOfX = document.documentElement.scrollLeft;
  }
  return scrOfY;
}

function setLink(link,to)
{
    var toElement = document.getElementById(to);
    toElement.href = link;
}

