function setInit()
{
	var comboCnt = document.getElementById("strEventID").options.length;
	if (comboCnt == 0) return;
	var conObj = document.getElementById("sessionType");
	var costObj = document.getElementById("intCostSum");
	var comboIdx = document.getElementById("strEventID").selectedIndex;
	var addTopObj = document.getElementById("addTop").getElementsByTagName("div");
	
	var pObj = document.getElementById("addTable");
	var addObj = pObj.getElementsByTagName("div");
	var addObjcnt = addObj.length - 1;

	if (addObjcnt>0)
	{
		for (i=0; i<addObjcnt; i++)
			pObj.removeChild(addObj[i]);
	}
	
	document.registFrm.strTitle.setAttribute("value", document.registFrm.strEventID.options.item(comboIdx).text);
	
	if (arrBitSeparate[comboIdx])
	{
		conObj.style.display = "";
		makeSessionName(comboIdx);
		addTopObj[0].style.display = "";
		addTopObj[1].style.display = "none";
	}
	else
	{
		conObj.style.display = "none";
		addTopObj[0].style.display = "none";
		addTopObj[1].style.display = "";
	}
	var arrTmpCost = arrSessionCost[comboIdx].split(",");
	costObj.setAttribute("value",addCommas(arrTmpCost[0]));
}

function makeSessionName(idx)
{
	var obj = document.getElementById("selectholder");
	var selObj = document.createElement("select");
	obj.appendChild(selObj);
	var arrTmp = arrSessionName[idx].split(",");
	for (i=0; i<arrTmp.length; i++)
	{
		var optionObj = document.createElement("option");
		optionObj.setAttribute("value", arrTmp[i]);
		optionObj.appendChild(document.createTextNode(arrTmp[i]));
		selObj.appendChild(optionObj);
	}
	if (navigator.appName == "Netscape")
		selObj.setAttribute("onchange", "sumCalculation()");
	else
		selObj.setAttribute("onchange", sumCalculation);
	selObj.setAttribute("name", "strSessionName");
}

function sumCalculation()
{
	var frmObj = document.registFrm;
	var comboIdx = frmObj.strEventID.selectedIndex;
	var obj = document.getElementById("selectholder");

	var sum = 0;
	if (arrBitSeparate[comboIdx])
	{
		var arrTmpCost = arrSessionCost[comboIdx].split(",");
		sum = parseInt(arrTmpCost[obj.childNodes.item(0).selectedIndex]);
		var addObj = document.getElementById("addTable").getElementsByTagName("select");
		if (addObj.length>0)
		{
			for (i=0; i<addObj.length; i++)
				sum += parseInt(arrTmpCost[addObj[i].selectedIndex]);
		}
	}
	else
	{
		sum = parseInt(arrSessionCost[comboIdx]);
		var addObj = document.getElementById("addTable").getElementsByTagName("img");
		if (addObj.length-1>0)
		{
			for (i=0; i<addObj.length-1; i++)
				sum += parseInt(arrSessionCost[comboIdx]);
		}
	}
	frmObj.intCostSum.value = addCommas(sum+"");
}

function realCheck(val)
{
	var obj = document.getElementById("realAttendance");
	if (val)
	{
		obj.style.display = "none";
		document.getElementById("strRealName").getAttribute("value","");
		document.getElementById("strRealCompany").getAttribute("value","");
		document.getElementById("strRealPost").getAttribute("value","");
		document.getElementById("strRealPlace").getAttribute("value","");
		document.getElementById("strRealMobile").getAttribute("value","");
		document.getElementById("strRealEmail").getAttribute("value","");
	}
	else
		obj.style.display = "";
}

