var img_domain_url = 'http://image.snow.or.kr/';
var img_domain_front_url = img_domain_url + 'front/';
var attach_domain_url = 'http://attach.snow.or.kr/';


window.onerror = function(message, url, line) {
	//alert('Url:'+url+'\r\nLine :'+line+'\r\n' +message);   2009-12-22 주석처리
	//return true;
	return true;
}

var instance = {}

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() {
	if (!isLogined()) {
		var txt = [];
		txt.push('작성중인 문서 있을때는 문서가 초기화 됩니다.');
		txt.push('지금 로그인 하시겠습니까?');
		if (confirm(txt.join('\r\n\r\n')))
			showLogin();
		return false;
	} else
		return true;
}

// 롤오버시 이미지 바꾸기
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 changeModeUrl(mode, uid) {
	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['mode'] = mode;
	getDataHash['uid'] = uid || '';
	var newData = [];
	for(var idx in getDataHash)
		newData.push(idx +'=' + getDataHash[idx]);
	document.location.href = mainUrl +'?' + newData.join('&');
}


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) {
	cafen.smallSWFAjax.getFlashXml({mode:'xmlMemList', page : page},setMemPage, getDocumentLocation());
}

function setMemPage(html) {
	var imgObj = document.getElementById('memnote_list');
	imgObj.innerHTML = html;
}

function checkNoteMemSearch(form,options) {
	if (form.sk.value == '') {
		alert('검색어를 입력하여 주십시오');
		form.sk.focus();
	} else {
		cafen.smallSWFAjax.getFlashXml(options,setMemSearch, getDocumentLocation());
	}
	return false;
}

function setMemSearch(html) {
	var imgObj = document.getElementById('popmem_list');
	imgObj.innerHTML = html;
}



