
/*
==============================================
	$Author: Kim Jong-gab <outmind@cafen.net>$
	$Date: 2006.07.12 11:13.20$
	$Source: /rainfile/images/home/home_common.js$
	$CharSet: UTF-8$
	$Comment: 홈관련 스크립터$
==============================================
*/


var hotlinkPos = null;
function changeHotLink(pos, className, bl) {
	var obj = $('hotlink_' + pos);
	obj.className = (bl) ? className + '_on' : className;
}

function swapTopmenu(idx, bl) {
	var img = $('topmenu_'+idx);
	if (bl) 
		img.src = base_img_url + 'section/iop/btn_menu_' + idx + '_over.gif';
	else
		img.src = base_img_url + 'section/iop/btn_menu_' + idx + '.gif';
}

function swapViewmode(html_name, imgobj) {
	var html_obj = document.getElementById(html_name);
	var firstChild = html_obj.firstChild;
	if ((firstChild == null || typeof firstChild.offsetHeight == 'undefined') && html_obj.childNodes.length > 1) 
		firstChild = html_obj.childNodes[1];
	var child_height = 200;
	if (firstChild == null)
		child_height = 10;
	else if (firstChild != null && typeof firstChild.offsetHeight != 'undefined') 
		child_height = parseInt(firstChild.offsetHeight);
	if (html_obj.style.overflow != 'hidden') {
		if (child_height > 100) {
			html_obj.style.overflow = 'hidden';
			html_obj.style.height = '100px';
		} else {
			html_obj.style.overflow = '';
			html_obj.style.height = 'auto';
		}
		imgobj.src = base_img_url + 'iop/ico_plus.gif';
	} else {
		html_obj.style.overflow = '';
		html_obj.style.height = 'auto';
		imgobj.src = base_img_url + 'iop/ico_minus.gif';
	}
}


var mainControl = {
	loadedData : {},
	shownData : {},
	getObject : function(idx) {
		if (this.loadedData[idx] == null) {
			this.loadedData[idx] = getElementsById('mainTop' + idx);
			this.shownData[idx] = 0;
		}
		return this.loadedData[idx];
	},
	setPrevNext : function(idx, dir) {
		var obj = this.getObject(idx);
		if (obj.length > 1) {
			Element.hide(obj[this.shownData[idx]]);
			this.shownData[idx] = this.shownData[idx] + ((dir)? 1 : -1);
			this.shownData[idx] = (this.shownData[idx] + obj.length) % obj.length;
			Element.show(obj[this.shownData[idx]]);
		}
	},
	prev : function(idx) {
		this.setPrevNext(idx, false);
	},
	next : function(idx) {
		this.setPrevNext(idx, true);
	}
}

function chkLogin(form){
	if (!isNULL(form.user_id.value)) { 
		rainPopup.alert ("아이디를 입력하십시오"); 
		form.user_id.focus(); 
		return false;
	} else if (!isNULL(form.user_pw.value)) { 
		rainPopup.alert ("비밀번호를 입력하십시오"); 
		form.user_pw.focus(); 
		return false;
	} else {
		form.next_url.value = parent.document.location.toString();
		return true;
	}
}
function smash (str) {
        newstr=str.replace(/=/gi, "%3D");
        newstr=newstr.replace(/\&/gi, "%26");
        newstr=newstr.replace(/\?/gi, "%3F");
        return newstr;
}


function selgoBlog(obj) {
	if (obj[obj.selectedIndex].value !='') {
		top.document.location.href = obj[obj.selectedIndex].value;
	}
}

function setKeyWord(val) {
	document.search_frm.sk.value = val;
	document.search_frm.submit();
}
	


function searchFocus(searchObj) {
	if (searchObj.value == '검색어를 입력하세요~') 
		searchObj.value = '';
}


function goSearch(form) {
	var searchObj = $('search_keyword');
	if (searchObj.value == '' || searchObj.value == '검색어를 입력하세요~') {
		rainPopup.alert('검색어를 입력하여 주십시오');
		searchObj.focus();
		return false;
	} else {
		goDetailSearch(searchObj.value);
		return false;
	}
}


function goDetailSearch(sk) {
	var keyword = (sk != null) ? '?sk=' + encodeURIComponent(sk):'';
	rainCheck.openPop('/SEARCH/' + keyword, 'blankscroll','M');
}

function goDetailSearchCate(sk) {
	var keyword = (sk != null) ? '?cate=' + encodeURIComponent(sk):'';
	rainCheck.openPop('/SEARCH/' + keyword, 'blankscroll','M');
}


function showTopMenu(idx) {
	Element.toggle(idx);
}

