   a=0
   b=0
   j=0
   k=4
   l=0

	function thismouseover(kk){
		kk.style.background = "#D5E5F1";
		//kk.style.border = "1px solid #c5d2f1";
	}

	function thismouseout(kk){
		kk.style.background = ''
		//kk.style.border = "0px solid #f1f1f1";
	}

	function thismouseout1(kk){
		kk.style.background = ''
	}

   function aa(FormName,ObjectName,x,y,NoMove)
    {

	 document.getElementById('calendarBox').style.display='block';
	
     a=0
     l=0
     b=0

	 ObjectY=eval(FormName+"."+"yy")
	 ObjectM=eval(FormName+"."+"mm")

     yy=ObjectY.value
     mm=ObjectM.value

	 today=new Date()
//      if (yy==""){
		 if(typeof(NoMove)=="undefined"){
         yy=today.getYear()
         ObjectY.value=yy
		 }
//      }
//      if (mm==""){
		 if(typeof(NoMove)=="undefined"){
		 mm=today.getMonth()+1
         ObjectM.value=mm
		 }
//      }

      if (yy<=0){
         return 0
      }

      if (mm==1 || mm==3 || mm==5 || mm==7 || mm==8 || mm==10 || mm==12){
         dd=31
      }
     else if (mm==4 || mm==6 || mm==9 || mm==11){
         dd=30
      }
     else if (mm==2){
        if (yy%400==0){
           dd=29
           l=1
        }
        else if (yy%100==0){
           dd=28}
        else if (yy%4==0) {
           dd=29
           l=1}
        else{
           dd=28}
        }

        j=(yy%28)
        k=(j%7)+(j-j%4)/4
        if (j==0){
           k=7
        }
        else if(k>7){
           k=k-7
        }
       for (p=1;p<13;p+=1){ 
          if (mm==p){
             break
          }
          if (p==1 || p==3 || p==5 || p==7 || p==8 || p==10){
             k=k+3
          }
          else if (p==4 || p==6 || p==9 || p==11){
             k=k+2
          }
          else if (p==2){
            if (l==1)
             k=k+4
            }
            if (mm==p){
            break
            }
            if (k>7){
            k=k%7
            }
           if (k==0)
            k=7}

//alert(k)  //¸Å´ÞÀÇ ½ÃÀÛ¿äÀÏ
      n(FormName,ObjectName,x,y,NoMove)
 }