function addAttendance()
{
	var parentObj = document.getElementById("addTable");
	var targetObj = document.getElementById("addButton");
	var firstObj = document.createElement("div");
	firstObj.setAttribute("className","plus_line");
	firstObj.setAttribute("class","plus_line");

	var secondObj = document.createElement("ul");
	var idx = document.getElementById("strEventID").selectedIndex;
	
	if (arrBitSeparate[idx])
	{
		var tmpString = "strAttendanceName,strAttendanceCompany,strAttendanceMobile,strAttendanceEmail,strAttendanceSession";
		var tmpPStyle = "p_name,p_company,p_mobile,p_email,p_session";
		var tmpIStyle = "i_name,i_company,i_mobile,i_email,i_session";
	}
	else
	{
		var tmpString = "strAttendanceName,strAttendanceCompany,strAttendancePost,strAttendancePlace,strAttendanceMobile,strAttendanceEmail";
		var tmpPStyle = "p_name,p_company,p_post,p_place,p_mobile,p_email";
		var tmpIStyle = "i_name,i_company,i_post,i_place,i_mobile,i_email";
	}

	var arrTmpString = tmpString.split(",");
	var arrTmpPStyle = tmpPStyle.split(",");
	var arrTmpIStyle = tmpIStyle.split(",");
	var arrTmpSessionName = arrSessionName[idx].split(",");
	var iCount = arrTmpString.length

	for (i=0; i<iCount; i++)
	{
		var liObj = document.createElement("li");
		liObj.setAttribute("className",arrTmpPStyle[i]);
		liObj.setAttribute("class",arrTmpPStyle[i]);
		if (i==4 && iCount-1 == i)
		{
			var childObj = document.createElement("select");
			childObj.setAttribute("className","i_session");
			childObj.setAttribute("class","i_session");
			childObj.setAttribute("name",arrTmpString[i]);
			for (j=0; j<arrTmpSessionName.length; j++)
			{
				var optionObj = document.createElement("option");
				optionObj.setAttribute("value", arrTmpSessionName[j]);
				optionObj.appendChild(document.createTextNode(arrTmpSessionName[j]));
				childObj.appendChild(optionObj);
			}
			if (navigator.appName == "Netscape")
				childObj.setAttribute("onchange", "sumCalculation()");
			else
				childObj.setAttribute("onchange", sumCalculation);
		}
		else
		{
			var childObj = document.createElement("input");
			childObj.setAttribute("className",arrTmpIStyle[i]);
			childObj.setAttribute("class",arrTmpIStyle[i]);
			childObj.setAttribute("name",arrTmpString[i]);
			if (arrTmpString[i]=="strAttendanceMobile")
				childObj.maxLength="14";
		}
		liObj.appendChild(childObj);
		secondObj.appendChild(liObj);
	}
	
	var liObj = document.createElement("li");
	liObj.setAttribute("className","p_img");
	liObj.setAttribute("class","p_img");
	var childObj = document.createElement("input");
	childObj.setAttribute("type","hidden");
	childObj.setAttribute("name","intAttendanceSeq");
	liObj.appendChild(childObj);
	var imgObj = document.createElement("img");
	imgObj.setAttribute("src","../images/registration/btn_delete.gif");
	imgObj.setAttribute("border","0");
	imgObj.style.cursor="pointer";
	liObj.appendChild(imgObj);
	var nowObjs = parentObj.getElementsByTagName("div");
	if (nowObjs.length-1>0)
	{
		var prevID = nowObjs[nowObjs.length-2].getAttribute("id");
		var arrTmpID = prevID.split("_");
		var nowIndex = parseInt(arrTmpID[1])+1;
	}
	else
		var nowIndex = nowObjs.length - 1;
	firstObj.setAttribute("id","newItem_"+nowIndex);

	if (navigator.appName == "Netscape")
		imgObj.setAttribute("onclick", "deleteAttendance("+nowIndex+");");
	else
		imgObj.setAttribute("onclick", function(){ deleteAttendance(nowIndex); });
	
	secondObj.appendChild(liObj);
	firstObj.appendChild(secondObj);

	parentObj.insertBefore(firstObj,targetObj);
	sumCalculation();
}

function deleteAttendance(idx)
{
	var parentObj = document.getElementById("addTable");
	var delObj = document.getElementById("newItem_"+idx);
	parentObj.removeChild(delObj);
	sumCalculation();
}

