
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':
			read_init();
			break;
		case 'D':
		default:
	}
	if ($('unc-category-list')) {
		Unc.tag.select.apply('unc-category-list',120);
	}	
	if (($fn('unc-cash', 'titleThumbnail_yn').value == 'Y' && c == 'A')|| c == 'D') {
		loadThumb();
	}
	Web.Element.setClass('span','unc-fnt-out', 'unc-fnt-over');
}

function read_init() {
	loadImage();
	loadPoll();
	loadStarPoint();
	size_init05();
	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);
		}
	}
	if (($fn('unc-cash', 'titleThumbnail_yn').value == 'Y' && $fn('unc-cash','boardModel_cd').value == 'A') || $fn('unc-cash','boardModel_cd').value == 'C') {
		loadThumb();
	}
	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['files'] = new Array();
	Web.Element.setClass('span','unc-fnt-out', 'unc-fnt-over');
	Web.Element.insertAdjacent();
	
	YAHOO.util.Event.onDOMReady(function () { 
		var uiLayer = YAHOO.util.Dom.getRegion('yui-file-select');
		var overlay = YAHOO.util.Dom.get('yui-uploader-overlay');

		YAHOO.util.Dom.setStyle(overlay, 'width', uiLayer.right-uiLayer.left + "px");
		YAHOO.util.Dom.setStyle(overlay, 'height', uiLayer.bottom-uiLayer.top + "px");
	});
	
	if (Web.Form.hash['file_cnt'] > 0) {
		YAHOO.widget.Uploader.SWFURL = "./swf/yui/uploader/uploader.swf";
		var uploader = new YAHOO.widget.Uploader( "yui-uploader-overlay" );
		uploader.addListener('contentReady', handleContentReady);
		uploader.addListener('fileSelect', onFileSelect);
		uploader.addListener('uploadStart', onUploadStart);
		uploader.addListener('uploadProgress', onUploadProgress);
		uploader.addListener('uploadCancel', onUploadCancel);
		uploader.addListener('uploadComplete', onUploadComplete);
		uploader.addListener('uploadCompleteData', onUploadResponse);
		uploader.addListener('uploadError', onUploadError);
	    //uploader.addListener('rollOver', handleRollOver);
	    //uploader.addListener('rollOut', handleRollOut);
	    //uploader.addListener('click', handleClick);
		//uploader.addListener('mouseDown', handleMouseDown);
		//uploader.addListener('mouseUp', handleMouseUp);
		Web.Form.hash['yuiuploader'] = uploader;

		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("|");
			
			var dataArr = [];
			var uploaded = [];
			var idx = 0;
			if (!Web.Form.hash['serialFileName'].empty() && 
				n.length == m.length && n.length == s.length) {
				
				for (var i = n.length-1; i >= 0; i--) {
					if (n[i] != 'ALICE.IMG') idx++;
				}
				
				for (var i = n.length-1; i >= 0; i--) {
					if (n[i] != 'ALICE.IMG') {
						idx--;
						uploaded[idx] = new make_files('up'+idx, idx, true, n[i], m[i], s[i]);
						var entry = {};
						entry["id"] = 'up'+idx;
						entry["name"] = n[i];
						entry["size"] = s[i];
						entry["progress"] = "<div style='overflow:hidden;height:5px;width:100px;background-color:pink;'><div style='overflow:hidden;height:5px;background-color:#FF0A88;width:100px;'></div></div>";
						entry["remove"] = "<span style='cursor:pointer' onclick='remove_file(\"up"+idx+"\")'>»èÁ¦</span>";
						dataArr.unshift(entry);	
					}
				}
			}
			Web.Form.hash['files'] = uploaded;
			draw_file_list(dataArr);
		}
		else {
			draw_file_list([]);
		}
	}

	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();
	}
	
	if ($fn('unc-cash','license_yn').value == 'Y') {
		if (Web.Form.hash['command'] == 'MODIFY') {
			var ccl = $fn('unc-cash','boardCCL_fg').value;
			if (ccl.charAt(0) == 'Y') {
				$('ccluse_yn').checked = true;
				$('unc-ccl-config').style.display = '';
				if (ccl.charAt(1) == 'Y') {
					$n('commercial_yn')[0].checked = true;
				}
				else if (ccl.charAt(1) == 'N') {
					$n('commercial_yn')[1].checked = true;
				}
				
				if (ccl.charAt(2) == 'Y') {
					$n('derivatives_yn')[0].checked = true;
				}
				else if (ccl.charAt(2) == 'N') {
					$n('derivatives_yn')[1].checked = true;
				}
				else if (ccl.charAt(2) == 'C') {
					$n('derivatives_yn')[2].checked = true;
				}
			}
			else if (ccl.charAt(0) == 'N') {
				$('ccluse_yn').checked = false;
				$('unc-ccl-config').style.display = 'none';
			}
			loadCCL();
		}
		else if (Web.Form.hash['command'] == 'WRITE' || Web.Form.hash['command'] == 'REPLY') {
			$('unc-ccl-config').style.display = 'none';
		}
	}

	if ($fn('unc-cash','popConfig_yn').value == 'Y' && Web.Form.hash['command'] == 'MODIFY') {
		if ($('unc-popup-config')) $('unc-popup-config').style.display = 'inline';
		
		Web.Form.setValue('unc-unit','popConfig','Y');
		Web.Form.setValue('unc-unit','popStyle', $fn('unc-cash','popStyle').value);
		Web.Form.setValue('unc-unit','popLocation', $fn('unc-cash','popLocation').value);
	}
	else {
		if ($('unc-popup-config')) $('unc-popup-config').style.display = 'none';
	}
		
	Unc.alice.hash['alice'] = Web.EditorManager.instance("unc-alice",{width:$fn('unc-cash','boardWidth').value,height:350,invoke:"editorUploadAfter",thumbnail:Web.Form.hash['thumbnailSize']});
	if ($fn('unc-unit','userNick')) {
		$fn('unc-unit','userNick').focus();
	}
	else {
		$fn('unc-unit','boardTitle').focus();
	}
	size_init03();
	loadAliceAutoSaved('alice', 'alice-content');
	setTimeout('loadAliceAutoSaving("alice", "alice-content")', 60000);
}

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_init99();
	scroll_init();
}

