<!--
String.prototype.trim = function() {
  return this.replace(/(^\s*)|(\s*$)/gi, "");
}

String.prototype.popupView = function() {
    var img_view = this;
    var x = x + 20 ;
    var y = y + 30 ;
    htmlz = "<html><head><title>ÀÌ¹ÌÁöÅ©°Ôº¸±â</title><style>body{margin:0;cursor:pointer;}</style></head><body scroll=auto onload='width1=document.getElementById(\"Timage\").width;if(width1>1024)width1=1024;height1=document.getElementById(\"Timage\").height;if(height1>768)height1=768;top.window.resizeTo(width1+30,height1+54);' onclick='top.window.close();'><img src='"+img_view+"' title='Å¬¸¯ÇÏ½Ã¸é ´ÝÈü´Ï´Ù.' name='Timage' id='Timage'></body></html>";
    imagez = window.open('', "image", "width="+ 100 +", height="+ 100 +", top=0,left=0,scrollbars=auto,resizable=1,toolbar=0,menubar=0,location=0,directories=0,status=1");
    imagez.document.open();
    imagez.document.write(htmlz);
    imagez.document.close();
}

var Alpha = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
var Num   = '0123456789';
var AlphaNum = Alpha+Num;

function chkSelect(objectName, initIndex, msg, isSet) {
	var obj = eval('document.'+objectName);
	var isselect = false;

	for (var i = initIndex; i < obj.options.length; i++) {
		if (obj.options[i].selected == true) {
			isselect = true;
			break;
		}
	}

	if (isselect) return true;
	else {
		alert(msg);
		if (isSet == 'true') obj.focus();
		return false;	
	}
}