function n(FormName,ObjectName,x,y,NoMove){
	b=0
	d=0
	Event=""
	b=1-k


	ObjectY=eval(FormName+"."+"yy")
	ObjectM=eval(FormName+"."+"mm")


	mm=ObjectM.value
	if (mm==1 || mm==3 || mm==5 || mm==7 || mm==8 || mm==10 || mm==12){
		dd=31
	}
	else if (mm==4 || mm==6 || mm==9 || mm==11){
		dd=30
	}
	else if (mm==2){
		if (yy%400==0){
			dd=29
			l=1
		}
		else if (yy%100==0){
			dd=28
		}
		else if (yy%4==0) {
			dd=29
			l=1
		}
		else{
			dd=28
		}
	}
	todate=today.getDate()

	Event+=(" <div id='calClose'><a tabindex='0' href="+"#"+" onClick="+"calClose()"+" title='´Ý±â'><img src='../images/mypage/btn_calClose.gif' width='19' height='18' title='´Ý±â' /></a></div>");
	Event+=(" <ul class='YearMonth'>");
	Event+=(" 	<li><a tabindex='0' href="+"#"+" onclick="+"PreYear('"+FormName+"','"+ObjectName+"')"+" title='ÀÌÀü ³âµµ º¸±â'><img src='../images/mypage/yearmonth_prev.gif' width='13' height='13' onmouseover='imgOver(this);' onmouseout='imgOut(this);' title='ÀÌÀü ³âµµ º¸±â' /></a></li>");
	Event+=(" 	<li class='nowDate'>");
	Event+=(yy)
	Event+=("	  <span class='nowDateTxt'>³â</span></li>");
	Event+=(" 	<li><a tabindex='0' href="+"#"+" onclick="+"NextYear('"+FormName+"','"+ObjectName+"')"+" title='´ÙÀ½ ³âµµ º¸±â'><img src='../images/mypage/yearmonth_next.gif' width='13' height='13' onmouseover='imgOver(this);' onmouseout='imgOut(this);' title='´ÙÀ½ ³âµµ º¸±â' /></a></li>");
	Event+=(" 	<li class='blank'></li>");
	Event+=(" 	<li><a tabindex='0' href="+"#"+" onclick="+"PreMonth('"+FormName+"','"+ObjectName+"')"+" title='ÀÌÀü ´Þ º¸±â'><img src='../images/mypage/yearmonth_prev.gif' width='13' height='13' onmouseover='imgOver(this);' onmouseout='imgOut(this);' title='ÀÌÀü ´Þ º¸±â' /></a></li>");
	Event+=(" 	<li class='nowDate'>");
	Event+=(mm)
	Event+=("	  <span class='nowDateTxt'>¿ù</span></li>");
	Event+=(" 	<li><a tabindex='0' href="+"#"+" onclick="+"NextMonth('"+FormName+"','"+ObjectName+"')"+" title='´ÙÀ½ ´Þ º¸±â'><img src='../images/mypage/yearmonth_next.gif' width='13' height='13' onmouseover='imgOver(this);' onmouseout='imgOut(this);' title='´ÙÀ½ ´Þ º¸±â' /></a></li>");
	Event+=(" </ul>");	
	Event+=(" <div class='calSection'>");
	Event+=("   <table id='calendar' summary='´Þ·Â'>");
	Event+=("	  <thead>");
	Event+=("		<tr>");
	Event+=("		  <th scope='col'><img src='/images/mypage/week_sun.gif' width='19' height='8' title='ÀÏ¿äÀÏ' /></th>");
	Event+=("		  <th scope='col'><img src='/images/mypage/week_mon.gif' width='23' height='8' title='¿ù¿äÀÏ' /></th>");
	Event+=("		  <th scope='col'><img src='/images/mypage/week_tue.gif' width='17' height='8' title='È­¿äÀÏ' /></th>");
	Event+=("		  <th scope='col'><img src='/images/mypage/week_wed.gif' width='21' height='8' title='¼ö¿äÀÏ' /></th>");
	Event+=("		  <th scope='col'><img src='/images/mypage/week_thu.gif' width='19' height='8' title='¸ñ¿äÀÏ' /></th>");
	Event+=("		  <th scope='col'><img src='/images/mypage/week_fri.gif' width='13' height='8' title='±Ý¿äÀÏ' /></th>");
	Event+=("		  <th scope='col'><img src='/images/mypage/week_sat.gif' width='17' height='8' title='Åä¿äÀÏ' /></th>");
	Event+=("		</tr>");
	Event+=("	  </thead>");
	Event+=("	  <tbody>");

	for (r=0;r<=35;r+=7 )
	{
		Event+=("	    <tr>")

		for (i=1;i<8;i+=1)
		{
			if (a==2){
				document.write("<td onclick='DateView('','"+FormName+"','"+ObjectName+"')'></td>");
				break;
			}

			d=i+r;
			b=b+1;
			
			if (r==35){
				if (b<=dd)
				{
					if (d%7==1){
						Event+=("<td class='first' onmouseover='thismouseover(this)' onmouseout='thismouseout1(this)' onclick="+"DateView('"+b+"','"+FormName+"','"+ObjectName+"')"+">"+b+"</td>");
					}else{
						Event+=("<td onmouseover='thismouseover(this)' onmouseout='thismouseout1(this)' onclick="+"DateView('"+b+"','"+FormName+"','"+ObjectName+"')"+">"+b+"</td>");
					}
				}else if ((dd+k)>35){
					//alert("1");
					Event+=("<td onclick="+"DateView('','"+FormName+"','"+ObjectName+"')></td>"); //³¯Â¥°¡ ¾ø´Â ºó °ø°£Àº $$·Î Ç¥Çö
				}

			}
			else if (b>dd || d<k){
				Event+=("<td onclick="+"DateView('','"+FormName+"','"+ObjectName+"')"+"></td>") //³¯Â¥°¡ ¾ø´Â ºó °ø°£Àº $$·Î Ç¥Çö
			}
			else if (d%7==1 ){
				if (b==todate)
				{
					Event+=("<td class='first' onmouseover='thismouseover(this)' onmouseout='thismouseout1(this)' onclick="+"DateView('"+b+"','"+FormName+"','"+ObjectName+"')"+"><strong>"+b+"</strong></td>");  //ÀÏ¿äÀÏÀº »¡°£»ö¹è°æÀ¸·Î..³¯Â¥¸¦ ¾²ÀÚ
				}
				else
				{
					Event+=("<td class='first' onmouseover='thismouseover(this)' onmouseout='thismouseout1(this)' onclick="+"DateView('"+b+"','"+FormName+"','"+ObjectName+"')"+">"+b+"</td>");  //ÀÏ¿äÀÏÀº »¡°£»ö¹è°æÀ¸·Î..³¯Â¥¸¦ ¾²ÀÚ
				}

			}

			else{
				if ( b==todate )
				{
					Event+=("<td onmouseover='thismouseover(this)' onmouseout='thismouseout(this)' onclick="+"DateView('"+b+"','"+FormName+"','"+ObjectName+"')"+"><strong>"+b+"</strong></td>") //³¯Â¥¸¦ ¾²ÀÚ
				}
				else
				{
					Event+=("<td onmouseover='thismouseover(this)' onmouseout='thismouseout(this)' onclick="+"DateView('"+b+"','"+FormName+"','"+ObjectName+"')"+">"+b+"</td>") //³¯Â¥¸¦ ¾²ÀÚ
				}
			}
		}

		Event+=("       </tr>");
	}

		Event+=("     </tbody>");
		Event+=("	</table>");
		Event+=(" </div>");

		//·¹ÀÌ¾î¸¦ ÇÔ ½áºÃ¾î¿©~

	document.all["span_sche"].style.display=""
	if (typeof(NoMove)=="undefined")
	{

//		document.all["span_sche"].style.left=event.clientX+parseInt(x);
//		document.all["span_sche"].style.top=event.clientY+parseInt(y);

		document.all["span_sche"].style.left=event.clientX-parseInt(x);
		document.all["span_sche"].style.top=event.clientY-parseInt(y);

		
	}
	document.all["span_sche"].innerHTML = Event;

}



