
var img_domain_url = 'http://image.snow.or.kr/';
var attach_domain_url = 'http://attach.snow.or.kr/';

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 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 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 checkSelectList(obj) {
	if (obj.className == 'on')
		obj.className = '';
	else
		obj.className = 'on';
}

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 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());
}

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 changeURLObject(obj, base_url) {
	document.location.href = base_url +'?'+obj.getAttribute('name') +'=' +obj[obj.selectedIndex].value;
}

var loginPopup = null;


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) {
	if (level == null)
		level = basePopupLevel;
	if (callURL == null)
		callURL= document.location.pathname;
	if (lastPopup[level] == null) {
		lastPopup[level] = new cafen.XFaceBox({className :'', tplName : '', attribute :{className : 'popupLayer'}, hideClose:true, title : '알림',ajax_url : callURL, ajax_data : param || {}, style : {zIndex : level}});
	}else
		lastPopup[level].loadAjax(callURL, param || {});
	if (sticker != null) {
		lastPopup[level].onLoad({obj : sticker, x : 'left',y : 'bottom'}, true);
	}else
		lastPopup[level].onLoad(null, true);
}

function hidePopup(level, bl) {
	if (level == null)
		level = (bl) ? basePopupLevel+100 : basePopupLevel;
	if (lastPopup[level] != null)
		lastPopup[level].close();
}

function goSelectedUrl(obj) {
	var self = (obj == null) ? this : obj;
	if (self[self.selectedIndex].value != '')
		document.location = self[self.selectedIndex].value;
}

function calObject() {
	this._className = 'calObject';
}


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());
	},
	moveNextYear : function() {
		this.showMonth(this._currentData.getFullYear()+1, this._currentData.getMonth() + 1);
	},
	movePrevYear : function() {
		this.showMonth(this._currentData.getFullYear()-1, this._currentData.getMonth() + 1);
	},
	clearMonth : function() {},
	getMonthYear : function() {
		return this._currentData.getFullYear() +'/' + this.getMonth();
	},
	getYear : function() {
		return this._currentData.getFullYear();
	},
	getMonth : function() {
		var month = this._currentData.getMonth() +1;
		return (month > 9) ? month : '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('<table border="0" cellpadding="1" cellspacing="1" width=100%>');
		html.push('<tr><td>');
		html.push('<a href="javascript:'+this._className+'.movePrevYear()">&lt;</a> '+this.getYear()+' <a href="javascript:'+this._className+'.moveNextYear()">&gt;</a>');
		html.push(' / ');
		html.push('<a href="javascript:'+this._className+'.movePrev()">&lt;</a> '+this.getMonth()+' <a href="javascript:'+this._className+'.moveNext()">&gt;</a>');
		html.push('</td></tr>');
		html.push('</table>');
		html.push('<table border="0" cellpadding="1" cellspacing="1" 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(''),''), 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;
			if (txt.indexOf('/') > 0 || txt.indexOf('.') > 0) {
				var year = txt.substring(0, 4);
				this._baseDate.setFullYear(year);
				var month = parseInt(txt.substring(5, 7));
				this._baseDate.setMonth(month-1);
				var day = parseInt(txt.substring(8, 10));
				this._baseDate.setDate(day);
			} else {
				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 :
				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;
	}
}

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 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');
	}
}