function chkEmail(objectName, limitByte, isSet) {
	var val = eval('document.'+objectName+'.value');

	if (!chkLength(objectName, 'ÀÌ¸ÞÀÏ', limitByte, isSet)) return false;
	if (val.length > 0) {
		var arrMatch = val.match(/^(\".*\"|[A-Za-z0-9_-]([A-Za-z0-9_-]|[\+\.])*)@(\[\d{1,3}(\.\d{1,3}){3}]|[A-Za-z0-9][A-Za-z0-9_-]*(\.[A-Za-z0-9][A-Za-z0-9_-]*)+)$/);
    		if (arrMatch == null) {
			alert('ÀÌ¸ÞÀÏÁÖ¼Ò°¡ ¿Ã¹Ù¸£Áö ¾Ê½À´Ï´Ù.\n´Ù½Ã È®ÀÎÇØÁÖ¼¼¿ä!');
			if (isSet == 'true') eval('document.'+objectName+'.focus();');
        		return false;
	    	}
	}
	
	return true;
}

function chkEmail2(objectName, limitByte, isSet) {
	var val = eval('document.'+objectName+'.value');

	if (!chkLength(objectName, 'ÀÌ¸ÞÀÏ', limitByte, isSet)) return false;
	if (val.length > 0) {
		var arrMatch = val.match(/^(\".*\"|[A-Za-z0-9_-]([A-Za-z0-9_-]|[\+\.])*)@(\[\d{1,3}(\.\d{1,3}){3}]|[A-Za-z0-9][A-Za-z0-9_-]*(\.[A-Za-z][A-Za-z_-]*)+)$/);
    		if (arrMatch == null) {
			alert('ÀÌ¸ÞÀÏÁÖ¼Ò°¡ ¿Ã¹Ù¸£Áö ¾Ê½À´Ï´Ù.\n´Ù½Ã È®ÀÎÇØÁÖ¼¼¿ä!');
			if (isSet == 'true') eval('document.'+objectName+'.focus();');
        		return false;
	    	}
	}
	
	return true;
}


function chkChar(objectName, msg, isSet) {
	var val = eval('document.'+objectName+'.value');

	for (i=0; i<val.length; i++) {
		if(Alpha.indexOf(val.substring(i,i+1))<0) {
			alert(msg+'Àß¸øµÈ ¹®ÀÚ°¡ ÀÖ½À´Ï´Ù\nÆ¯¼ö¹®ÀÚ´Â ÀÔ·ÂÇÒ ¼ö ¾ø½À´Ï´Ù');
			if (isSet == 'true') eval('document.'+objectName+'.focus();');
			return false;
		}
	}
	
	return true;
}

function chkCharNum(objectName, msg, isSet) {
	var val = eval('document.'+objectName+'.value');

	for (i=0; i<val.length; i++) {
		if(AlphaNum.indexOf(val.substring(i,i+1))<0) {
			alert(msg+'Àß¸øµÈ ¹®ÀÚ°¡ ÀÖ½À´Ï´Ù\nÆ¯¼ö¹®ÀÚ´Â ÀÔ·ÂÇÒ ¼ö ¾ø½À´Ï´Ù');
			if (isSet == 'true') eval('document.'+objectName+'.focus();');
			return false;
		}
	}
	
	return true;
}

function chkNum(objectName, msg, isSet) {
	var val = eval('document.'+objectName+'.value');

	for (i=0; i<val.length; i++) {
		if(Num.indexOf(val.substring(i,i+1))<0) {
			alert(msg+'Àß¸øµÈ ¼ýÀÚ°¡ ÀÖ½À´Ï´Ù\n¼ýÀÚ ÀÌ¿Ü ¹®ÀÚ´Â ÀÔ·ÂÇÒ ¼ö ¾ø½À´Ï´Ù');
			if (isSet == 'true') eval('document.'+objectName+'.focus();');
			return false;
		}
	}
	
	return true;
}
function chkRepeat(objectName, msg, limitCount, isSet) {
	var val = eval('document.'+objectName+'.value');
	var repeat = 0;
	var tmp_val;
	for (i=0; i<val.length; i++) {
		if(i>0){
			if(tmp_val==val.substring(i,i+1)){
				repeat = repeat+1;
				if(repeat>=limitCount){
					alert(msg+'¿Ã¹Ù¸£Áö ¾Ê½À´Ï´Ù.\n´Ù½Ã È®ÀÎÇØÁÖ¼¼¿ä!');
					if (isSet == 'true') eval('document.'+objectName+'.focus();');
					return false;
				}
			} else {
				repeat = 0;
			}
		}
		tmp_val = val.substring(i,i+1);
	}
	
	return true;
}
function chkPhone(objectName, isSet) {
	var val = eval('document.'+objectName+'.value');
		val = val.replace(/\-/gi,"");
	for (i=0; i<val.length; i++) {
		if(Num.indexOf(val.substring(i,i+1))<0) {
			alert('Àß¸øµÈ ¹øÈ£ÀÔ´Ï´Ù.\n¼ýÀÚ,- ÀÌ¿Ü ¹®ÀÚ´Â ÀÔ·ÂÇÒ ¼ö ¾ø½À´Ï´Ù.');
			if (isSet == 'true') eval('document.'+objectName+'.focus();');
			return false;
		}
	}
	if(val.length<9){
		alert('Àß¸øµÈ ¹øÈ£ÀÔ´Ï´Ù.\nÀüÈ­¹øÈ£ ÀÔ·ÂÀº Áö¿ª¹øÈ£ Æ÷ÇÔ 9ÀÚ ÀÌ»óÀÔ´Ï´Ù.');
		return false;
	}
	return true;
}

function chkKor(objectName, msg, isSet) {
	var val = eval('document.'+objectName+'.value');
	var len = val.length;
	var codeLen = 0;
	for (i=0; i<len; i++) 
		(val.charCodeAt(i) > 255)? codeLen+=2:codeLen++;
	if (len != codeLen) {
		alert(msg + ' ÇÑ±ÛÀº ÀÔ·ÂÇÒ ¼ö ¾ø½À´Ï´Ù');
		if (isSet == 'true') eval('document.'+objectName+'.focus();');
		return false;
	}
	return true;
}

function chkEng(objectName, msg, isSet) {
	var val = eval('document.'+objectName+'.value');
	var len = val.length;
	var codeLen = 0;
	for (i=0; i<len; i++) 
		(val.charCodeAt(i) > 255)? codeLen+=0:codeLen++;
	if (codeLen > 0) {
		alert(msg + ' ÇÑ±Û¸¸ ÀÔ·ÂÇÒ ¼ö ÀÖ½À´Ï´Ù');
		if (isSet == 'true') eval('document.'+objectName+'.focus();');
		return false;
	}
	return true;
}

function chkBlank(objectName, msg, isSet) {

	var val = eval('document.'+objectName+'.value');
	if (val.indexOf(' ') >= 0) {
		alert(msg+ ' °ø¹éÀÌ ¿Ã ¼ö ¾ø½À´Ï´Ù');
		if (isSet == 'true') eval('document.'+objectName+'.focus();');
		return false;
	}
	return true;
}

function chkLength(objectName, msg, limitByte, isSet) {

	var b = 0;
	var val = eval('document.'+objectName+'.value');
	var len = eval('document.'+objectName+'.value.length');
    	for (i=0; i<len; i++) b = (val.charCodeAt(i) > 255) ? b+2:b+1;

	if (b > limitByte) {
		alert(msg+' ÀÔ·ÂÀº '+limitByte+'byte ±îÁöÀÔ´Ï´Ù');
		if (isSet == 'true') eval('document.'+objectName+'.focus();');
		return false;
	}
	return true;
}

function chkMinLength(objectName, msg, limitByte, isSet) {

	var b = 0;
	var val = eval('document.'+objectName+'.value');
	var len = eval('document.'+objectName+'.value.length');
		for (i=0; i<len; i++) b = (val.charCodeAt(i) > 255) ? b+2:b+1;
	if (b < limitByte) {
		alert(msg+' ÀÔ·ÂÀº '+limitByte+'byte ÀÌ»óÀÔ´Ï´Ù');
		if (isSet == 'true') eval('document.'+objectName+'.focus();');
		return false;
	}
	return true;
}

function emailMinLength(objectName, limitByte, isSet) {

	var b = 0;
	var val = eval('document.'+objectName+'.value');
	var len = eval('document.'+objectName+'.value.length');
		for (i=0; i<len; i++) b = (val.charCodeAt(i) > 255) ? b+2:b+1;
	if (b < limitByte) {
		alert('ÀÌ¸ÞÀÏÁÖ¼Ò°¡ ¿Ã¹Ù¸£Áö ¾Ê½À´Ï´Ù.\n´Ù½Ã È®ÀÎÇØÁÖ¼¼¿ä!');
		if (isSet == 'true') eval('document.'+objectName+'.focus();');
		return false;
	}
	return true;
}

function chkValue(objectName, msg, isSet) {

	var val = eval('document.'+objectName+'.value');
	if (val.trim() == '') {
		alert(msg+' ÀÔ·ÂÇØÁÖ¼¼¿ä');
		if (isSet == 'true') eval('document.'+objectName+'.focus();');
		return false;
	}
	return true;
}

function chkBadContent(objectName, msg, badWord, isSet) {
	if (badWord == 'null' || badWord == '')
		return true;
	var val = eval('document.'+objectName+'.value');	
	var bad = badWord.split(";");
	for (var i = 0; i < bad.length; i++) {
		
		if (bad[i].trim().length > 0 && val.indexOf(bad[i]) > -1) {
			alert(msg+'¿¡ '+bad[i]+'¸¦ »ç¿ëÇÒ ¼ö ¾ø½À´Ï´Ù!');
			return false;
		}
	}
	return true;
}

function chkJumin(objectName1, objectName2) {
	var resiFirst = eval('document.'+objectName1+'.value');
	var resiLast = eval('document.'+objectName2+'.value');

	var chk = 0;
	var nYear   = resiFirst.substring(0,2);
	var nMondth = resiFirst.substring(2,4);
	var nDay    = resiFirst.substring(4,6);
	var nSex    = resiLast.charAt(0);

	for (i=0; i<resiFirst.length; i++) {
        	if(Num.indexOf(resiFirst.substring(i,i+1))<0) {
			alert('ÁÖ¹Îµî·Ï¹øÈ£ ¾ÕºÎºÐ¿¡ Àß¸øµÈ ¹®ÀÚ°¡ ÀÖ½À´Ï´Ù');
			eval('document.'+objectName1+'.focus();');
			eval('document.'+objectName1+'.select();');
			return false;
		}
	}
	for (i=0; i<resiLast.length; i++) {
        	if(Num.indexOf(resiLast.substring(i,i+1))<0) {
			alert('ÁÖ¹Îµî·Ï¹øÈ£ µÞºÎºÐ¿¡ Àß¸øµÈ ¹®ÀÚ°¡ ÀÖ½À´Ï´Ù');
			eval('document.'+objectName2+'.focus();');
			eval('document.'+objectName2+'.select();');
			return false;
		}
	}	
	
	if ( resiFirst.length!=6 ||  nMondth<1 || nMondth>12 || nDay<1 || nDay>31) {
		alert('ÁÖ¹Îµî·Ï¹øÈ£ ¾ÕºÎºÐ¿¡ Àß¸øµÇ¾ú½À´Ï´Ù');
		eval('document.'+objectName1+'.focus();');
		eval('document.'+objectName1+'.select();');
		return false;
	}
	
	if ( resiLast.length!=7 || (nSex!=1 && nSex!=2 && nSex!=3 && nSex!=4) ) {
		alert('ÁÖ¹Îµî·Ï¹øÈ£ µÞºÎºÐ¿¡ Àß¸øµÇ¾ú½À´Ï´Ù');
			eval('document.'+objectName2+'.focus();');
			eval('document.'+objectName2+'.select();');
		return false;
	}
	
	var i;
	for (i=0; i<6; i++) {
		chk += ( (i+2) * parseInt( resiFirst.charAt(i) ));
	}
	
	for (i=6; i<12; i++) {
		chk += ( (i%8+2) * parseInt( resiLast.charAt(i-6) ));
	}
	
	chk = 11 - (chk%11);
	chk %= 10;
	
	if (chk != parseInt( resiLast.charAt(6))) {
		alert('À¯È¿ÇÏÁö¾ÊÀº ÁÖ¹Îµî·Ï¹øÈ£ÀÔ´Ï´Ù!!');
		eval('document.'+objectName1+'.focus();');		
		return false;
	}
	return true;
}

function link(addr) {
	if (addr == 'login.do') {
		loginPreprocess('LOGIN');
		return;
	} else if (addr == 'logout.do') {
		loginPreprocess('LOGOUT');
		return;
	}
	
	var val = Math.floor(Math.random() * 100000000);
	if (addr.indexOf('&') > -1 || addr.indexOf('?') > -1) {
		addr = addr + '&m=' + val;
	} else {
		addr = addr + '?m='+ val;
	}
	
	window.open(addr, '_self');
}

function viewMyMessage(addr) {
	window.open(addr, '_blank', 'width=450, height=500');
}

function back() {
	window.history.back();
}

function loginPreprocess(flag) {
	var current = getCurrentpage();
	var t = document.commandForm;
	
	var cmd = '';
	current = (t.boardId.value.trim().length > 0 && t.boardNo.value.trim().length > 0? 'board-read.do':current);
	if (current == 'board-read.do') cmd = 'READ';	
	else if (current == 'board-edit.do') {
		if (document.setTransfer) 
			cmd = document.setTransfer.command.value;
	}

	t.beforeCommand.value = cmd;
	t.returnURI.value = current + getCurrentparameter();
	t.command.value = flag;
	t.action = flag.toLowerCase()+'.do';
	t.method = 'post';
	t.submit();
}

function getCurrentpage() {
	var temp = location.href;
	temp = temp.substring(temp.lastIndexOf('/')+1, temp.length);
	if (temp.lastIndexOf('?') > -1)
		temp = temp.substring(0, temp.lastIndexOf('?'));
		
	return temp;
}

function getCurrentparameter() {
	var temp = location.href;
	var current = getCurrentpage();
	if (temp.indexOf('?') > -1)
		temp = temp.substring(temp.lastIndexOf(current)+current.length, temp.length);
	else
		temp = '';
	return temp;
}

function imageResize() {
	var boardWidth = 650;
	if (document.setForm)
		boardWidth = document.setForm.boardWidth.value - 70;
	else if (document.setTransfer)
		boardWidth = document.setTransfer.boardWidth.value - 70;

	var obj = document.getElementsByName('unicornimage');
	for (var i = 0; i < obj.length; i++) {
		if (obj[i].width > boardWidth)
			obj[i].width = boardWidth;
	}
}

function pageQuery(q) {
        if(q.length > 1) this.q = q.substring(1, q.length);
        else this.q = null;
        this.keyValuePairs = new Array();
        if(q) {
                for(var i=0; i < this.q.split("&").length; i++) {
                        this.keyValuePairs[i] = this.q.split("&")[i];
                }
        }
        this.getKeyValuePairs = function() { return this.keyValuePairs; }
        this.getValue = function(s) {
                for(var j=0; j < this.keyValuePairs.length; j++) {
                        if(this.keyValuePairs[j].split("=")[0] == s)
                                return this.keyValuePairs[j].split("=")[1];
                }
                return -1;
        }
        this.getParameters = function() {
                var a = new Array(this.getLength());
                for(var j=0; j < this.keyValuePairs.length; j++) {
                        a[j] = this.keyValuePairs[j].split("=")[0];
                }
                return a;
        }
        this.getLength = function() { return this.keyValuePairs.length; }        
}
function Calen(obj) {
		var txtbox = "";
		if ( eval(obj).form == null ) {
				txtbox = eval(obj).name;
		} else {
				txtbox = eval(obj).form.name + "." + eval(obj).name;
		}
		if ( eval(txtbox).disabled == true ) return false;
		Xpos = event.clientX - 90;
		Ypos = event.clientY + 130;
		if ( Ypos > 550 ) Ypos = Ypos - 250;
		var tmpstr = "dialogTop:" + Ypos + "; dialogLeft:" + Xpos + "; dialogWidth:290px; dialogHeight:230px; resizable:no; status:no;help:no;center:no" ;
		var ret = window.showModalDialog("/jsp/calenDlg.html", eval(txtbox).value, tmpstr );
		if (ret == null || ret == 'closed') return;
		eval(txtbox).value = ret;
}

var isChecked = true;
function changeChecked() {
	for (var i=0;i<document.forms.length;i++) {
	obj = document.forms[i].elements;
		for (var j=0;j<obj.length;j++) {
			if (obj[j].type=="checkbox") {
				if(isChecked == true){
					obj[j].checked = true;
 				}else{
					obj[j].checked = false;
 				}
			}
		}
	}
	if(isChecked == true){
		isChecked = false;
	}else{
		isChecked = true;
	}
}
//-->
