<%@ page contentType="text/html; charset=utf-8"%>
<%@ page import="kr.co.hwenc.system.HandlerStorage"%>
<%@ page import="kr.co.hsnc.common.util.*"%>
<%@ page import="kr.co.hwenc.common.ui.*"%>
<%@ page import="kr.co.hwenc.hmcs.cmn.code.MaterialCodeManager"%>
<%@ page import="kr.co.hwenc.hmcs.cmn.code.ItemCategoryManager"%>
<%@ page import="kr.co.hwenc.hmcs.cmn.code.SizeSelectManager"%>
<jsp:useBean id="ctx" class="kr.co.hwenc.system.context.SessionContext" scope="session" />
<%
	ctx.init(request, response);

	HandlerStorage storage = ctx.getHandlerStorage();
	ValueObject user       = ctx.getUser();
	ValueObject params     = storage.getParams();
	String event           = storage.getEvent();
	ValueObject vo         = ctx.getParams();
%>

<SCRIPT language="JavaScript">
	
	var resultRowSet = null ;
	var rs;
	
	// 마지막으로 선택된 행의 번호를 기억하고 있음
	var CurMasterRow = 0;

	// Sheet의 초기화 작업
	function initIBSheet(sheetObj) {
	
		if( sheetObj.id == "sheet1" ) {
			with(sheetObj) { 

				//전체 너비 설정
				doResizeSheet(sheetObj);

				//전체Merge 종류 [선택, Default msNone]
				MergeSheet = msNone;
				
				//전체Edit 허용 여부 [선택, Default false]
				Editable = true;

				//행정보설정[필수][HEADROWS,DATAROWS,VIEWROWS,ONEPAGEROWS=100]
				InitRowInfo( 1, 1, 15, 100);
  
    			//컬럼정보설정[필수][COLS,FROZENCOL,LEFTHEADCOLS=0,FROZENMOVE=false]
    			InitColumnInfo(5, 2, 0, true);

    			//해더행정보[필수][ROW,HEADTEXT,ROWMERGE=false, HIDDEN=false]
    			InitHeadRow(0, "ALL|STAUS|FILED1|FILED2|Item", false);
    			
    			//헤더기능설정 [선택][SortEnable, ColumnMove, AllCheckEnable, UserResize, RowMove, Head3D] 
                InitHeadMode(false, true, true, true, true, true);

    			//데이터속성[ROW,COL,DATATYPE,WIDTH,DATAALIGN,COLMERGE,SAVENAME,KEYFIELD,CALCULOGIC,DATAFORMAT,POINTCOUNT,UPDATEEDIT,INSERTEDIT,EDITLEN,FULLINPUT,SORTENABLE,TOOLTIP,ALLCHECK, SAVESTATUS, FORMATFIX]    
    			var colNum = 0; 
    			InitDataProperty(0, colNum++, dtCheckBox,      	40, daCenter,	false,	"NUM_CHECK");
    			InitDataProperty(0, colNum++, dtHiddenStatus,  	0,  daCenter,	false, 	"STATUS");   
				InitDataProperty(0, colNum++, dtHidden,  		100,daLeft, 	false, 	"FILED1",	false,	"",	dfNone,	0,	false,	false,	20);    			    			
				InitDataProperty(0, colNum++, dtHidden,  		100,daLeft, 	false, 	"FILED2",	false,	"",	dfNone,	0,	false,	false,	20);    			    							
    			InitDataProperty(0, colNum++, dtData,      		205,daLeft, 	false, 	"CODE_NAME",false,  "", dfNone, 0,  false,  false);

				//Sheet 나타나도록 설정
			    Visible = true;
                sheetObj.CountPosition = 0;			    
			}			
		} else if( sheetObj.id == "sheet2" ) {
			with(sheetObj) { 
			
				//전체 너비 설정
				doResizeSheet(sheetObj);

				//전체Merge 종류 [선택, Default msNone]
				MergeSheet = msNone;
				
				//전체Edit 허용 여부 [선택, Default false]
				Editable = true;

				//행정보설정[필수][HEADROWS,DATAROWS,VIEWROWS,ONEPAGEROWS=100]
				InitRowInfo( 1, 1, 20, 20);
  
    			//컬럼정보설정[필수][COLS,FROZENCOL,LEFTHEADCOLS=0,FROZENMOVE=false]
    			InitColumnInfo(8, 6, 0, true);
                //헤더기능설정
                InitHeadMode(false, true, true, true, true, true);

                //해더행정보[필수][ROW,HEADTEXT, ROWMERGE=false, HIDDEN=false]
    			InitHeadRow(0, "All|STATUS|DEFAULT_FLAG|Item|Short Code|☞ Description|Item|Seq", false);

				var colNum = 0;
    			InitDataProperty(0, colNum++, dtCheckBox,      40,  daCenter,	false,	"NUM_CHECK");
    			InitDataProperty(0, colNum++, dtHiddenStatus,   0,  daCenter,	false, 	"STATUS");   
    			InitDataProperty(0, colNum++, dtHidden,  		0,  daCenter,	false, 	"DEFAULT_FLAG");
				InitDataProperty(0, colNum++, dtData,  		  150,  daLeft, 	true, 	"F_ITEM",		false,	"",	dfNone,	0,	false,	false,	20);	    			
				InitDataProperty(0, colNum++, dtData,  		  100,  daLeft, 	false, 	"SHORT_CD",		false,	"",	dfNone,	0,	false,	false,	20);	    							
				InitDataProperty(0, colNum++, dtData,  		  435,  daLeft, 	false, 	"SHORT_DESC",	false,	"",	dfNone,	0,	false,	false,	80);	
				InitDataProperty(0, colNum++, dtHidden,  	  150,  daLeft, 	false, 	"T_ITEM",		false,	"",	dfNone,	0,	false,	false,	80);	
				InitDataProperty(0, colNum++, dtHidden,  	   70,	daCenter, 	false, 	"ITEM_ORD",		false,	"",	dfNone,	0,	false,	false,	80);	
				
                //Sheet 나타나도록 설정
                Visible = true;
                sheetObj.CountPosition = 0;
                
                sheetObj.DataLinkMouse("SHORT_DESC") = true;
			}
		}
	}

	// 검색
	function doSearch(sheetObj) {
//		doRequisitionGroupNumberList(sheetObj);
	}
	function addSectSelectSch(value, dscr, formname) {

		var selectObj = eval("document.form1."+formname) ;	
		addOption(selectObj, value, dscr) ;
	} 		
	
	function add_select(obj, add_value, add_text, pos) {
		
		var opt = new Option(add_value, add_text);
		obj.options[pos] = opt;
		return ;
	}
	
	//Select Option Clear
	function clear_select(obj) {	
		sel_len = obj.length;	
		for(i = 0 ; i < sel_len; i++) {
			obj.options[i] = null;		
		}
		return ;
	}

	// 페이지 초기화 함수
	function doPageInit() {
		var f = document.form1;
		
		if(f.pop_div.value == "1"){
			
			if(f.insert_chk.value == '1'){
				document.getElementById('title_detail').innerHTML = 'Add';
			}else{
				document.getElementById('title_detail').innerHTML = 'Modify';
			}
			
		}else{
		
			var send = window.dialogArguments;
			// 팝업띄울때 제목 변환을 위한 추가 - 20120322
			if(send.insert_chk == '1'){
				document.getElementById('title_detail').innerHTML = 'Add';
			}else{
				document.getElementById('title_detail').innerHTML = 'Modify';
			}
			
			f.projectcd.value		= send.projectcd;
			f.projectid.value 		= send.projectid;
			f.projectnm.value 		= send.projectnm;
			f.SPEC_CLASS.value		= send.SPEC_CLASS;
			f.SCH_GROUP.value 		= send.SCH_GROUP;
			f.SIZE_MAX.value  		= send.SIZE_MAX;
			f.SIZE_MIN.value  		= send.SIZE_MIN;
			f.MATERIAL_CODE.value	= send.MATERIAL_CODE;
			f.RATING_CODE.value 	= send.RATING_CODE;
			f.R_SPEC_CLASS.value	= send.R_SPEC_CLASS;
			f.click_number.value	= send.click_number;
			f.insert_chk.value  	= send.insert_chk;
			f.GROUP_ID.value		= send.GROUP_ID;
			f.FIELD3.value			= send.FIELD3;
			f.FIELD4.value			= send.FIELD4;
			f.FIELD5.value			= send.FIELD5;
			f.FIELD6.value			= send.FIELD6;
			f.FIELD7.value      	= send.FIELD7;
			f.FIELD8.value			= send.FIELD8;	
			f.FIELD9.value			= send.FIELD9;
			f.FIELD10.value			= send.FIELD10;					
			f.FIELD11.value			= send.FIELD11;		
			f.CATE_CODE.value   	= send.CATE_CODE;
			f.DESIGN_CODE.value     = send.DESIGN_CODE;
			f.FLUID_SERVICE.value   = send.FLUID_SERVICE;
			f.p_hwen_code.value 	= send.p_hwen_code;
			makeSelect();
	
			if (f.CATE_CODE.value == '' && f.SIZE_MIN.value == '' && f.SIZE_MAX.value == '' && f.click_number.value) {
				f.CATE_CODE.value = '';
				f.SIZE_MIN.value = '';
				f.SIZE_MAX.value = '';
				f.click_number.value = '';
			}
			if (f.click_number.value != '') {	
				
				submitXmlRequest("/mcms/spec/specitem_detail_data.screen", "ITEM_DETAIL_LIST", document.form1, "ROWSET");	
				
			}
		}
		
	}
	
	function makeSelect(){
		var f = document.form1;
		if (f.projectcd.value == '') {
			
			return;
		}	
		if (f.SPEC_CLASS.value != '') {
			var spec = f.SPEC_CLASS.value.split(";");
	
			if (spec[2] == '-') {
				f.DESIGN_CODE.value = '';
			}
			else {
				f.DESIGN_CODE.value = spec[2];
			}
			if (spec[1] == '-') {
				f.FLUID_SERVICE.value = '';
			}
			else {
				f.FLUID_SERVICE.value = spec[1];
			}
			var len = f.RATING_CODE.length;
			if (len > 0) {
				for (var i=0; i < len; i++) {
				
					var ren = f.RATING_CODE[i].value.split(":");
					if (spec[3] == '-') {
						spec[3] = '';
					}
					if (ren[0].trim() == spec[3].trim()) {
						f.RATING_CODE[i].selected = true;
					}
				}
			}
			f.R_SPEC_CLASS.value = spec[0];
			f.class_value.value = spec[0];
			f.C_SPEC_CLASS.value = '';
			f.SCH_TYPE.value = '2';
			submitXmlRequest("/cmn/code/schedule_group_select.screen", "SCHEDULE_GROUP_LIST", document.form1, "ROWSET");
			document.form1.isSubmit = false;
		}
		else {
			f.DESIGN_CODE.value = '';
			f.FLUID_SERVICE.value = '';
			f.MATERIAL_CODE.value = '';
			f.RATING_CODE.value = '';
			clear_select(eval('document.form1.S_SCH_GROUP'));
			add_select(eval('document.form1.S_SCH_GROUP'), "-- Select --", "", 0);							
		}
	}
	
	
	
	//Item Category 선택시
	function doItemList() {
		if(document.form1.CATE_CODE.value == null || document.form1.CATE_CODE.value ==""){
			return;
		}
		document.form1.ing_change.value = '1';
		document.all.sheet2.RemoveAll();
		submitXmlRequest("/mcms/spec/specitem_category.screen", "ITEM_CATEGORY_LIST", document.form1, "ROWSET");
	}
	
	// 저장 처리 결과를 받는 예약 함수
	function doResult(resultObj) {
		try {
			var rs = resultObj.getRowSet();
			var f = document.form1;
			var cate_code 		= 	f.CATE_CODE.value.split(":");				
			if(resultObj.getRequestEvent() == "ITEM_CATEGORY_LIST"){
				resultRowSet = resultObj.getRowSet();				
				if( resultObj.getSuccess() == true){			
				    var upcnt = 0;
			        code_cloumn = new Array();
			        desc_column = new Array();
			        code_table  = new Array();
			        lib_column	= new Array();
			        lib_code	= new Array();
			        order_column= new Array();
			        desc_flag 	= new Array();
			        sub_code_no = new Array();
			        code_no = new Array();
			        
					doTitleInnerHtml(rs);
					
					f.MATERIAL_ITEM_1.value = '';
					f.MATERIAL_ITEM_3.value = '';
					resultRowSetSize = rs.getRowSize();						
					for( var i = 0 ; i < rs.getRowSize() ; i++ ) {					
						code_cloumn[upcnt] = rs.getColValue(i, 2);
						desc_column[upcnt] = rs.getColValue(i, 3);
						code_table[upcnt]  = rs.getColValue(i, 0);
						lib_column[upcnt]  = rs.getColValue(i, 4);
						lib_code[upcnt]    = rs.getColValue(i, 5);	
						order_column[upcnt]= rs.getColValue(i, 6);																							
						desc_flag[upcnt]   = rs.getColValue(i, 8);
						sub_code_no[upcnt] = rs.getColValue(i, 13);
						code_no[upcnt] 	   = rs.getColValue(i, 10);
						upcnt++;
					}
				    f.code_cloumn.value = code_cloumn.join(";");
				    f.desc_column.value = desc_column.join(";");
				    f.code_table.value 	= code_table.join(";");
				    f.lib_column.value 	= lib_column.join(";");
				    f.lib_code.value 	= lib_code.join(";");
				    f.order_column.value= order_column.join(";");
				    f.desc_flag.value 	= desc_flag.join(";");	
				    f.sub_code_no.value = sub_code_no.join(";");
				    f.m_code_no.value 	= code_no.join(";");
			    }		    			    			    			    			    			    
			    else {
					dlgErrorMsg(resultObj);
				}
				document.form1.isSubmit = false;	
				submitXmlRequest("/mcms/spec/specitem_material_select.screen", "MATERIAL_SLECT_VALUE", document.form1, "ROWSET");		
			}
			else if(resultObj.getRequestEvent() == "SCHEDULE_GROUP_LIST" ){
				if( resultObj.getSuccess() ) {
					
					clear_select(eval('document.form1.S_SCH_GROUP'));
					add_select(eval('document.form1.S_SCH_GROUP'), "-- Select --", "", 0);
					for( var i = 0 ; i < rs.getRowSize() ; i++ ) {
						addSectSelectSch(rs.getColValue(i, 0), rs.getColValue(i, 1), "S_SCH_GROUP");	
					}
					for( var j=0; j < f.S_SCH_GROUP.length; j++) {
						if (f.S_SCH_GROUP[j].value == f.SCH_GROUP.value) {
							f.S_SCH_GROUP[j].selected = true;
						}
					}
				}
				else {
					dlgErrorMsg(resultObj);
				}
				document.form1.isSubmit = false;
				
			}
			else if(resultObj.getRequestEvent() == "MATERIAL_SLECT_VALUE"){
				if( resultObj.getSuccess() == true){		
					for( var i = 0 ; i < rs.getRowSize() ; i++ ) {
						addSectSelect(rs.getColValue(i, 3), rs.getColValue(i, 3), rs.getColValue(i, 0));	
					}
					
					//setSelect(f.MATERIAL_ITEM_1, f.MATERIAL_CODE.value);
					/* else{
						f.MATERIAL_ITEM_1.value = f.MATERIAL_CODE.value;
					} */
				}
				else {
					dlgErrorMsg(resultObj);				
				}
				document.form1.isSubmit = false;
				document.form1.list_count.value = '';	
				searchIBSheet("/mcms/spec/specitem_add_data.screen", "SPECITEM_ADD_LIST", document.form1, document.all.sheet1);
				document.form1.isSubmit = false;
				if (f.click_number.value != '') {
					//getSubCode(1);									
					//submitXmlRequest("/cmn/lib/lib_spec_data.screen", "MATERIAL_DETAIL_SUB", document.form1, "rowset");					
					submitXmlRequest("/mcms/spec/specitem_sub_detail.screen", "MATERIAL_DETAIL_SUB", document.form1, "ROWSET");
				}
			}
			else if(resultObj.getRequestEvent() == "MATERIAL_DETAIL_SUB"){
				if( resultObj.getSuccess() == true){		
					for( var i = 0 ; i < rs.getRowSize() ; i++ ) {
						if (i == 0) {
							clearSectSelectSub(rs.getColValue(i, 0));
						}
						addSectSelect(rs.getColValue(i, 3), rs.getColValue(i, 3), rs.getColValue(i, 0));	
					}					
								
					if (f.ing_change.value == '1') {
						setSelect(f.MATERIAL_ITEM_1, f.MATERIAL_CODE.value);
						//f.MATERIAL_ITEM_1.value = f.MATERIAL_CODE.value;
					}
					else {
						if (f.MATERIAL_ITEM_1.length > 0) {
							
							var field3 = f.FIELD3.value.split(":");
							
							for (var i=0; i < f.MATERIAL_ITEM_1.length; i++) {
							
								var material_item = f.MATERIAL_ITEM_1[i].value.split(":");
							
								if (material_item[0] == field3[0]) {
									f.MATERIAL_ITEM_1[i].selected = true;
								}
							}
						}												
						if (f.MATERIAL_ITEM_2.length > 0) {
							
							var field4 = f.FIELD4.value.split(":");
							
							for (var i=0; i < f.MATERIAL_ITEM_2.length; i++) {
							
								var material_item = f.MATERIAL_ITEM_2[i].value.split(":");
							
								if (material_item[0] == field4[0]) {
									f.MATERIAL_ITEM_2[i].selected = true;
								}							
							}
						}						
						if (f.MATERIAL_ITEM_3.length > 0) {
							var field5 = f.FIELD5.value.split(":");	
							
							for (var i=0; i < f.MATERIAL_ITEM_3.length; i++) {
							
								var material_item = f.MATERIAL_ITEM_3[i].value.split(":");
							
								if (material_item[0] == field5[0]) {
									f.MATERIAL_ITEM_3[i].selected = true;
								}					
							}
						}
						if (f.MATERIAL_ITEM_4.length > 0) {
							var field6 = f.FIELD6.value.split(":");							
							
							for (var i=0; i < f.MATERIAL_ITEM_4.length; i++) {
							
								var material_item = f.MATERIAL_ITEM_4[i].value.split(":");
							
								if (material_item[0] == field6[0]) {
									f.MATERIAL_ITEM_4[i].selected = true;
								}				
							}
						}						
						if (f.MATERIAL_ITEM_5.length > 0) {
							var field7 = f.FIELD7.value.split(":");							
							
							for (var i=0; i < f.MATERIAL_ITEM_5.length; i++) {
							
								var material_item = f.MATERIAL_ITEM_5[i].value.split(":");
							
								if (material_item[0] == field7[0]) {
									f.MATERIAL_ITEM_5[i].selected = true;
								}		
							}
						}						
						if (f.MATERIAL_ITEM_6.length > 0) {
							
							var field8 = f.FIELD8.value.split(":");							
							
							for (var i=0; i < f.MATERIAL_ITEM_6.length; i++) {
							
								var material_item = f.MATERIAL_ITEM_6[i].value.split(":");
							
								if (material_item[0] == field8[0]) {
									f.MATERIAL_ITEM_6[i].selected = true;
								}															
							}
						}																								

						if (resultRowSetSize == 8 || resultRowSetSize == 10) {
							if (f.MATERIAL_ITEM_7.length > 0) {
							
								var field9 = f.FIELD9.value.split(":");		
							
								for (var i=0; i < f.MATERIAL_ITEM_7.length; i++) {
							
									var material_item = f.MATERIAL_ITEM_7[i].value.split(":");
							
									if (material_item[0] == field9[0]) {
										f.MATERIAL_ITEM_7[i].selected = true;
									}
								}
							}												
						}
						if (resultRowSetSize == 10) {
							if (f.MATERIAL_ITEM_8.length > 0) {
								
								var field10 = f.FIELD10.value.split(":");
								
								for (var i=0; i < f.MATERIAL_ITEM_8.length; i++) {
								
									var material_item = f.MATERIAL_ITEM_8[i].value.split(":");
									
									if (material_item[0] == field10[0]) {
										f.MATERIAL_ITEM_8[i].selected = true;
									}
								}
							}						
							if (f.MATERIAL_ITEM_9.length > 0) {
								
								var field11 = f.FIELD11.value.split(":");
								
								for (var i=0; i < f.MATERIAL_ITEM_9.length; i++) {

									var material_item = f.MATERIAL_ITEM_9[i].value.split(":");

									if (material_item[0].trim() == field11[0].trim()) {
										f.MATERIAL_ITEM_9[i].selected = true;
									}									
								}
							}																			
						}
					}									
				}
				else {
					dlgErrorMsg(resultObj);				
				}
				document.form1.isSubmit = false;
				
				if (f.click_number.value != '' && f.ing_change.value == '') {
					if (f.insert_chk.value == '') {
						var chk_value = f.category_code.value.split(";");
						for (var i=1; i < (document.all.sheet1.RowCount+1); i++) {
							for (var j=0; j < chk_value.length; j++) {
								if (document.all.sheet1.CellValue(i, "FILED1") == chk_value[j]) {
				                	document.getElementById("sheet1").CellValue(i,"NUM_CHECK")="1";
			    		        }
							}
						}
					}
					searchIBSheet("/mcms/spec/auto_symbol_data.screen", "AUTO_SYMBOLITEM_LIST", document.form1, document.all.sheet2);				
					document.form1.isSubmit = false;
					
					for (var k=1; k < (document.all.sheet2.RowCount+1); k++) {
						document.all.sheet2.CellText(k, "STATUS") = "입력";
					}
					
					var iCheckRow = document.all.sheet1.FindCheckedRow("NUM_CHECK").split("|");
					var itemcategory = f.CATE_CODE.value.split(":");
					
					
					
					if (itemcategory.length == 2) {
						//if (itemcategory[0].trim() == 'F') {
							if (iCheckRow.length == 2) {
								f.MATERIAL_ITEM_0.disabled = true;
								setSelect(f.MATERIAL_ITEM_0, document.all.sheet1.CellValue(iCheckRow[0], "CODE_NAME"));
								/*
								if (f.MATERIAL_ITEM_0.length > 0) {
									for (var i=0; i < f.MATERIAL_ITEM_0.length; i++) {
										if (document.all.sheet1.CellValue(iCheckRow[0], "CODE_NAME") == f.MATERIAL_ITEM_0[i].value) {
											
											//f.MATERIAL_ITEM_0[i].selected = true;
										}
									}
								}
								*/
							}
						//}
					}						
				}	
				if (f.insert_chk.value == '') {					
					
					var f = document.form1;
					var sheet1 = document.all.sheet1;
					var iCheckRow = sheet1.FindCheckedRow("NUM_CHECK");
					var arrRow = iCheckRow.split("|");
			
					if (arrRow.length == 1) {
						alert('Please, Check Item.');
						return;
					}						        
			        item_name = new Array();
			        item_code = new Array();
					var upcnt = 0;
			
					for( var i = 0 ; i < (arrRow.length-1) ; i++ ) {						
						item_name[upcnt] = sheet1.CellValue(arrRow[i], "CODE_NAME");
						item_code[upcnt] = sheet1.CellValue(arrRow[i], "FILED1");
						upcnt++;
					}					
					
					f.item_name.value = item_name.join(";");
					
					
					f.item_name.value = item_name;
					var cate_code = f.CATE_CODE.value.split(":");	
					
					//Valve 인경우 삭제, 박정규 2009.02.05				
					//if (cate_code[0].trim() == 'V') {						
	    				//submitXmlRequest("/mcms/spec/specitem_valve.screen", "VALVE_SUB_LIST", document.form1, "ROWSET");
	    			//}
    			}    	
    			//f.MATERIAL_ITEM_0.value = f.item_name.value;	  		
    			
    				
    			if(cate_code[0].trim() == 'F'||cate_code[0].trim() == 'V'){
    			}else{    				
    				//getSearchSubCode(1);	//beoms(2012.03.07): 수정모드일경우 아이템정보를 사라지게 만들어서 주석처리함
    			}
								
			}				
			else if(resultObj.getRequestEvent() == "MATERIAL_SUB_VALUE"){
				document.form1.isSubmit = false;
				if( resultObj.getSuccess() == true){					
					for( var i = 0 ; i < rs.getRowSize() ; i++ ) {
						if (i == 0) {							
							clearSectSelectSub(rs.getColValue(i, 0));
						}						
						addSectSelect(rs.getColValue(i, 3), rs.getColValue(i, 3), rs.getColValue(i, 0));	
					}
					if(document.form1.ing_change.value == '1'){
						setSelect(f.MATERIAL_ITEM_1, f.MATERIAL_CODE.value);
					}
				}
				else {
				
					dlgErrorMsg(resultObj);				
				}
				
			}			
			else if (resultObj.getRequestEvent() == "SPEC_ITEM_CHECK") {
				if (resultObj.getSuccess() == true) {

					var vo = resultObj.getValueObject();
			        f.size_from.value     =	vo.get("size_from");
			        f.size_to.value       = vo.get("size_to");
			        f.size_interval.value = vo.get("size_interval");
			        f.min_size_check.value 	  = vo.get("min_size_check");
			        f.max_size_check.value 	  = vo.get("max_size_check");

				}else{
					dlgErrorMsg(resultObj);
				}

				document.form1.isSubmit = false;
		        if (parseInt(f.size_from.value) > 0 ) {
					alert('The size range is overlaped !');
					return;					
				}
				if (parseInt(f.size_to.value) > 0 ) {
					alert('The size range is overlaped !');
					return;					
				}
				if (parseInt(f.size_interval.value) > 0 ) {
					alert('The size range is overlaped !');
					return;					
				}
				if(parseInt(f.min_size_check.value) == 0 ) {
					alert('Not finding the minimum value !');
					return;
				}
				if(parseInt(f.max_size_check.value) == 0 ) {
					alert('Not finding the maximum value !');
					return;
				}
				submitIBSheetRequest("/mcms/spec/specitem_add_process.screen", "AUTO_SPECITEM_SAVE", document.form1, document.all.sheet2);
			}
			else if (resultObj.getRequestEvent() == "AUTO_VALVE_CHK") {
				if (resultObj.getSuccess() == true) {

					var vo = resultObj.getValueObject();
			        var item_cnt = vo.get("item_cnt");
				}
				else {
					dlgErrorMsg(resultObj);
				}
				document.form1.isSubmit = false;
		        if (parseInt(item_cnt) != 1 ) {
				    alert("One Valve Group Select...\n*. Gate, Check, Globe Valve ...\n*. Ball Valve ...\n*. Plug Valve ...\n*. Butterfly Valve ...");
					return;					
				}
				else {
					doAddItem();
				}
			}			
			else if (resultObj.getRequestEvent() == "AUTO_FLANGE_CHK") {
				if (resultObj.getSuccess() == true) {

					var vo = resultObj.getValueObject();
			        var item_cnt = vo.get("item_cnt");
				}
				else {
					dlgErrorMsg(resultObj);
				}
				document.form1.isSubmit = false;
		        if (parseInt(item_cnt) != 1 ) {
				    alert("One Flange Group Select...\n*. 4,5,6,7,B,L,S,U,W,T,H ...\n*. C,D,P,E...");
					return;					
				}
				else {
					doAddItem();
				}
			}			
			else if (resultObj.getRequestEvent() == "AUTO_SPECITEM_SAVE") {
				if (resultObj.getSuccess() == true) {			
					alertMsg('SAVE_OK','');					
					//2009.04.30 Park Add하게되면 저장후 Window 닫히게 처리!
					if(f.insert_chk.value==''){
						window.close();
					}else{
						window.opener.doSearch1();
						window.parent.focus();
					}
			    }
				else {
					dlgErrorMsg(resultObj);
				}
				document.form1.isSubmit = false;				
			}
			else if (resultObj.getRequestEvent() == "ITEM_DETAIL_LIST") {
				
				code = new Array();
				var upcnt = 0;
				for( var i = 0 ; i < rs.getRowSize() ; i++ ) {
					code[upcnt] = rs.getColValue(i, 0);
					upcnt++;
				}		
				f.category_code.value = code.join(";");
				document.form1.isSubmit = false;
				
				submitXmlRequest("/mcms/spec/specitem_category.screen", "ITEM_CATEGORY_LIST", document.form1, "ROWSET");
			}
			else if (resultObj.getRequestEvent() == "VALVE_SUB_LIST") {
				if( resultObj.getSuccess() == true){					
					for( var i = 0 ; i < rs.getRowSize() ; i++ ) {
						if (rs.getColValue(i, 0) == 0) {
							clearSectSelectSub(rs.getColValue(i, 4));																		
						}
						addSectSelect(rs.getColValue(i, 2), rs.getColValue(i, 2), rs.getColValue(i, 4));							
					}
				}
				else {
					dlgErrorMsg(resultObj);				
				}
			}
			document.form1.isSubmit = false;		
		} catch(errorObject) {
	        showErrorDlg("doResult()", errorObject);
		}
	}
	
	//서브 코드를 찾는다.
	function doSubItem(sub_code) {
		
		var f = document.form1;
		
		if (sub_code != '0') {
			document.form1.CODE_NO.value = sub_code;
			f.MATERIAL_CODE.value = f.MATERIAL_ITEM_1.value;
			
			submitXmlRequest("/mcms/spec/specitem_sub_select.screen", "MATERIAL_SUB_VALUE", document.form1, "ROWSET");	
		}
	}
	
	function doTitleInnerHtml(rs) {
		var selectBoxModel = "";	
		var f = document.form1;
		var cate_code = f.CATE_CODE.value.split(":");
		for (var i=0; i < rs.getRowSize(); i++) {
			selectBoxModel+="<TABLE WIDTH='100%' BORDER='0' CELLSPACING='0' CELLPADDING='0'>\n";
			selectBoxModel+="<TR height='23' width='100%'>\n"; 
			selectBoxModel+="<TD width='30%' ALIGN='RIGHT' style='padding-right:3px;'>"+rs.getColValue(i, 1)+"</TD>\n";			  	
			selectBoxModel+="<TD id='sheet2_td' height='23' width='55%'>\n";
			selectBoxModel+="<select style='width:100%;height=18' class='input_select' name='MATERIAL_ITEM_"+rs.getColValue(i, 9)+"' class='input_select' onChange='getSearchSubCode("+rs.getColValue(i, 10)+");' id=''\n";
			//selectBoxModel+="<select style='width:100%;height=18' class='input_select' name='MATERIAL_ITEM_"+rs.getColValue(i, 9)+"' class='input_select' onChange='doSubItem("+rs.getColValue(i, 13)+");' \n";
			if (i == 0) {
				selectBoxModel+=" disabled \n";
			} 

			if (cate_code[0].trim() == 'F') {
				if (i ==3 || i == 5 || i == 6) {
					selectBoxModel+="style='background-color:00ff7f;' \n";
				}
			}
			if (cate_code[0].trim() == 'V') {
				//if (i ==3 || i == 6 || i == 7 || i == 8) {
				if (i ==3 || i == 7 || i == 8) {
					selectBoxModel+="style='background-color:00ff7f;' \n";
				}
			}
			selectBoxModel+=" >\n";
			selectBoxModel+="<OPTION value=''>-- Select --</OPTION>\n";
			selectBoxModel+="</select>\n";
			selectBoxModel+="</TD>\n";
			selectBoxModel+="<TD>\n";
			if (i != 0) {
				selectBoxModel+="<IMG id='search_material_button_"+rs.getColValue(i, 10)+"' onClick='doMaterialItemPopup("+rs.getColValue(i, 10)+");' src='/img/button/bt_search_right.gif' border='0' align='absmiddle' alt='[MATERIAL ITEM Select]' style='cursor:hand;'>\n";
			} else {
				selectBoxModel+="&nbsp;\n";
			} 
			
			selectBoxModel+="</TD>\n";
			selectBoxModel+="</TR>\n";
			selectBoxModel+="</TABLE>\n";			
			
			if (rs.getColValue(i, 1) == 'CLASS') {
				f.list_count.value = '1';
			} 
		}		
		//f.test_area.value = selectBoxModel;
		materialTitle.innerHTML = selectBoxModel;
	}
	
	//	Material Item 팝업
	function doMaterialItemPopup(sel_no) {
		var f = document.form1;		
		var result = "false";
		var url = '/cmn/lib/POPUPSearchMaterialItem.screen';
		
		var sel_id = sel_no - 1;
		var selectObj = document.getElementById(eval("'MATERIAL_ITEM_"+sel_id+"'"));
		var selArray = new Array();
		//alert(selectObj.options[1].value);
		
		for(var i=1; i < selectObj.length; i++) {
			var tmp = selectObj.options[i].value.split(":");
			selArray.push(tmp[0] + "|" + selectObj.options[i].text);
			
		}
		//alert(selArray[0]);
		result = window.showModalDialog(url, selArray,'dialogWidth:705px;dialogHeight:485px; center:yes; help:no; status:no; scroll:yes; resizable:no');
		
		if( result == null ){
	        return;
	    }
	    
	    setSelect(eval("document.getElementById('MATERIAL_ITEM_"+sel_id+"')"), result[1]);
	    getSearchSubCode(sel_no);

	}

	//비어있는 셀렉트박스 항목 조회조건 세팅및 해당항목 조회
	function getSearchSubCode(dep){
		//alert(dep);
		var idx = dep -1 ;
		//if(eval("document.all['MATERIAL_ITEM_"+idx+"']").value == ""){
		//	alert("1111");
		//	return ;
		//}		
		document.getElementById("isWhere1").value = "" ;		
		document.getElementById("isKey1").value = "" ;		
		var f 				= document.form1 ;
		var cate_code 		= 	f.CATE_CODE.value.split(":");
		var key 			= cate_code[0].trim();		
		var category		= cate_code[0].trim();		
		var res				= "" ;
		var tempStr			= "" ;		
		var tmpCodeId		= "" ;
		var tObj			= eval("document.all['MATERIAL_ITEM_"+(idx+1)+"']");
		var nextIsSubmit	= false ;					
		//alert("resultRowSet.getColValue(idx, 13)"+resultRowSet.getColValue(idx, 13));
	//선택항항목이 있을경우 해당 코드분리후 일치하는 SUBCODE 존재유무에 따라처리한다.
		if(resultRowSet.getColValue(idx, 13) != ""){			
			tempStr = resultRowSet.getColValue(idx, 13);
			tmpCodeId = resultRowSet.getColValue(dep, 10);
			var selectObj = eval("document.all['MATERIAL_ITEM_"+dep+"']");		// 선택된 SELECT BOX 객체
			var nextObj = eval("document.all['MATERIAL_ITEM_"+tmpCodeId+"']");
			
			if(document.all.sheet2.RowCount == 0){
				alert('Please, Check Item.');
				return; 				
			}
			
			var flg_key = document.all.sheet2.CellValue(1, "F_ITEM").substring(0,1);			
			
			for(var i = 0; i<resultRowSet.getRowSize(); i++){
				var keyObj = eval("document.all['MATERIAL_ITEM_"+i+"']");
				var value = keyObj.value.split(":");
				var keyvalue = value[0].trim();
				if(keyObj.value == ""){
					//FLANGE 일때 처리 부분					
					if(i==0){						
						key += flg_key;						
					}else{					
						key += "%";					
					}
				}else{
					key += keyvalue;
				}
			}
				
			document.getElementById("isWhere1").value = key ;
			document.getElementById("isKey1").value = tempStr;
			
			nextIsSubmit = true;
			if(nextIsSubmit == true){				
				if(tempStr != ""){
					getTmpStrCut(tempStr);
				}		
				f.ing_change.value = dep;
				submitXmlRequest("/cmn/lib/lib_spec_data.screen", "MATERIAL_SUB_VALUE", document.form1, "ROWSET");
			}
		}
	}
	
	//Modify 후 SubCode Search
	function getSubCode(dep){
		var idx = dep -1 ;
		if(eval("document.all['MATERIAL_ITEM_"+idx+"']").value == ""){
			return ;
		}		
		document.getElementById("isWhere1").value = "" ;		
		document.getElementById("isKey1").value = "" ;		
		var f 				= document.form1 ;
		var cate_code 		= 	f.CATE_CODE.value.split(":");
		var key 			= cate_code[0].trim();		
		var res				= "" ;
		var tempStr			= "" ;		
		var tmpCodeId		= "" ;
		var tObj			= eval("document.all['MATERIAL_ITEM_"+(idx+1)+"']");
		var nextIsSubmit	= false ;						
		
	
	//선택항항목이 있을경우 해당 코드분리후 일치하는 SUBCODE 존재유무에 따라처리한다.
		if(resultRowSet.getColValue(idx, 13) != "0"){			
			tempStr = resultRowSet.getColValue(idx, 13);
			tmpCodeId = resultRowSet.getColValue(dep, 10);			
			
			var selectObj = eval("document.all['MATERIAL_ITEM_"+dep+"']");		// 선택된 SELECT BOX 객체
			var nextObj = eval("document.all['MATERIAL_ITEM_"+tmpCodeId+"']");
			
			
			for(var i = 0; i<resultRowSet.getRowSize(); i++){
				var keyObj = eval("document.all['MATERIAL_ITEM_"+i+"']");
				var value = keyObj.value.split(":");
				var keyvalue = value[0].trim();
				if(keyObj.value == ""){
					
					key += "%";
				}else{
					key += keyvalue;
				}
			}
				
			document.getElementById("isWhere1").value = key ;
			document.getElementById("isKey1").value = tempStr;
			nextIsSubmit = true;				
			if(nextIsSubmit == true){				
				if(tempStr != ""){
					getTmpStrCut(tempStr);
				}
				return true;				
				
			}
		}
	}
	
	function getTmpStrCut(str){	
	var idx = "" ;
	for( var i = 0; i<str.length; i++){
		idx = str.substr(i, 1) ;
		if(idx == "0"){
			clearSectSelectSub(idx);
		}else{
			clearSectSelectSub(idx-1);
			}
		}
	}

	// 분류체계 SELECT 추가
	function addSectSelect(value, dscr, key) {
		var selectObj = eval("document.form1.MATERIAL_ITEM_"+key) ;	
		addOption(selectObj, value, dscr) ;
		
	} 
	
	// 분류체계 SUBCODE SELECT Clear
	function clearSectSelectSub(key) {
		if(key!=0){
			obj = eval("document.form1.MATERIAL_ITEM_"+key) ;		
			removeAllOptions(obj);
			addOption(obj, "", "-- Select --" );			
		}
	}

	function doSizeValue() {
		var f = document.form1;
		f.SIZE_MAX.value = f.SIZE_MIN.value;
	}	
	
	function doSizInterval() {
		var f = document.form1;
		if (parseFloat(f.SIZE_MIN.value) > parseFloat(f.SIZE_MAX.value)) {
			alert('Largest size is lesser than shortest size.');
			f.SIZE_MAX.value = '';
			return;
		}		
	}
		
	function doFlangeValueList(Row) {
		var f = document.form1;

		var argObj = new Object();
		
		argObj.title = 'Flange & Valve Setting List';
		
		argObj.projectcd   = f.projectcd.value;
		argObj.cate_code   = f.CATE_CODE.value;
		argObj.rating_code = f.RATING_CODE.value;
		argObj.sch_group   = document.all.sheet2.CellValue(Row, "SHORT_CD");
	    result = window.showModalDialog(getDummyUrl('/mcms/spec/flange_valve_list.screen'), argObj, 'dialogWidth:800px;dialogHeight:600px; center:yes; help:no; status:no; scroll:no; resizable:no');
		
        return;		
	}
	
	
	function doValveChk() {
	
		var f = document.form1;
		// 화살표 버튼을 막기 위한 추가 - 20120322 
		if(f.insert_chk.value != '1'){
			alert('It is only a add event.');
			return;
		}
		var sheet1 = document.all.sheet1;
		var iCheckRow = sheet1.FindCheckedRow("NUM_CHECK");
		var arrRow = iCheckRow.split("|");

		if (arrRow.length == 1) {
			alert('Please, Check Item.');
			return;
		}
		var category = f.CATE_CODE.value.split(":");
        item_code = new Array();
        item_name = new Array();
		var upcnt = 0;

		for( var i = 0 ; i < (arrRow.length-1) ; i++ ) {	
			item_code[upcnt] = sheet1.CellValue(arrRow[i], 2);
			item_name[upcnt] = sheet1.CellValue(arrRow[i], 4);
			upcnt++;
		}
		
		f.item_code.value = item_code.join(";");
		f.item_name.value = item_name.join(";");
		if (category[0].trim() == 'V') {
			submitXmlRequest("/mcms/spec/auto_valve_check.screen", "AUTO_VALVE_CHK", document.form1, "VALUEOBJECT");	
		}else if(category[0].trim() == 'F'){			
			submitXmlRequest("/mcms/spec/auto_flange_check.screen", "AUTO_FLANGE_CHK", document.form1, "VALUEOBJECT");	
		}else{
			doAddItem();
		}
	}
	
	function removeValveChk() {
	
		var f = document.form1;
		// 화살표 버튼을 막기 위한 추가 - 20120322 
		if(f.insert_chk.value != '1'){
			alert('It is only a add event.');
			return;
		}
		var sheet2 = document.all.sheet2;
		var iCheckRow = sheet2.FindCheckedRow("NUM_CHECK");
		var arrRow = iCheckRow.split("|");

		if (arrRow.length == 1) {
			alert('Please, Check Remove Item.');
			return;
		}
		var category = f.CATE_CODE.value.split(":");
        item_code = new Array();
        item_name = new Array();
		var upcnt = 0;

		for( var i = 0 ; i < (arrRow.length-1) ; i++ ) {	
			item_code[upcnt] = sheet2.CellValue(arrRow[i], 2);
			item_name[upcnt] = sheet2.CellValue(arrRow[i], 4);
			upcnt++;
		}
		
		f.item_code.value = item_code.join(";");
		f.item_name.value = item_name.join(";");		
		doRemoveItem();
		
	}

	function doAddItem() {
		var result = "false";
		var f = document.form1;
		var iCheckRow = document.all.sheet1.FindCheckedRow("NUM_CHECK").split("|");
		var itemcategory = f.CATE_CODE.value.split(":");

		
		f.MATERIAL_ITEM_0.disabled = true;
	   
		var url = '/mcms/spec/auto_symbol_list.screen';
		argObj = new Object();
		argObj.projectcd	= f.projectcd.value;
		argObj.R_SPEC_CLASS	= f.R_SPEC_CLASS.value;
		argObj.item_name 	= f.item_name.value;
		argObj.item_code	= f.item_code.value;
		argObj.click_number	= f.click_number.value;
		argObj.GROUP_ID		= f.GROUP_ID.value;
		argObj.CATE_CODE    = f.CATE_CODE.value;

		var result = window.showModalDialog(getDummyUrl(url), argObj, 'dialogWidth:700px;dialogHeight:500px;center:yes;help:no;status:no;scroll:no;resizable:no');			
	    
		if( result != null ) {
			with(document.all.sheet2) {
				RemoveAll();
				for(var i = 0; i < result.length; i++){
					DataInsert(i+1);
					CellText(i+1, "STATUS") = "입력";
					CellValue(i+1, "DEFAULT_FLAG")=  result[i]["DEFAULT_FLAG"];       
					CellValue(i+1, "F_ITEM")     	=  result[i]["F_ITEM"];      
					CellValue(i+1, "SHORT_CD")	=  result[i]["SHORT_CD"];			
					CellValue(i+1, "SHORT_DESC")	=  result[i]["SHORT_DESC"];			
					CellValue(i+1, "T_ITEM")		=  result[i]["T_ITEM"];			
					CellValue(i+1, "ITEM_ORD")	=  result[i]["ITEM_ORD"];												
				}
			}
		}else{
			return;
		}
				    
		if (iCheckRow.length == 2) {
			f.MATERIAL_ITEM_0.disabled = false;
			setSelect(f.MATERIAL_ITEM_0, document.all.sheet1.CellValue(iCheckRow[0], "CODE_NAME"));
			f.MATERIAL_ITEM_0.disabled = true;
		}
		else {
			f.MATERIAL_ITEM_0.disabled = true;
			f.MATERIAL_ITEM_0.value = '';
		}
/**		
		var url_param1 = 'CATE_CODE='+f.CATE_CODE.value+'&ITEM_NAME='+f.item_name.value+'&ITEM_CODE='+f.item_code.value+'&FIELD3='+f.FIELD3.value;
		var url_param2 = '&FIELD4='+f.FIELD4.value+'&FIELD5='+f.FIELD5.value+'&FIELD6='+f.FIELD6.value+'&FIELD7='+f.FIELD7.value;
		var url_param3 = '&FIELD8='+f.FIELD8.value+'&FIELD9='+f.FIELD9.value+'&FIELD10='+f.FIELD10.value+'&FIELD11='+f.FIELD11.value;
		var url = '/mcms/spec/auto_symbol_list.screen?'+url_param1+url_param2+url_param3;
	    result = window.showModalDialog(url,'addsymbol','dialogWidth:700px;dialogHeight:500px;center:yes;help:no;status:no;scroll:no;resizable:no');
		
		if( result == null ) {
	        return;
	    } else {
	    	var sheet2 = document.all.sheet2;

			var num_check 	= result[0].split(";");
			var defalut_flag= result[1].split(";");
			var f_item 		= result[2].split(";");
			var short_cd 	= result[3].split(";");
			var short_desc 	= result[4].split(";");
			var t_item 		= result[5].split(";");
			var item_ord 	= result[6].split(";");
			
			sheet2.RemoveAll();						
							
			if (num_check.length > 0) {
			

		
				for (var i=0; i < num_check.length; i++) {
					var rowIndex = sheet2.DataInsert();
					sheet2.CellValue(rowIndex, "NUM_CHECK") 	= num_check[i];
					sheet2.CellValue(rowIndex, "DEFAULT_FLAG") 	= defalut_flag[i];
					sheet2.CellValue(rowIndex, "F_ITEM")     	= f_item[i];
					sheet2.CellValue(rowIndex, "SHORT_CD")		= short_cd[i];
					sheet2.CellValue(rowIndex, "SHORT_DESC")	= short_desc[i];
					sheet2.CellValue(rowIndex, "T_ITEM")		= t_item[i];
					sheet2.CellValue(rowIndex, "ITEM_ORD")		= item_ord[i];
				}
			} 
		}			
*/		
	}
	
	function doRemoveItem() {
		
          var iCheckRow = document.all.sheet2.FindCheckedRow("NUM_CHECK");
          var removeCheckRow = iCheckRow.split("|");          
          for (idx=(removeCheckRow.length-1); idx > 0; idx--) {
              document.all.sheet2.RowDelete(removeCheckRow[idx-1], false);
          }
          document.all.sheet2.CheckAll(0) = 0;
          //document.all.sheet1.CheckAll(0) = 0;
	}
	
	function doInputSch(){
		document.form1.SCH_GROUP.value = document.form1.S_SCH_GROUP.value;
		
		
	}
		
	function doAdd() {

		var sheet1 = document.all.sheet1;
		var sheet2 = document.all.sheet2;
		var f = document.form1;
		var cate_code = f.CATE_CODE.value.split(":");
		
		if (sheet1.FindCheckedRow("NUM_CHECK").length == '0') {
			alertMsg('SELECT_CHK','Item Grtegory.');			
			return;
		}
		if (sheet2.CellValue(1, "F_ITEM") == '') {
			alertMsg('SELECT_CHK','Symbol Item.'); 
			return;
		}
		if (f.SIZE_MIN.value == '') {
			alertMsg('SELECT_CHK','Size Min.'); 
			return;
		}
		if (f.SIZE_MAX.value == '') {
			alertMsg('SELECT_CHK','Size Max.'); 
			return;
		}

		if (cate_code[0].trim() == 'F') {
			if (f.MATERIAL_ITEM_1.value == '' ) {
				alertMsg('SELECT_CHK','Material Code.'); 
				f.MATERIAL_ITEM_1.focus();				
				return;
			}
			if (f.MATERIAL_ITEM_2.value == '' ) {
				alertMsg('SELECT_CHK','Material Code.'); 
				f.MATERIAL_ITEM_2.focus();				
				return;
			}		
			if (f.MATERIAL_ITEM_4.value == '' ) {
				alertMsg('SELECT_CHK','Material Code.'); 
				f.MATERIAL_ITEM_4.focus();				
				return;
			}				
		}
		else if (cate_code[0].trim() == 'V') {
			if (f.MATERIAL_ITEM_1.value == '' ) {
				alertMsg('SELECT_CHK','Material Code.'); 
				f.MATERIAL_ITEM_1.focus();
				return;
			}		
			if (f.MATERIAL_ITEM_2.value == '' ) {
				alertMsg('SELECT_CHK','Material Code.'); 
				f.MATERIAL_ITEM_2.focus();				
				return;
			}
			if (f.MATERIAL_ITEM_4.value == '' ) {
				alertMsg('SELECT_CHK','Material Code.'); 
				f.MATERIAL_ITEM_4.focus();				
				return;
			}
			if (f.MATERIAL_ITEM_5.value == '' ) {
				alertMsg('SELECT_CHK','Material Code.'); 
				f.MATERIAL_ITEM_5.focus();				
				return;
			}		
			if (f.MATERIAL_ITEM_6.value == '' ) {
				alertMsg('SELECT_CHK','Material Code.'); 
				f.MATERIAL_ITEM_6.focus();				
				return;
			}		
			if (f.MATERIAL_ITEM_9.value == '' ) {
				alertMsg('SELECT_CHK','Material Code.'); 
				f.MATERIAL_ITEM_9.focus();				
				return;
			}				
		}
		else if (cate_code[0].trim() == 'K') {
			if (f.MATERIAL_ITEM_1.value == '' ) {
				alertMsg('SELECT_CHK','Material Code.'); 
				f.MATERIAL_ITEM_1.focus();
				return;
			}		
			if (f.MATERIAL_ITEM_2.value == '' ) {
				alertMsg('SELECT_CHK','Material Code.'); 
				f.MATERIAL_ITEM_2.focus();				
				return;
			}
			if (f.MATERIAL_ITEM_3.value == '' ) {
				alertMsg('SELECT_CHK','Material Code.'); 
				f.MATERIAL_ITEM_3.focus();				
				return;
			}		
			if (f.MATERIAL_ITEM_4.value == '' ) {
				alertMsg('SELECT_CHK','Material Code.'); 
				f.MATERIAL_ITEM_4.focus();				
				return;
			}
			if (f.MATERIAL_ITEM_5.value == '' ) {
				alertMsg('SELECT_CHK','Material Code.'); 
				f.MATERIAL_ITEM_5.focus();				
				return;
			}			
			if (f.MATERIAL_ITEM_6.value == '' ) {
				alertMsg('SELECT_CHK','Material Code.'); 
				f.MATERIAL_ITEM_6.focus();				
				return;
			}						
		}
		else if (cate_code[0].trim() == 'P') {
			if (f.MATERIAL_ITEM_1.value == '' ) {
				alertMsg('SELECT_CHK','Material Code.'); 
				f.MATERIAL_ITEM_1.focus();				
				return;
			}
			if (f.MATERIAL_ITEM_2.value == '' ) {
				alertMsg('SELECT_CHK','Material Code.'); 
				f.MATERIAL_ITEM_2.focus();				
				return;
			}		
			if (f.MATERIAL_ITEM_3.value == '' ) {
				alertMsg('SELECT_CHK','Material Code.'); 
				f.MATERIAL_ITEM_3.focus();				
				return;
			}
			if (f.MATERIAL_ITEM_4.value == '' ) {
				alertMsg('SELECT_CHK','Material Code.'); 
				f.MATERIAL_ITEM_4.focus();				
				return;
			}		
			if (f.MATERIAL_ITEM_5.value == '' ) {
				alertMsg('SELECT_CHK','Material Code.'); 
				f.MATERIAL_ITEM_5.focus();				
				return;
			}
			if (f.MATERIAL_ITEM_6.value == '' ) {
				alertMsg('SELECT_CHK','Material Code.'); 
				f.MATERIAL_ITEM_6.focus();				
				return;
			}		
			if (f.MATERIAL_ITEM_7.value == '' ) {
				alertMsg('SELECT_CHK','Material Code.'); 
				f.MATERIAL_ITEM_7.focus();				
				return;
			}
		}
		for (var j=1; j < (sheet2.RowCount+1); j++) {
			sheet2.RowStatus(j) = "I";
		}
		var i_row = sheet2.FindStatusRow("I").split(";");
		symbol_code = new Array();
		upcnt = 0;
		for (var i=0; i < (i_row.length-1); i++) {
			symbol_code[upcnt] = sheet2.CellValue(i_row[i], "SHORT_CD");
			
			upcnt++;
		}
		f.symbol_code.value = symbol_code.join(";");
		document.form1.isSubmit = false;
		submitXmlRequest("/mcms/spec/auto_specitem_chk.screen", "SPEC_ITEM_CHECK", document.form1, "VALUEOBJECT");			
		
	}
		
	function doExit() {
		returnValue = new Array('OK');
		window.close();
	}	
	document.body.onload = doPageInit;
    document.body.onresize = addEvent( document.body.onresize, "doResizeSheet(document.all.sheet1)");	
	document.body.onunload = doExit;	
