/****************************************************************************** 
* **
* V 1.1.3
* - 기존 년도 선택되지 않은 문제 추가
* - MS 필터에 따른 마우스 오버 이벤트에 따라 스타일 효과에 대한 클라이언트 부하가 존재하여
* 스타일 쉬트에 대한 전면 조정 작업.
* - 여러개의 객체 생성 할 경우 blur 이벤트 발생에 대한 포커스 이동이 숨겨진 SELECT BOX 를 통해 이루어져
* 다른 달력 객체에 대한 이동이 번거로웠음.
*
* **
* V 1.xx
*
* input=text object에 대한 Data Picker Script 
* HTC로 개발하였으나, 잦은 IE 충돌로 인하여 변형함. 
* IE 5.5 이상에서 테스트 
* 사용법 : <input type="text" name="textbox" value="2006-01-01" isEmpty="true"  empty="날짜없음" 
* arrowImage="/images/ico_dtp_def.gif" prevImage="/images/ico_arrow_left_gray.gif" nextImage="/images/ico_arrow_right_gray.gif"> 
* 해결 문제 : 해당객체의 disabled = true일때 이벤트 훅킹이 어려움, 이벤트에 따른 색상 교체 소스 최적화 -_-;; 
* **  
* Last update : 2006. 
* Copyright (c) 2006, By Lee N.THU 
* e-Mail : <support@x-wiz.com> 
* - 사람이면 맘대로 쓸 수 있는 데, 단 제작자 표기는 해주삼. 
* PS : 달력 선택 시 SELECT BOX 또는 팝업창 형태인것이 불편해 4시간 동안 고민해서 제작 -.-, 년도 선택부분 시간관계상 생략 
* 
*
*
******************************************************************************/ 
var xwzDatePicker = function(objTextbox){
	if(window.__xwzDatePickers == null) window.__xwzDatePickers = new Array(0);
	this.index = window.__xwzDatePickers.length;
	window.__xwzDatePickers[this.index] = this;

	this.oText = objTextbox;
	this.dtCurrent = null;//입력된 날짜
	this.dtDisplay = new Date();//출력용 날짜
	this.objField =null;// 디스플레이 테이블
	this.objLabel = null;// 날짜 출력될 셀
	this.objArrow = null;// 화살표 셀
	this.imgArrow = null;// 화살표 이미지
	this.isEmpty = false;// 날짜 없음 을 출력할지 여부
	this.emptyValue = "";// 날짜 없음 표기 값
	this.isVisible = false;// 팝업창 보임 여부
	this.isActive = false;// 활성화되었는지 여부
	this.Images = {arrow : "", prev : "", next : ""};//디스플레이에서 화살표 이미지,  달력에서 이전, 다음 이미지
	this.Week = new Array(0);// 주 표기 텍스트 배열
	this.Formula = new Array(0);//날짜 포멧 형태
	this.WeekColor = ['#CC0000', '', '', '', '', '','#0066CC'];//일별 색상
	this.Styles = {def:new Array(0), hov:new Array(0), act:new Array(0), flt:new Array(0)}// 기본, 마우스 오버, 활성화 되었을 때 색상 설정, 활성화, 오버 되었을 때 오른쪽 화살표 필터효과 색상

	this.objWindow = null;//팝업창 객체
	this.lblCaption = null;// 달력에서 월, 년 표기 레이어
	this.lblEmpty = null;// 달력에서 날짜 없음 출력 객체
	this.cellCalendar = null;//달력의 각 셀을 배열로 저장

	this.setLanguage("ko");//기본 날짜 출력 포멧을 한글
	//기본 색상 설정
	this.setStyleColor("default:#ABC1DE,#EAF2FB,#740048;Hover:#ABC1DE,#FFFFFF,#740048;Active:#ABC1DE,#AEC4E8,#500040;filter:#E0D4B2,#FFD456,#E0D4B2,#FFD456");

	this.Initializ();//초기화
	this.oText.DatePick = this;//대상 텍스트 박스의 객체 속성으로 현재 function으로 지정
	//텍스트 박스의 프로퍼티가 변경될 때 분기함수
	this.oText.onpropertychange=function(){if(window.event.type == "propertychange" && this.DatePick !=null) this.DatePick.__setPropertyAttribute(window.event.propertyName);}

}
xwzDatePicker.prototype.Version			= '1.1.3' ;
/*=========================================================
날짜없음 출력여부 및 날짜없음 표시 문자 설정
=========================================================*/
xwzDatePicker.prototype.letDisplayEmpty = function(bool){this.isEmpty=eval(bool);if(this.lblEmpty!=null) this.lblEmpty.style.display = this.isEmpty ? '' : 'none'; }
xwzDatePicker.prototype.letEmptyValue = function(str){this.emptyValue=str;}
/*=========================================================
이미지 셋팅
=========================================================*/
xwzDatePicker.prototype.setArrowImageValue = function(str){this.Images.arrow = str;}
xwzDatePicker.prototype.setPrevImageValue = function(str){this.Images.prev = str;}
xwzDatePicker.prototype.setNextImageValue = function(str){this.Images.next = str;}
xwzDatePicker.prototype.letDisabled = function(bool){
	if(bool == true){
		this.objLabel.style.color="#666666";
		this.objLabel.style.filter="gray()";
		this.objArrow.style.filter="gray()";
	}else{
		this.objLabel.style.color="";
		this.objLabel.style.filter="";
		this.objArrow.style.filter="";
	}
}
/*=========================================================
주 표시 단위
=========================================================*/
xwzDatePicker.prototype.setLanguage = function(str){
	var WeekText = {"ch": ['日','月','火','水','木','金','土'],"ko" : ['일','월','화','수','목','금','토'],"en" : ['Sun','Mon','Tue','Wed','Thu','Fri','Sat']};
	var DateText = {"ch": ['月 ','日','年 '],"ko" : ['월 ','일', '년 '],"en" : ['-', '', '-']};
	if(WeekText[str] != null) this.Weeks = WeekText[str];else this.Weeks = WeekText["ko"];
	if(DateText[str] != null) this.Formula = DateText[str];else this.Formula = DateText["ko"];
}