function addNoteMem(userid, usernm, email) {
	var memo = cafen.$(popup_memo).value;
	new cafen.Ajax({mode: 'xmlAddMem', user_id : userid, user_name : usernm, email : email, memo : memo}, ajaxCallEnd, document.location.pathname , 'post');
}

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, bl) {
	if (bl != null) {
		if (bl) {
			if (checkLogin())
				showPopup(null, {no:no, mode : 'xmlTailReply'});
		} else
			memberNote	();
	} else {
		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 (confirm('해당 댓글에 투표하시겠습니까?'))
			new cafen.Ajax({no : no, isgood : (bl) ? 'Y' : 'N', mode : 'xmlTailVote'}, ajaxCallEnd, document.location.pathname, 'post');
}

function showLectuteVote(no) {
		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 checkRemindTags(form,options) {
	if (form.tagkeyword.value != '') {
		alert('선택버튼을 누르셔야 태그가 등록 됩니다."');
		form.tagkeyword.focus();
		return false;
	} else
		return true;
}

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

function showScriptPopup(mode) {
	if (checkLogin())
		showPopup(null, {mode : mode}, 525, document.getElementById('title'));
		//showPopup(null, {mode : mode},null, document.getElementById('scriptPos'));
		//showPopup(null, {mode : mode}, null, null);
}
function showScriptPopupDetail(arg, level, stickid) {
	if (checkLogin()) showPopup(null, arg, level, document.getElementById(stickid));
}
function showScriptEngList() {
	if (checkLogin())
		showPopup(null, {mode : "xmlScriptEngListWiki"}, 530, document.getElementById('title'), false);
}
function showScriptEngPager(cline) {
	if (checkLogin())
		showPopup(null, {"mode" : "xmlScriptEngListWiki", "cline" : cline}, 530, document.getElementById('title'), true);
}
function showScriptKorList() {
	if (checkLogin())
		showPopup(null, {mode : "xmlScriptKorListWiki"}, 530, document.getElementById('title'), false);
}
function showScriptKorPager(cline) {
	if (checkLogin())
		showPopup(null, {"mode" : "xmlScriptKorListWiki", "cline" : cline}, 530, document.getElementById('title'), true);
}
function showScriptDiff(no) {
	new cafen.Ajax( { "mode" : 'xmlScriptDiffXml', "no" : no }, showScriptDiff_, document.location.pathname, 'post' );
}
function showScriptDiff_(channel) {
	if (channel.getNode) {
		var no = channel.getNode('no');
		var script_diff = channel.getNode('script_diff');  //alert(script_diff);
		document.getElementById("script_diff").innerHTML = script_diff;
	}
}
function addScriptEngPara() {
	var iPara, scriptVal, scriptHistoryVal;

	try{  scriptVal = formScriptKorWiki.script.value;  }
	catch(e){  alert("한글스크립트 편집창이 없습니다.");  return;  }

	try{  scriptHistoryVal = formScriptEngLoad.script_history.value;  }
	catch(e){  alert("영문스크립트 불러오기 창이 없습니다.");  return;  }
	if(scriptHistoryVal.length<1) {  alert("영문스크립트 단락바구니에 영문단락이 없습니다.");  return;  }

	iPara=scriptVal.indexOf("[-]");
	if(iPara < 0 && !ScriptTxtRange) {  alert("한글스크립트 편집창에 [-]문자가 없습니다.");  return;  }
	
	if(iPara>=0) {
		scriptVal = scriptVal.substring(0, iPara) +"[영문단락Start]"+ scriptHistoryVal +"[영문단락End]"+ scriptVal.substring(iPara+3);
		formScriptKorWiki.script.value = scriptVal;
	} else if(ScriptTxtRange) {
		ScriptTxtRange.text = "[영문단락Start]"+ scriptHistoryVal +"[영문단락End]";
		ScriptTxtRange = null;
	}
}
var ScriptTxtRange;
function mkScriptTxtRange(){
	ScriptTxtRange = document.selection.createRange();
}

function showScriptPopupSmall(mode, arg, stick_id) {
	arg["mode"] = mode;
	if (checkLogin())
		showPopup(null, arg, 540, document.getElementById(stick_id));
}

function showMsgPopup(user_id, recv_no) {
	if(!user_id) user_id = "";
	if(!recv_no) recv_no = "";

	if(!checkLogin()) return;
	showPopup('/common/popup_sendmsg.html', {user_id:user_id, recv_no:recv_no}, 600, null);
}
function hideMsgPopup() {
	hidePopup(600);
	if(document.getElementById("ImgPopUpMsgRead")) hidePopup();
}
function showContentsLen() { with(document.formMsgSend) {
	if(hLen(contents.value)>600) contents.value = hSubStr(contents.value, 0, 600);
	var html = "("+ Math.floor(hLen(contents.value)/2) +"자/300자)";
	document.getElementById("lContentsLen").innerHTML = html;
} }

function showFindMemPopup() {
	showPopup('/common/popup_find_mem.html', {}, null, null);
}
function showFindMemAct(form) { with(form) {
	showPopup('/common/popup_find_mem.html', {user_var:user_var.value, user_val:user_val.value}, null, null, true);
} }

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

function noteTailCheck(obj, bl) {
	if (checkLogin()) {
		if (!bl) {
			memberNote();
			obj.blur();
		}
	}
}

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

function closeNote(no) {
	if (checkLogin()) {
		if (confirm('해당 지식모둠을 폐쇄하시겠습니까?'))
			new cafen.Ajax({mode : 'xmlNoteCloseDB', no : no}, ajaxCallEnd, '/common/addnote.html', '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="'+img_domain_front_url+'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 showPopupMsg(popuptitle, msg, width, okurl, level, stickobj) {
	if(!width) width = 200;
	if(!okurl) {
		okurl = "javascript:hidePopup()";
		if(level) okurl = "javascript:hidePopup("+ level +")";
	}
	showPopupHtml(makePopupHtml(popuptitle, '<div style="width:'+ width +'px;padding:5px;text-align:left;line-height:200%">'+msg+'<div style="text-align:center;margin-top:10px"><a href='+ okurl +'><img src='+ img_domain_front_url +'images/pop/btn_confirm.gif></a></div></div>'), level, stickobj);
}

function gnb_resize(h){
    if (navigator.appName.indexOf("Microsoft") != -1) {
        document.getElementById('snow_navi1').height = h + 'px';
    } else {
        document['snow_navi1'].height = h + 'px';
    }
	//document.getElementById('snow_navi1').height = h;
}

function toplnb(bl){
	document.write(			'<div id="lnb">');
	if (isLogined()) {
		document.write(			'    	<a href="/common/logout.html"><img src="'+img_domain_front_url+'images/common/lnb_logout.gif" alt="로그아웃" /></a>');
	} else {
		document.write(			'    	<a href="/common/login.html"><img src="'+img_domain_front_url+'images/common/lnb_login.gif" alt="로그인" /></a></li>');
		document.write(			'        <a href="javascript:memberUrl(\'join\')"><img src="'+img_domain_front_url+'images/common/lnb_join.gif" alt="회원가입" /></a>');
	}
	document.write(			'        <a href="/common/faq.html"><img src="'+img_domain_front_url+'images/common/lnb_help.gif" alt="도움말" /></a>');
	document.write(         '		 <a href="/common/qna.html?mode=writeForm&gbn=tab06"><img src="'+img_domain_front_url+'images/common/lnb_propose.gif" alt="제안하기"></a> ');
	document.write(			'        <a href="/Search/search.php"><img src="'+img_domain_front_url+'images/common/lnb_search.gif" alt="상세검색" /></a>');
	document.write(			'</div>');
	document.write(			'<div id="'+((bl)?'main_':'')+'lnb_search"  style="z-index:300">');
	if (typeof mainsearch == 'function')
		mainsearch();
	document.write(			'</div>');
}


function drawTopMenu(){
	document.write('		<iframe src="about:blank" name="clipHideFrm" id="clipHideFrm" mce_src="about:blank" scrolling="no" frameborder="0" style="position:absolute;width:497px;height:284px; top:90px;left:230px;z-index:0; border:none;display:none"></iframe>');
	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="'+img_domain_front_url+'images/swf/snow_navi.swf" />'
		+'<param name="quality" value="high" />'
		+'<param name="flashvars" value="xmlPath='+attach_domain_url+'uploads/xml/gnb.xml&xmlPath1='+attach_domain_url+'uploads/xml/gnb1.xml" />'
		+'<param name="allowScriptAccess" value="always" />'
		+'<param name="wmode" value="transparent" />'
		+'<param name="scale" value="noscale" />'
		+'<embed allowScriptAccess="always" id=snow_navi1 name=snow_navi1 wmode="transparent" flashvars="xmlPath='+attach_domain_url+'uploads/xml/gnb.xml&xmlPath1='+attach_domain_url+'uploads/xml/gnb1.xml" src="'+img_domain_front_url+'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>');
}

//topmenu
function topmenu(){
	document.write('		<div id="top" tabindex="-1"><div id="header">');
	toplnb();
	drawTopMenu();
	document.write('		</div></div>');
}

// flash 사이즈 변경 2010-01-05
function maintopmenu(){
	document.write('		<div id="top_menu"  tabindex="-1" > ');
	document.write('		<div id="main_menu">');
	drawTopMenu();
	document.write('		</div>');
    document.write('<div id="top_visual"><div id="snow_visual" >'
		+'  <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="891" height="340" id="snow_visual1" align="middle">'
		+'    <param name="wmode" value="transparent" />'
		+'    <param name="allowScriptAccess" value="always" />'
		+'    <param name="movie" value="'+img_domain_front_url+'images/swf/snow_visual.swf?nPos=5" width="891" height="340" />'
		+'    <param name="flashvars" value="xmlPath='+attach_domain_url+'uploads/xml/visual.xml&visual1='+img_domain_front_url+'images/swf/visual_0.swf&visual3='+img_domain_front_url+'images/swf/diagram.swf">'
		+'    <embed allowScriptAccess="always" wmode="transparent" flashvars="xmlPath='+attach_domain_url+'uploads/xml/visual.xml&visual1='+img_domain_front_url+'images/swf/visual_0.swf&visual3='+img_domain_front_url+'images/swf/diagram.swf" src="'+img_domain_front_url+'images/swf/snow_visual.swf?nPos=5" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="891" height="383"></embed>'
		+'  </object>'
		+' </div></div>');
	document.write('		</div> ');
}

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

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



function getCookie(name){
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1) {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    } else {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1) end = dc.length;
    return unescape(dc.substring(begin + prefix.length, end));
}

function setCookie(c_name,value,expiredays) {
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	document.cookie= c_name+ "=" +escape(value)+ 	((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}



//quick sub
function quick(){
	document.write('<div id="quick"> ');
	document.write('		<a href="/common/mypage.html"><img src="'+img_domain_front_url+'images/common/quick_mypage.gif" alt="마이페이지" class="pb5"  /></a> ');
	var params = [];
	if (isLogined()) {
		var userName = Base64.decode(getCookie('CLTNAME'));
		var userPointer = getCookie('CLTPOINTER');
		params.push('log_result=out');
		params.push('out_name='+userName);
		params.push('quick_2='+userPointer);
	} else {
		params.push('log_result=in');
		if (typeof snowInfoGlobal == 'object') {
			params.push('in_name='+snowInfoGlobal.cnt);
			params.push('quick_1='+snowInfoGlobal.point);
		} else {
			params.push('in_name=0');
			params.push('quick_1=0');
		}
	}
	params.push('quick_URL_in=/common/snow/status.html');
	params.push('quick_URL_out=/common/mypage.html');
	document.write('			<div id="snow_quick"> ');
	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="63" height="180">'
		+'<param name="movie" value="'+img_domain_front_url+'images/swf/snow_quick.swf" />'
		+'<param name="quality" value="high" />'
		+'<param name="flashvars" value="'+params.join('&')+'" />'
		+'<param name="allowScriptAccess" value="always" />'
		+'<param name="wmode" value="transparent" />'
		+'<param name="scale" value="noscale" />'
		+'<embed allowScriptAccess="always" wmode="transparent" flashvars="'+params.join('&')+'" src="'+img_domain_front_url+'images/swf/snow_quick.swf" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="63" height="180"></embed>'
		+'</object>');
	document.write('			</div>');
	document.write('	</div> ');
}

//quick main
function quick_main(){
	document.write('<div id="quick"> ');
	document.write('		<a href="/common/mypage.html"><img src="'+img_domain_front_url+'images/common/quick_mypage.gif" alt="마이페이지" class="pb5 pt5"  /></a> ');
	var params = [];
	if (isLogined()) {
		var userName = Base64.decode(getCookie('CLTNAME'));
		var userPointer = getCookie('CLTPOINTER');
		params.push('log_result=out');
		params.push('out_name='+userName);
		params.push('quick_2='+userPointer);
	} else {
		params.push('log_result=in');
		if (typeof snowInfoGlobal == 'object') {
			params.push('in_name='+snowInfoGlobal.cnt);
			params.push('quick_1='+snowInfoGlobal.point);
		} else {
			params.push('in_name=0');
			params.push('quick_1=0');
		}
	}
	params.push('quick_URL_in=/common/snow/status.html');
	params.push('quick_URL_out=/common/mypage.html');
	document.write('			<div id="snow_quick"> ');
	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="63" height="180">'
		+'<param name="movie" value="'+img_domain_front_url+'images/swf/snow_quick.swf" />'
		+'<param name="quality" value="high" />'
		+'<param name="flashvars" value="'+params.join('&')+'" />'
		+'<param name="allowScriptAccess" value="always" />'
		+'<param name="wmode" value="transparent" />'
		+'<param name="scale" value="noscale" />'
		+'<embed allowScriptAccess="always" wmode="transparent" flashvars="'+params.join('&')+'" src="'+img_domain_front_url+'images/swf/snow_quick.swf" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="63" height="180"></embed>'
		+'</object>');
	document.write('			</div>');
	document.write('	</div> ');
}


function LeftMenuResize(h) {	
	if (navigator.appName.indexOf("Microsoft") != -1) {
        document.getElementById('LeftNavigation').height = h + 'px';
    } else {
        document['LeftNavigation'].height = h + 'px';
    }
}

function addMovePlus() {
	document.write('	<a href="/common/addlecture.html"><img src="'+img_domain_front_url+'images/btn/btn_movieplus.gif" alt="동영상강의 더하기 +"></a> ');
}
function addLangPlus() {
	document.write('	<a href="/lang/">스크립트 강의 전체</a><br/> ');
	document.write('	<a href="/lang/kor/">한글 스크립트 강의</a><br/> ');
	document.write('	<a href="/lang/eng/">영문 스크립트 강의</a> ');
}

function leftmenu(nPos, offaddPlus){
	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="'+img_domain_front_url+'images/swf/LeftNavigation.swf" />'
     +'<param name="quality" value="high" />'
     +'<param name="flashvars" value="xmlPath='+attach_domain_url+'uploads/xml/leftMenu.xml&nPos='+nPos+'&Main='+main+'" />'
     +'<param name="allowScriptAccess" value="always" />'
    +'<param name="wmode" value="transparent" />'
   +'<embed allowScriptAccess="always" id="LeftNavigation" name="LeftNavigation" wmode="transparent" flashvars="xmlPath='+attach_domain_url+'uploads/xml/leftMenu.xml&nPos='+nPos+'&Main='+main+'" src="'+img_domain_front_url+'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>');
   //if (!offaddPlus)   
		document.write('<div style="margin-left:6px; margin-bottom:6px;"> ');
		addMovePlus();
		document.write('</div> ');
		//addLangPlus();
	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="'+img_domain_front_url+'images/swf/LeftNavigation.swf" />'
		+'<param name="quality" value="high" />'
		+'<param name="flashvars" value="xmlPath='+attach_domain_url+'uploads/xml/leftMenuNote.xml&nPos='+nPos+'&Main='+main+'" />'
		+'<param name="allowScriptAccess" value="always" />'
		+'<param name="wmode" value="transparent" />'
		+'<embed allowScriptAccess="always" wmode="transparent" flashvars="xmlPath='+attach_domain_url+'uploads/xml/leftMenuNote.xml&nPos='+nPos+'&Main='+main+'" src="'+img_domain_front_url+'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>');
	document.write('<div id="leftmenuSearch"> ');
	document.write('	<ul class="pl7"><form action="/common/notesearch.html">');
	document.write('		<li class="top"><img src="'+img_domain_front_url+'images/common/tit_note_search.gif" alt="지식모둠 찾기" /></li>');
	document.write('		<li class="mt3"><input type="text" name=sk class="txt w145"> <input type=image src="'+img_domain_front_url+'images/btn/btn_search02.gif" class="vam" alt="검색"></li>');
	document.write('   </form></ul>');
	document.write('</div> ');
	document.write('<div id="leftmenuNoteview"> ');
	document.write('	<ul>');
	document.write('		<li class="top"><span class="btn"><a href="/common/addnote.html"><img src="'+img_domain_front_url+'images/common/btn_note_make.gif" alt="지식모둠만들기" class="vam ar" /></a></span></li>');
	if (!isLogined())
		document.write('		<li class="bt"><p class="pt10"><span class="ac blue"><img src="'+img_domain_front_url+'images/common/ico_login.gif" /> <a href="javascript:showLogin()">로그인 해주세요</a></span></p></li>');
	else {
		var noteStr = getCookie('CLTNOTE');
		var noteInfo = ['0','0'];
		if (noteStr != null)
			noteInfo = noteStr.split('/');
		document.write('		<li class="bt2"><p class="pt2 pl15">개설 : <span class="t_black">'+noteInfo[0]+'</span> / 참여 : <span class="t_black">'+noteInfo[1]+'</span></p>');
		document.write('		<div id="search"><a href="javascript:getMyNotes();" onfocus=this.blur() class="sType_set">:: 지식모둠 목록 ::</a>');
		document.write('			<div id="sType_list" style="display:none">');
		document.write('				<ul id="myNoteList">');
		document.write('					<li>잠시만 기다려 주십시오...</li>');
		document.write('				</ul>');
		document.write('			</div>');
		document.write('		</div></li>');
	}
	document.write('   </ul>');
	document.write('</div> ');
	document.write('</div> ');
}

