function chkKeyPress(e)
{
	var keyValue = e.keyCode;
	if (keyValue == 13) chkLogin();
}

function chkLogin()
{
	var f = document.LOGINFORM;
	if (!(chkInput(f.mid,'¾ÆÀÌµð¸¦ ÀÔ·ÂÇÏ¼¼¿ä.'))) return;
	if (!(chkInput(f.mpass,'ºñ¹Ð¹øÈ£¸¦ ÀÔ·ÂÇÏ¼¼¿ä.'))) return;
	f.submit();
}

function chkEnter(e)
{
	var keyValue = e.keyCode;
	if (keyValue == 13) chkSearch('');
}

function chkSearch(val)
{
	var f = document.FORM;
	f.SortStr.value = val;
	f.submit();
}

function chkCode(e)
{
	var keyValue = e.keyCode;
	if( keyValue == 13 )
		return true;
	if( (keyValue >= 48) && (keyValue <= 57) || keyValue == 8 || keyValue == 45)
		return true;
	else
		return false;
}

function chkInputIden(inputname)
{
  var inputvalue = inputname.value;
  if (!(chkInput(inputname,'¾ÆÀÌµð¸¦ ÀÔ·ÂÇÏ¼¼¿ä.','¾ÆÀÌµð',4,20))) return false;
  for (var i=0; i < inputvalue.length; i++)
  {
    str = inputvalue.charAt(i);
    if (((str < '0')||(str > '9'))&&((str < 'a')||(str > 'z'))) {
      setMsgbox('¾ÆÀÌµð¿¡´Â ¿µ¹®ÀÚ(a-z), ¼ýÀÚ(0-9)¸¸ »ç¿ëÇÏ½Ç ¼ö ÀÖ½À´Ï´Ù.',inputname);
      return false;
    }
  }
  return true;
}

//ÀÔ·Â À¯È¿¼º
function chkInput(inputname, prompt, tit, min, max, maxw) {
  var inputvalue = inputname.value.toLowerCase();
  var cntChr=1;
  if (!min) min = 0;
  if (!max) max = Math.pow(10,5);

  if (inputvalue.search(/(\S+)/) == -1)
  {
    setMsgbox(prompt,inputname);
    return false;
  }

  if (inputvalue.length < min || inputvalue.length > max) {
    setMsgbox(tit + '(Àº)´Â '+min+'ÀÚÀÌ»ó '+max+'ÀÚ ÀÌ³»·Î ÀÔ·ÂÇÏ¼¼¿ä.',inputname);
    
	return false;
  }
  
  if (maxw)
  {
	  for (var i=0; i < inputvalue.length; i++)
	  {
		str = inputvalue.charAt(i);
		if (str==' ')
		{
			cntChr+=1
		}
	  }
	 if ( cntChr > maxw )
	 {
		setMsgbox(tit + '(Àº)´Â '+maxw+'´Ü¾î ÀÌ³»·Î ÀÔ·ÂÇÏ¼¼¿ä.',inputname);
		return false;
	 }
  }
  return true;
}

//ÀüÀÚ¿ìÆí À¯È¿¼º
function chkInputMail(inputname, prompt) {
  var inputvalue = inputname.value.toLowerCase();
  if (inputvalue.search(/(\S+)@(\S+)\.(\S+)/) == -1)
  {
    setMsgbox(prompt,inputname);
    return false;
  }
  return true;
}

//ÀÔ·Âºñ±³
function chkInputComp(inputname, inputcomp, prompt) {
  if (inputname.value.trim() != inputcomp.value.trim())
  {
    setMsgbox(prompt,inputname);
    return false;
  }

  return true;
}

String.prototype.trim = function()
{
    return this.replace(/(^\s*)|(\s*$)/g, "");
}

//¸Þ¼¼Áö»óÀÚ
function setMsgbox(prompt, inputname) {
  alert(prompt);
  inputname.focus();
}

function chkRadio(obj)
{
	var len = obj.length;
	if (len == undefined)
	{
		if(obj.checked)
			return true;
	}else{
		for(i=0;i<len;i++)
		{
			if(obj[i].checked)
			{
				return true;
				break;
			}
		}
	}
	return false;
}
	
function zipfinder(frm,obj)
{
	var popurl = '/member/Zipcode.asp?frm='+frm+'&sec='+obj;
	OpenWin(555,400,'zipcode',popurl);
}

