var img_domain_url = 'http://snowimg.fuzewire.com/';
var attach_domain_url = 'http://snowattach.fuzewire.com/';

window.onerror = function(message, url, line) { alert('Url:'+url+'\r\nLine :'+line+'\r\n' +message);return true;}

function swapTopImage(obj, img_name, bl) {
	if (bl) 
		obj.src= img_domain_url + img_name +'.gif';
	else
		obj.src= img_domain_url + img_name +'_1.gif';
}

var lastShownObj = null;
var lastShownObjID = null;
var lastShownObj3th = null;

function showSubMenu(id, img, obj) {
	if (lastShownObjID != null && lastShownObjID != id)
		hideSubMenu(lastShownObjID);
	var tmpObj = document.getElementById('submenu_'+id);
	if (tmpObj != null) {
		lastShownObj = tmpObj;
//		if (!obj.isFixed) {
//			lastShownObj.style.left= Math.round((obj.offsetWidth - 113)/2) +'px'
//			obj.isFixed = true;
//		}
		lastShownObj.style.display = 'block';
	}
	lastShownObjID = id;
	if (img != '' && img != null) {
		var imgObj = document.getElementById('imgmenu_'+id);
		if (imgObj != null) {
			if (imgObj.tmpImage == null) {
				imgObj.orgImage = new Image();
				imgObj.orgImage.src = imgObj.src;
				imgObj.tmpImage = new Image();
				imgObj.tmpImage.src = img_domain_url + img +'.gif';
			}
			imgObj.src = imgObj.tmpImage.src;
		}
	}
}

function hideSubMenu(id) {
	if (lastShownObj != null) {
		lastShownObj.style.display = 'none';
		lastShownObj = null;
		lastShownObjID = null;
	}
	var imgObj = document.getElementById('imgmenu_'+id);
	if (imgObj != null && imgObj.orgImage != null) 
		imgObj.src = imgObj.orgImage.src;
}
var stopMenuNavi = false;

function hideAllMenu() {
	if (	lastShownObjID != null)
		hideSubMenu(lastShownObjID);
}
function stopSubMenu(bl) {
	stopMenuNavi = bl;
}

function show3thMenu(id1, id2, no) {
	var divObj = document.getElementById('submenu_'+id1 +id2);
	if (lastShownObj3th != null)
		lastShownObj3th.style.display = 'none';
	if (divObj != null) {
		lastShownObj3th = divObj;
		lastShownObj3th.style.display = 'block';
//		if (!divObj.isFixed) {
//			lastShownObj3th.style.top = '-'+22+'px';
//			var topOffset = (no +1) * 18;
//			lastShownObj3th.style.top = '-'+((topOffset-10))+'px';
//			divObj.isFixed = true;
//		}
	}
}

function toggleLayer(layerName) {
	var divObj = document.getElementById(layerName);
	if (divObj != null) {
		if (divObj.style.display == 'none')
			divObj.style.display = 'block';
		else
			divObj.style.display = 'none';
	}
}

function showHideLayer(layerName, bl) {
	var divObj = document.getElementById(layerName);
	if (divObj != null) 
		divObj.style.display = (bl) ? 'block' : 'none';
}

function swapLayer(layerName1, layerName2, layerName3) {
	showHideLayer(layerName1,true);
	if (layerName2 != null)
		showHideLayer(layerName2,false);
	if (layerName3 != null)
		showHideLayer(layerName3,false);
}

function changeTab(layerName1, layerName2, layerName3) {
	var divObj = document.getElementById(layerName1);
	if (	divObj != null) {
		changeimgSeical(divObj,'on',true);
		divObj.onmouseover = null;
		divObj.onmouseout = null;
	}
	var divObj1 = document.getElementById(layerName2);
	if (	divObj1 != null) {
		changeimgSeical(divObj1,'on',false);
		divObj1.onmouseover = overimg;
	}
	var divObj2 = document.getElementById(layerName3);
	if (	divObj2 != null) {
		changeimgSeical(divObj2,'on',false);
		divObj2.onmouseover = overimg;
	}
}

function lectureTab(gbn) {
	var linkObj = document.getElementById('scriptbtn_comment_link');
	var imgObj = document.getElementById('scriptbtn_comment_title');
	var imgObj1 = document.getElementById('scriptbtn_comment');
	var imgObj2 = document.getElementById('scriptbtn_kor');
	var imgObj3 = document.getElementById('scriptbtn_eng');
	switch(gbn) {
		case 'script'	 :
			if (linkObj != null)
				linkObj.style.display = 'none';
			if (imgObj != null)
				imgObj.style.display = '';
			if (imgObj1 != null)
				changeimgSeical(imgObj1,'on',true);
			if (imgObj2 != null)
				changeimgSeical(imgObj2,'on',false);
			if (imgObj3 != null)
				changeimgSeical(imgObj3,'on',false);
			swapLayer('script_comment','script_kor','script_eng');
			break;
		case 'eng'	 :
			if (linkObj != null)
				linkObj.style.display = '';
			if (imgObj != null)
				imgObj.style.display = 'none';
			if (imgObj1 != null)
				changeimgSeical(imgObj1,'on',true);
			if (imgObj2 != null)
				changeimgSeical(imgObj2,'on',false);
			if (imgObj3 != null)
				changeimgSeical(imgObj3,'on',true);
			swapLayer('script_eng','script_kor','script_comment');
			break;
		case 'kor'	 :
			if (linkObj != null)
				linkObj.style.display = '';
			if (imgObj != null)
				imgObj.style.display = 'none';
			if (imgObj1 != null)
				changeimgSeical(imgObj1,'on',true);
			if (imgObj2 != null)
				changeimgSeical(imgObj2,'on',true);
			if (imgObj3 != null)
				changeimgSeical(imgObj3,'on',false);
			swapLayer('script_kor','script_eng','script_comment');
			break;
	}
	
	
}
function  popupLogin() {
		
}

// 롤오버시 이미지 바꾸기
function overimg(imgobj,dmt){
	if (imgobj == null)
		imgobj = this;
	changeimg(imgobj,dmt);
	imgobj.onmouseout=function(){
		changeimg(this,dmt);
	}
}
function changeimgSeical(imgobj,dmt,bl){
	if(!dmt) dmt='on';
	var src=imgobj.src;
	var ext=src.substring(src.lastIndexOf('.'));
	if(src.indexOf(dmt+ext)==-1 && bl) 
		imgobj.src=src.replace(ext,dmt+ext);
	else if (!bl)
		imgobj.src=src.replace(dmt+ext,ext);
}


// 이미지 바꾸기
function changeimg(imgobj,dmt,alt){
	if(!dmt) dmt='on';
	var src=imgobj.src;
	var ext=src.substring(src.lastIndexOf('.'));
	if(src.indexOf(dmt+ext)==-1) imgobj.src=src.replace(ext,dmt+ext);
	else imgobj.src=src.replace(dmt+ext,ext);
	if(alt) imgobj.alt=alt;
}


function updateTailText(obj, base_name) {
	var textInfo = {
		'C' : 'front/images/txt/txt_lecquestion',
		'U' : 'front/images/txt/txt_lechelp',
		'T' : 'front/images/txt/txt_trans'
	}
	var checkedValue = obj.value;
	for(var idx in textInfo) {
		var imgUrl = img_domain_url + textInfo[idx];
		var imgObj = document.getElementById(base_name + idx);
		if (imgObj != null) {
			if (checkedValue == idx)
				imgObj.src= imgUrl +'_on.gif';
			else
				imgObj.src= imgUrl +'.gif';
		}
	}
}


function getDocumentLocation() {
	var theUrl = 	document.location.href;
	if (theUrl.indexOf('?') > 0)
		return theUrl.substring(0,theUrl.indexOf('?'));
	else if (theUrl.indexOf('#') > 0)
		return theUrl.substring(0,theUrl.indexOf('#'));
	else
		return theUrl;
}


function goChangeParam(key, value) {
	var theURL = document.location.href;
	var urlVal = theURL.split('?');
	var mainUrl = urlVal[0];
	var getDataHash = {};
	if (urlVal.length > 1 && urlVal[1] != '') {
		urlVal[1] = urlVal[1].split('#')[0];
		var getDatas = urlVal[1].split('&');
		for(var i = 0; i < getDatas.length; i++) {
			var keyVal = 	getDatas[i].split('=');
			if (keyVal.length > 1 && keyVal[0] != '' && keyVal[1] != '')
				getDataHash[keyVal[0]] = keyVal[1];
		}
	}
	getDataHash['cline'] = 0;
	getDataHash[key] = value;
	var newData = [];
	for(var idx in getDataHash) 
		newData.push(idx +'=' + getDataHash[idx]);
	document.location.href = mainUrl +'?' + newData.join('&');
}

function getConsiderPage(page) {
	cafen.smallSWFAjax.getFlashXml({mode:'xmlConsider', page : page},setConsiderPage, getDocumentLocation());
}


function setConsiderPage(html) {
	var imgObj = document.getElementById('consider_pages');
	imgObj.innerHTML = html;
}

function getNoteMemPage(page) {
	cafen.smallSWFAjax.getFlashXml({mode:'xmlMemNote', page : page},setNoteMemPage, getDocumentLocation());
}

function setNoteMemPage(html) {
	var imgObj = document.getElementById('memnote_pages');
	imgObj.innerHTML = html;
}

function getMemPage(page) {
	if (checkLogin()) 
		showPopup(null, {mode:'xmlMemList', page : page}, null, document.getElementById('layerPos'));
}


function checkSelectList(obj) {
	if (obj.className == 'on')
		obj.className = '';
	else
		obj.className = 'on';
}

function moveMemList(objid1, objid2, mode) {
	var orgObj = document.getElementById(objid1);
	var tarObj = document.getElementById(objid2);
	var selectedObjs = [];
	for (var i = 0; i < orgObj.childNodes.length; i++) {
		var childObj = 	orgObj.childNodes[i];
		if (childObj.className == 'on')
			selectedObjs.push(childObj);
	}
	if (selectedObjs.length > 0) {
		var memList = [];
		for (var i = 0; i < selectedObjs.length; i++) {
			tarObj.appendChild(selectedObjs[i]);
			memList.push(selectedObjs[i].getAttribute('for'));
		}
		updateMemList(memList, mode);
	} else 
		alert('이동하실 회원을 선택하여 주십시오');	
}

function removeMemList(objid) {
	var orgObj = document.getElementById(objid);
	var selectedObjs = [];
	for (var i = 0; i < orgObj.childNodes.length; i++) {
		var childObj = 	orgObj.childNodes[i];
		if (childObj.className == 'on')
			selectedObjs.push(childObj);
	}
	if (selectedObjs.length > 0) {
		if (confirm('선택하신 회원을 삭제하시겠습니까?')) {
			var memList = [];
			for (var i = 0; i < selectedObjs.length; i++) {
				orgObj.removeChild(selectedObjs[i]);
				memList.push(selectedObjs[i].getAttribute('for'));
			}
			updateMemList(memList, 'DEL');
		}
	} else 
		alert('삭제할 회원을 선택하여 주십시오');	
}

