
function list_init() {
	var c = $fn('unc-cash','boardModel_cd').value;
	switch (c) {
		case 'A':
			size_init01();
			break;
		case 'B':
			size_init02();
			scroll_init();
			break;
		case 'C':
			size_init05();
			read_init();
			break;
		case 'D':
		default:
	}
	if ($('unc-category-list')) {
		Unc.tag.select.apply('unc-category-list',120);
	}
	Web.Element.setClass('span','unc-fnt-out', 'unc-fnt-over');
}

function read_init() {	
	loadImage();
	loadPoll();
	loadStarPoint();
	
	if (typeof(tag_init) == "function") {
		if ($fn('unc-cash','tag_yn').value == 'Y') {
			tag_init();
		}
	}
	
	if ($fn('unc-cash','boardModel_cd').value != 'C') {
		size_init04();
	}

	loadList();	
	if ($fn('unc-cash','boardModel_cd').value != 'C') {
		if ($('unc-category-list')) {
			Unc.tag.select.apply('unc-category-list',120);
		}
	}
	Web.Element.setClass('span','unc-fnt-out', 'unc-fnt-over');	
}


function edit_init() {	
	Web.Form.setStyle('unc-unit');
	Web.Form.loadForm('unc-cash');
	Web.Form.hash['pollSeq'] = 0;	
	Web.Form.hash['badNick'] = Web.Form.hash['serialBadNick']+','+Web.Form.hash['boardSerialBadNick'];
	Web.Form.hash['badContent'] = Web.Form.hash['serialBadContent']+','+Web.Form.hash['boardSerialBadContent'];
	Web.Form.hash['scripts'] = new Array();
	Web.Form.hash['uploaded'] = new Array();
	Web.Element.setClass('span','unc-fnt-out', 'unc-fnt-over');
	Web.Element.insertAdjacent();

	if (Web.Form.hash['command'] == 'MODIFY') {
		var n = Web.Form.hash['serialFileName'].split("|");
		var m = Web.Form.hash['serialFileMask'].split("|");
		var s = Web.Form.hash['serialFileSize'].split("|");
		
		if (!Web.Form.hash['serialFileName'].empty() && 
			 n.length == m.length && n.length == s.length) {
			for (var i = 0; i < n.length; i++) {
				add_file(n[i], m[i], s[i]);
			}
		}	
	}

	if (Web.Form.hash['file_cnt'] > 0) {
		if (Web.Form.hash['command'] == 'MODIFY') {
			$('unc-uploaded-totalSize').update(Web.Form.hash['simpleFileTotalSize']);
		}
	}

	if ($fn('unc-unit','userNick')) {
		$fn('unc-unit','userNick').focus();
	}
	else {
		$fn('unc-unit','boardTitle').focus();
	}

	if ($('unc-poll-1')) {
		var obj = $('unc-unit');
		for (var i = 0; i < obj.elements.length; i++) {
			if (obj.elements[i].type == 'text' && 
				obj.elements[i].name.include('unc-poll-')) {
				Web.Form.hash['pollSeq']++;
			}
		}
	}
	if ($fn('unc-cash','tag_yn').value == 'Y') {
		tag_init();
	}

	Unc.alice.hash['alice'] = Web.EditorManager.instance("unc-alice",{width:$fn('unc-cash','boardWidth').value,height:350,invoke:"editorUploadAfter",thumbnail:Web.Form.hash['thumbnailSize']});
	size_init03();
}

function boardtag_init() {
	var wid =  $fn('unc-cash','commonWidth').value;
	var col1 = $('unc-title01')? Element.getStyle($('unc-title01'), 'width'):0;
	var col2 = $('unc-title02')? Element.getStyle($('unc-title02'), 'width'):0;
	var col3 = $('unc-title03')? Element.getStyle($('unc-title03'), 'width'):0;
	var col4 = 0;
	var col5 = $('unc-title05')? Element.getStyle($('unc-title05'), 'width'):0;
	var col6 = $('unc-title06')? Element.getStyle($('unc-title06'), 'width'):0;
	var col7 = $('unc-title07')? Element.getStyle($('unc-title07'), 'width'):0;

	col4 = parseInt(wid) - parseInt(col1) - parseInt(col2) - parseInt(col3) -  parseInt(col5) - parseInt(col6) - parseInt(col7);
	var obj = $n('unc-nobr');
	for (var i = 0; i < obj.length; i++) {
		Element.setStyle(obj[i], {width:col4});
	}
}

function search_init() {
	Web.Form.setStyle('unc-unit');
	Web.Element.setClass('span','unc-fnt-out', 'unc-fnt-over');
	$('unc-search-and-key').value = $fn('unc-cash','searchAndKey').value;
	$('unc-search-or-key').value  = $fn('unc-cash','searchOrKey').value;
	$('unc-search-not-key').value = $fn('unc-cash','searchNotKey').value;
	$('unc-search-and-key').focus();	
	size_init06();
	scroll_init();
}

function size_init01() {
	var wid =  $fn('unc-cash','boardWidth').value;
	var col1 = $('unc-title01')? Element.getStyle($('unc-title01'), 'width'):0;
	var col2 = $('unc-title02')? Element.getStyle($('unc-title02'), 'width'):0;
	var col3 = $('unc-title03')? Element.getStyle($('unc-title03'), 'width'):0;
	var col4 = $('unc-title04')? Element.getStyle($('unc-title04'), 'width'):0;
	var col5 = $('unc-title05')? Element.getStyle($('unc-title05'), 'width'):0;
	var col6 = 0;
	var col7 = $('unc-title07')? Element.getStyle($('unc-title07'), 'width'):0;
	var col8 = $('unc-title08')? Element.getStyle($('unc-title08'), 'width'):0;
	var col9 = $('unc-title09')? Element.getStyle($('unc-title09'), 'width'):0;
	var col10 = $('unc-title10')? Element.getStyle($('unc-title10'), 'width'):0;

	col6 = parseInt(wid) - parseInt(col1) - parseInt(col2) - parseInt(col3) - parseInt(col4) - parseInt(col5) - parseInt(col7) - parseInt(col8) - parseInt(col9) -parseInt(col10);
	var obj = $n('unc-nobr');
	for (var i = 0; i < obj.length; i++) {
		Element.setStyle(obj[i], {width:col6});		
	}
}

function size_init02() {
	var tot =  $fn('unc-cash','boardWidth').value;
	if (tot > 0) {
		var wid = parseInt(tot) - 22 - 10 - 25;
		var obj = $n('unc-nobr');
		for (var i = 0; i < obj.length; i++) {
			Element.setStyle(obj[i], {width:wid});
		}
		wid = parseInt(tot) - (Web.isIE? 23 : 25);
		if ($('unc-scr-box')) {
			Element.setStyle($('unc-scr-box'), {width: wid});
		}
	}
}

function size_init03() {
	var tot =  $fn('unc-cash','boardWidth').value;	
	var wid = parseInt(tot)-3;
	var obj = $n('unc-nobr');
	for (var i = 0; i < obj.length; i++) {
		Element.setStyle(obj[i], {width:wid});
	}	
}

function size_init04() {
	var tot =  $fn('unc-cash','boardWidth').value;	
	var wid = parseInt(tot)-12;
	var obj = $n('unc-nobr-title');
	var obj2 = $n('unc-nobr-content');
	for (var i = 0; i < obj.length; i++) {
		Element.setStyle(obj[i], {width:wid});		
	}
	for (var i = 0; i < obj2.length; i++) {
		Element.setStyle(obj2[i], {width:wid});
	}
	
	if ($fn('unc-cash','replyList_yn').value == 'Y') {
		var col1 = $n('unc-reply01') && $n('unc-reply01').length > 0? $n('unc-reply01')[0].width : 0;
		var col2 = $n('unc-reply02') && $n('unc-reply02').length > 0? $n('unc-reply02')[0].width : 0;
		var col3 = 0;
		var col4 = $n('unc-reply04') && $n('unc-reply04').length > 0? $n('unc-reply04')[0].width : 0;
		var col5 = $n('unc-reply05') && $n('unc-reply05').length > 0? $n('unc-reply05')[0].width : 0;
		col3 = parseInt(tot) - parseInt(col1) - parseInt(col2) - parseInt(col4) - parseInt(col5);
		
		var nobr = $n('unc-nobr-reply');
		for (var i = 0; i < nobr.length; i++) {
			Element.setStyle(nobr[i], {width:col3});
		}
	}	
}

