﻿function inPoll_SendForm(pType){
	var poll_frm = document.getElementById("frm");
	var poll_amode = document.getElementById("amode");
	var poll_title = document.getElementById("polltitle");
	var poll_item1 = document.getElementById("pollitem1");
	var poll_item2 = document.getElementById("pollitem2");
	var poll_item3 = document.getElementById("pollitem3");
	var poll_item4 = document.getElementById("pollitem4");


	poll_amode.value = pType;


	switch(pType){
		case "poll" :
			checkCount = 0;
			for(i=0;i<poll_frm.chkpoll.length;i++){
			  if(poll_frm.chkpoll[i].checked)
				checkCount++;
			}
			if(checkCount==0){ alert("설문에 대한 답변을 선택해 주세요."); return; }
			poll_frm.action = "frmPoll.asp";
			break;

		case "insert" :
			if(poll_title.value == ''){ alert('제목을 입력하세요.'); poll_title.focus();	return; }
			if(poll_item1.value == ''){ alert('항목1을 입력하세요.'); poll_item1.focus();	return; }
			if(poll_item2.value == ''){ alert('항목2을 입력하세요.'); poll_item2.focus();	return; }
			if(poll_item3.value == ''){ alert('항목3을 입력하세요.'); poll_item3.focus();	return; }
			if(poll_item4.value == ''){ alert('항목4을 입력하세요.'); poll_item4.focus();	return; }
			poll_frm.action = "frm.asp";
			break;

		case "update" :			
			if(poll_title.value == ''){ alert('제목을 입력하세요.'); poll_title.focus();	return; }
			if(poll_item1.value == ''){ alert('항목1을 입력하세요.'); poll_item1.focus();	return; }
			if(poll_item2.value == ''){ alert('항목2을 입력하세요.'); poll_item2.focus();	return; }
			if(poll_item3.value == ''){ alert('항목3을 입력하세요.'); poll_item3.focus();	return; }
			if(poll_item4.value == ''){ alert('항목4을 입력하세요.'); poll_item4.focus();	return; }
			if(!confirm("수정 하시겠습니까?")){return;}
			poll_frm.action = "frm.asp";
			break;

		case "delete" :
			if(!confirm("삭제된 자료는 복구되지 않습니다.")){return;}
			poll_frm.action = "frm.asp";
			break;
	}
	poll_frm.method = "POST";
	poll_frm.submit();
}

function lstPoll_Search() {
	var poll_frm = document.getElementById("frm");

	poll_frm.method = "GET";
	poll_frm.submit();
}