// 2010-01-05 나눔소개의 다이아그램 flash 추가
function Diagram(){
	document.write('<div id="diagram"> ');
    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="685" height="358">'
     +'<param name="movie" value="'+img_domain_front_url+'images/swf/diagram.swf" />'
     +'<param name="quality" value="high" />'
     +'<param name="flashvars" value="" />'
     +'<param name="allowScriptAccess" value="always" />'
    +'<param name="wmode" value="transparent" />'
   +'<embed allowScriptAccess="always" id="diagram" name="diagram" wmode="transparent" flashvars="" src="'+img_domain_front_url+'images/swf/diagram.swf" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="685" height="358"></embed>'
   +'</object>'); 
	document.write('</div> ');
}

var lastMyNoteSelectObj = null;
function getMyNotes(obj) {
	toggleLayer('sType_list');
	if (lastMyNoteSelectObj == null) {
		lastMyNoteSelectObj =document.getElementById("myNoteList");;
		new cafen.Ajax({mode : 'xmlGetMyNote'}, updateMyNoteSelectBox, '/common/mynoteinfo.xml', 'post');
	}
	return ;
}


function updateMyNoteSelectBox(channel) {
	if (lastMyNoteSelectObj == null)
		return ;
	lastMyNoteSelectObj.innerHTML = '';
	if (channel == null) {
		var tmpObj = lastMyNoteSelectObj.appendChild(document.createElement('li'));
		tmpObj.innerHTML = '서버통신오류 잠시후 시도하여 주십시오.';
	} else 	{
		var item = null;
		while(item = channel.getNext()) {
			var noteName = item.getNode('title');
			if (noteName != null && noteName != '') {
				var noteLink = item.getNode('link');
				if (noteLink != null && noteLink != '') {
					var tmpObj = lastMyNoteSelectObj.appendChild(document.createElement('li'));
					tmpObj.className = 'bg';
					if (noteLink == 'none')
						tmpObj.innerHTML = noteName;
					else
						tmpObj.innerHTML = '<a href="'+item.getNode('link')+'">'+noteName+'</a>';
				} else {
					if (tmpObj != null)
						tmpObj.className = '';
				}

			}
		}
	}
}

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="170">'
     +'<param name="movie" value="'+img_domain_front_url+'images/swf/LeftNavigation2.swf" />'
     +'<param name="quality" value="high" />'
     +'<param name="flashvars" value="xmlPath='+img_domain_url+'xml/snowLeftMenu.xml&nPos='+nPos+'&Main='+main+'" />'
     +'<param name="allowScriptAccess" value="always" />'
    +'<param name="wmode" value="transparent" />'
   +'<embed allowScriptAccess="always" wmode="transparent" flashvars="xmlPath='+img_domain_url+'xml/snowLeftMenu.xml&nPos='+nPos+'&Main='+main+'" src="'+img_domain_front_url+'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="170"></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="190">'
     +'<param name="movie" value="'+img_domain_front_url+'images/swf/LeftNavigation2.swf" />'
     +'<param name="quality" value="high" />'
     +'<param name="flashvars" value="xmlPath='+img_domain_url+'xml/helpLeftMenu.xml&nPos='+nPos+'&Main='+main+'" />'
     +'<param name="allowScriptAccess" value="always" />'
    +'<param name="wmode" value="transparent" />'
   +'<embed allowScriptAccess="always" wmode="transparent" flashvars="xmlPath='+img_domain_url+'xml/helpLeftMenu.xml&nPos='+nPos+'&Main='+main+'" src="'+img_domain_front_url+'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="190"></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="170">'
     +'<param name="movie" value="'+img_domain_front_url+'images/swf/LeftNavigation2.swf" />'
     +'<param name="quality" value="high" />'
     +'<param name="flashvars" value="xmlPath='+img_domain_url+'xml/guideLeftMenu.xml&nPos='+nPos+'&Main='+main+'" />'
     +'<param name="allowScriptAccess" value="always" />'
    +'<param name="wmode" value="transparent" />'
   +'<embed allowScriptAccess="always" wmode="transparent" flashvars="xmlPath='+img_domain_url+'xml/guideLeftMenu.xml&nPos='+nPos+'&Main='+main+'" src="'+img_domain_front_url+'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="170"></embed>'
   +'</object>');
	addMovePlus();
	document.write("<div id=\"leftmenuBanner3\"> ");
	document.write("	<ul> ");
	document.write("		<li class=\"tit\"> ");
	document.write("		<a href=\"/common/qna.html?mode=writeForm&gbn=tab03\"><img src=\""+img_domain_front_url+"images/tit/tit_openpropose.gif\" alt=\"\"></a> ");
	document.write("		</li> ");
	document.write("		<li class=\"bg\" <sp>인터넷에는 더많은 오픈리소스</p> <p>제공 사이트와 툴이 있습니다.</p> <p>사용자 여러분이 알고계시는 오픈</p> <p>소스를 공유해주세요</p></li> ");
	document.write("	</ul> ");
	document.write("</div> ");
	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="130">'
		+'<param name="movie" value="'+img_domain_front_url+'images/swf/LeftNavigation2.swf" />'
		+'<param name="quality" value="high" />'
		+'<param name="flashvars" value="xmlPath='+img_domain_url+'xml/memberLeftMenu.xml&nPos='+nPos+'&Main='+main+'" />'
		+'<param name="allowScriptAccess" value="always" />'
		+'<param name="wmode" value="transparent" />'
		+'<embed allowScriptAccess="always" wmode="transparent" flashvars="xmlPath='+img_domain_url+'xml/memberLeftMenu.xml&nPos='+nPos+'&Main='+main+'" src="'+img_domain_front_url+'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="130"></embed>'
		+'</object>');
	addMovePlus();
	document.write('</div> ');
}

