 
 
function spacexf(obj){
	if (obj.value == "" || obj.value.replace(/(^ +)|( +$)/g,'') == "" ){
		obj.value = "";
		return false;
	}
	return true;
}	
 
function checkChr(code) 
{   
	var codeStr = "8,37,38,39,40,46,48,49,50,51,52,53,54,55,56,57,96,97,98,99,100,101,102,103,104,105,106,";

	if(!(codeStr.indexOf(code+",")>-1))
	{
		alert("¼ýÀÚ¸¸ »ç¿ë°¡´ÉÇÕ´Ï´Ù.");
        event.returnValue = false; 
    }  
} 

function floatcheckChr(code) {   
 
    if(((code<48) || (code > 57)) && code != 46){   
        event.returnValue = false; 
    }  
} 


function disabled_object_set(obj,flag){
	var Tbool;
	Tbool = (flag) ? false:true;
	obj.disabled = Tbool; 
}


function validJumin(str)
{
     var Jumin = str.toString();
     a = Jumin.substring(0, 1);
     b = Jumin.substring(1, 2);
     c = Jumin.substring(2, 3);
     d = Jumin.substring(3, 4);
     e = Jumin.substring(4, 5);
     f = Jumin.substring(5, 6);
     g = Jumin.substring(6, 7);
     h = Jumin.substring(7, 8);
     i = Jumin.substring(8, 9);
     j = Jumin.substring(9, 10);
     k = Jumin.substring(10, 11);
     l = Jumin.substring(11, 12);
     m = Jumin.substring(12, 13);

     temp=a*2+b*3+c*4+d*5+e*6+f*7+g*8+h*9+i*2+j*3+k*4+l*5;
     temp=temp%11;
     temp=11-temp;
     temp=temp%10;
    
     if(temp == m)
        return true;
     else
        return false; 
}


var popup_win=0;
function open_window(url, width, height, scrollbars ){
	var a = screen.width;
	var b = screen.height;
	var aleft = a/2 - width/2;
	var atop = b/2 - height/2;
 
	if(scrollbars == null) scrollbars = "yes";
  
	if(popup_win)
		if(!popup_win.closed) popup_win.close();

	popup_win = open( url, "window_id", 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars='+scrollbars+',resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+aleft+', top='+atop+',screenX='+aleft+',screenY='+atop+'');
	popup_win.focus();
}

 


function autoCommaVal(cls) { 
	var moneyorg = cls.toString();  	
	var moneyorglen = moneyorg.length;
	 
//	if (moneyorg.substr(0,1) == "0")
//	{
//		moneyorg = moneyorg.substr(1,moneyorglen);
//	}
 
	moneyorglen--; 
	money = ""; 
	var moyo = ""; 
	var y = 0; 
	for (var x=moneyorglen; x>=0; x--){ 
		moyo = moneyorg.charAt(x);
		if (moyo != ","){ 
			if (y%3 == 0 && y != 0){ 
				money = moyo + "," + money 
				y++; 
			} else { 
				money = moyo + money;
				y++; 
			} 
		} 
	} 
	return money;
}

function autoComma(cls) { 
	var moneyorg = cls.value;
	var moneyorglen = moneyorg.length;
	if (moneyorg.substr(0,1) == "0")
	{
		moneyorg = moneyorg.substr(1,moneyorglen);
	}


	moneyorglen--; 
	money = ""; 
	var moyo = ""; 
	var y = 0; 
	for (var x=moneyorglen; x>=0; x--){ 
		moyo = moneyorg.charAt(x);
		if (moyo != ","){ 
			if (y%3 == 0 && y != 0){ 
				money = moyo + "," + money 
				y++; 
			} else { 
				money = moyo + money;
				y++; 
			} 
		} 
	} 
	cls.value = money;
} 
 

