//============ »çÀÌÆ® °øÅë Å¬¶óÀÌ¾ðÆ® ½ºÅ©¸³Æ® =============================================

function nextVal(ths,nxt,flag)
{
	if(ths.value.length == flag)
	{
		nxt.focus();
		return
	}
}

//============= ÆÄÀÏ´Ù¿î·Îµå ÇÔ¼ö
function getDownLoad(flag,fileURL)
{
	var url='../download/downLoad.jsp?downItem='+flag+'&fileURL='+fileURL;
	window.open(url,'fileDown','width=575, height=450, scrollbars=yes');
	return false;
}


//============= ¶óµð¿À¹Ú½º Ã¼Å©
function chkRadio(field,name)
{
	var sum=0;
	for(i=0;i<field.length;i++)
	{
		if(field[i].checked==true)
		{
			++sum;
		}
	}
	if(sum==0)
	{
		alert(name+'¸¦ ÇÏ³ª¶óµµ Ã¼Å©ÇØ ÁÖ½Ê½Ã¿À');
		return false;
	}
	return true;
}
	

//============= ¿µ¹®ÀÚ¿Í ¼ýÀÚ ÀÔ·Â Ã¼Å© =========================================
function isEng(field, name) { 
 	var valid = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_';
 	var temp; 
 	
 	for (var i=0; i<field.value.length; i++) { 
 		temp = '' + field.value.substring(i, i+1); 
 		if (valid.indexOf(temp) == "-1") {
 		    alert( name + '¶õÀº ¿µ¹® ¶Ç´Â ¼ýÀÚ·Î¸¸ ÀÔ·ÂÇØ ÁÖ¼¼¿ä.'); 
 		    field.value='';
			field.focus(); 
 		    return false; 
 		}
   	} 
   return true; 
}

//¼ýÀÚÀÎÁö °Ë»ç
function justNum(field) { 
 	var valid = '0123456789';
 	var cnt = 0;
 	var temp; 
 	for (var i=0; i<field.value.length; i++) { 
 		temp = '' + field.value.substring(i, i+1); 
 		if (valid.indexOf(temp) == "-1")  cnt++;
    	} 
   return cnt; 
}

//¼ýÀÚ¸¸ ÀÔ·Â¹Þ´Â Æû Ã¼Å©

function isNum(field, name) { 
	var valid = '0123456789-.';
	var temp; 

	for (var i=0; i<field.value.length; i++) { 
		temp = '' + field.value.substring(i, i+1); 
		if (valid.indexOf(temp) == "-1") {
			alert(name + '¶õÀº ¼ýÀÚ·Î¸¸ ÀÔ·ÂÇØ ÁÖ¼¼¿ä.'); 
			field.value='';
			field.focus(); 
			return false; 
		}
	} 
return true; 
}

//¼¿·ºÆ® ¹Ú½º ³Î°ª Ã¼Å©
function isSel(f,n) {
	if(f.options[f.selectedIndex].value=='' || f.selectedIndex<0) {
	alert( n + '¶õÀ» ¼±ÅÃÇØ ÁÖ¼¼¿ä.'); 
	f.focus();
	return false;
	}
	else return true;
}

//°ø¹é Æû Ã¼Å©
function isNull(field, name) { 
	if (null != field)
	{	
		if (field.value == '') { 
		 alert(name + '¶õÀ» ÀÔ·ÂÇØ ÁÖ¼¼¿ä.'); 
		 field.focus(); 
		 return false; 
		}
	}
	return true; 
}