function updateMemList(ids, mode) {
	new cafen.Ajax({mode : 'xmlModifyMemDB', smode : mode, ids : ids.join(',')}, updateMemCallEnd, document.location.pathname, 'post');
}

function updateMemCallEnd() {}

function checkEmailSend(form, options) {
	var emailList = [];
	for (var i = 1; i <= 5; i++) {	
		var obj = form['email'+i];
		if (obj.value != '' && !formFilter('email', obj.value)) {
			alert('메일 주소를 입력하여 주십시오');	
			obj.focus();
			return false;
		} else if (obj.value != '')
			emailList.push(obj.value);
	}
	if (emailList.length > 0) 
		return true;
	else {
		alert('메일 주소를 입력하여 주십시오');
		return false;
	}
}

function checkDummy() {
	alert('해당 기능은 준비 중입니다.');	
	return false;
}

var currLegalityPage = null;
var currLegalityPageTotal = null;
function moveLegalityPage(bl) {
	if (currLegalityPage == null) {
		var seqn = 0;
		var tmpObj = null;
		while(tmpObj = document.getElementById('legality_' + seqn)) {
			if (tmpObj.style.display != 'none')
				currLegalityPage = seqn;
			seqn++;
		}
		currLegalityPageTotal = seqn;
	}
	if (bl) {
		if (	currLegalityPage < (currLegalityPageTotal -1)) {
			document.getElementById('legality_' + currLegalityPage).style.display = 'none';
			currLegalityPage ++;
			document.getElementById('legality_' + currLegalityPage).style.display = 'block';
		} 
	} else {
		if (	currLegalityPage > 0) {
			document.getElementById('legality_' + currLegalityPage).style.display = 'none';
			currLegalityPage --;
			document.getElementById('legality_' + currLegalityPage).style.display = 'block';
		} 
	}
}

function showTailReply(no) {
	if (checkLogin()) 
		showPopup(null, {no:no, mode : 'xmlTailReply'});
}


function showTailReport(no) {
	if (checkLogin()) 
		showPopup(null, {no:no, mode : 'xmlTailReport'});
}

function addTailReport(no, reportType) {
	if (checkLogin()) 
		new cafen.Ajax({no:no, mode : 'xmlTailReportDB', reporttype : reportType}, ajaxCallEnd, document.location.pathname, 'post');
}

function showTailDelete(no) {
	if (checkLogin()) 
		if (confirm('해당 댓글을 삭제하시겠습니까?'))
			new cafen.Ajax({no : no, mode : 'xmlTailDelete'}, ajaxCallEnd, document.location.pathname, 'post');
}

function showTailVote(no, bl) {
	if (checkLogin()) 
		if (confirm('해당 댓글에 투표하시겠습니까?'))
			new cafen.Ajax({no : no, isgood : (bl) ? 'Y' : 'N', mode : 'xmlTailVote'}, ajaxCallEnd, document.location.pathname, 'post');
}

function showLectuteVote(no) {
	if (checkLogin()) 
		if (confirm('해당 강의에 점수를 주시겠습니까?')) {
			new cafen.Ajax({point : no, mode : 'xmlLectureVote'}, ajaxCallEnd, document.location.pathname, 'post');
			toggleLayer('pop_point')
		}
}

function checkScrapNote(form,options) {
	if (options.noteuid == null || options.noteuid == '') {
		alert('하나 이상의 지식 모둠을 선택하여 주십시오');
		return false;
	} else 
		return true;
}

function showLectutePopup(mode) {
	if (checkLogin()) 
		showPopup(null, {mode : mode},null, document.getElementById('layerPos'));
}

function memberNote() {
	if (checkLogin()) {
		if (confirm('해당 지식모둠의 회원으로 참여 하시겠습니까?'))
			new cafen.Ajax({mode : 'xmlNoteMemberDB'}, ajaxCallEnd, document.location.pathname, 'post');
	}
}

function leaveNote() {
	if (checkLogin()) {
		if (confirm('해당 지식모둠의 회원에서 탈퇴하시겠습니까?'))
			new cafen.Ajax({mode : 'xmlNoteLeaveDB'}, ajaxCallEnd, document.location.pathname, 'post');
	}
}

function closeNote() {
	if (checkLogin()) {
		if (confirm('해당 지식모둠을 폐쇄하시겠습니까?'))
			new cafen.Ajax({mode : 'xmlNoteCloseDB'}, ajaxCallEnd, document.location.pathname, 'post');
	}
}

function deleteNoteMem(no) {
	if (checkLogin()) {
		if (confirm('지식모둠에서 해당 강의를 삭제하시겠습니까?'))
			new cafen.Ajax({mode : 'xmlDeleteMemNoteDB', no : no}, ajaxCallEnd, document.location.pathname, 'post');
	}
}

function previewLecture(obj) {
	if (obj.value == '') {
		alert('강의 동영상 Embed Code 를 입력하여 주십시오');
		obj.focus();		
	} else {
		var script_code = obj.value.replace(/transparent/gi,'window');
		showPopupHtml(makePopupHtml('동영상 미리보기', "<div style='width:501px;height:312px;overflow:hidden;text-align:center;z-index:200'>"+script_code+"</div>",'front/images/pop/tit_lecture_movie_ok.gif'),100);
	}
}

function showTailModify(no) {
	if (checkLogin()) 
		if (confirm('해당 댓글을 수정하시겠습니까?'))
			showPopup(null, {no:no, mode : 'xmlTailModifyForm'});
}

function drawTag(id) {
	var areaObj = document.getElementById(id +'_area');
	var hiddenObj = document.getElementById(id +'_input');
	var tagHtml = [];
	if (hiddenObj.value != '') {
		var oldTags = hiddenObj.value.split(',');	
		for(var i = 0 ; i <	oldTags.length; i++)
			tagHtml.push('<span class="c_pointer"> '+oldTags[i]+' <a href="javascript:tagMaker(\''+id+'\',\'del\',\''+oldTags[i]+'\')"><img src="http://snowimg.fuzewire.com/front/images/icon/icon_del.gif" class="vam" alt="삭제 아이콘" /></a>');
	}
	areaObj.innerHTML = tagHtml.join(' , ');
}

function tagMaker(id,mode,tag) {
	var txtObj = document.getElementById(id +'_keyword');
	var hiddenObj = document.getElementById(id +'_input');
	switch(mode) {
		case 'add' :
			if (txtObj.value.split(' ').join('') == '') {
				alert('태그를 입력하여 주십시오');
				txtObj.focus();
			} else {
				var newTags = txtObj.value.split(',');
				var oldTags = hiddenObj.value.split(',');	
				var newTagData = [];
				for(var i = 0 ; i < oldTags.length; i++) {
					if (	oldTags[i].split(' ').join('') != '')
						newTagData.push(oldTags[i]);
				}
                var regx = /^[가-힣a-zA-Z0-9]{2,10}$/;
				for(var j = 0;  j < newTags.length; j++) {
					var newTag = newTags[j];
					if (	newTag.split(' ').join('') != '' && regx.test(newTag)) {
						var findTag  = false;
						for(var i = 0 ; i < oldTags.length; i++) {
							if (oldTags[i] == newTag) 
								findTag = true;
						}
						if (!findTag) 
							newTagData.push(newTag);
					}
				}
				hiddenObj.value = newTagData.join(',');
				txtObj.value = '';
				drawTag(id);
			}
			break;
		case 'del' :
			var oldTags = hiddenObj.value.split(',');	
			var newTagData = [];
			for(var i = 0 ; i < oldTags.length; i++) {
				if (	oldTags[i].split(' ').join('') != '' && oldTags[i] != tag)
					newTagData.push(oldTags[i]);
			}
			hiddenObj.value = newTagData.join(',');
			drawTag(id);
			break;
		
	}
}


function makePopupHtml(popuptitle, html, img) {
	var txt = [];
	txt.push('<table border="0" cellpadding="0" cellspacing="0" >');
	txt.push('<tr>');
	txt.push('<td class="popupSkin s-tl"><i>&#160;</i></td>');
	txt.push('<td class="popupSkin s-tc">'+(img ? '<img src="'+img_domain_url+img+'" title="'+popuptitle+'">': '<font class="title">'+popuptitle+'</font>')+'</td>');
	txt.push('<td class="popupSkin s-tr"><i>&#160;</i></td>');
	txt.push('</tr>');
	txt.push('<tr>');
	txt.push('<td class="popupSkin s-ml"><i>&#160;</i></td>');
	txt.push('<td class="popupSkin s-mc">');
	txt.push(html);
	txt.push('</td>');
	txt.push('<td class="popupSkin s-mr"><i>&#160;</i></td>');
	txt.push('</tr>');
	txt.push('<tr>');
	txt.push('<td class="popupSkin s-bl"><i>&#160;</i></td>');
	txt.push('<td class="popupSkin s-bc"><i>&#160;</i></td>');
	txt.push('<td class="popupSkin s-br"><i>&#160;</i></td>');
	txt.push('</tr>');
	txt.push('</table>');
	return txt.join('');
}
function showFullText(idName) {
	showPopupHtml(makePopupHtml('내용 상세 보기', '<div style="width:400px;padding:5px;text-align:left;line-height:200%">'+cafen.$(idName).innerHTML+'</div>'),100);
}

function gnb_resize(h){
	document.getElementById('snow_navi1').height = h;
}

function toplnb(bl){
	document.write(			'<div id="lnb">');
	document.write(			'	<ul>');
	if (isLogined()) {
		document.write(			'    	<li><a href="/common/logout.html"><img src="http://snowimg.fuzewire.com/front/images/common/lnb_logout.gif" alt="로그아웃" /></a></li>');
	} else {
		document.write(			'    	<li><a href="/common/login.html"><img src="http://snowimg.fuzewire.com/front/images/common/lnb_login.gif" alt="로그인" /></a></li>');
		document.write(			'        <li><a href="javascript:memberUrl(\'join\')"><img src="http://snowimg.fuzewire.com/front/images/common/lnb_join.gif" alt="회원가입" /></a></li>');
	}
	document.write(			'        <li><a href="/common/faq.html"><img src="http://snowimg.fuzewire.com/front/images/common/lnb_help.gif" alt="도움말" /></a></li>');
	document.write(			'        <li><a href="/Search/search.php"><img src="http://snowimg.fuzewire.com/front/images/common/lnb_search.gif" alt="상세검색" /></a></li>');
	document.write(			'    </ul>');
	document.write(			'</div>');
	document.write(			'<div id="'+((bl)?'main_':'')+'lnb_search">');
	if (typeof mainsearch == 'function')
		mainsearch();
	document.write(			'</div>');
}