function commaNum(num) {  

        if (num < 0) { num *= -1; var minus = true} 
        else var minus = false 
         
        var dotPos = (num+"").split(".") 
        var dotU = dotPos[0] 
        var dotD = dotPos[1] 
        var commaFlag = dotU.length%3 

        if(commaFlag) { 
                var out = dotU.substring(0, commaFlag)  
                if (dotU.length > 3) out += "," 
        } 
        else var out = "" 

        for (var i=commaFlag; i < dotU.length; i+=3) { 
                out += dotU.substring(i, i+3)  
                if( i < dotU.length-3) out += "," 
        } 

        if(minus) out = "-" + out 
        if(dotD) return out + "." + dotD 
        else return out  
} 


function checkListCheckBox( form, box_name, check_limit ){

	var box_count = 0;
	var check_nums = form.elements.length;

	for( var i = 0; i < check_nums; i++ )
	{
		
		if( form.elements[i].checked == true && form.elements[i].name == box_name)
		{
			box_count++; 
		}
	}
  
	if( box_count <= 0 ){ 
		return false; 
	}
	else
	{

		return true;
	}
}

var allcheckbox = false;
function checkAllCheckbox( form, box_name )
{
 
	allcheckbox = !allcheckbox;

	for( var i = 0; i < form.length; i++ )
	{
		var e = form.elements[i];

		if(e.name == box_name)
		{
			e.checked = allcheckbox;
		}
	}

	return;
}
 
function checkAllCheckbox2( form, obj,box_name )
{
 
	var checkval = (obj.checked) ? 1 : 0 ;
 	
	for( var i = 0; i < form.length; i++ )
	{
		var e = form.elements[i];

		if(e.name == box_name)
		{
			e.checked = checkval;
		}
	}
	return;
}
  
function submitMultiCheckboxForm( form, url, boxName, noSelMsg, confirmMsg )
{
	var flag = checkListCheckBox( form, boxName, 0 );
	if( !flag  ){
		alert( noSelMsg );	}
	else{
 
		if(confirmMsg!="" && !confirm( confirmMsg ) ){
			return;
		}
 
		form.action = url;
		form.submit();
	}
}

function CheckPhoneFormat(date_value){    
	if(date_value.match(/\d{2}-\d{4}-\d{4}/g)==date_value || date_value.match(/\d{3}-\d{4}-\d{4}/g)==date_value || date_value.match(/\d{2}-\d{3}-\d{4}/g)==date_value || date_value.match(/\d{3}-\d{3}-\d{4}/g)==date_value) 
		return true;
	else 
		return false;	 
}

function CheckPhoneFormat2(date_value){    
	if(date_value.match(/\d{2}-\d{4}-\d{4}/g)==date_value || date_value.match(/\d{3}-\d{4}-\d{4}/g)==date_value || date_value.match(/\d{2}-\d{3}-\d{4}/g)==date_value || date_value.match(/\d{3}-\d{3}-\d{4}/g)==date_value || date_value.match(/\d{2}\d{4}\d{4}/g)==date_value || date_value.match(/\d{3}\d{4}\d{4}/g)==date_value || date_value.match(/\d{2}\d{3}\d{4}/g)==date_value || date_value.match(/\d{3}\d{3}\d{4}/g)==date_value) 
		return true;
	else 
		return false;	 
}

function setCookie(name, value, expiredays) {
	var todayDate = new Date();
	todayDate.setDate(todayDate.getDate() + expiredays);
	todayDate.setHours(0,0,0);
	document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + todayDate.toGMTString()+ ";"
}