/**
 * ¸ñ·ÏÇü A-Type
 */
function size_init01() {
	var wid =  $fn('unc-cash','boardWidth').value;
	var col1 = $('unc-title01')? 22:0;
	var col2 = $('unc-title02')? 70:0;
	var col3 = $('unc-title03')? 40:0;
	var col4 = $('unc-title04')? $fn('unc-cash','thumbnailSize').value:0;
	var col5 = $('unc-title05')? 20:0;
	var col6 = 0;
	var col7 = $('unc-title07')? 100:0;
	var col8 = $('unc-title08')? 85:0;
	var col9 = $('unc-title09')? 50:0;
	var col10 = $('unc-title10')? 4:0;

	if ($('unc-title01')) Element.setStyle($('unc-title01'), {width:col1});
	if ($('unc-title02')) Element.setStyle($('unc-title02'), {width:col2});
	if ($('unc-title03')) Element.setStyle($('unc-title03'), {width:col3});
	if ($('unc-title04')) Element.setStyle($('unc-title04'), {width:col4});
	if ($('unc-title05')) Element.setStyle($('unc-title05'), {width:col5});
	if ($('unc-title07')) Element.setStyle($('unc-title07'), {width:col7});
	if ($('unc-title08')) Element.setStyle($('unc-title08'), {width:col8});
	if ($('unc-title09')) Element.setStyle($('unc-title09'), {width:col9});
	if ($('unc-title10')) Element.setStyle($('unc-title10'), {width:col10});
	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});		
	}
}

/**
 * ½ºÅ©·ÑÇü B-Type
 */
function size_init02() {
	var tot =  $fn('unc-cash','boardWidth').value;
	if (tot > 0) {
		var wid = parseInt(tot) - 22 - 40 - 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});
		}
	}
}

/**
 * NOBR °øÅë (¹æ¸í·ÏÇü C-Type)
 */
function size_init03() {
	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_init04() {
	var tot =  $fn('unc-cash','boardWidth').value;	
	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-rd-nobr');
	for (var i = 0; i < obj.length; i++) {
		Element.setStyle(obj[i], {width:wid});
	}
	obj = $n('unc-me-nobr');
	wid -= 40;
	for (var i = 0; i < obj.length; i++) {
		Element.setStyle(obj[i], {width:wid});
	}
}

/**
 * °Ô½ÃÆÇ °øÅë(½ºÅ²Á¦¿Ü,ex: °Ë»ö)
 */
function size_init99() {
	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 = 80;
	$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 ($fn('unc-cash','articleWritable').value == 'false' ) {
		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) - 23;
	}

	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;
		}
	}
	if ($fn('unc-cash','boardModel_cd').value != 'C')
		loadSlider();	
}

function loadSlider() {
	var imgs = $('unc-read-content').getElementsByTagName('img');
	var alcs = [];
	for (var i = 0; i < imgs.length; i++) {
		if (imgs[i].name == 'alc-images') {
			alcs.push(imgs[i]);
		}
	}
	if (alcs.length > 1) {
		$('unc-slider-title').style.display = 'inline';
		Web.Slider.load(alcs);
	}
	else {
		$('unc-slider-title').style.display = 'none';
	}
}