function size_init05() {
	var tot =  $fn('unc-cash','boardWidth').value;	
	var wid = parseInt(tot)-23;
	var obj = $n('unc-nobr');
	for (var i = 0; i < obj.length; i++) {
		Element.setStyle(obj[i], {width:wid});
	}	
}

function size_init06() {
	var tot =  $fn('unc-cash','commonWidth').value;
	if (tot > 0) {
		var wid = parseInt(tot) - 22 - 10 - 25;
		var obj = $n('unc-nobr');
		for (var i = 0; i < obj.length; i++) {
			Element.setStyle(obj[i], {width:wid});
		}
		wid = parseInt(tot) - (Web.isIE? 23 : 25);
		if ($('unc-scr-box')) {
			Element.setStyle($('unc-scr-box'), {width: wid});
		}
	}
}

function viewCategory() {
	Web.Element.toggleDisplay('unc-category-list');
}

function categoryList(cid) {
	$fn('unc-cash','categoryId').value = cid;
	$fn('unc-cash','page').value = 1;
	Web.submit('unc-cash', {method:'post',action:'board-list.do'});
}

function searchArticle() {
	if (!Web.Form.validateValue('unc-search-key')) return false;
	if (!Web.Form.validateMinByte('unc-search-key',2)) return false;
	$fn('unc-cash','command').value = 'DETAIL';	
	$fn('unc-cash','searchOrKey').value = $('unc-search-key').value;
	$fn('unc-cash','searchType').value = 'T C N MC MN FF';
	$fn('unc-cash','thumbnailSize').value = 50;
	$fn('unc-cash','pageScale').value = 50;
	$fn('unc-cash','page').value = 1;	
	Web.submit('unc-cash', {method:'post',action:'search.do'});
}

function boardNext(pg) {
	nextArticle(pg);	
}

function nextArticle(pg) {
	$fn('unc-cash','page').value = pg;
	Web.submit('unc-cash', {method:'post',action:'board-list.do'});
}

function checkArticle(obj) {
	var skin = $fn('unc-cash','defaultBoardSkin').value;
	if (obj.getAttribute('checkeditem') == 'Y') {
		obj.setAttribute('checkeditem', 'N');
		obj.innerHTML = '<img src=./img/skin/'+skin+'/i_nox.gif>';
	} 
	else {
		obj.setAttribute('checkeditem', 'Y');
		obj.innerHTML = '<img src=./img/skin/'+skin+'/i_okx.gif>';
	}
}

function writeArticle() {
	if (arguments.length > 0 && arguments[0] == -1) {
		Web.alert({title:'°æ°í', msg:'±ÛÀÛ¼º ±ÇÇÑÀÌ ¾ø½À´Ï´Ù'});
		return;	
	}
	$fn('unc-cash','command').value = 'WRITE';
	Web.submit('unc-cash', {method:'post',action:'board-edit.do'});
}

function readArticle(pk) {
	if (pk < 0) {
		var checkeditems = '';
		var c = $fn('unc-cash','boardModel_cd').value;
		var nm = $n('unc-check-box');
		for(var i = 0; i < nm.length; i++) {
			if (nm[i].getAttribute('checkeditem') == 'Y') {
				checkeditems += nm[i].getAttribute('value')+',';
			}
		}

		if (checkeditems == '') {
			Web.message({title:'¾Ë¸²',msg:'ÇÑ¹ø¿¡ º¸½Ç ±Û(µ¿½Ãº¸±âÇÒ ±Û)À» ¼±ÅÃÇØ ÁÖ½Ê½Ã¿ä.',height:80});
			return;
		}

		$fn('unc-cash','boardNo').value = checkeditems;
		$fn('unc-cash','command').value = 'READ';
		Web.submit('unc-cash', {method:'post',action:'board-read.do'});
	} 
	else {
		Web.link('board-read.do?boardId='+$('unc-cash','boardId').value+'&boardNo='+pk+'&command=READ&page='+$('unc-cash','page').value+'&categoryId='+$fn('unc-cash','categoryId').value);
	}
}

function readSearchArticle(pk) {
	if (pk < 0) {
		var checkeditems = '';
		var c = $fn('unc-cash','boardModel_cd').value;
		var nm = $n('unc-check-box');
		for(var i = 0; i < nm.length; i++) {
			if (nm[i].getAttribute('checkeditem') == 'Y') {
				checkeditems += nm[i].getAttribute('value')+',';
			}
		}

		if (checkeditems == '') {
			Web.message({title:'¾Ë¸²',msg:'ÇÑ¹ø¿¡ º¸½Ç ±Û(µ¿½Ãº¸±âÇÒ ±Û)À» ¼±ÅÃÇØ ÁÖ½Ê½Ã¿ä.',height:80});
			return;
		}		
		$fn('unc-cash','boardNo').value = checkeditems;		
	} 
	else {
		$fn('unc-cash','boardNo').value = pk;	
	}
	$fn('unc-cash','searchKey').value = $fn('unc-cash','searchAndKey').value.empty()? $fn('unc-cash','searchOrKey').value : $fn('unc-cash','searchAndKey').value;
	$fn('unc-cash','command').value = 'SEARCH';
	Web.submit('unc-cash', {method:'post',action:'search-read.do'});
}


function showSearchForm(){
	var txt = 	"<form name=unc-search-frm onsubmit=\"return false\">"+
					"<div><b>°Ë»ö¾î</b> <input type=text id=unc-search-key name=unc-search-key title=\"°Ë»ö¾î\" onkeydown=\"Web.Event.captureEnter(event, 'searchArticle()')\">"+
					"</div>"+
				"</form>";
	
	Web.popup({title:'°Ë»öÇÏ±â',msg:txt,width:300,height:80});
	Web.Form.setStyle("unc-search-frm");
	$('unc-search-key').focus();	
}



function loadImage() {
	var boardWidth = 600;
	if ($fn('unc-cash','boardWidth') != null) {
		boardWidth = parseInt($fn('unc-cash','boardWidth').value) - 30;
	}

	var obj = $n('alc-images');
	for (var i = 0; i < obj.length; i++) {		
		if (obj[i].width > boardWidth) {
			obj[i].width = boardWidth;
		}
	}
	
	/* ±¸¹öÁ¯ È£È¯ */
	obj = $n('unicornimage');
	for (var i = 0; i < obj.length; i++) {		
		if (obj[i].width > boardWidth) {
			obj[i].width = boardWidth;
		}
	}
}

function loadPoll() {
	var nm = $n('unc-poll-c');
	var sz = $n('pollSize');
	for (var i = 0; i < nm.length; i++) {
		nm[i].style.width = sz[i].value;
	}
}