// ÀÔ·Â°ªÀÌ ¼ýÀÚ °ü·ÃµÈ °ªÀÎÁö Ã¼Å©ÇÏ´Â ÇÔ¼ö
// ÆÄ¶ó¹ÌÅÍ ¼³¸í
// obj   : °ªÀ» °Ë»çÇÒ °´Ã¼ÀÇ ÀÌ¸§
// gubun : ±¸ºÐ°ª( 'only' = ¼ýÀÚ¸¸ Çã¶ô, 'comma' = ¼ýÀÚ¿Í ÄÞ¸¶¸¸ Çã¿ë, 'dot' = ¼ýÀÚ¿Í µµÆ®¸¸Çã¿ë)
// min   : ÃÖ¼Ò°ª, ³Î°ªÀÌ¸é ÃÖ¼Ò°ª ¾øÀ½
// max	 : ÃÖ´ë°ª, ³Î°ªÀÌ¸é ÃÖ´ë°ª ¾øÀ½
// ¿¹Á¦  : checkDigit(this, 'comma','4','') = °ªÀÌ ÄÞ¸¶¸¦ Çã¿ëÇÏ°í ÃÖ¼Ò°ªÀÌ 4ÀÌ»ó 
// ¿¹Á¦  : checkDigit(this, 'only','','') = °ªÀÌ ¼ýÀÚ¸¸À» Çã¿ëÇÏ°í °ª¿¡ Á¦ÇÑ ¾øÀ½
function checkDigit(obj,gubun,min,max) 
{
	var Digits;
	
	if (gubun == "comma") 
		Digits = "0123456789,";
	else if (gubun == "dot")
		Digits = "0123456789.";
	else if (gubun == "only")
		Digits = "0123456789";
		
	for (i = 0; i < obj.value.length; i++) 
	{
		NumberChar = obj.value.charAt(i);
		ChkFlag = false;
		for (j = 0; j < 11; j++) 
		{
			CompChar = Digits.charAt(j);
			if (NumberChar == CompChar) ChkFlag = true;
		}
		if (ChkFlag == false) 
		{
			var msg = "";
			
			if(gubun=='comma')		msg = "¼ýÀÚ¿Í ÄÞ¸¶(,)¸¸ °¡´ÉÇÕ´Ï´Ù.";
			else if(gubun=="dot")	msg = "¼ýÀÚ¿Í Dot(.)¸¸ °¡´ÉÇÕ´Ï´Ù.";
			else					msg = "¼ýÀÚ¸¸ °¡´ÉÇÕ´Ï´Ù.";
				

			alert(msg);
			obj.select();
			obj.focus();
			return false;
		}
	}
	
	if ((min != "") && (parseFloat(min) > parseFloat(obj.value))) 
	{
		alert("ÀÔ·Â°ªÀº ÃÖ¼Ò " + min + " ÀÌ»óÀÌ¾î¾ß ÇÕ´Ï´Ù.");
		obj.select();
		obj.focus();
		return false;
	}
	
	if ((max != "") && (parseFloat(max) < parseFloat(obj.value))) 
	{
		alert("ÀÔ·Â°ªÀº ÃÖ´ë " + max + " ÀÌÇÏÀÌ¾î¾ß ÇÕ´Ï´Ù.");
		obj.select();
		obj.focus();
		return false;
	}

	return true;
}  
 

function blank_int_check(obj,msg1,msg2){
	var pattern_number_list = /^[0-9]+$/; 

	if(!spacexf(obj)){
		alert(msg1+" ÀÔ·ÂÇÏ¼¼¿ä");
		obj.value="";
		obj.focus();
		return false;
	}
	else if(!pattern_number_list.test(obj.value)){
		alert(msg2+" ¼ýÀÚ·Î¸¸ ÀÔ·ÂÇÏ¼Å¾ßÇÕ´Ï´Ù.");
		obj.value="";
		obj.focus();
		return false;	 
	} 
	return true;	 
}

function ajax_href(url){     
	formDataSend("","GET",url,ajaxMsgReturn);	  
	
 }
 function ajaxMsgReturn(result){
	var msg=result.responseText;  
	document.getElementById("sp_main_panel").innerHTML = msg; 
 }	



function excel_chk(form,url){ 
	form.action=url;
	form.submit();
}

function frame_href(url,target){
	window.open(url,target);
}