function loadThumb() {
	var arr = $n('alc-thumb');
	var siz = parseInt($fn('unc-cash','thumbnailSize').value)+1;
	var bid = $fn('unc-cash', 'boardId').value;
	var rel = Web.isIE? '0':'3px';
	for (var i =0; i < arr.length; i++) {		
		if (arr[i].src.substring(arr[i].src.lastIndexOf('/')+1) != 'no.gif')  {
			var bno = arr[i].id.substring(arr[i].id.lastIndexOf('-')+1);
			var img = '<div style="text-align:right;width:'+(siz)+'px;overflow:hidden;position:relative;margin:-19px 0 0 '+rel+';"><img id=unc-plus-'+bno+' src=./img/common/board/i_plus.gif class=unc-pnt style="border:none;padding:0" onmouseover=showThumbnailList("'+bid+'","'+bno+'")></div>';
			var ht = $('alc-thumb-span-'+bno).innerHTML + img;
			$('alc-thumb-span-'+bno).update(ht);
		}
	}
}

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 loadAliceAutoSaved(editor, key) {
	var c = Unc.Cookie.getCookie(key);
	if (c != null && !c.empty() && '<br>' != c) {
		Web.confirm({title:'È®ÀÎ',msg:'ÀúÀåµÇ¾ú´ø ³»¿ëÀÌ ÀÖ½À´Ï´Ù<br>ºÒ·¯¿À°Ú½À´Ï±î?',fnok: function() {
			Unc.alice.hash[editor].setContent(c);
		}});
	}
}

function loadAliceAutoSaving(editor, key) {
	var c = Unc.alice.hash[editor].getContent();
	Unc.Cookie.setCookie(key, c, 7);
	setTimeout('loadAliceAutoSaving("'+editor+'","'+key+'")', 60000);
	if ($('unc-edit-save'))
		$('unc-edit-save').update('1ºÐ¸¶´Ù ÀÚµ¿ ÀúÀå µË´Ï´Ù - ÀúÀåµÇ¾ú½À´Ï´Ù ('+(new Date().toLocaleString())+')');
}

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, uid, bul) {
	if (bul) {
		actionArticle(fg, pk);
	}
	else {
		if (uid.length == 0)
			showPwForm(evt, fg, pk);
		else {
			if (fg == 'modify') 
				Web.alert({title:'°æ°í', msg:'ÇØ´ç±ÛÀÇ <b>¼öÁ¤ ±ÇÇÑ</b>ÀÌ ¾ø½À´Ï´Ù'});
			else if (fg == 'delete') 
				Web.alert({title:'°æ°í', msg:'ÇØ´ç±ÛÀÇ <b>»èÁ¦ ±ÇÇÑ</b>ÀÌ ¾ø½À´Ï´Ù'});
			else if (fg == 'delete-memo') 
				Web.alert({title:'°æ°í', msg:'ÇØ´ç´ñ±ÛÀÇ <b>»èÁ¦ ±ÇÇÑ</b>ÀÌ ¾ø½À´Ï´Ù'});
		}
	}
}

