﻿// -- Dialog / Slide show --

var dialogWidth = 900;
var dialogHeight = 480;

function dialog_setup(width, height)
{
	dialogWidth = width;
	dialogHeight = height;
}

function dialog_showStaticContent(content)
{
	TOOL.getDomElement("DialogMainTable_1_1").innerHTML = content;
}

// creates border and content tables if not available
function dialog_createContentTable()
{
	var container = TOOL.getDomElement("DialogContainer");

	// a 1px border around the dialog
	if ($get("DialogOuterBorder") == null)
	{
		var outerBorder = TOOL.createTable("DialogOuterBorder", 1, 1, "100%", "top");
		outerBorder.style.border = "none";
		outerBorder.style.width = dialogWidth + "px";
		outerBorder.style.height = dialogHeight + "px";
		outerBorder.height = dialogHeight;

		container.appendChild(outerBorder);	
	}

	// the actual content a 3x3 table
	if ($get("DialogMainTable") == null)
	{
		var content = TOOL.createTable("DialogMainTable", 3, 3, "100%", "top");
		//		content.setAttribute("style", "border-collapse:collapse; overflow:hidden; width:100%; height: " + dialogHeight + "px;")
		content.style.height = dialogHeight + "px";
		TOOL.getDomElement("DialogOuterBorder_0_0").appendChild(content);

		// set non corner cells
		TOOL.getDomElement("DialogMainTable_1_0").style.backgroundColor = "#ffffff";

		TOOL.getDomElement("DialogMainTable_0_1").style.backgroundColor = "#ffffff";		
		TOOL.getDomElement("DialogMainTable_1_1").style.backgroundColor = "#ffffff";		
		TOOL.getDomElement("DialogMainTable_2_1").style.backgroundColor = "#ffffff";

		TOOL.getDomElement("DialogMainTable_1_2").style.backgroundColor = "#ffffff";

		// add the rounded corners
		var cornerPic = document.createElement("img");
		cornerPic.setAttribute("src", "Images/SignalsInfo/top_left_corner.gif");
		
		var corner = TOOL.getDomElement("DialogMainTable_0_0");
		corner.style.height = "8px";
		corner.style.width = "8px"
		corner.appendChild(cornerPic);

		cornerPic = document.createElement("img");
		cornerPic.setAttribute("src", "Images/SignalsInfo/top_right_corner.gif");

		corner = TOOL.getDomElement("DialogMainTable_0_2");
		corner.style.height = "8px";
		corner.style.width = "8px"
		corner.appendChild(cornerPic);

		cornerPic = document.createElement("img");
		cornerPic.setAttribute("src", "Images/SignalsInfo/bottom_right_corner.gif");

		corner = TOOL.getDomElement("DialogMainTable_2_2");
		corner.style.height = "8px";
		corner.style.width = "8px"
		corner.appendChild(cornerPic);

		cornerPic = document.createElement("img");
		cornerPic.setAttribute("src", "Images/SignalsInfo/bottom_left_corner.gif");

		corner = TOOL.getDomElement("DialogMainTable_2_0");
		corner.style.height = "8px";
		corner.style.width = "8px"
		corner.appendChild(cornerPic);
	}
}

function dialog_show()
{
	var screenHeight = Sys.UI.DomElement.getBounds($get("mainContainer")).height;
	var screenWidth = Sys.UI.DomElement.getBounds($get("mainContainer")).width;

	var dialogBox = $get("ctl00_DialogBox");

	dialogBox.style.height = screenHeight + "px";
	dialogBox.style.display = "block";

	// container for the whole dialog window
	var test = $get("DialogContainer");
	if (test == null)
	{
		var container = document.createElement("DIV");
		container.style.position = "absolute";
		container.style.left = (screenWidth - dialogWidth) / 2 + "px";

		var scrolls = TOOL.getScrollXY();

		container.style.top = (scrolls[1] + 100) + "px";
		container.id = "DialogContainer";

		// add the container to the box
		dialogBox.appendChild(container);
	}
}

// shows the darken layer
function dialog_showLayer()
{
	var layer = $get("ctl00_DialogLayer");

	layer.style.display = "block";
	layer.style.height = "100%";
}

function dialog_hide()
{
	var layer = $get("ctl00_DialogLayer");

	layer.style.display = "none";

	$get("ctl00_DialogBox").innerHTML = "";
	$get("ctl00_DialogBox").style.display = "none";
}