/*=========================================================
마우스 오버등의 이벤트에 따른 색상 설정 함수
=========================================================*/
xwzDatePicker.prototype.setStyleColor = function(str){
	var Composition = new Array(0), Rule = new Array(0), sSelector = "", Colors = new Array(0);
	Composition = str.replace(/\s/gi, '').toString().split(";")
	if(Composition.length == 0) return;
	for(var i = 0 ; i < Composition.length; i++){
		Composition[i] = Composition[i].replace(/\s/gi, '');//무효문자 제거
		if(Composition[i] == '') continue;sSelector = Composition[i].split(':').shift();Colors = Composition[i].split(':').pop().toString().split(',');
		if(sSelector.toLowerCase() == 'default'){for(var n = 0; n < Colors.length;n++) this.Styles.def[n] = Colors[n];}
		else if(sSelector.toLowerCase() == 'hover'){for(var n = 0; n < Colors.length;n++) this.Styles.hov[n] = Colors[n];}
		else if(sSelector.toLowerCase() == 'active'){for(var n = 0; n < Colors.length;n++) this.Styles.act[n] = Colors[n];}
		else if(sSelector.toLowerCase() == 'filter'){for(var n = 0; n < Colors.length;n++) this.Styles.flt[n] = Colors[n];}
	}
}

/*=========================================================
값 변경에 따른 셋팅
=========================================================*/
xwzDatePicker.prototype.changeValue = function(sValue){
	if( (/^([0-9]){4}-([0-9]){2}-([0-9]){2}/).test(sValue) == true){
		this.dtCurrent = new Date(sValue.substr(0,4), sValue.substr(5,2)-1, sValue.substr(8,2));
		this.dtDisplay=this.dtCurrent;
		this.setDateValue(this.dtCurrent.getDate());
		this.display();
	}else{
		this.setEmptyValue();
	}
}
xwzDatePicker.prototype.setEmptyValue = function(){
	this.oText.onpropertychange=null;
	this.oText.value = "";
	this.objLabel.innerHTML = this.emptyValue;
	this.isVisible = true;
	this.swapVisible();
	this.oText.onpropertychange=function(){if(window.event.type == "propertychange" && this.DatePick !=null) this.DatePick.__setPropertyAttribute(window.event.propertyName);}
}
/*=========================================================
선택된 날짜에 대한 출력
=========================================================*/
xwzDatePicker.prototype.setDateValue = function(day){

	this.oText.onpropertychange=new Function("return false");

	var year = this.dtDisplay.getYear(), month = this.dtDisplay.getMonth();
	this.dtCurrent = new Date(year, month, day);
	this.oText.value = year + "-" + this.__fillZero(month+1, 2) + "-" +  this.__fillZero(day, 2);
	this.objLabel.innerHTML = year + this.Formula[2] + this.__fillZero(month+1, 2) + this.Formula[0] +  this.__fillZero(day, 2) +this.Formula[1] ;
	this.isVisible = true;
	this.swapVisible();
	this.oText.onpropertychange=function(){if(window.event.type == "propertychange" && this.DatePick !=null) this.DatePick.__setPropertyAttribute(window.event.propertyName);}
}
/*=========================================================
프로퍼티 설정 -- 속성값이 변경될때
=========================================================*/
xwzDatePicker.prototype.__setPropertyAttribute = function(sType){
	switch(sType.toString()){
		case "isEmpty" : this.letDisplayEmpty(this.oText.getAttribute(sType));break;
		case "empty" : this.letEmptyValue(this.oText.getAttribute(sType));break;
		case "value" : this.changeValue(this.oText.getAttribute(sType));break;
		case "arrowImage" : this.setArrowImageValue(this.oText.getAttribute(sType));break;
		case "prevImage" : this.setPrevImageValue(this.oText.getAttribute(sType));break;
		case "nextImage" : this.setNextImageValue(this.oText.getAttribute(sType));break;
		case "colorStyle" : this.setStyleColor(this.oText.getAttribute(sType));break;
		case "language" : this.setLanguage(this.oText.getAttribute(sType));break;
		case "disabled" : this.letDisabled(this.oText.disabled);break;
		default : break;
	}
}
xwzDatePicker.prototype.__isPopupView = function(){{if(this.objWindow == null) return false;return this.objWindow.isOpen;}}
xwzDatePicker.prototype.__fillZero = function(num, len){if(num.toString().length >= len) return num;var nMax = len-( num.toString().length );var str = "";for(var i=0; i < nMax; i++) str +="0";return str + (num).toString();}
/*=========================================================
마우스 이벤트에 따른 효과
=========================================================*/
xwzDatePicker.prototype.hoverIn = function(){
	if(this.isActive == false && this.oText.disabled == false){
		this.objField.style.border=this.Styles.hov[0] + " 1px solid" ;
		this.objField.style.backgroundColor=this.Styles.hov[1] ;

		this.objLabel.style.border=this.Styles.hov[1] + " 1px solid";
		this.objLabel.style.backgroundColor=this.Styles.hov[1] ;
		this.objLabel.style.color=this.Styles.hov[2];

		this.objArrow.style.border=this.Styles.hov[0] + " 1px solid";
		this.objArrow.style.backgroundColor=this.Styles.hov[1] ;
		this.objArrow.style.color=this.Styles.hov[1];
		this.objArrow.style.filter="progid:DXImageTransform.Microsoft.Gradient(gradientType=0,startColorStr="+this.Styles.flt[0]+",endColorStr="+this.Styles.flt[1]+");";
	}
}
xwzDatePicker.prototype.hoverOut = function(){
	if(this.isActive == false && this.oText.disabled == false){
		this.objField.style.border=this.Styles.def[0] + " 1px solid" ;
		this.objField.style.backgroundColor=this.Styles.def[1] ;

		this.objLabel.style.border=this.Styles.def[1] + " 1px solid";
		this.objLabel.style.backgroundColor=this.Styles.def[1] ;
		this.objLabel.style.color=this.Styles.def[2];

		this.objArrow.style.border=this.Styles.def[1] + " 1px solid";
		this.objArrow.style.backgroundColor=this.Styles.def[1] ;
		this.objArrow.style.color=this.Styles.def[1];
		this.objArrow.style.filter="";
	}
}