function viewMemo(pk) {	
	var isEdit = true;
	if ($fn('unc-cash','boardModel_cd').value == 'C') {
		if ($('unc-memo-lst-'+pk)) {
			Web.Element.toggleDisplay('unc-memo-lst-'+pk, true);
		}
		isEdit = $fn('unc-cash','memoWritable').value == 'true';
	}
	else {
		if ($fn('unc-cash','memoWritable').value == 'false' ) {
			Web.alert({title:'°æ°í', msg:'´ñ±ÛÀÛ¼º ±ÇÇÑÀÌ ¾ø½À´Ï´Ù'});
			return;	
		}
	}
	if (isEdit) {
		Web.Element.toggleDisplay('unc-memo-'+pk, true);
		var obj = $('unc-memo-'+pk);
		if (obj.style.display == 'inline') {
			loadAliceAutoSaved(pk, 'unc-memo-input-'+pk);
			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);
			
			setTimeout('loadAliceAutoSaving("'+pk+'", "unc-memo-input-'+pk+'")', 60000);
		}
	}
}

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 ($fn('unc-cash','memoWritable').value == 'false' ) {
		Web.alert({title:'°æ°í', msg:'´ñ±ÛÀÛ¼º ±ÇÇÑÀÌ ¾ø½À´Ï´Ù'});
		return;	
	}
	
	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 'up-memo':
			Web.confirm({title:'È®ÀÎ',msg:'ÀÌ ´ñ±ÛÀ» <b>ºÕ¾÷</b> ÇÏ½Ã°Ú½À´Ï±î?',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_UP';
				Web.Form.submit('unc-cash',{method:'post',action:'memo-save.do'});
			}});
			break;
		case 'down-memo':
			Web.confirm({title:'È®ÀÎ',msg:'ÀÌ ´ñ±ÛÀ» <b>ºÕ´Ù¿î</b> ÇÏ½Ã°Ú½À´Ï±î?',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_DOWN';
				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 h = 0;
	var root = xml.getElementsByTagName("articles")[0];
	var articles = [];
	if (root != null) {
		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>";
		}
		h = articles.length * 20;
	}
	if (root == null || articles.length == 0) {
		txt += "°ü·ÃµÈ ±ÛÀÌ ¾ø½À´Ï´Ù";
		h = 25;
	}

	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();
	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(/"/,'');
	}

	if ($fn('unc-cash','license_yn').value == 'Y' && $('ccluse_yn').checked) {
		var ccl = 'Y';
		if ($n('commercial_yn')[0].checked) ccl += 'Y';
		else if ($n('commercial_yn')[1].checked) ccl += 'N';
		if ($n('derivatives_yn')[0].checked) ccl += 'Y';
		else if ($n('derivatives_yn')[1].checked) ccl += 'N';
		else if ($n('derivatives_yn')[2].checked) ccl += 'C';
		$fn('unc-cash','boardCCL_fg').value = ccl;
	}
	else 
		$fn('unc-cash','boardCCL_fg').value = 'NXX';

	if ($('popConfig') && $('popConfig').checked) {
		if (!Web.Form.validateValue('unc-pop-from')) return;
		if (!Web.Form.validateLength('unc-pop-from',10)) return;
		if (!Web.Form.validateValue('unc-pop-to')) return;
		if (!Web.Form.validateLength('unc-pop-to',10)) return;		
		
		if (!Web.Form.validateValue($fn('unc-unit','popFrom_hhmm'))) return;
		if (!Web.Form.validateLength($fn('unc-unit','popFrom_hhmm'), 4)) return;
		if (!Web.Form.validateNum($fn('unc-unit','popFrom_hhmm'))) return;
		
		if (!Web.Form.validateValue($fn('unc-unit','popTo_hhmm'))) return;
		if (!Web.Form.validateMaxByte($fn('unc-unit','popTo_hhmm'), 4)) return;
		if (!Web.Form.validateNum($fn('unc-unit','popTo_hhmm'))) return;
		
		if (!Web.Form.validateValue($fn('unc-unit','popWidth'))) return;
		if (!Web.Form.validateMaxByte($fn('unc-unit','popWidth'), 4)) return;
		if (!Web.Form.validateNum($fn('unc-unit','popWidth'))) return;
		
		if (!Web.Form.validateValue($fn('unc-unit','popHeight'))) return;
		if (!Web.Form.validateMaxByte($fn('unc-unit','popHeight'), 4)) return;
		if (!Web.Form.validateNum($fn('unc-unit','popHeight'))) return;
		
		if (!Web.Form.validateRadio('popStyle')) {
			Web.alert({title:'ÁÖÀÇ',msg:'ÆË¾÷Ã¢ Á¾·ù¸¦ ¹Ýµå½Ã ¼±ÅÃÇÏ¼¼¿ä'});
			return;
		}
		if (!Web.Form.validateRadio('popLocation')) {
			Web.alert({title:'ÁÖÀÇ',msg:'ÆË¾÷Ã¢ À§Ä¡¼³Á¤À» ¹Ýµå½Ã ¼±ÅÃÇÏ¼¼¿ä'});
			return;
		}
		if ($fn('unc-unit','popLocation').value == 'D') {
			if (!Web.Form.validateValue($fn('unc-unit','popLocationLeft'))) return;
			if (!Web.Form.validateMaxByte($fn('unc-unit','popLocationLeft'), 4)) return;
			if (!Web.Form.validateNum($fn('unc-unit','popLocationLeft'))) return;
			
			if (!Web.Form.validateValue($fn('unc-unit','popLocationTop'))) return;
			if (!Web.Form.validateMaxByte($fn('unc-unit','popLocationTop'), 4)) return;
			if (!Web.Form.validateNum($fn('unc-unit','popLocationTop'))) return;
		}
		if (Web.Form.getValue('unc-unit','popStyle') == 'C') {
			Web.Form.setValue('unc-unit', 'popLocation', 'B');
		}
		else if (Web.Form.getValue('unc-unit','popStyle') == 'D') {
			Web.Form.setValue('unc-unit', 'popLocation', 'A');
		}
		else if (Web.Form.getValue('unc-unit','popStyle') == 'E') {
			Web.Form.setValue('unc-unit', 'popLocation', 'A');
		}

		$fn('unc-cash','popFrom_time').value = $('unc-pop-from').value.substring(0,4)+$('unc-pop-from').value.substring(5,7)+$('unc-pop-from').value.substring(8,10)+$fn('unc-unit','popFrom_hhmm').value;
		$fn('unc-cash','popTo_time').value = $('unc-pop-to').value.substring(0,4)+$('unc-pop-to').value.substring(5,7)+$('unc-pop-to').value.substring(8,10)+$fn('unc-unit','popTo_hhmm').value;
		
		if (parseInt($fn('unc-cash','popFrom_time').value) > parseInt($fn('unc-cash','popTo_time').value)) {
			Web.alert({title:'°æ°í',msg:'ÆË¾÷Ã¢ ½ÃÀÛ±â°£ÀÌ Á¾·á±â°£º¸´Ù ¾Õ¼·´Ï´Ù'});
			return;
		}
		
		$fn('unc-cash','popWidth').value = $fn('unc-unit','popWidth').value;
		$fn('unc-cash','popHeight').value = $fn('unc-unit','popHeight').value;
		$fn('unc-cash','popStyle').value = $rd('popStyle'); 
		$fn('unc-cash','popLocation').value = $rd('popLocation');
		$fn('unc-cash','popLocationLeft').value = $fn('unc-unit','popLocationLeft').value;
		$fn('unc-cash','popLocationTop').value = $fn('unc-unit','popLocationTop').value;		
		$fn('unc-cash','popConfig_yn').value = 'Y';
	}
	else
		$fn('unc-cash','popConfig_yn').value = 'N';
	
	var uploadCount = getUploadCount();
	if (uploadCount > 0 && Web.Form.hash['file_cnt'] > 0) {
		uploadFile();
	}
	else {
		uploadSuccess();
	}
}