function loadStarPoint() {
	var skin = $fn('unc-cash','defaultBoardSkin').value;
	var obj = $n('totalStarPoint');
	var star01 = $n('unc-star1');
	var star02 = $n('unc-star2');
	var star03 = $n('unc-star3');
	var star04 = $n('unc-star4');
	var star05 = $n('unc-star5');
	
	for (var i = 0; i < obj.length; i++) {
		if (2 <= obj[i].value && obj[i].value < 4) {
			star01[i].src = './img/skin/'+skin+'/star_on.gif';
		}
		else if (4 <= obj[i].value && obj[i].value < 6) {
			star01[i].src = './img/skin/'+skin+'/star_on.gif';
			star02[i].src = './img/skin/'+skin+'/star_on.gif';
		} 
		else if (6 <= obj[i].value && obj[i].value < 8) {
			star01[i].src = './img/skin/'+skin+'/star_on.gif';
			star02[i].src = './img/skin/'+skin+'/star_on.gif';
			star03[i].src = './img/skin/'+skin+'/star_on.gif';
		} 
		else if (8 <= obj[i].value && obj[i].value < 10) {
			star01[i].src = './img/skin/'+skin+'/star_on.gif';
			star02[i].src = './img/skin/'+skin+'/star_on.gif';
			star03[i].src = './img/skin/'+skin+'/star_on.gif';
			star04[i].src = './img/skin/'+skin+'/star_on.gif';
		} 
		else if (obj[i].value == 10) {
			star01[i].src = './img/skin/'+skin+'/star_on.gif';
			star02[i].src = './img/skin/'+skin+'/star_on.gif';
			star03[i].src = './img/skin/'+skin+'/star_on.gif';
			star04[i].src = './img/skin/'+skin+'/star_on.gif';
			star05[i].src = './img/skin/'+skin+'/star_on.gif';
		}
	}
}

function starProgress(obj) {
	var skin = $fn('unc-cash', 'defaultBoardSkin').value;
	var star01 = $n('unc-star1');
	var star02 = $n('unc-star2');
	var star03 = $n('unc-star3');
	var star04 = $n('unc-star4');
	var star05 = $n('unc-star5');
	
	var idx = 0;
	for (var i = 0; i < star01.length; i++) if (star01[i] == obj) idx = i;
	for (var i = 0; i < star02.length; i++) if (star02[i] == obj) idx = i;
	for (var i = 0; i < star03.length; i++) if (star03[i] == obj) idx = i;
	for (var i = 0; i < star04.length; i++) if (star04[i] == obj) idx = i;
	for (var i = 0; i < star05.length; i++) if (star05[i] == obj) idx = i;
	
	var starArray = new Array();
	starArray[0] = star01[idx];
	starArray[1] = star02[idx];
	starArray[2] = star03[idx];
	starArray[3] = star04[idx];
	starArray[4] = star05[idx];
		
	var on = true;	
	for (var i = 0; i < starArray.length; i++) {
		if (on) {
			starArray[i].src = './img/skin/'+skin+'/star_on.gif';
		}
		else {
			starArray[i].src = './img/skin/'+skin+'/star_off.gif';
		}
		if (starArray[i] == obj) {
			on = false;
		}
	}
}

function loadList() {
	if ($fn('unc-cash','list_yn').value == 'Y') {
		if ($fn('unc-cash','boardModel_cd').value == 'A') {
			size_init01();
		}
		else if ($fn('unc-cash','boardModel_cd').value == 'B') {
			size_init02();
			scroll_init();
		}
	}
}

function actionSecurity(evt, fg, pk, bul) {
	if (bul) {
		actionArticle(fg, pk)
	}
	else {
		showPwForm(evt, fg, pk);
	}	
}

function viewMemo(pk) {
	Web.Element.toggleDisplay('unc-memo-'+pk, true);
	var obj = $('unc-memo-'+pk);
	if (obj.style.display == 'inline') {
		Unc.alice.hash[pk] = Web.EditorManager.instance('unc-memo-input-'+pk,{type:'detail',width:'98.7%',height:300,limit:4000});
		Web.Element.setInputBoxStyle('unc-memo-user-'+pk);
		Web.Element.setInputBoxStyle('unc-memo-pwd-'+pk);
	} 
}

function viewTag(pk) {
	Web.Element.toggleDisplay('unc-tag-'+pk, true);
	Web.Element.setInputBoxStyle('unc-tagsname-'+pk);
}

function validatePassword(fg,pk) {
	if (Web.Form.validateValue('unc-del-pwd')) {
		$fn('unc-cash','userPw').value = $('unc-del-pwd').value;
		actionArticle($('unc-tmp-fg').value, $('unc-tmp-pk').value);
	}
}

function showPwForm(evt, fg, pk) {
	var txt = "<div>"+
				"ºñ¹Ð¹øÈ£ <input type=password name=unc-del-pwd id=unc-del-pwd title='ºñ¹Ð¹øÈ£' onkeyup=\"Web.Event.captureEnter(event, 'validatePassword()')\">"+
				"<input type=hidden id=unc-tmp-fg><input type=hidden id=unc-tmp-pk>"+
			  "</div>";
			  
	Web.popup({title:'ºñ¹Ð¹øÈ£ ÀÔ·Â',msg:txt,width:300});
	Web.Element.setInputBoxStyle('unc-del-pwd');
	$('unc-del-pwd').focus();
	$('unc-tmp-fg').value = fg;
	$('unc-tmp-pk').value = pk;
}

function chnageMemoReplyImage(obj) {
	var src = obj.src;
	var objs = $n('unc-memo-reicon');
	for (var i = 0; i < objs.length; i++) {
		 objs[i].src = objs[i].src.replace('i_memo_re2.gif', 'i_memo_re.gif');
	}
	
	if (src.include('i_memo_re.gif')) {
		obj.src = src.replace('i_memo_re.gif', 'i_memo_re2.gif');
	}
	else {
		obj.src = src.replace('i_memo_re2.gif', 'i_memo_re.gif');
	}
}

function showMemoReply(pk, seq) {
	if ($('unc-memo-'+pk).style.display != 'inline') {
		viewMemo(pk);
	}
	
	var source = $('unc-memo-reply-'+pk+'-'+seq);
	var target = $('unc-memo-reply-'+pk);

	if ($fn('unc-cash','boardNo').value == pk &&
		$fn('unc-cash','memoSeq').value == seq) {
		target.update('');
		$fn('unc-cash','boardNo').value = pk;
		$fn('unc-cash','memoSeq').value = 0;
		$fn('unc-cash','command').value = "MEMO_WRITE";
	} 
	else {
		$fn('unc-cash','boardNo').value = pk;
		$fn('unc-cash','memoSeq').value = seq;
		$fn('unc-cash','command').value = "MEMO_REPLY";
		var str = source.innerHTML.stripTags();
		target.update('<br><font color=red>"</font><b>'+str.substring(0, 50) + '</b><font color=red>"</font>... ±ÛÀÇ ´äº¯À» ´ä´Ï´Ù');
	}
}

