<!--

	function calendar(){
		this.today = new Date();
		this.year = this.today.getYear();
		this.month = this.today.getMonth();
		this.day = this.today.getDate();
		this.week = (new Date(this.year,this.month,1)).getDay();

		this.div = null;
		this.table = null;
		this.table_label = null;
		this.table_yoil = null;
		this.target_cal = null;

		this.expandYear = null;
		this.back = null;

	}

	calendar.prototype.getLastDate = function(){
		return ((new Date(this.year,this.month+1,0)).getDate());
	}

	calendar.prototype.getPrevDate = function(){
		return ((new Date(this.year,this.month,0)).getDate());
	}

	calendar.prototype.setPrev = function(){
		if( this.month == 0 ){
			this.year = this.year - 1;
			this.month = 11;
		}else{
			this.month = this.month - 1;
		}
		this.week = (new Date(this.year,this.month,1)).getDay();
	}
	calendar.prototype.setPrevY = function(){
			this.year = this.year - 1;
		this.week = (new Date(this.year,this.month,1)).getDay();
	}

	calendar.prototype.setCYear = function( yy ){
		this.year = yy;
		this.week = (new Date(this.year,this.month,1)).getDay();
	}

	calendar.prototype.setNext = function(){
		if( this.month == 11 ){
			this.year = this.year + 1;
			this.month = 0;
		}else{
			this.month = this.month + 1;
		}
		this.week = (new Date(this.year,this.month,1)).getDay();
	}
	calendar.prototype.setNextY = function(){
			this.year = this.year + 1;
		this.week = (new Date(this.year,this.month,1)).getDay();
	}

	calendar.prototype.setInit = function(){
		for( var i = (this.table.rows.length-1) ; i >= 0 ; i-- ){
			for( var s = 6 ; s >= 0 ; s-- ){
				this.table.rows[i].deleteCell(s);
			}
			this.table.deleteRow(i);
		}
	}

	calendar.prototype.setLabel = function(){
		this.table_label.rows[0].cells[2].innerHTML = this.year + "년" + ( this.month + 1 ) + "월";
	}

	function mk2( str ){
		if( str.length == 1 ){
			return "0"+str;
		}else{
			return str;
		}
	}

	calendar.prototype.setPvalue = function( dd ){
		
		if( this.month == 0 ){
			this.target_cal.value = ( this.year-1 ) + "-12-" + mk2(dd.toString());
		}else{
			this.target_cal.value = this.year + "-" + mk2(( this.month  ).toString()) + "-" + mk2(dd.toString());
		}

		this.div.style.display = "none";
		this.back.style.display = "none";

	}
	calendar.prototype.setCvalue = function( dd ){
		this.target_cal.value = this.year + "-" +  mk2(( this.month + 1 ).toString()) + "-" + mk2(dd.toString());
		this.div.style.display = "none";
		this.back.style.display = "none";
	}
	calendar.prototype.setNvalue = function( dd ){
		if( this.month == 11 ){
			this.target_cal.value = ( this.year+1 ) + "-01-" + mk2(dd.toString());
		}else{
			this.target_cal.value = this.year + "-" + mk2(( this.month  + 2 ).toString()) + "-" + mk2(dd.toString());
		}
		this.div.style.display = "none";
		this.back.style.display = "none";
	}


	calendar.prototype.draw = function(){
		
		var thisPath = this;
		

		if( ! this.div ){



			this.table_label = document.createElement("table");
			
			this.table_label.cellSpacing="1px";
			this.table_label.cellPadding="2px";
			//this.table_label.bgColor = "#1053a4";
			this.table_label.width = "152px";
			var _tr = this.table_label.insertRow();
			_tr.className = "cal_lb";
			var td_left1 = _tr.insertCell();
			td_left1.className = "cal_lb_left1";
			var td_left = _tr.insertCell();
			td_left.className = "cal_lb_left";
			var td_center = _tr.insertCell();
			td_center.className = "cal_lb_center";
			var td_right = _tr.insertCell();
			td_right.className = "cal_lb_right";
			var td_right1 = _tr.insertCell();
			td_right1.className = "cal_lb_right1";
			var td_close = _tr.insertCell();
			td_close.className = "cal_lb_close";

			td_left.onclick = function(){
				thisPath.setPrev();
				thisPath.setInit();
				thisPath.draw();
				thisPath.setLabel();
			}
			td_left1.onclick = function(){
				thisPath.setPrevY();
				thisPath.setInit();
				thisPath.draw();
				thisPath.setLabel();
			}

			td_right.onclick = function(){
				thisPath.setNext();
				thisPath.setInit();
				thisPath.draw();
				thisPath.setLabel();
			}
			td_right1.onclick = function(){
				thisPath.setNextY();
				thisPath.setInit();
				thisPath.draw();
				thisPath.setLabel();
			}
			td_close.onclick = function(){
				thisPath.div.style.display = "none";
				this.back.style.display = "none";
				if( thisPath.expandRow ){
					thisPath.expandRow.style.display = "none";
				}
			}

			this.table_yoil = document.createElement("table");
			this.table_yoil.cellSpacing="1px";
			this.table_yoil.bgColor = "#EFEFEF";
			this.table_yoil.cellPadding="0px";
			var yo = new Array("일","월","화","수","목","금","토","일");
			var tr_yo = this.table_yoil.insertRow();

			for( var i = 0 ; i < 7 ; i++ ){
				var td_yo = tr_yo.insertCell();
				td_yo.className = "cal_yo";
				td_yo.innerHTML = yo[i];
			}
			td_left1.innerHTML= "<img src='/front/images/cal/ico_leftarrow.gif' alt='이전년도' border='0' />";
			td_left.innerHTML= "<img src='/front/images/cal/ico_leftarrow.gif' alt='이전달' border='0' />";
			td_center.innerHTML= this.year + "년" + ( this.month + 1 ) + "월";
			td_center.style.fontWeight = "bold";
			td_right.innerHTML= "<img src='/front/images/cal/ico_rightarrow.gif' alt='다음달' border='0' />";
			td_right1.innerHTML= "<img src='/front/images/cal/ico_rightarrow.gif' alt='다음년도' border='0' />";
			td_close.innerHTML= "<img src='/front/images/cal/bt_close.gif'>";


			td_center.onclick = function(){

				var _x = event.x + document.body.scrollLeft - ( event.offsetX ) - 5;
				var _y = event.y + document.body.scrollTop + ( 20 - event.offsetY );
				
				if( ! thisPath.expandRow ){

					thisPath.expandRow = document.createElement("div");
					thisPath.expandRow.style.position = "absolute";
					thisPath.expandRow.style.border = "solid 2px #AEC935";
					thisPath.expandRow.style.zIndex = 10010;
					thisPath.expandRow.style.left = _x;
					thisPath.expandRow.style.top = _y;

					var yearRow = document.createElement("table");
					yearRow.style.backgroundColor = "#FFFFFF";
					
					var tr = null;
					for( var i = 2000; i < 2010 ; i ++ ){
						if( i % 3 == 2 ){
							tr = yearRow.insertRow();
						}
						var td = tr.insertCell();
						td.style.fontFamily = "verdana";
						td.style.fontSize = "11";
						td.style.color = "#AEC935";
						td.style.cursor = "hand";
						td.onmouseover = function(){
							//this.style.backgroundColor = "#333333";
							this.style.color = "#5d9424";
						}
						td.onmouseout = function(){
							//this.style.backgroundColor = "#FFFFFF";
							this.style.color = "#AEC935";
						}
						td.innerHTML = i;
						td.onclick = function(){
							thisPath.setCYear( parseInt(this.innerHTML) );
							thisPath.setInit();
							thisPath.draw();
							thisPath.setLabel();
							thisPath.expandRow.style.display = "none";
						}
					}

					thisPath.expandRow.appendChild(yearRow);

					document.body.appendChild(thisPath.expandRow);
				}else{
					thisPath.expandRow.style.display = "block";
					thisPath.expandRow.style.left = _x;
					thisPath.expandRow.style.top = _y;
				}

			}


			this.div = document.createElement("div");
			this.table = document.createElement("table");
			this.table.cellSpacing = "1px";
			this.table.cellPadding = "0px";
			this.table.border = "0px"
			this.table.bgColor = "#CCCCCC";

			

			this.out = document.createElement("table");
			this.out.cellPadding = "0px";
			this.out.cellSpacing = "0px";
			this.out.border = "0px";
			var tr_out_top = this.out.insertRow();
			var td_out_top = tr_out_top.insertCell();
			td_out_top.innerHTML = "<img src='/front/images/cal/cal_top.gif'>";

			var tr_out_mid = this.out.insertRow();
			var td_out_mid = tr_out_mid.insertCell();
			td_out_mid.style.paddingLeft = "6px";
			td_out_mid.style.paddingBottom = "10px";
			td_out_mid.style.background = "url('/front/images/cal/cal_mid.gif') repeat-y";

			var tr_out_bot = this.out.insertRow();
			var td_out_bot = tr_out_bot.insertCell();
			td_out_bot.innerHTML = "<img src='/front/images/cal/cal_bot.gif'>";

			this.div.appendChild( this.out );
					
			td_out_mid.appendChild( this.table_label , true );
			td_out_mid.appendChild( this.table_yoil , true );
			td_out_mid.appendChild( this.table , true );

			
			

			this.div.style.position = "absolute";
			//this.div.style.border = "solid 1px #1053a4";
			//this.div.style.backgroundImage = "url('../../common/css/cal_top.gif')";
			this.div.style.padding = "10px 10px 10px 10px ";
			this.div.style.zIndex = 10000;
			this.div.style.display = "none";
			
			//
			this.back = document.createElement("iframe");
			this.back.src = "about:blank";
			this.back.style.zIndex = 9000;
			this.back.style.position = "absolute";	
			this.back.style.border = "none";		
			this.back.style.width = this.div.style.width;
			this.back.style.height = this.div.style.height;
			this.back.style.backgroundColor = "transparent";
			this.back.frameBorder = "0";
			
			try{
				//document.body.appendChild( this.div);
			}catch(E){
			}
		}

		var n = 0;
		var m = 0;
		var flag = false;
		var endday = this.getLastDate();
		var rowend = false;
		var s = this.getPrevDate() -  this.week ;


		for( var i = 0 ; i < 6 ; i++ ){

				if( rowend ) break;
				var tr = this.table.insertRow();
				
				for( var j = 0 ; j < 7 ; j++ ){
					var td = tr.insertCell();
					if( (n+1) == this.day && this.month == ( new Date() ).getMonth() && this.year == ( new Date() ).getYear()){ td.className = "cal_now"; }
					else if( j == 0 ){ td.className = "cal_sun"; }
					else if( j == 6 ){ td.className = "cal_sat"; }
					else{ td.className = "cal"; }

					if( i == 0 && j == this.week ){	flag = true; }
					
					if( flag ){
						if( n >= endday ){
							td.innerHTML = ++m;	
							rowend = true;
							td.className = "cal_not";
							
							td.data = m;
							td.onclick = function(){
								thisPath.setNvalue( this.data );
							}
							 
						}else{
							td.innerHTML = ++n;
							td.data = n;
							td.onclick = function(){
								thisPath.setCvalue( this.data );
							}
						}
					}else{
						td.className = "cal_not";
						td.innerHTML = ++s;
						td.data = s;
						td.onclick = function(){
							thisPath.setPvalue( this.data );
						}
					}

				}
			}


	}


	var cal = new calendar();
	cal.draw();

	

	function showCal( obj ){
		
		document.body.appendChild( cal.div );
		
		var flag = false;
		for( var i = 0 ; i < document.body.childNodes.length ; i++ ){
			if( document.body.childNodes[i] == cal.back ){
				flag = true;
			}
		}
		if( flag == false ){
			document.body.appendChild( cal.back );
		}

		cal.target_cal = obj;

		var _tx = event.x + document.body.scrollLeft - ( event.offsetX + 0 ) + 120 ;
		var _ty = event.y + document.body.scrollTop + ( 98 - event.offsetY );


		cal.div.style.left = _tx;
		cal.div.style.top = _ty;
		cal.div.style.display = "block";
		
		cal.back.style.left = _tx + 10;
		cal.back.style.top = _ty + 10;
		cal.back.style.width = "163px";
		cal.back.style.height = "195px";
		cal.back.style.display = "block";
		
		if( cal.expandRow ){
			cal.expandRow.style.display = "none";
		}

		
	}

	

//-->