﻿
//===============================================================================
//								Explore Program
//===============================================================================

var ViewType = 
{
	table : 1, 
	listCheckBox : 2,
	listRadioBox : 3
};

var oAjaxEP = new ExploreQuestionAction();

var ExploreProgram =
{
	oForm : null,
	oContainer : null,
	oHeader : null,
	oFooter : null,
	oBody : null,
	oContainerQuestion : null,
	oContainerAnswer : null,
	oMPopup : null,
	idAnswerInputRadioBox : "idAnswerInputRadioBox_",
	idAnswerInputCheckBox : "idAnswerInputCheckBox_",
	idAnswerInputTextBox : "idAnswerInputTextBox_",
	questionData : null,
	nextQuestionID : -1,
	resultAnswer : new Array(),
	resultRadioBoxTableView : new Array(),
	isFirstQuestion : false,

	init : function()
	{
		this.closeMPopup_onEscKey();
	},

	closeMPopup_onEscKey : function()
	{
		utilObj.addEvent(document, "keypress", function(e)
		{
			e = utilObj.getWindowEvent();
			if (e.keyCode == 27)
			{
				ExploreProgram.hide();
			}
		});
	},

/*****************************************************************************
								Question End
*****************************************************************************/

	setValueHeader : function(session)
	{
		this.oHeader.innerHTML = "<div class='EPTitle'>" + session.exploreName + "</div>";
	},
	
	setValueQuestion : function(question)
	{
		var html = "";
		if (question.questionImage != "")
		{
			html += "<img src='" + BKC.pathExploreProgram + question.questionImage + "' border='0' />";
		}
		this.oContainerQuestion.innerHTML = html + 
			"<br /><div class='containerTextQuestion'><strong>" + question.questionName + 
			": </strong> " + question.questionContent + "</div>";
	},
	
	setValueFooter : function(previous, next)
	{
		var html = "";
		if (previous)
		{
			html += "<button onclick='javascript:ExploreProgram.previewQuestion()'>Lui</button>&nbsp;";
		}
		if (next)
		{
			html += "<button onclick='javascript:ExploreProgram.nextQuestion()'>Tới</button>&nbsp;";
		}
		this.oFooter.innerHTML = html + "<button onclick='javascript:ExploreProgram.hide()'>Đóng</button>&nbsp;";
	},
	
/*****************************************************************************
								Create Container Start
*****************************************************************************/

/*****************************************************************************
								Question Start
*****************************************************************************/

	getQuestionFirst : function()
	{
		var o = oAjaxEP.getQuestionFirst();
		if (!o.hasErrors)
		{
			var result = o.data;
			
			// Store to session
			if (result == null || result.sessionExplore == null)
			{
				alert("Hiện giờ chưa có câu hỏi!");
				return false;
			}
			this.customerSession.exploreID = result.sessionExplore.exploreID;
			
			this.questionData = result.question;
			this.setValueHeader(result.sessionExplore);
			this.showIntroExploreProgram(result.sessionExplore);
			return true;
		}
		else
		{
			alert(GetTextLang(15));
			return false;
		}
	},
	
	getQuestion : function(id)
	{
		var o = oAjaxEP.getQuestion(id);
		if (!o.hasErrors)
		{
			this.questionData = o.data;
			this.showQuestion();
		}
		else
		{
			alert(GetTextLang(15));
		}
	},
	
	showQuestion : function()
	{
		this.setValueFooter(true, true);
		this.resetContentContainer();
		this.setValueQuestion(this.questionData);
		this.createGroupAnswer(this.questionData.groupAnswer);
	},
	
/*****************************************************************************
								Question End
*****************************************************************************/

/*****************************************************************************
								Group Answer Start
*****************************************************************************/
	
	createGroupAnswer : function(listGroupAnswer)
	{
		if (listGroupAnswer.length == 1)
		{
			this.createAnswer(listGroupAnswer[0]);
		}
		else if (listGroupAnswer.length > 1)
		{
			for (var i = 0; i < listGroupAnswer.length; i++)
			{
				var groupAnswer = listGroupAnswer[i];
				this.createElementGroupAnswer(groupAnswer);
				this.createAnswer(groupAnswer);
			}
		}
	},
	
	createElementGroupAnswer : function(groupAnswer)
	{
		if (groupAnswer.isShowTitle)
		{
			var o = utilObj.createEl("DIV");
			o.className = "textGroupAnswer";
			o.innerHTML = groupAnswer.groupAnswerTitle + ": ";
			this.oContainerAnswer.appendChild(o);
		}
	},

/*****************************************************************************
								Group Answer End
*****************************************************************************/

/*****************************************************************************
								Answer Start
*****************************************************************************/
	
	createAnswer : function(groupAnswer)
	{
		switch(groupAnswer.viewTypeID)
		{
			case ViewType.table:
				this.createAnswerTable(groupAnswer.answer, groupAnswer.groupAnswerID);
				break;
			case ViewType.listCheckBox:
				this.createAnswerListCheckBox(groupAnswer.answer, groupAnswer.groupAnswerID);
				break;
			case ViewType.listRadioBox:
				this.createAnswerListRadioBox(groupAnswer.answer, groupAnswer.groupAnswerID);
				break;
		}
	},
	
	createAnswerTable : function(listAnswer, groupAnswerID)
	{
		var oTable = utilObj.createEl("TABLE");
		oTable.cellPadding = 0; oTable.cellSpacing = 0; oTable.border = 1; oTable.width = "95%";
		oTable.style.borderCollapse = "collapse"; oTable.style.margin = "auto";
		var nr = oTable.insertRow(oTable.rows.length);
		var c = nr.insertCell(0);
		for (var i = 1; i <= listAnswer.length; i++)
		{
			c = nr.insertCell(i);
			c.style.textAlign = "center";
			c.innerHTML = i;
		}
		
		for (var i = 0; i < listAnswer.length; i++)
		{
			var answer = listAnswer[i];
			var numRow = oTable.rows.length;
			nr = oTable.insertRow(numRow);
			c = nr.insertCell(0);
			c.innerHTML = answer.answerContent;
			for (var j = 1; j <= listAnswer.length; j++)
			{
				c = nr.insertCell(j);
				c.style.textAlign = "center";
				var idInput = this.idAnswerInputRadioBox + numRow + "_" + j;
				var nameInput = this.idAnswerInputRadioBox + numRow + "_" + groupAnswerID;
				c.innerHTML = "<input type='radio' name='" + nameInput + 
					"' id='" + idInput + "' class='EPRadio' value='" + j + "' />";
			}
		}
		this.oContainerAnswer.appendChild(oTable);
	},
	
	createAnswerListCheckBox : function(listAnswer, groupAnswerID)
	{
		for (var i = 0; i < listAnswer.length; i++)
		{
			this.oContainerAnswer.appendChild(this.getElementCheckBox(listAnswer[i], groupAnswerID));
			var oBR = utilObj.createEl("BR");
			oBR.className = "EPBR";
			this.oContainerAnswer.appendChild(oBR);
		}
	},
	
	createAnswerListRadioBox : function(listAnswer, groupAnswerID)
	{
		for (var i = 0; i < listAnswer.length; i++)
		{
			this.oContainerAnswer.appendChild(this.getElementRadioBox(listAnswer[i], groupAnswerID));
			var oBR = utilObj.createEl("BR");
			oBR.className = "EPBR";
			this.oContainerAnswer.appendChild(oBR);
		}
	},
	
	getElementCheckBox : function(answer, groupAnswerID)
	{
		var idInput = this.idAnswerInputCheckBox + answer.answerID;
		var oContainer = utilObj.createEl("LABEL");
		oContainer.id = "ContainerElAnswer_" + answer.answerID;
		oContainer.htmlFor = idInput;
		var oInput = utilObj.createEl("INPUT");
		oInput.id = idInput;
		oInput.type = "checkbox";
		oInput.className = "EPCheckBox";
		oInput.value = answer.answerID;
		utilObj.createAttribute(oInput, "nextQuestionID", answer.nextQuestionID);
		oContainer.appendChild(oInput);
		oContainer.appendChild(utilObj.createElText(answer.answerContent));
		if (answer.isTextBox)
		{
			var oInputTextBox = utilObj.createEl("INPUT");
			oInputTextBox.id = this.idAnswerInputTextBox + answer.answerID;
			oInputTextBox.type = "text";
			oInputTextBox.className = "EPText";
			oContainer.appendChild(oInputTextBox);
		}
		return oContainer;
	},
	
	getElementRadioBox : function(answer, groupAnswerID)
	{
		var idInput = this.idAnswerInputRadioBox + answer.answerID;
		var nameInput = this.idAnswerInputRadioBox + groupAnswerID;
		
		var oLabel = utilObj.createEl("LABEL");
		oLabel.htmlFor = idInput;
		oLabel.innerHTML = "<input type='radio' name='" + nameInput + 
			"' id='" + idInput + "' class='EPRadio' value='" + 
			answer.answerID + "'> " + answer.answerContent;
		
		return oLabel;
	},
	
/*****************************************************************************
								Answer End
*****************************************************************************/

/*****************************************************************************
								Check Value Start
*****************************************************************************/

	checkResult : function()
	{
		var listGroupAnswer = this.questionData.groupAnswer;
		var isCorrect = false;
		for (var i = 0; i < listGroupAnswer.length; i++)
		{
			var groupAnswer = listGroupAnswer[i];
			switch(groupAnswer.viewTypeID)
			{
				case ViewType.table:
					isCorrect = this.checkResultTable(groupAnswer.answer, groupAnswer.groupAnswerID);
					if (isCorrect == -1)
					{
						alert(GetTextLang(17));
						this.resultAnswer = new Array();
						return;
					}
					break;
				case ViewType.listCheckBox:
					isCorrect = this.checkResultCheckBox(groupAnswer.answer, groupAnswer.groupAnswerID);
					break;
				case ViewType.listRadioBox:
					isCorrect = this.checkResultRadioBox(groupAnswer.answer, groupAnswer.groupAnswerID);
					break;
			}
			if (!isCorrect)
			{
				alert(GetTextLang(16));
				this.resultAnswer = new Array();
				return;
			}
		}
		
		for (var i = 0; i < this.resultAnswer.length; i++)
		{
			// Store to session
			this.customerSession.add(this.resultAnswer[i]);
		}
		
		if (this.nextQuestionID == -1)
		{
			this.showFormCustomer();
		}
		else
		{
			this.getQuestion(this.nextQuestionID);
		}
	},
	
	checkResultTable : function(listAnswer, groupAnswerID)
	{
		var counter = 0;
		var numRow = 1;
		var length = listAnswer.length;
		var valueExist = new Array();
		
		for (var i = 0; i < length; i++, numRow++)
		{
			var answer = listAnswer[i];
			this.nextQuestionID = answer.nextQuestionID;
			for (var j = 1; j <= length; j++)
			{
				var idInput = this.idAnswerInputRadioBox + numRow + "_" + j;
				var o = utilObj.getElById(idInput);
				if (o.checked)
				{
					// Check value exist
					if (valueExist["value" + o.value] != null || valueExist["value" + o.value] != undefined)
					{
						return -1;
					}
					valueExist["value" + o.value] = o.value;
					counter += 1;
					// Store to session
					this.resultAnswer.push({ customerID : -1, questionID : this.questionData.questionID, 
						answerID : answer.answerID, value : j });
					break;
				}
			}
			
		}
		return counter != 0;
	},
	
	checkResultCheckBox : function(listAnswer, groupAnswerID)
	{
		var isCorrect = false;
		for (var i = 0; i < listAnswer.length; i++)
		{
			var answer = listAnswer[i];
			var o = utilObj.getElById(this.idAnswerInputCheckBox + answer.answerID);
			if (o.checked)
			{
				isCorrect = true;
				this.nextQuestionID = answer.nextQuestionID;
				
				var value = "";
				if (answer.isTextBox)
				{
					value = utilObj.getElById(this.idAnswerInputTextBox + answer.answerID).value;
				}
				
				// Store to session
				this.resultAnswer.push({ customerID : -1, questionID : this.questionData.questionID, answerID : answer.answerID, value : value });
			}
		}
		return isCorrect;
	},
	
	checkResultRadioBox : function(listAnswer, groupAnswerID)
	{
		var isCorrect = false;
		
		for (var i = 0; i < listAnswer.length; i++)
		{
			var answer = listAnswer[i];
			var o = utilObj.getElById(this.idAnswerInputRadioBox + answer.answerID);
			if (o.checked)
			{
				isCorrect = true;
				this.nextQuestionID = answer.nextQuestionID;
				
				var value = "";
				if (answer.isTextBox)
				{
					value = utilObj.getElById(this.idAnswerInputRadioBox + answer.answerID).value;
				}
				
				// Store to session
				this.resultAnswer.push({ customerID : -1, questionID : this.questionData.questionID, answerID : answer.answerID, value : value });
				break;
			}
		}
		return isCorrect;
	},

/*****************************************************************************
								Check Value End
*****************************************************************************/

	show : function()
	{
		this.resetElementInBody();
		this.createAllElement();
		var re = this.getQuestionFirst();
		if (this.oMPopup == null)
		{
			this.oMPopup = new ModalPopup("divContainerExploreProgram", "ExploreProgram.oMPopup");
		}
		if (re) this.oMPopup.display();
	},
	
	hide : function()
	{
		if (this.oMPopup != null)
		{
			this.oMPopup.hide();
		}
	},
	
	nextQuestion : function()
	{
		if (this.isFirstQuestion)
		{
			this.isFirstQuestion = false;
			this.showQuestion();
		}
		else
		{
			this.checkResult();
		}
	},
	
	previewQuestion : function()
	{
		var questionID = this.customerSession.getLastQuestion();
		if (questionID == -1)
		{
			alert("Đây là câu hỏi đâu tiên.");
		}
		else
		{
			this.getQuestion(questionID);
		}
	},
	
	showIntroExploreProgram : function(oEP)
	{
		this.isFirstQuestion = true;
		// o.sessionExplore.exploreContent, exploreName, beginDate, endDate 
		this.oContainerQuestion.innerHTML = "<string>" + oEP.exploreName + "</strong>";
		this.oContainerAnswer.innerHTML = "<string>" + oEP.exploreContent + "</strong>";
		this.setValueFooter(false, true);
	},
	
/*****************************************************************************
								Create Form Customer Start
*****************************************************************************/
	
	showAnswerComplete : function()
	{
		this.resetElementInBody();
		this.customerSession.reset();
		var o = utilObj.createEl("SPAN");
		o.className = "EPContainerComplete";
		o.innerHTML = "<table cellpadding='0' cellspacing='0' border='0'>" +
			"<tr>" +
			"	<td class='EPComplete'>" +
			"		Xin cám ơn, Bạn đã trả lời hoàn tất.<BR />" +
			" <b>Số điện thoại</b> của bạn đã được đưa vào danh sách <b>rút thăm trúng thưởng</b>.</td>" +
			"	</tr> " +
			"	</table>";
		this.oBody.appendChild(o);
	},
	
	showFormCustomer : function()
	{
		this.setValueFooter(false, false);
		this.resetElementInBody();
		this.createFormCustomer();
		var oTable = utilObj.createEl("TABLE");
		oTable.cellPadding = 0; oTable.cellSpacing = 0; oTable.border = 0; oTable.width = "80%";
		oTable.style.margin = "auto"; oTable.style.textAlign = "left";
		
		// Customer Info
		var nr = oTable.insertRow(oTable.rows.length);
		var c = nr.insertCell(0);
		c.colSpan = 2;
		c.className = "EPTitleCustomer";
		c.innerHTML = "Thông tin khách hàng";
		
		// Sep 
		nr = oTable.insertRow(oTable.rows.length); c = nr.insertCell(0); c.style.height = "5px";
		
		// Telephone
		nr = oTable.insertRow(oTable.rows.length);
		c = nr.insertCell(0);
		c.innerHTML = "Họ tên:(<strong style='color:red;'>*</strong>)";
		c = nr.insertCell(1);
		c.innerHTML = "<input type='text' name='customerNameEP' id='customerNameEP' class='inputText  w250px' />";
		
		// Sep 
		nr = oTable.insertRow(oTable.rows.length); c = nr.insertCell(0); c.style.height = "5px";
		
		// Region
		nr = oTable.insertRow(oTable.rows.length);
		c = nr.insertCell(0);
		c.innerHTML = "Bạn đang ở vùng nào:(<strong style='color:red;'>*</strong>)";
		c = nr.insertCell(1);
		c.appendChild(this.getBlockRadio("regionEP", "regionEP1", "Hà nội"));
		c.appendChild(this.getBlockRadio("regionEP", "regionEP2", "Đà nẵng"));
		c.appendChild(this.getBlockRadio("regionEP", "regionEP3", "HCM"));
		c.appendChild(this.getBlockRadio("regionEP", "regionEP4", "Khác"));
		
		// Sep 
		nr = oTable.insertRow(oTable.rows.length); c = nr.insertCell(0); c.style.height = "5px";
		
		// Gender
		nr = oTable.insertRow(oTable.rows.length);
		c = nr.insertCell(0);
		c.innerHTML = "Giới tính:(<strong style='color:red;'>*</strong>)";
		c = nr.insertCell(1);
		c.appendChild(this.getBlockRadio("genderEP", "genderEPMale", "Nam"));
		c.appendChild(this.getBlockRadio("genderEP", "genderEPFemale", "Nữ"));
		
		// Sep 
		nr = oTable.insertRow(oTable.rows.length); c = nr.insertCell(0); c.style.height = "5px";
		
		// Age
		nr = oTable.insertRow(oTable.rows.length);
		c = nr.insertCell(0);
		c.innerHTML = "Độ tuổi:(<strong style='color:red;'>*</strong>)";
		c = nr.insertCell(1);
		c.appendChild(this.getBlockRadio("ageEP", "ageEP1", "11-14t"));
		c.appendChild(this.getBlockRadio("ageEP", "ageEP2", "15-18t"));
		c.appendChild(this.getBlockRadio("ageEP", "ageEP3", "19-22t"));
		c.appendChild(this.getBlockRadio("ageEP", "ageEP4", "22-25t"));
		c.appendChild(this.getBlockRadio("ageEP", "ageEP5", ">25t"));
		
		// Sep 
		nr = oTable.insertRow(oTable.rows.length); c = nr.insertCell(0); c.style.height = "5px";
		
		// Job
		nr = oTable.insertRow(oTable.rows.length);
		c = nr.insertCell(0);
		c.innerHTML = "Bạn đang là:(<strong style='color:red;'>*</strong>)";
		c = nr.insertCell(1);
		c.appendChild(this.getBlockRadio("jobEP", "jobEP1", "Học sinh"));
		c.appendChild(this.getBlockRadio("jobEP", "jobEP2", "Sinh viên"));
		c.appendChild(this.getBlockRadio("jobEP", "jobEP3", "Đang đi làm"));
		c.appendChild(this.getBlockRadio("jobEP", "jobEP4", "Khác"));
		
		// Sep 
		nr = oTable.insertRow(oTable.rows.length); c = nr.insertCell(0); c.style.height = "5px";
		
		// Income
		nr = oTable.insertRow(oTable.rows.length);
		c = nr.insertCell(0);
		c.innerHTML = "Thu nhập:(<strong style='color:red;'>*</strong>)";
		c = nr.insertCell(1);
		c.appendChild(this.getBlockRadio("incomeEP", "incomeEP1", "Chưa có thu nhập"));
		c.appendChild(this.getBlockRadio("incomeEP", "incomeEP2", "2tr"));
		c.appendChild(this.getBlockRadio("incomeEP", "incomeEP3", "2 - 4tr"));
		c.appendChild(this.getBlockRadio("incomeEP", "incomeEP4", "4 - 6tr"));
		c.appendChild(this.getBlockRadio("incomeEP", "incomeEP5", ">= 6tr"));
		
		// Sep 
		nr = oTable.insertRow(oTable.rows.length); c = nr.insertCell(0); c.style.height = "5px";
		
		// Telephone
		nr = oTable.insertRow(oTable.rows.length);
		c = nr.insertCell(0);
		c.innerHTML = "Điện thoại:(<strong style='color:red;'>*</strong>)";
		c = nr.insertCell(1);
		c.innerHTML = "<input type='text' name='telephoneEP' id='telephoneEP' class='inputText w250px' />";
		
		// Sep 
		nr = oTable.insertRow(oTable.rows.length); c = nr.insertCell(0); c.style.height = "5px";
		
		// Email
		nr = oTable.insertRow(oTable.rows.length);
		c = nr.insertCell(0);
		c.innerHTML = "Email:(<strong style='color:red;'>*</strong>)";
		c = nr.insertCell(1);
		c.innerHTML = "<input type='text' name='emailEP' id='emailEP' class='inputText w250px' />";
		
		// Sep 
		nr = oTable.insertRow(oTable.rows.length); c = nr.insertCell(0); c.style.height = "5px";
		
		// Button
		nr = oTable.insertRow(oTable.rows.length);
		c = nr.insertCell(0);
		c.colSpan = 2;
		c.style.textAlign = "center";
		c.innerHTML = "<input type='submit' value='Gửi' />" +
			"<input type='reset' value='Nhập lại' />";
		
		this.oForm.appendChild(oTable);
	},
	
	getBlockRadio : function(name, id, value)
	{
		/*
		var oLabel = utilObj.createEl("LABEL");
		oLabel.htmlFor = id;
		var o = utilObj.createEl("INPUT");
		o.type = "radio";
		o.name = name;
		o.id = id;
		o.value = value;
		oLabel.appendChild(o);
		oLabel.appendChild(utilObj.createElText(" " + value));
		*/
		var oLabel = utilObj.createEl("LABEL");
		oLabel.htmlFor = id;
		oLabel.innerHTML = "<input type='radio' name='" + name + 
			"' id='" + id + "' class='EPRadio' value='" + value + "'> " + value;
		return oLabel;
	},
	
	createFormCustomer : function()
	{
		this.oForm = utilObj.createEl("FORM");
		this.oForm.id = "formCustomerEP";
		this.oForm.method = "post";
		this.oForm.style.textAlign = "center";
		var self = this;
		this.oForm.onsubmit = function (e)
		{
			self.checkFormCustomer();
			return false;
		};
		this.oBody.appendChild(this.oForm);
	},
	
	formEl : function(id)
	{
		return this.oForm.elements[id];
	},
	
	getValueRadio : function(id)
	{
		var re = null;
		var oRadio = this.formEl(id);
		for (var i = 0; i < oRadio.length; i++)
		{
			if (oRadio[i].checked)
			{
				re = oRadio[i];
				break;
			}
		}
		return re;
	},
	
	checkFormCustomer : function()
	{
		// emailEP, telephoneEP, incomeEP, jobEP, ageEP, genderEP, regionEP, customerNameEP
		var oName = this.formEl("customerNameEP");
		if (oName.value.trim() == "")
		{
			alert("Bạn chưa nhập họ tên!");
			oName.focus();
			return;
		}
		
		var oRegion = this.getValueRadio("regionEP");
		if (oRegion == null)
		{
			alert("Bạn chưa chọn vùng!");
			return;
		}
		
		var oGender = this.getValueRadio("genderEP");
		if (oGender == null)
		{
			alert("Bạn chưa chọn giới tính!");
			return;
		}
		
		var oAge = this.getValueRadio("ageEP");
		if (oAge == null)
		{
			alert("Bạn chưa chọn tuổi!");
			return;
		}
		
		var oJob = this.getValueRadio("jobEP");
		if (oJob == null)
		{
			alert("Bạn chưa chọn nghề nghiệp!");
			return;
		}
		
		var oIncome = this.getValueRadio("incomeEP");
		if (oIncome == null)
		{
			alert("Bạn chưa chọn thu nhập!");
			return;
		}
		
		var oTel = this.formEl("telephoneEP");
		if (oTel.value.trim() == "")
		{
			alert("Bạn chưa nhập số điện thoại của bạn để liên lạc!");
			oTel.focus();
			return;
		}
		
		var oEmail = this.formEl("emailEP");
		var valueEmail = oEmail.value.trim();
		if (valueEmail != "" && !utilObj.isEmail(valueEmail))
		{
			oEmail.focus();
			oEmail.select();
			alert("Email của bạn không hợp lệ!");
			return;
		}
		var result = oAjaxEP.createNewCustomer(oName.value, 
			oRegion.value, (oGender.value == "Nam"), oAge.value, oJob.value,
			oIncome.value, oTel.value, oEmail.value, this.customerSession);
		
		if (result.hasErrors)
		{
			alert(result.errorsAlert);
		}
		else
		{
			this.showAnswerComplete();
		}
	},
	
/*****************************************************************************
								Create Form Customer Start
*****************************************************************************/
	
/*****************************************************************************
								Create Container Start
*****************************************************************************/
	
	createHeader : function()
	{
		if (this.oHeader == null)
		{
			o = utilObj.createEl("DIV");
			o.id = "idHeaderExploreProgram";
			o.className = "headerExploreProgram";
			o.innerHTML = "<div class='EPTitle'>Thăm dò ý kiến khách hàng</div>";
			o.style.textAlign = "left";
			this.oContainer.appendChild(o);
			this.oHeader = o;
		}
	},
	
	createBody : function()
	{
		if (this.oBody == null)
		{
			o = utilObj.createEl("DIV");
			o.id = "idBodyExploreProgram";
			o.className = "bodyExploreProgram";
			this.oContainer.appendChild(o);
			this.oBody = o;
		}
	},
	
	createQuestion : function()
	{
		if (this.oContainerQuestion == null)
		{
			this.oContainerQuestion = utilObj.createEl("DIV");
			this.oContainerQuestion.className = "containerQuestion";
			this.oBody.appendChild(this.oContainerQuestion);
		}
	},
	
	createContainerAnswer : function()
	{
		if (this.oContainerAnswer == null)
		{
			this.oContainerAnswer = utilObj.createEl("DIV");
			this.oContainerAnswer.className = "containerAnswer";
			this.oBody.appendChild(this.oContainerAnswer);
		}
	},
	
	createFooter : function()
	{
		if (this.oFooter == null)
		{
			o = utilObj.createEl("DIV");
			o.id = "idFooterExploreProgram";
			o.className = "footerExploreProgram";
			this.oContainer.appendChild(o);
			this.oFooter = o;
		}
	},
	
	createContainer : function()
	{
		if (this.oContainer == null)
		{
			var o = utilObj.createEl("DIV");
			o.id = "divContainerExploreProgram";
			utilObj.addChildToBody(o);
			this.oContainer = o;
		}
	},
	
	createAllElement : function()
	{
		this.createContainer();
		this.createHeader();
		this.createBody();
		this.createQuestion();
		this.createContainerAnswer();
		this.createFooter();
		this.setValueFooter(true, true);
	},
	
	resetContentContainer : function()
	{
		this.oContainerQuestion.innerHTML = "";
		this.oContainerAnswer.innerHTML = "";
		this.resultAnswer = new Array();
		this.resultRadioBoxTableView = new Array();
	},
	
	resetElementInBody : function()
	{
		if (this.oBody != null)
		{
			this.oBody.innerHTML = "";
		}
		this.oContainerQuestion = null;
		this.oContainerAnswer = null;
	}
/*****************************************************************************
								Create Container End
*****************************************************************************/
};

/*****************************************************************************
								Store Session Start
*****************************************************************************/

ExploreProgram.customerSession = 
{
	exploreID : -1,
	
	listCustomerAnswer : new Array(),
	
	add : function(customerAnswer)
	{
		this.listCustomerAnswer.push(customerAnswer);
	},
	
	remove : function(questionID)
	{
		for (var i = this.listCustomerAnswer.length - 1; i >= 0; i--)
		{
			if (questionID == this.listCustomerAnswer[i].questionID)
			{
				this.listCustomerAnswer.splice(i, 1);
			}
		}
	},
	
	getLastQuestion : function()
	{
		var questionID = -1;
		if (this.listCustomerAnswer.length > 0)
		{
			questionID = this.listCustomerAnswer[this.listCustomerAnswer.length - 1].questionID;
			this.remove(questionID);
		}
		return questionID;
	},
	
	reset : function()
	{
		this.exploreID = -1;
		this.listCustomerAnswer = new Array();
	}
};

/*****************************************************************************
								Store Session End
*****************************************************************************/

try
{
	ExploreProgram.init();
}
catch (e) { }