//topmenu
function topmenu(){
	document.write("		<div id=\"top\" tabindex=\"-1\" ><div id='header'>");
	toplnb();
	document.write("		<div style='width:992px;height:110px;position:relative;' align=center> ");
	document.write("			<div id=\"snow_navi\" class=\"z-index110\" style='position:absolute;left:0px'> ");
	document.write(			'<object id=snow_navi1 classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="992" height="110">'
     +'<param name="movie" value="http://snowimg.fuzewire.com/front/images/swf/snow_navi.swf" />'
     +'<param name="quality" value="high" />'
	 +'<param name="flashvars" value="xmlPath=http://snowattach.fuzewire.com/uploads/xml/gnb.xml&xmlPath1=http://snowattach.fuzewire.com/uploads/xml/gnb1.xml" />'
     +'<param name="allowScriptAccess" value="always" />'
    +'<param name="wmode" value="transparent" />'
    +'<param name="scale" value="noscale" />'
	+'<embed allowScriptAccess="always" wmode="transparent" flashvars="xmlPath=http://snowattach.fuzewire.com/uploads/xml/gnb.xml&xmlPath1=http://snowattach.fuzewire.com/uploads/xml/gnb1.xml" src="http://snowimg.fuzewire.com/front/images/swf/snow_navi.swf" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="992" height="110"></embed>'
  								 +'</object>');
	document.write("			</div></div>");
	document.write("			</div></div>");
}

function maintopmenu(){
	document.write("		<div id=\"top_menu\"  tabindex=\"-1\" > ");
	document.write("<iframe src='about:blank' name='clipHideFrm' mce_src='about:blank' scrolling='no' frameborder='0' style='position:absolute;width:500px;height:285px; top:90px;left:230px;z-index:0; border:none;display:none'></iframe>");
	document.write("			<div id=\"snow_navi\"> ");
	document.writeln(			'<object id=snow_navi1 classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="992" height="110">'
     +'<param name="movie" value="http://snowimg.fuzewire.com/front/images/swf/snow_navi.swf" />'
     +'<param name="quality" value="high" />'
	 +'<param name="flashvars" value="xmlPath=http://snowattach.fuzewire.com/uploads/xml/gnb.xml&xmlPath1=http://snowattach.fuzewire.com/uploads/xml/gnb1.xml" />'
     +'<param name="allowScriptAccess" value="always" />'
    +'<param name="wmode" value="transparent" />'
    +'<param name="scale" value="noscale" />'
	+'<embed allowScriptAccess="always" wmode="transparent" flashvars="xmlPath=http://snowattach.fuzewire.com/uploads/xml/gnb.xml&xmlPath1=http://snowattach.fuzewire.com/uploads/xml/gnb1.xml" src="http://snowimg.fuzewire.com/front/images/swf/snow_navi.swf" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="992" height="110"></embed>'
  								 +'</object>');
	document.write("			</div> ");
	document.write("		</div> ");
}

function viewIframe() {
	document.getElementById('clipHideFrm').style.display = 'block';
}

function hideIframe() {
	document.getElementById('clipHideFrm').style.display = 'none';
}

function LeftMenuResize(h) {
	var tmpObj = document.getElementById('LeftNavigation');
	if (tmpObj != null)
		tmpObj.style.height = h +'px';
}

function addMovePlus() {
	document.write("	<a href=\"/common/addlecture.html\"><img src=\"http://snowimg.fuzewire.com/front/images/btn/btn_movieplus.gif\" alt=\"동영상강의 더하기 +\"></a> ");
}

function leftmenu(nPos){
	var main = '1';
	document.write("<div id=\"leftmenu\"> ");
    document.writeln('<object id=LeftNavigation classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="192" height="290">'
     +'<param name="movie" value="http://snowimg.fuzewire.com/front/images/swf/LeftNavigation.swf" />'
     +'<param name="quality" value="high" />'
     +'<param name="flashvars" value="xmlPath=http://snowattach.fuzewire.com/uploads/xml/leftMenu.xml&nPos='+nPos+'&Main='+main+'" />'
     +'<param name="allowScriptAccess" value="always" />'
    +'<param name="wmode" value="window" />'
   +'<embed allowScriptAccess="always" wmode="window" flashvars="xmlPath=http://snowattach.fuzewire.com/uploads/xml/leftMenu.xml&nPos='+nPos+'&Main='+main+'" src="http://snowimg.fuzewire.com/front/images/swf/LeftNavigation.swf" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="192" height="290"></embed>'
   +'</object>');
	addMovePlus();
	document.write("</div> ");
}

function leftmenuNote(nPos){
	var main = '1';
	document.write("<div id=\"leftmenu\"> ");
    document.writeln('<object id=LeftNavigation classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="192" height="290">'
     +'<param name="movie" value="http://snowimg.fuzewire.com/front/images/swf/LeftNavigation.swf" />'
     +'<param name="quality" value="high" />'
     +'<param name="flashvars" value="xmlPath=http://snowattach.fuzewire.com/uploads/xml/leftMenuNote.xml&nPos='+nPos+'&Main='+main+'" />'
     +'<param name="allowScriptAccess" value="always" />'
    +'<param name="wmode" value="window" />'
   +'<embed allowScriptAccess="always" wmode="window" flashvars="xmlPath=http://snowattach.fuzewire.com/uploads/xml/leftMenuNote.xml&nPos='+nPos+'&Main='+main+'" src="http://snowimg.fuzewire.com/front/images/swf/LeftNavigation.swf" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="192" height="290"></embed>'
   +'</object>');
	addMovePlus();
	document.write("</div> ");
}


function leftmenuSnow(nPos){
	var main = '';
	document.write("<div id=\"leftmenu\"> ");
    document.writeln('<object id=LeftNavigation classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="200" height="200">'
     +'<param name="movie" value="http://snowimg.fuzewire.com/front/images/swf/LeftNavigation2.swf" />'
     +'<param name="quality" value="high" />'
     +'<param name="flashvars" value="xmlPath=http://snowimg.fuzewire.com/xml/snowLeftMenu.xml&nPos='+nPos+'&Main='+main+'" />'
     +'<param name="allowScriptAccess" value="always" />'
    +'<param name="wmode" value="window" />'
   +'<embed allowScriptAccess="always" wmode="window" flashvars="xmlPath=http://snowimg.fuzewire.com/xml/snowLeftMenu.xml&nPos='+nPos+'&Main='+main+'" src="http://snowimg.fuzewire.com/front/images/swf/LeftNavigation2.swf" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="200" height="200"></embed>'
   +'</object>');
	addMovePlus();
	document.write("</div> ");
}

function leftmenuHelp(nPos){
	var main = '';
	document.write("<div id=\"leftmenu\"> ");
    document.writeln('<object id=LeftNavigation classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="200" height="200">'
     +'<param name="movie" value="http://snowimg.fuzewire.com/front/images/swf/LeftNavigation2.swf" />'
     +'<param name="quality" value="high" />'
     +'<param name="flashvars" value="xmlPath=http://snowimg.fuzewire.com/xml/helpLeftMenu.xml&nPos='+nPos+'&Main='+main+'" />'
     +'<param name="allowScriptAccess" value="always" />'
    +'<param name="wmode" value="window" />'
   +'<embed allowScriptAccess="always" wmode="window" flashvars="xmlPath=http://snowimg.fuzewire.com/xml/helpLeftMenu.xml&nPos='+nPos+'&Main='+main+'" src="http://snowimg.fuzewire.com/front/images/swf/LeftNavigation2.swf" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="200" height="200"></embed>'
   +'</object>');
	addMovePlus();
	document.write("</div> ");
}

function leftmenuGuide(nPos){
	var main = '';
	document.write("<div id=\"leftmenu\"> ");
    document.writeln('<object id=LeftNavigation classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="200" height="200">'
     +'<param name="movie" value="http://snowimg.fuzewire.com/front/images/swf/LeftNavigation2.swf" />'
     +'<param name="quality" value="high" />'
     +'<param name="flashvars" value="xmlPath=http://snowimg.fuzewire.com/xml/guideLeftMenu.xml&nPos='+nPos+'&Main='+main+'" />'
     +'<param name="allowScriptAccess" value="always" />'
    +'<param name="wmode" value="window" />'
   +'<embed allowScriptAccess="always" wmode="window" flashvars="xmlPath=http://snowimg.fuzewire.com/xml/guideLeftMenu.xml&nPos='+nPos+'&Main='+main+'" src="http://snowimg.fuzewire.com/front/images/swf/LeftNavigation2.swf" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="200" height="200"></embed>'
   +'</object>');
	addMovePlus();
	document.write("</div> ");
}


function leftmenuMember(nPos){
	var main = '';
	document.write("<div id=\"leftmenu\"> ");
    document.writeln('<object id=LeftNavigation classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="200" height="200">'
     +'<param name="movie" value="http://snowimg.fuzewire.com/front/images/swf/LeftNavigation2.swf" />'
     +'<param name="quality" value="high" />'
     +'<param name="flashvars" value="xmlPath=http://snowimg.fuzewire.com/xml/memberLeftMenu.xml&nPos='+nPos+'&Main='+main+'" />'
     +'<param name="allowScriptAccess" value="always" />'
    +'<param name="wmode" value="window" />'
   +'<embed allowScriptAccess="always" wmode="window" flashvars="xmlPath=http://snowimg.fuzewire.com/xml/memberLeftMenu.xml&nPos='+nPos+'&Main='+main+'" src="http://snowimg.fuzewire.com/front/images/swf/LeftNavigation2.swf" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="200" height="200"></embed>'
   +'</object>');
	addMovePlus();
	document.write("</div> ");
}

//quick
function quick(){
	document.write("<div id=\"quick\"> ");
	document.write("		<a href='/common/mypage.html'><img src=\"http://snowimg.fuzewire.com/front/images/common/quick_mypage.gif\" alt=\"마이페이지\" class=\"pb5\" /></a> ");
	document.write("		<img src=\"http://snowimg.fuzewire.com/front/images/common/quick_banner.gif\" alt=\"나눔배너\"> ");
	document.write("	</div> ");
}