function popView(what) 
{  
	var imgwin = window.open("",'WIN','scrollbars=no,status=no,toolbar=no,resizable=1,location=no,menu=no,width=10,height=10');  
	imgwin.focus();  
	imgwin.document.open();  

	imgwin.document.write("<html>");  
	imgwin.document.write("<head>");  
	imgwin.document.write("<title>Photo Preview</title>");  
	imgwin.document.write("<sc"+"ript>\n");  
	imgwin.document.write("function resize() {\n");  
	imgwin.document.write("pic = document.il;\n");  
	//imgwin.document.write("alert(eval(pic).height);\n");  
	imgwin.document.write("if (eval(pic).height) { var name = navigator.appName\n");  
	imgwin.document.write("  if (name == 'Microsoft Internet Explorer') { myHeight = eval(pic).height + 10; myWidth = eval(pic).width + 10;\n");  // 40 12
	imgwin.document.write("  } else { myHeight = eval(pic).height + 0; myWidth = eval(pic).width; }\n");  // 9
	imgwin.document.write("  clearTimeout();\n");  
	imgwin.document.write("  var height = screen.height;\n");  
	imgwin.document.write("  var width = screen.width;\n");  
	imgwin.document.write("  var leftpos = width / 2 - myWidth / 2;\n");  
	imgwin.document.write("  var toppos = height / 2 - myHeight / 2; \n");  
	imgwin.document.write("  self.moveTo(leftpos, toppos);\n");  
	imgwin.document.write("  self.resizeTo(myWidth+20, myHeight+20);\n");  
	imgwin.document.write("}else setTimeOut(resize(), 100);}\n");  
	imgwin.document.write("</sc"+"ript>");  
	imgwin.document.write("</head>");  
	imgwin.document.write('<body topmargin="0" leftmargin="0" marginheight="0" marginwidth="0" bgcolor="#FFFFFF">');  
	imgwin.document.write("<a href=# onclick=window.close() onfocus=this.blur()><img border=0 src="+what+" xwidth=100 xheight=9 name=il onload='resize();' alt='Å¬¸¯ÇÏ¸é ºê¶ó¿ìÁ®°¡ ´ÝÈü´Ï´Ù.'></a>");  
	imgwin.document.write("</body>");  
	imgwin.document.close();  
}  

function popViewSize(what,width,height)  
{  
	var imgwin = window.open("",'WIN','scrollbars=no,status=no,toolbar=no,resizable=1,location=no,menu=no,width='+width+',height='+height);  
	imgwin.focus();  
	imgwin.document.open();  

	imgwin.document.write("<html>");  
	imgwin.document.write("<head>");  
	imgwin.document.write("<title>Photo Preview</title>");  
	imgwin.document.write("<sc"+"ript>\n");  
	imgwin.document.write("function resize() {\n");  
	imgwin.document.write("pic = document.il;\n");  
	//imgwin.document.write("alert(eval(pic).height);\n");  
	imgwin.document.write("if (eval(pic).height) { var name = navigator.appName\n");  
	imgwin.document.write("  if (name == 'Microsoft Internet Explorer') { myHeight = eval(pic).height + 10; myWidth = eval(pic).width + 10;\n");  // 40 12
	imgwin.document.write("  } else { myHeight = eval(pic).height + 0; myWidth = eval(pic).width; }\n");  // 9
	imgwin.document.write("  clearTimeout();\n");  
	imgwin.document.write("  var height = screen.height;\n");  
	imgwin.document.write("  var width = screen.width;\n");  
	imgwin.document.write("  var leftpos = width / 2 - myWidth / 2;\n");  
	imgwin.document.write("  var toppos = height / 2 - myHeight / 2; \n");  
	imgwin.document.write("  self.moveTo(leftpos, toppos);\n");  
	imgwin.document.write("}else setTimeOut(resize(), 100);}\n");  
	imgwin.document.write("</sc"+"ript>");  
	imgwin.document.write("</head>");  
	imgwin.document.write('<body topmargin="0" leftmargin="0" marginheight="0" marginwidth="0" bgcolor="#FFFFFF">');  
	imgwin.document.write("<a href=# onclick=window.close() onfocus=this.blur()><img border=0 src='"+what+"' xwidth=100 xheight=9 name=il onload='resize();' alt='Å¬¸¯ÇÏ¸é ºê¶ó¿ìÁ®°¡ ´ÝÈü´Ï´Ù.'></a>");  
	imgwin.document.write("</body>");  
	imgwin.document.close();  
}  

