/*
Div ´Þ·Â class
# Âü°í ¼Ò½º :mins,°ø´ë¿©ÀÚ mins01(at)lycos.co.kr (email,MSN,NateOn)
# Âü°í ¼Ò½º : ÃâÃ³ ºÒ¸íÀÇ ¸¸¼¼·Â (ÁßÈ­±Ç¿¡¼­ Èê·¯ ³ª¿Âµí)

# class list
	Holiday Class ÈÞÀÏÀ¯¹«
	Lunar Class À½·Â°è»ê
	Calendar Class ´Þ·ÂÃâ·Â

#ÁÖÀÇ»çÇ×
	Prototype.js ÇÊ¿ä

#»ç¿ë¿¹
	<script language="JavaScript" src="/common/js/prototype1.5.js"></script>
	<script language="JavaScript" src="/common/js/Calendar.js"></script>
	<body>
	<input type=text name="test" value="">
	</body>
	<script>new Carendal($('test'));</script>

#Ãß°¡ÇÊ¿ä»çÇ×
	24Àý±â °Ô»ê Å¬·¡½º
	ºÒÇÊ¿äÇÑ ¼Ò½ºÄÚµå Á¤¸®
	Å×¸¶º° µðÀÚÀÎ º¯°æ ±â´É
*/