function calClose(){
     document.all["span_sche"].style.display="none"
	 document.getElementById('calendarBox').style.display='none';
}

function DateView(DD,FormName,ObjectName){


	ObjectY=eval(FormName+"."+"yy")
	ObjectM=eval(FormName+"."+"mm")
	ObjectYMD=eval(FormName+"."+ObjectName)


	 ObjectY.value=""
	 ObjectM.value=""
	 mm="00"+mm
 	 mm=mm.substr(mm.length-2,mm.length)
	 DD="00"+DD
	 DD=DD.substr(DD.length-2,DD.length)

	chkYMD=yy+"-"+mm+"-"+DD
	if (DD=="00")
	{
		yy="";
		mm="";
		DD="";
		chkYMD=""
	}
     ObjectYMD.value=chkYMD;

     document.all["span_sche"].style.display="none"
	 document.getElementById('calendarBox').style.display='none';

}

function PreYear(FormName,ObjectName){

	  ObjectY=eval(FormName+"."+"yy")
	  ObjectM=eval(FormName+"."+"mm")

	  yy=ObjectY.value
	  yy=yy-1

	  if (yy<=0){
		 yy=ObjectY.value
	  }

	  ObjectY.value=yy
	  aa(FormName,ObjectName,'0','0',"NoMove")

}

function NextYear(FormName,ObjectName,x,y){

	 ObjectY=eval(FormName+"."+"yy")
	 ObjectM=eval(FormName+"."+"mm")

	 yy=ObjectY.value
	 yy=parseInt(yy)+1
	 ObjectY.value=yy
	 aa(FormName,ObjectName,'0','0','NoMove')
}

function PreMonth(FormName,ObjectName){

	 ObjectY=eval(FormName+"."+"yy")
	 ObjectM=eval(FormName+"."+"mm")

	 mm=ObjectM.value
	 mm=mm-1

	 if (mm<=0){
		mm="12"
		yy=yy-1

		if (yy<=0){
		 yy=ObjectY.value
		}

		ObjectY.value=yy
	  }

		ObjectM.value=mm
		aa(FormName,ObjectName,'0','0','NoMove')
}