function actionArticle(fg,pk) {

	var target = $('unc-cash');
	$fn('unc-cash','provenance').value = Web.Location.current();
	switch (fg) {
		case 'search':
		case 'tag':
			Web.Location.back();
			break;
		case 'list':
			$fn('unc-cash','boardNo').value = '';
			Web.Form.submit('unc-cash',{method:'post',action:'board-list.do'});
			break;
		case 'write':
			$fn('unc-cash','command').value = 'WRITE';
			Web.Form.submit('unc-cash',{method:'post',action:'board-edit.do'});
			break;
		case 'reply':
			$fn('unc-cash','boardNo').value = pk;
			$fn('unc-cash','command').value = 'REPLY';
			Web.Form.submit('unc-cash',{method:'post',action:'board-edit.do'});
			break;
		case 'modify':
			$fn('unc-cash','boardNo').value = pk;
			$fn('unc-cash','command').value = 'MODIFY';
			Web.Form.submit('unc-cash',{method:'post',action:'board-edit.do'});
			break;
		case 'delete':
			Web.confirm({title:'È®ÀÎ',msg:'Á¤¸» »èÁ¦ÇÏ½Ã°Ú½À´Ï±î?',fnok: function() {
				$fn('unc-cash','boardNo').value = pk;
				$fn('unc-cash','command').value = 'DELETE';
				Web.Form.submit('unc-cash',{method:'post',action:'board-save.do'});
			}});
			break;
		case 'delete-memo':
			Web.confirm({title:'È®ÀÎ',msg:'Á¤¸» »èÁ¦ÇÏ½Ã°Ú½À´Ï±î?',fnok: function() {
				var mpk = pk.split(/,/);
				$fn('unc-cash','boardNo').value = mpk[0];
				$fn('unc-cash','memoSeq').value = mpk[1];
				$fn('unc-cash','command').value = 'MEMO_DELETE';
				Web.Form.submit('unc-cash',{method:'post',action:'memo-save.do'});
			}});
			break;
		case 'bad-memo':
			Web.confirm({title:'È®ÀÎ',msg:'Á¤¸» ½Å°íÇÏ½Ã°Ú½À´Ï±î?',fnok: function() {
				var mpk = pk.split(/,/);
				$fn('unc-cash','boardNo').value = mpk[0];
				$fn('unc-cash','memoSeq').value = mpk[1];
				$fn('unc-cash','beforeCommand').value = 'READ';
				$fn('unc-cash','returnURI').value = 'board-read.do';
				$fn('unc-cash','command').value = 'MEMO_BAD';
				Web.Form.submit('unc-cash',{method:'post',action:'memo-save.do'});
			}});
			break;
		case 'rate-up':
			Web.confirm({title:'È®ÀÎ',msg:'ÃßÃµ ÇÏ½Ã°Ú½À´Ï±î?',fnok: function() {
				$fn('unc-cash','boardNo').value = pk;
				$fn('unc-cash','command').value = 'PLUS';
				Web.Form.submit('unc-cash',{method:'post',action:'rate-save.do'});
			}});
			break;
		case 'rate-down':
			Web.confirm({title:'È®ÀÎ',msg:'ºñÃß ÇÏ½Ã°Ú½À´Ï±î?',fnok: function() {
				$fn('unc-cash','boardNo').value = pk;
				$fn('unc-cash','command').value = 'MINUS';
				Web.Form.submit('unc-cash',{method:'post',action:'rate-save.do'});
			}});
			break;
		case 'poll':
			Web.confirm({title:'È®ÀÎ',msg:'¼³¹®¿¡ ÅõÇ¥ ÇÏ½Ã°Ú½À´Ï±î?',fnok: function() {
				var nm = $n('unc-poll-'+pk);
				$fn('unc-cash','pollSeq').value = '';
				for (var i = 0; i < nm.length; i++) {
					if (nm[i].checked) {
						$fn('unc-cash','pollSeq').value = nm[i].value;
						break;
					}
				}
				if ($fn('unc-cash','pollSeq').value == '') {
					Web.alert({title:'°æ°í',msg:'ÅõÇ¥ÇÒ º¸±â¸¦ ¼±ÅÃÇØ ÁÖ¼¼¿ä'});
					return;	
				}
				
				$fn('unc-cash','boardNo').value = pk;
				$fn('unc-cash','command').value = 'POLL';
				Web.Form.submit('unc-cash',{method:'post',action:'poll-save.do'});
			}});
			break;
		case 'best':
			Web.confirm({title:'È®ÀÎ',msg:'º£½ºÆ® ´äº¯À¸·Î ¼±ÅÃ ÇÏ½Ã°Ú½À´Ï±î?',fnok: function() {
				$fn('unc-cash','boardNo').value = pk;
				$fn('unc-cash','command').value = 'BEST';
				Web.Form.submit('unc-cash',{method:'post',action:'best-save.do'});
			}});
			break;
		case 'star':
			var mpk = pk.split(/,/);			
			Web.confirm({title:'È®ÀÎ',msg:'ÀÌ °Ô½Ã¹°¿¡ '+mpk[1]+'Á¡À» ÁÖ½Ã°Ú½À´Ï±î?',fnok: function() {
				var mpk = pk.split(/,/);				
				$fn('unc-cash','boardNo').value = mpk[0];
				$fn('unc-cash','memoSeq').value = mpk[1];
				$fn('unc-cash','command').value = 'STAR';
				Web.Form.submit('unc-cash',{method:'post',action:'star-save.do'});
			}});
			break;
		case 'tag-yo':
			var v1 = '';
			if ($('unc-tagsname-'+pk)) {
				v1 = $('unc-tagsname-'+pk).value;
				if (Web.Form.validateValue('unc-tagsname-'+pk) &&
					Web.Form.validateContent('unc-tagsname-'+pk, $fn('unc-cash','serialBadContent').value)) {
	
					Web.confirm({title:'È®ÀÎ',msg:'ÀÌ ÅÂ±×¸¦ ÀÔ·ÂÇÏ½Ã°Ú½À´Ï±î?',fnok: function() {
						$fn('unc-cash','tagsName').value = v1;
						$fn('unc-cash','boardNo').value = pk;
						$fn('unc-cash','command').value = 'TAG';
						Web.Form.submit('unc-cash', {method:'post',action:'tag-save.do'});
					}});
				}
			}
			break;
		case 'editor-memo':
			if ($('unc-memo-'+pk).style.display != 'inline') {
				viewMemo(pk);
				return;
			}
		
			var n = $fn('unc-cash','serialBadNick').value+','+$fn('unc-cash','boardSerialBadNick').value;
			var c = $fn('unc-cash','serialBadContent').value+','+$fn('unc-cash','boardSerialBadContent').value;
			if ($('unc-memo-user-'+pk)) {
				if (!Web.Form.validateValue('unc-memo-user-'+pk) ||
					!Web.Form.validateContent('unc-memo-user-'+pk, n)) {
					return;
				}
			}
			if ($('unc-memo-pwd-'+pk)) {
				if (!Web.Form.validateValue('unc-memo-pwd-'+pk)) {
					return;
				}
			}

			var m = Unc.alice.hash[pk].getContentWithLimit();
			if (m == null) {
				return;
			}
			$fn('unc-cash','memoContent').value = m;
			if (!Web.Form.validateValue($fn('unc-cash','memoContent'), 'µ¡±Û') ||
				!Web.Form.validateContent($fn('unc-cash','memoContent'),c)) {
					return;
			}
			
			$fn('unc-cash','userNick').value = $('unc-memo-user-'+pk)? $('unc-memo-user-'+pk).value:"";
			$fn('unc-cash','userPw').value = $('unc-memo-pwd-'+pk)? $('unc-memo-pwd-'+pk).value:"";
			$fn('unc-cash','boardNo').value = pk;
			$fn('unc-cash','command').value = $fn('unc-cash','command').value == 'MEMO_REPLY'? 'MEMO_REPLY':'MEMO_WRITE';
		
			Web.Form.submit('unc-cash', {method:'post',action:'memo-save.do'});
			break;
		default:		
	}
}

function printPage(bid, bno) {
	window.open('print-read.do?boardId='+bid+'&boardNo='+bno+'&command=READ', '_print');
}

function tagAction() {
	actionArticle('tag-yo', Unc.tagging.currentPk);
}

function tagAction2(pk) {
	actionArticle('tag-yo', pk);
}

function viewRelation(bid, bno) {
	$fn('unc-cash','relationNo').value = bno;
	Web.Element.toggleDisplay('unc-relation-'+bno, true);
	Web.Element.toggleDisplay('unc-loading-'+bno, true);
	Web.Ajax.invoke({action:'ajax-relation.do', params:'boardId='+bid+'&boardNo='+bno, handler:'relationParsing'});
}