//foot
function foot(){
	document.write("<div id=\"foot\"> ");
	document.write("	<div id=\"foot_logo\"> ");
	document.write("		<a href=\"/\"><img src=\"http://snowimg.fuzewire.com/front/images/common/foot_logo.gif\" alt=\"SNOW\"></a> ");
	document.write("	</div> ");
	document.write("	<div id=\"foot_menu_ccl\"> ");
	document.write("		<div id=\"foot_btn\"> ");
	document.write("			<a href=\"/common/aboutus_kr.html\"><img src=\"http://snowimg.fuzewire.com/front/images/common/foot_btn01k.gif\" alt=\"SNOW소개 - KOREA\"></a> ");
	document.write("			<a href=\"/common/aboutus_en.html\"><img src=\"http://snowimg.fuzewire.com/front/images/common/foot_btn01e.gif\" alt=\"SNOW소개 - English\"></a> ");
	document.write("			<a href=\"/common/termsofuse.html\"><img src=\"http://snowimg.fuzewire.com/front/images/common/foot_btn02.gif\" alt=\"이용약관\"></a> ");
	document.write("			<a href=\"/common/rule.html\"><img src=\"http://snowimg.fuzewire.com/front/images/common/foot_btn03.gif\" alt=\"사이트 운영원칙\"></a> ");
	document.write("			<a href=\"/common/legalnotice.html\"><img src=\"http://snowimg.fuzewire.com/front/images/common/foot_btn04.gif\" alt=\"책임의 한계와 법적 고지\"></a> ");
	document.write("			<a href=\"/common/qna.html\"><img src=\"http://snowimg.fuzewire.com/front/images/common/foot_btn05.gif\" alt=\"문의하기\"></a> ");
	document.write("			<a href=\"/common/addlecture.html\"><img src=\"http://snowimg.fuzewire.com/front/images/common/foot_btn06.gif\" alt=\"제안하기\"></a> ");
	document.write("			<img src=\"http://snowimg.fuzewire.com/front/images/common/foot_copy.gif\" alt=\"(C) 2009 SNOW. ALL RIGHT RESERVED.\"> ");
	document.write("		</div> ");
	document.write("		<div id=\"foot_ccl\"> ");
	document.write("			<p class=\"fl disin\"><a rel=\"license\" href=\"http://creativecommons.org/licenses/by/2.0/kr/\"><img alt=\"Creative Commons License\" style=\"border-width:0\" src=\"http://i.creativecommons.org/l/by/2.0/kr/88x31.png\" class=\"vam\" /></a></p><p class=\"fl disin fl pl15\"><a xmlns:cc=\"http://creativecommons.org/ns#\" href=\"http://snow.or.kr\" property=\"cc:attributionName\" rel=\"cc:attributionURL\">SNOW</a>&#50640; &#51032;&#54644; &#52285;&#51089;&#46108; <span xmlns:dc=\"http://purl.org/dc/elements/1.1/\" property=\"dc:title\">SNOW&#50724;&#54536;&#51648;&#49885;&#54252;&#53448;</span> &#51008;(&#45716;) <a rel=\"license\" href=\"http://creativecommons.org/licenses/by/2.0/kr/\">&#53356;&#47532;&#50640;&#51060;&#54000;&#48652; &#52964;&#47676;&#51592; &#51200;&#51089;&#51088;&#54364;&#49884; 2.0 &#45824;&#54620;&#48124;&#44397; &#46972;&#51060;&#49440;&#49828;</a>&#50640; &#46384;&#46972; &#51060;&#50857;&#54624; &#49688; &#51080;&#49845;&#45768;&#45796;.<br /><a xmlns:dc=\"http://purl.org/dc/elements/1.1/\" href=\"http://snow.or.kr\" rel=\"dc:source\">snow.or.kr</a>&#51032; &#51200;&#51089;&#47932;&#50640; &#44592;&#52488;</p><span class=\"clear disn\"></span> ");
	document.write("		</div> ");
	document.write("	</div> ");
	document.write("</div> ");
}

function cumulativeOffset(_element) {
	var valueT = 0, valueL = 0;
	do {
		valueT += _element.offsetTop  || 0;
		valueL += _element.offsetLeft || 0;
		_element = _element.offsetParent;
	} while (_element);
	return [valueL, valueT];
}


function checkSearch(form) {
	if (form.sk.value == '') {
		alert('검색어를 입력하여 주십시오.');
		form.sk.focus();
		return false;
	} else 
		return true;
}

function changeURLObject(obj, base_url) {
	document.location.href = base_url +'?'+obj.getAttribute('name') +'=' +obj[obj.selectedIndex].value;
}


function memberUrl(mode) {
	var nextUrl = '';
	switch(mode) {
		case 'findidpw' :
			nextUrl = 'http://roset.sookmyung.ac.kr/intra21/idpass_find.html';	
			window.open(nextUrl);
			break;
		case 'join' :
			nextUrl = 'http://club.sookmyung.ac.kr:8086/jsps/member/srch_user.jsp?p_mbr_menu=2';	
			window.open(nextUrl);
			break;
		case 'myinfo' :
			nextUrl = 'http://club.sookmyung.ac.kr:8086/jsps/mypage/myInfoMdf.jsp?p_menu=6';
			window.open(nextUrl);
			break;
		case 'pw' :
			nextUrl = 'http://club.sookmyung.ac.kr:8086/jsps/mypage/myPassMdf.jsp?p_menu=6';	
			window.open(nextUrl);
			break;
	}
}

var loginPopup = null;

function showLoginPopup() {
	if (loginPopup == null) 
		loginPopup = new cafen.XFaceBox({className :'', tplName : '', attribute :{className : 'popupLayer'}, hideClose:true, title : '로그인',ajax_url : '/common/login_popup.html', ajax_data : {mode :'xmlLoginForm'}, style : {zIndex: 50}});
	loginPopup.onLoad();
}

function showLogin() {
	document.location.href= '/common/login.html?next_url='+encodeURIComponent(document.location.href);
}


function isLogined() {
	return (document.cookie.indexOf("CLTCOOKINFO") == -1) ? false : true;
}

function checkLogin(obj) {
	if (!isLogined()) {
		var txt = [];
		txt.push('해당 기능은 로그인을 하셔야 사용하실 수 있습니다.');
		txt.push('지금 로그인 하시겠습니까?');
		if (confirm(txt.join('\r\n\r\n')))
			showLogin();
		if (obj != null)
			obj.blur();
		return false;
	} else 
		return true;
}


function ajaxCallEnd(channel) {
	var nextURL = null, msg = null, msgtitle = null, msgsubtitle = null, closeall = null, msgtitleimg = null, msghtml = null;
	if (channel.checkMsg()) 
		msg = channel.getMsg().title;
	if (channel.getNode) {
		nextURL = channel.getNode('nexturl');
		msgtitle = channel.getNode('msgtitle');
		msgsubtitle = channel.getNode('msgsubtitle');
		msgtitleimg = channel.getNode('msgtitleimg');
		msghtml = channel.getNode('msghtml');
		closeall = channel.getNode('closeall');
		if (msg == null && msgsubtitle != null && msgsubtitle != '')
			msg = msgsubtitle;
	}
	if (closeall == '1') 
		hidePopup();
	if (nextURL == 'reload') {
		if (msg != null) 
			alert(msg.replace(/<br\/?[^>]+>/gi, '\r\n').replace(/<\/?[^>]+>/gi, ''));
		top.document.location.reload();
	} else if (nextURL != null && nextURL != '') {
		if (msg != null) 
			alert(msg.replace(/<br\/?[^>]+>/gi, '\r\n').replace(/<\/?[^>]+>/gi, ''));
		top.document.location.href = nextURL;
	} else if (msghtml != null  && msghtml != '') {
		showPopupHtml(makePopupHtml(msgtitle,msghtml, msgtitleimg),basePopupLevel+100);
	} else if (msg != null || msgsubtitle != '') {
		var txt = [];
		txt.push('<table border=0 width=200px>');
		if (msg != null && msg != '') {
			if (msgsubtitle != null && msgsubtitle != '') 
				txt.push('<tr><td class="subtitle">'+msgsubtitle+'</td></tr>');
			if (msg != null && msg != msgsubtitle)
				txt.push('<tr><td style="padding:5px;text-align:center;line-height:200%" nowrap>'+msg+'</td></tr>');
		} else if (msgsubtitle != null && msgsubtitle != '') 
			txt.push('<tr><td style="padding:5px;text-align:center;line-height:200%" nowrap>'+msgsubtitle+'</td></tr>');
		txt.push('</table>');
		showPopupHtml(makePopupHtml(msgtitle,txt.join(''), msgtitleimg),basePopupLevel+100);
	}
}


function goUrl(theUrl) {
	document.location.href = theUrl;
}

function goUrlForm(form, options) {
	var theUrl = form.action || document.location.pathname ;
	var params = [];
	for(var idx in options) {
		params.push(idx+'='+encodeURIComponent(options[idx]));
	}
	if (params.length > 0)
		theUrl += '?' + params.join('&'); 
	goUrl(theUrl);
}

function goUrlButton(obj, mode, uid) {
	var theUrl = obj.getAttribute('href') || document.location.pathname;
	if (mode != null) {
		theUrl += '?mode=' + encodeURIComponent(mode);
		if (uid != null) 
			theUrl += '&uid=' + encodeURIComponent(uid);
	}
	goUrl(theUrl);
}

function goXmlButtonSimple(mode, uid, suid, href) {
	goXmlButton({href : href}, {mode: mode, uid : uid || '', suid : suid || ''});
}

function goXmlButton(obj, options) {
	switch(options.mode) {
		case 'xmlProcessDB' :
			if (!confirm('처리하시겠습니까?'))
				return false;
			new cafen.Ajax(options || {}, ajaxCallEnd, (obj.getAttribute ? obj.getAttribute('href') : obj.href || null) || document.location.pathname , 'post');
			break;
		case 'xmlTailDeleteDB' :
		case 'xmlDeleteDB' :
			if (!confirm('삭제하시겠습니까?'))
				return false;
			new cafen.Ajax(options || {}, ajaxCallEnd, (obj.getAttribute ? obj.getAttribute('href') : obj.href || null) || document.location.pathname , 'post');
			break;
		case 'modifyForm' :
			if (!confirm('수정하시겠습니까?'))
				return false;
			goUrlForm(obj , options);
			break;
		case 'replyForm' :
			if (!confirm('답변하시겠습니까?'))
				return false;
			goUrlForm(obj , options);
			break;
		case 'passwdTailDeleteForm' :
		case 'passwdTailModifyForm' :
		case 'passwdDeleteForm' :
		case 'passwdModifyForm' :
		case 'xmlPopupForm' :
			showPopup((obj.getAttribute ? obj.getAttribute('href') : obj.href || null) || document.location.pathname, options)
			break;
	}
}




function checkBoxParse() {
	var objs = document.getElementsByTagName('label'); 
	var result = [];
	var className = 'formCheck';
	for(var i =0; i < objs.length; i++) 
		if (objs[i].className.match(new RegExp("(^|\\s)" + className + "(\\s|$)"))) 
			result.push(objs[i]);
	for(var i = 0; i < result.length ; i++) {
		var currObj = result[i];
		var checkboxObj = document.getElementById(currObj.getAttribute('for'));
		if (checkboxObj != null) {
			currObj.parentNode.insertBefore(checkboxObj,currObj);
			checkboxObj.className = 'formCheckHide';
			var checkedVal = checkboxObj.getAttribute('checked');
			if (checkedVal == 'true' || checkedVal == 'checked')
				currObj.className = 'formCheck checked';
			result[i].onclick = updateCheckBox;
			if (checkboxObj.onchange != null) {
				currObj.onchange = checkboxObj.onchange;
				checkboxObj.onchange = null;
			}
		}
	}
}