function leftmenuTedx(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="210">'
     +'<param name="movie" value="'+img_domain_front_url+'images/swf/LeftNavigation2.swf" />'
     +'<param name="quality" value="high" />'
     +'<param name="flashvars" value="xmlPath='+img_domain_url+'xml/tedxLeftMenu.xml&nPos='+nPos+'&Main='+main+'" />'
     +'<param name="allowScriptAccess" value="always" />'
    +'<param name="wmode" value="transparent" />'
   +'<embed allowScriptAccess="always" wmode="transparent" flashvars="xmlPath='+img_domain_url+'xml/tedxLeftMenu.xml&nPos='+nPos+'&Main='+main+'" src="'+img_domain_front_url+'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="210"></embed>'
   +'</object>');
   //alert(img_domain_url+'xml/tedxLeftMenu.xml');
	document.write('</div> ');
}

//foot
function foot(){
	document.writeln('<div id="foot"> ');
	document.writeln('	<div id="foot_logo"> ');
	document.writeln('		<a href="/"><img src="'+img_domain_front_url+'images/common/foot_logo.gif" alt="SNOW"></a> ');
	document.writeln('	</div> ');
	document.write('	<div id="foot_menu_ccl"> ');
	document.write('		<div id="foot_btn"> ');
	document.write('			<p class=\"fl disin\"><a rel=\"license\" href=\"http://creativecommons.org/licenses/by-nc-nd/2.0/kr/\"><img alt=\"Creative Commons License\" style=\"border-width:0\" src=\"http://creativecommons.org/images/public/somerights20.png\" class=\"vam\" /></a></p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="/common/aboutus_kr.html"><img src="'+img_domain_front_url+'images/common/foot_btn01k.gif" alt="SNOW소개 - KOREA"></a> ');
	document.writeln('			<a href="/common/aboutus_en.html"><img src="'+img_domain_front_url+'images/common/foot_btn01e.gif" alt="SNOW소개 - English"></a> ');
	document.write('			<a href="/common/termsofuse.html"><img src="'+img_domain_front_url+'images/common/foot_btn02.gif" alt="이용약관"></a> ');
	document.write('			<a href="/common/rule.html"><img src="'+img_domain_front_url+'images/common/foot_btn03.gif" alt="사이트 운영원칙"></a> ');
	document.write('			<a href="/common/legalnotice.html"><img src="'+img_domain_front_url+'images/common/foot_btn04.gif" alt="책임의 한계와 법적 고지"></a> ');
	document.write('			<a href="/common/qna.html?mode=writeForm&gbn=tab06"><img src="'+img_domain_front_url+'images/common/foot_btn06.gif" alt="제안하기"></a> ');
	document.write('			<img src="'+img_domain_front_url+'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 fl pl15\"><a xmlns:cc=\"http://creativecommons.org/ns#\" href=\"http://www.snow.or.kr\" property=\"cc:attributionName\" rel=\"cc:attributionURL\">SNOW 홈페이지</a>의 <span xmlns:dc=\"http://purl.org/dc/elements/1.1/\" href=\"http://purl.org/dc/dcmitype/MovingImage\" rel=\"dc:type\">&#51200;&#51089;&#47932;</span>&#51008; <a rel=\"license\" href=\"http://creativecommons.org/licenses/by-nc-nd/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;</p><span class=\"clear disn\"></span> ");
	document.write("		</div> ");
	document.write('	</div> ');
	document.writeln('</div> ');
}

function footTedx(){
	document.writeln('<div id="foot"> ');
	document.writeln('        <div id="foot_logo" style="width:300px"> ');
	document.writeln('            <img src="'+img_domain_front_url+'tedx/img/foot_logo.gif" border="0" usemap="#MapFoot" class="mb10" style="border-width:0" />');
	document.writeln('            <map name="MapFoot" id="MapFoot">');
	document.writeln('                <area shape="rect" coords="0,0,107,28" href="/" />');
	document.writeln('                <area shape="rect" coords="136,-1,225,31" href="http://creativecommons.org/licenses/by-nc-nd/2.0/kr/" />');
	document.writeln('                <area shape="rect" coords="0,42,224,83" href="/Tedx/" alt="TEDx Sookmyung" /></map>');
	document.writeln('            </map>');
	document.writeln('        </div>');
	document.writeln('	<div id="foot_menu_ccl"> ');
	document.writeln('		<div id="foot_btn"> ');
	document.writeln('			<a href="/common/aboutus_kr.html"><img src="'+img_domain_front_url+'images/common/foot_btn01k.gif" alt="SNOW소개 - KOREA"></a> ');
	document.writeln('			<a href="/common/aboutus_en.html"><img src="'+img_domain_front_url+'images/common/foot_btn01e.gif" alt="SNOW소개 - English"></a> ');
	document.writeln('			<a href="/common/termsofuse.html"><img src="'+img_domain_front_url+'images/common/foot_btn02.gif" alt="이용약관"></a> ');
	document.writeln('			<a href="/common/rule.html"><img src="'+img_domain_front_url+'images/common/foot_btn03.gif" alt="사이트 운영원칙"></a> ');
	document.writeln('			<a href="/common/legalnotice.html"><img src="'+img_domain_front_url+'images/common/foot_btn04.gif" alt="책임의 한계와 법적 고지"></a> ');
	document.writeln('			<a href="/common/qna.html?mode=writeForm&gbn=tab06"><img src="'+img_domain_front_url+'images/common/foot_btn06.gif" alt="제안하기"></a> ');
	document.writeln('			<img src="'+img_domain_front_url+'images/common/foot_copy.gif" alt="(C) 2009 SNOW. ALL RIGHT RESERVED."> ');
	document.writeln('		</div> ');

	document.writeln('        	<div id="foot_ccl" class="mb10"> ');
	document.writeln('          	<p class="disin"></p><p class="disin"><a xmlns:cc="http://creativecommons.org/ns#" href="http://www.snow.or.kr" property="cc:attributionName" rel="cc:attributionURL">SNOW 홈페이지</a>의 <span xmlns:dc="http://purl.org/dc/elements/1.1/" href="http://purl.org/dc/dcmitype/MovingImage" rel="dc:type">&#51200;&#51089;&#47932;</span>&#51008; <a rel="license" href="/Tedx/">&#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;</p><span class="clear disn"></span> ');
	document.write('            </div>');
	document.write('            <p>This independent TEDx event is operated under license from TED.</p>');
	document.write('            <p>This is an independently organized TED event</p>');
	document.write('            <p>TEDxSoomyung은 TED로부터 라이센스를 통해 독립적으로 개최되는 행사입니다. </p>');
	document.write('            <p class="pb20">TEDxSookmyung은 독립적으로 운영되는 조직입니다.</p>');
	document.write('        	</div>');

	document.write('	</div> ');
	document.writeln('</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_snow' :
			location.href = '/common/findidpw.html';
			break;
		case 'findidpw' :
			nextUrl = 'http://club.sookmyung.ac.kr/jsps/member/idpass_inquiry_snow.jsp';
			window.open(nextUrl);
			break;
		case 'findid' :
			location.href = '/common/findidpw.html';
			//location.href = '/common/findid.html';
			break;
		case 'findid_sm' :
			nextUrl = 'http://club.sookmyung.ac.kr/jsps/member/idpass_inquiry_snow.jsp';
			window.open(nextUrl);
			break;
		case 'findpw' :
			location.href = '/common/findidpw.html';
			//location.href = '/common/findpw.html';
			break;
		case 'findpw_sm' :
			nextUrl = 'http://club.sookmyung.ac.kr/jsps/member/idpass_inquiry_phone_snow.jsp?p_search_fg=pwd&p_mbr_menu=4';
			window.open(nextUrl);
			break;
		case 'join' :
			location.href = '/common/join.html';
			break;
		case 'join_sm' :
			nextUrl = 'http://club.sookmyung.ac.kr/jsps/member/srch_user_snow.jsp';
			window.open(nextUrl);
			break;
		case 'myinfo' :
			nextUrl = '/Member/myInfoMdf.html';
			window.open(nextUrl);
			break;
		case 'pw' :
			nextUrl = 'http://club.sookmyung.ac.kr/jsps/mypage/myPassMdf_snow.jsp';
			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, ''));
		if (nextURL.indexOf('mode:') == 0) {
			var urlData = nextURL.split(':');
			changeModeUrl(urlData[1],urlData[2]);
		} else {
			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);
		if (msgtitle != null && msgtitle != '')
			txt.push('+ ' +msgtitle+'\r\n');
		if (msg != null && msg != '') {
			if (msgsubtitle != null && msgsubtitle != '')
				txt.push(msgsubtitle);
			if (msg != null && msg != msgsubtitle)
				txt.push(msg);
		} else if (msgsubtitle != null && msgsubtitle != '')
			txt.push(msgsubtitle);
		alert(txt.join('\r\n').replace(/<br\/?[^>]+>/gi, '\r\n').replace(/<\/?[^>]+>/gi, ''));
	}
}


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

