/**
 * ...
 * @author Nityanand Ojha
 */
 
var defaultObj = {
					parent:null,
					displayText: "String as param",
					left: 100,
					top: 100,
					width: 200,
					height: 100,
					lineHeight:17,
					fontSize:18,
					backgroundColor:"#f0f0f0",
					color:"#000",
				 };


var dialogBox;

function openDialogPopup(_option){
	var param = Object.keys(_option);
	
	for(var ii=0;ii<param.length;ii++){
		defaultObj[param[ii]] =  _option[param[ii]];
	}
	
	dialogBox = document.createElement("div");
	dialogBox.style.position = "absolute";
	dialogBox.style.top = defaultObj.top+"px";
	dialogBox.style.left = defaultObj.left+"px";
	dialogBox.style.width = defaultObj.width+"px";
	dialogBox.style.height = defaultObj.height+"px";
	dialogBox.style.backgroundColor = defaultObj.backgroundColor;
	dialogBox.style.padding = "20px";
	dialogBox.style.borderRadius = "18px";
	dialogBox.style.border = '1px solid #ccc';
	dialogBox.style.boxShadow = '0px 0px 6px #09F';
	dialogBox.style.zIndex = 1;
	
	defaultObj.parent.appendChild(dialogBox);
	
	var dialogBoxTxt = document.createElement("div");
	dialogBox.appendChild(dialogBoxTxt);
	dialogBoxTxt.innerHTML = defaultObj.displayText;
	dialogBoxTxt.style.width = defaultObj.width-50+"px";
	dialogBoxTxt.style.height = defaultObj.height+"px";
	dialogBoxTxt.style.fontSize = defaultObj.fontSize+"px";
	dialogBoxTxt.style.color = defaultObj.color;
	dialogBoxTxt.style.lineHeight = defaultObj.lineHeight+"px";
	dialogBoxTxt.style.margin = '0px 0 0 5px';
	
	var closeImg = new Image(50, 50);
	closeImg.style.position = "absolute";
	closeImg.src = "Assets/images/xclose.png";
	dialogBox.appendChild(closeImg);
	closeImg.style.cursor = "pointer";
	closeImg.style.top = -2+"px";
	closeImg.style.left = dialogBox.offsetWidth-closeImg.offsetWidth+"px";
	closeImg.addEventListener("click", onCloseClicked);
}

function onCloseClicked(e){
	defaultObj.parent.removeChild(dialogBox);
	dialogBox = null;
}