var Holiday = Class.create(); 
Object.extend(Holiday.prototype, { 

		lunarInfo:null,//»ó¼ö
		sFtv:null,//¾ç·ÂÈÞÀÏ
		lFtv:null,//À½·ÂÈÞÀÏ
		title:null,//ÈÞÀÏ¸íÄª
		color:null,//»ö»ó
		Lunar:null,//À½·Â


		initialize: function(){
		this.sFtv = new Array(
		"0101*¾ç·Â¼³",
		"0301*3¡¤1Àý",
		"0303 ³³¼¼ÀÚÀÇ³¯",
		"0321 »ó°øÀÇ³¯",
		"0322 ¹°ÀÇ³¯",
		"0323 ±â»óÀÇ³¯",
		"0401 ¸¸¿ìÀý",
		"0405 ½Ä¸ñÀÏ",
		"0407 º¸°ÇÀÇ³¯",
		"0413 ÀÓ½ÃÁ¤ºÎ¼ö¸³±â³äÀÏ",
		"0419 4.19Çõ¸í±â³äÀÏ",
		"0420 Àå¾ÖÀÎÀÇ³¯",
		"0421 °úÇÐÀÇ³¯",
		"0422 Á¤º¸Åë½ÅÀÇ³¯",
		"0425 ¹ýÀÇ³¯",
		"0428 Ãæ¹«°øÅº½ÅÀÏ",
		"0501 ±Ù·ÎÀÚÀÇ³¯",
		"0505*¾î¸°ÀÌ³¯",
		"0508 ¾î¹öÀÌ³¯",
		"0515 ½º½ÂÀÌ³¯",
		"0518 5.18¹ÎÁÖÈ­¿îµ¿±â³äÀÏ",
		"0519 ¹ß¸íÀÇ³¯",
		"0521 ¼º³âÀÇ³¯",
		"0531 ¹Ù´ÙÀÇ³¯",
		"0605 È¯°æÀÇ³¯",
		"0606*ÇöÃæÀÏ",
		"0625 6.25»çº¯ÀÏ",
		"0717*Á¦ÇåÀý",
		"0815*±¤º¹Àý",
		"0907 »çÈ¸º¹ÁöÀÇ³¯",
		"0918 Ã¶µµÀÇ³¯",
		"1001 ±¹±ºÀÇ³¯",
		"1002 ³ëÀÎÀÇ³¯",
		"1003*°³ÃµÀý",
		"1008 ÀçÇâ±ºÀÎÀÇ³¯",
		"1009 ÇÑ±Û³¯",
		"1015 Ã¼À°ÀÇ³¯",
		"1020 ¹®È­ÀÇ³¯",
		"1021 °æÂûÀÇ³¯",
		"1024 ±¹Á¦¿¬ÇÕÀÏ",
		"1028 ±³Á¤ÀÇ³¯",
		"1030 ÀúÃàÀÇ³¯",
		"1103 ÇÐ»ýÀÇ³¯",
		"1109 ¼Ò¹æÀÇ³¯",
		"1111 ³ó¾÷ÀÎÀÇ³¯",
		"1117 ¼ø±¹¼±¿­ÀÇ³¯",
		"1130 ¹«¿ªÀÇ³¯",
		"1203 ¼ÒºñÀÚÀÇ³¯",
		"1225*¼ºÅºÀý"
		);
		this.lFtv = new Array(
		"0101*¼³³¯",
		"0115 ´ëº¸¸§",
		"0408*ºÎÃ³´Ô¿À½Å³¯",
		"0505 ´Ü¿À",
		"0707 Ä¥¼®",
		"0815*Ãß¼®");
		this.Lunar = new Lunar();
		},
	//====================================== À½·Â y³âÀÇ ³¯Â¥ ÃÑ¼ö¸¦ ¹ÝÈ¯
		Check:function(date) {
		  
		   var y = date.getFullYear();
		   var m = date.getMonth();
		   var day = date.getDate();
		   this.Lunar.Lunar(date);
		   this.color="";
		   this.title="";
			
			//¾ç·ÂÈÞÀÏ
			var i=0
			while(this.sFtv[i]){
		     
			  if(this.sFtv[i].match(/^(\d{2})(\d{2})([\s\*])(.+)$/)){
				  
		         if(Number(RegExp.$1)==(m+1)) {
		          
					if(Number(RegExp.$2)==day) {
				
						if(this.title) this.title +=",";
						this.title= RegExp.$4;
		            	if(RegExp.$3=='*') {this.color = 'red';}
						else {this.color = 'blue';}
				
					}
				}
			  }
			  i++;
			}
			i=0;
			//À½·ÂÈÞÀÏ
			

			
			while(this.lFtv[i]){
		      if(this.lFtv[i].match(/^(\d{2})(\d{2})([\s\*])(.+)$/)){
		         
				 if(Number(RegExp.$1)==(this.Lunar.month)) {
		            
					if(Number(RegExp.$2)==this.Lunar.day) {

						if(this.title) this.title +=",";
						this.title += RegExp.$4;
		            	if(RegExp.$3=='*') {this.color = 'red';}
						else {this.color = 'blue';}
					}
				}
			  }
			  i++;
			}
			
			
		}
			

});
var Lunar = Class.create(); 
Object.extend(Lunar.prototype, { 

		lunarInfo:null,//»ó¼ö
		year:null,//³âµµ
		month:null,//´Þ
		day:null,//ÀÏ
		text:null,//


		initialize: function(){
		this.lunarInfo=new Array(
		0x4bd8,0x4ae0,0xa570,0x54d5,0xd260,0xd950,0x5554,0x56af,0x9ad0,0x55d2,
		0x4ae0,0xa5b6,0xa4d0,0xd250,0xd295,0xb54f,0xd6a0,0xada2,0x95b0,0x4977,
		0x497f,0xa4b0,0xb4b5,0x6a50,0x6d40,0xab54,0x2b6f,0x9570,0x52f2,0x4970,
		0x6566,0xd4a0,0xea50,0x6a95,0x5adf,0x2b60,0x86e3,0x92ef,0xc8d7,0xc95f,
		0xd4a0,0xd8a6,0xb55f,0x56a0,0xa5b4,0x25df,0x92d0,0xd2b2,0xa950,0xb557,
		0x6ca0,0xb550,0x5355,0x4daf,0xa5b0,0x4573,0x52bf,0xa9a8,0xe950,0x6aa0,
		0xaea6,0xab50,0x4b60,0xaae4,0xa570,0x5260,0xf263,0xd950,0x5b57,0x56a0,
		0x96d0,0x4dd5,0x4ad0,0xa4d0,0xd4d4,0xd250,0xd558,0xb540,0xb6a0,0x95a6,
		0x95bf,0x49b0,0xa974,0xa4b0,0xb27a,0x6a50,0x6d40,0xaf46,0xab60,0x9570,
		0x4af5,0x4970,0x64b0,0x74a3,0xea50,0x6b58,0x5ac0,0xab60,0x96d5,0x92e0,
		0xc960,0xd954,0xd4a0,0xda50,0x7552,0x56a0,0xabb7,0x25d0,0x92d0,0xcab5,
		0xa950,0xb4a0,0xbaa4,0xad50,0x55d9,0x4ba0,0xa5b0,0x5176,0x52bf,0xa930,
		0x7954,0x6aa0,0xad50,0x5b52,0x4b60,0xa6e6,0xa4e0,0xd260,0xea65,0xd530,
		0x5aa0,0x76a3,0x96d0,0x4afb,0x4ad0,0xa4d0,0xd0b6,0xd25f,0xd520,0xdd45,
		0xb5a0,0x56d0,0x55b2,0x49b0,0xa577,0xa4b0,0xaa50,0xb255,0x6d2f,0xada0,
		0x4b63,0x937f,0x49f8,0x4970,0x64b0,0x68a6,0xea5f,0x6b20,0xa6c4,0xaaef,
		0x92e0,0xd2e3,0xc960,0xd557,0xd4a0,0xda50,0x5d55,0x56a0,0xa6d0,0x55d4,
		0x52d0,0xa9b8,0xa950,0xb4a0,0xb6a6,0xad50,0x55a0,0xaba4,0xa5b0,0x52b0,
		0xb273,0x6930,0x7337,0x6aa0,0xad50,0x4b55,0x4b6f,0xa570,0x54e4,0xd260,
		0xe968,0xd520,0xdaa0,0x6aa6,0x56df,0x4ae0,0xa9d4,0xa4d0,0xd150,0xf252,
		0xd520);
		
		
		},
	//====================================== À½·Â y³âÀÇ ³¯Â¥ ÃÑ¼ö¸¦ ¹ÝÈ¯
		lYearDays:function(y) {
		    var i, sum = 348;
		    for(i=0x8000; i>0x8; i>>=1) sum += (this.lunarInfo[y-1900] & i)? 1: 0;
		    return(sum+this.leapDays(y));
		},
		
		//====================================== À½·Â y³âÀÇ À±´Þ ³¯Â¥ ¼ö¸¦ ¹ÝÈ¯
		leapDays:function(y) {
		    if(this.leapMonth(y)) return( (this.lunarInfo[y-1899]&0xf)==0xf? 30: 29);
		    else return(0);
		},
		
		//====================================== À½·Â y³âÀÇ À±´ÞÀÌ ¸î¿ùÀÎÁö(1-12, À±´ÞÀÌ ¾ø´Â ÇØ¸é 0À» ¹ÝÈ¯)
		leapMonth:function(y) {
		    var lm = this.lunarInfo[y-1900] & 0xf;
		    return(lm==0xf?0:lm);
		},
		
		//====================================== À½·Â y³â m¿ùÀÇ ³¯Â¥ ÃÑ¼ö¸¦ ¹ÝÈ¯
		monthDays:function(y,m) {
		    return( (this.lunarInfo[y-1900] & (0x10000>>m))? 30: 29 );
		},
		
		
		//====================================== ß©õóÀ½·Â, îîìýìíÑ¢ÍóËì, À½·ÂìíÑ¢ÍóËì ¹ÝÈ¯
		//                                       ú±ÍóËìáÕàõêó .year .month .day .isLeap
		Lunar:function(objDate) {
			if(typeof(objDate)=="string"){
				var t=objDate.replace(/ /g,'').replace(/[^0-9]/g,'');
				objDate = new Date(t.substr(0,4),t.substr(4,2)-1,t.substr(6,2));
			}
		    var i, leap=0, temp=0;
		    var offset = (Date.UTC(objDate.getFullYear(),objDate.getMonth(),objDate.getDate()) - Date.UTC(1900,0,31))/86400000;
		
		    for(i=1900; i<2100 && offset>0; i++) { temp=this.lYearDays(i); offset-=temp; }
		
		    if(offset<0) { offset+=temp; i--; }
		
		    this.year = i;
		
		    leap = this.leapMonth(i); //À±¸îêÅ
		    this.isLeap = false;
		
		    for(i=1; i<13 && offset>0; i++) {
		        //À±êÅ
		        if(leap>0 && i==(leap+1) && this.isLeap==false) {
		            --i; this.isLeap = true; temp = this.leapDays(this.year);
		        }
		        else {
		            temp = this.monthDays(this.year, i);
		        }
		
		        //ú°ð¶À±êÅ
		        if(this.isLeap==true && i==(leap+1)) {
		            this.isLeap = false;
		        }
		        offset -= temp;
		    }
		
		    if(offset==0 && leap>0 && i==leap+1) {
		        if(this.isLeap) {
		            this.isLeap = false;
		        }
		        else {
		            this.isLeap = true; --i;
		        }
		    }
		
		    if(offset<0) {
		        offset += temp; --i;
		    }
		
		    this.month = i;
		    this.day = offset + 1;

			//this.text =  this.year+"-"+this.month+"-"this.day;
		}

});
var Carendal = Class.create(); 
Object.extend(Carendal.prototype, { 
    
	inputbox:null, //input box
	showBut:null,//´Þ·Â »ý¼º¹öÆ°
	carDiv:null,//´Þ·Â ·¹ÀÌ¾î
	headDiv:null,//»óºÎ ·¹ÀÌ¾î
	mainDiv:null,//¸ÞÀÎ ·¹ÀÌ¾î
	footDiv:null,//ÇÏºÎ ·¹ÀÌ¾î
	mailTb:null,//¸ÞÀÎ Å×ÀÌºí
	td:null,//Å¬·Ð¼¿
	toDay:null,//¿À´Ã³¯Â¥
	selDay:null,//¼±ÅÃ¿ù³¯Â¥
	nowDay:null,//Ãâ·Â³¯Â¥

	now_y:null,//Ãâ·Â³â
	now_m:null,//Ãâ·Â¿ù
	now_d:null,//Ãâ·ÂÀÏ
	
	preYbut:null,//ÀÌÀü³âµµ¹öÆ°
	nextYbut:null,//´ÙÀ½³âµµ¹öÆ°
	preMbut:null,//ÀÌÀü¿ù¹öÆ°
	nextMbut:null,//´ÙÀ½¿ù¹öÆ°
	yBox:null,//³âµµÇ¥½Ã¹Ú½º
	mBox:null,//¿ùÇ¥½Ã¹Ú½º
	toDiv:null,//¿À´Ã³¯Â¥Ç¥½Ã
	closeDiv:null,//´Ý±â
	selDiv:null,//¼±ÅÃÀÏÇ¥½Ã
	debug:null,//µð¹ö±ë
	arr:null,//ÆË¾÷Ã¢
	//Lunar:null,//À½·Â
	dtDiv:null,//»ó¼¼Á¤º¸
	Holiday:null,//ÈÞÀÏ
	navi:null,//ºê¶ó¿ìÁ® N=FF / M=IE

  
	
	initialize: function (inputbox){   
		this.debug=null;
		if(this.debug) {
			this.arr = window.open('','Carendal','toolbar=yes,scrollbars=yes,width=400,height=300');
			this.arr.document.open("text/html","replace");
			this.arr.document.write(inputbox.name+' init start <br>');
			//alert($('edu_off_lec_no').getAttribute('ival'));
		}
	//this.Lunar = new Lunar();
	this.Holiday = new Holiday();
	this.inputbox=inputbox;

	this.navi=navigator.appName.charAt(0);


		if(!this.carDiv) {
			
			this.carDiv = document.createElement('div');
			this.carDiv.style.backgroundColor="#ffffff";
			this.carDiv.style.display="none";
			this.carDiv.style.width="0";

			this.carDiv.style.position="absolute";
			this.carDiv.style.border="1px solid black";
			this.carDiv.style.zIndex="100";
			document.body.appendChild(this.carDiv);
		}
		if(!this.dtDiv) {
			
			this.dtDiv = document.createElement('div');
			
			this.dtDiv.style.display="none";
			this.dtDiv.style.position="absolute";
			this.dtDiv.style.backgroundColor="#ffffff";
			this.dtDiv.style.border="1px solid black";
			this.dtDiv.style.zIndex="101";
			this.dtDiv.style.fontSize="10px";
			document.body.appendChild(this.dtDiv);
		}
		
	if(this.debug) {this.arr.document.write(' document.createElement(div) <br>');	}


	
	//±âº» ³¯Â¥ »ý¼º
	this.toDay = new Date();
	
	
	
	
	if(this.debug) {this.arr.document.write('±âº» ³¯Â¥ »ý¼º end <br>');	}
	//»ý¼º¹öÆ°
	this.showBut = document.createElement('img');
	this.showBut.src = "/IMG/calender.gif";///img_new/edu_new/calender.gif
	this.showBut.style.cursor ="pointer";
	this.showBut.style.border ="none";
	this.showBut.align ="absmiddle";
	this.showBut.onclick=this.xshow.bindAsEventListener(this);
	
	if (this.inputbox.nextSibling){ this.inputbox.parentNode.insertBefore(this.showBut,this.inputbox.nextSibling);}
	else{ this.inputbox.parentNode.appendChild(this.showBut);}
	/*
	if (this.inputbox.nextSibling){ this.inputbox.parentNode.insertBefore(this.carDiv,this.inputbox.nextSibling);}
	else{ this.inputbox.parentNode.appendChild(this.carDiv);}	
	*/

	if(this.debug) {this.arr.document.write('»ý¼º¹öÆ° end <br>');	}

	//·¹ÀÌ¾Æ¿ô
	this.headDiv = document.createElement('div');//»óºÎ·¹ÀÌ¾î
	this.headDiv.style.width="100%";
	this.headDiv.style.textAlign="center";
	this.carDiv.appendChild(this.headDiv);

	this.mainDiv = document.createElement('div');//¸ÞÀÎ·¹ÀÌ¾î
	this.mainDiv.style.width="100%";

	this.carDiv.appendChild(this.mainDiv);

	this.footDiv = document.createElement('div');//ÇÏºÎ·¹ÀÌ¾î
	this.footDiv.style.width="100%";
	
	this.carDiv.appendChild(this.footDiv);
	if(this.debug) {this.arr.document.write('·¹ÀÌ¾Æ¿ô end <br>');	}

	
	//»óºÎ
	//¹öÆ° ±âº»Çü
	var but = document.createElement('input');
	but.type="button";
	with(but.style){
		fontSize="10px";
		padding="0px";
		width="18px";
		height="16px";
		backgroundColor= "#d4d0c8";

		borderWidth="1px";
		borderColor= "#000000";
		borderStyle= "outset";
		
	}
	
	if(this.debug) {this.arr.document.write('±âº»Çü1 end <br>');	}
	// ÅØ½ºÆ®¹Ú½º ±âº»Çü
	var text = document.createElement('input');
	text.type="text";
	text.readOnly=true;
	with(text.style){
		//width=(this.inputbox.clientWidth+this.showBut.clientWidth - (18*4))/2-2;
		fontSize="10px";
		border="1px solid #999999";
		padding="0px";
		height="14px";
		fontWeight="bolder";
		textAlign='center';
	}
	if(this.debug) {this.arr.document.write('±âº»Çü end <br>');	}

	this.preYbut=but.cloneNode(true);//ÀÌÀü³âµµ
	this.preYbut.value="-³â";
	this.preYbut.title="pre year";
	this.preYbut.onclick=this.preYear.bindAsEventListener(this);

	this.preMbut=but.cloneNode(true);//ÀÌÀü¿ù
	this.preMbut.value="-¿ù";
	this.preMbut.title="pre month";
	this.preMbut.onclick=this.preMon.bindAsEventListener(this);

	this.yBox=text.cloneNode(true);//³âµµÇ¥½Ã¹Ú½º
	this.mBox=text.cloneNode(true);//¿ùÇ¥½Ã¹Ú½º
	

	this.nextMbut=but.cloneNode(true);//ÀÌÀü¿ù
	this.nextMbut.value="+¿ù";
	this.nextMbut.title="next month";
	this.nextMbut.onclick=this.nextMon.bindAsEventListener(this);

	this.nextYbut=but.cloneNode(true);//´ÙÀ½¿ù
	this.nextYbut.value="+³â";
	this.nextYbut.title="next year";
	this.nextYbut.onclick=this.nextYear.bindAsEventListener(this);

	this.headDiv.appendChild(this.preYbut);
	this.headDiv.appendChild(this.preMbut);
	this.headDiv.appendChild(this.yBox);
	this.headDiv.appendChild(this.mBox);
	this.headDiv.appendChild(this.nextMbut);
	this.headDiv.appendChild(this.nextYbut);
	
	if(this.debug) {this.arr.document.write('»óºÎ end <br>');	}


	//¸ÞÀÎ
	this.mainTb = document.createElement('table');//¸ÞÀÎÅ×ÀÌºí
	this.mainTb.width='100%';
	this.mainTb.border=1; 
	this.mainTb.cellspacing=0;
	this.mainTb.cellpadding=0;
	this.mainTb.style.borderCollapse='collapse';	
	this.td = document.createElement('td');
	this.td.style.fontSize='12px';
	this.td.style.fontWeight='bold';
	
	this.td.style.textAlign='center';
	this.td.style.border='1px solid #eeeeee';
	
	var ta_cal_tr1 = this.mainTb.insertRow(-1);
	
	var day_header = ["ÀÏ", "¿ù", "È­", "¼ö", "¸ñ", "±Ý", "Åä"];
	var i=0
	while(day_header[i]){
		var ftd = ta_cal_tr1.insertCell(i);
		ftd.style.cssText=this.td.style.cssText;
		ftd.innerHTML=day_header[i];
		if(i==0) ftd.style.color="#C00000";
		else if(i==6) ftd.style.color="#35A3FD";
		i++;
	}

	
	this.td.style.fontWeight='normal';
	this.td.style.fontSize='12px';
	
	this.mainDiv.appendChild(this.mainTb);
	if(this.debug) {this.arr.document.write('¸ÞÀÎ end <br>');	}

	//ÇÏºÎ
	var temtb = document.createElement('table');
	temtb.width='100%';
	temtb.border=0; 
	temtb.cellspacing=0;
	temtb.cellpadding=0;
	var temtr = temtb.insertRow(-1);
	this.toDiv=	temtr.insertCell(-1);


	//this.toDiv = document.createElement('span');//¿À´Ã³¯Â¥¹Ù·Î°¡±â
	this.toDiv.title = "¿À´Ã³¯Â¥¹Ù·Î°¡±â";
	this.toDiv.style.width="40%";
	this.toDiv.style.fontSize="10px";
	this.toDiv.innerHTML="x";
	this.toDiv.style.textAlign="center";
	this.toDiv.style.cursor="pointer";
	this.toDiv.onclick=this.goToday.bindAsEventListener(this);
	this.toDiv.innerHTML=this.makeDay(this.toDay);
	if(this.debug) {this.arr.document.write('ÇÏºÎ 1 <br>');	}
	
	this.closeDiv=	temtr.insertCell(-1);
	//this.closeDiv = document.createElement('span');//´Ý±â
	if(this.debug) {this.arr.document.write('ÇÏºÎ 2 <br>');	}
	this.closeDiv.title = "´Þ·Â´Ý±â";

	this.closeDiv.style.width="20%";
	this.closeDiv.style.fontSize="12px";
	this.closeDiv.style.color="red";
	this.closeDiv.style.fontWeight="bold";
	this.closeDiv.innerHTML="´Ý±â";
	if(this.debug) {this.arr.document.write('ÇÏºÎ 3 <br>');	}
	this.closeDiv.style.textAlign="center";
	this.closeDiv.style.cursor="pointer";

	if(this.debug) {this.arr.document.write('ÇÏºÎ 4 <br>');	}
	this.closeDiv.onclick=this.xhide.bindAsEventListener(this);

	if(this.debug) {this.arr.document.write('ÇÏºÎ 5 <br>');	}
	
	this.selDiv=	temtr.insertCell(-1);
	//this.selDiv = document.createElement('span');//¼±ÅÃ³¯Â¥¹Ù·Î°¡±â
	this.selDiv.title = "¼±ÅÃ³¯Â¥¹Ù·Î°¡±â";
	this.selDiv.style.width="40%";
	this.selDiv.style.fontSize="10px";
//	this.selDiv.innerHTML="x";
	this.selDiv.style.textAlign="center";
	this.selDiv.style.cursor="pointer";
	this.selDiv.onclick=this.goSelday.bindAsEventListener(this);
	if(this.debug) {this.arr.document.write('ÇÏºÎ end <br>');	}

	this.footDiv.appendChild(temtb);



	if(this.debug) {this.arr.document.write('init end <br>');	}
	
    },
	
	preYear: function(){
		if(this.debug) {this.arr.document.write('preYear start <br>');	}
		this.now_y = this.now_y -1;
		this.changeCal();
		if(this.debug) {this.arr.document.write('preYear end <br>');	}
	},
	preMon: function(){
		if(this.debug) {this.arr.document.write('preMon start <br>');	}
		this.now_m = this.now_m -1;
		this.changeCal();
		if(this.debug) {this.arr.document.write('preMon end <br>');	}
	},
	nextYear: function(){
		if(this.debug) {this.arr.document.write('nextYear start <br>');	}
		this.now_y = this.now_y +1;
		this.changeCal();
		if(this.debug) {this.arr.document.write('nextYear end <br>');	}
	},
	nextMon: function(){
		if(this.debug) {this.arr.document.write('nextMon start <br>');	}
		this.now_m = this.now_m +1;
		this.changeCal();
		if(this.debug) {this.arr.document.write('nextMon end <br>');	}
	},
	goToday: function(){
		if(this.debug) {this.arr.document.write('goToday start <br>');	}
		this.now_y = this.toDay.getFullYear();
		this.now_m= this.toDay.getMonth()+1;
		this.changeCal();
		if(this.debug) {this.arr.document.write('goToday end <br>');	}
	},
	goSelday: function(){

		if(this.debug) {this.arr.document.write('goSelday start <br>');	}
		if(this.selDay != null){
			this.now_y = this.selDay.getFullYear();
			this.now_m= this.selDay.getMonth()+1;
			this.changeCal();
		}else {
			alert("¼±ÅÃÀÏÀÌ ¾ø½À´Ï´Ù");
		}
		if(this.debug) {this.arr.document.write('goSelday end <br>');	}
	},

	valueSet: function(){
		if(this.debug) {this.arr.document.write('valueSet start <br>');	}
		
		var value = this.inputbox.value.toString().replace(/ /g,'').replace(/[^0-9]/g,'');
		

		if(value.length>=6){
			this.selDay.setFullYear(value.substr(0,4),value.substr(4,2)-1,value.substr(6,2));
		}
		

		if(this.debug) {this.arr.document.write('valueSet end <br>');	}
	},

	makeDay: function (date){
		if(this.debug) {this.arr.document.write(date+'makeDay start <br>');	}

		var year = date.getFullYear().toString();
		var mon = (date.getMonth()+1).toString();
		var day = date.getDate().toString();
		var retval = "";
	
		retval = year;
		retval += '-'+(mon.length < 2? "0" + mon:mon);
		retval += '-'+(day.length < 2? "0" + day:day);
		
		if(this.debug) {this.arr.document.write(retval+' makeDay end <br>');	}
		return retval;

		
	},
	setClick: function (e){
		if(this.debug) {this.arr.document.write('setClick start <br>');	}

		if(this.navi=='M') {
			srcElement = event.srcElement;		
		}else{
			event=e;
			srcElement = e.currentTarget;
		}

			this.inputbox.value=srcElement.title;
			this.xhide();
		if(this.debug) {this.arr.document.write('setClick end <br>');	}
	},
	makeCal: function (){
		if(this.debug) {this.arr.document.write('makeCal start <br>');	}
		//½ÃÀÛ¿äÀÏ
		
		var	firstday = new Date(this.now_y,this.now_m-1,1);
		
			firstday.setDate(1-1*firstday.getDay());
	
		if(this.debug) {this.arr.document.write('makeCal 1 <br>');	}
		//³¡³¯
		var	endday = new Date(this.now_y,this.now_m,1);

		if(7-endday.getDay()!=7)endday.setDate(7-endday.getDay());

		

		if(this.debug) {this.arr.document.write('makeCal 2 <br>');	}
		
		
		for(var j=this.mainTb.rows.length;j>1;j--){
				this.mainTb.deleteRow(j-1);
		}
		while(firstday.getTime() < endday.getTime() ){
			var tem_tr = this.mainTb.insertRow(-1);
			
			
			for(i=0;i<7;i++){
				
				var tem_td = tem_tr.insertCell(i);
				this.retval = 
				tem_td.innerHTML = firstday.getDate();
				tem_td.title=this.makeDay(firstday);
			//	this.Lunar.Lunar(tem_td.title);
				
				this.Holiday.Check(firstday);
				
				tem_td.setAttribute("holiday",this.Holiday.title);
				
				if(this.Holiday.Lunar.isLeap==false) tem_td.setAttribute("lunar",this.Holiday.Lunar.year+"-"+this.Holiday.Lunar.month+"-"+this.Holiday.Lunar.day);
				else tem_td.setAttribute("lunar",this.Holiday.Lunar.year+"-"+this.Holiday.Lunar.month+"-"+this.Holiday.Lunar.day+"-À±´Þ");
				
				tem_td.style.cssText = this.td.style.cssText;
				tem_td.style.cursor='pointer';

					tem_td.onclick=this.setClick.bindAsEventListener(this);
					tem_td.onmouseover=this.detailview.bindAsEventListener(this);
					tem_td.onmouseout=this.detailhide.bindAsEventListener(this);

				if(i==0){tem_td.style.color='#C00000';}//ÀÏ¿äÀÏ
				else if(i==6){tem_td.style.color='#35A3FD';}//Åä¿äÀÏ
				
				if(tem_td.title==this.selDiv.innerHTML){//¼±ÅÃÀÏ
					tem_td.style.fontWeight='bold'
					tem_td.style.backgroundColor='#FACDCD'
				}else if( tem_td.title==this.toDiv.innerHTML ){//¿À´Ã
					

					tem_td.style.fontWeight='bold';
					tem_td.style.backgroundColor='#CFCFFA'
				
				}else if(firstday.getMonth() !=this.nowDay.getMonth()){//ÀÌÀü´Þ ´ÙÀ½´Þ ¹ÙÅÁ
					tem_td.style.backgroundColor='#F7F7F7'
				}else if(this.Holiday.color=='red'){//ÈÞÀÏ
					tem_td.style.color='#C00000';
				}else if(this.Holiday.color=='blue'){//ÈÞÀÏ
					tem_td.style.color='#35A3FD';
				}

				//±â³äÀÏ

				
				firstday.setDate(firstday.getDate()+1);
			}
		}



		//Aprint(this.dtDiv.style);

		if(this.debug) {this.arr.document.write('makeCal end <br>');	}
		
	},
	holiday: function(){
		
	},
	detailhide: function(e){
		this.dtDiv.style.display="none";
	},
	detailview: function (e){
		if(this.navi=='M') {
			srcElement = event.srcElement;		
		}else{
			
			event=e;
			srcElement = e.currentTarget;
		}
		
		this.dtDiv.style.left=(event.clientX+srcElement.clientWidth/2)+'px';
		this.dtDiv.style.top=(event.clientY)+'px';
		this.dtDiv.style.display="inline";
		this.dtDiv.innerHTML="";
		
		if(srcElement.getAttribute("holiday")){//È¦¸®µ¥ÀÌ
			this.dtDiv.innerHTML+=srcElement.getAttribute("holiday")
		}
		
		if(this.dtDiv.innerHTML) this.dtDiv.innerHTML+="<br>";
		this.dtDiv.innerHTML+="À½·Â:"+srcElement.getAttribute("lunar");
		//Aprint(e);

	},
	changeCal: function (){
		
		if(this.debug) {this.arr.document.write('changCal start <br>');	}
		

		if(this.now_m != null && this.now_y != null ) {
			if(this.now_m == 0) {
				this.now_m = 12;
				this.now_y--;
			} else if(this.now_m == 13) {
				this.now_m = 1;
				this.now_y++;
			}
			

			this.mBox.value=this.now_m;
			this.yBox.value=this.now_y;
			this.nowDay.setMonth(this.now_m-1);
			this.nowDay.setFullYear(this.now_y);
		}
		
		//alert(this.now_y);
		this.makeCal();
		

		if(this.debug) {this.arr.document.write('changeCal end <br>');	}
	},
	xshow: function (e){
		if(this.debug) {this.arr.document.write('xshow start <br>');	}
		//alert(this.inputbox.value.replace(/ /g,"").length);
		//alert(this.inputbox.value.replace(/ /g,"").length);
		/*
			º¸±â ¹öÆ° Å¬¸¯½Ã inputbox.value °ªÀ¸·Î ¼±ÅÃ³¯Â¥ ÁöÁ¤
			¼±ÅÃ³¯Â¥ À¯¹«¿¡ µû¶ó Ãâ·Â³¯Â¥ ÁöÁ¤

		*/
		//Ãâ·Â³¯Â¥
		//this.preYbut.className="test";
		
		//Aprint(this.preYbut.currentStyle);
		/*
		var sels = document.getElementsByTagName("select");
		
		for(var i=0;i<sels.length;i++){
			sels[i].style.display="none";
		}
		*/
		

		//¼±ÅÃ³¯Â¥ ¼³Á¤
		if(this.inputbox.value.toString().replace(/ /g,'').replace(/[^0-9]/g,'').length>0) {
			this.selDay = new Date();
			this.valueSet();
			this.nowDay= new Date(this.selDay.getFullYear(),this.selDay.getMonth(),this.selDay.getDate());//¼±ÅÃÀÏÀÌ ÀÖÀ¸¸é ÇöÀçÆäÀÌÁö´Â ¼±ÅÃ³¯Â¥·Î
			this.selDiv.innerHTML=this.makeDay(this.selDay);
		}
		else {
			this.selDay = null;
			this.nowDay = new Date();//¼±ÅÃÀÏ ¾øÀ¸¸é ÇöÀçÆäÀÌÁö´Â ¿À´Ã³¯Â¥·Î
			this.selDiv.innerHTML="¼±ÅÃÀÏ ¾øÀ½";
		}
		
		//Ãâ·Â ³â ¿ù ÁöÁ¤
		this.now_y=this.nowDay.getFullYear();
		this.now_m=this.nowDay.getMonth()+1;
		
	
		if(this.navi=='M') {
			srcElement = event.srcElement;		
		}else{
			event=e;
			srcElement = e.currentTarget;
		}
		
		offset = Position.cumulativeOffset(this.inputbox);
		
		//´Þ·Â À§Ä¡ Á¶Á¤
		this.carDiv.style.display="inline";
		this.carDiv.style.left=(offset[0])+'px';
		this.carDiv.style.top=(offset[1]+this.inputbox.offsetHeight)+'px';
		this.carDiv.style.width=(this.inputbox.clientWidth+this.showBut.clientWidth+4)+'px';
		
		//¿À´Ã³¯Â¥¿Í ¼±ÅÃÀÏ ÀÔ·Â
	
		

		//´Þ·Â ÀÏÀÚ º¯°æ »ý¼º
		this.changeCal();
		
		this.yBox.style.width=this.mBox.style.width=(this.carDiv.clientWidth-20*4)/2+'px';
		//ÇÏºÎ³ÊºñÁ¶Á¤
		this.toDiv.style.width="40%";
		this.closeDiv.style.width="20%";
		this.selDiv.style.width="40%";
		
		selectbox_hidden(this.carDiv);
		if(this.debug) {this.arr.document.write('xshow end <br>');	}
		
	},
	xhide: function (){
		if(this.debug) {this.arr.document.write('xhide start <br>');	}
		/*
		var sels = document.getElementsByTagName("select");
		for(var i=0;i<sels.length;i++){
			sels[i].style.display="inline";
		}
		*/
			selectbox_visible() ;
			this.carDiv.style.display="none";
		if(this.debug) {this.arr.document.write('xhide end <br>');	}
		
	}

	

}); 