function reloadUrl() {
		top.document.location.reload();
}

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;
		default :
			new cafen.Ajax(options || {}, ajaxCallEnd, (obj.getAttribute ? obj.getAttribute('href') : obj.href || null) || document.location.pathname , 'post');
			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) -70)+'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('div');
				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 = 'selectFile';
				selectObj.onchange = uploadFilePreview;
				selectObj.style.width = (checkboxObj.offsetWidth -230)+'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('div');
				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.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.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, onload_x) {
	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(onload_x==null) onload_x = false;
	if(onload_x) {
		lastPopup[level].onLoad(null, true, true);
	} else if (sticker != null) {
		lastPopup[level].onLoad({obj : sticker, x : 'left',y : 'bottom'}, true, false);
	}else {
		lastPopup[level].onLoad(null, true, false);
	}
}

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) {
	var self = (obj == null) ? this : obj;
	if (self[self.selectedIndex].value != '')
		document.location = self[self.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,
	zIndex : 1000,
	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'), this.zIndex, 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(this.zIndex);
	},
	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 , (obj != null) ? {obj:obj, x: 'exright',y: 'bottom'} : null, true);
	lastPopup[level].onLoad((obj != null) ? {obj:obj, x: 'exright',y: 'bottom'} : null, true);
}


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);
}

