/*bbs-list table header init style*/
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':
			//gallery_init();	
		default:
	}
/* catagory combo box ui setting
	if ($('unc-category-list')) {
		Unc.tag.select.apply('unc-category-list',200);
	}
*/
	if (($fn('unc-cash', 'titleThumbnail_yn').value == 'Y' && c == 'A')) {
		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', "24px");
	});
	
	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+"\")'>delete</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';
	}
	
	// alice editor initialize
	Unc.alice.hash['alice'] = Web.EditorManager.instance("unc-alice",{width:689,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();
	// define auto save
	/*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);
	var bid = $fn('unc-cash','boardId').value;
	location.href="board-list.do?boardId="+ bid +"&page="+pg;
}

function nextArticle(pg) {
	$fn('unc-cash','page').value = pg;
	Web.submit('unc-cash', {method:'get',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:'Alert', msg:'You don\'t permission'});
		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>Search keyword</b> <input type=text id=unc-search-key name=unc-search-key title=\"검색어\" onkeydown=\"Web.Event.captureEnter(event, 'searchArticle()')\">"+
					"</div>"+
				"</form>";
	
	Web.popup({title:'Search',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() {
	try{
		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';
		}
	} catch (err){
	}
}

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);
		}
	}
}

/*using jQuery*/
function gallery_init() {
	var bid = $fn('unc-cash', 'boardId').value;
	var siz = parseInt($fn('unc-cash','thumbnailSize').value)+1;

	var obj = jQuery("p.img");
	var glink = jQuery("a", obj);
	//var img = jQuery("img:first", glink);

	jQuery(glink).each(function(){
		this.img = jQuery("img:first", this);
		var src = "";

		jQuery(this).bind("click",function(){
			src = jQuery(this.img).attr("src");
			src.replace('thumb','editor').viewer();
		})
	});


	
	//Unc.Thumb.loading(bno,bid);
	//Web.Ajax.invoke({action:'ajax-thumbs.do', params:'boardId='+bid+'&boardNo='+bno, handler:'Unc.ThumbManager.parsing'});
/*
	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:'Alert',msg:'There is temporary content in your computer.<br>Do you want to use it?',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('The content will be saved in every 1 minute - Saved it. ('+(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:'Alert', msg:'You do not have any permission to modify it.'});
			else if (fg == 'delete') 
				Web.alert({title:'Alert', msg:'You do not have any permission to delete it.'});
			else if (fg == 'delete-memo') 
				Web.alert({title:'Alert', msg:'You do not have any permission to delete it.'});
		}
	}
}

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:'Alert', msg:"You don't permission"});
			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:100,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>"+
				"password <input type=password name=unc-del-pwd id=unc-del-pwd title='password' onkeyup=\"Web.Event.captureEnter(event, 'validatePassword()')\">"+
				"<input type=hidden id=unc-tmp-fg><input type=hidden id=unc-tmp-pk>"+
			  "</div>";
			  
	Web.popup({title:'insert password',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:'Alert', msg:'You don\'t have permission'});
		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><b>'+str.substring(0, 50) + '</b>... to replay it');
	}
}

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:'Confirm',msg:'Are you sure to delete it?',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:'Confirm',msg:'Are you sure to delete it?',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:'Confirm',msg:'Do you want to join the poll?',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:'Alert',msg:'Select view poll.'});
					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:'Confirm',msg:'Do you submit this Tag?',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':
			
			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;
				}
			}			

			$fn('unc-cash','memoContent').value = $('unc-memo-input-'+pk).value;
			if (!Web.Form.validateValue($fn('unc-cash','memoContent'), 'Memo') ||
				!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:'get',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:'Alert', 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:'Alert',msg:'Please write the contents.'});	
		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:'Alert', msg:'Please select category.'});
			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:'Alert',msg:'Please specify scedule!'});
		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:'Alert',msg:'Yon can upload up to <strong>'+Web.Form.hash['file_cnt']+'</strong>files at a time'});
			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:'information',msg:'팝업창 종류가 <b>메세지</b>일 경우<br>팝업창 위치는 <b>좌측위</b>로 고정됩니다',width:250});
		Web.Form.setValue('unc-unit','popLocation','B');
	}
	else if (fg == 'D') {
		Web.information({title:'information',msg:'팝업창 종류가 <b>레이어알럿창</b>일 경우<br>팝업창 위치는 <b>가운데</b>로 고정됩니다',width:250});
		Web.Form.setValue('unc-unit','popLocation','A');
	}
	else if (fg == 'E') {
		Web.information({title:'information',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:'Alert',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:'Alert',width:400,msg:'<b>'+string+'</b><br>You can not put any special character in the filename'});
    			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:'Alert',width:400,msg:'<b>'+string+'</b><br>You should specify the different name respectively. Please change the file name and try it again.'});
        		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:'Alert',width:400,msg:'The maxium fiie size is up to <strong>'+limitSize+'Mbyte</strong>.<br /><b>'+files[i].filename+'</b>is too big to upload.'});
			return;
		}
		sum += parseInt(files[i].filesize);
	}
	var totalLimit = Web.Form.hash['totalSize'] * 1024 * 1024;
	if (sum > totalLimit) {
		Web.alert({title:'Alert',msg:'The whole maximum size is <strong>'+Web.Form.hash['totalSize']+'Mbyte</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+"\")'>delete</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+"\")'>delete</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: "filename", sortable:false, width:(Web.isIE? 325:300)},
     	{key:"size", label: "size", formatter:"myCustom", sortable:false, width:(Web.isIE? 80:60)},
     	{key:"progress", label: "status", sortable:false, width:(Web.isIE? 120:100)},
     	{key:"remove", label: "delete", 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('Total size : <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:'Do you join poll?',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:'Please select view poll'});
			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 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:'Alert',msg:'You do not have any permission for download.'});
}

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';
}