function setPopStyle(fg) {
	if (fg == 'C') {
		Web.information({title:'Á¤º¸',msg:'ÆË¾÷Ã¢ Á¾·ù°¡ <b>¸Þ¼¼Áö</b>ÀÏ °æ¿ì<br>ÆË¾÷Ã¢ À§Ä¡´Â <b>ÁÂÃøÀ§</b>·Î °íÁ¤µË´Ï´Ù',width:250});
		Web.Form.setValue('unc-unit','popLocation','B');
	}
	else if (fg == 'D') {
		Web.information({title:'Á¤º¸',msg:'ÆË¾÷Ã¢ Á¾·ù°¡ <b>·¹ÀÌ¾î¾Ë·µÃ¢</b>ÀÏ °æ¿ì<br>ÆË¾÷Ã¢ À§Ä¡´Â <b>°¡¿îµ¥</b>·Î °íÁ¤µË´Ï´Ù',width:250});
		Web.Form.setValue('unc-unit','popLocation','A');
	}
	else if (fg == 'E') {
		Web.information({title:'Á¤º¸',msg:'ÆË¾÷Ã¢ Á¾·ù°¡ <b>¾Ë·µÃ¢</b>ÀÏ °æ¿ì<br>ÆË¾÷Ã¢ À§Ä¡´Â <b>°¡¿îµ¥</b>·Î °íÁ¤µË´Ï´Ù',width:250});
		Web.Form.setValue('unc-unit','popLocation','A');
	}
}

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 files = Web.Form.hash['files'];
	var cnt = 0;
	for (var i = 0; i < files.length; i++) {
		if (!files[i].complete)
			cnt++;
	}
	return cnt;
}

function uploadFile() {
	var sum = 0;
	var files = Web.Form.hash['files'];
	
	
    // ÆÄÀÏ¸í Áßº¹ Ã¼Å©	
    for (var i = 0; i < files.length; i++) {
    	var string = files[i].filename;
    	for (var j = 0; j < string.length; j++) {
    		if ("!@#$%^&*,;:'\"?=".indexOf(string.substring(j, j + 1)) > -1) {
    			Web.alert({title:'°æ°í',width:400,msg:'<b>'+string+'</b><br>ÆÄÀÏ¿¡ Æ¯¼ö¹®ÀÚ°¡ µé¾î°¡¸é ¾ÈµË´Ï´Ù'});
    			return;
    		}
    	}
    	for (var k = 0; k < files.length; k++) {
    		//alert('i : '+i+', k : '+k+', '+string+', '+files[k].filename);
    		if (k != i && string == files[k].filename) {
    			Web.alert({title:'°æ°í',width:400,msg:'<b>'+string+'</b><br>µ¿ÀÏÇÑ ÀÌ¸§ÀÇ ÆÄÀÏÀº Ã·ºÎÇÒ¼ö ¾ø½À´Ï´Ù<br>ÆÄÀÏ¸íÀ» ¼öÁ¤ÈÄ ¾÷·Îµå ÇÏ¼¼¿ä'});
        		return;
        	}
    	}
    }
	
	var limitSize = parseInt($fn('unc-cash','fileLimitSize').value);
	for (var i = 0; i < files.length; i++) {
		if (limitSize * 1024 * 1024 <= parseInt(files[i].filesize)) {
			Web.alert({title:'°æ°í',width:400,msg:'ÆÄÀÏ ¾÷·Îµå Á¦ÇÑ »çÀÌÁî´Â <strong>'+limitSize+'M</strong> ÀÔ´Ï´Ù<br><b>'+files[i].filename+'</b>ÆÄÀÏÀÇ »çÀÌÁî°¡ ³Ê¹« Å®´Ï´Ù'});
			return;
		}
		sum += parseInt(files[i].filesize);
	}
	var totalLimit = Web.Form.hash['totalSize'] * 1024 * 1024;
	if (sum > totalLimit) {
		Web.alert({title:'°æ°í',msg:'ÀüÃ¼ ÆÄÀÏ ¾÷·Îµå Á¦ÇÑ »çÀÌÁî´Â <strong>'+Web.Form.hash['totalSize']+'M</strong> ÀÔ´Ï´Ù'});
		return;
	}

	$('unc-btn-action').style.display = 'none';
	var context = $fn('unc-cash','context').value;
	Web.Form.hash['yuiuploader'].setSimUploadLimit(1);

	Web.Form.hash['yuiuploader'].uploadAll(context+'/uploadManager',
			"POST",
			{subId:document.getElementsByName("subId")[0].value,
			 mode:document.getElementsByName("mode")[0].value});
	uploadComleteCheck();
}