var oldLen = 0;
function checkLen(obj, id, len) {
	var hanLen = obj.value.length;
	var tmpObj = document.getElementById(id);
	if (tmpObj != null) {
		if ((hanLen +1 ) > len) {
			tmpObj.innerHTML = '<font color=red>'+hanLen +'</font>';
			if (hanLen  == len && oldLen < hanLen) {
				alert(len + '자까지 입력하실 수 있습니다');
				obj.blur();
			}
		}else
			tmpObj.innerHTML = hanLen;
		oldLen = hanLen;

	}
}


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;

	}
}

// 2009-12-28 추가
function checkLenHan2(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>';
			alert(len + 'byte까지 입력하실 수 있습니다');
			obj.value = hSubStr(obj.value,0,len);
			hanLen = getHanByte(obj.value);
			tmpObj.innerHTML = '<font color=red>'+hanLen +'</font>';
			obj.blur();			
		}else
			tmpObj.innerHTML = hanLen;
	}
}

// 2009-12-30 추가 에디트화면용
function checkLenHan3(obj, len) {
	var hanLen = getHanByte(obj.value);
	if (hanLen > len) {
		alert(len + 'byte까지 입력하실 수 있습니다');
		obj.value = hSubStr(obj.value,0,len);
		hanLen = getHanByte(obj.value);
		obj.blur();			
	}
}

