var EduCommonManager = Class.create();
EduCommonManager.prototype = {
		
	initialize : function(){
		this.ns = '';
		this.pg = '';
		this.pg_a = '';
		this.attachPath = '/user/educrse/common';
	},
	
	/* 목록 페이지 변경 */
	changePage: function(pageNo){
		location.href="viewPerd.aff?stdt_idx="+$('stdt_idx').value+"&perd_idx="+$('perd_idx').value+"&pageSize="+$('pageSize').value+"&nowPageNo="+pageNo+"&orde=A&pg="+this.pg+"&pg_a=l#"+this.pg;
	},
	
	/* 목록개수 변경 */
	changePageSize: function(){
		$('nowPageNo').value = "1";
		location.href="viewPerd.aff?stdt_idx="+$('stdt_idx').value+"&perd_idx="+$('perd_idx').value+"&pageSize="+$('pageSize').value+"&nowPageNo="+$('nowPageNo').value+"&orde=A&pg="+this.pg+"&pg_a=l#"+this.pg;
	},
	
	/* 설문 등록 */
	insertSrv : function() {
		var exam_count = $('exam_count').value;
		var item_count;
		var exam_idx_str = "";
		var item_idx_str = "";
		for(var i = 0 ; i < exam_count; i++ ) {
			var exam = "";
			var item = "";
			if( exam_idx_str == "" ) {
				item_count = document.all['itemlist' + (i + 1)].length;
				for( var j = 0; j < item_count; j ++ ) {
					if( document.all['itemlist' + (i + 1)][j].checked ) {
						if( item == "" ) item += document.all['itemlist' + (i + 1)][j].value;
						else item += "," + document.all['itemlist' + (i + 1)][j].value;
					}
				}
				if( item != "" ) {
					exam_idx_str += $('exam_idx' + ( i + 1 )).value;
					item_idx_str += item;
				} else {
					if(!confirm( ( i + 1 ) + "번째 항목을 입력 하지 않았습니다. \n 계속 진행 하시겠습니까?")) {
						return;
					}
				}
			} else {
				item_count = document.all['itemlist' + (i + 1)].length;
				for( var j = 0; j < item_count; j ++ ) {
					if( document.all['itemlist' + (i + 1)][j].checked ) {
						if( item == "" ) item += document.all['itemlist' + (i + 1)][j].value;
						else item += "," + document.all['itemlist' + (i + 1)][j].value;
					}
				}
				if( item != "" ) {
					exam_idx_str += "," + $('exam_idx' + ( i + 1 )).value;
					item_idx_str += "|"  + item;
				} else {
					if(!confirm( ( i + 1 ) + "번째 항목을 입력 하지 않았습니다. \n 계속 진행 하시겠습니까?")) {
						return;
					}
				}
			}
		}
		if( exam_idx_str == "") {
		//	alert("설문에 참여해 주세요");
		//	return;
		}
	
		$('exam_idx_str').value = exam_idx_str;
		$('item_idx_str').value = item_idx_str;
		
		$('form').action="/user/educrse/common/incCreateSrv.aff";
		$('form').submit();
	},
	
	
	createEdups: function(){
		var bbsForm = $('bbsForm');
		bbsForm.action = '/user/educrse/common/incCreateEdups.aff';
		bbsForm.submit();
	},
	
	modifyEdups: function(){
		var bbsForm = $('bbsForm');
		bbsForm.action = '/user/educrse/common/incModifyEdups.aff';
		bbsForm.submit();
	},
	
	deleteEdups: function(){
		var bbsForm = $('bbsForm');
		if (confirm("선택한 글을 삭제 하시겠습니까?")) {
			bbsForm.action = '/user/educrse/common/incDeleteEdups.aff';
			bbsForm.submit();
		}
	}, 
	
	/* 다음,이전 글읽기 */
	readFromView : function(bbs_seq, file_cnt){
		$('bbs_seq').value = bbs_seq;
		$('file_cnt').value = file_cnt;
		$('bbsForm').action="viewPerd.aff";
		$('bbsForm').submit();
	}
	
};