function cboSelect(obj,val)
{
  for (var i = 0; i < obj.length; i++) {
    if (val == obj.options[i].value) obj.options[i].selected = true;
  }
}

function cboRadio(obj,val)
{
  for (var i = 0; i < obj.length; i++) {
    if (val == obj[i].value) obj[i].checked = true;
  }
}

function cboCheckbox(obj,val)
{
  if (obj.length == undefined)
  {
	 if (val == obj.value) obj.checked = true;
  }else{
	  for (var i = 0; i < obj.length; i++)
	  {
		if (val == obj[i].value)
			obj[i].checked = true;
	  }
  }
}

function cal(year, month, day, obj){
	var i, j, day_num=1;
	var last_week, month_link, objval, chklen="";
	var calDate = new Date(year, month-1, day_num);
	var checkDate = new Date();
	var date_array = new Array(6);

	for(i=0;i<6;i++) date_array[i] = new Array("","","","","","","");

	//½ºÅ©¸³Æ® ÃßÃâ ¹× º¯È¯, ³»¿ëÀÌ ¾øÀ¸¸é ¸¶Áö¸· action »ç¿ë

	for(j=0;j<6;j++){
		for(i=0;i<7;i++){
			if(j==0 && i==0)i = calDate.getDay();
			date_array[j][i]=day_num+"";
			day_num++;

			//ÇØ´ç ³¯Â¥°ª¿¡ ´ëÇÑ À¯È¿¼º °Ë»ç
			checkDate.setFullYear(year, month-1, day_num);
			if(checkDate.getDate() != day_num) break;
		}
		if(checkDate.getDate() != day_num) break;
	}
	last_week = (date_array[5][0])?6:5;

	outStr = "<table bgcolor=#CCCCCC width=160 height=160 border=0 cellpadding=0 cellspacing=0 style='border:1 solid black'><tr><td>\n";
	outStr += "<table width=100% height=100% border=0 cellpadding=0 cellspacing=1 style='border:1 solid black'>\n";
	outStr += "<col width=20 align=center></col><col width=20 align=center></col><col width=20 align=center></col><col width=20 align=center></col><col width=20 align=center></col><col width=20 align=center></col><col width=20 align=center></col>\n";
	outStr += "<tr><td class=calendar style='color:red'>S<td class=calendar>M<td class=calendar>T<td class=calendar>W<td class=calendar>T<td class=calendar>F<td class=calendar style='color:blue'>S</tr>\n";
	for(j=0;j<last_week;j++){
		outStr += "<tr>";
		for(i=0;i<7;i++){
			//½ºÅ©¸³Æ® ÀÚ·áº¯È¯
			if(date_array[j][i]!=""){
				if(month < 10) chklen="0"
				objval = year+"-"+chklen+month
				chklen=""
				if(date_array[j][i] < 10) chklen="0" 
				objval += "-"+chklen+date_array[j][i];
				chklen=""
			}
			else objval = "";


			//³¯Â¥º°·Î ½ºÅ©¸³Æ® Ãâ·Â
			if(i==0){ outStr += "<td class=calendar style='color:red;cursor:hand' onMouseover=this.style.backgroundColor='#FFEEEE' onMouseout=this.style.backgroundColor='' onClick=\""+ obj +".value='"+ objval +"';document.all.G_cal.style.visibility='hidden';\">"+date_array[j][i]+"</td>"; continue; }
			if(i==6){ outStr += "<td class=calendar style='color:blue;cursor:hand' onMouseover=this.style.backgroundColor='#EEEEFF' onMouseout=this.style.backgroundColor='' onClick=\""+ obj +".value='"+ objval +"';document.all.G_cal.style.visibility='hidden';\">"+date_array[j][i]+"</td>"; continue; }
			outStr += "<td class=calendar style='cursor:hand' onMouseover=this.style.backgroundColor='#EEEEEE' onMouseout=this.style.backgroundColor='' onClick=\""+ obj +".value='"+ objval +"';document.all.G_cal.style.visibility='hidden';\">"+date_array[j][i]+"</td>";
		}
		outStr += "</tr>\n";
	}
	outStr += "</table></td></tr></table>";

	//month_link = (month > 1)? "<a onClick=\"cal("+year+","+(month-1)+","+day+",'')\" style='text-decoration:none; color:#909090; cursor:hand'>¢·</a> <font color=black>"+month:"¢· <font color=black>"+month;
	//month_link += (month < 12)? "</font> <a onClick=\"cal("+year+","+(month+1)+","+day+",'')\" style='text-decoration:none; color:#909090; cursor:hand'>¢¹</a>":"</font> ¢¹";
	
	month_link = (month > 1)? "<a onClick=\"cal("+year+","+(month-1)+","+day+",'"+obj+"')\" style='text-decoration:none; color:#909090; cursor:hand'>¢·</a> <font color=black>"+month:"<a onClick=\"cal("+(year-1)+",12,"+day+",'"+obj+"')\" style='text-decoration:none; color:#909090; cursor:hand'>¢·</a> <font color=black>"+month;
	month_link += (month < 12)? "</font> <a onClick=\"cal("+year+","+(month+1)+","+day+",'"+obj+"')\" style='text-decoration:none; color:#909090; cursor:hand'>¢¹</a>":"</font> <a onClick=\"cal("+(year+1)+",1,"+day+",'"+obj+"')\" style='text-decoration:none; color:#909090; cursor:hand'>¢¹</a>";


	//HTML ´ëÀÔ
	document.all.G_cal_body.innerHTML = outStr;
	document.all.G_cal_year.innerHTML = "<a onClick=\"cal("+(year-1)+","+month+","+day+",'"+obj+"')\" style='text-decoration:none; color:#909090; cursor:hand'>¢·</a> <font color=black>"+year+"</font> <a onClick=\"cal("+(year+1)+","+month+","+day+",'"+obj+"')\" style='text-decoration:none; color:#909090; cursor:hand'>¢¹</a>";
	document.all.G_cal_month.innerHTML = month_link;
}