// 2009-12-28 추가
function hSubStr(str, st, len) {
 var bHangul=0;
 var start = 0;
 var end = 0;
 var i, nlen;

 for(i=nlen=0; i<str.length; ++i) {
  if(nlen==len) return str.substr(st, i-st);
  else if(nlen>len) return str.substr(st, i-st-1);

  if(str.charCodeAt(st+i)>255) nlen += 2;
  else ++nlen;
 }

 return str;
}

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' : ''+attach_domain_url+'upload_fileswf.php',
	'uploadURL' : ''+attach_domain_url+'uploads/',
	'scripturl' : img_domain_url +'service2/',
	useImageEditor : true, useMediaPlayer : true,
	useFlashChart : true,
	attachAs : true,
	hl : 'ko'
}

/* URL복사 2009-12-16 추가 */
 function URLScrap()
 {
   var url = document.URL;
   window.clipboardData.setData("Text", url);
   alert("동영상정보 페이지 URL이 클립보드에 복사되었습니다.\nCtrl + V 하시면 URL이 입력됩니다.");

 }

 
 //**   컨텐츠 프린트 2010-01-07 추가   *//
function goPrint(scriptFlag){
	popup('/Member/print.html?'+scriptFlag,600,384,1);
}

// ** popup  2010-01-07 추가   *//
function popup(url,w,h,scroll,resize){
 if(scroll) w=w+17;
 if(!scroll) scroll='no'; if(!resize) resize='no';
 var winl=(screen.width-w)/2; var wint=(screen.height-h)/2;
 var winnameset=url.split('/'); var winname=winnameset[winnameset.length-1].split('.')[0];
 window.open(url,winname,'width='+w+',height='+h+',top='+wint+',left='+winl+',resizable='+resize+',scrollbars='+scroll+',toolbars=no,status=yes,menu=no');
}


