Unc = {
	version:'3.3',
	creator:'GoodBug',
	updated:'2007.12.31'
};

Web.namespace("Unc.tag");

Unc.alice = {
	hash: new Hash	
}

Unc.tag.select = {
	selectedIndex:0,
	apply: function(id, w,h) {
		var obj = $(id);		
		var i1 = id+'-1';
		var i2 = id+'-2';
		var i3 = id+'-3';
		h = h||19;
		obj.style.display = 'none';

		var txt = ""+
			"<table width='"+w+"' cellspacing=0 cellpadding=0 style=position:absolute;cursor:default;>"+
				"<tr height=1><td></td></tr><tr><td>"+
					"<table border=0 cellspacing=0 cellpadding=0 style=\"width:100%;height:"+h+";border:1px solid #c0c0c0;line-height:117%;font-family:vernada;font-size:9pt;\" "+
							"onmouseover=\"Unc.tag.select.overMainlayer(this, '"+i3+"','"+i2+"')\" "+
							"onmouseout=\"Unc.tag.select.outMainlayer(this , '"+i3+"')\" >"+ 
						"<tr onclick=\"Unc.tag.select.showSublayer('"+i2+"','"+i1+"')\">"+
							"<td id='"+i1+"' onblur=\"Unc.tag.select.blur(this)\">&nbsp;"+obj.options[obj.selectedIndex].text+"</td>"+
							"<td align=right width=10 bgcolor=#eeeeee><img id='"+i3+"' src='./img/skin/default/dot.gif' style=\"vertical-align:middle;filter:gray()\"></td></tr>"+
					"</table>"+
					"<table id='"+i2+"' cellspacing=2 cellpadding=2 onblur=\"Unc.tag.select.hide(this)\" style=\"display:none;width:100%;display:none;border:1px solid #c0c0c0;font-family:vernada;font-size:9pt;background-color:#ffffff;\">";
		for (var i = 0 ; i < obj.length; i++) {
			txt += "<tr height=18 onclick=\"Unc.tag.select.change('"+obj.id+"',"+i+",this,'"+i2+"','"+i1+"')\">"+
						"<td width='"+w+"' style=";
			if (obj.selectedIndex == i) {
				txt += "'background-color:#225588;color:#ffffff;'";
			} else {
				txt += "'background-color:#ffffff;color:#000000;'";
			}
			txt += "onmouseover=\"Unc.tag.select.overSublayer(this)\" onmouseout=\"Unc.tag.select.outSublayer(this)\">&nbsp;"+
					obj.options[i].text+"</td></tr>";
		}
		txt += "</table></td></tr></table><img src='' width='"+w+"' height=0>";
		Web.Html.appendHtml(txt, id);
	},
	
	overSublayer: function(obj) {
		obj.style.backgroundColor = '#225588';
		obj.style.color = '#ffffff';
	},
	outSublayer: function(obj) {
		obj.style.backgroundColor = '#ffffff';
		obj.style.color = '#000000';
	},
	
	change: function(id, i, tr, i2, i1) {
		this.selectedIndex = i;
		var obj = $(id);
		var o2 = $(i2);
		var o1 = $(i1);
		
		obj.value = obj.options[i].value;
		o2.style.display = 'none';
		o1.update("&nbsp;"+obj.options[i].text);
		o1.style.backgroundColor = '#225588';
		o1.style.color = '#ffffff';
		if (Web.isIE) {
			o1.focus();
		}
		this.list();
	},
	
	list: function() {
		if ($('unc-category-list') && $('unc-category-list').present()) {
			categoryList($('unc-category-list').value);	
		}
	},
	
	hide: function(obj) {
		if (obj.style.display != 'none') {
			setTimeout("$(\""+obj.id+"\").style.display = 'none';" , 1000);
		}
	},
	
	showSublayer: function(i2, i1) {
		var o2 = $(i2);
		var o1 = $(i1);
		if(o2.style.display == 'none') {
			o1.style.background = '#ffffff';
			o1.style.color = '#000000';	
			o2.style.display = 'block';
			if (Web.isIE) {
				o2.focus();
			}
		} else {
			o1.style.background = '#225588';
			o1.style.color = '#ffffff';
			o2.style.display = 'none';
		}
	},
	
	overMainlayer: function(obj, i3, i2) {		
		var o2 = $(i2);
		var o3 = $(i3);
		if (o2.style.display == 'none') {
			obj.style.border = '1px solid #225588';
			o3.style.filter = '';
		}
	},
	
	outMainlayer: function(obj, i3) {
		var o3 = $(i3);
		obj.style.border = '1px solid #c0c0c0';
		o3.style.filter = 'gray()';
	},
	
	blur: function(obj) {
		obj.style.background = '#FFFFFF';
		obj.style.color = '#000000';
	}
}

