////////////////////////////////////////////////
//¿¡·¯Ãâ·Â
function err_proc(err, msg) {
	var tt="";
	if(msg.length > 0){
		alert(msg);
	}
//alert(err.type);
	if(err){
		tt=err.type;
		if(tt=="select-multiple" || tt=="select-one"){
			err.focus();
			err[0].selected=true;
		}else if(tt=="hidden"){
			// ¿¹¿Ü
		}else{
			err.focus();
			err.select();
		}
/*
button
checkbox
file
hidden
image
password
radio
reset
select-multiple
select-one
submit
text
textarea
*/

	}

	return false;
}


// Ã¼Å©/¶óµð¿À ¼±ÅÃ Ã¼Å©
function empty_check(obj){
	if(obj.length){
		for(i=0; i<obj.length; i++){
			if(obj[i].checked && !obj[i].disabled){	return false;	}
		}
	}else{
		if(obj.checked && !obj.disabled){	return false;	}
	}
	return true;
}


// select box Ã¼Å©
function empty_selected_value(obj){
	for(i=0; i<obj.length; i++){
		if(obj[i].selected && obj[i].value){
			return false;
		}
	}
	return true;
}


//¸ÞÀÏ Ã¼Å©
function check_email(obj, email){
	if(check_mail(email)){
		return true;
	}else{
		alert("ÀÌ¸ÞÀÏ Çü½ÄÀÌ Æ²¸³´Ï´Ù");
		obj.value = "";
		obj.focus();
		return false;
	}
}

//¸ÞÀÏ Ã¼Å©
function check_mail(val) {
	var cnt = 0;
	for (i = 0; i < val.length; i++)
		if(val.charAt(i) == '@' ) 
			cnt++
		if(cnt != 1)
			return false;     
		else if (val.indexOf("@") < 3) 
			return false;
		else if(val.length - val.substr(0, val.indexOf("@")).length == 0 )
			return false;
		else if(val.search(/(\S+)@(\S+)\.(\S+)/) == -1 )
			return false;
		else 
			return true;
}

// °ø¹éÀ» Ã¼Å©
function check_space(str){
	if(str.value.indexOf(" ") != -1){
		return true;
	}
}
// replace
function es_replace(str, val, val2){
	var sss="";
	var i=0;
	if(str){
		for(i=0;i<str.length;i++){
			if(str.substr(i,1)==val){
				sss+=val2;				
			}else{
				sss+=str.substr(i,1);
			}
		}
	}
	return sss;
}