function checkAllBox(checkObj, objs) {
	var bl = checkObj.checked;
	if (objs != null) {
		var checkObjs = [];
		if (objs.length == null) 	
			checkObjs.push(objs);
		else if (objs.length > 0) {
			for(var i = 0; i < objs.length ; i++)
				checkObjs.push(objs[i]);
		}
		for(var i = 0; i < checkObjs.length ; i++) {
			var currObj = checkObjs[i];
			if (bl && !currObj.checked) {
				currObj.checked = true;
			} else if (!bl && currObj.checked) {
				currObj.checked = false;
			}
		}
	}
	return true;
}

function checkAllBoxSpecial(checkObj1, bl, objs, checkObj2) {
	if (checkObj1.checked && objs != null) {
		var checkObjs = [];
		if (objs.length == null) 	
			checkObjs.push(objs);
		else if (objs.length > 0) {
			for(var i = 0; i < objs.length ; i++)
				checkObjs.push(objs[i]);
		}
		for(var i = 0; i < checkObjs.length ; i++) {
			var currObj = checkObjs[i];
			currObj.checked = bl;
		
		}
		checkObj2.checked = false;
	}
}

function updateCheckBox(obj, bl) {
	var self = (obj != null && obj.innerHTML) ? obj : this;
	var checkboxObj = document.getElementById(self.getAttribute('for'));
	if (checkboxObj != null) {
		if (typeof self.onchange == 'function' && !self.onchange()) 
			checkboxObj.checked = !checkboxObj.checked;
		if (typeof bl != 'boolean') 
			self.className = (!checkboxObj.checked) ? 'formCheck checked' : 'formCheck';
		else
			self.className = (checkboxObj.checked) ? 'formCheck checked' : 'formCheck';
	}
}

function fileBoxParse(result) {
	if (result == null) {
		var objs = document.getElementsByTagName('div'); 
		var result = [];
		var className = 'formFile';
		for(var i =0; i < objs.length; i++) 
			if (objs[i].className.match(new RegExp("(^|\\s)" + className + "(\\s|$)"))) 
				result.push(objs[i]);
	}
	for(var i = 0; i < result.length ; i++) {
		var checkboxObj = result[i].childNodes[0];
		if (checkboxObj.hasAttribute == null)
			checkboxObj.hasAttribute = function(name) { return (this.getAttribute(name) == null) ? false : true;}
		if (checkboxObj != null) {
			var filetypes = (checkboxObj.getAttribute('filetype') || 'all').split(',');
			var file_types = [];
			var file_types_description = [];
			for (var j =0 ; j <filetypes.length; j++) {
				var filetype = filetypes[j].toLowerCase();
				if (filetype == 'all') {
					file_types = ['*.*'];
					file_types_description = ['all'];
					break;
				}
				switch(filetype.toLowerCase()) {
					case 'photo' :
					case 'jpg' :
						file_types.push('*.jpg;*.jpeg');
						file_types_description.push('Photo');
						break;
					case 'image' :
						file_types.push('*.png;*.jpg;*.jpeg;*.gif');
						file_types_description.push('Image');
						break;						
					case 'zip' :
						file_types.push('*.zip;*.alz;*.rar;*.gz;*.tgz');
						file_types_description.push('Zip');
						break;						
					case 'video' :
						file_types.push('*.avi;*.wmv;*.wma;*.mpg;*.mpeg;*.flv;*.mp3');
						file_types_description.push('Video');
						break;
					case 'flash' :
						file_types.push('*.flv;*.swf');
						file_types_description.push('Flash');
						break;
				}
			}
			if (file_types.length == 0) {
				file_types = ['*.*'];
				file_types_description = ['all'];
			}
			var tmpTypes = file_types.join(';').split(';');
			var newTypes = [];
			var newTypesObj = {};
			for(var j = 0 ; j <	 tmpTypes.length; j++) {
				var tmpType = tmpTypes[j];	
				if (newTypesObj[tmpType] == null) {
					newTypesObj[tmpType] = tmpType;
					newTypes.push(tmpType);
				}
			}
			file_types = newTypes;
			var showfileTypes = (file_types.length > 4) ? [file_types[0],file_types[1],file_types[2]].join(',') + '...': file_types.join(',');
			var fileSize = parseInt(checkboxObj.getAttribute('maxsize')) || 1024*1024*2;
			var oneSize = Math.min(parseInt(checkboxObj.getAttribute('onesize')) || 1024*1024*1, fileSize);
			result[i].maxSize = fileSize;
			result[i].uploadSize = 0;
			if (checkboxObj.tagName == 'INPUT') {
				var tmpObj = document.createElement('input');
				tmpObj.value = '';
				tmpObj.setAttribute('readOnly','true');
				tmpObj.className = 'poptxt';
				tmpObj.onchange = uploadFilePreview;
				tmpObj.style.width = ((checkboxObj.offsetWidth || 170) -60)+'px';
				result[i].appendChild(tmpObj);
				var tmpObj = document.createElement('input');
				tmpObj.value = '';
				tmpObj.setAttribute('type','hidden');
				tmpObj.setAttribute('name', checkboxObj.getAttribute('name')+'_ofc');
				if (checkboxObj.hasAttribute('require')) {
					tmpObj.setAttribute('require', checkboxObj.getAttribute('require'));
					tmpObj.setAttribute('title', checkboxObj.getAttribute('title'));
					checkboxObj.removeAttribute('require');
				}
				result[i].appendChild(tmpObj);
				var tmpObj = document.createElement('span');
				var tmpID = cafen.getUniqID('upload');
				tmpObj.id = tmpID;
				tmpObj.uploadFileStart = uploadFileStart.bind(tmpObj);
				tmpObj.uploadFileComplete = uploadFileComplete.bind(tmpObj);
				tmpObj.uploadError = uploadFileError.bind(tmpObj);
				tmpObj.className = 'uploadButton';
				result[i].appendChild(tmpObj);
				checkboxObj.style.display = 'none';
				var upload_options = {
					upload_url : cafenGlobalConf.uploadSCRIPT,
					flash_url : cafenGlobalConf.scripturl+"images/swfupload.swf",
					file_size_limit : Math.round(oneSize/1024),
					file_types : file_types.join(';'),
					file_types_description : file_types_description.join(',') ,
					file_upload_limit : 1000,
					file_queue_limit : 100,
					button_action : -100,
					upload_success_handler : tmpObj.uploadFileComplete,
					file_dialog_complete_handler : tmpObj.uploadFileStart,
					handleErrors : tmpObj.uploadError,
					file_queue_error_handler : tmpObj.uploadError,
					button_placeholder_id : tmpID,
					button_width: 49,
					button_height: 16,
					button_window_mode : 'transparent',
					button_cursor : -2,
					button_image_url : img_domain_url + 'layout/uploadset.gif',
					debug : false
				}
				tmpObj.last_swfuploadobj = new SWFUpload(upload_options);
			} else {
				var selectObj = document.createElement('select');
				selectObj.value = '';
				selectObj.setAttribute('multiple','multiple');
				selectObj.className = 'formSelect';
				selectObj.onchange = uploadFilePreview;
				selectObj.style.width = (checkboxObj.offsetWidth -200)+'px';
				selectObj.style.height = checkboxObj.offsetHeight+'px';
				result[i].appendChild(selectObj);
				var tmpObj = document.createElement('input');
				tmpObj.value = '';
				tmpObj.setAttribute('type','hidden');
				tmpObj.setAttribute('name', checkboxObj.getAttribute('name')+'_ofc');
				tmpObj.setAttribute('value', checkboxObj.value);
				if (checkboxObj.hasAttribute('require')) {
					tmpObj.setAttribute('require', checkboxObj.getAttribute('require'));
					tmpObj.setAttribute('title', checkboxObj.getAttribute('title'));
					checkboxObj.removeAttribute('require');
				}
				if (checkboxObj.value != '') {
					var oldValues = 	checkboxObj.value.split('#');
					for(var j =0; j < oldValues.length; j++) {
						var currValues = 	oldValues[j].split('|');
						if (currValues.length > 1) {
							selectObj.options[selectObj.options.length] = new Option(currValues[3], oldValues[j],true); 
						}
					}
				}
				result[i].appendChild(tmpObj);
				var tmpObj = document.createElement('span');
				var tmpID = cafen.getUniqID('upload');
				tmpObj.id = tmpID;
				tmpObj.uploadFileStart = uploadFileStart.bind(tmpObj);
				tmpObj.uploadFileComplete = uploadFileComplete.bind(tmpObj);
				tmpObj.uploadError = uploadFileError.bind(tmpObj);
				result[i].uploadUpdate = uploadFileUpdate.bind(result[i]);
				tmpObj.className = 'uploadButton';
				result[i].appendChild(tmpObj);
				result[i].setAttribute('linkID', tmpID);
				var deleteButton  = document.createElement('button');
				deleteButton.setAttribute('type','button');
				deleteButton.className = 'bgButton size4';
				deleteButton.innerHTML = '선택 삭제';
				deleteButton.onclick = uploadFileDelete;
				result[i].appendChild(deleteButton);
				var linkContentsID = checkboxObj.getAttribute('linkcontents');
				if (linkContentsID != null) {
					var insertButton  = document.createElement('button');
					insertButton.setAttribute('type','button');
					insertButton.className = 'bgButton size4';
					insertButton.innerHTML = '본문 삽입';
					insertButton.onclick = uploadFileInsertContents;
					insertButton.linkedObject = document.getElementById(linkContentsID);
					result[i].appendChild(insertButton);
				}
				var brObject = document.createElement('br');
				result[i].appendChild(brObject);
				var commentObject = document.createElement('div');
				commentObject.className = 'comment';
				var html = [];
				html.push('문서 첨부 제한 : <span id="'+tmpID+'_txt">0</span>/ '+getSize2Short(fileSize,1));
				html.push('파일 크기 제한 : '+getSize2Short(oneSize,1)+' (허용 확장자 '+showfileTypes+')');
				commentObject.innerHTML = html.join('<br/>') ;
				result[i].appendChild(commentObject);
				checkboxObj.style.display = 'none';
				var upload_options = {
					upload_url : cafenGlobalConf.uploadSCRIPT,
					flash_url : cafenGlobalConf.scripturl+"images/swfupload.swf",
					file_size_limit : Math.round(oneSize/1024),
					file_types : file_types.join(';'),
					file_types_description : file_types_description.join(',') ,
					file_upload_limit : 1000,
					file_queue_limit : 100,
					upload_success_handler : tmpObj.uploadFileComplete,
					file_dialog_complete_handler : tmpObj.uploadFileStart,
					handleErrors : tmpObj.uploadError,
					file_queue_error_handler : tmpObj.uploadError,
					button_placeholder_id : tmpID,
					button_width: 49,
					button_height: 16,
					button_window_mode : 'transparent',
					button_cursor : -2,
					button_image_url : img_domain_url + 'layout/uploadset.gif',
					debug : false
				}
				tmpObj.last_swfuploadobj = new SWFUpload(upload_options);
				result[i].uploadUpdate();
			}
		}
	}
}