</SCRIPT>
<Script language="javascript" for="sheet2" event="OnClick(Row,Col)">
	
	var sName = ColSaveName(Col);
	var f = document.form1;
	
	var category = f.CATE_CODE.value.split(":");
	
	if (category[0].trim() == 'F' || category[0].trim() == 'V') {
		switch(sName)
	    {	
			case "SHORT_DESC":
				doFlangeValueList(Row);
				break;
		}
	}
</script>
<SCRIPT language="javascript" for="sheet1" event="OnClick(Row,Col,Value)">
</SCRIPT>
<form name="form1">
<!-- <textarea rows="5" cols="50" id="test_area" name="test_area"></textarea> -->
<input type="hidden" name="projectid" 	value="<%= params.get("projectid") %>"/>
<input type="hidden" name="projectcd" 	value="<%= params.get("projectcd") %>"/>
<input type="hidden" name="projectnm" 	value="<%= params.get("projectnm") %>" />
<input type="hidden" name="SPEC_CLASS"  value="<%= params.get("SPEC_CLASS") %>"/>
<input type="hidden" name="SCH_GROUP" 	value="<%= params.get("SCH_GROUP") %>"/>
<input type="hidden" name="SCH_TYPE" 	value="<%= params.get("SCH_TYPE") %>"/>
<input type="hidden" name="MATERIAL_CODE" value="<%= params.get("MATERIAL_CODE") %>"/>
<input type="hidden" name="RATING_CODE" value="<%= params.get("RATING_CODE") %>"/>
<input type="hidden" name="R_SPEC_CLASS" value="<%= params.get("R_SPEC_CLASS") %>"/>
<input type="hidden" name="C_SPEC_CLASS" value="<%= params.get("C_SPEC_CLASS") %>">
<input type="hidden" name="code_cloumn" value="<%= params.get("code_cloumn") %>"/>
<input type="hidden" name="desc_column" value="<%= params.get("desc_column") %>"/>
<input type="hidden" name="code_table" 	value="<%= params.get("code_table") %>"/>
<input type="hidden" name="lib_column" 	value="<%= params.get("lib_column") %>"/>
<input type="hidden" name="lib_code" 	value="<%= params.get("lib_code") %>"/>
<input type="hidden" name="order_column" value="<%= params.get("order_column") %>"/>
<input type="hidden" name="desc_flag" 	value="<%= params.get("desc_flag") %>"/>		
<input type="hidden" name="list_count"	value="<%= params.get("list_count") %>">
<input type="hidden" name="class_value" value="<%= params.get("class_value") %>" >
<input type="hidden" name="CODE_NO"		value="">
<input type="hidden" name="item_code"	value="">
<input type="hidden" name="item_name"	value="">
<input type="hidden" name="fevent"		value="">
<input type="hidden" name="size_from"	value="">
<input type="hidden" name="size_to"		value="">
<input type="hidden" name="size_interval" value="">
<input type="hidden" name="min_size_check" value="">
<input type="hidden" name="max_size_check" value="">
<input type="hidden" name="symbol_code"	value="">
<input type="hidden" name="click_number" value="<%= params.get("click_number") %>">
<input type="hidden" name="GROUP_ID" 	value="<%= params.get("GROUP_ID") %>">
<input type="hidden" name="category_code">
<input type="hidden" name="F_CATE_CODE" value="<%= params.get("F_CATE_CODE") %>">
<input type="hidden" name="FIELD3" 	value="<%= params.get("FIELD3") %>">
<input type="hidden" name="FIELD4" 	value="<%= params.get("FIELD4") %>">
<input type="hidden" name="FIELD5" 	value="<%= params.get("FIELD5") %>">
<input type="hidden" name="FIELD6" 	value="<%= params.get("FIELD6") %>">
<input type="hidden" name="FIELD7" 	value="<%= params.get("FIELD7") %>">
<input type="hidden" name="FIELD8" 	value="<%= params.get("FIELD8") %>">
<input type="hidden" name="FIELD9" 	value="<%= params.get("FIELD9") %>">
<input type="hidden" name="FIELD10" value="<%= params.get("FIELD10") %>">
<input type="hidden" name="FIELD11" value="<%= params.get("FIELD11") %>">
<input type="hidden" name="ing_change">
<input type="hidden" name="sub_code_no" value="<%= params.get("sub_code_no") %>">
<input type="hidden" name="m_code_no" 	value="<%= params.get("m_code_no") %>">
<input type="hidden" name="insert_chk"  value="<%= params.get("insert_chk") %>">
<input type="hidden" id="DESIGN_CODE" name="DESIGN_CODE" value="<%= params.get("DESIGN_CODE") %>">
<input type="hidden" id="FLUID_SERVICE" name="FLUID_SERVICE" value="<%= params.get("FLUID_SERVICE") %>">

