function uctlDivWindow(p_oButton) {
	this.btnAddRecord = p_oButton; 
	this.divWindow = null;
	this.divResult = null;
	
	this.init();
}

uctlDivWindow.prototype.createConfirmPage = function() {
	//create confirmation page
	oThis = this;
	var oDiv = null;
	var oForm = document.createElement("form");
	oForm.setAttribute("onsubmit", "return false;");

	this.divWindow = document.createElement("div");
	//Header Row
	oDiv = document.createElement("div");
	oDiv.className = "divWindowHeader";
	oDiv.innerHTML = "Add New Phone Book Record";
	this.divWindow.appendChild(oDiv);


	
	//First Row
	oDiv = document.createElement("div");
	var oLabel = document.createElement("label");
	oLabel.innerHTML = "Insert Name";
	var txtName = document.createElement("input");
	txtName.setAttribute("id", "txtName");
	txtName.setAttribute("type", "text");
	txtName.style.width = "200";
	txtName.style.top = "200";
	txtName.style.left = "200";

	oDiv.appendChild(oLabel);
	oDiv.appendChild(txtName);
	oForm.appendChild(oDiv);
	//this.divWindow.appendChild(oDiv);
	
	//2nd Row
	oDiv = document.createElement("div");

	oLabel = document.createElement("label");
	oLabel.innerHTML = "Insert Mobile Number";

	txtName = document.createElement("input");
	txtName.setAttribute("id", "txtPhoneNumber");
	txtName.setAttribute("type", "text");
	txtName.style.width = "200";
	txtName.style.top = "200";
	txtName.style.left = "200";

	oDiv.appendChild(oLabel);
	oDiv.appendChild(txtName);
	oForm.appendChild(oDiv);
	//this.divWindow.appendChild(oDiv);

	//3rd Row
	this.divResult = document.createElement("div");	
	this.divResult.setAttribute("id", "divResult");
	this.divResult.style.padding = "5px 10px 5px 10px";
	this.divResult.style.width = "100%";
	this.divResult.style.minHeight = "25px";
	//this.divResult.style.position = "relative";

	oForm.appendChild(this.divResult);
	//this.divWindow.appendChild(this.divResult);
	
	//create button
	oDiv = document.createElement("div");	
	var btnSubmit = document.createElement("button");
	btnSubmit.style.width = "100";
	btnSubmit.innerHTML = "Confirm";
	btnSubmit.onmouseup = function (oEvent) {
		oThis.insertPhoneBook(document.getElementById("txtName").value, document.getElementById("txtPhoneNumber").value)
	};

	//create button
	var btnClose = document.createElement("button");
	btnClose.style.width = "100";
	btnClose.innerHTML = "Close";
	btnClose.onmouseup = function (oEvent) {
		oThis.divWindow.style.display = "none"; 
	};
	//create button
	var btnReset = document.createElement("input");
	btnReset.setAttribute("type", "reset");
	btnReset.style.width = "100";
	btnReset.value = "Reset";

	oDiv.appendChild(btnSubmit);
	oDiv.appendChild(btnReset);
	oDiv.appendChild(btnClose);
	
	oForm.appendChild(oDiv);
	
	//this.divWindow.appendChild(oDiv);
	oDiv = document.createElement("div");
	oDiv.className = "divWindowBody";
//	oDiv.style.padding = "10px";
	oDiv.appendChild(oForm);
	

//--------------------------
	this.divWindow.className = "divWindowContainer";
	
	this.divWindow.style.position = "absolute";
	this.divWindow.style.width =  "400px";
	this.divWindow.style.height =  "150px";
	var iLeft = (parseInt(document.body.clientWidth) - parseInt(this.divWindow.style.width)) / 2;
	var iTop  = (parseInt(document.body.clientHeight) - parseInt(this.divWindow.style.height)) / 2;;
	this.divWindow.style.top = iTop;
	this.divWindow.style.left = iLeft;
	this.divWindow.style.display = "none";	
	
	this.divWindow.appendChild(oDiv);// add divWindowBody
	
	document.body.appendChild(this.divWindow);
	
};