function getSize2Short(in_size, per) {
	in_size = parseInt((in_size == null) ? 0 : in_size);
	if (per == null || typeof per == 'undefined')
		per = 0;
	if (in_size > 1024*1024*1024) return (in_size/ (1024*1024*1024)).toFixed(per) + " GB";
	else if (in_size >= 1024*1024) return (in_size/ (1024*1024)).toFixed(per) + " MB";
	else if (in_size >= 1024) return (in_size/ 1024).toFixed(per) + " KB";
	else return in_size + " B";
}

function uploadFileUpdate() {
	var textObj = this.childNodes[1];
	var hiddenObj = this.childNodes[2];
	var totalSize = 0;
	var uploadedFiles = [];
	for(var i = 0; i <  textObj.options.length; i++) {
		var uFile = new uploadFileObject(textObj.options[i].value);
		if (uFile.size > 0) {
			totalSize += uFile.size; 
			uploadedFiles.push(textObj.options[i].value);
		}
	}
	hiddenObj.value = uploadedFiles.join('#');
	if (this.showSizeObj == null) {
		var linkID = this.getAttribute('linkID');
		if (linkID != null) 
			this.showSizeObj = 	document.getElementById(linkID +'_txt');
	}
	if (this.showSizeObj != null) {
		this.showSizeObj.innerHTML = getSize2Short(totalSize,1);
		this.uploadSize = totalSize;
	}
}

function uploadFileError(ufile, code, message) {
	switch(code) {
		case -100 :
			alert('더이상 첨부 하실 수 없습니다.');
			break;
		case -110 :
			alert('첨부 가능 용량을 초과 하였습니다.\r\n\r\n'+ufile.name +'('+getSize2Short(ufile.size)+')');
			break;
		case -120 :
			alert('파일 크기에 이상이 있습니다.');
			break;
		case -130 :
			alert('첨부 불가한 파일 타잎입니다.');
			break;
		case -130 :
			alert('첨부 불가한 파일 타잎입니다.');
			break;
		default :
			alert('업로드 서버에서 이상이 발생하였습니다.\r\n' + code +'\r\n'+message);
			break;
	}
}
var uploadErrors = [];

function uploadFileComplete(infile, response) {
	var channel, xml = new cafen.xmlParser(response);
	var textObj = this.parentNode.childNodes[1];
	var hiddenObj = this.parentNode.childNodes[2];
	var uploadedSize = this.parentNode.uploadSize;
	var maxSize = this.parentNode.maxSize;
	if (channel = xml.getNext()) {
		var item , msg = null;
		while(item = channel.getNext()) {
			if (item.getNode('fileext') != '') {
				var ufile =	{
					size : parseInt(item.getNode('filesize')),
					extension : item.getNode('fileext'),
					server : item.getNode('fileserver'),
					sorce : item.getNode('filesorce'),
					fileName: item.getNode('filename'),
					width : parseInt(item.getNode('imgwidth')),
					height : parseInt(item.getNode('imgheight')),
					extra : ''
				}
				if (ufile.fileName == '') 
					ufile.fileName = infile.name;
				if (uploadedSize + ufile.size > maxSize) {
					uploadErrors.push(ufile.fileName +'('+getSize2Short(ufile.size,1)+')');
				} else {
					if (textObj.tagName == 'INPUT') {
						textObj.value = ufile.fileName;
						if (hiddenObj != null)
							hiddenObj.value = ufile.server + '|' + ufile.size + '|' + ufile.extension + '|' + ufile.fileName + '#';
					} else {
						textObj.options[textObj.options.length] = new Option(ufile.fileName , ufile.server + '|' + ufile.size + '|' + ufile.extension + '|' + ufile.fileName + '#', true, true) ;
						if (hiddenObj != null) 
							hiddenObj.value += ufile.server + '|' + ufile.size + '|' + ufile.extension + '|' + ufile.fileName + '#';
					}
				}
			}
		}
	}
	this.uploadFileStart();
}

function uploadFileObject(str) {
	var value = str.split('|');
	this.server = value[0];
	this.size  = parseInt(value[1]) || 0;
	this.extension = value[2];
	this.fileName = value[3];
}

function uploadFilePreview() {
	if (this.previewObj == null) 
		this.previewObj = document.getElementById(this.parentNode.getAttribute('for')) || '';
	if (this.previewObj != null && this.previewObj != '') {
		var ufile = null;
		var regx = /\.(jpg|gif|jpeg|png|JPEG|GIF|PNG)$/;
		if (this.tagName == 'SELECT') {
			for(var i = (this.options.length -1); i >= 0; i--) {
				if (this.options[i].selected && regx.test(this.options[i].text)) {
					ufile = new uploadFileObject(this.options[i].value);
					break;	
				}
			}
		} else {
			var hiddenObj = this.parentNode.childNodes[2];
			ufile = new uploadFileObject(hiddenObj.value);
			if (ufile.server == null && !regx.test(ufile.server))
				ufile = null;
		}
		if (ufile != null && ufile.server != null && ufile.server != '') {
			if (this.previewObj.tagName == 'IMG') {
				this.previewObj.src = cafenGlobalConf.uploadURL +ufile.server;
			} else {
				if (this.previewObj.tmpImg == null) {
					this.previewObj.tmpImg = new Image();
					this.previewObj.tmpImg.onload = uploadFilePreviewResize;
					this.previewObj.tmpImg.linkObj = this.previewObj;
				}
				if (this.previewObj.tmpImg.src != cafenGlobalConf.uploadURL +ufile.server) {
					this.previewObj.tmpImg.src = cafenGlobalConf.uploadURL +ufile.server;
					this.previewObj.innerHTML = '<img src=' +cafenGlobalConf.uploadURL +ufile.server +' border=0>';
					if (this.previewObj.tmpImg.width > 0 && this.previewObj.tmpImg.height > 0) 
						this.previewObj.tmpImg.onload();					
				}
			}
		}
	}
}

function uploadFilePreviewResize() {
	var maxWidth = this.linkObj.offsetWidth - 6 || 64;
	var maxHeight = this.linkObj.offsetHeight - 6 || 64;
	var frmRate = maxWidth/maxHeight;
	var imgWidth = this.width || 10;
	var imgHeight = this.height || 10;
	var imgRate = imgWidth/imgHeight;
	var imgObj = this.linkObj.firstChild;
	if (frmRate < imgRate) {
		imgObj.style.width = maxWidth +'px';
		fixedSize = Math.round(maxHeight/imgRate);
		imgObj.style.height = fixedSize +'px';
		imgObj.style.marginTop = ((maxHeight - fixedSize)/2) +'px';
	} else {
		imgObj.style.height = maxHeight +'px';
		fixedSize = Math.round(maxWidth/imgRate);
		imgObj.style.width = fixedSize +'px';
		imgObj.style.marginLeft = ((maxWidth - fixedSize)/2) +'px';
	}
}

function uploadFileDelete() {
	var textObj = this.parentNode.childNodes[1];
	var hiddenObj = this.parentNode.childNodes[2];
	var newOptions = [];
	var deleteCnt = 0;
	for(var i = 0; i <  textObj.options.length; i++) {
		if (!textObj.options[i].selected) 
			newOptions.push(textObj.options[i]);
		else
			deleteCnt++;
	}
	if (deleteCnt > 0) {
		if (confirm('선태된 파일 '+deleteCnt+'건을 삭제하시겠습니까?')) {
			textObj.options.length = 0;
			for(var i = 0; i <  newOptions.length; i++) 
				textObj.options[i] = 	newOptions[i];
			this.parentNode.uploadUpdate();
		}
	} else
		alert('삭제하실 파일을 선택하여 주십시오');
}

function uploadFileInsertContents() {
	var textObj = this.parentNode.childNodes[1];
	var newValues = [];
	var regx = /\.(jpg|gif|jpeg|png)$/gi;
	for(var i = 0; i <  textObj.options.length; i++) {
		if (textObj.options[i].selected  && regx.test(textObj.options[i].text)) 
			newValues.push(textObj.options[i].value);
	}
	if (newValues.length == 0)
		alert('본문에 넣어실 이미지파일을 선택하여 주십시오');
	else {
		var html = [];
		for(var i = 0 ; i < newValues.length; i++) {
			ufile = new uploadFileObject(newValues[i]);
			html.push('<img src="'+cafenGlobalConf.uploadURL + ufile.server+'" border=0 align=center alt="'+ufile.fileName +'">');
		}
		if (this.linkedObject != null) {
			if (typeof this.linkedObject.insertHTML == 'function')
				this.linkedObject.insertHTML(html.join('<br>\r\n'));
			else {
				var myField = this.linkedObject;
				var myValue = '\r\n' +html.join('\r\n');
				if (document.selection) { 
					myField.focus(); 
					sel = document.selection.createRange(); 
					sel.text = myValue; 
				} else if (myField.selectionStart && myField.selectionStart == '0') { 
					var startPos = myField.selectionStart; 
					var endPos = myField.selectionEnd; 
					myField.value = myField.value.substring(0, startPos)+ myValue+ myField.value.substring(endPos, myField.value.length); 
				} else 
					myField.value += myValue; 
			}
		}
	}
}



function uploadFileStart() {
	this.uploadStat = this.last_swfuploadobj.getStats();
	if (this.uploadStat.files_queued > 0) 
		this.last_swfuploadobj.startUpload();
	else {
		if (typeof this.parentNode.uploadUpdate == 'function') 
			this.parentNode.uploadUpdate();
		if (uploadErrors.length > 0) {
			alert(uploadErrors.join('\r\n')+'\r\n\r\n위파일은 업로드 용량 제한으로 업로드 되지 않았습니다.');
			uploadErrors = [];
		}
		var textObj = this.parentNode.childNodes[1];
		if (typeof textObj.onchange == 'function')
			textObj.onchange();
	}
}


var lastPopup = {};
var basePopupLevel = 520;
function showPopup(callURL, param, level, sticker) {
	if (level == null)
		level = basePopupLevel;
	if (callURL == null) 
		callURL= document.location.pathname;
	if (lastPopup[level] == null) {
		lastPopup[level] = new cafen.XFaceBox({className :'', tplName : '', attribute :{className : 'popupLayer'}, hideClose:true, title : '알림',ajax_url : callURL, ajax_data : param || {}, style : {zIndex : level}});
	}else
		lastPopup[level].loadAjax(callURL, param || {});
	if (sticker != null) {
		lastPopup[level].onLoad({obj : sticker, x : 'left',y : 'bottom'});
	}else
		lastPopup[level].onLoad();
}