xwzDatePicker.prototype.deactive = function(){
	if(this.oText.disabled == false){
		this.isActive = false;
		this.objField.style.border=this.Styles.def[0] + " 1px solid" ;
		this.objField.style.backgroundColor=this.Styles.def[1] ;

		this.objLabel.style.border=this.Styles.def[1] + " 1px solid";
		this.objLabel.style.backgroundColor=this.Styles.def[1] ;
		this.objLabel.style.color=this.Styles.def[2];

		this.objArrow.style.border=this.Styles.def[1] + " 1px solid";
		this.objArrow.style.backgroundColor=this.Styles.def[1] ;
		this.objArrow.style.color=this.Styles.def[1];
		this.objArrow.style.filter="";
	}
}
xwzDatePicker.prototype.active = function(){
	if(this.oText.disabled == false){
		this.isActive = true;
		this.objField.style.border=this.Styles.act[0] + " 1px solid" ;
		this.objField.style.backgroundColor=this.Styles.hov[1] ;

		this.objLabel.style.border=this.Styles.act[1] + " 1px solid";
		this.objLabel.style.backgroundColor=this.Styles.act[1] ;
		this.objLabel.style.color=this.Styles.act[2];

		this.objArrow.style.border=this.Styles.act[0] + " 1px solid";
		this.objArrow.style.backgroundColor=this.Styles.act[1] ;
		this.objArrow.style.color=this.Styles.act[1];
		this.objArrow.style.filter="progid:DXImageTransform.Microsoft.Gradient(gradientType=0,startColorStr="+this.Styles.flt[2]+",endColorStr="+this.Styles.flt[3]+");";
	}
}
/* ================================================
팝업창 출력 결정
================================================ */
xwzDatePicker.prototype.swapVisible = function(){
    if(this.isVisible == false){
		if(this.oText.disabled == false && this.objWindow != null){
			var nHeight = 164;
			if(this.isEmpty == true) nHeight =183;
			var nDiff = window.screen.height - window.event.screenY - nHeight;posY = nDiff < nHeight ?  nHeight *-1 : this.objField.offsetHeight;
			this.objWindow.show(0, posY, 139, nHeight, this.objField);
			this.objWindow.document.getElementById('IDS_MONTH_LIST').style.display = "none";
			this.active();
			this.isVisible = true;
		}
    }else{
		this.deactive();
		if(this.__isPopupView()==true) this.objWindow.hide();
		this.isVisible = false;
		setTimeout("window.__xwzDatePickers[" +this.index + "].display()", 30);
    }
}
/* ================================================
초기화 함수
================================================ */
xwzDatePicker.prototype.Initializ = function(){
    var bwver = new Number(((window.navigator.appVersion.split('; '))[1].split(' '))[1]);
    if(window.navigator.appName != "Microsoft Internet Explorer" || bwver < 5.5) return;
	//== 기본변수대입
	var sValue=this.oText.getAttribute("value");
	if(sValue != "" && sValue != null) this.dtCurrent = new Date(sValue.substr(0,4), sValue.substr(5,2)-1, sValue.substr(8,2));
	if(isNaN(this.dtCurrent) || this.dtCurrent == null){this.oText.value="";this.dtCurrent=new Date();}
	this.dtDisplay=this.dtCurrent;
	var attributes = ["isEmpty","empty", "arrowImage", "prevImage","nextImage", "colorStyle", "language"];
	for(var i = 0; i < attributes.length; i++){
		if(this.oText.getAttribute(attributes[i]) == null || this.oText.getAttribute(attributes[i]) =="" ) continue;
		this.__setPropertyAttribute(attributes[i]);
	}

	var row = null;
	//=== 테이블 생성
	this.objField = document.createElement("TABLE");
	this.objField.setAttribute('cellPadding', 1);
	this.objField.setAttribute('cellSpacing', 1);

	this.objField.style.display='inline' ;

	this.objField.style.margin="0 0 0 0";
	this.objField.style.padding="0 0 0 0";
 	this.objField.style.border=this.Styles.def[0] + " 1px solid" ;
	this.objField.style.verticalAlign='text-bottom';
	this.objField.style.backgroundColor=this.Styles.def[1];

	this.objField.onmouseover=new Function("window.__xwzDatePickers[" +this.index + "].hoverIn()");
	this.objField.onmouseout=new Function("window.__xwzDatePickers[" + this.index+ "].hoverOut()");

	//=== Row 생성
	var tBody = document.createElement("TBODY");
	this.objField.appendChild(tBody);

	row = document.createElement("TR");
	row.style.cssText = "";
	row.onmousedown=new Function("e", "if((window.event.button||e.which)==1) window.__xwzDatePickers[" +this.index + "].swapVisible()");
	//=== 디스플레이 cell 생성
	this.objLabel = document.createElement("TD");
	this.objLabel.onselectstart=new Function("return false");

	if(this.oText.value == ""){
		this.objLabel.setAttribute("innerText", this.emptyValue);
	}else{

		this.objLabel.innerHTML = this.dtDisplay.getYear() + this.Formula[2] + this.__fillZero(this.dtDisplay.getMonth()+1, 2) + this.Formula[0] +  this.__fillZero(this.dtDisplay.getDate(), 2) + this.Formula[1];
	}
	this.objLabel.style.cssText = "";
	this.objLabel.style.width=100;
	this.objLabel.style.height=15;
	this.objLabel.style.font="normal normal normal 11px 돋움";
	this.objLabel.style.cursor="default";
	this.objLabel.style.textAlign="center";

	this.objLabel.style.margin="0 0 0 0";
	this.objLabel.style.padding="0 0 0 0";
	this.objLabel.style.border=this.Styles.def[1] + " 1px solid";
	this.objLabel.style.backgroundColor=this.Styles.def[1] ;
	this.objLabel.style.color=this.Styles.def[2];
	row.appendChild(this.objLabel);

	//=== 화살표 생성
	this.imgArrow=document.createElement("IMG");
	this.imgArrow.src = this.Images.arrow;
	this.imgArrow.valign = "middle";
	this.imgArrow.style.cssText = "";

	this.objArrow= document.createElement("TD");
	this.objArrow.onselectstart=new Function("return false");
	this.objArrow.style.margin="0 0 0 0";
	this.objArrow.style.padding="0 3 0 3";
	this.objArrow.style.border=this.Styles.def[1] + " 1px solid";
	this.objArrow.style.backgroundColor=this.Styles.def[1] ;
	this.objArrow.style.color=this.Styles.def[1];
	this.objArrow.appendChild(this.imgArrow);
	row.appendChild(this.objArrow);
	tBody.appendChild(row);

	this.objLabel.onfocus=new Function("window.__xwzDatePickers[" +this.index + "].active();");
	this.objArrow.onfocus=new Function("window.__xwzDatePickers[" +this.index + "].active()");
	//this.objLabel.setAttribute('tabIndex', 0);

	this.objLabel.onblur=new Function("window.__xwzDatePickers[" +this.index + "].deactive()");
	this.objArrow.onblur=new Function("window.__xwzDatePickers[" +this.index + "].deactive()");

	this.oText.insertAdjacentElement("afterEnd", this.objField);
	if(this.oText.disabled == true) this.__setPropertyAttribute('disabled');

	this.oText.style.width='0px';
	this.oText.style.visibility='hidden';
	this.createWindow();
	this.InitializCalendar();
	this.display();
	window.document.attachEvent("onmousedown", new Function("window.__xwzDatePickers[" +this.index + "].hideCalendar()"));
}
/* ================================================
문서 객체에서의 마우스 다운 이벤트 발생시 비활성화
================================================ */
xwzDatePicker.prototype.hideCalendar = function(){
	if(window.event.srcElement ==this.objArrow ||window.event.srcElement ==this.objLabel || window.event.srcElement ==this.imgArrow) return;
	if(this.isVisible == true) this.swapVisible();
}

