
//**************************************************************************************
// Global Functions

function __closeDivPopup() {
	CDA.getDocBody().removeChild(CDA.find("popupOuterTable"));
	CDA.getDocBody().removeChild(CDA.find("popupScreen"));
} // end function


//**************************************************************************************
// Object:		DivPopup.  Used for popup layers
// Inherits:	n/a
DivPopup = function(w, h) {

	this.w = w;
	this.h = h;
	this.outerTable;
	this.contentCell;
	this.masterDiv;
	this.contentDiv;		
  	this.screen = new Screen("popupScreen", "white", "opaque50");  
	
} // end object

	DivPopup.prototype.show = function() {
		this.screen.show();
		this.createElements();	
		this.contentDiv.innerHTML = "";
		
	} // end method 
	
	DivPopup.prototype.addContent = function() {			
		CDA.getDocBody().appendChild(this.outerTable);	
	} // end method

	DivPopup.prototype.createElements = function() {

		// Create master layer with top nav and bottom gutter
		this.masterDiv = document.createElement("div");
		this.masterDiv.className = "master";
		this.masterDiv.style.width=this.w+"px";
		//this.masterDiv.style.height=h+"px";
		var topnavHtml = "<!-- Start nav top -->"
			+ "<table border=\"0\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border='1'>"	
			+ CDA.Html.rowStart
			+ "<td valign=\"top\" class=\"bg_blue\"><img src=\"images/spacer.gif\" border=\"0\" width=\"5\" height=\"7\" /></td>"
			+ "<td valign=\"top\" class=\"bg_blue\"><img src=\"images/spacer.gif\" border=\"0\" width=\"5\" height=\"7\" /></td>"
			+ "<td valign=\"top\" class=\"bg_blue\"><img src=\"images/spacer.gif\" border=\"0\" width=\"5\" height=\"7\" /></td>"
			+ CDA.Html.rowEnd
			+ CDA.Html.rowStart		
			+ "<td class\"bg_brown\"><img src=\"images/spacer.gif\" border=\"0\" height=\"1\" /></td>"
			+ "<td class\"bg_brown\" align=\"right\" valign=\"top\"><img src=\"images/popupTab.gif\" border=\"0\" /></td>"
			+ "<td class=\"bg_blue\" valign=\"top\" align=\"right\" width=\"65\">"
			+ "<div id='divClose'><a id='lnkClose' href=\"javascript:__closeDivPopup();\" class=\"smalllink font-color-white\">Close <img  id='imgClose' src='images/popupClose.gif' border='0'/></a> </div>"
			+ "</td>"
			+ CDA.Html.rowEnd	
			+ "</table>";
		
		
		var footerDiv = document.createElement("div");
		footerDiv.className = "footer bg_blue";
		
		// Create content layer setting width and height to 100%
		this.contentDiv = document.createElement("div");
		this.contentDiv.id = "popupContentDiv";
		this.contentDiv.className="content"
		this.contentDiv.style.width=this.w+"px";
		this.contentDiv.style.height=this.h+"px";
		this.contentDiv.style.overflow="auto";
		this.contentDiv.style.position="relative";
		
		// Create containing table, row and cell element
		this.outerTable = document.createElement("table");
		this.outerTable.id="popupOuterTable";
		this.outerTable.className="outer_table"
		this.outerTable.cellPadding = "0";
		this.outerTable.cellSpacing = "0";
		this.outerTable.border="0";
		
		var tblBody = document.createElement("tbody");
		var row = document.createElement("tr");
		this.contentCell = document.createElement("td");
		this.contentCell.align="center";
		this.contentCell.vAlign="center";
		
		
		row.appendChild(this.contentCell);					// Append TD to TR
		tblBody.appendChild(row);							// Append TR to TBODY
		this.outerTable.appendChild(tblBody)				// Append TBODY to TABLE
			
		this.masterDiv.innerHTML=topnavHtml;				// Write top nav
		this.masterDiv.appendChild(this.contentDiv);		// Append content div
		this.masterDiv.appendChild(footerDiv);				// Append footer	
		this.contentCell.appendChild(this.masterDiv);		// Append contentDiv to master
	} // end method 