function playflash(swffile,width,height,bgcolor,quality,name){
	swffile = base_img_url + swffile;
	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="'+width+'" height="'+height+'" id="'+name+'">');  //플래쉬플레이어 버전이 이전버전일경우 버전 8을 변경
	document.write('<param name="movie" value="'+swffile+'" />');
	document.write('<param name="quality" value="'+quality+'" />');
	document.write('<param name="wmode" value="transparent" />');
	document.write('<param name="allowScriptAccess" value="always" />');
	document.write('<param name="bgcolor" value="'+bgcolor+'" />');
	document.write('<embed src="'+swffile+'" allowScriptAccess="always" quality="'+quality+'" wmode="transparent" bgcolor="'+bgcolor+'" width="'+width+'" height="'+height+'" name="'+name+'" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
	document.write('</object>')
}


var itemControl = {
	topFrm : null,
	lastCateIdx : null,
	purchaseItem : [],
	cateObj :  {},
/**
 * 파일 아이콘 정보
 * @type object
 */
	attach_icon : {
		avi:'avi.gif', mov:'mov.gif', flv:'avi.gif', wma:'avi.gif', asf:'avi.gif', wav:'avi.gif', mp3:'mp3.gif',
		com:'com.gif', exe:'exe.gif', dll:'com.gif', 
		htm:'htm.gif', html:'htm.gif', docx:'doc.gif', doc:'doc.gif', hwp:'hwp.gif', 
		bmp:'bmp.gif', gif:'gif.gif',jpg:'jpg.gif', png:'jpg.gif', jpeg:'jpg.gif', psd:'psd.gif', tif:'tif.gif', 
		pdf:'pdf.gif', pptx:'ppt.gif', ppt:'ppt.gif', txt:'txt.gif', xls:'xls.gif',xlsx:'xls.gif',
		zip:'zip.gif', mcast : 'mcast.gif', etc:'etc.gif' 
	},
/**
 * 첨부 파일 아이콘 가져오기
 * @param {string} ext  확장자
 * @param {string} iconsize  아이콘 크기
 * @return {string} 아이콘 URL
 */
	getAttachIcon : function(ext, iconsize) { 
		ext = ext.toLowerCase();
		var icon =  (this.attach_icon[ext] == null)?this.attach_icon.etc:this.attach_icon[ext]; 
		return rainGlobalConf.imageURL + 'ext/' + ((iconsize == null)?'s':'')+icon;
	},
	del : function(obj) {
		this.sendObj = obj;
		parent.rainPopup.confirm(
			'삭제하시겠습니까?', 
			this.delEnd.bind(this));
	},
	delEnd : function(bl) {
		if (bl) {
			switch(this.sendObj.areaid) {
				case 'track':
					this.submitAjax('/GLOBAL/xml_deletetrack.html',this.sendObj);
					break;
				case 'scrap':
					this.submitAjax('/GLOBAL/xml_deletescrap.html',this.sendObj);
					break;
				case 'tail':
					this.submitAjax('/GLOBAL/xml_deletetail.html',this.sendObj);
					break;
				case 'board':
					this.submitAjax('/GLOBAL/xml_deleteboard.html',this.sendObj);
					break;
				default :
					rainPopup.alert('삭제 영역 오류');
					break;
			}
		}
	},
	isGood : function(obj) {
		this.sendObj = obj;
		parent.rainPopup.confirm(
			'추천하시겠습니까?', 
			this.isGoodEnd.bind(this));
	},
	isGoodEnd : function(bl) {
		if (bl) {
			switch(this.sendObj.areaid) {
				case 'board':
					this.submitAjax('/GLOBAL/xml_isgoodboard.html',this.sendObj);
					break;
				default :
					rainPopup.alert('추천 영역 오류');
					break;
			}
		}
	},
	delPass : function(obj) {
		this.sendObj = obj;
		parent.rainPopup.prompt(
			'기존에 입력하신 암호를 입력하십시오', 
			this.delPassEnd.bind(this)
		);
	},
	delPassEnd : function(pass) {
		if (pass != '') {
			this.sendObj.user_pw = pass;
			this.delEnd(true);
		}
	},
	tailReply : function(obj) {
		this.sendObj = obj;
		if (parent.rainCheck.checkBlog()) {
			var tabObjTail = $('tailFrm_'+this.sendObj.tailuid);
			if (tabObjTail != null) {
				if (tabObjTail.style.display == 'block') {
					tabObjTail.style.display = 'none';
				} else {
					if (typeof tabObjTail.isParsed == 'undefined' || !tabObjTail.isParsed) {
						var html = ''
						+ '<form name=f action=tailok.html method=post target=submit_frm onsubmit="return itemControl.checkTailForm(this)" style="margin-top:0px">'
						+ '<input type=hidden name=tailuid value="'+obj.tailuid+'">'
						+ '<input type=hidden name=muid value="'+obj.muid+'">'
						+ '<input type=hidden name=board_id value="'+obj.board_id+'">'
						+ '<input type=hidden name=mode value="REPLY">'
						+ '<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr>'
						+ '<td><textarea name="contents" id="contents" cols="45" rows="3" style="width:100%; height:52px; margin:8px 0 12px 0;" class=input></textarea></td>'
						+ '<td width="60" align="right" valign="top"><input type=image src="'+base_img_url+'section/commons/btn_reply_write.gif" border="0" style="margin:8px 0 12px 0;"></td>'
						+ '</tr>'
						+ ''
						+ '</table></form>';
						tabObjTail.innerHTML = html;
						tabObjTail.isParsed = true;
					}
					tabObjTail.style.display = 'block';
				}
			}
			try {
				parent.rainReSize('post'+this.sendObj.muid+'_frame');
			} catch(ex) {}
		}
	},
	checkTailForm : function(form) {
		if (!submitCheck()) {
			return false;
		} else {
			if (!rainCheck.chkLogin()) {
				parent.rainCheck.jumpLogin('댓글을 입력하시려면 로그인을 필요로 합니다.<br>지금 로그인 하시겠습니까?');
				return false;
			} else if (form.contents.value == '') {
				parent.rainPopup.alert('내용을 입력하여 주십시오');
				form.contents.focus();
				return false;
			}else {
				submitLock();
				return true;
			}
		}
	},
	searchProject : function(idx) {
		if (this.lastCateIdx == idx) {
			rainPopup.close();
			this.lastCateIdx = null;
		} else {
			var linkObj = $(idx + '_txt');
			this.lastCateIdx = idx;
			if (this.cateObj['project'] == null) {
				rainPopup.check();
				this.cateObj['project'] = new searchPopup(rainPopup.style_class, {title : 'Search Project', mode : 'project'});
			}
			rainPopup.add(this.cateObj['project'],{is_scrollable:true});
		}
	},
	setProject : function(puid, pname) {
		var linkObj = $(this.lastCateIdx + '_txt');
		if (linkObj != null)
			linkObj.innerHTML = pname;
		var hiddenObj = $(this.lastCateIdx);
		if (hiddenObj != null)
			hiddenObj.value = puid;
		this.lastCateIdx = null;
		rainPopup.close();
	},
	searchActivity : function(idx) {
		if (this.lastCateIdx == idx) {
			rainPopup.close();
			this.lastCateIdx = null;
		} else {
			var linkObj = $(idx + '_img');
			this.lastCateIdx = idx;
			if (this.cateObj['activitycompare'] == null) {
				rainPopup.check();
				this.cateObj['activitycompare'] = new searchPopup(rainPopup.style_class, {title : 'Search Activity', mode : 'activitylist'});
			}
			rainPopup.add(this.cateObj['activitycompare'],{is_scrollable:true});
		}
	},
	setCompare : function(muid, title) {
		$(this.lastCateIdx + '_div').innerHTML = '<div style="padding:40 0 40 0px;text-align:center"><b>'+title+'</b><hr>잠시만 기다려 주십시오. 자료를 수집 중입니다</div>';
		Element.show($(this.lastCateIdx + '_div'));
		document.location.href = "#" + this.lastCateIdx + '_pos';
		$(this.lastCateIdx + '_frm').src = 'frm_view.html?muid=' + muid;
		this.lastCateIdx = null;
		rainPopup.close();
	},
	showCcrap : function(obj) {
		this.sendObj = obj;
	},
	toggleSearch : function() {
		var btnObj = $('detailSearchBtn');
		var layerObj = $('detailSearchLayer');
		if (layerObj.style.display == 'none') {
			btnObj.src = base_img_url + 'section/commons/bttn_search_close.gif';
			btnObj.title = '상세검색닫기';
			layerObj.style.display = '';
		} else {
			btnObj.src = base_img_url + 'section/commons/bttn_search_open.gif';
			btnObj.title = '상세검색열기';
			layerObj.style.display = 'none';
		}
	},
	checkAll : function(bl, obj) {
		if (obj.length > 0) {
			for (var i = 0; i <obj.length; i++)
				obj[i].checked = bl;
		} else
			obj.checked = bl;
	},
	getDate : function(str) {
		var dateinfo = str.split('.0').join('.').split('.');
		if (dateinfo.length == 3) {
			var year = parseInt(dateinfo[0]);
			var month = parseInt(dateinfo[1]) -1;
			var day = parseInt(dateinfo[2]);
			return new Date(year,month,day);
		} else
			return false;				
	},
	isDate : function(str) {
		var dateinfo = str.split('.0').join('.').split('.');
		if (dateinfo.length == 3) {
			var year = parseInt(dateinfo[0]);
			var month = parseInt(dateinfo[1]) -1;
			var day = parseInt(dateinfo[2]);
			var tempDate = new Date(year,month,day);
			if (
				year == tempDate.getFullYear() && 
				month == tempDate.getMonth() && 
				day == tempDate.getDate()
			)
				return true;
			else
				return false
		} else
			return false;	
	},
	isValidDateRange : function(from_date, to_date) {
		if (from_date != '' && !this.isDate(from_date)) 
			return false;
		else if (to_date != '' && !this.isDate(to_date)) 
			return false;
		else {
			if (from_date != '' && to_date != '') {
				if (this.getDate(from_date) <=  this.getDate(to_date))
					return true;
				else
					return false;
			} else
				return true;
		}
	},
	getChecked : function(obj) {
		var checkedObj = [];
		if (obj.length > 0) {
			for (var i = 0; i <obj.length; i++)
				if (obj[i].checked)
					checkedObj.push(obj[i].value);
		} else if (obj.checked)
				checkedObj.push(obj.value);
		return checkedObj.join(' ');
	},
	resetForm : function(obj) {
		for(var i = 0; i < obj.elements.length; i++) {
			var tmpObj = obj.elements[i];
			switch(tmpObj.type.toLowerCase()) {
				case 'password':
				case 'hidden':
				case 'text' :
					tmpObj.value = '';
					break;
				case 'radio' :
				case 'checkbox' :
					tmpObj.checked = false;
					break;
				case 'select-one' :
					tmpObj.selectedIndex = 0;
					break;
			}
		}
		var tmpDivs = ['tmp_cate_s_txt','tmp_cate_i_txt','tmp_cate_r_txt'];
		tmpDivs.each(function(val) {
			var obj = $(val);
			if (obj != null) 
				obj.innerHTML = '';
		});
		
	},
	formSubmit : function(idx) {
		$(idx).submit();
	},
	changeOrderBy : function(obj, ob) {
		var formObj = $(obj);
		if (formObj.ob != null)
			formObj.ob.value = ob;
		formObj.submit();
	},
	showTopList : function(idx, frmObj) {
		var imgObj = $('topList_' + idx + '_btn');
		var divObj = $('topList_' + idx + '_div');
		var frmObj = $(frmObj);
		if (divObj.style.display == 'none') {
			if (this.topLoaded == null) {
				this.topFrm = frmObj;
				this.topListSubmit();
				this.topLoaded = true;
			}
			divObj.style.display = '';
			imgObj.src = base_img_url + 'section/commons/btn_list_close.gif';
			imgObj.title = '목록닫기';
		} else {
			divObj.style.display = 'none';
			imgObj.src = base_img_url + 'section/commons/btn_list_open.gif';
			imgObj.title = '목록열기';
		}
	},
	jumpPageTopList : function(cline) {
		this.topFrm.cline.value = cline;
		this.topListSubmit();
	},
	jumpPage : function(cline) {
		if (this.topFrm == null)
			this.topFrm = $('searchTop');
		this.topFrm.cline.value = cline;
		this.topFrm.submit();
	},
	viewDetail : function(uid) {
		if (this.topFrm == null)
			this.topFrm = $('searchTop');
		this.topFrm.action = 'view.html';	
		this.topFrm.muid.value = uid;
		this.topFrm.submit();
	},
	topListSubmit : function() {
		this.topFrm.target = 'submit_frm';
		this.topFrm.action = 'frm_list.html';
		this.topFrm.submit();
		this.topFrm.target = '';
		this.topFrm.action = 'list.html';
	},
	getList : function() {
		var form = $('searchTop');
		if (form != null) {
			form.action = 'list.html';
			form.submit();
		} else
			document.location.href = 'list.html';
	},
	getCalendar : function(obj) {
		if (this.class_calendar == null) {
			rainPopup.check();
			this.class_calendar = new rain.Calendar(rainPopup.style_class);
		}
		this.class_calendar.setObj($(obj));
		rainPopup.add(this.class_calendar, {is_transparent : true,toolbar : false,shadow : false,sticker :{obj : $(obj), pos : 'BL', margin : [0,2]}});
	},
	getCategory : function(idx, areaid, bl) {
		if (this.lastCateIdx == idx) {
			rainPopup.close();
			this.lastCateIdx = null;
		} else {
			var linkObj = $(idx + '_txt');
			this.lastCateIdx = idx;
			var subidx = (bl) ? 'fold' : 'item';
			var hiddenObj = $(idx);
			var tmpCate = [];
			if (hiddenObj != null && hiddenObj.value != '') {
				var cateVal = hiddenObj.value;
				for(var i = 0; i < cateVal.length ; i++)
					tmpCate.push(cateVal.substring(0,i+1));
			}
			if (this.cateObj[areaid] == null) 
				this.cateObj[areaid] = {}
			if (this.cateObj[areaid][subidx] == null) {
				rainPopup.check();
				var class_cate = new rain.Category(
					{
						postData :{mode : areaid}, 
						folderSelect : bl, 
						width : 200,
						initValue : tmpCate,
						onchange : this.setCategory.bind(this)
					}, rainPopup.style_class);
				this.cateObj[areaid][subidx] = class_cate;
			} else 
				this.cateObj[areaid][subidx].setInit(tmpCate);
			rainPopup.add(this.cateObj[areaid][subidx],{is_transparent : true,toolbar : false,shadow : false,sticker:{obj:linkObj,pos:'BL', margin : [0,0]}});
		}
	},
	setCategory : function(ids, texts, msg) {
		if (msg != null) 
			rainPopup.alert(msg);
		else if (ids != null && texts != null){
			var textObj = $(this.lastCateIdx + '_txt');
			if (textObj != null)
				textObj.innerHTML = texts[0];
			var hiddenObj = $(this.lastCateIdx);
			if (hiddenObj != null)
				hiddenObj.value = ids[0];
		} else {
			var textObj = $(this.lastCateIdx + '_txt');
			if (textObj != null)
				textObj.innerHTML = '';
			var hiddenObj = $(this.lastCateIdx);
			if (hiddenObj != null)
				hiddenObj.value = '';
		}
		this.lastCateIdx = null;
		rainPopup.close();
	},
	scrapFrame : function(board_id, muid) {
		if (parent.rainCheck.checkBlog()) {
			this.lastScrapObj = {board_id : board_id, muid : muid}
			parent.itemControl.scrap(this.scrapEnd.bind(this));
		}
	},
	scrap : function(callback) {
		if (this.class_scrap == null) {
			rainPopup.check();
			this.class_scrap = new itemScrap('스크랩하실 위치를 선택하여 주십시오', callback, rainPopup.style_class, false);
		} else 
			this.class_scrap.call_back = callback;
		rainPopup.add(this.class_scrap, {is_scrollable:true});
	},
	scrapEnd : function(blog_id, cate_id, tail_text, comment_txt) {
		parent.rainPopup.close();
		var postData = Object.extend(this.lastScrapObj, {tg_blogid : blog_id, cate_id : cate_id, tail : tail_text, greet : comment_txt });
		this.submitAjax('/GLOBAL/xml_scrapok.html', postData);
	},
	checkPoint : function(board_id, muid, mode, point) {
		if (rainCheck.checkLogin()) {
			if (muid == 0 || muid == '0' || muid == '') 
				rainPopup.alert('미리보기에서 지원되지 않습니다.');
			else
				this.submitAjax('/GLOBAL/xml_checkpoint.html' , {board_id : board_id, muid : muid, mode : mode, point : point});
		}
	},
	getUserInfo : function(user_id) {
		this.submitAjax('/GLOBAL/xml_userinfo.html' , {user_id : user_id});
	},
	showHTML : function(html, width) {
		if (this.html_class == null) {
			rainPopup.check();
			this.html_class = new rain.showHTML(rainPopup.style_class, width, html);
		} else 
			this.html_class.setHTML(html);
		rainPopup.add(this.html_class, {is_scrollable:true});
	},
	payPoint : function(options) {
		if (this.pay_class == null) {
			rainPopup.check();
			this.pay_class = new itemPoint(options, this.usePoint.bind(this), rainPopup.style_class);
		} else
			this.pay_class.setOptions(options);
		rainPopup.add(this.pay_class, {is_scrollable:true});
	},
	usePoint : function(sendData) {
		this.submitAjax('/GLOBAL/xml_usepoint.html' , sendData);
	},
	swapPostTab : function(board_id, post_no, mode) {
		var tabObjTail = $('post'+post_no+'_tail');
		var tabObjScrap = $('post'+post_no+'_scrap');
		var tabObjTrack = $('post'+post_no+'_track');
		var tabObjFrm = $('post'+post_no+'_frame');
		rainPopup.close();
		if (tabObjFrm != null)
			tabObjFrm.height = 1;
		switch(mode) {
			case 'tail' :
				if (tabObjFrm != null)
					tabObjFrm.src = '/GLOBAL/tail.html?board_id='+board_id+'&muid=' + post_no;
				if (tabObjTail != null)
					tabObjTail.className = 'on';
				if (tabObjScrap != null)
					tabObjScrap.className = 'off';
				if (tabObjTrack != null)
					tabObjTrack.className = 'off';
				break;
			case 'scrap' :
				if (tabObjFrm != null)
					tabObjFrm.src = '/GLOBAL/scrap.html?board_id='+board_id+'&muid=' + post_no;
				if (tabObjTail != null)
					tabObjTail.className = 'off';
				if (tabObjScrap != null)
					tabObjScrap.className = 'on';
				if (tabObjTrack != null)
					tabObjTrack.className = 'off';
				break;
			case 'track' :
				if (tabObjFrm != null)
					tabObjFrm.src = '/GLOBAL/track.html?board_id='+board_id+'&muid=' + post_no;
				if (tabObjTail != null)
					tabObjTail.className = 'off';
				if (tabObjScrap != null)
					tabObjScrap.className = 'off';
				if (tabObjTrack != null)
					tabObjTrack.className = 'on';
				break;
		}
	},
	togglePostTab : function(board_id, post_no, mode) {
		var tabObjTail = $('post'+post_no+'_tail');
		var tabObjFrm = $('post'+post_no+'_frame');
		if (tabObjFrm.style.display == 'none') {
			if (tabObjFrm != null) {
				tabObjFrm.style.display = '';
				tabObjFrm.src = '/GLOBAL/tail.html?board_id='+board_id+'&muid=' + post_no;
				window.setTimeout("rainReSize('post"+post_no+"_frame')",100);				
			}
			if (tabObjTail != null)
				tabObjTail.className = 'on';
		} else {
			if (tabObjFrm != null) {
				tabObjFrm.src = '/GLOBAL/tail.html?board_id='+board_id+'&muid=' + post_no;
				tabObjFrm.style.display = 'none';
			}
			if (tabObjTail != null)
				tabObjTail.className = 'off';
		}
		
	},
	submitAjax : function(theUrl, datas) {
		rainPopup.close();
		new rain.Ajax(datas, this.setAjax.bind(this), theUrl, 'post');
	},
	setFileboxDownload : function(board_id, muid) {
		var purchaseObj = $('purchase_' + muid);
		purchaseObj.style.display = 'none';
		this.purchaseItem.push(muid);
	},
	isPreview : function(muid) {
		if (muid == '' || muid == 0) {
			rainPopup.alert('미리보기에서는 지원되지 않습니다.');
			return true;
		} else 
			return false;
	},
	download : function(board_id, muid, fileuid, isBuyed) {
		if (!this.isPreview(muid) && parent.rainCheck.checkLogin()) {
			if (!isBuyed) {
				this.purchaseItem.each(function(idx) {
					if (idx == muid)
						isBuyed = true;
				});
			}
			if (isBuyed)
				this.startDownload(board_id, muid, fileuid);	
			else if (confirm('파일을 다운로드 받으시려면 구매를 하셔야 합니다.\r\n지금 구매하시겠습니까?'))
				this.checkPoint(board_id,muid,'filebox');
//				rainPopup.alert('파일을 다운로드 받으시려면 구매를 하셔야 합니다.');
		}
	},
	downloadByName : function(board_id, muid, fileName, isBuyed) {
		if (!this.isPreview(muid) && parent.rainCheck.checkLogin()) {
			if (!isBuyed) {
				this.purchaseItem.each(function(idx) {
					if (idx == muid)
						isBuyed = true;
				});
			}
			if (isBuyed)
				this.startDownloadByName(board_id, muid, fileName);	
			else if (confirm('파일을 다운로드 받으시려면 구매를 하셔야 합니다.\r\n지금 구매하시겠습니까?'))
				this.checkPoint(board_id,muid,'filebox');
//				rainPopup.alert('파일을 다운로드 받으시려면 구매를 하셔야 합니다.');
		}
	},
	checkPointValue : function(val) {
		var intVal = parseInt(val);
		if (intVal == null) {
			rainPopup.alert('가격을 입력하여 주십시오.');
			return false;
		} else if (intVal < 100) {
			rainPopup.alert('최소 가격은 100 Point 입니다.');
			return false;
		} else if (intVal % 100 != 0) {
			rainPopup.alert('가격은 100 Point 단위로 입력하여 주십시오.');
			return false;
		} else {
			return true;
		}
	},
	startDownload : function(board_id, muid, fileuid) {
		$('submit_frm').src = '/GLOBAL/filebox_download.html?board_id=' + board_id + '&muid=' + muid + '&fileuid=' + fileuid;
	},
	startDownloadByName : function(board_id, muid, fileName) {
		$('submit_frm').src = '/GLOBAL/filebox_download.html?board_id=' + board_id + '&muid=' + muid + '&filename=' + fileName;
	},
	setAjax : function(channel) {
		if (channel.checkMsg()) {
			rainPopup.alert(channel.getMsg().contents);
		} else {
			switch(channel.getNode('restype')) {
				case 'result' :
					var msg = channel.getNode('msg');
					if (msg != '') 
						rainPopup.alert(msg);
					var linkurl = channel.getNode('link');
					if (linkurl != '') {
						switch(channel.getNode('linktype')) {
							case 'top' :
								top.document.location.href = linkurl;
								break;
							default :
								document.location.href = linkurl;
								break;
						}
					}
					break;
				case 'point' :
					var pointOptions = {
							top : channel.getNode('title'),
							title : channel.getNode('pointtitle'),
							board_id : channel.getNode('boardid'),
							mode : channel.getNode('mode'),
							muid : channel.getNode('muid'),
							question : channel.getNode('pointquestion'),
							mypoint : channel.getNode('mypoint'),
							usepoint : channel.getNode('usepoint')
					};
					this.payPoint(pointOptions);
					break;
				case 'html' :
					var html = channel.getNode('htmldoc');
					var htmlwidth = channel.getNode('htmlwidth');
					this.showHTML(html, htmlwidth);
					break;
				case 'usepoint' : 
					switch(channel.getNode('mode')) {
						case 'invest' :
							var board_id = channel.getNode('boardid');
							var muid = channel.getNode('muid');
							var point = channel.getNode('point');
							investControl.setResult(board_id,muid, point);					
							break;						
						case 'filebox' :
							var board_id = channel.getNode('boardid');
							var muid = channel.getNode('muid');
							this.setFileboxDownload(board_id,muid);
							alert('구매가 완료되었습니다. \r\n구매 하신 파일은 [마이페이지  -> 내가 구매한 컨텐츠]에서도 다운로드 받으실 수 있습니다.');
							break;
						default :
							alert('^^');
							break;
					}			
					break;
			}
		}
	}
}

function searchPopup(style_class, options) {
	this.style_class = style_class;
	this.options = Object.extend({title : '', mode : 'project'}, options);
	this.init();

}

searchPopup.prototype = {
	popupMagin : {top:0, right:0, bottom:0, left:0},
	init : function() {
		this.search_keyword = '';
		this.obj = rain.nodeUtil.getDiv({},{width:'350px', height:'auto', padding: '1px 1px 1px 1px', textalign : 'center', border:'5px solid #2c3a57', overflow : 'hidden', backgroundColor : '#FFFFFF'});
		var tmpObj = this.obj.appendChild(rain.nodeUtil.getDiv({},{width : '100%', height : '32px', textAlign:'left', margin:'0px', backgroundImage : 'url(' + base_img_url+ 'iop/layer_title.gif)', backgroundRepeat : 'no-repeat',backgroundColor : '#243a66', overflow : 'hidden',textAlign:'left'}));
		this.titletop = tmpObj.appendChild(rain.nodeUtil.getDiv({innerHTML: this.options.title},{color : '#FFFFFF', fontSize : '12px', fontWeight : 'bolder', margin:'8 0 0 20px',textAlign:'left'}));
		var subObj = this.obj.appendChild(rain.nodeUtil.getDiv({},{padding:'5 10 5 10px'}));
		var tmpObj = subObj.appendChild(rain.nodeUtil.getDiv({},{width : '100%', height : '30px', textAlign:'center', padding:'5px'}));
		this.input_box = tmpObj.appendChild(rain.nodeUtil.getInput({
			value : ''
		}, Object.extend(this.style_class.getStyle('input'),{width:'210px',height:'20px'})));
		Event.observe(this.input_box, 'keypress', this.enterKey.bind(this));
		tmpObj.appendChild(
			rain.nodeUtil.getImgButton(
				{onclick:this.search.bind(this)},
				base_img_url + 'section/commons/top_bttn_search.gif',
				25,20
			)
		);
		this.listObj = subObj.appendChild(rain.nodeUtil.getDiv({},{width : '100%', height : 'auto', textAlign:'center', padding:'5px'}));
		var tmpObj = subObj.appendChild(rain.nodeUtil.getDiv({},{width : '100%', height : '30px', textAlign:'center', padding:'0px'}));
		this.pageInfo = tmpObj.appendChild(rain.nodeUtil.getDiv({},{width : '210px', height : 'auto', textAlign:'left', padding:'5px',cssFloat:'left',styleFloat:'left', overflow : 'hidden'}));
		this.pageMove = tmpObj.appendChild(rain.nodeUtil.getDiv({},{width : '100px', height : 'auto', textAlign:'right', padding:'5px',cssFloat:'left',styleFloat:'left', overflow : 'hidden'}));
		this.getAjax(0);
	},
/**
 * Enter 키 입력 시 
 * @param {object} event Event
 */
	enterKey : function(event) {
		if (event.keyCode == 13) 
			this.search();
	},
	search : function() {
		this.search_keyword = this.input_box.value;
		this.getAjax(0);
	},
	getAjax : function(cline) {
		new rain.Ajax({mode : this.options.mode,cline : cline, sk : this.search_keyword}, this.setAjax.bind(this), '/BRIDGE/xml_category.html', 'post');
	},
	setAjax : function(channel) {
		if (channel.checkMsg()) {
			rainPopup.alert(channel.getMsg().contents);
		} else {
			this.channel = channel;
			this.drawList(0);
		}		
	},
	mouseOver : function(idx) {
		if (this.listItems[idx] != null)
			Element.setStyle(this.listItems[idx],{backgroundColor : '#f0f0f0'});
	},
	mouseOut : function(idx) {
		if (this.listItems[idx] != null)
			Element.setStyle(this.listItems[idx],{backgroundColor : 'transparent'});
	},
	drawList : function(cline) {
		var channel = this.channel;

		this.listObj.innerHTML = (channel.getNode('htmltext') != '') ? channel.getNode('htmltext') : '';
		
		if (channel.getNode('total') != '') {
			var total = parseInt(channel.getNode('total'));
			var pages = parseInt(channel.getNode('pages'));
			var perpage = parseInt(channel.getNode('perpage'));
			var currpage = parseInt(channel.getNode('currpage'));
			this.pageInfo.innerHTML = '<b>' + currpage + '</b>/<b>' + pages + '</b> Pages total <b>' + total + '</b>';
			this.pageMove.innerHTML = '';
			if (currpage > 1) 
				this.pageMove.appendChild(
					rain.nodeUtil.getImgButton(
						{onclick : this.getAjax.bind(this,(currpage - 2)*perpage  )},
						base_img_url + 'b_pre.gif',13,11
					)
				);
			else
				this.pageMove.appendChild(
					rain.nodeUtil.getImgButton(
						{},
						base_img_url + 'b_prex.gif',13,11
					)
				);
			if (currpage < pages) 
				this.pageMove.appendChild(
					rain.nodeUtil.getImgButton(
						{onclick : this.getAjax.bind(this,(currpage)*perpage)},
						base_img_url + 'b_next.gif',13,11
					)
				);
			else
				this.pageMove.appendChild(
					rain.nodeUtil.getImgButton(
						{},
						base_img_url + 'b_nextx.gif',13,11
					)
				);
				
		} else {
			this.pageInfo.innerHTML = '';
			this.pageMove.innerHTML = '';
		}
		if (this.popup_class != null) {
			this.popup_class.is_resized = false;
			this.popup_class.reSize();
		}
	},
	sendValue : function(idx, name) {
		this.onchange(idx, name);
	},
	close : function() {
		this.popup_class.close();
	}
	
}




function itemPoint(options, onchange, style_class) {
	this.style_class = style_class;
	this.onchange = onchange;
	this.init();
	this.setOptions(options);
}

itemPoint.prototype = {
	popupMagin : {top:0, right:0, bottom:0, left:0},
	init : function() {
		this.obj = rain.nodeUtil.getDiv({},{width:'350px', height:'auto', padding: '1px 1px 1px 1px', textalign : 'center', border:'5px solid #2c3a57', overflow : 'hidden'});
		var tmpObj = this.obj.appendChild(rain.nodeUtil.getDiv({},{width : '100%', height : '32px', textAlign:'left', margin:'0px', backgroundImage : 'url(' + base_img_url+ 'iop/layer_title.gif)', backgroundRepeat : 'no-repeat',backgroundColor : '#243a66', overflow : 'hidden',textAlign:'left'}));
		this.titletop = tmpObj.appendChild(rain.nodeUtil.getDiv({innerHTML:'투자하기'},{color : '#FFFFFF', fontSize : '12px', fontWeight : 'bolder', margin:'8 0 0 20px',textAlign:'left'}));
		var subObj = this.obj.appendChild(rain.nodeUtil.getDiv({},{padding:'5 10 5 10px'}));
		this.titlemsg = subObj.appendChild(rain.nodeUtil.getDiv({},{width : '100%', height : 'auto', textAlign:'left', margin:'15 0 15 0px', lineHeight:'150%'}));
		var tmpObj = subObj.appendChild(rain.nodeUtil.getDiv({},{width : '100%', height : 'auto', textAlign:'left'}));
		tmpObj.appendChild(rain.nodeUtil.getDiv({innerHTML : ''},{width : '100%', height : '1px', textAlign:'left', fontSize : '2px', borderBottom : '2px solid #2c3a57'}));
		this.mypointObj = rain.nodeUtil.getDiv({innerHTML : ''},{width : '100px', height : '17px', textAlign:'right'});
		tmpObj.appendChild(
			rain.nodeUtil.getIndex('&nbsp; &nbsp; 나의 마일리지',this.mypointObj,180,this.style_class,'left',29)
		);
		tmpObj.appendChild(rain.nodeUtil.getDiv({innerHTML : ''},{width : '100%', height : '1px', textAlign:'left', fontSize : '1px', borderBottom : '1px solid #dedede'}));
		this.usepointObj = rain.nodeUtil.getDiv({innerHTML : ''},{width : '100px', height : '17px', textAlign:'right'});
		tmpObj.appendChild(
			rain.nodeUtil.getIndex('&nbsp; &nbsp; 결재할 마일리지',this.usepointObj,180,this.style_class,'left',29)
		);
		tmpObj.appendChild(rain.nodeUtil.getDiv({innerHTML : ''},{width : '100%', height : '1px', textAlign:'left', fontSize : '1px', borderBottom : '2px solid #2c3a57'}));
		this.remindpointObj = rain.nodeUtil.getDiv({innerHTML : ''},{width : '100px', height : '17px', textAlign:'right'});
		var tmpMyPoint = tmpObj.appendChild(
			rain.nodeUtil.getIndex('&nbsp; &nbsp; 결재후 나의 마일리지',this.remindpointObj,180,this.style_class,'left', 29)
		);
		Element.setStyle(tmpMyPoint, {backgroundColor : '#f6f6f6'});
		
		tmpObj.appendChild(rain.nodeUtil.getDiv({innerHTML : ''},{width : '100%', height : '1px', textAlign:'left', fontSize : '2px', borderBottom : '2px solid #2c3a57'}));
		this.questionmsg = subObj.appendChild(rain.nodeUtil.getDiv({},{width : '100%', height : 'auto', textAlign:'center', padding:'15px'}));
		var tmpObj = subObj.appendChild(rain.nodeUtil.getDiv({},{width : '100%', height : 'auto', textAlign:'center', padding:'5px'}));
		tmpObj.appendChild(rain.nodeUtil.getButton({innerHTML:'확인', onclick:this.sendValue.bind(this)},this.style_class.getStyle('designbutton', 20)));
		tmpObj.appendChild(rain.nodeUtil.getButton({innerHTML:'닫기', onclick:this.close.bind(this)},this.style_class.getStyle('designbutton', 20)));
	},
	sendValue : function() {
		this.sendValue = {board_id : this.options.board_id, mode : this.options.mode, muid : this.options.muid, usepoint : this.options.usepoint};
		this.onchange(this.sendValue);
	},
	close : function() {
		this.popup_class.close();
	},
	setOptions : function(options) {
		this.options = options;
		this.titletop.innerHTML = this.options.top;
		this.titlemsg.innerHTML = this.options.title;
		this.mypointObj.innerHTML = rain.nodeUtil.int2Money(this.options.mypoint) + ' point';
		this.usepointObj.innerHTML = rain.nodeUtil.int2Money(this.options.usepoint) + ' point';
		this.remindpointObj.innerHTML = rain.nodeUtil.int2Money((parseInt(this.options.mypoint) - parseInt(this.options.usepoint)).toString()) + ' point';
		this.questionmsg.innerHTML = this.options.question;
		
	}
}


var investControl = {
	minV : 100,
	maxV : 1000,
	stepV : 100,
	getObjectValue : function(seqn) {
		return $('money_'+seqn+'_text');
	},
	getObjectView : function(seqn) {
		return $('money_'+seqn+'_view');
	},
	isValid : function(selVal) {
		if (selVal % this.stepV != 0) {
			rainPopup.alert('투자 금액은 '+this.stepV+' 단위로만 입력 하실 수 있습니다.');
			return false;
		} else if (selVal >= this.minV && selVal <= this.maxV) {
			return true;
		} else {
			rainPopup.alert('투자 금액은 <b>'+this.minV+'~'+this.maxV+'</b>Point 사이에서만<br> 입력하실 수 있습니다.');
			return false;
		}
	},
	upDown : function(seqn, bl) {
		var valObj = this.getObjectValue(seqn);
		if (valObj != null) {
			if (rainCheck.chkInt(valObj)) {
				var selVal = parseInt(valObj.value) ? parseInt(valObj.value) : this.minV;
				selVal +=  this.stepV * ((bl) ? (+1) : (-1));
				selVal = Math.round(selVal / this.stepV) * this.stepV;
				if (this.isValid(selVal)) 
					valObj.value = selVal;
			}
		}
	},
	submitFrm : function(invest_type, seqn) {
		if (parent.rainCheck.checkLogin()) {
			var valObj = this.getObjectValue(seqn);
			if (valObj != null) {
				if (rainCheck.chkInt(valObj)) {
					var selVal = parseInt(valObj.value);
					if (this.isValid(selVal)) 
						itemControl.checkPoint(invest_type, seqn, 'invest', selVal);
				}
			}
		}
	},
	setResult : function(invest_type, seqn, val) {
		this.getObjectView(seqn).innerHTML = rain.nodeUtil.int2Money(val);
	}
}

var fileBoxUpload = {
	swfupload_class : null,
	options : {upload_max_size : 1024*1024*20 ,singleupload_max : 1024*1024*20, total_uploaded : 0},
	category : {id:null, name : null},
	getFileBoxObj : function(areaid) {
		switch(areaid) {
			case 'draw' :
				return $(this.filebox_idx + '_draw');
				break;
			case 'point' :
				return $(this.filebox_idx + '_point');
				break;
			case 'cate' :
				return $(this.filebox_idx + '_cate');
				break;
			case 'catebtn' :
				return $(this.filebox_idx + '_catebtn');
				break;
			case 'uploadbtn' :
				return $(this.filebox_idx + '_uploadbtn');
				break;
			case 'process' :
				return $(this.filebox_idx + '_process');
				break;
		}
	},
	selectFile : function() {
		if (this.category.id == null) 
			rainPopup.alert('Content Type 을 먼저 선택하여 주십시오');
		else {
			if (this.swfupload_class == null) {
				rainPopup.check();
				var swfupload_options = {
					flash_path : rainGlobalConf.imageURL,
					base_upload_script : rainGlobalConf.uploadSCRIPT,
					upload_max_size : this.options.upload_max_size,
					file_queue_limit : 40,
					singleupload_max : this.options.singleupload_max,
					checkRemindSize : this.checkRemindSize.bind(this),
					fileDialogComplete : this.fileDialogComplete.bind(this),
					uploadProgress : this.uploadProgress.bind(this),
					uploadFileComplete : this.uploadFileComplete.bind(this),
					handleErrors : this.handleErrors.bind(this),
					button_placeholder_id : this.getFileBoxObj('uploadbtn'),
					button_width: 69,
					button_height: 23,
					autoupload : true, 
					autobrowse : true
				};
				this.swfupload_class = new rain.SimpleUpload(swfupload_options, rainPopup.popup_class);
			} else {
				this.swfupload_class.openBrowse();
			}
		}
	},
	checkRemindSize : function(fileSize, queue_size) {
		if (this.options.total_uploaded + queue_size + fileSize > this.options.upload_max_size)
			return false;
		else
			return true;
	},
	fileDialogComplete : function(fileObjs) {
		this.getFileBoxObj('process').innerHTML = '<u>' + fileObjs.length + '</u>건 선택';
	},
	uploadProgress :function(ufile, bytes_complete, bytes_total) {
		if (bytes_total == 0) {
			Element.setStyle(this.getFileBoxObj('process'),{backgroundImage:'none'});
			this.getFileBoxObj('process').innerHTML = '&nbsp;';
		} else {
			var percent = bytes_complete / bytes_total;
			var percent_px = (bytes_total > 0)?Math.ceil(percent* this.graph_width): 0;
			Element.setStyle(this.getFileBoxObj('process'),{backgroundImage:'url('+rainGlobalConf.imageURL+'img_sliderbg.gif)', backgroundPosition: (percent_px - 700)+'px 0px'});
			this.getFileBoxObj('process').innerHTML = ufile.name + ' (' + (percent *100).toFixed(2)+'%)';
		}
	},
	uploadFileComplete : function(ufile) {
		var fileObj = {
			fileName : ufile.fileName,
			fileSize :  ufile.size,
			fileExt : ufile.ext,
			server : ufile.server,
			sorce : ufile.sorce,
			cateId : this.category.id,
			cateName : this.category.name
		}
		this.addFile(fileObj, true);
	},
	handleErrors : function(errorLogs) {
		if (errorLogs.length > 0) {
			var html = '';
			for(var i = 0; i < errorLogs.length ; i++) 
				html += '<div align=left><b>+ ' + errorLogs[i].title +'</b><hr>'+errorLogs[i].name+'<hr>' + errorLogs[i].msg + '</div>';
			rainPopup.alert(html);
		}
	},
	addFile : function(fileObj, synkAuto) {
		var tableobj = Object.extend(document.createElement('table'), {width:'100%',height:'22px',border : '0', cellPadding :'0', cellSpacing :'0'});
		var tr_obj = tableobj.insertRow(-1);
		var td_obj = tr_obj.insertCell(-1);
		td_obj.appendChild(rain.nodeUtil.getDiv({innerHTML : fileObj.cateName},{width:'200px', textAlign:'left'}));
		td_obj.className = 'category';
		var td_obj = tr_obj.insertCell(-1);
		var file_html = '<img src="' + itemControl.getAttachIcon(fileObj.fileExt) + '" border=0 align=absmiddle> '+ fileObj.fileName + ' (' + rain.nodeUtil.getSize2Short(fileObj.fileSize) + ')';
		td_obj.appendChild(rain.nodeUtil.getDiv({innerHTML : file_html},{width:'405px', textAlign:'left'}));
		td_obj.className = 'filename';
		var td_obj = tr_obj.insertCell(-1);
		var delete_btn = td_obj.appendChild(
			rain.nodeUtil.getButton(
				{className:'delete', onclick : this.deleteConfirm.bind(this,fileObj)},
				{width:'13px',height:'13px', border:'0px', backgroundColor:'transparent', cursor : rain.nodeUtil.getCursor()}
			)
		);
		var areaObj = this.getFileBoxObj('draw');
		var tmpDiv = areaObj.appendChild(rain.nodeUtil.getDiv({className:'items'},{margin:'0 0 0 7px'}));
		tmpDiv.className = 'items';
		tmpDiv.appendChild(tableobj);
		this.fileboxObj.push({info:fileObj,obj:tmpDiv});
		this.options.total_uploaded += parseInt(fileObj.fileSize);
		if (synkAuto) 
			this.checkFileCnt();
	},
	checkFileCnt : function() {
		if (this.fileboxObj.length > 0) {
			this.filebox_msg.style.display = 'none';
			var file_pointObj = this.getFileBoxObj('point');
			if (file_pointObj != null)
				file_pointObj.style.display = '';
		} else {
			this.filebox_msg.style.display = '';
			this.filebox_msg.innerHTML = '파일을 추가해 주세요!!';
			var file_pointObj = this.getFileBoxObj('point');
			if (file_pointObj != null)
				file_pointObj.style.display = 'none';
		}
	},
	deleteConfirm : function(fileObj) {
		this.lastTmpFileObj = fileObj;
		rainPopup.confirm('[<b>' + fileObj.fileName +'</b>] 파일을 삭제하시겠습니까?', this.deleteConfirmEnd.bind(this));
	},
	deleteConfirmEnd : function(bl) {
		if (bl) 
			this.deleteFile(this.lastTmpFileObj);
	},
	deleteFile : function(fileObj) {
		if (fileObj != null)
			this.options.total_uploaded -= parseInt(fileObj.fileSize);
		this.fileboxObj = this.fileboxObj.findAll(function(obj) {
			if (obj.info == fileObj) {
				obj.obj.parentNode.removeChild(obj.obj);
				return false;
			} else {
				return true;
			}
		});
		this.checkFileCnt();
	},
	getFileBox : function() {
		var vals = [];
		this.fileboxObj.each(function(fileObj) {
			var obj = fileObj.info;
			vals.push(obj.cateId + '$$$' + obj.fileName + '$$$' + obj.server + '$$$' + obj.fileSize + '$$$' + obj.fileExt);
		});
		return vals.join('###');
	},
	setFileBox : function(idx, oldObj) {
		this.fileboxObj = [];
		this.filebox_idx = idx;
		var tmpObj = rain.nodeUtil.getDiv(
			{id : idx + '_uploadbtn'},
			{
				width:'69px', 
				height:'23px',
				backgroundImage: 'url('+base_img_url+'section/commons/btn_scr_file.gif)'
			}
		);
		var tmpBtn = this.getFileBoxObj('uploadbtn');
		tmpBtn.parentNode.insertBefore(tmpObj, tmpBtn);
		tmpBtn.parentNode.removeChild(tmpBtn);
		
		Element.setStyle(this.getFileBoxObj('uploadbtn'), {cursor : rain.nodeUtil.getCursor()});
		Element.setStyle(this.getFileBoxObj('catebtn'), {cursor : rain.nodeUtil.getCursor()});
		var areaObj = this.getFileBoxObj('draw');
		this.getFileBoxObj('catebtn').onclick = this.getCategory.bind(this);
		this.getFileBoxObj('uploadbtn').onclick = this.selectFile.bind(this);
		this.filebox_msg = areaObj.appendChild(rain.nodeUtil.getDiv({className : 'items', innerHTML : ''},{height:'40px', display : 'none', padding:'10 0 0 0px', textAlign:'center'}));
		this.graph_width = this.getFileBoxObj('process').offsetWidth;
		if (oldObj != null) {
			for(var i = 0; i < oldObj.length; i++)
				this.addFile(oldObj[i], false);
		}
		this.checkFileCnt();
	},
	getCategory : function() {
		if (this.lastCateIdx != null) {
			rainPopup.close();
			this.lastCateIdx = null;
		} else {
			if (this.cateObj == null) {
				rainPopup.check();
				var class_cate = new rain.Category(
					{
						postData :{mode : 'content'}, 
						folderSelect : false, 
						width : 150,
						initValue : null,
						onchange : this.setCategory.bind(this)
					}, rainPopup.style_class);
				this.cateObj = class_cate;
			}
			this.lastCateIdx = true;
			rainPopup.add(this.cateObj,{is_transparent : true,toolbar : false,shadow : false,sticker:{obj:this.getFileBoxObj('cate'),pos:'BL', margin : [0,0]}});
		}
	},
	setCategory : function(ids, texts, msg) {
		if (msg != null) 
			rainPopup.alert(msg);
		else if (ids != null && texts != null) {
			this.category	= {id : ids[0], name : texts[0]}
			this.getFileBoxObj('cate').innerHTML = this.category.name;
			if (this.swfupload_class == null)
				this.selectFile();
		} else {
			this.category	= {id : null, name : null}
			this.getFileBoxObj('cate').innerHTML = '';
			if (this.swfupload_class != null) {
				this.swfupload_class.destory();
				this.swfupload_class = null;
			}
		}
		this.lastCateIdx = null;
		rainPopup.close();
	}
}


function itemScrap(msg, call_back, style_class, donotuse_tail) {
	this.style_class = style_class;
	this.call_back = call_back;
	this.blog_id = null;
	this.cate_id = null;
	this.category_class = {};
	if (donotuse_tail == undefined || donotuse_tail == false)
		donotuse_tail = false;
	else
		donotuse_tail = true;
	this.obj = rain.nodeUtil.getDiv({},{width:'270px', height:'auto', padding:'5px 5px 0px 5px', textalign : 'center'});
	this.obj.appendChild(rain.nodeUtil.getDiv({innerHTML:msg},Object.extend(this.style_class.getStyle('msg'),{margin:'7px',height:'auto', fontSize : '12px', fontWeight : 'bolder'})));
	var tmpObj = rain.nodeUtil.getDiv({},{width:'260px', height:'25px', padding:'3px', borderBottom : '1px dotted ' + this.style_class.options.line, marginBottom : '10px', marginTop : '10px'});
	this.blog_obj = tmpObj.appendChild(rain.nodeUtil.getDiv({innerHTML:'내블로그-기본카테고리'}, {width:'200px', textAlign:'left', cssFloat:'left' , styleFloat : 'left', overflow : 'hidden'}));
	this.blog_change = tmpObj.appendChild(rain.nodeUtil.getButton({innerHTML:'변경',onclick:this.getBlog.bind(this)}, Object.extend(this.style_class.getStyle('designbutton',17),{cssFloat:'left' , styleFloat : 'left', margin:'0 4 0 0px'})));
	this.obj.appendChild(tmpObj);
	if (!donotuse_tail) {
		this.tailtext_obj = rain.nodeUtil.getTextArea({cols:10,rows:4,disabled:true,maxlength:1000}, Object.extend(this.style_class.getStyle('input'),{width:'190px', height:'40px',textAlign:'left'}))
		this.obj.appendChild(rain.nodeUtil.getIndex('꼬릿말', this.tailtext_obj, 45, this.style_class));
	}

	this.greettext_obj = rain.nodeUtil.getTextArea({cols:10,rows:4,disabled:false,maxlength:1000}, Object.extend(this.style_class.getStyle('input'),{width:'190px', height:'30px',textAlign:'left'}))
	this.obj.appendChild(rain.nodeUtil.getIndex('인사말', this.greettext_obj, 45, this.style_class));
	var tmp = this.obj.appendChild(rain.nodeUtil.getDiv({},{width:'260px', height:'20px', margin:'5px 0px 0px 0px'}));
	this.autogreet_obj = tmp.appendChild(rain.nodeUtil.getCheck({title : '자동 인사 남기기', onclick : this.setAutoGreet.bind(this)},{styleFloat : 'left', cssFloat : 'left', padding : '0px', margin : '0 0 0 50px'}));
	tmp.appendChild(rain.nodeUtil.getDiv({innerHTML : '자동으로 인사를 남깁니다'},{width:'170px', styleFloat : 'left', cssFloat : 'left', padding : '0px', margin : '3 0 0 3px', textAlign:'left'}));
	var tmp = this.obj.appendChild(rain.nodeUtil.getDiv({},{width:'260px', height:'30px', margin:'5px 0px 0px 0px'}));
	tmp.appendChild(rain.nodeUtil.getButton({innerHTML:'확인', onclick:this.sendValue.bind(this)},this.style_class.getStyle('designbutton', 20)));
	tmp.appendChild(rain.nodeUtil.getButton({innerHTML:'닫기', onclick:this.close.bind(this)},this.style_class.getStyle('designbutton', 20)));
	this.setBlog('','내블로그-기본카테고리');
}

itemScrap.prototype = {
	popupMagin : {top:2, right:5, bottom:3, left:5},
	getBlog : function() {
		if (this.blog_isshown) {
			this.popup_class.closeChild();
			this.blog_isshown = false;
		} else {
			if (this.blog_class == null) {
				this.blog_class = new rain.Category(
					{
						postData :{mode : 'FOLDER'}, 
						folderSelect : false, 
						width : 180,
						initValue : null,
						canbenull : false,
						xmlURL : '/BRIDGE/xml_usercontrol.html',
						onchange : this.setBlogCategory.bind(this)
					}, this.style_class);
			}
			this.popup_class.add(this.blog_class, {is_transparent : true,toolbar : false,shadow : false,sticker:{obj:this.blog_change,pos:'BL', margin : [20,2]}});
			this.blog_isshown = true;
		}
	},
	setAutoGreet : function() {
		if (this.autogreet_obj.checked) 
			this.greettext_obj.value = '감사합니다~~';
	},
	setBlogCategory : function(blogids, blog_names, msg) {
		if (msg != null) {
			this.popup_class.add(new rain.Popup.alert('<b>' + msg.title + '</b><hr>' + msg.contents, this.style_class));
		} else if (blogids != null && blog_names != null && blogids.length > 2 && blog_names.length > 2) {
			this.blog_id = blogids[1];
			this.blog_obj.innerHTML = rain.nodeUtil.getHanCut(blog_names[1],20) + ' - <u>' + blog_names[0] + '</u>';
			this.setCategory(blogids[0], 'Y');
			if (this.popup_class != null) 
				this.popup_class.closeChild();
		}
		this.blog_isshown = false;
	},
	setBlog : function(blog_id, blog_name) {
		this.blog_obj.innerHTML = blog_name;
		this.blog_id = blog_id;
		this.setCategory(0, 'Y');
		if (this.popup_class != null)
			this.popup_class.closeChild();
	},
	setCategory : function(cate_id, opt_tail) {
		this.cate_id = cate_id;
		this.cate_tail = opt_tail;
		if (this.tailtext_obj != null) {
			if (this.cate_tail != 'Y') {
				this.tailtext_obj.title = '꼬릿말 입력 불가';
				Element.setStyle(this.tailtext_obj, {backgroundColor:this.style_class.options.bg,border : '1px dotted ' + this.style_class.options.line});
				this.tailtext_obj.disabled = true;
			} else {
				this.tailtext_obj.title = '꼬릿말을 입력하여 주시요';
				Element.setStyle(this.tailtext_obj, {backgroundColor:this.style_class.options.bg,border : '1px solid ' + this.style_class.options.line});
				this.tailtext_obj.disabled = false;
			}
		}
		if (this.popup_class != null)
			this.popup_class.closeChild();
	},
	sendValue : function() {
		if (this.blog_id == null) 
			this.popup_class.add(new rain.Popup.alert('블로그/팀을 선택하여 주십시오', this.style_class));
		else if (this.cate_id == null) 
			this.popup_class.add(new rain.Popup.alert('카테고리를 선택하여 주십시오', this.style_class));
		else {
			var tail_text = comment_txt = '';
			if (this.tailtext_obj != null && this.cate_tail == 'Y') 
				tail_text = this.tailtext_obj.value;
			if (this.greettext_obj != null) 
				comment_txt = this.greettext_obj.value;
			this.call_back(this.blog_id, this.cate_id, tail_text, comment_txt);
		}
	},
	close : function() {
		this.popup_class.close();
	}
}

function rainFloat(id) {
	this.Xpos = 0;
	this.Ypos = 0;
	this.stepMove = 1;
	this.Ygravity = 1;
	this.scrollPos = 0;
	this.oldScrollPos = 0;
	this.isFirefox = navigator.userAgent.toLowerCase().indexOf("firefox")!=-1,
	this.offsetLeft = (this.isFirefox) ? 438 : 435;
	this.floater = document.getElementById(id);
	this.floater_height = this.floater.offsetHeight;
	this.resize();
	this.floater.style.display = 'block';
	window.onscroll = this.scroll.bind(this);
	window.onresize = this.resize.bind(this);
}

rainFloat.prototype = {
	resize : function() {
		this.docWidth = document.body.clientWidth + document.body.scrollLeft; 
		if (this.docWidth < 876)
			this.docWidth = 876;
		this.docHeight = document.body.clientHeight; 
		this.scroll();	
	},
	scroll : function() {
		this.setXPos();
		this.setYPos();
	},
	setXPos : function() {
		this.Xpos = (this.docWidth / 2) + this.offsetLeft;
		this.floater.style.left = Math.round(this.Xpos) + 'px';
	},
	setYPos : function() {
		this.scrollPos = document.body.scrollTop; 
		this.Ypos = ((this.scrollPos + this.docHeight) - this.floater_height) - 210;
		this.floater.style.top =  Math.round(this.Ypos) + 'px';
	}
}