// ÀüÈ­¹øÈ£/ÈÞ´ëÆù/ÆÑ½º Ã¼Å©
function check_tel(){
	var arr_val = Array("1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "-");
	for(i=0; i<arr_val.length; i++){
		if(String.fromCharCode(window.event.keyCode) == arr_val[i]){
			return true;
		}
	}
	return false;
}

// ¼ýÀÚ Ã¼Å©
function check_num(){
	var arr_val = Array("1", "2", "3", "4", "5", "6", "7", "8", "9", "0");
	for(i=0; i<arr_val.length; i++){
		if(String.fromCharCode(window.event.keyCode) == arr_val[i]){
			return true;
		}
	}
	return false;
}



//ÅÂ±×¹× (')¹®ÀÚ ¸·±â
function check_tag(val){
	for(i=0; i<val.value.length; i++){
		if(val.value.charAt(i) == "<" || val.value.charAt(i) == ">" || val.value.charAt(i) == "'"){
			alert("¹®ÀÚ (), (>), (')´Â »ç¿ëÇÒ¼ö ¾ø½À´Ï´Ù!");
			val.value = val.value.substr(0, i);
			return false;
		}
	}
}



// ¼ýÀÚ Ã¼Å©
function isNumeric(s) {
        for (i=0; i<s.length; i++) {
                c = s.substr(i, 1);
                if (c < "0" || c > "9") return false;
        }
        return true;
}


// ³¯Â¥ Ã¼Å©
function isYYYYMMDD(y, m, d) {
        switch (m) {
        case 2:        // 2¿ùÀÇ °æ¿ì
                if (d > 29) return false;
                if (d == 29) {
                        // 2¿ù 29ÀÇ °æ¿ì ´çÇØ°¡ À±³âÀÎÁö¸¦ È®ÀÎ
                        if ((y % 4 != 0) || (y % 100 == 0) && (y % 400 != 0))
                                return false;
                }
                break;
        case 4:        // ÀÛÀº ´ÞÀÇ °æ¿ì
        case 6:
        case 9:
        case 11:
                if (d == 31) return false;
        }
        // Å« ´ÞÀÇ °æ¿ì
        return true;
}

// ÁÖ¹Î¹øÈ£
function isSSN(s1, s2) {
        n = 2;
        sum = 0;
        for (i=0; i<s1.length; i++)
                sum += parseInt(s1.substr(i, 1)) * n++;
        for (i=0; i<s2.length-1; i++) {
                sum += parseInt(s2.substr(i, 1)) * n++;
                if (n == 10) n = 2;
        }
        c = 11 - sum % 11;
        if (c == 11) c = 1;
        if (c == 10) c = 0;
        if (c != parseInt(s2.substr(6, 1))) return false;
        else return true;
}

// »ç¾÷ÀÚµî·Ï¹øÈ£ Ã¼Å©
function check_busino(vencod) {
	var sum = 0;
	var getlist =new Array(10);
	var chkvalue =new Array("1","3","7","1","3","7","1","3","5");
	for(var i=0; i<10; i++) { getlist[i] = vencod.substring(i, i+1); }
	for(var i=0; i<9; i++) { sum += getlist[i]*chkvalue[i]; }
	sum = sum + parseInt((getlist[8]*5)/10);
	sidliy = sum % 10;
	sidchk = 0;
	if(sidliy != 0) { sidchk = 10 - sidliy; }
	else { sidchk = 0; }
	if(sidchk != getlist[9]) { return false; }
	if(!vencod) { return false; }
	return true;
}



// ??
function isLeapYear(y) {
	if (y < 100)	y = y + 1900;
	if ( (y % 4 == 0) && (y % 100 != 0) || (y % 400 == 0) ) {
		return true;
	} else {
		return false;
	}
}
// ??
function getNumberOfDate(yy, mm) {
	month = new Array(29,31,28,31,30,31,30,31,31,30,31,30,31);
	if (mm == 2 && isLeapYear(yy)) mm = 0;
	return month[mm];
}


// preview
function es_open_view(url){
	kk = window.open('','kk','width=500,height=500,scrollbars,resizable');
	kk.document.write("<body  topmargin=0 leftmargin=0 onLoad='window.resizeTo(document.all.kk.width+60,document.all.kk.height+95);'>");
	kk.document.write("<table width=100% height=100%><tr><td align=center><img id=kk src='" + url + "' style='cursor:hand;border:solid 1 #eeeeee;' onClick=self.close();></td></tr></table>");
	kk.document.write("</body>");
	kk.document.close();
	
}

// preview -> print
function es_open_print(url){
	kk = window.open('','kk','width=500,height=500,scrollbars,resizable');
	kk.document.write("<body  topmargin=0 leftmargin=0 onLoad='window.resizeTo(document.all.kk.width+60,document.all.kk.height+95);window.print();'>");
	kk.document.write("<table width=100% height=100%><tr><td align=center><img id=kk src='" + url + "' style='cursor:hand;border:solid 0 #eeeeee;' onClick=self.close();></td></tr></table>");
	kk.document.write("</body>");
	kk.document.close();
	
}



// ¸Å°³º¯¼ö·Î ³Ñ¾î¿Â °³Ã¼ »©°í ´Ù disabled ///////////
// not_disable_obj(form, "mode", "id", "page");
function not_disable_obj(form){
	var arg = not_disable_obj.arguments;
	for(i=0; i<form.length; i++){
		kk =0;
		for(j=1; j<arg.length; j++){	// j=0Àº form;
			if(form[i].name == arg[j]){
				kk = 1;
				continue;
			}
		}
		if(!kk){
			form[i].disabled = true;
		}
	}
	
}


// HiddenFrame ¸¸µé±â
function createHiddenFrame(){
	var zone = "hiddenZone";
	var frame = "hiddenFrame";
	var _name = createHiddenFrame.arguments;
	if(_name.length > 1){
		zone = _name[0];
		frame = _name[1];
	}

	if(typeof(eval("document.all." + frame))!="object"){
		var frame_str = "<iframe name='" + frame + "' width=100% height=150px style='display:none'></iframe>";
		var frame_obj = document.createElement(frame_str);
		var zone_obj = eval(zone);
		zone_obj.insertAdjacentElement("BeforeEnd", frame_obj);
	}
}

// select ¹Ú½º·Ñ default select ¹Ù²ãÁÜ
function default_select(obj){
	for(i=0; i<obj.length; i++){
		if(obj[i].defaultSelected){
			obj[i].selected = true;
			return true;
		}
	}
}
// radio default cheked
function default_checked(obj){
	for(i=0; i<obj.length; i++){
		if(obj[i].defaultChecked){
			obj[i].checked = true;
		}
	}
}

// Å°°ª Ã¼Å©
function check_key(key, keys){
	var arr = keys.split("|");
	for(i=0; i<arr.length; i++){
		if(arr[i]==key){
			return true;
		}
	}
	return false;
}

// ¿ÀÇÁÁ§Æ®»ç¿ë/¹Ì»ç¿ë
function use_obj(obj, use, view){
	if(use){
		obj.disabled = false;
		obj.style.backgroundColor = "";
		obj.style.display = "inline";
	}else{
		obj.disabled = true;
		obj.style.backgroundColor = "#aaaaaa";
		obj.style.display = "none";
	}
	if(view){
		obj.style.display = view;
	}
}

// Ã¼Å©¹Ú½º °ª
function checkbox_result(cbox){
	var str = "";
	if(cbox.length){
		for(i=0; i<cbox.length; i++){
			if(cbox[i].checked && cbox[i].value){
				str += cbox[i].value + "|";
			}
		}
	}else{
		if(cbox.checked && cbox.value){
			str = cbox.value + "|";
		}
	}
	if(str){
		str = str.substr(0, str.length-1);
	}
	return str;
}

// ¶óµð¿À °ª
function radio_result(cbox){
	var str = "";
	for(i=0; i<cbox.length; i++){
		if(cbox[i].checked){
			str = cbox[i].value;
			break;
		}
	}
	return str;
}

// ÀüÃ¼¼±ÅÃ/ÀüÃ¼ÇØÁ¦
function _es_all_select(uids,chk){
	var kk = "";
	if(uids){
		if(chk.checked){
			cc = true;
		}else{
			cc = false;
		}
		if(uids.length){
			for(i=0; i<uids.length; i++){
				uids[i].checked = cc;
			}
		}else{
			uids.checked = cc;
		}
	}
}

// ¾÷·Îµå °¡´É È®ÀåÀÚ Ã¼Å©
// exts Çã¿ë ÆÄÀÏ ¸®½ºÆ®	exts="JPG|JPEG|GIF|PNG|SWF";
function check_upload_ext(file,exts){
	var ext=file.value.substr(file.value.lastIndexOf(".")+1);
	var chk=0;
	var able_file="";
	ext = ext.toUpperCase();
	__exts=exts.split("|");
	
	for(i=0;i<__exts.length;i++){	// ¸àÆ® ÆÄÀÏ¸í
		able_file+=__exts[i];
		if(i<(__exts.length-1)){
			able_file+=", ";
		}
	}
	for(i=0;i<__exts.length;i++){
		if(ext==__exts[i].toUpperCase()){
			chk=1;
		}
	}
	if(chk==0){	// ºÒ°¡´É
		file.focus();
		file.select();
		alert(able_file+" ÆÄÀÏ¸¸ ¾÷·Îµå °¡´ÉÇÕ´Ï´Ù.");
		return false;
	}else{
		return true;
	}
}

// ¾÷·Îµå °¡´É È®ÀåÀÚ Ã¼Å©2
// exts Çã¿ë ÆÄÀÏ ¸®½ºÆ®2	exts="JPG|JPEG|GIF|PNG|SWF";
function check_upload_ext2(file,exts){
	var ext=file.value.substr(file.value.lastIndexOf(".")+1);
	var chk=0;
	var able_file="";
	ext = ext.toUpperCase();
	__exts=exts.split("|");
	
	for(i=0;i<__exts.length;i++){	// ¸àÆ® ÆÄÀÏ¸í
		able_file+=__exts[i];
		if(i<(__exts.length-1)){
			able_file+=", ";
		}
	}
	for(i=0;i<__exts.length;i++){
		if(ext==__exts[i].toUpperCase()){
			chk=1;
		}
	}
	if(chk==0){	// ºÒ°¡´É
		//file.focus();
		//file.select();
		//alert(able_file+" ÆÄÀÏ¸¸ ¾÷·Îµå °¡´ÉÇÕ´Ï´Ù.");
		return false;
	}else{
		return true;
	}
}





// ¸¶¿ì½º ¿À¹ö ///////////////////////////////////////////////////////////////////////
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


//ÄíÅ°°ªÀ» °¡Á®¿À´Â ÇÔ¼ö ///////////////////////////////////////////////////////////////////////
function getCookie(name){
	var from_idx = document.cookie.indexOf(name+'=');
	if (from_idx != -1) { 
		from_idx += name.length + 1
		to_idx = document.cookie.indexOf(';', from_idx) 			

		if (to_idx == -1) {
			to_idx = document.cookie.length
		}
		return unescape(document.cookie.substring(from_idx, to_idx))
	}
}

//¼³Á¤ÇÑ ³¯Â¥¸¸Å­ ÄíÅ°°¡ À¯ÁöµÇ°Ô. expiredays°¡ 1ÀÌ¸é ÇÏ·çµ¿¾È À¯Áö//////////////////////////////
function setCookie(name, value, expiredays){
	var expire_date = new Date();
	expire_date.setDate(expire_date.getDate() + expiredays );
	document.cookie = name + "=" + escape( value ) + "; expires=" + expire_date.toGMTString() + "; path=/";
 }

//ÄíÅ° ¼Ò¸ê ÇÔ¼ö ////////////////////////////////////////////////////////////////////////////////////////////////
function clearCookie(name){
	var expire_date = new Date();
	//¾îÁ¦ ³¯Â¥¸¦ ÄíÅ° ¼Ò¸ê ³¯Â¥·Î ¼³Á¤ÇÑ´Ù.
	expire_date.setDate(expire_date.getDate() - 10);
	document.cookie = name + "= " + "; expires=" + expire_date.toGMTString() + "; path=/";
}



function bluring() {
 if(event.srcElement.tagName=="A" || event.srcElement.tagName=="IMG" || event.srcElement.tagName=="AREA")
  document.body.focus();
}
document.onfocusin=bluring;


// ÀÌ¹ÌÁö »èÁ¦ ¹öÆ°
function disabled_check(obj){
	if(obj.disabled){
		obj.disabled = false;
		obj.style.backgroundColor="white";
	}else{
		obj.disabled = true;
		obj.style.backgroundColor="#aaaaaa";
	}
}



// mnt box º¸ÀÌ±â/°¨Ãß±â
function mnt_view_hidden(view,mnt,top,left,width,height){
//alert(document.body.scrollTop);
	var obj=document.all.mnt;
	var obj2=document.all.mnt_mnt;
	if(view=="view"){
		obj2.innerHTML=mnt;
		obj.style.visibility="visible";
		obj.style.width=width;
		obj.style.height=height;

		obj.style.top=top;
		obj.style.left=left;
	}else{
		obj.style.visibility="hidden";
		obj.style.width=1;
		obj.style.height=1;
		obj.style.top=-100;
		obj.style.left=-100;
	}
}