<input type="hidden" name="p_hwen_code" value="<%= params.get("p_hwen_code") %>">


<input type="hidden" name="isKey1" value="">
<input type="hidden" name="isWhere1" value="">

<input type="hidden" name="pop_div" value="<%= params.get("pop_div") %>">	<!-- 팝업타입이 다이얼로그:0, open:1 -->


<table border="0" cellspacing="0" cellpadding="0" width="100%" height="100%">
	<!-- tr>
		<td height="1" colspan="3">
			<table class="screen_title_table">
				<tr height="2">
					<td colspan="2"></td>
				</tr>
				<tr height="25">
					<td width="16" valign="middle"><img src="/img/button/bullet_03.gif"></td>
					<td width="100%" class="screen_title_text">List of Item</td>
				</tr>
			</table>
		</td>
	</tr-->
	<tr height="25" style="width:100%;">
		<td width="100%" colspan="3">
			<table border="0" cellspacing="1" cellpadding="0" width="100%" class="search_table">
				<tr height="25">
					<td width="20%" class="search_table_data">&nbsp;&nbsp;<span id="title_detail" style="font:bold;"></span></td>
					<td width="80%" class="search_table_data">
						<div id="button" style="display:block;">
							<table border="0" cellpadding="0" cellspacing="0" align="right">
								<tr>
									<td width="10"></td>
									<td>
										<div id="btn_insert" style="display:''" onclick="javascript:doAdd()" class="button_style">
											<table border="0" cellpadding="0" cellspacing="0">
												<tr>
													<td class="button_left1"></td>
													<td class="button_text2">Add</td>
													<td class="button_right"></td>
												</tr>
											</table>
										</div>
									</td>
									<td width="5">
									</td>										
									<td>
										<div id="btn_insert" style="display:''" onclick="javascript:doExit()" class="button_style">
											<table border="0" cellpadding="0" cellspacing="0">
												<tr>
													<td class="button_left1"></td>
													<td class="button_text2">Close</td>
													<td class="button_right"></td>
												</tr>
											</table>
										</div>
									</td>										
									<td width="10"></td>
								</tr>
							</table>
						</div>
					</td>
				</tr>
			</table>
		</td>
	</tr>
		
	<tr height="1">
		<td colspan="3">
			<table border="0" cellspacing="0" cellpadding="0" class="search_data_div_height">
				<tr>
					<td></td>
				</tr>
			</table>
	 	</td>
	</tr>
	<tr>
		<td height="100%">
			<table border='0' cellspacing="0" cellpadding="0" style="width:100%;height:100%;">
				<tr style="height:25">
					<td width="10%" valign="center" class="search_table_title"><img src="/img/button/bullet_01.gif" align="middle">Item Category</td>
					<td witdh="15%" class="search_table_data">
						&nbsp;<%= ItemCategoryManager.getSelectCodeList1("CATE_CODE", "style='width:70%;height=22;' onchange='javascript:doItemList();'", "<option value=''>-- Select --</option>", "" , "") %> 
					</td>							
					<td width="10%" valign="center" class="search_table_title"><img src="/img/button/bullet_01.gif" align="middle">Schedule</td>																						
					<td witdh="15%" class="search_table_data">
						&nbsp;<select name="S_SCH_GROUP" class='input_select' style="width:80%;height=22;" align='absmiddle' onchange="javascript:doInputSch();">
					  			<OPTION>-- Select --</OPTION>
							  </select>
					</td>		
					<td width="10%" valign="center" class="search_table_title"><img src="/img/button/bullet_01.gif" align="middle"> Size, Min/Max</td>
					<td witdh="40%" class="search_table_data">
						&nbsp;<%= SizeSelectManager.getSelectCodeList(user.get("SIZE_UNIT"), "SIZE_MIN", "style='width:30%;height=22;' onchange='javascript:doSizeValue();'", "<option value=''>-- Select --</option>", "" , "") %> 
						&nbsp;<%= SizeSelectManager.getSelectCodeList(user.get("SIZE_UNIT"), "SIZE_MAX", "style='width:30%;height=22;' onchange='javascript:doSizInterval();'", "<option value=''>-- Select --</option>", "" , "") %> 
					</td>						
				</tr>
				<tr height="6">
					<td colspan="6" class="search_data_div_height"></td>
				</tr>
				<tr>
					<td colspan="6">
						<table border='1' cellspacing="0" cellpadding="0" style="width:100%;height:100%;">
							<tr height="100%">
								<td id="sheet1_td" width="25%" align='center'>
									<script>
										var sheetObj = new IBSheetObject("sheet1");
										sheetObj.display();
									</script>
								</td>
								<td width="5%" class="search_table_data" align='center'>
									&nbsp;
									<div id="move" >
								        <IMG id='search_spot_button' onClick="javascript:doValveChk();" src='/img/button/bt_arrow_1.gif' border='0' align='absmiddle' style='cursor:hand;'>
							        </div>
								        <br>
							        <div id="remove">
								        <IMG id='search_spot_button' onClick="javascript:removeValveChk();" src='/img/button/bt_arrow_3.gif' border='0' align='absmiddle' style='cursor:hand;'>
							        </div>
								</td>
								<td>
									<table border='0' cellspacing="0" cellpadding="0" style="width:100%;height:100%;">										
										<tr height='60%'>
											<td id="sheet2_td" width='100%' colspan='2'>
												<script>
													var sheetObj = new IBSheetObject("sheet2");
													sheetObj.display();
												</script>
											</td>
										</tr>
										<tr>
											<TD><DIV ID="materialTitle"></DIV></TD>
										</tr>
									</table>
								</td>
							</tr>
						</table>
					</td>
				</tr>
			</table>
		</td>
	</tr>
	<tr>
		<td colspan="3">
			<table border="0" cellspacing="0" cellpadding="0" class="search_data_div_height">
				<tr>
					<td></td>
				</tr>
			</table>
	 	</td>
	</tr>
</table>
</form>