function NextMonth(FormName,ObjectName){

	 ObjectY=eval(FormName+"."+"yy")
	 ObjectM=eval(FormName+"."+"mm")

	 mm=ObjectM.value
	 mm=parseInt(mm)+1

	  if (mm>"12"){
		 mm="1"
		 yy=parseInt(yy)+1
		 ObjectY.value=yy
	  }

	  ObjectM.value=mm
	  aa(FormName,ObjectName,'0','0','NoMove')
}

function findday(vdate){
monthnames = new Array(
"January",
"Februrary",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"Decemeber");
var linkcount=0;
function addlink(month, day, href) {
var entry = new Array(3);
entry[0] = month;
entry[1] = day;
entry[2] = href;
this[linkcount++] = entry;
}
Array.prototype.addlink = addlink;
linkdays = new Array();
monthdays = new Array(12);
monthdays[0]=31;
monthdays[1]=28;
monthdays[2]=31;
monthdays[3]=30;
monthdays[4]=31;
monthdays[5]=30;
monthdays[6]=31;
monthdays[7]=31;
monthdays[8]=30;
monthdays[9]=31;
monthdays[10]=30;
monthdays[11]=31;
todayDate=new Date(vdate);
thisday=todayDate.getDay();
thismonth=todayDate.getMonth();
thisdate=todayDate.getDate();
thisyear=todayDate.getYear();
thisyear = thisyear % 100;
thisyear = ((thisyear < 50) ? (2000 + thisyear) : (1900 + thisyear));
if (((thisyear % 4 == 0) 
&& !(thisyear % 100 == 0))
||(thisyear % 400 == 0)) monthdays[1]++;
startspaces=thisdate;
return monthdays[thismonth]
}

function CalView(FormName,ThisName,SbGu){
   if (SbGu=="s"){
      selys=eval(FormName+"."+ThisName+"ys")
      selms=eval(FormName+"."+ThisName+"ms")
      selds=eval(FormName+"."+ThisName+"ds")
	  selye=eval(FormName+"."+ThisName+"ye")
      selme=eval(FormName+"."+ThisName+"me")
      selde=eval(FormName+"."+ThisName+"de")
      selye.value=""
	  selme.value=""
	  selde.value=""
      selys.value=""
	  selms.value=""
	  selds.value=""
   }
   else{
      selys=eval(FormName+"."+ThisName+"YS")
      selms=eval(FormName+"."+ThisName+"MS")
      selds=eval(FormName+"."+ThisName+"DS")
	  selye=eval(FormName+"."+ThisName+"YE")
      selme=eval(FormName+"."+ThisName+"ME")
      selde=eval(FormName+"."+ThisName+"DE")
      selys.value=""
	  selms.value=""
	  selds.value=""
      selye.value=""
	  selme.value=""
	  selde.value=""
   }
}


function check_txtlen(chktxt,chkbyte,outfocus)
{
	var length = calculate_chklen(chktxt.value);
	if (length > chkbyte) {
		txtname=eval(outfocus)
        txtname.focus()
		chktxt.value = assert_msglen(chktxt.value, chkbyte);
		chktxt.focus()
	}
}

function calculate_chklen(chktxt)
{
	var nbytes = 0;

	for (i=0; i<chktxt.length; i++) {
		var ch = chktxt.charAt(i);
		if (escape(ch).length > 4) {
			nbytes += 2;
		} else if (ch != '\r') {
			nbytes++;
		}
	}

	return nbytes;
}

function assert_msglen(chktxt, maximum)
{
	var inc = 0;
	var nbytes = 0;
	var msg = "";
	var msglen = chktxt.length;

	for (i=0; i<msglen; i++) {
		var ch = chktxt.charAt(i);
		if (escape(ch).length > 4) {
			inc = 2;
		} else if (ch != '\r') {
			inc = 1;
		}
		if ((nbytes + inc) > maximum) {
			break;
		}
		nbytes += inc;
		msg += ch;
	}
	return msg;
}