function uploadComleteCheck() {
	var isComplete = true;
	var files = Web.Form.hash['files'];
	for (var i = 0; i < files.length; i++) {
		if (files[i].complete == false) {
			isComplete = false;
			break;
		}
	}
	if (isComplete) {
		uploadSuccess();
	}
	else {
		setTimeout('uploadComleteCheck()', 500);
	}
}

function uploadSuccess() {
	$fn('unc-cash','fileMask').value = '';
	$fn('unc-cash','fileSize').value = '';
	$fn('unc-cash','fileName').value = '';

	var files = Web.Form.hash['files'];
	for (var i = 0; i < files.length; i++) {
		$fn('unc-cash','fileMask').value += files[i].filemask + "|";
		$fn('unc-cash','fileSize').value += files[i].filesize + "|";
		$fn('unc-cash','fileName').value += files[i].filename + "|";
	}
	
	var imgs = Unc.alice.hash['alice'].getAliceContentWindow().document.body.getElementsByTagName('img');
	var alcs = [];
	for (var i = 0; i < imgs.length; i++) {
		if (imgs[i].name == 'alc-images') {
			fn = 'ALICE.IMG';
			fm = imgs[i].src.substring(imgs[i].src.lastIndexOf('/')+1);
			fs = imgs[i].fileSize;
			if ($fn('unc-cash','thumbnailName').value == '') {
				$fn('unc-cash','thumbnailName').value = fm;
			}
			$fn('unc-cash','fileMask').value += fm + "|";
			$fn('unc-cash','fileSize').value += fs + "|";
			$fn('unc-cash','fileName').value += fn + "|";
		}
	}
	//Unc.Cookie.delCookie('alice-content');
	Web.Form.submit('unc-cash',{target:'_self',method:'post',action:'board-save.do'});
}

function make_files(fid, seq, complete, filename, filemask, filesize) {
	this.fid = fid;
	this.seq = seq;
	this.complete = complete;
	this.filename = filename;
	this.filemask = filemask;
	this.filesize = filesize;
}

/**
 *	Ã·ºÎÆÄÀÏ ¾÷·ÎµåÈÄ ³Ñ°ÜÁÖ´Â ÇÔ¼ö
 */
function add_attach(fn, fm, fs) {}


/**
 * ÀÌ¹ÌÁö, FLASH Ãß°¡½Ã
 */
function add_picture(fn, fm, fs) {
	$fn('unc-cash','thumbnailName').value = fm;
}

/**
 * Ã·ºÎÆÄÀÏ
 */

function handleContentReady () {
    // Allows the uploader to send log messages to trace, as well as to YAHOO.log
	Web.Form.hash['yuiuploader'].setAllowLogging(true);
	
	// Allows multiple file selection in "Browse" dialog.
	Web.Form.hash['yuiuploader'].setAllowMultipleFiles(true);
	
	// New set of file filters.
	//var ff = new Array({description:"Images", extensions:"*.jpg;*.png;*.gif"},
	//                   {description:"Videos", extensions:"*.avi;*.mov;*.mpg"});
	                   
	// Apply new set of file filters to the uploader.
	//uploader.setFileFilters(ff);
}

function onFileSelect(event) {
	if('fileList' in event && event.fileList != null) {
		Web.Form.hash['yuifilelist'] = event.fileList;
		createDataTable(Web.Form.hash['yuifilelist']);
	}
}

function createDataTable(entries) {
	var dataArr = [];
	var files = Web.Form.hash['files'];	
    for (var i = 0; i < files.length; i++) {
		if (files[i].fid.indexOf('up') == 0) {
			var entry = {};
			entry["id"] = files[i].fid;
			entry["name"] = files[i].filename;
			entry["size"] = files[i].filesize;
			entry["progress"] = "<div style='overflow:hidden;height:5px;width:100px;background-color:pink;'><div style='overflow:hidden;height:5px;background-color:#FF0A88;width:100px;'></div></div>";
			entry["remove"] = "<span style='cursor:pointer' onclick='remove_file(\"up"+i+"\")'>»èÁ¦</span>";
			dataArr.unshift(entry);
		}
	}
    for(var i in entries) {
		var entry = entries[i];
	    entry["progress"] = "<div style='overflow:hidden;height:5px;width:100px;background-color:pink;'></div>";
	    entry["remove"] = "<span style='cursor:pointer' onclick='remove_file(\""+i+"\")'>»èÁ¦</span>";
	    dataArr.unshift(entry);
	}
    
	var tempFiles = new Array();
	for (var j = 0; j < dataArr.length; j++) {		
		if (dataArr[j].id.indexOf('up') == 0) {			
			var filemask = '';
			for (var i = 0; i < files.length; i++) {
				if (files[i].fid == dataArr[j].id) {					
					filemask = files[i].filemask;
					break;
				}
			}
			tempFiles[j] = new make_files(dataArr[j].id, j, true, dataArr[j].name, filemask, dataArr[j].size);
		}
		else {
			tempFiles[j] = new make_files(dataArr[j].id, j, false, dataArr[j].name, null, dataArr[j].size);
		}
	}
	Web.Form.hash['files'] = tempFiles;	
	draw_file_list(dataArr);
}