function relationParsing(xml) {		
	var skin = $fn('unc-cash','defaultBoardSkin').value;
	var bno = $fn('unc-cash','relationNo').value;
	var obj = $('unc-relation-'+bno);
	var txt = "<fieldset><div id=unc-relation-scroll-"+bno+" style=\"scrollbar-face-color:#d0d0d0;scrollbar-highlight-color:#ffffff;scrollbar-3dlight-color:#d0d0d0;scrollbar-darkshadow-color:#666666;scrollbar-shadow-color:#a0a0a0;scrollbar-arrow-color:#ffffff;scrollbar-track-color:#feedf4;\">";	

	var root = xml.getElementsByTagName("articles")[0];
	var articles = root.getElementsByTagName("article");
	for (var i = 0; i < articles.length; i++) {
		var article = articles[i];
		var boardid = article.getElementsByTagName("boardid")[0].firstChild.nodeValue;
		var boardname = article.getElementsByTagName("boardname")[0].firstChild.nodeValue;
		var boardno = article.getElementsByTagName("boardno")[0].firstChild.nodeValue;
		var memocnt = article.getElementsByTagName("memocnt")[0].firstChild.nodeValue;
		var recent = article.getElementsByTagName("recent")[0].firstChild.nodeValue;
		var upgrade = article.getElementsByTagName("upgrade")[0].firstChild.nodeValue;
		var subject = article.getElementsByTagName("subject")[0].firstChild.nodeValue;
		var user = article.getElementsByTagName("user")[0].firstChild.nodeValue;
		var register = article.getElementsByTagName("register")[0].firstChild.nodeValue;
		var read = article.getElementsByTagName("read")[0].firstChild.nodeValue;
		var tagcnt = article.getElementsByTagName("tagcnt")[0].firstChild.nodeValue;
		
		txt += "<div class=unc-relation>"+
				"<div class=unc-relation-subject>"+
				"<a href=board-list.do?boardId="+boardid+" class=unc-gray><strong>"+boardname+"</strong></a> | "+user+"&#160;&#160;"+
				"<a href=board-read.do?boardId="+boardid+"&boardNo="+boardno+"&command=READ&page=1&categoryId=-1 target=_self class=unc-main>"+subject+"</a> "+
					(memocnt > 0 ? "<img src=./img/skin/"+skin+"/i_memo.gif class=unc-bsc> <font class=unc-added>"+memocnt+"</font> " : "")+
            		(tagcnt > 0 ? "<img src=./img/skin/"+skin+"/i_tag.gif class=unc-bsc> <font class=unc-added>"+tagcnt+"</font> " : "")+
            		(recent == 'Y' ? "<img src=./img/skin/"+skin+"/i_new.gif class=unc-bsc>" : 
           	  			(upgrade == 'Y' ? "<img src=./img/skin/"+skin+"/i_update.gif class=unc-bsc>" : "")
             		)+
             	"</div>"+
             	"<div class=unc-relation-regdt><em>"+register+"</em></div>"+
             	"</div>";
	}
	var h = 0;
	if (articles.length == 0) {
		txt += "°ü·ÃµÈ ±ÛÀÌ ¾ø½À´Ï´Ù";
		h = 25;
	} 
	else {
		h = articles.length * 20;
	}
	txt += "</div></fieldset><div style=clear:both></div>";
	obj.update(txt);
	$('unc-relation-scroll-'+bno).style.height = (h > 200? 200: h)+'px';
	$('unc-relation-scroll-'+bno).style.overflow = 'auto';
	$('unc-loading-'+bno).style.display = 'none';
}

function editorUploadAfter(p1,p2,p3) {
	/* p1 : logical, p2: phsycal, p3: size */
	add_picture(p2, p1, p3);
}

function listArticle() {
	Web.Form.submit('unc-cash',{method:'post',action:'board-list.do'});
}