function CheckData()
{
	var obj = document.registFrm;

	if (obj.strName.value == "")
	{
		alert("이름을 입력해 주세요");
		obj.strName.focus();
		return false;
	}
	if (obj.strPassword.value == "")
	{
		alert("비밀번호을 입력해 주세요");
		obj.strPassword.focus();
		return false;
	}
	if (obj.strEmail.value == "")
	{
		alert("이메일을 입력해 주세요");
		obj.strEmail.focus();
		return false;
	}
	if (!checkMail(obj.strEmail.value))
	{
		alert("이메일이 바르지 않습니다.");
		obj.strEmail.focus();
		return false;
	}
	for (i=0; i<obj.strComPhone.length; i++)
	{
		if (obj.strComPhone[i].value == "")
		{
			alert("회사전화번호를 입력해 주세요");
			obj.strComPhone[i].focus();
			return false;
		}
	}
	for (i=0; i<obj.strMobile.length; i++)
	{
		if (obj.strMobile[i].value == "")
		{
			alert("이동전화번호를 입력해 주세요");
			obj.strMobile[i].focus();
			return false;
		}
	}
	if (obj.strCompany.value == "")
	{
		alert("회사명을 입력해 주세요");
		obj.strCompany.focus();
		return false;
	}
	if (obj.strPost.value == "")
	{
		alert("부서명을 입력해 주세요");
		obj.strPost.focus();
		return false;
	}
	if (obj.strPlace.value == "")
	{
		alert("직위를 입력해 주세요");
		obj.strPlace.focus();
		return false;
	}
	if (obj.bitAttendance[1].checked)
	{
		if (obj.strRealName.value == "")
		{
			alert("실제 참석자의 이름을 입력해 주세요");
			obj.strRealName.focus();
			return false;
		}
		if (obj.strRealCompany.value == "")
		{
			alert("실제 참석자의 회사명을 입력해 주세요");
			obj.strRealCompany.focus();
			return false;
		}
		if (obj.strRealPost.value == "")
		{
			alert("실제 참석자의 부서명을 입력해 주세요");
			obj.strRealPost.focus();
			return false;
		}
		if (obj.strRealPlace.value == "")
		{
			alert("실제 참석자의 직위를 입력해 주세요");
			obj.strRealPlace.focus();
			return false;
		}
		if (obj.strRealMobile.value == "")
		{
			alert("실제 참석자의 이동전화번호를 입력해 주세요");
			obj.strRealMobile.focus();
			return false;
		}
		if (obj.strRealEmail.value == "")
		{
			alert("실제 참석자의 이메일을 입력해 주세요");
			obj.strRealEmail.focus();
			return false;
		}
		if (!checkMail(obj.strRealEmail.value))
		{
			alert("이메일이 바르지 않습니다");
			obj.strRealEmail.focus();
			return false;
		}
	}

	var addObj = document.getElementById("addTable").getElementsByTagName("div");
	var cnt = addObj.length - 1;
	if (cnt>0)
	{
		var checkCnt = addObj[0].childNodes[0].childNodes.length - 1;

		for (i=0; i<cnt; i++)
		{
			for (j=0; j<checkCnt; j++)
			{
				var inputObj = addObj[i].childNodes[0].childNodes[j].childNodes[0];
				var tmpName = inputObj.getAttribute("name");
				var tmpValue = inputObj.value;
				switch (tmpName)
				{
					case "strAttendanceName" :
						if (tmpValue == "")
						{
							alert("추가신청자의 이름을 입력해 주세요");
							inputObj.focus();
							return false;
						}
						break;
					case "strAttendanceCompany" :
						if (tmpValue == "")
						{
							alert("추가신청자의 회사/소속을 입력해 주세요");
							inputObj.focus();
							return false;
						}
						break;
					case "strAttendancePost" :
						if (tmpValue == "")
						{
							alert("추가신청자의 부서를 입력해 주세요");
							inputObj.focus();
							return false;
						}
						break;
					case "strAttendancePlace" :
						if (tmpValue == "")
						{
							alert("추가신청자의 직위를 입력해 주세요");
							inputObj.focus();
							return false;
						}
						break;
					case "strAttendanceMobile" :
						if (tmpValue == "")
						{
							alert("추가신청자의 이동전화번호를 입력해 주세요");
							inputObj.focus();
							return false;
						}
						else
						{
							if (!checkMobile(tmpValue))
							{
								alert("이동전화번호가 바르지 않습니다. 각 자리는'-'로 구분해 주세요");
								inputObj.focus();
								return false;
							}
						}
						break;
					case "strAttendanceEmail" :
						if (tmpValue == "")
						{
							alert("추가신청자의 이메일을 입력해 주세요");
							inputObj.focus();
							return false;
						}
						if (!checkMail(tmpValue))
						{
							alert("이메일이 바르지 않습니다");
							inputObj.focus();
							return false;
						}
						break;
				}
			}
		}
	}
	return true;
}

function deleteEditAttendance(seq, ref, idx)
{
	var parentObj = document.getElementById("addTable");
	var childObj = document.getElementById("newItem_"+idx);
	var procObj = document.getElementById("procFrm");

	parentObj.removeChild(childObj);
	sumCalculation();

	var cost = document.getElementById("intCostSum").getAttribute("value");

	procObj.setAttribute("src","deleteAttendance.asp?intSeq="+seq+"&intRef="+ref+"&intSessionCost="+cost);
}