function draw_file_list(dataArr) {	
	var myCustomFormatter = function(elLiner, oRecord, oColumn, oData) {
        elLiner.innerHTML = "<div align='right'>"+Web.Format.file(oRecord.getData("size"))+"</div>";
    };
    
	YAHOO.widget.DataTable.Formatter.myCustom = myCustomFormatter;

	var myColumnDefs = [
        {key:"name", label: "ÆÄÀÏ¸í", sortable:false, width:(Web.isIE? 325:300)},
     	{key:"size", label: "»çÀÌÁî", formatter:"myCustom", sortable:false, width:(Web.isIE? 80:60)},
     	{key:"progress", label: "¾÷·Îµå ÁøÇà¹Ù", sortable:false, width:(Web.isIE? 120:100)},
     	{key:"remove", label: "»èÁ¦", sortable:false, width:(Web.isIE? 45:30)}
	];

	var myDataSource = new YAHOO.util.DataSource(dataArr);
	myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSARRAY;
	myDataSource.responseSchema = {
			fields: ["id","name", "size", "progress", "remove"]
	};
	
	this.singleSelectDataTable = new YAHOO.widget.DataTable("dataTableContainer",
           myColumnDefs, myDataSource, { selectionMode:"single", height:"5em"});
	show_file_size();
}

function onUploadProgress(event) {
	var filename = '';
	var filesize = 0;
	var seq = 0;
	var sum = 0;
	var com = 0;
	var files = Web.Form.hash['files'];
	for (var i = 0; i < files.length; i++) {		
		if (files[i].fid == event["id"]) {
			filename = files[i].filename;
			filesize = files[i].filesize;
			seq = files[i].seq;
		}
		if (files[i].complete) {
			com += files[i].filesize;
		}
		sum += files[i].filesize;
	}
	prog = Math.round(100*(event["bytesLoaded"]/event["bytesTotal"]));
	totprog = Math.round(100* (575*((event["bytesLoaded"]+com)/(sum)))/100 );
	progbar = "<div style='overflow:hidden;height:5px;width:100px;background-color:pink;'><div style='overflow:hidden;height:5px;background-color:#FF0A88;width:" + prog + "px;'></div></div>";
	totalprogress = "<div style='overflow:hidden;height:5px;width:575px;background-color:pink;'><div style='overflow:hidden;height:5px;background-color:#FF0A88;width:" + totprog + "px;'></div></div>";
	singleSelectDataTable.updateRow(seq, {name: filename, size: filesize, progress: progbar, remove:prog+"%"});
	$('yui-total-progress').update(totalprogress);
}

function onUploadComplete(event) {
	var filename = '';
	var filesize = 0;
	var seq = 0;
	var files = Web.Form.hash['files'];
	for (var i = 0; i < files.length; i++) {
		if (files[i].fid == event["id"]) {
			filename = files[i].filename;
			filesize = files[i].filesize;
			seq = files[i].seq;
		}
	}	
	progbar = "<div style='overflow:hidden;height:5px;width:100px;background-color:pink;'><div style='overflow:hidden;height:5px;background-color:#FF0A88;width:100px;'></div></div>";
	singleSelectDataTable.updateRow(seq, {name: filename, size: filesize, progress: progbar, remove:"100%"});
}

function onUploadStart(event) {    
}   
	   
function onUploadError(event) {
}   
	        
function onUploadCancel(event) {   
}   
	        
function onUploadResponse(event) {
	if (event.data.indexOf('errors.') != 0) {
		var files = Web.Form.hash['files'];
		for (var i = 0; i < files.length; i++) {
			if (files[i].fid == event.id) {
				files[i] = new make_files(files[i].fid, files[i].seq, true, files[i].filename, event.data.trim(), files[i].filesize);
			}
		}
	}
}

function remove_file(fid) {	
	var seq = 0;
	var files = Web.Form.hash['files'];
	for (var i = 0; i < files.length; i++) {
		if (files[i].fid == fid) {
			seq = files[i].seq;
		}
	}
	//alert('delete row is '+seq);
	if (fid.indexOf('up') != 0) {
		Web.Form.hash['yuiuploader'].removeFile(fid);
	}
	singleSelectDataTable.deleteRow(seq);
    var idx = 0;
    var tempFiles = new Array();
	for (var i = 0; i < files.length; i++) {		
		if (files[i].fid != fid) {
			//alert(files[i].fid+' '+idx+' '+files[i].filename+' '+files[i].filemask);
			tempFiles[idx] = new make_files(files[i].fid, idx++, files[i].complete, files[i].filename, files[i].filemask, files[i].filesize);
		}
	}
	
    Web.Form.hash['files'] = tempFiles;
    show_file_size();
}