function saveArticle() {
	var un = $fn('unc-unit','userNick');
	if (un) {
		if (!Web.Form.validateValue(un) ||
			!Web.Form.validateContent(un, Web.Form.hash['badNick'])) {
			return;
		}
		$fn('unc-cash','userNick').value = un.value.strip();
	}

	var bt = $fn('unc-unit','boardTitle');
	if (!Web.Form.validateValue(bt) ||
		!Web.Form.validateMaxByte(bt, 255) ||
		!Web.Form.validateContent(bt, Web.Form.hash['badContent'])) {
		return;
	}
	$fn('unc-cash','boardTitle').value = bt.value.strip();	
	
	if (Web.Form.hash['server'] != 'null' && Web.Form.hash['server'] != '') {
		var fileserverdomain = Web.Form.hash['server']+ (Web.Form.hash['port'] == 80? '':':'+Web.Form.hash['port']);
		var cw = Unc.alice.hash['alice'].getAliceContentWindow();
		var images = cw.document.getElementsByName('alc-images');
		for (i = 0; i < images.length; i++) {			
			var src = images[i].src;
			if (src.include('http://'+Web.Location.domain())) {
				src = src.gsub('http://'+Web.Location.domain(), '');
			}
			images[i].src = "http://"+fileserverdomain+src;
		}
	}

	var ct = Unc.alice.hash['alice'].getContent(true);
	if (Unc.alice.hash['alice'].isLimit()) {
		Web.alert({title:'°æ°í', msg:'º»¹®À» ³Ê¹« ¸¹ÀÌ ÀÛ¼ºÇÏ¼Ì½À´Ï´Ù<br>ÃÖ´ë º»¹® ÀÛ¼º°¡´É ±ÛÀÚ¼ö´Â <b>'+Unc.alice.hash['alice'].limit+'</b>¹ÙÀÌÆ® ÀÔ´Ï´Ù<br>ÇöÀç ÀÛ¼º ±ÛÀÚ¼ö´Â <b>'+ct.getByte()+'</b>¹ÙÀÌÆ® ÀÔ´Ï´Ù',width:400});
		return;
	}
	else if (ct.empty() || ct == '<br>') {
		Web.alert({title:'ÁÖÀÇ',msg:'º»¹®À» ÀÔ·ÂÇÏ¼¼¿ä'});			
		return;
	}
	$fn('unc-cash','boardContent').value = ct;
	if (!Web.Form.validateContent($fn('unc-cash','boardContent'), Web.Form.hash['badContent'])) {
		return;
	}
	
	if ($('unc-category-list')) {
		if ($('unc-category-list').selectedIndex == 0) {
			Web.alert({title:'ÁÖÀÇ', msg:'Ä«Å×°í¸®¸¦ ¼±ÅÃÇÏ¼¼¿ä'});
			return;
		}
		$fn('unc-cash','categoryId').value = $('unc-category-list').value;
	}
	
	var up = $fn('unc-unit','userPw');
	if (up) {
		if (!Web.Form.validateValue(up) ||
			!Web.Form.validateMaxByte(up, 24) ||
			!Web.Form.validateMaxByte(up, 12)) {
			return;
		}
		$fn('unc-cash','userPw').value = up.value;
	}
	
	if ($fn('unc-unit','userEmail')) {		
		$fn('unc-cash','userEmail').value = $fn('unc-unit','userEmail').value.strip();
	}
	if ($fn('unc-unit','userHomepage')) {
		$fn('unc-cash','userHomepage').value = $fn('unc-unit','userHomepage').value.strip();
	}
	$fn('unc-cash','boardTop_fg').value = $fn('unc-unit','boardTop_fg')? ($fn('unc-unit','boardTop_fg').checked? 'Y':'N'):'N';
	$fn('unc-cash','boardSecret_fg').value = $fn('unc-unit','boardSecret_fg')? ($fn('unc-unit','boardSecret_fg').checked? 'Y':'N'):'N';

	if ($('unc-poll-from') && !$('unc-poll-from').value.empty()) {
		if (!Web.Form.validateLength('unc-poll-from',10)) {
			return;				
		}
		$fn('unc-cash','boardPollFrom_time').value = $('unc-poll-from').value.substring(0,4)+$('unc-poll-from').value.substring(5,7)+$('unc-poll-from').value.substring(8,10)+'0000';
	}

	if ($('unc-poll-to') && !$('unc-poll-to').value.empty()) {
		if (!Web.Form.validateLength('unc-poll-to',10)) {
			return;				
		}
		$fn('unc-cash','boardPollTo_time').value = $('unc-poll-to').value.substring(0,4)+$('unc-poll-to').value.substring(5,7)+$('unc-poll-to').value.substring(8,10)+'2359';
	}

	if (parseInt($fn('unc-cash','boardPollFrom_time').value) > parseInt($fn('unc-cash','boardPollTo_time').value)) {
		Web.alert({title:'°æ°í',msg:'¼³¹® ½ÃÀÛ±â°£ÀÌ Á¾·á±â°£º¸´Ù ¾Õ¼·´Ï´Ù'});
		return;
	}

	if ($('unc-poll-1') && !$('unc-poll-1').value.empty()) {
		$fn('unc-cash','pollContent').value = '';
		var frm = $('unc-unit');
		for (var i = 0; i < frm.elements.length; i++) {
			if (frm.elements[i].type == 'text' &&
				frm.elements[i].name.indexOf('unc-poll-') > -1) {
				$fn('unc-cash','pollContent').value += frm.elements[i].value.strip().gsub(/\|/,'')+"|";
			}
		}
	}

	$fn('unc-cash','boardPoint').value = 0;
	if ($('unc-point')) {
		if (!Web.Form.validateNum('unc-point')) {
			return;
		}		
		if (parseInt($('unc-point').value) > parseInt(Web.Form.hash['userPoint'])) {
			Web.alert({title:'ÁÖÀÇ',msg:'´ç½ÅÀÇ ÀÔ·Â °¡´ÉÇÑ ÃÖ´ë Æ÷ÀÎÆ®´Â <strong>'+Web.Form.hash['userPoint']+'</strong> ÀÔ´Ï´Ù'});
			return;
		}
		$fn('unc-cash','boardPoint').value = $('unc-point').value.strip().empty()? 0 : $('unc-point').value.strip();
	}	

	if (Web.Form.hash['file_cnt'] > 0) {		
		var uploadCount = getUploadCount();
		if (Web.Form.hash['file_cnt'] < uploadCount) {
			Web.alert({title:'°æ°í',msg:'ÆÄÀÏ ¾÷·Îµå ÃÖ´ë °¹¼ö´Â <strong>'+Web.Form.hash['file_cnt']+'</strong>°³ ÀÔ´Ï´Ù'});
			return;
		}
	}

	if ($('unc-tagsname-0')) {
		$fn('unc-cash','tagsName').value = $('unc-tagsname-0').value.strip().gsub(/'/,'').gsub(/"/,'');
	}

	var uploadCount = getUploadCount() - getUploadedCount();
	if (uploadCount > 0 && Web.Form.hash['file_cnt'] > 0) {
		uploadFile();
	}
	else {
		uploadSuccess();
	}
}

function pollAppend() {	
	Web.Form.hash['pollSeq']++;

	var tbl = $("unc-poll-tab").getElementsByTagName("TBODY")[0];
	var html1 = Web.Form.hash['pollSeq']+'.';
	var html2 = '<input type=text name=unc-poll-'+Web.Form.hash['pollSeq']+' id=unc-poll-'+Web.Form.hash['pollSeq']+' size=50>';
	
	var row = document.createElement("tr");
	var col1 = document.createElement("td"); 
	var col2 = document.createElement("td"); 
	row.appendChild(col1);
	row.appendChild(col2);
	col1.innerHTML = html1;
	col2.innerHTML = html2;
	tbl.appendChild(row);	
	Web.Element.setInputBoxStyle('unc-poll-'+Web.Form.hash['pollSeq']);	
}

function pollRemove() {
	if (Web.Form.hash['pollSeq'] == 2) {
		Web.alert({title:'ÁÖÀÇ',msg:'¼³¹® º¸±â´Â ÃÖ¼Ò 2°³ÀÌ¾î¾ß ÇÕ´Ï´Ù!'});
	 	return;
	 }	

	var tbl = $("unc-poll-tab").getElementsByTagName("TBODY")[0];
	
	if (tbl.hasChildNodes()) {
		tbl.removeChild(tbl.lastChild); 	
	}	
	
	Web.Form.hash['pollSeq']--;
}

function getUploadCount() {
	var uploadCount = 0;
	var scripts = Web.Form.hash['scripts'];
	for (var i = 0; i < scripts.length; i++) {
		if (scripts[i].status) {
			uploadCount++;
		}
	}
	//alert('upload count '+uploadCount);
	return uploadCount;
}

function getUploadedCount() {
	var uploadedCount = 0;
	var uploaded = Web.Form.hash['uploaded'];
	for (var i = 0; i < uploaded.length; i++) {
		if (uploaded[i].status) {
			uploadedCount++;
		}
	}
	//alert('uploaded count '+uploadedCount);
	return uploadedCount;
}

function uploadFile() {
	preprocessing();
	$('unc-uploading').style.display = 'inline';
	$('unc-btn-action').style.display = 'none';
	Web.Form.submit('unc-unit',{target:'invisible',method:'post',action:'uploadManager',resubmit:'y'});
}

function uploadSuccess() {
	$fn('unc-cash','fileMask').value = '';
	$fn('unc-cash','fileSize').value = '';
	$fn('unc-cash','fileName').value = '';

	var sum = 0;
	var uploaded = Web.Form.hash['uploaded'];
	for (var i = 0; i < uploaded.length; i++) {
		if (Web.Form.hash['uploaded'][i].status) {
			$fn('unc-cash','fileMask').value += uploaded[i].filemask + "|";
			$fn('unc-cash','fileSize').value += uploaded[i].filesize + "|";
			$fn('unc-cash','fileName').value += uploaded[i].filename + "|";
			sum += parseInt(uploaded[i].filesize);
		}
	}

	if (Web.Form.hash['file_cnt'] > 0 ) {
		var totalLimit = Web.Form.hash['totalSize'] * 1024 * 1024;
		if (sum > totalLimit) {
			Web.alert({title:'°æ°í',msg:'ÀüÃ¼ ÆÄÀÏ ¾÷·Îµå Á¦ÇÑ »çÀÌÁî´Â <strong>'+Web.Form.hash['totalSize']+'M</strong> ÀÔ´Ï´Ù'});
			return;
		}
	}
	
	//alert('¾÷·Îµå´ë»ó°Ç¼ö : '+uploaded.length + ', ¾÷·ÎµåµÈ°Ç¼ö : '+cc);
	//alert('¾÷·ÎµåÁ¤º¸\n'+document.unc-cash.fileMask.value+'\n\n'+document.unc-cash.fileName.value);

	Web.Form.submit('unc-cash',{target:'_self',method:'post',action:'board-save.do'});
}

function limitUpload() {
	if (Web.Form.hash['file_cnt'] > 0) {
		var uploadCount = getUploadCount();
		if (Web.Form.hash['file_cnt'] <= uploadCount) {
			Web.alert({title:'°æ°í',msg:'ÆÄÀÏ ¾÷·Îµå Á¦ÇÑ °¹¼ö´Â <strong>'+limitCount+'°³</strong>ÀÔ´Ï´Ù'});
			return false;
		}
	} 
	else {
		Web.alert({title:'ÁÖÀÇ',msg:'ÆÄÀÏ ¾÷·Îµå±â´ÉÀÌ Á¦ÇÑµÇ¾î ÀÖ½À´Ï´Ù'});
		return false;
	}
	return true;
}

function make_script(status, display_script) {
	this.status = status;
	this.display_script = display_script;
}

function make_upload(status, filename, filemask, filesize) {
	this.status = status;
	this.filename = filename;
	this.filemask = filemask;
	this.filesize = filesize;
}

/**
 *	Ã·ºÎÆÄÀÏ ¾÷·ÎµåÈÄ ³Ñ°ÜÁÖ´Â ÇÔ¼ö
 */
function add_attach(fn, fm, fs) {
	var uploaded = Web.Form.hash['uploaded'];
	var idx = uploaded.length;
	uploaded[idx] = new make_upload(true, fn, fm, fs);
	Web.Form.hash['uploaded'] = uploaded;
}

/**
 * ¼öÁ¤½Ã ÃÊ±âÈ­
 */
function add_file(fn, fm, fs) {
	var scripts = Web.Form.hash['scripts'];
	var uploaded = Web.Form.hash['uploaded'];
	var seq = scripts.length;
	var display_script = '<span id=unc-file-disply-items'+fm+' style=color:darkblue>'+fn+'('+Web.Format.file(fs)+') <b onclick=remove_item_image('+seq+',"'+fm+'") style=cursor:pointer>remove..</b></span><br>';
	scripts[seq] = new make_script(true, display_script);
	var idx = uploaded.length;
	uploaded[idx] = new make_upload(true, fn, fm, fs);
	Web.Form.hash['scripts'] = scripts;
	Web.Form.hash['uploaded'] = uploaded;
	item_list();
}

/**
 * ÀÌ¹ÌÁö, FLASH Ãß°¡½Ã
 */
function add_picture(fn, fm, fs) {
	var scripts = Web.Form.hash['scripts'];
	var uploaded = Web.Form.hash['uploaded'];
	recalcul(fs, '+');
	var seq = scripts.length;
	var display_script = '<span id=unc-file-disply-items'+fm+' style=color:blue>'+fn+'('+Web.Format.file(fs)+') <b onclick=remove_item_image('+seq+',"'+fm+'") style=cursor:pointer>remove..</b></span><br>';
	scripts[seq] = new make_script(true, display_script);
	var idx = uploaded.length;
	uploaded[idx] = new make_upload(true, fn, fm, fs);
	Web.Form.hash['scripts'] = scripts;
	Web.Form.hash['uploaded'] = uploaded;
	item_list();
}

/**
 * Ã·ºÎÆÄÀÏ
 */
function attach(obj) {
	if (!limitUpload()) return;
	var val = obj.value;
	var idx = obj.name.substring('unc-file'.length);
	obj.style.display = 'none';
	
	add_item(++idx, val);	
	item_list();
}

function add_item(idx, val) {
	var scripts = Web.Form.hash['scripts'];
	var seq = scripts.length;
	var display_script = '<span id=unc-file-disply-items'+idx+'>'+val+' <b onclick=remove_item('+seq+') style=cursor:pointer><font color=#000066>remove..</font></b></span><br>';
	var file_script = '<span id=unc-file-item'+idx+'><input type=file name=unc-file'+idx+' id=unc-file'+idx+' onchange=attach(this) size=1 style=width:0;cursor:pointer></span>';
	scripts[seq] = new make_script(true, display_script);
	Web.Form.hash['scripts'] = scripts;
	$('unc-file-items').insertAdjacentHTML("afterEnd", file_script);
}

function item_list() {
	var validate_cnt = 0;
	var display_scripts = '';
	var scripts = Web.Form.hash['scripts'];
	for (var i = 0; i < scripts.length; i++) {
		if (scripts[i].status){
			validate_cnt++;
			display_scripts += '<b>'+validate_cnt+'</b>. '+scripts[i].display_script;
		}
	}

	if (validate_cnt == 0) {
		display_scripts = 'Ã·ºÎµÈ ÆÄÀÏÀÌ ¾ø½À´Ï´Ù..';
	}
	$('unc-file-disply-items').update(display_scripts);
}

function remove_item(seq) {
	var scripts = Web.Form.hash['scripts'];
	scripts[seq].status = false;
	//alert(seq + ' ' + scripts.length);
	if ((seq+1) != scripts.length || scripts.length == 1) {
		if ($('unc-file-item'+(seq+1))) {
			$('unc-file-item'+(seq+1)).update('');
		}
	}
	Web.Form.hash['scripts'] = scripts;
	item_list();
}

function remove_item_uploaded(seq, fm) {
	var scripts = Web.Form.hash['scripts'];
	var uploaded = Web.Form.hash['uploaded'];
	scripts[seq].status = false;
	for (var i = 0; i < uploaded.length; i++) {
		//alert(fm + ' ' + uploaded[i].filemask);
		if (uploaded[i].filemask == fm) {
			uploaded[i].status = false;
			recalcul(uploaded[i].filesize, '-');
		}
	}
	Web.Form.hash['scripts'] = scripts;
	Web.Form.hash['uploaded'] = uploaded;
	item_list();
}
function remove_item_image(seq, fm) {
	var alice = Unc.alice.hash['alice'];
	var contents = alice.getContent();
	if (contents != null && !contents.empty()) {
		var tmpidx = contents.indexOf('/'+fm.substring(0,8)+'/'+fm);
		if (tmpidx > -1) {
			var tmp1 = contents.substring(0, tmpidx);
			var tmp2 = contents.substring(tmpidx);
			var startidx = Web.isIE? tmp1.lastIndexOf('<IMG') : tmp1.lastIndexOf('<img');
			var endidx = tmp2.indexOf('>')+1;
			if (startidx > 0) {
				var tmp3 = contents.substring(0, startidx);
				if (endidx > 0) {
					var tmp4 = tmp2.substring(endidx);
					contents = tmp3+tmp4;
					alice.setContent(contents);
				}
			} 
			else if (startidx == 0) {
				if (endidx > 0) {
					var tmp4 = tmp2.substring(endidx);
					contents = tmp4;
					alice.setContent(contents);
				}
			}
		}
	}

	remove_item_uploaded(seq, fm);
}

function preprocessing() {
	var scripts = Web.Form.hash['scripts'];
	var idx = scripts.length + 1;
	if ($('unc-file-item'+idx)) {
		$('unc-file-item'+idx).update('');
	}
}

function closeUpload(bul) {
	$('unc-uploading').style.display = 'none';
	$('unc-btn-action').style.display = 'inline';
	if (!bul) {
		uploadClear();
	}
}

function getMaxUpload() {
	var max = 0;
	var frm = $('unc-unit');
	for (var i = 0; i < frm.elements.length; i++) {
		if (frm.elements[i].type == 'file') {
			var t = frm.elements[i].name.substring('unc-file'.length);
			if (max < parseInt(t))
				max = parseInt(t);
		}
	}
	return max;
}

function uploadClear() {	
	var max = getMaxUpload();
	for (var i = max; i > 0; i--) {
		$('unc-file-item'+i).update('');
	}
	$('unc-file-item'+max).update('<input type=file name=unc-file'+max+' id=unc-file'+max+' onchange=attach(this) size=1 style=width:0;cursor:pointer>');

	var scripts = Web.Form.hash['scripts'];
	var uploaded = Web.Form.hash['uploaded'];
	for (var i = 0; i < scripts.length; i++) {
		scripts[i] = null;
	}
	scripts = null;
	scripts = new Array();

	for (var i = 0; i < uploaded.length; i++) {
		if (uploaded[i].status) {
			var seq = scripts.length;
			var fm = uploaded[i].filemask;
			var fn = uploaded[i].filename;
			var fs = uploaded[i].filesize;
			var display_script = '<span id=unc-file-disply-items'+fm+' style=color:blue>'+fn+'('+Web.Format.file(fs)+') <b onclick=remove_item_image('+seq+',"'+fm+'") style=cursor:pointer>remove..</b></span><br>';
			scripts[seq] = new make_script(true, display_script);
		}
	}
	Web.Form.hash['scripts'] = scripts;
	Web.Form.hash['uploaded'] = uploaded;	
	item_list();
}

function recalcul(fs, op) {
	var cur = parseInt($fn('unc-cash','fileTotalSize').value) + (op == '+'?  parseInt(fs) : -1 * parseInt(fs));
	$fn('unc-cash','fileTotalSize').value = cur;
	$('unc-uploaded-totalSize').update(Web.Format.file(cur));
}

function searchNext(pg) {
	$fn('unc-cash','command').value = "DETAIL";
	$fn('unc-cash','page').value = pg;
	Web.submit('unc-cash',{method:'post',action:'search.do'});
}

function searchSummary() {
	boardSearch('SUMMARY');
}

function boardSearch(cmd) {
	if ($('unc-search-and-key').value.empty() &&
        $('unc-search-or-key').value.empty()) {
     	Web.alert({title:'°æ°í',msg:'°Ë»ö¾î¸¦ ÀÔ·ÂÇÏ¼¼¿ä',focus:'unc-search-and-key'});
     	return;   	
	}
	if ($('unc-search-and-key').value.strip().length < 2 &&
		$('unc-search-or-key').value.strip().length < 2) {
		Web.alert({title:'°æ°í',msg:'°Ë»ö¾î¸¦ µÎ±ÛÀÚ ÀÌ»ó ÀÔ·ÂÇÏ¼¼¿ä',focus:'unc-search-and-key'});
		return;
	}
	if (!$('unc-search-not-key').value.empty() &&
		$('unc-search-and-key').value.empty() &&
		$('unc-search-or-key').value.empty()) {
		Web.alert({title:'°æ°í',msg:'<strong>´ÙÀ½´Ü¾î</strong>µé ¾øÀÌ ¿É¼ÇÀº <strong>¸ðµç´Ü¾î Æ÷ÇÔ</strong>ÀÌ³ª <strong>Àû¾îµµ ÇÑ´Ü¾î¸¦ Æ÷ÇÔ</strong> ¿É¼Ç°ú ÇÔ²² »ç¿ëÇØ¾ß ÇÕ´Ï´Ù',focus:'unc-search-not-key'});
		return;
	}
	
	$fn('unc-cash','command').value = cmd;
	$fn('unc-cash','searchType').value = $fn('unc-cash','searchType').value.empty() ? 'T C N MC MN FF' : $fn('unc-cash','searchType').value;
	$fn('unc-cash','searchAndKey').value = $('unc-search-and-key').value;
	$fn('unc-cash','searchOrKey').value = $('unc-search-or-key').value;
	$fn('unc-cash','searchNotKey').value = $('unc-search-not-key').value;
	$fn('unc-cash','thumbnailSize').value = 50;
	$fn('unc-cash','pageScale').value = 10;
	$fn('unc-cash','summary').value = 200;
	$fn('unc-cash','page').value = 1;
	Web.submit('unc-cash',{method:'post'});
}

function searchDetail(bid) {
	$fn('unc-cash','boardId').value = bid;
	boardSearch('DETAIL');
}

function indexPoll() {
	$fn('unc-idx-poll','provenance').value = "board-read.do?boardId="+$fn('unc-idx-poll','boardId').value+"&boardNo="+$fn('unc-idx-poll','boardNo').value+"&command=READ&page=1&categoryId=-1";
	Web.confirm({title:'È®ÀÎ',msg:'¼³¹®¿¡ ÅõÇ¥ ÇÏ½Ã°Ú½À´Ï±î?',fnok: function() {
		var nm = $n('unc-poll-cash');
		$fn('unc-idx-poll','pollSeq').value = '';
		for (var i = 0; i < nm.length; i++) {
			if (nm[i].checked) {
				$fn('unc-idx-poll','pollSeq').value = nm[i].value;
				break;
			}
		}
		if ($fn('unc-idx-poll','pollSeq').value == '') {
			Web.alert({title:'°æ°í',msg:'ÅõÇ¥ÇÒ º¸±â¸¦ ¼±ÅÃÇØ ÁÖ¼¼¿ä'});
			return;	
		}
		
		Web.Form.submit('unc-idx-poll',{method:'post',action:'poll-save.do'});
	}});
}

function auctionNext(p) {
	if (p) {
		$fn('unc-cash','page').value = p;	
	}
	Web.submit('unc-cash', {method:'post',action:'auction-list.do'});
}

function auction_init() {
	var boardWidth = 600;
	if ($fn('unc-cash','commonWidth') != null) {
		boardWidth = parseInt($fn('unc-cash','commonWidth').value) - 30;
	}
	var obj = $n('alc-images');
	for (var i = 0; i < obj.length; i++) {		
		if (obj[i].width > boardWidth) {
			obj[i].width = boardWidth;
		}
	}
	
	if ($('auc-point')) {
		Web.Element.setInputBoxStyle('auc-point');
		$('auc-point').focus();
	}
	if ($fn('unc-cash','progressable').value == 'true') {
		Web.util.Countdown.init($fn('unc-cash','current_time').value);
		auction_count();
	}
	else if ($fn('unc-cash','notStartable').value == 'true') {
		$("auc-remain").innerHTML = '°æ¸Å½ÃÀÛÀü ÀÔ´Ï´Ù';
	}
	else if ($fn('unc-cash','terminatable').value == 'true') {
		$("auc-remain").innerHTML = '°æ¸Å°¡ Á¾·áµÇ¾ú½À´Ï´Ù';
	}
}

function auction_count() {
	$("auc-remain").innerHTML = Web.util.Countdown.count($fn('unc-cash','toAuction_time').value);
	setTimeout('auction_count()',500);
}

function auctionAction() {
	if ($('auc-login').value.toString() == 'false') {
		Web.alert({title:'·Î±×ÀÎ',msg:'Æ÷ÀÎÆ®°æ¸Å¿¡ ÀÔÂûÇÏ±â À§ÇØ¼­´Â <b>·Î±×ÀÎ</b> ÇÏ¼Å¾ß ÇÕ´Ï´Ù',width:300});
		return;
	}

	if (parseInt($fn('unc-cash','userPoint').value) < (parseInt($('auc-point').value)+parseInt($fn('unc-cash','joinPoint').value))) {
		Web.alert({title:'Æ÷ÀÎÆ® È®ÀÎ',msg:'ÇöÀç ¼ÒÀ¯ Æ÷ÀÎÆ®´Â <b>'+$fn('unc-cash','userPoint').value+'</b>Á¡ ÀÔ´Ï´Ù<br>¼ÒÀ¯Æ÷ÀÎÆ®º¸´Ù ÀÔÂû Æ÷ÀÎÆ®(ÀÔÂû ¼ÒºñÆ÷ÀÎÆ® Æ÷ÇÔ)¸¦ Àû°Ô ÀÔ·ÂÇØ¾ß ÇÕ´Ï´Ù',width:440});
		return;
	}
	
	if (parseInt($fn('unc-cash','fromPoint').value) > parseInt($('auc-point').value)) {
		Web.alert({title:'Æ÷ÀÎÆ® È®ÀÎ',msg:'ÀÔÂûÆ÷ÀÎÆ® ÃÖ¼Ò Æ÷ÀÎÆ®º¸´Ù ³ô°Ô ÀÔ·ÂÇÏ¼¼¿ä',width:390});
		return;
	}
	
	if (parseInt($fn('unc-cash','toPoint').value) < parseInt($('auc-point').value)) {
		Web.alert({title:'Æ÷ÀÎÆ® È®ÀÎ',msg:'ÀÔÂûÆ÷ÀÎÆ® ÃÖ´ë Æ÷ÀÎÆ®º¸´Ù ³·°Ô ÀÔ·ÂÇÏ¼¼¿ä'});
		return;
	}
	
	if (!Web.Form.validateValue('auc-point')) return;
	if (!Web.Form.validateNum('auc-point')) return;
	
	Web.confirm({title:'Æ÷ÀÎÆ® °æ¸Å ÀÔÂû',msg:'Æ÷ÀÎÆ® °æ¸Å¿¡ <b>'+$("auc-point").value+' Á¡</b>À» ÀÔÂûÇÕ´Ï´Ù',fnok: function() {
		$fn('unc-cash','point').value = $('auc-point').value;
		Web.submit('unc-cash', {method:'post',action:'auction-save.do'});
	}});
}

function auctionJoin() {
	if ($('auc-join-list').style.display == '' || $('auc-join-list').style.display == 'none') {
		$('auc-join-list').style.display = 'inline';
	}
	else {
		$('auc-join-list').style.display = 'none';
	}
}