//E-mail°Ë»çÇÏ´Â ½ºÅ©¸³Æ®
function isValidEmail(f,n) {
  if(isEmail(f.value)==false) {
   alert( n + '¶õÀ» ¹Ù¸£°Ô ÀÔ·ÂÇØ ÁÖ¼¼¿ä.'); 
   f.value='';
   f.focus();
   return false;
  }
  else return true;
 }


 //ÀÌ¸ÞÀÏ Á¤±Ô½Ä °Ë»ç
 function isEmail( email ) {
	var fmt3 = /^[-!#$%&\'*+\\./0-9=?A-Z^_a-z{|}~]+@[-!#$%&\'*+\\/0-9=?A-Z^_a-z{|}~]+\.[-!#$%&\'*+\\./0-9=?A-Z^_a-z{|}~]+$/;
	if(!fmt3.test(email)) return false;
    else return true;	
 }
	
	
 
 //ÁÖ¹Îµî·Ï¹øÈ£ Ã¼Å©
 function checkJumin(f_01,f_02) 
 { 		

	// Á¤»óÀûÀ¸·Î °´Ã¼ Á¤º¸°¡ ³Ñ¾î ¿ÓÀ¸¸é, Ã³¸®ÇÔ
	if( (null != f_01) && (null != f_02) )
	{
		 
		if(f_01.value=='') 
		{
				 
			alert('ÁÖ¹Îµî·Ï¹øÈ£¸¦ ÀÔ·ÂÇØ ÁÖ½Ê½Ã¿ä.');
				 
			f_01.focus();
				 
			return false;
			 
		}

			 
		if(f_02.value=='') 
		{
				 
			alert('ÁÖ¹Îµî·Ï¹øÈ£¸¦ ÀÔ·ÂÇØ ÁÖ½Ê½Ã¿ä.');
				 
			f_02.focus();
				 
			return false;
			 
		}

	 
		if(f_01.value.length<6 || f_02.value.length<7) 
		{
				 
			alert('ÁÖ¹Îµî·Ï¹øÈ£¿¡ ¿À·ù°¡ ÀÖ½À´Ï´Ù. ´Ù½Ã È®ÀÎÇÏ¿© ÁÖ½Ê½Ã¿À.');
				 
			f_01.value='';
				 
			f_02.value='';
				 
			f_01.focus();
				 
			return false;
			 
		}

/*
		var rn=f_01.value+f_02.value;
			 
		var sum=0;
			 
		for(i=0;i<8;i++) 
		{ 
			sum+=rn.substring(i,i+1)*(i+2); 
		}
			 
		for(i=8;i<12;i++) 
		{ 
			sum+=rn.substring(i,i+1)*(i-6); 
		}
			 
		sum=11-(sum%11);

			 
		if(sum>=10) sum-=10;
			 
		if(rn.substring(12,13)!=sum || (rn.substring(6,7)!=1 && rn.substring(6,7) != 2)) 
		{
				 
			alert('ÁÖ¹Îµî·Ï¹øÈ£¿¡ ¿À·ù°¡ ÀÖ½À´Ï´Ù. ´Ù½Ã È®ÀÎÇÏ¿© ÁÖ½Ê½Ã¿À.');
				 
			f_01.value='';
				 
			f_02.value='';
				 
			f_01.focus();
				 
			return false;
			 
		}

	*/		 
	/*	if(f_01.value.length==6) 
		{
			  
			var today=new Date();
			  
			var toyear=parseInt(today.getYear());
			  
			var tomonth=parseInt(today.getMonth()) + 1;
			  
			var todate=parseInt(today.getDate());
			  
			var bhyear=parseInt('19'+f_01.value.substring(0,2)); 
			  
			var ntyear=f_02.value.substring(0,1);
			  
			var bhmonth=f_01.value.substring(2,4); 
			  
			var bhdate=f_01.value.substring(4,6); 
			  
			var birthyear=toyear-bhyear;
			 
		} */
		
	}	 
	return true;
}


// ========== Ã¼Å©¹Ú½º ÀüÃ¼¼±ÅÃ/ÇØÁ¦ =========================================== 
// »ç¿ë¹ý: CHK_ALL(this.form)
//         <input type=checkbox name=CHKALL  onclick='CHK_ALL(this.form);'>
//         <INPUT TYPE='CHECKBOX' NAME='CHK_ALL[]' VALUE='value'>
function CHK_ALL(form) 
{
	var f= document.form;

	if(f['CHK_ALL[]'].length) 
	{
		for(i = 0; i < f['CHK_ALL[]'].length; i++) 
		{
			f['CHK_ALL[]'][i].checked = f.CHKALL.checked;
		}
	}
	else
	{
		f['CHK_ALL[]'].checked = f.CHKALL.checked;
	}

}


//============ ¿ÀÇÂÀ©µµ¿ì¿ë ====================================================
function openWin(flag)
{
	if(flag == 'id')
	{
		var url = '/members/findId.jsp';
		var width=350;
		var height=225;
	}
	if(flag == 'zip')
	{
		var url = '/admin/memberManage/findZipCode.jsp';
		var width=500;
		var height=250;
	}

	window.open(url,flag,'width='+width+',height='+height+',toolbars=no,scrollbars=no,resize=no');
	return false;
}

function popup(url, width, height){
	var dt = new Date();
	var id = "ID_" + dt.getTime();
	window.open(url,id,'width='+width+',height='+height+',toolbars=no,scrollbars=no,resize=no');
}

function popupScroll(url, width, height){
	var dt = new Date();
	var id = "ID_" + dt.getTime();
	window.open(url,id,'width='+width+',height='+height+',toolbars=no,scrollbars=yes,resize=no');
}


function openWinAdmin(flag)
{
	if(flag == 'id')
	{
		var url = 'memberManage/findId.jsp';
		var width=350;
		var height=225;
	}
	if(flag == 'zip')
	{
		var url = 'memberManage/findZipCode.jsp';
		var width=500;
		var height=250;
	}

	window.open(url,flag,'width='+width+',height='+height+',toolbars=no,scrollbars=no,resize=no');
	return false;
}

//====================== »ç¾÷ÀÚ µî·Ï¹øÈ£ Ã¼Å© ½ºÅ©¸³ ============================================

//»ç¾÷ÀÚ µî·Ï¹øÈ£ °Ë»ç ½ºÅ©¸³

function BizCheck(obj1, obj2, obj3)
{
	biz_value = new Array(10);

	if (isBizInteger(obj1.value,3) == false) {
	  obj1.focus();
	  obj1.select();
	  return false;
	}

	if (isBizInteger(obj2.value,2) == false) {
	  obj2.focus();
	  obj2.select();
	  return false;
	}

	if (isBizInteger(obj3.value,5) == false) {
	  obj3.focus();
	  obj3.select();
	  return false;
	}

	var objstring = obj1.value +"-"+ obj2.value +"-"+ obj3.value;
	var li_temp, li_lastid;

	if ( objstring.length == 12 ) 
	{
		  biz_value[0] = ( parseFloat(objstring.substring(0 ,1)) * 1 ) % 10;
		  biz_value[1] = ( parseFloat(objstring.substring(1 ,2)) * 3 ) % 10;
		  biz_value[2] = ( parseFloat(objstring.substring(2 ,3)) * 7 ) % 10;
		  biz_value[3] = ( parseFloat(objstring.substring(4 ,5)) * 1 ) % 10;
		  biz_value[4] = ( parseFloat(objstring.substring(5 ,6)) * 3 ) % 10;
		  biz_value[5] = ( parseFloat(objstring.substring(7 ,8)) * 7 ) % 10;
		  biz_value[6] = ( parseFloat(objstring.substring(8 ,9)) * 1 ) % 10;
		  biz_value[7] = ( parseFloat(objstring.substring(9,10)) * 3 ) % 10;
		  li_temp = parseFloat(objstring.substring(10,11)) * 5 + "0";
		  biz_value[8] = parseFloat(li_temp.substring(0,1)) + parseFloat(li_temp.substring(1,2));
		  biz_value[9] = parseFloat(objstring.substring(11,12));
		  li_lastid = (10 - ( ( biz_value[0] + biz_value[1] + biz_value[2] + biz_value[3] + biz_value[4] + biz_value[5] + biz_value[6] + biz_value[7] + biz_value[8] ) % 10 ) ) % 10;
		  if (biz_value[9] != li_lastid) 
		  {
			obj1.focus();
			obj1.select();
			return false;
		  }
		  else
		  {
	    		return true;
	    	  }
	}
	else 
	{
	  obj1.focus();
	  obj1.select();
	  return false;
	}
}

//»ç¾÷ÀÚ ¹øÈ£ Ã¼Å© ½ºÅ©¸³
function CheckBizNo(flag_01,flag_02,flag_03)
{ 
	if (BizCheck(flag_01,flag_02,flag_03) == false) 
	{
	  	alert( "¿Ã¹Ù¸¥ »ç¾÷ÀÚ µî·Ï¹øÈ£°¡ ¾Æ´Õ´Ï´Ù.\n´Ù½Ã È®ÀÎÇØ ÁÖ½Ã±â ¹Ù¶ø´Ï´Ù." );
	  	flag_01.value='';
	  	flag_02.value='';
	  	flag_03.value='';
	  	flag_01.focus();
	  	return false;
	} else {
		return true;
	}
}

//»ç¾÷ÀÚ ¹øÈ£ ±¸¼ºÃ¼Å©

function isBizInteger(st,maxLength)
{
	if (st.length == maxLength) 
	{
		  for (j=0; j < maxLength; j++)
		  {    
		  	if (((st.substring(j, j+1) < "0") || (st.substring(j, j+1) > "9")))
		    	return false;
		  }
	}
	else 
	{
	  	return false;
	}
return true;
}

function IsNumber(formname) 
{
      var form = eval("document.regform." + formname);

      for(var i = 0; i < form.value.length; i++) 
      {
	         var chr = form.value.substr(i,1);
	         if(chr < '0' || chr > '9') 
	         {            
	            return false;
	         }
      }
      return true;   
}



//ÀÚ¹Ù½ºÅ©¸³Æ® ´Þ·Â
var target;

function MiniCal(jucke) 
{
	target = jucke;
	x = (document.layers) ? loc.pageX : event.clientX;
	y = (document.layers) ? loc.pageY : event.clientY;
	minical.style.pixelTop	= y-0;
	minical.style.pixelLeft	= x-50;
	minical.style.display = (minical.style.display == "block") ? "none" : "block";
	Show_cal(0,0,0)
}

var stime

function doOver() 
{
	var el = window.event.srcElement;
	cal_Day = el.title;

	if (cal_Day.length > 7) 
	{
		el.style.borderTopColor = el.style.borderLeftColor = "buttonhighlight";
		el.style.borderRightColor = el.style.borderBottomColor = "buttonshadow";
	}
	window.clearTimeout(stime);
}

function doClick() 
{
	cal_Day = window.event.srcElement.title;
	window.event.srcElement.style.borderColor = "red";

	if (cal_Day.length > 7) target.value=cal_Day;
}

function doOut() 
{
	var el = window.event.fromElement;
	cal_Day = el.title;

	if (cal_Day.length > 7) 
	{
		el.style.borderColor = "white";
	}
	stime=window.setTimeout("minical.style.display='none';", 200);
}
//´Þ·Â ½ºÅ©¸³Æ® ³¡


//star10 Ãß°¡ ÇÔ¼ö °ãÄ¡´Â°ÍÀº »èÁ¦ÇÒ°Í
// °ª Á¸Àç¿©ºÎ È®ÀÎ
function existValue(elementName,comment){
	var target = document.all(elementName);	
	if (target.value.length == 0){	
		alert(comment);
		target.focus();	
		return false;
	}	
	return true;
}

// °ª Á¸Àç¿©ºÎ È®ÀÎ
function existValueWithComment(elementName){
	var target = document.all(elementName);	
	if (target.value.length == 0){				
		return false;
	}
	return true;
}

// Æ¯Á¤¹üÀ§ÀÇ °ªÀ» È®ÀÎ
function checkRange(elementName,comment,startNumber,endNumber){
	var target = document.all(elementName);
	var number = target.value;

	if ((number < startNumber) || (number > endNumber)) {
		alert(comment);
		target.value="";
		target.focus();	
		return false;
	}
	return true;
}

// ¼ýÀÚÀÔ·Â È®ÀÎ
function checkNumber(elementName,comment){
	var target = document.all(elementName);	
	var len = target.value.length;
	var i, chr, point=0;
	for (i=0;i<len;i++){
		chr=target.value.substring(i,i+1);		
		if (chr < "0" || chr > "9") {
			alert(comment);			
			target.focus();		
			return false;		  
		}
	}	
	return true;
}

// ¼ýÀÚÀÔ·Â È®ÀÎ
function checkNumberWithoutComment(input_string){
	
	var len = input_string.length;
	var i, chr, point=0;
	for (i=0;i<len;i++){
		chr=input_string.substring(i,i+1);		
		if (chr < "0" || chr > "9") {
			return false;		  
		}
	}	
	return true;
}

// ½Ç¼ö°ªÀ» È®ÀÎ ÇÕ´Ï´Ù. 
function checkDouble(elementName, comment, acc, scale)
{
	var target = document.all(elementName);
	var str = new String(target.value);
	str_array  = str.split('.');
	
	var is_ok = false;	
	if( (str_array.length != null) && (str_array.length == 2 )) {	
		var len = str_array[0].length + str_array[1].length;
		if ( (str_array[0].length == (acc-scale) ) && (len <= acc) && (str_array[1].length <= scale) ) {			
			if( (checkNumberWithoutComment(str_array[0])) && (checkNumberWithoutComment(str_array[1]))) 			
				is_ok = true;
		}
	}
	
	if( !is_ok) {
		alert(comment);
		target.focus();
		return;
	}
	
	return is_ok;
	/*
	if (target.value.length <= 4)
	{
		
		
		
		if (str[0].length==1)	
		{
			return true;
		}
		else	
		{
			target.value="";
			target.focus();
			return false;
		}
	}
	else
	{
		target.value="";
		target.focus();
		return false;
	}
	*/
}

// ¼ýÀÚÀÔ·Â È®ÀÎ
function onlyNumberInTextbox() 
{
   if ((event.keyCode>=48) && (event.keyCode <= 57))
      event.returnValue=true;
   else
      event.returnValue=false;
}

// ÇÑ±ÛÀ» Æ÷ÇÔÇÑ ¹®ÀÚ¿­¿¡¼­ ¹®ÀÚ¿­ÀÇ ±æÀÌ¸¦ ¹ÝÈ¯ÇÑ´Ù. 
function getLengthOfString(elementName) {
	var target = document.all(elementName);
	var str = target.value;
	var len = str.length; 
	var han = 0; 
	var res = 0; 
	
	for(i=0;i<len;i++) { 
		var a=str.charCodeAt(i); 
		if(a>128) han++; 	
	} 		
	res = (len-han) + (han*2); 	
	return res; 
}
// ÇÑ±ÛÀ» Æ÷ÇÔÇÑ ¹®ÀÚ¿­ÀÇ ±æÀÌ°¡ ÁÖ¾îÁø ±æÀÌ¿Í °°ÀºÁö¸¦ Ã¼Å© ÇÑ´Ù. 
function isLenghStr(elementName, comment, checklength) {
	var target = document.all(elementName);
	var len = getLengthOfString(elementName);
	
	if( len != checklength) {
		alert(comment);
		target.focus();
		return false;		
	}
	return true;
}

// ÇÑ±ÛÀ» Æ÷ÇÔÇÑ ¹®ÀÚ¿­ÀÇ ±æÀÌ°¡ Æ¯Á¤¹üÀ§³»¿¡ ÀÖ´ÂÁö Ã¼Å©ÇÑ´Ù.
function checkStringLength(elementName,comment,maxlength) {
	var target = document.all(elementName);
	var content = target.value
	var len = content.length; 
	var han = 0; 
	var res = 0; 
	
	for(i=0;i<len;i++) { 
		var a=content.charCodeAt(i); 
		if(a>128) han++; 	
	} 
	res = (len-han) + (han*2); 

	if(maxlength >= res){	
		return true; 
	}else{
		alert(comment);
		target.focus();		
		return false;	
	}
}
// Select ÀÇ ¼±ÅÃ »óÅÂ¸¦ Á¡°Ë ÇÕ´Ï´Ù. 
function checkSelectedIndex(elementName, comment, except_index) {
	var target = document.all(elementName);
	var index = target.selectedIndex;
	
	if( index == except_index) {
		alert(comment);
		target.focus();
		return false;	
	}
	return true;	
}


// ÆÄÀÏ Å¸ÀÔÀ» ¹ÝÈ¯ ÇÕ´Ï´Ù. 
function get_file_extension(file_frm) {		
	file_path = document.all(file_frm).value;
	if( file_path == "") return "";
	var pos = file_path.lastIndexOf(".");
	//alert("Type is : " + file_path.substring(pos));re
	return file_path.substring(pos+1).toLowerCase();
}

// ÀÌ¹ÌÁö »çÀÌÁî¸¦ Ã¼Å© ÇÕ´Ï´Ù. 	
function check_image(image_frm, max_width, max_height, msg) {				
	var result = true;
	img_path = document.all(image_frm).value;					
	if( img_path != "") {
		img = new Image();
		img.src =img_path;
		
		if( (img.width >max_width) || ( img.height>max_height) ) {
			alert(msg);
			result = false;
		}			
	}
	return result;
}

// Checkbox ¸®½ºÆ®¿¡¼­ ¼±ÅÃµÈ Ç×¸ñÀÇ ¸®½ºÆ®¸¦ ±¸ÇÕ´Ï´Ù.
// ¹ÝÈ¯ °ªÀº Array Object ÀÔ´Ï´Ù.  
function get_checked_list(check_object) {
	var checked_list = new Array();
	var check = document.all(check_object);
	
	if(check.length == null) {
		if(check.checked) checked_list.push(check.value);
	}
	else {
		for(i=0; i<check.length;i++) {
			if(check[i].checked) {
				//alert(check[i].value);
				checked_list.push(check[i].value);
			}	
		}
	}	
	return checked_list;
}

function set_all_checked_state(check_object, state) {	
	var obj_list = document.all(check_object);
	if(obj_list.length == null) {
		obj_list.checked = state;
	}
	else {
		for(i=0; i<obj_list.length;i++) {
			obj_list[i].checked = state;				
		}
	}
}

//ÇÑ¸ÞÀÏ Ã¼Å©
function hanmailCheck(elementName)
{
	var target = document.all(elementName);
	var str = target.value;
	var len = str.length;
	var hanmailChk = "";
	var a;
	var firstNum;
	var secondNum;
	
	for(i=0; i<len; i++) 
	{ 
		a = str.charAt(i);

		if (a=="@") firstNum = i;
		
		if (a==".")
		{
			secondNum = i;
			break;	
		}
	}
	
	for(i=firstNum+1; i<secondNum; i++)
	{
		hanmailChk = hanmailChk + str.charAt(i);
	}
	
	if (hanmailChk=="hanmail") 
	{
		alert("ÇÑ¸ÞÀÏÀº »ç¿ë ºÒ°¡´ÉÇÕ´Ï´Ù");
		return false;
	}
	else
	{
		return true;
	}
}


//´Ù¿î·Îµå Áú¹®Ã¢ ´Ý±â
function closeFileDown()
{
	setTimeout('closeWin()', 1000)
}

//Ã¢´Ý±â
function closeWin()
{
	var win = window.open('ablut:blank','filedown');
	win.close();
}