function show_file_size() {
	var sum = 0;
	var files = Web.Form.hash['files'];
	for (var i = 0; i < files.length; i++) {
		sum += parseInt(files[i].filesize);
	}
	
	$('unc-uploaded-totalSize').update('ÆÄÀÏÃÑ »çÀÌÁî : <b>'+Web.Format.file(sum)+'</b>');
	$('unc-edit-file').style.height = (42+(files.length == 0? 1:files.length) * 22.2)+'px';
}

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 = 80;
	$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' && $fn('unc-cash','terminate_fg').value == 'N') {
		Web.util.Countdown.init($fn('unc-cash','current_time').value);
		auction_count();
	}
	else if ($fn('unc-cash','notStartable').value == 'true' && $fn('unc-cash','terminate_fg').value == 'N') {
		$("auc-remain").innerHTML = '°æ¸Å½ÃÀÛÀü ÀÔ´Ï´Ù';
	}
	else if ($fn('unc-cash','terminate_fg').value == 'Y' || $fn('unc-cash','terminate_fg').value == 'E') {
		$("auc-remain").innerHTML = '°æ¸Å°¡ Á¾·áµÇ¾ú½À´Ï´Ù';
		$('auc-join-list').style.display = 'inline';
	}
}

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';
	}
}

function showThumbnailList(bid, bno, left, top) {
	Unc.ThumbManager.loading({bid:bid, bno:bno, left:left, top:top});
}

function viewCCL() {
	if ($('ccluse_yn').checked) {
		$('unc-ccl-config').style.display = '';
		if (!$n('commercial_yn')[1].checked && !$n('commercial_yn')[1].checked)
			$n('commercial_yn')[1].checked = true;
		if (!$n('derivatives_yn')[0].checked && !$n('derivatives_yn')[1].checked && !$n('derivatives_yn')[2].checked) 
			$n('derivatives_yn')[1].checked = true;
	}
	else
		$('unc-ccl-config').style.display = 'none';
	loadCCL();
}

function loadCCL() {
	var txt = '';
	if ($('unc-ccl-config').style.display != 'none') {
		if ($('ccluse_yn').checked)
			txt += '<img src=./img/common/icon/ccl/i_ccl1.gif>';
		if ($n('commercial_yn')[1].checked)
			txt += '<img src=./img/common/icon/ccl/i_ccl2.gif>';
		if ($n('derivatives_yn')[1].checked)
			txt += '<img src=./img/common/icon/ccl/i_ccl4.gif>';
		else if ($n('derivatives_yn')[2].checked)
			txt += '<img src=./img/common/icon/ccl/i_ccl3.gif>';
	}
	else
		txt = '';
	$('unc-ccl-img').update(txt);	
}

function fileDownload() {
	Web.alert({title:'È®ÀÎ',msg:'ÆÄÀÏ ´Ù¿î·Îµå ±ÇÇÑÀÌ ¾ø½À´Ï´Ù'});
}

function showCCLHelp(ccl) {
	var txt = '<b>ÀÌ ÀúÀÛ¹°Àº ¾Æ·¡ Á¶°Ç ¸¸Á· ½Ã<br>º°µµ Çã°¡¾øÀÌ »ç¿ë °¡´É ÇÕ´Ï´Ù</b><br><br>';
	if (ccl.charAt(0) == 'Y')
		txt += '<img src=./img/common/user/i_bul.gif> ÀúÀÛÀÚ ¸í½Ã ÇÊ¼ö<br>';
	if (ccl.charAt(1) == 'N')
		txt += '<img src=./img/common/user/i_bul.gif> ¿µ¸®Àû »ç¿ë ºÒ°¡<br>';
	if (ccl.charAt(2) == 'N')
		txt += '<img src=./img/common/user/i_bul.gif> ³»¿ë º¯°æ ºÒ°¡<br>';
	else if (ccl.charAt(2) == 'C')
		txt += '<img src=./img/common/user/i_bul.gif> µ¿ÀÏÁ¶°Ç À¯Áö½Ã º¯°æ Çã°¡<br>';
	txt += '<br>';
	Web.information({title:'Á¤º¸',msg:txt,width:220,height:140});
}

function linkCCLHelp(ccl) {
	var url = '';
	if (ccl == 'YNN') url = 'http://creativecommons.org/licenses/by-nc-nd/2.0/kr/';	
	else if (ccl == 'YNC') url = 'http://creativecommons.org/licenses/by-nc-sa/2.0/kr/';
	else if (ccl == 'YNY') url = 'http://creativecommons.org/licenses/by-nc/2.0/kr/';
	else if (ccl == 'YYN') url = 'http://creativecommons.org/licenses/by-nd/2.0/kr/';
	else if (ccl == 'YYC') url = 'http://creativecommons.org/licenses/by-sa/2.0/kr/';
	else if (ccl == 'YYY') url = 'http://creativecommons.org/licenses/by/2.0/kr/';
	window.open(url,'_blank');
}

function viewPopConfig() {
	if ($('popConfig').checked) 
		$('unc-popup-config').style.display = '';
	else
		$('unc-popup-config').style.display = 'none';
}