/* 동영상 EmbedCode Source복사 2010-02-03 추가 */
function CopyToEmbededCode() {
	obj = null;
    //alert(document.all.mvembed.innerHTML);
	if(document.getElementById) obj=document.getElementById('mvembed_blog');

	if (obj) {
		window.clipboardData.setData('Text', obj.innerHTML);		
		//alert('동영상정보 Source Code가 클립보드에 복사되었습니다.\n\n원하는 부분에 CTRL + V로 붙혀넣기 하세요.');
		//showPopup(null, {mode:"xmlCopyEmbedCode"}, 550, document.getElementById("copy_to_embeded_code"));
		//showLectutePopup("xmlCopyEmbedCode");
		showPopup(null, {mode : "xmlCopyEmbedCode"}, null, document.getElementById('layerPos'));
	}
}

function hLen(str) {
	var len=0;
	for(var i=0; i<str.length; ++i)
		len += str.charCodeAt(i)>255? 2:1;

	return len;
}

function hSubStr(str, st, len) {
	var bHangul=0;
	var start = 0;
	var end = 0;
	var i, nlen;

	for(i=nlen=0; i<str.length; ++i) {
		if(nlen==len) return str.substr(st, i-st);
		else if(nlen>len) return str.substr(st, i-st-1);

		if(str.charCodeAt(st+i)>255) nlen += 2;
		else ++nlen;
	}

	return str;
}


var Base64 = {
 
	// private property
	_keyStr : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
 
	// public method for encoding
	encode : function (input) {
		var output = "";
		var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
		var i = 0;
 
		input = Base64._utf8_encode(input);
 
		while (i < input.length) {
 
			chr1 = input.charCodeAt(i++);
			chr2 = input.charCodeAt(i++);
			chr3 = input.charCodeAt(i++);
 
			enc1 = chr1 >> 2;
			enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
			enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
			enc4 = chr3 & 63;
 
			if (isNaN(chr2)) {
				enc3 = enc4 = 64;
			} else if (isNaN(chr3)) {
				enc4 = 64;
			}
 
			output = output +
			this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) +
			this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4);
 
		}
 
		return output;
	},
 
	// public method for decoding
	decode : function (input) {
		var output = "";
		var chr1, chr2, chr3;
		var enc1, enc2, enc3, enc4;
		var i = 0;
 
		input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
 
		while (i < input.length) {
 
			enc1 = this._keyStr.indexOf(input.charAt(i++));
			enc2 = this._keyStr.indexOf(input.charAt(i++));
			enc3 = this._keyStr.indexOf(input.charAt(i++));
			enc4 = this._keyStr.indexOf(input.charAt(i++));
 
			chr1 = (enc1 << 2) | (enc2 >> 4);
			chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
			chr3 = ((enc3 & 3) << 6) | enc4;
 
			output = output + String.fromCharCode(chr1);
 
			if (enc3 != 64) {
				output = output + String.fromCharCode(chr2);
			}
			if (enc4 != 64) {
				output = output + String.fromCharCode(chr3);
			}
 
		}
 
		output = Base64._utf8_decode(output);
 
		return output;
 
	},
 
	// private method for UTF-8 encoding
	_utf8_encode : function (string) {
		string = string.replace(/\r\n/g,"\n");
		var utftext = "";
 
		for (var n = 0; n < string.length; n++) {
 
			var c = string.charCodeAt(n);
 
			if (c < 128) {
				utftext += String.fromCharCode(c);
			}
			else if((c > 127) && (c < 2048)) {
				utftext += String.fromCharCode((c >> 6) | 192);
				utftext += String.fromCharCode((c & 63) | 128);
			}
			else {
				utftext += String.fromCharCode((c >> 12) | 224);
				utftext += String.fromCharCode(((c >> 6) & 63) | 128);
				utftext += String.fromCharCode((c & 63) | 128);
			}
 
		}
 
		return utftext;
	},
 
	// private method for UTF-8 decoding
	_utf8_decode : function (utftext) {
		var string = "";
		var i = 0;
		var c = c1 = c2 = 0;
 
		while ( i < utftext.length ) {
 
			c = utftext.charCodeAt(i);
 
			if (c < 128) {
				string += String.fromCharCode(c);
				i++;
			}
			else if((c > 191) && (c < 224)) {
				c2 = utftext.charCodeAt(i+1);
				string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
				i += 2;
			}
			else {
				c2 = utftext.charCodeAt(i+1);
				c3 = utftext.charCodeAt(i+2);
				string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
				i += 3;
			}
 
		}
 
		return string;
	}
 
}
