/* modalFrame.js */

function DialogFrame (title, message) {
	this.title = title;
	this.message = message;

	this.load = function () {
		var doc = window.document;

		var style_maskOfFrame = "style=\" " +
			"visibility: hidden; " +
			"z-index: 98; " +
			"width: 100%; " +
			"height: 100%; " +
			"position: fixed; " + 
			"top: 0; " +
			"left: 0; " +
			//"background-color: #222; " +
			//"-moz-opacity: 0.5; " +
			"background: url('../img/modalFrame/bg_modalFrame_2.png') repeat-x repeat-y; " +
			/*"width: 100%; " +
			"height: 100%; " +*/
			"color: black; \"";
		
		var style_modalFrame = "style=\" " +
			"z-index: 99; " +
			"position: absolute; " +
			"background-color: #fcfcfc; " +
			//"-moz-opacity: 1.0; " +
			"border: solid 3px #013C72; " +
			/*"width: 300px; " +
			"height: 252px; " +*/
			"width: 500px; " +
			"height: 400px; " +
			"top: 50%; " +
			"left: 50%; " +
			/*
			"margin-left: -150px; " +
			"margin-top: -126px; " +
			*/
			"margin-left: -250px; " +
			"margin-top: -200px; " +
			"text-align: center; \"";
			
		var style_modalFrame_Header = "style=\" " +
			"z-index: 100; " +
			"margin: 0; padding: 2px 0 2px 0; " +
			"border-bottom: 2px solid #013C72; " +
			"background-color: #6A8DAD; " +
			"font-size: 1.1em; " +
			"font-weight: bold; " +
			"color: #fcfcfc; \"";
		
		var body_content = doc.body.innerHTML;

		doc.body.innerHTML = body_content + "" +
				"<div id=\"maskOfFrame\" "+style_maskOfFrame+">" +
					"<div id=\"modalFrame\" "+style_modalFrame+">" +
						"<div id=\"modalFrame-Header\" "+style_modalFrame_Header+">" +
							""+this.title+"" +
						"</div>" +
						"<div id=\"modalFrame-Content\">" +
							"<div>"+this.message+"</div>" +
							"<input type=\"submit\" value=\"Fermer\" name=\"btn_valid\" onclick=\"DialogFrame.hide();\" />" +
						"</div>" +
					"</div>" +		
				"</div>";
	}

}
DialogFrame.show = function () {
	var maskOfFrame = window.document.getElementById("maskOfFrame");
	maskOfFrame.style.visibility = "visible";
	var modalFrame = window.document.getElementById("modalFrame");
	modalFrame.style.visibility = "visible";
}
DialogFrame.hide = function () {
	_hideModalFrame();
}

function _hideModalFrame() {
	var modalFrame = window.document.getElementById("modalFrame");
	modalFrame.style.visibility = "hidden";
	setTimeout("_hideMaskOfFrame();", 200);
}
function _hideMaskOfFrame() {
	var maskOfFrame = window.document.getElementById("maskOfFrame");
	maskOfFrame.style.visibility = "hidden";
}