Unc.scroll = {
	form: new Hash,
	boundaryMax: 0,
	direction: 'UP',
	lock: false,

	init: function() {
		this.form = Web.Form.loadForm('unc-cash');
		if (Web.Location.current() == 'search.do') {
			this.form['boardSkin'] = this.form['commonSkin'];
		}
		else {
			this.form['boardSkin'] = this.form['defaultBoardSkin'];	
		}		
	
		if ($('unc-scr-box')) {
			if ($('unc-scr-page-no')) {	
				$('unc-scr-page-no').update(Web.Math.format(this.form['page']));
			}

			if (Web.isIE) {
				$('unc-scr-box').attachEvent('onmousewheel', Unc.scroll.start);
			} 
			else {
				$('unc-scr-box').addEventListener('DOMMouseScroll', Unc.scroll.start, false);
			}

			//this.middle();
		}
	},
	
	start: function(e) {
		var list = $('unc-scr-box');
		var amount = 0;
		if (Web.isIE) {
			amount = event.wheelDelta;
		}
		else {
			amount = -e.detail;
		}
		
		if (amount > 0) {
			Unc.scroll.up();
		}
		else {
			Unc.scroll.down();
		}
	},
	
	up: function() {
		this.direction = 'UP';
		this.roll($('unc-scr-box').scrollTop-150, -10);
		this.middle();
	},
	
	down: function() {
		this.direction = 'DOWN';
		var list = $('unc-scr-box');
		this.roll(list.scrollTop+150, 10);
	
		var content = $('unc-scr-content');
		if ((content.offsetHeight*9/10) < (list.scrollTop+list.offsetHeight) &&
			this.boundaryMax < list.scrollTop) {
			this.process();
		}
		this.middle();
	},
	
	roll: function(to, off) {
		if ((off > 0 && this.direction == 'UP') || (off < 0 && this.direction == 'DOWN')) return;
		var list = $('unc-scr-box');
		var now = list.scrollTop;
		if ((off > 0 && now < to) ||
			(off < 0 && now > to)
		) {
			if (off > 0 && (to - now < 20)) off = 1;
			else if (off < 0 && (now - to < 20)) off = -1;
			else if (off > 0 && (to - now < 40)) off = 2;
			else if (off < 0 && (now - to < 40)) off = -2;
			else if (off > 0 && (to - now < 60)) off = 3;
			else if (off < 0 && (now - to < 60)) off = -3;
			list.scrollTop += off;
			setTimeout("Unc.scroll.roll("+to+","+off+")", 25);
		} 
	},
	
	move: function(diff) {
		var list = $('unc-scr-box');
		var content = $('unc-scr-content');
		var total = parseInt(content.offsetHeight);
		if (diff > 0) {
			this.direction = 'DOWN';
		}
		else {
			this.direction = 'UP';
		}
		var offset = 8 * total*diff / 100;
		this.roll(list.scrollTop+(total * diff), parseInt(offset));
		if (this.direction == 'DOWN' &&
		    (content.offsetHeight*9/10) < (list.scrollTop+list.offsetHeight) &&
			this.boundaryMax < list.scrollTop) {
			this.process();
		}
		else if (diff == 1) {
			setTimeout("Unc.scroll.process()", 500);
		}
		else if (diff == -1) {
			this.top();
		}		
	},
	
	process: function() {
		var list = $('unc-scr-box');
		if (this.boundaryMax < list.scrollTop) {
			this.boundaryMax = list.scrollTop;
		}
		if (parseInt(this.form['page']) < parseInt(this.form['totalPage'])) {
			this.middle();
	
			if (this.lock) {
				return;
			}
			this.synchronize(true);
			this.form['page']++;
			$('unc-scr-page-no').update(Web.Math.format(this.form['page']));

			if ((typeof this.form['searchAndKey'] == 'undefined' ||	typeof this.form['searchOrKey'] == 'undefined' || typeof this.form['searchNotKey'] == 'undefined') ||
				(this.form['searchAndKey'].empty() && this.form['searchOrKey'].empty() && this.form['searchNotKey'].empty())) {
				Web.Ajax.invoke({action:'ajax-list.do', params:'boardId='+this.form['boardId']+'&page='+this.form['page']+'&totalRecords='+this.form['totalRecords'], handler:'Unc.scroll.parsing'});
			} 
			else {
				Web.Ajax.invoke({action:'ajax-search.do',params:'command=DETAIL&boardId='+this.form['boardId']+'&page='+this.form['page']+'&thumbnailSize='+this.form['thumbnailSize']+'&pageScale='+this.form['pageScale']+'&searchType='+encodeURIComponent(this.form['searchType'])+'&searchAndKey='+encodeURIComponent(this.form['searchAndKey'])+'&searchOrKey='+encodeURIComponent(this.form['searchOrKey'])+'&searchNotKey='+encodeURIComponent(this.form['searchNotKey']),handler:'Unc.scroll.parsing'});				
			}
		}
	},
	
	middle: function() {
		var ifrm = window.frames["unc-scr-iframe"];
		ifrm.moveScrollMiddle();
	},
	
	top: function() {
		this.direction = 'UP';		
		this.roll(0, -10);
	},
	
	synchronize: function(bul) {
		this.lock = bul;
	},
	
	parsing: function(xml) {
		var root = xml.getElementsByTagName("articles")[0];
		var articles = root.getElementsByTagName("article");
		for (var i = 0; i < articles.length; i++) {
			var article = articles[i];
			var row = article.getElementsByTagName("row")[0].firstChild.nodeValue;
			var selected = article.getElementsByTagName("selected")[0].firstChild.nodeValue;
			var boardno = article.getElementsByTagName("boardno")[0].firstChild.nodeValue;
			var boardpoint = article.getElementsByTagName("boardpoint")[0].firstChild.nodeValue;
			var memocnt = article.getElementsByTagName("memocnt")[0].firstChild.nodeValue;
			var thumbnailborder = article.getElementsByTagName("thumbnailborder")[0].firstChild.nodeValue;
			var presentthumbnail = article.getElementsByTagName("presentthumbnail")[0].firstChild.nodeValue;
			var thumbnail = article.getElementsByTagName("thumbnail")[0].firstChild.nodeValue;
			var boardbestfg = article.getElementsByTagName("boardbestfg")[0].firstChild.nodeValue;
			var boardicon = article.getElementsByTagName("boardicon")[0].firstChild.nodeValue;
			var boarddep = article.getElementsByTagName("boarddep")[0].firstChild.nodeValue;
			var recent = article.getElementsByTagName("recent")[0].firstChild.nodeValue;
			var upgrade = article.getElementsByTagName("upgrade")[0].firstChild.nodeValue;
			var readover = article.getElementsByTagName("readover")[0].firstChild.nodeValue;
			var categoryname = article.getElementsByTagName("categoryname")[0].firstChild.nodeValue;
			var subject = article.getElementsByTagName("subject")[0].firstChild.nodeValue;
			var contents = article.getElementsByTagName("contents")[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 tagid = article.getElementsByTagName("tagid")[0].firstChild.nodeValue;
			var tagname = article.getElementsByTagName("tagname")[0].firstChild.nodeValue;
			var tagcnt = article.getElementsByTagName("tagcnt")[0].firstChild.nodeValue;
	
			this.append(row, selected, boardno, boardpoint, memocnt, thumbnailborder, presentthumbnail, thumbnail, boardbestfg, boardicon, boarddep, recent, upgrade, readover, categoryname, subject, contents, user, register, read, tagid, tagname, tagcnt);
		}	
		this.synchronize(false);		
	},
	
	append: function(row, selected, boardno, boardpoint, memocnt, thumbnailborder, presentthumbnail, thumbnail, boardbestfg, boardicon, boarddep, recent, upgrade, readover, categoryname, subject, contents, user, register, read, tagid, tagname, tagcnt) {
		var skin = this.form['boardSkin'];
		var tbl = $('unc-scr-record');
		var html1 = "<span onclick=checkArticle(this) id=unc-check-box name=unc-check-box checkeditem=N  value='"+boardno+"'>"+
						(this.form['multiView_yn'] == 'Y' ? "<img src=./img/skin/"+skin+"/i_nox.gif class=unc-bsc>":"")+
					"</span>";
		var html2 = ""+
					"<nobr id=unc-nobr name=unc-nobr>"+
					"<div style=\"padding:0 0 0 "+(boarddep == 1? 0 : boarddep*15)+"\">"+
						"<div class=unc-scr-title>"+
						(this.form['titleNo_yn'] == 'Y' ? 
							(selected == 'true' ?
								"<img src=./img/skin/"+skin+"/i_selected.gif class=unc-bsc>"
								:"<span class=unc-scr-no>"+row+"</span>"
							):""
						)+
						" "+
						(this.form['titleCategory_yn'] == 'Y' && this.form['category_yn'] == 'Y' ? categoryname : "")+
						" "+
						(this.form['titleIcon_yn'] == 'Y' ?
							(boardbestfg == 'Y' ? "<img src=./img/skin/"+skin+"/i_best.gif class=unc-bsc>" :
								(boardicon =='A' ? "<img src=./img/skin/"+skin+"/i_doc.gif class=unc-bsc>" : "")+
								(boardicon =='B' ? "<img src=./img/skin/"+skin+"/i_file.gif class=unc-bsc>" : "")+
								(boardicon =='C' ? "<img src=./img/skin/"+skin+"/i_poll.gif class=unc-bsc>" : "")+
								(boardicon =='D' ? "<img src=./img/skin/"+skin+"/i_secret.gif class=unc-bsc>" : "")
							):""
	           			)+
	           			" " +
						(boarddep != 1 ? "[re]" : "")+
						(this.form['titlePoint_yn'] == 'Y' && boardpoint > 0 ? "<span class=unc-point>[$"+boardpoint+"]</span>" : "")+
						" "+
						(this.form['titleTag_yn'] == 'Y' ? "<span class=unc-scr-tag onmouseover=this.calssName='unc-scr-tag-over' onmouseout=this.className='unc-scr-tag' onclick=viewTagList('"+tagid+"')>"+tagname+"</span>":"")+
						" "+
						"<strong><a href=\"javascript:readSearchArticle('"+boardno+"')\" target=\"_self\" class=\"unc-main\">"+subject+"</a></strong>"+
						" "+
						(this.form['titleMemo_yn'] == 'Y' && memocnt > 0 ? "<img src=./img/skin/"+skin+"/i_memo.gif class=unc-bsc> <span class=unc-scr-memo>"+memocnt+"</span> " : "")+
						(this.form['titleTag_yn'] == 'Y' && tagcnt > 0 ? "<span class=unc-scr-memo><img src=./img/skin/"+skin+"/i_tag.gif class=unc-bsc> "+tagcnt+"</span> " : "")+
						(this.form['titleNew_yn'] == 'Y' && 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>" : "")
						)+
						"<a href=\"javascript:readSearchArticle('"+boardno+"')\" target=\"_unicornblank\" class=\"unc-main\"><img src=./img/skin/"+skin+"/i_pop.gif class=unc-bsc></a>"+
						"</div>"+
						"<div class=unc-scr-cnt>"+
						(this.form['titleThumbnail_yn'] == 'Y' && presentthumbnail == 'true' ? 
          					"<div class=unc-scr-cnt-thumb style=\"width:"+this.form['thumbnailSize']+"\">"+thumbnailborder+"</div>"
						:"")+
							"<div class=unc-scr-cnt-dtl>"+
							(this.form['titleNick_yn'] == 'Y' && this.form['anonymity_yn'] == 'N' ? user : "")+" "+
							(this.form['titleRead_yn'] == 'Y' ? 
									(this.form['readOver_yn'] == 'Y' ? "<strong>"+this.form['readOver_color']+"</strong>":"")+
									"<span class=unc-scr-read>read "+read+"</span>"
							:"")+
							"<br/><br/>"+contents+
							"</xmp></pre>"+
                    		"</div>"+
						"</div>"+
						"<div class=unc-scr-regdt>"+
							(this.form['titleDate_yn'] == 'Y' ?	"<span class=unc-scr-read>"+register+"</span>":"")+
						"</div>"+
					"</div>"+
                	"</nobr>";
		
		if (Web.isIE) {
			var row = tbl.insertRow();
			var cel1 = row.insertCell();
			var cel2 = row.insertCell();
			row.className = 'unc-scr-tr';
			cel1.className = 'unc-scr-col-multiple';
			cel2.className = 'unc-scr-bsc';
			cel1.innerHTML = html1;
			cel2.innerHTML = html2;
			
		} else {
			var row = document.createElement("tr");
			var cel1 = document.createElement("td");
			var cel2 = document.createElement("td");
			row.appendChild(cel1);
			row.appendChild(cel2);
			row.className = 'unc-scr-tr';
			cel1.className = 'unc-scr-col-multiple';
			cel2.className = 'unc-scr-bsc';
			cel1.innerHTML = html1;
			cel2.innerHTML = html2;
	
			tbl.appendChild(row);
		}
		size_init02();
		
	}
}


Unc.scroll.bar = {
	y: 0,
	vertical: null,
	imgheight: 0,
	dragapproved: false,
	barheight: 0,
	start: 0,
	finish: 0,
	lock: false,	
	init: function() {
		this.vertical = $('unc-vertical');
		this.vertical.style.top = 0;
		this.barheight = Web.isIE? document.documentElement.offsetHeight : self.innerHeight;
		this.imgheight = this.vertical.offsetHeight;
		
		Event.observe(document, "mouseup", this.up);
		Event.observe(document, "mousedown", this.down);
		Event.observe(document, "mousemove", this.move);
		Event.observe(document, "click", this.click);
		this.middle();
	},
	
	down: function(e) {
		Unc.scroll.bar.dragapproved = true;
		Unc.scroll.bar.start = parseInt(Unc.scroll.bar.vertical.style.top);
		Unc.scroll.bar.y = Web.isIE? event.clientY : e.pageY;
	},
	
	up: function(e) {
		Unc.scroll.bar.finish = parseInt(Unc.scroll.bar.vertical.style.top);	
		Unc.scroll.bar.dragapproved = false;
		var diff = (Unc.scroll.bar.finish - Unc.scroll.bar.start) / (Unc.scroll.bar.barheight-65);
		parent.moveScrollBox(diff);
	},
	
	move: function(e) {
		if (Unc.scroll.bar.dragapproved) {
			if (parseInt(Unc.scroll.bar.vertical.style.top) < 0) { 
				Unc.scroll.bar.vertical.style.top = "0px";
				Unc.scroll.bar.up(e);
				return;
			} 
			else if ((Unc.scroll.bar.barheight - Unc.scroll.bar.imgheight) < parseInt(Unc.scroll.bar.vertical.style.top)) { 
				Unc.scroll.bar.vertical.style.top = (Unc.scroll.bar.barheight - Unc.scroll.bar.imgheight)+"px";
				Unc.scroll.bar.up(e);
				return; 
			}
			
			var cy = Web.isIE? event.clientY : e.pageY;
			Unc.scroll.bar.vertical.style.top = (Unc.scroll.bar.start+cy-Unc.scroll.bar.y)+"px";
			if (parseInt(Unc.scroll.bar.vertical.style.top) <= 0) {
				parent.moveScrollTop();
			}			
			return false;
		}
	},
	
	click: function(e) {		
		if (!Unc.scroll.bar.lock) {
			var cy = Web.isIE? event.clientY : e.pageY;
			Unc.scroll.bar.vertical.style.top = ((parseInt(Unc.scroll.bar.vertical.style.top)+Unc.scroll.bar.imgheight/2 < cy)? parseInt(Unc.scroll.bar.vertical.style.top)+Unc.scroll.bar.imgheight/2 : parseInt(Unc.scroll.bar.vertical.style.top)-Unc.scroll.bar.imgheight/2)  +"px";
		}
		
		if ((Unc.scroll.bar.barheight - Unc.scroll.bar.imgheight) < parseInt(Unc.scroll.bar.vertical.style.top)) {
			Unc.scroll.bar.vertical.style.top = (Unc.scroll.bar.barheight - Unc.scroll.bar.imgheight)+"px";
		}
		else if (parseInt(Unc.scroll.bar.vertical.style.top) < 0) {
			Unc.scroll.bar.vertical.style.top = "0px";
			parent.moveScrollTop();
		} 
		else if ((Unc.scroll.bar.barheight - Unc.scroll.bar.imgheight) < parseInt(Unc.scroll.bar.vertical.style.top)) {
			Unc.scroll.bar.vertical.style.top = (Unc.scroll.bar.barheight - Unc.scroll.bar.imgheight)+"px";
		}
	
		Unc.scroll.bar.up(e);
		return false;
	},
	
	middle: function() {	
		var cur = parseInt(this.vertical.style.top)+32;		
		var off = (cur < this.barheight / 2 - this.imgheight/2)? 3:-3;		
		var to = parseInt(this.barheight / 2 - this.imgheight/2);		
		setTimeout("Unc.scroll.bar.roll("+to+","+off+")", 15);
	},
	
	roll: function(to, off) {		
		if ((off < 0 && to >= parseInt(this.vertical.style.top)) || (off > 0 && to <= parseInt(this.vertical.style.top))) {
			return;
		}

		this.vertical.style.position = 'absolute';
		this.vertical.style.left = 1;		
		this.vertical.style.top = (parseInt(this.vertical.style.top) + off) + "px";		
		setTimeout("Unc.scroll.bar.roll("+to+","+off+")", 15);
	},
	
	synchronize: function(bul) {
		this.lock = bul;
	}
}

Unc.tagging = {
	tagSeq: 0,
	curTagIdx: 0,
	currentPk: null,
	oldTextbox: null,
	keystatus: true,
	tagMouseOver: false,
	mconti: false,
	
	init: function() {
		if ($fn('unc-cash','tag_yn').value = 'Y') {
			this.start();
			/*
			if (Web.isIE) {
				this.start();
			}
			else {
				this.start();//document.onkeydown=Unc.tagging.capcureKeyDown;
			}*/
		}
	},
	
	onfocus: function(pk) {
		this.setCurrentPk(pk);
		this.loadBox(true);
		this.setOldTextBox('');
	},      
	
	onblur: function() {
		this.loadBox(false);
		this.setCurrentPk('');		
	},
	
	start: function() {
		if (this.currentPk != '' && !this.mconti) {
			this.monitor();	
		}
		setTimeout('Unc.tagging.start()', 1000);
	},
	
	coloring: function(qry, svd) {
		var rtn = '';
		var qry2 = (qry.length > 1? qry.substring(0,qry.length-1) : qry);
		for (var i = 1; i <= svd.length; i++) {
			if (qry2.toLowerCase() == svd.substring(0,i).toLowerCase())
				rtn = '<span class=unc-tag-color>'+qry2+'</span>'+svd.substring(i);
				
			if (qry.toLowerCase() == svd.substring(0,i).toLowerCase())
				rtn = '<span class=unc-tag-color>'+qry+'</span>'+svd.substring(i);
		}
		return rtn;
	},

	parsing: function(xml) {
		var html = "";
		var pk = this.currentPk;
		var obj = this.getTagName();
		var root = xml.getElementsByTagName("tags")[0];
		var tags = root.getElementsByTagName("tag");
		this.tagSeq = 0;
		this.curTagIdx = 0;
		for (var i = 0; i < tags.length; i++) {	
			var item = tags[i].getElementsByTagName("name")[0].firstChild.nodeValue;
			var colored = this.coloring(obj.value, item);
			html += "<div id=unc-tag-"+pk+"-no-"+(i+1)+" onclick=\"parent.insertTag('"+pk+"','"+item.gsub(/'/, '')+"')\" onmouseover=\"this.style.backgroundColor='#eeeeee';\" onmouseout=\"this.style.backgroundColor='';\">"+(colored.indexOf('<span')== 0? colored:item)+"</div>";
			this.tagSeq++;
		}
		var box = $('unc-tag-box-'+pk);
		//box.style.height = '150px';
		var tag_list = box.contentWindow.document.getElementById('unc-tag-list');
		tag_list.innerHTML = html;
	
		if (this.tagSeq > 0) {
			this.loadBox(true);
		}
		else {
			this.loadBox(false);
		}
	},
	
	ladderKey: function(e) {
		var pk = this.currentPk;
		var key = Web.isIE? window.event.keyCode : e.keyCode;
		if (this.tagSeq > 0) {
			if (key == 40 || key == 38) {
				if (key == 40 && this.curTagIdx < this.tagSeq) {
					this.curTagIdx++;
				}
				else if (key == 38 && this.curTagIdx > 1) {
					this.curTagIdx--;
				}
			
				var box = $('unc-tag-box-'+pk);
				var rw = box.contentWindow.document.getElementById('unc-tag-'+pk+'-no-'+this.curTagIdx);
				this.keystatus = false;
				
				for (var i = 1; i <= this.tagSeq; i++) {
					box.contentWindow.document.getElementById('unc-tag-'+pk+'-no-'+i).style.backgroundColor = '#ffffff';
				}
				
				var tag_list = box.contentWindow.document.getElementById('unc-tag-list');
				if (key == 40) {
					if (this.curTagIdx <= this.tagSeq) {					
						rw.style.backgroundColor = '#eeeeee';
						if (this.curTagIdx > 2) {
							tag_list.scrollTop += 21;
						}
					}
				} 
				else if (key == 38) {
					if (this.curTagIdx > 0) {
						rw.style.backgroundColor = '#eeeeee';
						tag_list.scrollTop -= 21;
					}							
				}
				
				try {
					var obj = this.getTagName();
					obj.value = rw.getAttribute("innerText");
					obj.focus();
				}
				catch(E) {}
				//if (rw)
					//rw.onclick();
			}
			else {
				this.keystatus = true;
			}
		}
	},
	
	setTagMouseOver: function(bul) {
		this.tagMouseOver = bul;
	},
	
	setCurrentPk: function(pk) {
		this.currentPk = pk;
	},
	
	setOldTextBox: function(val) {
		this.oldTextbox = val;
	},
	
	insertTag: function(pk, val) {
		var obj = $('unc-tagsname-'+pk);
		obj.value = val;
		var box = $('unc-tag-box-'+pk);
		box.style.display = 'none';
	},
	
	loadBox: function(bul) {
		var pk = this.currentPk;
		if (bul) {
			if (this.tagSeq > 0 && pk != '') {
				var box = $('unc-tag-box-'+pk);
				var obj = this.getTagName();
				if (obj.value.length > 0) {
					box.style.display = 'inline';
				}
			}
		} 
		else {
			if (!this.tagMouseOver && pk != '') {
				var box = $('unc-tag-box-'+pk);
				box.style.display = 'none';
			}
		}
	},	
	
	getTagName: function() {
		return $('unc-tagsname-'+this.currentPk);
	},
	
	capcureKeyDown: function(e) {
		if (Unc.tagging.currentPk != '') {
			var node = Web.isIE? window.event.srcElement : e.target;
			var textbox = Unc.tagging.getTagName();
			if (textbox == node) {
				Unc.tagging.monitor();
			}
		}
	},

	monitor: function() {
		if (this.currentPk &&
			this.currentPk != '' && 
			this.keystatus) {
			var obj = this.getTagName();
			var textbox = obj.value;			
			if (textbox.strip().length == 0) {
				this.oldTextbox = textbox;
				this.loadBox(false);
			}
	
			if (this.oldTextbox != textbox) {
				Web.Ajax.invoke({action:'ajax-tag.do', params:'tagsName='+encodeURIComponent(textbox), handler:'Unc.tagging.parsing'});
			}
			this.oldTextbox = textbox;
			setTimeout('Unc.tagging.monitor()', 200);
			this.mconti = true;
		} 
		else {
			this.mconti = false;
		}
	}
}

Unc.calendar = {
	target:null,
	stime:null,
	box:null,
	
	over: function() {
		window.clearTimeout(this.stime);
	},
	
	out: function() {
		this.stime = window.setTimeout("Unc.calendar.box.style.display='none';", 200);
	},
	
	click: function(v) {
		this.target.value = v;
		this.box.style.display='none';
	},
	
	day: function(obj) {
		var now = obj.value.split("-");
		this.target = obj;
	
		this.box = $('unc-calendar');
		this.box.style.top = Web.util.Position.objectY(obj) + obj.offsetHeight;
		this.box.style.left = Web.util.Position.objectX(obj)-2;

		this.box.style.display = '';
		
		var ifrm = window.frames["unc-calendar-iframe"];
		if (now.length == 3) {
			ifrm.calendarShow(now[0],now[1],now[2]);					
		} 
		else {
			now = new Date();
			ifrm.calendarShow(now.getFullYear(), now.getMonth()+1, now.getDate());
		}
	},
	
	overit: function(e) {
		var el = Web.isIE? event.srcElement : e.target;
		var d = el.title;
		if (d.length > 7) {
			el.style.borderTopColor = el.style.borderLeftColor = "buttonhighlight";
			el.style.borderRightColor = el.style.borderBottomColor = "buttonshadow";
			el.style.cursor = 'pointer';
		}	
	},
	
	outit: function(e) {
		var el = Web.isIE? event.srcElement : e.target;
		var d = el.title;
		if (d.length > 7) {
			el.style.borderColor = "white";
			el.style.cursor = 'pointer';
		}
	},
	
	day2: function(d) {
		var s = new String();		
		if (parseInt(d) < 10) {
			s = "0" + parseInt(d);
		} 
		else {
			s = "" + parseInt(d);
		}
		return s;	
	},
	
	show: function(y, m, d) {
		var md = new Array(0,31,28,31,30,31,30,31,31,30,31,30,31);
		var hd = new Array('1.1','3.1','5.5','6.6','8.15','10.3','12.25');
		var to = new Date();
		var iy = parseInt(y);
		var im = parseInt(m);
		var id = parseInt(d);
		$('unc-calendar-box').update('');
		
		if (iy == 0) {
			iy = to.getFullYear();
		}
		if (im == 0) {
			im = parseInt(to.getMonth())+1;
		}
		if (id == 0) {
			id = to.getDate();
		}
		
		switch (im) {
			case 1:
				ipy = iy -1;
				ipm = 12;
				iny = iy;
				inm = 2;
				break;
			case 12:
				ipy = iy;
				ipm = 11;
				iny = iy + 1;
				inm = 1;
				break;
			default:
				ipy = iy;
				ipm = parseInt(im) - 1;
				iny = iy;
				inm = parseInt(im) + 1;
				break;
		}
		ippy = iy-1
		inny = iy+1

		ny = to.getFullYear();
		nm = to.getMonth()+1;
		nd = to.getDate();
		
		dfd = new Date(iy, im-1, 1);
		ifw = dfd.getDay();
		
		isw = ifw;
		itw = ifw;
		
		dtd = new Date(iy, im, id);
		itwd = dtd.getDay();
		tpd = 1;

		flg = 0
		if ((iy % 4)==0) {
			if ((iy % 100) == 0) {
				if ((iy % 400) == 0) {
					md[2] = 29;
				}
			} else {
				md[2] = 29;
			}
		}
		ild = md[im];

		txt = "<table id=unc-calendar-tab class=unc-calendar-tab bgcolor='#f4f4f4' border=0 cellpadding=1 cellspacing=1 width=100% onmouseover='Unc.calendar.overit(event)' onmouseout='Unc.calendar.outit(event)'>"+
				"<tr align=center bgcolor='#000066'>"+
				"<td colspan=7 height=25>"+
				"<div style=float:left;padding-left:10px>"+
				"<a class=unc-calendar-title onclick='Unc.calendar.show("+ippy+","+im+","+id+");'>"+ippy+"³â</a> "+
				"<a class=unc-calendar-title onclick='Unc.calendar.show("+ipy+","+ipm+","+id+");'>¢·ÀÌÀü¿ù</a>"+
				"</div>"+
				"<div style=float:right;padding-right:10px>"+
				"<a class=unc-calendar-title onclick='Unc.calendar.show("+iny+","+inm+","+id+");'>ÀÌÈÄ¿ù¢¹</a> "+
				"<a class=unc-calendar-title onclick='Unc.calendar.show("+inny+","+im+","+id+");'>"+inny+"³â</a>"+
				"</div>"+
				"</td></tr>"+
				"<tr align=center bgcolor='#f6f6f6'>"+
				"<td style='padding-top:3px;'><b>ÀÏ</td><td style='padding-top:3px;'><b>¿ù</td><td style='padding-top:3px;'><b>È­</td><td style='padding-top:3px;'><b>¼ö</td><td style='padding-top:3px;'><b>¸ñ</td><td style='padding-top:3px;'><b>±Ý</td><td style='padding-top:3px;'><b>Åä</td>"+
				"</tr>";
			
		for (intLoopWeek=1; intLoopWeek < 7; intLoopWeek++) {
			txt += "<tr align=right bgcolor='white'>"
			for (intLoopDay=1; intLoopDay <= 7; intLoopDay++) {
				if (itw > 0) {
					txt += "<td>";
					itw--;
				} else {
					if (tpd > ild) {
						txt += "<td>";
					} else {
						txt += "<td onClick=Unc.calendar.clickit(this); title="+iy+"-"+Unc.calendar.day2(im).toString()+"-"+Unc.calendar.day2(tpd).toString()+" style=\"cursor:Hand;border:1px solid white;";
						if (iy == ny && im==nm && tpd==id) {
							txt += "background-color:#FEEDF4;font-weight:bold;";
						}
						
						switch(intLoopDay) { 
							case 1:
								txt += "color:#ff0000;";
								break;
							case 7:
								txt += "color:#54A6E2;";
								break;
							default:
						}
						
						for (var i = 0; i < hd.length; i++) {
							if (hd[i] == im+'.'+tpd) {
								txt += "color:#ff0000;";
							}
						}
						
						txt += "\">"+tpd;
						
					}
					tpd++;
					
					if (tpd > ild) {
						flg = 1;
					}
				}
				txt += "</td>";
			}
			txt += "</tr>";
			if (flg==1) break;
		}
	
		txt += "<tr><td colspan=7 align=center height=25 bgcolor=#eeeeee><b>"+iy +"³â "+ im +"¿ù"+"</b></td></tr></table>";
		$('unc-calendar-box').update(txt);
		parent.calendarResize(300, $('unc-calendar-tab').offsetHeight);		
	},
	
	clickit: function(e) {
		parent.calendarClick(e.title);
	}
}

Unc.user = {
	loading: function(uid, e) {
		e = Web.isIE? window.event : e;
		var div = null;
		if ($("unc-user-view")) {
			div = $("unc-user-view");
		}
		else {
			div = document.createElement("div");
			div.setAttribute("id", "unc-user-view");
			document.body.appendChild(div);	
		}
		div.style.left = (e.clientX - 5 + Web.util.Position.deltaX()) + 'px';
		div.style.top = (e.clientY + 1 + Web.util.Position.deltaY()) + 'px';
		div.innerHTML = '<img src=./img/common/board/i_large_loading2.gif>';
		div.style.visibility = 'visible';
		Web.Ajax.invoke({action:'ajax-member-view.do', params:'userId='+uid, handler:'Unc.user.parsing'});
	},
	parsing: function(xml) {
		var root = xml.getElementsByTagName("users")[0];
		var user = root.getElementsByTagName("user")[0];
		var uid = user.getElementsByTagName("uid")[0].firstChild.nodeValue;
		var photo = user.getElementsByTagName("photo")[0].firstChild.nodeValue;
		var level = user.getElementsByTagName("level")[0].firstChild.nodeValue;
		var levelterm = user.getElementsByTagName("levelterm")[0].firstChild.nodeValue;
		var levelgage = user.getElementsByTagName("levelgage")[0].firstChild.nodeValue;
		var point = user.getElementsByTagName("point")[0].firstChild.nodeValue;
		var uname = user.getElementsByTagName("uname")[0].firstChild.nodeValue;
		var nick = user.getElementsByTagName("nick")[0].firstChild.nodeValue;
		var grade = user.getElementsByTagName("grade")[0].firstChild.nodeValue;
		var email = user.getElementsByTagName("email")[0].firstChild.nodeValue;
		var tel1 = user.getElementsByTagName("tel1")[0].firstChild.nodeValue;
		var tel2 = user.getElementsByTagName("tel2")[0].firstChild.nodeValue;
		var tel3 = user.getElementsByTagName("tel3")[0].firstChild.nodeValue;
		var hp1 = user.getElementsByTagName("hp1")[0].firstChild.nodeValue;
		var hp2 = user.getElementsByTagName("hp2")[0].firstChild.nodeValue;
		var hp3 = user.getElementsByTagName("hp3")[0].firstChild.nodeValue;
		var birthday = user.getElementsByTagName("birthday")[0].firstChild.nodeValue;
		var wedding = user.getElementsByTagName("wedding")[0].firstChild.nodeValue;
		var post = user.getElementsByTagName("post")[0].firstChild.nodeValue;
		var addr = user.getElementsByTagName("addr")[0].firstChild.nodeValue;
		var talk = user.getElementsByTagName("talk")[0].firstChild.nodeValue;
		var visitdt = user.getElementsByTagName("visitdt")[0].firstChild.nodeValue;
		var actives = user.getElementsByTagName("active");
		var bests = user.getElementsByTagName("best");
		
		var active_set = new Array();
		for (var k = 0; k < actives.length; k++) {
			var active = actives[k];
			var board = active.getElementsByTagName("board")[0].firstChild.nodeValue;
			var write = active.getElementsByTagName("write")[0].firstChild.nodeValue;
			var reply = active.getElementsByTagName("reply")[0].firstChild.nodeValue;
			var memo = active.getElementsByTagName("memo")[0].firstChild.nodeValue;
			active_set[k] = new Unc.user.history(board, write, reply, memo);
		}
		var best_set = new Array();
		for (var k = 0; k < bests.length; k++) {
			var best = bests[k];
			var board = best.getElementsByTagName("board")[0].firstChild.nodeValue;
			var write = best.getElementsByTagName("write")[0].firstChild.nodeValue;
			var reply = best.getElementsByTagName("reply")[0].firstChild.nodeValue;
			best_set[k] = new Unc.user.history(board, write, reply);
		}
		
		var txt = ""+
		"<div id=unc-user-box>"+
			"<table cellspacing=0 cellpadding=0 id=box>"+
				"<tr>"+
					"<td id=header colspan=3></td>"+
				"</tr>"+
				"<tr>"+
					"<td id=left></td>"+
					"<td id=body>"+
						"<fieldset class=top>"+
							"<div id=info><strong>"+nick+"</strong>´ÔÀÇ È¸¿øÁ¤º¸</div><div id=close><img src=./img/common/board/i_close.gif class=unc-pnt onclick=\"Unc.user.hide()\"></div></fieldset>"+
						"<fieldset class=main>"+
							"<table width=100%>"+
								"<tr><td width=70 class=subject>¾ÆÀÌµð</td><td class=unc-verdana><strong>"+uid+"</strong></td></tr>"+
								"<tr><td class=subject>Æ÷ÀÎÆ®</td><td class=unc-verdana><strong>"+point+"</strong> Á¡</td></tr>"+
								"<tr><td class=subject>·¹º§</td><td>"+level+"</td></tr>"+
								"<tr><td class=subject>´ÙÀ½·¹º§¾÷</td><td class=unc-verdana>"+levelterm+" "+levelgage+"%</td></tr>"+
								"<tr><td class=subject>µî±Þ</td><td>"+grade+"</td></tr>"+
								(uname.strip().length > 0 ? "<tr><td class=subject>ÀÌ¸§</td><td>"+uname+"</td></tr>":"")+
								(photo.strip().length > 0 ? "<tr><td class=subject>»çÁø</td><td>"+photo+"</td></tr>":"")+
								(email.strip().length > 0 ? "<tr><td class=subject>ÀÌ¸ÞÀÏ</td><td class=unc-verdana>"+email+"</td></tr>":"")+
								(tel1.strip().length > 0 && tel2.strip().length > 0 && tel3.strip().length > 0 ? "<tr><td class=subject>ÀüÈ­</td><td class=unc-verdana>"+tel1+"-"+tel2+"-"+tel3+"</td></tr>":"")+
								(hp1.strip().length > 0 && hp2.strip().length > 0 && hp3.strip().length > 0 ? "<tr><td class=subject>ÇÚµåÆù</td><td class=unc-verdana>"+hp1+"-"+hp2+"-"+hp3+"</td></tr>":"")+
								(birthday.strip().length == 8 ? "<tr><td class=subject>»ýÀÏ</td><td>"+birthday.substring(0,4)+"."+birthday.substring(4,6)+"."+birthday.substring(6,8)+"</td></tr>":"")+
								(wedding.strip().length == 8 ? "<tr><td class=subject>°áÈ¥±â³äÀÏ</td><td>"+wedding.substring(0,4)+"."+wedding.substring(4,6)+"."+wedding.substring(6,8)+"</td></tr>":"")+
								(post.strip().length > 0 ? "<tr><td class=subject>¿ìÆí¹øÈ£</td><td class=unc-verdana>"+post+"</td></tr>":"")+
								(addr.strip().length > 0 ? "<tr><td class=subject>ÁÖ¼Ò</td><td class=unc-verdana>"+addr+"</td></tr>":"")+
								(talk.strip().length > 0 ? "<tr><td class=subject>Àâ´ã</td><td class=talk>"+talk+"</td></tr>":"")+
								"<tr><td class=subject>È°µ¿ÀÌ·Â</td><td><div style='height:100px;overflow:auto;border:1px solid #eeeeee;'><table class=history><tr bgcolor=#eeeeee><td>°Ô½ÃÆÇ</td><td>±ÛÀÛ¼º</td><td>±Û´äº¯</td><td>´ñ±Û¼ö</td></tr>";

			for (var i = 0; i < active_set.length; i++) {
				txt += "<tr><td>"+active_set[i].board+"</td><td>"+active_set[i].write+"</td><td>"+active_set[i].reply+"</td><td>"+active_set[i].memo+"</td></tr>";
			}
			txt += 				"</table></div></td></tr>"+
							"<tr><td class=subject>º£½ºÆ®ÀÌ·Â</td><td><div style='height:100px;overflow:auto;border:1px solid #eeeeee;'><table class=history><tr bgcolor=#eeeeee><td>°Ô½ÃÆÇ</td><td>¸¶°¨¼ö</td><td>Ã¤ÅÃ¼ö</td></tr>";
			for (var i = 0; i < best_set.length; i++) {
				txt += "<tr><td>"+best_set[i].board+"</td><td>"+best_set[i].write+"</td><td>"+best_set[i].reply+"</td></tr>";
			}
			txt += 				"</table></div></td></tr>"+
								(visitdt.strip().length > 0 ? "<tr><td class=subject>¹æ¹®ÀÏÀÚ</td><td class=unc-verdana>"+visitdt+"</td></tr>":"")+
							"</table>"+
						"</fieldset>"+
						"<div id=bottom><img src=./img/common/board/btn_msg.gif class=unc-pnt onclick=\"writeMessage('"+uid+"')\"> <img src=./img/common/board/btn_writen.gif class=unc-pnt onclick=\"viewUserArticle('"+uid+"')\"> <img src=./img/common/board/btn_close.gif class=unc-pnt onclick=\"Unc.user.hide()\"></div>"+
					"</td>"+
					"<td id=right></td>"+
				"</tr>"+
				"<tr>"+
					"<td id=footer colspan=3></td>"+
				"</tr>"+
			"</table>"+
		"</div>";
		
		$("unc-user-view").update(txt);
	},
	history: function(b,w,r,m) {
		this.board = b;
		this.write = w;
		this.reply = r;
		this.memo = m;	
	},
	hide: function() {
		if ($("unc-user-view")) {
			$("unc-user-view").update('');
			$("unc-user-view").style.visibility = 'hidden';	
		}
	}
}