uctlDivWindow.prototype.insertPhoneBook = function (p_sName, p_sPhoneNumber) {

	oThis = this;
	var ShowResult = function (p_oXml) 	{		
		if (p_oXml.responseText.length > 0) {
			//oThis.divWindow.innerHTML = p_oXml.responseText;
		//alert(document.getElementById("txtName").value);
		//alert(document.getElementById("txtPhoneNumber").value);
			
			oThis.divResult.innerHTML = p_oXml.responseText;
		}
	}
	
	var sPostStr = "Name=" + p_sName;
	sPostStr += "&PhoneNumber=" + p_sPhoneNumber;	
	//oThis.suggestionBox.innerHTML = "<div style='text-align:center;'>Processing...</div>"
	doAJAXCall("ajaxPhoneBook_Insert.asp", "POST", sPostStr, ShowResult);		
	
};


uctlDivWindow.prototype.init = function () {
	var oThis = this;
	oThis.createConfirmPage();
	oThis.btnAddRecord.onmouseup = function (oEvent) {
		
		oThis.divWindow.style.display = "block";
    };
	
	
	
};


/*
uctlConfirmPage.prototype.receive = function(p_oButton) {
	oThis = this;
	this.btnTopUp = p_oButton;
	oThis.displayConfirmPage();
};
uctlConfirmPage.prototype.executeMemberTopUp = function(p_sMemberID, p_sMemberID_Trial) {
	var ShowResult = function (p_oXml) 	{		
		if (p_oXml.responseText.length > 0) {
			oThis.suggestionBox.innerHTML = p_oXml.responseText;
		}
	}
	
	var sPostStr = "MemberID=" + p_sMemberID;
	sPostStr += "&MemberID_Trial=" + p_sMemberID_Trial;	
	oThis.suggestionBox.innerHTML = "<div style='text-align:center;'>Processing...</div>"
	doAJAXCall("ajaxConfirmTopUp100Promotion.asp", "POST", sPostStr, ShowResult);		
};

uctlConfirmPage.prototype.displayConfirmPage = function () {
	var oThis = this;
	if (this.suggestionBox.hasChildNodes())	{
		while ( this.suggestionBox.childNodes.length >= 1 )	{
			this.suggestionBox.removeChild( this.suggestionBox.firstChild );       
		} 
	}
	
	//screen value
	var oDiv = document.createElement("div");
	oDiv.className = "messageBoxHeader";
	oDiv.innerHTML = "Confirmation for " + this.btnTopUp.parentNode.parentNode.childNodes[3].innerHTML;
	
	oThis.suggestionBox.appendChild(oDiv);

	var oDiv = document.createElement("div");
	oDiv.className = "messageBoxMessage";
	oDiv.innerHTML = "This user account balance will be added with 100 points."
	oThis.suggestionBox.appendChild(oDiv);
	
	var oDiv = document.createElement("div");
	oDiv.style.textAlign = "center";

	//create button
	var btnSubmit = document.createElement("button");
	btnSubmit.style.width = "100";
	btnSubmit.innerHTML = "Confirm";
	btnSubmit.onmouseup = function (oEvent) {
		oThis.executeMemberTopUp(oThis.btnTopUp.parentNode.parentNode.childNodes[0].innerHTML
								, oThis.btnTopUp.parentNode.parentNode.childNodes[1].innerHTML);
    };
	oDiv.appendChild(btnSubmit);
	
	//create button
	btnSubmit = document.createElement("button"); 
	btnSubmit.style.width = "100";
	btnSubmit.innerHTML = "Cancel";
	btnSubmit.onmouseup = function (oEvent) {
		oThis.hideConfirmPage();
    };
	oDiv.appendChild(btnSubmit);

	this.suggestionBox.appendChild(oDiv);
	
	var iLeft = (parseInt(document.body.clientWidth) - parseInt(this.suggestionBox.style.width)) / 2;
	var iTop  = (parseInt(document.body.clientHeight) - parseInt(this.suggestionBox.style.height)) / 2;;
	this.suggestionBox.style.top = iTop;
	this.suggestionBox.style.left = iLeft;
	this.suggestionBox.style.display = "block";
};
uctlConfirmPage.prototype.hideConfirmPage = function () {
	this.suggestionBox.style.display = "none";
}

*/