function hidePopup(level, bl) {
	if (level == null) 
		level = (bl) ? basePopupLevel+100 : basePopupLevel;
	if (lastPopup[level] != null) 
		lastPopup[level].close();
}

function calObject() {
	this._className = 'calObject';
}

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

calObject.prototype = {
	dateString : ['일','월','화','수','목','금','토'],
	_DOMonth : [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31], 
	_lDOMonth : [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31],
	_currentData : null,
	_monthDate : [],
	_className : '',
	_textObj : null,
	init : function() {
		
	},
	getDaysOfMonth : function(year, month) { 
		if ((year % 4) == 0) { 
			if ((year % 100) == 0 && (year % 400) != 0) 
				return this._DOMonth[month]; 
			else
				return this._lDOMonth[month]; 
		} else 
			return this._DOMonth[month]; 
	},
	getFirstDay : function(year, month) {
		var tmpDate = new Date(); 
		tmpDate.setDate(1); 
		tmpDate.setMonth(month); 
		tmpDate.setFullYear(year); 
		return tmpDate.getDay(); 
	},
	getLastDay : function(year, month) {
		var tmpDate = new Date(); 
		tmpDate.setMonth(month); 
		tmpDate.setFullYear(year); 
		tmpDate.setDate( getDaysOfMonth(year, month) ); 
		return tmpDate.getDay(); 
	},
	moveNext : function() {
		this.showMonth(this._currentData.getFullYear(), this._currentData.getMonth() + 2);
	},
	movePrev : function() {
		this.showMonth(this._currentData.getFullYear(), this._currentData.getMonth());
	},
	clearMonth : function() {
	
	},
	getMonthYear : function() {
		var txt  = this._currentData.getFullYear() +'/';
		var month = this._currentData.getMonth() +1;
		return (month > 9) ? txt + month : txt + '0'+month;
	},
	showMonth : function (year, month) {
		this._currentData = new Date(year,month -1,10);
		var isCurrent = (this._currentData.getFullYear() == this._baseDate.getFullYear() && this._currentData.getMonth()  == this._baseDate.getMonth()) ? true : false;
		this._monthDate = [];
		var cnt = this.getDaysOfMonth(this._currentData.getFullYear(), this._currentData.getMonth());
		var start = (this.getFirstDay(this._currentData.getFullYear(), this._currentData.getMonth())) % 7;
		for (var i =0; i < 42 ; i++)
			this._monthDate.push('');
		for (var i = 1; i <= cnt ; i++) 
			this._monthDate[start+i-1] = i;
		var html = [];
		html.push('<div style="width:150px;">');
		html.push('<div class="popCalendar top"> <a href="javascript:'+this._className+'.movePrev()">&lt;</a> '+this.getMonthYear()+' <a href="javascript:'+this._className+'.moveNext()">&gt;</a></div>');
		html.push('<table border="0" cellpadding="0" cellspacing="0" width=100% class="popCalendar">');
		html.push('<thead><tr>');
		for(var i = 0; i < this.dateString.length; i++)
			html.push('<td>'+this.dateString[i]+'</td>');
		html.push('</tr></thead>');
		html.push('<tbody>');
		for (var i =0; i < 42 ; i++) {
			var col = i % 7;
			if (col == 0)
				html.push('<tr>');
			if (this._monthDate[i] == '')
				html.push('<td class="blank">&nbsp;</td>');
			else {
				var txt = '<a href="javascript:'+this._className+'.setDate('+this._monthDate[i]+')">'+this._monthDate[i]+'</a>';
				if (isCurrent && this._baseDate.getDate() == this._monthDate[i])
					html.push('<td class="today">'+txt+'</td>');
				else {
					switch(col) {
						case 0 :
							html.push('<td class="sun">'+txt+'</td>');
							break;
						case 6 :
							html.push('<td class="sat">'+txt+'</td>');
							break;
						default :
							html.push('<td>'+txt+'</td>');
							break;
					}
				}
			}
			if (col == 6)
				html.push('</tr>');
		}
		html.push('</tbody>');
		html.push('</table>');
		html.push('</div>');
		showPopupHtml(makePopupHtml('날짜 선택', html.join(''),'front/images/mini_calendar/tit_mini_calendar.gif'), 0, this._baseObj);
	},
	setDate: function(i) {
		if (this._textObj != null) {
			var txt = [];
			txt.push(this._currentData.getFullYear());
			var month = this._currentData.getMonth()+1;
			txt.push((month > 9) ? month : '0'+month);
			var day = i;
			txt.push((day > 9) ? day : '0'+day);
			this._textObj.value = txt.join('');
		} else 
			alert(this.getMonthYear()+'/'+i);
		hidePopup();
	},
	parseDate : function(obj) {
		this._baseObj = obj;
		this._textObj = document.getElementById(obj.getAttribute('for'));
		this._baseDate = new Date(); 
		if (this._textObj != null && this._textObj.value != '' && this._textObj.value.length == 8) {
			var txt = this._textObj.value;
			var year = txt.substring(0, 4);
			this._baseDate.setFullYear(year); 
			var month = parseInt(txt.substring(4, 6));
			this._baseDate.setMonth(month-1); 
			var day = parseInt(txt.substring(6, 8));
			this._baseDate.setDate(day); 
		}
		this.showMonth(this._baseDate.getFullYear(), this._baseDate.getMonth()+1)
	}
}

var calObject = new calObject();


function showPopupHtml(html,level, obj) {
	if (level == null)
		level = basePopupLevel;
	if (lastPopup[level] == null) 
		lastPopup[level] = new cafen.XFaceBox({className :'', tplName : '', attribute :{className : 'popupLayer'}, hideClose:true, title : '알림', contents : html, style : {zIndex : 200 + level}});
	else
		lastPopup[level].loadHtml(html);
	lastPopup[level].onLoad((obj != null) ? {obj:obj, x: 'exright',y: 'bottom'} : null);
}


function checkFormElement(form, param, callFnc, msg) {
	var xmlOptions = param || {};
	for(var i = 0 ; i < form.elements.length; i++) {
		var obj = form.elements[i];
		var objType = obj.getAttribute('type') || '';
		if (obj.hasAttribute == null)
			obj.hasAttribute = function(name) { return (this.getAttribute(name) == null) ? false : true;}
		switch((obj.tagName +'_'+ objType).toLowerCase()) {
			case 'select_select-one' :
			case 'select_' :
				var selectedValue = '';
				if (obj.getAttribute('multiple')) {
					var selectedValues = [];
					for(var j = 0 ; j < obj.length; j++)
						if (obj.options[j].selected && obj.options[j].value != '')
							selectedValues.push(obj.options[j].value);
					selectedValue = selectedValues.join(',');
				} else if (obj.selectedIndex > -1)
					selectedValue = obj[obj.selectedIndex].value;
				if (obj.hasAttribute('require') && selectedValue == '') {
					var title = obj.getAttribute('title') || obj.getAttribute('name');
					alert(title +'을(를) 선택하여 주십시오');
					try {
						obj.focus();
					} catch(ex) {}
					return false;
				}
				if (obj.hasAttribute('name') && selectedValue != '') {
					xmlOptions[obj.getAttribute('name')] = selectedValue;
				}
				
				break;
			case 'input_radio' :
			case 'input_checkbox' :
				if (obj.hasAttribute('name') && obj.checked) {
					if (xmlOptions[obj.getAttribute('name')] != null)
						xmlOptions[obj.getAttribute('name')] += ','+obj.value;
					else
						xmlOptions[obj.getAttribute('name')] = obj.value;
				}
				break;
			case 'textarea_textarea' :
			case 'textarea_' :
				if (obj.parse != null && typeof obj.parse == 'function' && !obj.parse()) {
					obj.focus();
					return false;
				}
			case 'input_text' :
			case 'input_password' :
			case 'input_hidden' :
				if (obj.hasAttribute('require')) {
					var value = obj.value;
					var title = obj.getAttribute('title') || obj.getAttribute('name');
					if (value.split(' ').join('') == '') {
						alert(title +'을(를) 입력하여 주십시오');
						try {obj.focus(); } catch(ex) {} 
						return false;
						break;
					} else {
						if (!formFilter(obj.getAttribute('require'), value)) {
							alert(title +'을(를) 입력하여 주십시오.\r\n\r\n입력하신 값에 오류가 있습니다.');
							try {obj.focus(); } catch(ex) {}
							return false;
							break;
						}
					}
				}
				if (obj.hasAttribute('maxhanlen') && obj.value != '' && (getHanByte(obj.value) > parseInt(obj.getAttribute('maxhanlen')))) {
					var title = obj.getAttribute('title') || obj.getAttribute('name');
					var txt = [];
					txt.push(title +'의 자릿수에 오류가 있습니다.');
					txt.push('한글최대 : '+Math.round(parseInt(obj.getAttribute('maxhanlen'))/2)+'자');
					txt.push('영문최대 : '+parseInt(obj.getAttribute('maxhanlen'))+'자');
					alert(txt.join('\r\n\r\n'));
					obj.focus();
					return false;
				}	
				if ((obj.hasAttribute('maxlength') || obj.hasAttribute('fixlength') || obj.hasAttribute('minlength')) && !formFilterLength(obj.value, parseInt(obj.getAttribute('maxlength')) || null , parseInt(obj.getAttribute('minlength')) || null, parseInt(obj.getAttribute('fixlength')) || null)) {
					var value = obj.value;
					var title = obj.getAttribute('title') || obj.getAttribute('name');
					var txt = [];
					txt.push(title +'의 자릿수에 오류가 있습니다.');
					if (obj.hasAttribute('fixlength'))
						txt.push('고정 : '+obj.getAttribute('fixlength')+'자');
					else {
						if (obj.hasAttribute('minlength'))
							txt.push('최소 : '+obj.getAttribute('minlength')+'자');
						if (obj.hasAttribute('maxlength'))
							txt.push('최대 : '+obj.getAttribute('maxlength')+'자');
					}						
					alert(txt.join('\r\n\r\n'));
					obj.focus();
					return false;
				}	
				if (obj.hasAttribute('name'))
					xmlOptions[obj.getAttribute('name')] = obj.value;
				break;
			default :
//				alert(obj.getAttribute('name') + '/'+(obj.tagName +'_'+ objType).toLowerCase());
				break;
		}
	}
	if (callFnc !=null && typeof callFnc == 'function' &&  !callFnc(form, xmlOptions))
		return false;
	if (msg != null && !confirm(msg))
		return false;
	new cafen.Ajax(xmlOptions, ajaxCallEnd, form.action || document.location.pathname , 'post');
	return false;
}