/* ================================================
팝업창 생성함수
================================================ */
xwzDatePicker.prototype.createWindow= function(){
	var Doc	 = null, Body = null, StyleSheet = null;
	this.objWindow = window.createPopup();
	Doc		= this.objWindow.document;
	Body		= this.objWindow.document.body;
	/*생성된 Window 객체에 각 스타일을 적용 시킴*/
	Body.style.cssText = "margin:1px;padding:0px;border:#A0A0A0 1px solid;cursor:default;background-color:#FCFCFC;overflow:hidden";

	StyleSheet = Doc.createStyleSheet();
	StyleSheet.addRule("BODY", "font-size:8pt;color:#666666;font-family:sans-serif,serif");
	StyleSheet.addRule("TD", "font-size:8pt;color:#666666;font-family:sans-serif,serif");
	StyleSheet.addRule("SPAN", "font-size:8pt;font-family:sans-serif,serif");
	StyleSheet.addRule("DIV", "font-size:8pt;color:#666666;font-family:sans-serif,serif");
	StyleSheet.addRule(".cssTitle",			"color:#0000FF;font-size:13px;font-family:Verdana;");
	StyleSheet.addRule(".cssTitleOver",	"color:#0066CC;font-size:13px;font-family:Verdana;");

	StyleSheet.addRule(".cssEmpty",			"padding-top:1px;cursor:pointer;height:19;text-align:center;border:#FCFCFC 1px solid;FILTER: progid:DXImageTransform.Microsoft.Gradient(GradientType=0, StartColorStr='#FFFFFF', EndColorStr='#FFFFFF')");
	StyleSheet.addRule(".cssEmptyOver", "padding-top:1px;cursor:pointer;height:19;text-align:center;border:#E77B0F 1px solid;FILTER: progid:DXImageTransform.Microsoft.Gradient(GradientType=0, StartColorStr='#FFF2DD', EndColorStr='#F6A53D')");
	StyleSheet.addRule(".cssEmptyOver SPAN",  "color:#2F2F2F;FILTER: progid:DXImageTransform.Microsoft.dropShadow( Color=#FFF2DD,offX=1,offY=1,positive=true);width:100%");

	StyleSheet.addRule(".cssSel",			"padding-top:1px;cursor:default;color:#000000;border:#E77B0F 1px solid;FILTER: progid:DXImageTransform.Microsoft.Gradient(GradientType=0, StartColorStr='#FFF2DD', EndColorStr='#F6A53D')progid:DXImageTransform.Microsoft.dropShadow( Color=#999999,offX=1,offY=1,positive=true);");
	StyleSheet.addRule(".cssDef",			"cursor:pointer;border:#FCFCFC 1px solid;");
	StyleSheet.addRule(".cssDefOver",	"cursor:pointer;border:#7A98AF 1px solid;");

	StyleSheet.addRule(".cssDef SPAN",		"width:100%;border:#FFFFFF 1px solid;background-color:transparent;");
	StyleSheet.addRule(".cssDefOver SPAN","width:100%;border:#FFFFFF 1px solid;border-bottom-color:#D7D1C5;border-right-color:#D7D1C5;background-color:#C9F7FA");
	/*년 / 월 선택란*/
	StyleSheet.addRule(".cssRect TD.cssItem",		"cursor:pointer;color:#666666;border:#F6F6F6   1px solid;background-color:transparent;");
	StyleSheet.addRule(".cssRect TD.cssHover",	"cursor:pointer;color:#333333;border:#F6A53D  1px solid;background-color:#FFF2DD;");
	StyleSheet.addRule(".cssRect TD.cssDisable",	"cursor:pointer;color:#666666;border:#CECECE  1px solid;background-color:#FAFAFA;");

	StyleSheet.addRule(".cssRect TD.cssItem SPAN",	"font-size:10px;font-familye:Tahoma;width:100%;border-top:#F6F6F6 1px solid;border-left:#F6F6F6 1px solid;border-bottom:#F6F6F6 1px solid;border-right:#F6F6F6 1px solid;cursor:pointer;padding:1px 3px 1px 3px");
	StyleSheet.addRule(".cssRect TD.cssHover SPAN",	"font-size:10px;font-familye:Tahoma;width:100%;border-top:#FFFFFF 1px solid;border-left:#FFFFFF 1px solid;border-bottom:#FFF2DD 1px solid;border-right:#FFF2DD 1px solid;cursor:pointer;padding:1px 3px 1px 3px");
	StyleSheet.addRule(".cssRect TD.cssDisable SPAN","font-size:10px;font-familye:Tahoma;width:100%;border-top:#F6F6F6 1px solid;border-left:#F6F6F6 1px solid;border-bottom:#FFFFFF 1px solid;border-right:#FFFFFF 1px solid;cursor:pointer;padding:1px 3px 1px 3px");

	StyleSheet.addRule(".cssTab TD.cssItem",	"cursor:pointer;color:#666666;letter-spacing: -1;height: 19px;border:#F6F6F6 1px solid;background-color:transparent")
	StyleSheet.addRule(".cssTab TD.cssHover","cursor:pointer;color:#333333;letter-spacing: -1;height: 19px;border:#88ACCB 1px solid;background-color:#E8FBFF;border:#70D9FF 1px solid");
	StyleSheet.addRule(".cssTab TD.cssItem SPAN",	 "width:100%;height:17px;border-top:#F6F6F6 1px solid;border-left:#F6F6F6 1px solid;border-bottom:#F6F6F6 1px solid;border-right:#F6F6F6 1px solid;padding: 2 0 0 2;cursor:pointer;")
	StyleSheet.addRule(".cssTab TD.cssHover SPAN","width:100%;height:17px;border-top:#FFFFFF 1px solid;border-left:#FFFFFF 1px solid;border-bottom:#E8FBFF 1px solid;border-right:#E8FBFF 1px solid;padding: 2 0 0 2;cursor:pointer;")

}
/* ================================================
달력 초기화 함수
================================================ */
xwzDatePicker.prototype.InitializCalendar = function(){
	var Doc		= this.objWindow.document;
	var table =null,tbody=null,  row = null, cell =null, img = null;

	table = Doc.createElement("TABLE");
	table.setAttribute('cellPadding', 1);
	table.setAttribute('cellSpacing', 0);
	table.setAttribute('align', 'center');
	table.setAttribute('width', '100%');

	tbody=Doc.createElement("TBODY");
	table.appendChild(tbody);
	row = Doc.createElement('TR');
	tbody.appendChild(row);
	//-- Prev
	img = Doc.createElement('img');
	img.src=this.Images.prev;
	cell = Doc.createElement('TD');
	cell.setAttribute('height', 21);
	cell.setAttribute('width', 17);
	cell.setAttribute('align', 'center');
	cell.setAttribute('bgColor', '#E3EDF6');
	cell.style.cursor='pointer';

	cell.onclick=new Function("window.__xwzDatePickers[" +this.index + "].setCurrentDateSibling(0, -1)");
	cell.appendChild(img);
	row.appendChild(cell);
	img = null; cell=null;

	//-- Title
	this.lblCaption = Doc.createElement('TD');
	this.lblCaption.setAttribute('height', 21);
	this.lblCaption.setAttribute('align', 'center');
	this.lblCaption.setAttribute('bgColor', '#E3EDF6');
	this.lblCaption.style.cursor='default';
	/*
	---- 년. 월 순서인 경우  ----
	var div = Doc.createElement("div");//년
	div.style.cssText="display:inline;width:44px;cursor:pointer";
	div.innerHTML = "&nbsp;";
	div.onclick=new Function("__xwzDatePickers[" +this.index + "].yearList(__xwzDatePickers[" +this.index + "].dtDisplay.getYear())");
	this.lblCaption.appendChild(div);
	row.appendChild(this.lblCaption);

	div = Doc.createElement("div");//월
	div.style.cssText="display:inline;width:40;text-align:right;cursor:pointer;";
	div.innerHTML = "<span class=\"cssTitle\">&nbsp;</span>월,";
	div.onclick=new Function("var table =window.__xwzDatePickers[" +this.index + "].objWindow.document.getElementById('IDS_MONTH_LIST');table.style.display = table.style.display == 'none' ? '' : 'none';window.__xwzDatePickers[" +this.index + "].objWindow.document.getElementById('IDS_YEAR_LIST').style.display='none';");
	this.lblCaption.appendChild(div);

	*/
	var div = Doc.createElement("div");//월
	div.style.cssText="display:inline;width:40;text-align:right;cursor:pointer;";
	div.innerHTML = "<span class=\"cssTitle\">&nbsp;</span>월,";
	div.onclick=new Function("var table =window.__xwzDatePickers[" +this.index + "].objWindow.document.getElementById('IDS_MONTH_LIST');table.style.display = table.style.display == 'none' ? '' : 'none';window.__xwzDatePickers[" +this.index + "].objWindow.document.getElementById('IDS_YEAR_LIST').style.display='none';");
	this.lblCaption.appendChild(div);

	div = Doc.createElement("div");//년
	div.style.cssText="display:inline;width:44px;cursor:pointer";
	div.innerHTML = "&nbsp;";
	div.onclick=new Function("__xwzDatePickers[" +this.index + "].yearList(__xwzDatePickers[" +this.index + "].dtDisplay.getYear())");
	this.lblCaption.appendChild(div);
	row.appendChild(this.lblCaption);

	//-- Next
	img = Doc.createElement('img');
	img.src=this.Images.next;
	cell = Doc.createElement('TD');
	cell.setAttribute('height', 21);
	cell.setAttribute('width', 17);
	cell.setAttribute('align', 'center');
	cell.setAttribute('bgColor', '#E3EDF6');
	cell.style.cursor='pointer';
	cell.onclick=new Function("window.__xwzDatePickers[" +this.index + "].setCurrentDateSibling(0, 1)");
	cell.appendChild(img);
	row.appendChild(cell);

	Doc.body.insertAdjacentElement("beforeEnd",table);
	img = null; cell=null, row = null, table=null, tbody=null;

	//====[월 선택란]====//
	table = Doc.createElement("TABLE");
	table.setAttribute('cellPadding', 0);
	table.setAttribute('cellSpacing', 2);
	table.align="center";
	table.style.backgroundColor="#F6F6F6";
	table.style.border="#CACACA 1px solid";
	table.className="cssTab";
	table.setAttribute('id', 'IDS_MONTH_LIST');
	table.style.position="absolute";
	table.style.left="42";

	tbody=Doc.createElement("TBODY");
	table.appendChild(tbody);
	for(var i = 1 ;  i <= 6; i++){
		row = Doc.createElement('TR');
		tbody.appendChild(row);
		cell = Doc.createElement("TD");
		cell.className="cssItem";
		cell.align="center"
		cell.innerHTML = "<span>" + i + this.Formula[0].replace(/([\s\-]+)/, '') + "</span>";
		cell.onmouseover=new Function("this.className='cssHover' ");
		cell.onmouseout=new Function("this.className='cssItem' ");
		cell.onclick=new Function("window.__xwzDatePickers[" +this.index + "].setCurrentDate(__xwzDatePickers[" +this.index + "].dtDisplay.getYear(), "+ i+")");
		row.appendChild(cell);

		cell = Doc.createElement("TD");
		cell.className="cssItem";
		cell.align="center"
		cell.innerHTML = "<span>" + (6+i) + this.Formula[0].replace(/([\s\-]+)/, '') + "</span>";
		cell.onmouseover=new Function("this.className='cssHover' ");
		cell.onmouseout=new Function("this.className='cssItem' ");
		cell.onclick=new Function("window.__xwzDatePickers[" +this.index + "].setCurrentDate(__xwzDatePickers[" +this.index + "].dtDisplay.getYear(), "+ (6+i)+")");
		row.appendChild(cell);
	}
	Doc.body.insertAdjacentElement("beforeEnd",table);
	img = null; cell=null, row = null, table=null, tbody=null;
	//====[년도 선택란]====//
	table = Doc.createElement("TABLE");
	table.setAttribute('cellPadding', 0);
	table.setAttribute('cellSpacing', 2);
	table.align="center";
	table.style.backgroundColor="#F6F6F6";
	table.style.border="#CACACA 1px solid";
	table.className="cssRect";
	table.setAttribute('id', 'IDS_YEAR_LIST');
	table.style.position="absolute";
	table.style.left="66";

	tbody=Doc.createElement("TBODY");
	table.appendChild(tbody);
	Doc.body.insertAdjacentElement("beforeEnd",table);
	img = null; cell=null, row = null, table=null, tbody=null;
	//====[요일표시]====//
	table = Doc.createElement("TABLE");
	table.setAttribute('cellPadding', 1);
	table.setAttribute('cellSpacing', 0);
	table.setAttribute('align', 'center');
	table.setAttribute('width', '100%');
	table.style.cssText = 'border-top:#999999 1px solid;border-bottom:#808080 1px solid';
	tbody = Doc.createElement("TBODY");
	table.appendChild(tbody);

	row = Doc.createElement("TR");
	for(var i = 0 ; i < this.Weeks.length; i++){
		cell = Doc.createElement("TD");
		cell.setAttribute('height', 19);
		cell.setAttribute('align', 'center');
		cell.setAttribute('bgColor', '#F2F2F2');
		if(this.WeekColor[i] != null || this.WeekColor[i] !='') cell.style.color=this.WeekColor[i];
		cell.innerHTML = this.Weeks[i];
		row.appendChild(cell);
	}
	tbody.appendChild(row);
	Doc.body.insertAdjacentElement("beforeEnd",table);
	img = null; cell=null, row = null, table=null, tbody=null;


	//====[기간없음 표시]====//
	this.lblEmpty = Doc.createElement("div");
	this.lblEmpty.className="cssEmpty";
	this.lblEmpty.style.width="100%"
	if(this.isEmpty==false) this.lblEmpty.style.display="none";
	this.lblEmpty.onmouseover=function(){this.className='cssEmptyOver';}
	this.lblEmpty.onmouseout=function(){this.className='cssEmpty';}
	this.lblEmpty.onclick=new Function("window.__xwzDatePickers[" +this.index + "].setEmptyValue();this.className='cssEmpty';");
	this.lblEmpty.innerHTML = "<span>"+this.emptyValue+"</span>";
	Doc.body.insertAdjacentElement("beforeEnd",this.lblEmpty);

	table = Doc.createElement("TABLE");
	tbody=Doc.createElement("TBODY");
	table.setAttribute('cellPadding', 0);
	table.setAttribute('cellSpacing', 1);
	table.setAttribute('align', 'center');
	table.setAttribute('width', '100%');
	table.appendChild(tbody);

	var nWeek = 0;
	var cells = new Array(0);
	for(var i = 0; i < 42; i++){
		if(i%7 ==0){
			row = Doc.createElement("TR");
			tbody.appendChild(row);
		}
		nWeek = (i%7) ;

		cell = Doc.createElement("TD");
		cell.setAttribute('align', 'right');
		cell.setAttribute('height', '17');
		cell.setAttribute('width', '17');
		if(this.WeekColor[nWeek] != null || this.WeekColor[nWeek] !='') cell.style.color=this.WeekColor[nWeek];
		cell.innerText = i;
		row.appendChild(cell);
		cells[i] = cell;
	}
	this.cellCalendar = cells;
	Doc.body.insertAdjacentElement("beforeEnd",table);

}
/* ================================================
년도 목록 출력함수
================================================ */
xwzDatePicker.prototype.yearList=function(nYear,isChange)
{
	var Doc		= this.objWindow.document;
	var table =null,tbody=null,  row = null, cell =null, img = null;
	table =Doc.getElementById('IDS_YEAR_LIST');

	tbody=table.tBodies[0];
	if( table.style.display == 'none' || isChange==true)
	{
		for(var i=tbody.rows.length-1;i>=0;i--)
		{
			tbody.removeChild(tbody.rows[i]);
		}
		//-- 이전 년도 선택
		row = Doc.createElement('TR');
		tbody.appendChild(row);
		cell = Doc.createElement("TD");
		cell.className="cssItem";
		cell.align="center";
		cell.style.fontSize="8px";
		cell.setAttribute('height', 10);
		cell.innerHTML = "▲";
		cell.onmouseover=new Function("this.className='cssHover' ");
		cell.onmouseout=new Function("this.className='cssItem' ");
		cell.onclick=new Function("__xwzDatePickers[" +this.index + "].yearList("+(nYear-3)+", true)");
		row.appendChild(cell);

		for(var i = 2 ;  i >0; i--){
			row = Doc.createElement('TR');
			tbody.appendChild(row);
			cell = Doc.createElement("TD");
			cell.className="cssItem";
			cell.align="center";
			cell.innerHTML = "<span>"+(nYear-i)+"</span>";
			cell.onmouseover=new Function("this.className='cssHover' ");
			cell.onmouseout=new Function("this.className='cssItem' ");
			cell.onclick=new Function("__xwzDatePickers[" +this.index + "].setCurrentDate("+(nYear-i)+", " +( this.dtDisplay.getMonth()+1) +")");
			row.appendChild(cell);
		}
		row = Doc.createElement('TR');
		tbody.appendChild(row);
		cell = Doc.createElement("TD");
		cell.align="center";
		if(nYear == this.dtDisplay.getYear())
		{
			cell.className="cssDisable";
			cell.innerHTML = "<span>"+nYear+"</span>";
			cell.onclick=new Function("__xwzDatePickers[" +this.index + "].objWindow.document.getElementById('IDS_YEAR_LIST').style.display =  'none' ");
		}
		else
		{
			cell.className="cssItem";
			cell.innerHTML = "<span>"+nYear+"</span>";
			cell.onmouseover=new Function("this.className='cssHover' ");
			cell.onmouseout=new Function("this.className='cssItem' ");
			cell.onclick=new Function("__xwzDatePickers[" +this.index + "].setCurrentDate("+(nYear)+", " +( this.dtDisplay.getMonth()+1) +")");
		}
		row.appendChild(cell);

		for(var i = 1 ;  i <=2; i++){
			row = Doc.createElement('TR');
			tbody.appendChild(row);
			cell = Doc.createElement("TD");
			cell.align="center";
			cell.className="cssItem";
			cell.innerHTML = "<span>"+(nYear+i)+"</span>";
			cell.onmouseover=new Function("this.className='cssHover' ");
			cell.onmouseout=new Function("this.className='cssItem' ");
			cell.onclick=new Function("__xwzDatePickers[" +this.index + "].setCurrentDate("+(nYear+i)+", " +( this.dtDisplay.getMonth()+1) +")");
			row.appendChild(cell);
		}
		//-- 다음 년도 선택
		row = Doc.createElement('TR');
		tbody.appendChild(row);
		cell = Doc.createElement("TD");
		cell.className="cssItem";
		cell.align="center";
		cell.style.fontSize="8px";
		cell.setAttribute('height', 10);
		cell.innerHTML = "▼";
		cell.onmouseover=new Function("this.className='cssHover' ");
		cell.onmouseout=new Function("this.className='cssItem' ");
		cell.onclick=new Function("__xwzDatePickers[" +this.index + "].yearList("+(nYear+3)+", true)");
		row.appendChild(cell);
		Doc.getElementById('IDS_MONTH_LIST').style.display='none';
		table.style.display = '';
	}
	else
	{
		table.style.display = 'none';
	}
}
/* ================================================
설정된 날짜 변경 함수
================================================ */
xwzDatePicker.prototype.setCurrentDate =function(nYear, nMonth){	this.dtDisplay=new Date(nYear , nMonth-1, 1 );this.display();}
xwzDatePicker.prototype.setCurrentDateSibling =function(nYear, nMonth){	this.dtDisplay=new Date(this.dtDisplay.getYear() + nYear , this.dtDisplay.getMonth() + nMonth, 1 );this.display();}
/* ================================================
날짜 출력 함수
================================================ */
xwzDatePicker.prototype.display =function(){
	var dpYear = this.dtDisplay.getYear(), dpMonth = this.dtDisplay.getMonth(), dpDay = 0;
	var curYear = this.dtCurrent.getYear(), curMonth = this.dtCurrent.getMonth(), curDay = this.dtCurrent.getDate();
	var cells = this.cellCalendar;
	var dtTemp = null, nMin = 0, nMax = 0;

	dtTemp = new Date(dpYear, dpMonth, 1);
	nMin = dtTemp.getDay();
	dtTemp = new Date(dpYear, dpMonth+1, 0);
	nMax = nMin + dtTemp.getDate()-1;

	this.objWindow.document.getElementById('IDS_MONTH_LIST').style.display ='none';
	this.objWindow.document.getElementById('IDS_YEAR_LIST').style.display ='none';
	/*
	---- 년, 월 출력시 ----
	this.lblCaption.childNodes[0].innerHTML=dpYear ;
	this.lblCaption.childNodes[1].innerHTML="<span class=\"cssTitle\">"+ (dpMonth+1)+"</span>"+this.Formula[0].replace(/\s/, '')+",";
	*/
	this.lblCaption.childNodes[0].innerHTML="<span class=\"cssTitle\">"+ (dpMonth+1)+"</span>"+this.Formula[0].replace(/\s/, '')+",";
	this.lblCaption.childNodes[1].innerHTML=dpYear ;
	for(var i=0; i < 42; i++){

		cells[i].onclick=new Function("return false");
		cells[i].onmouseover=new Function("return false");
		cells[i].onmouseout=new Function("return false");
		if(i>=nMin && i<=nMax){
			dpDay = i - nMin+1;
			cells[i].innerHTML = "<span>"+dpDay+"</span>";
			if(dpYear==curYear && dpMonth==curMonth && dpDay==curDay && this.oText.value !=""){
				cells[i].className='cssSel';
			}else{
				cells[i].className='cssDef';
				cells[i].onclick=new Function("with(window.__xwzDatePickers[" +this.index + "]){setDateValue("+dpDay+");}");
				cells[i].onmouseover=function(){this.className=this.className + "Over";	}
				cells[i].onmouseout=function(){this.className=this.className.replace("Over", "");}
			}
		}else{
			cells[i].className='';
			cells[i].innerHTML = "<span>&nbsp;</span>";
		}
	}
}