function onoff_Gcal(val,obj)
{
	document.all.G_cal.style.top = event.clientY+15;
	document.all.G_cal.style.left = event.clientX-50;
	if(document.all.G_cal.style.visibility=="hidden")
	{
		
		if(val.length < 1)
		{
			val=new Date();
    	year  = parseInt(val.getYear());
    	month = parseInt(val.getMonth())+1;
    	day   = parseInt(val.getDate());			
    }
		else
		{
    	year  = parseInt(val.substr(0,4));
    	month = parseInt(val.substr(5,2));
    	day   = parseInt(val.substr(8,2));
		}	
		
		cal(year,month,day,obj);
	}
	document.all.G_cal.style.visibility = ""//(document.all.G_cal.style.visibility=="hidden")?"":"hidden";
}
document.writeln("<style>td.calendar{font-size:7pt; font-family:tahoma;color:black; background-color:white}</style>");
document.writeln(""
+"<div id=G_cal style='width=160;position:absolute;visibility:hidden'>"
+"<table bgcolor=#EEEEEE width=160 height=25 border=0 cellpadding=3 cellspacing=0 style='border:1 solid black'>"
+"	<tr><td align=center style='font-size:8pt; font-family:tahoma'>"
+"		<span id=G_cal_year></span>&nbsp;&nbsp;<span id=G_cal_month></span> &nbsp;&nbsp;<a OnClick=\"document.all.G_cal.style.visibility='hidden'\" style='text-decoration:none; color:#909090; cursor:hand'>´Ý±â</a>"
+"	</td></tr>"
+"</table>"
+"<div id=G_cal_body style='width:160'>"
+"</div></div>");

function OpenWin(popwidth,popheight,popname,popurl)
{
	LeftPosition=(screen.width)?(screen.width-popwidth)/2:100;
	TopPosition=(screen.height)?(screen.height-popheight)/2:100;
	
	window.open(popurl,popname,'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=yes,resizable=0,top='+TopPosition+',left='+LeftPosition+',copyhistory=0,width='+popwidth+',height='+popheight);
}

function chkFileSize(path)
{
	var img = new Image();
	img.dynsrc = path;
	return img.fileSize;
}

function chkValue(obj, val)
{
	var st=1;
	if(val > 12)
	{
	 st=1900;
	}
	
	if(obj.value < st || obj.value > val)
	{
	 alert("³â,¿ùÀ» Á¤È®È÷ ÀÔ·ÂÇØ ÁÖ¼¼¿ä");
	 obj.value="";
	}
}