function getHanByte(v){
	var reEng = /[a-z]|[0-9]/gi;
	var reHan = /[ㄱ-힣]/g;
	var vEng = v.match(reEng);
	var vHan = v.match(reHan);
	if(vEng != null) vEng = vEng.length;
	if(vHan != null) vHan = vHan.length;
	return vEng + (vHan * 2);
}

function checkLenHan(obj, id, len) {
	var hanLen = getHanByte(obj.value);
	var tmpObj = document.getElementById(id);
	if (tmpObj != null) {
		if (hanLen > len)
			tmpObj.innerHTML = '<font color=red>'+hanLen +'</font>';
		else
			tmpObj.innerHTML = hanLen;
		
	}
}

function formFilterLength(value, maxValue, minValue, fixValue) {
	if (fixValue != null && fixValue > 0 && value.length != fixValue)
		return false;
	else if (maxValue != null && 	maxValue > 0 && value.length > maxValue)
		return false;
	else if (minValue != null && 	minValue > 0 && value.length < minValue)
		return false;
	else
		return true;
}


function formFilter(filter, value) {
    switch(filter) {
        case "email" :
              var regx = /^[_0-9a-zA-Z-]+(\.[_0-9a-zA-Z-]+)*@[0-9a-zA-Z-]+(\.[0-9a-zA-Z-]+)*$/;
              return regx.test(value);
            break;
        case "passwd" :
                var regx = /^[a-zA-Z0-9\_]{3,12}$/;
              return regx.test(value);
        case "userid" :
            var regx = /^[a-z]([_0-9a-z]{3,20})$/;
            return regx.test(value);
            break;
        case "homepage" :
            var regx = /^(http|https|ftp|mms):\/\/[0-9a-z-]+(\.[_0-9a-z-\/\~]+)+(:[0-9]{2,4})*$/;
            return regx.test(value);
            break;
        case "korean" :
                var regx = /^[가-힣]*$/;
                return regx.test(value);
            break;
        case "korean_number" :
                var regx = /^[가-힣0-9]*$/;
                return regx.test(value);
            break;
        case "alpha" :
                var regx = /^[a-zA-Z]*$/;
                return regx.test(value);
            break;
        case "folder" :
                var regx = /^[a-z][a-z0-9\_]{1,15}$/;
                return regx.test(value);
            break;
        case "alpha_number_space" :
                var regx = /^[a-zA-Z][a-zA-Z0-9 &\_]*$/;
                return regx.test(value);
            break;
        case "alpha_number" :
                var regx = /^[a-zA-Z][a-zA-Z0-9\_]*$/;
                return regx.test(value);
            break;
        case "salpha" :
                var regx = /^[a-z]*$/;
                return regx.test(value);
            break;
        case "salpha_number" :
                var regx = /^[a-z][a-z0-9\_]*$/;
                return regx.test(value);
            break;
        case "number_pid1" :
                var regx = /^[0-9]{2}[0-1][0-9][0123][0-9]$/;
                return regx.test(value);
            break;
        case "number_pid2" :
                var regx = /^[1234][0-9]{6}$/;
                return regx.test(value);
            break;
        case "number" :
            return !isNaN(value);
	        break;
	    default : 
	    	return true;
	        break;
    }
}

function rolling(moveobj,childtag,direction,defaultdirection,movesize,howmanyshow,maxcontents,speed,replaytime){


	var obj=document.getElementById(moveobj);
	var items,finalp,setmg,tempobj;
	clearTimeout(obj.replayaction);
	clearTimeout(obj.moveaction);

	var getmargin=function(){
		if(direction=='up' || direction=='down') return parseInt(obj.style.marginTop);
		if(direction=='left' || direction=='right') return parseInt(obj.style.marginLeft);
	}

	var setmargin=function(value){
		if(direction=='up' || direction=='down') obj.style.marginTop=value+'px';
		if(direction=='left' || direction=='right') obj.style.marginLeft=value+'px';
	}

	var objp=getmargin();
	var maxp=-(movesize*(maxcontents-howmanyshow));

	var getnextposition=function(){
		var tmp;
		for(var i=-(maxcontents); i<=maxcontents; i++){
			tmp=i*movesize;
			if(direction=='left' || direction=='up'){
				if(tmp>objp) break;
			}else	if(direction=='right' || direction=='down'){
				if(tmp>objp){
					tmp=(i*movesize)-(movesize*2);
					break;
				}
			}
		}
		return tmp;
	}
	finalp=getnextposition();

	var appendfirst=function(){
		items=obj.getElementsByTagName(childtag);
		tempobj=items[items.length-1].cloneNode(true);
		obj.removeChild(items[items.length-1]);
		obj.insertBefore(tempobj,obj.firstChild);
		setmargin(objp-movesize);
		finalp=0;
	}

	var appendlast=function(){
		items=obj.getElementsByTagName(childtag);
		tempobj=items[0].cloneNode(true);
		obj.removeChild(items[0]);
		obj.appendChild(tempobj);
		setmargin(objp+movesize);
		finalp=maxp;
	}

	if(direction=='left' || direction=='up'){
		if(finalp>0) appendfirst();
	}else	if(direction=='right' || direction=='down'){
		if(finalp<maxp) appendlast();
	}

	var moveanimation=function(){
		clearTimeout(obj.moveaction);
		objp=getmargin();
		if(objp>finalp){
			setmg=objp-Math.ceil((objp-finalp)/speed);setmargin(setmg);
			obj.moveaction=setTimeout(moveanimation,10);
		}else	if(objp<finalp){
			setmg=objp+Math.ceil((finalp-objp)/speed);setmargin(setmg);
			obj.moveaction=setTimeout(moveanimation,10);
		}else	if(objp==finalp){
			setmg=finalp;setmargin(setmg);
			clearTimeout(obj.moveaction);
			if(replaytime) obj.replayaction=setTimeout(replay,replaytime);
		}
	}
	moveanimation();

	var replay=function(){
		clearTimeout(obj.replayaction);
		clearTimeout(obj.moveaction);
		move(moveobj,childtag,defaultdirection,defaultdirection,movesize,howmanyshow,maxcontents,speed,replaytime);
	}
}


function exifParse(baseWidth) {
	if (baseWidth == null)
		baseWidth =3000;
	
	var tmpObj = document.getElementById('boardContents');
	var imgObjs = tmpObj.getElementsByTagName('img');
	var result =[];
	for(var i = 0;  i < imgObjs.length; i++) {
		var imgObj = imgObjs[i];
		var tmpImg = new Image();
		tmpImg.linkObj = imgObj;
		tmpImg.onerror = showImageError;
		tmpImg.src = imgObj.src;
		if (imgObj.src.indexOf('uploads/') > 0 && imgObj.src.indexOf('.jpg') > 0)
			result.push(imgObj);
		if (imgObj.width > baseWidth) {
			imgObj.style.width = baseWidth + 'px'	;
			imgObj.style.height = 'auto'	;
			imgObj.style.cursor = 'pointer'	;
			imgObj.isResized = true;
			imgObj.onclick = showImage;
		}
	}
	for(var i = 0;  i < result.length; i++) {
		result[i].onclick = showExif;
	}
}

function showImageError() {
	this.linkObj.src = img_domain_url + 'blank.gif';
	this.linkObj.style.width = '1px';
	this.linkObj.style.height = '1px';
}

function showImagePopup() {
	if (!this.isLoaded) {
		this.isLoaded = true;
		var max_width = 600;
		var max_height = 600;
		var img_width = this.width;
		var img_height = this.width;
		if (img_width > max_width) {
			var img_rate = img_height / img_width;
			img_width = max_width;
			img_height = Math.round(img_width * img_rate);
		}
		if (img_height > max_height) {
			var img_rate = img_width / img_height;
			img_height = max_height;
			img_width = Math.round(img_height * img_rate);
		}
		showPopupHtml(makePopupHtml('이미지 확인', "<img onclick='hidePopup()' style='cursor:pointer' src='"+this.src+"' border=0 width='"+img_width+"' height='"+img_height+"' title='"+this.title+"'>"));
	}
}

function showImg(objTxt) {
	var objArr = objTxt.split('#')[0].split('|');
	var tmpImg = new Image();
	tmpImg.src = attach_domain_url + 'uploads/'+ objArr[0];
	tmpImg.title = objArr[3];
	tmpImg.onload = 	showImagePopup;
	if (tmpImg.width != null && tmpImg.width > 1) 
		tmpImg.onload();	
}


var imgPopup = null;
function showImage(obj) {
	var self = (obj != null) ? obj : this;
	var tmpImg = new Image();
	tmpImg.src = self.src;
	var html = '<img src='+self.src+' width='+tmpImg.width+'>';
	if (imgPopup == null) 
		imgPopup = new cafen.XFaceBox({className :'', tplName : '', attribute :{className : 'popupLayer'}, hideClose:true, title : '알림', contents : html, style : {zIndex : 100}});
	else
		imgPopup.loadHtml(html);
	imgPopup.onLoad();
}


var lastExifObj = null;
var exifLayerObj = null;
var exifContentsObj = null;
var exifLayerAlpha = [0,0];

var baseExifInfo = {
	'Model' : '모델',
	'ISOSpeedRatings' : 'ISO',
	'GPSLatitude' : '위도',
	'GPSLongitude' : '경도',
	'Model' : '모델',
	'Model' : '모델',
	'DateTime' : '촬영일자'
}

function updateExif(channel) {
	if (channel == null)
		html = lastExifObj.channel;
	else 	{
		var html = [];
		html.push('<table border=0 width=200>');
		var item = null;
		while(item = channel.getNext()) {
			var name = baseExifInfo[item.getNode('name')];
			if (name != null ) {
				html.push('<tr>');
				html.push('<td>'+name+'</td>');
				html.push('<td>'+item.getNode('description')+'</td>');
				html.push('</tr>');
			}
		}
		html.push('</table>');
		lastExifObj.channel = html;
	}
	if (lastExifObj.isResized) 
		showImage(lastExifObj);
	showPopupHtml(html.join(''));
}

function showExif() {
	lastExifObj = this;
	if (this.channel != null)
		updateExif();
	else {
		var objValue = lastExifObj.src.substring(lastExifObj.src.indexOf('uploads/') + 8);
		new cafen.Ajax({mode : 'EXIF', img : objValue}, updateExif, cafenGlobalConf.uploadSCRIPT, 'post');
	}
}


window.debug_mode = false;

var cafenGlobalConf = {
	licence : true,
	'uploadSCRIPT' : 'http://snowattach.fuzewire.com/upload_fileswf.php',
	'uploadURL' : 'http://snowattach.fuzewire.com/uploads/',
	'scripturl' : img_domain_url +'service2/',
	useImageEditor : true, useMediaPlayer : true,
	useFlashChart : true,
	attachAs : true,
	hl : 'ko'
}



