//	based on code written by Tan Ling Wee on 2 Dec 2001
//	last updated 20 June 2003
//	email :	fuushikaden@yahoo.com
//
// Modified to be completely object-oriented, CSS based and using proper DOM-access functions
// @author Martin Marinschek
// @author Sylvain Vieujot
// last modifed 2008/08/04 by Park Kyungil
var pwInputCalendar = function() {}
pwInputCalendar.ctl = document.getElementById("pw:inputCalendar");
if (!pwInputCalendar.ctl) {
	if (document.body) {
		pwInputCalendar.ctl = document.createElement("div");
		pwInputCalendar.ctl.id = "pw:inputCalendar";
		pwInputCalendar.ctl.style.position = "absolute";
		pwInputCalendar.ctl.style.left = "0";
		pwInputCalendar.ctl.style.top = "0";
		pwInputCalendar.ctl.style.zIndex = 999;
		document.body.appendChild(pwInputCalendar.ctl);
	} else {
		Event.observe(window, "load", function()
		{
			pwInputCalendar.ctl = document.createElement("div");
			pwInputCalendar.ctl.id = "pw:inputCalendar";
			pwInputCalendar.ctl.style.position = "absolute";
			pwInputCalendar.ctl.style.left = "0";
			pwInputCalendar.ctl.style.top = "0";
			pwInputCalendar.ctl.style.zIndex = 999;
			document.body.appendChild(pwInputCalendar.ctl);
		}, false);
	}
}
pwInputCalendar.addPopupCalendar = function(calendarDiv) {
	if (pwInputCalendar.ctl) {
		var pNode = calendarDiv.parentNode;
		if (pNode!=pwInputCalendar.ctl) {
			calendarDiv = pNode.removeChild(calendarDiv);
			pwInputCalendar.ctl.appendChild(calendarDiv);
		}
	}
}
pwInputCalendar._keypresshandler = function(event) {
	var calendarDiv = this;
	if(calendarDiv.renderAsPopup){
		try {
			if (event && event.keyCode == 27){
				calendarDiv._hideCalendar();
			}
		} catch(ex) {}
	}
}

pwInputCalendar._clickhandler = function(event) {
	var calendarDiv = this;
	if(calendarDiv.renderAsPopup){
		if (!calendarDiv.bClickOnCalendar) {
			if (calendarDiv.style.display != "none") {
				calendarDiv._hideCalendar();
			}
		}
		calendarDiv.bClickOnCalendar = false;
	}
}

com_tmax_prowave_CalendarInitData = function()
{
    this.fixedX = -1;
    // x position (-1 if to appear below control)
    this.fixedY = -1;
    // y position (-1 if to appear below control)
    this.startAt = 0;
    // 0 - sunday ; 1 - monday
    this.showWeekNumber = 0;
    // 0 - don't show; 1 - show
    this.showToday = 1;
    // 0 - don't show; 1 - show
    this.imgDir = "images/";
    // directory for images ... e.g. this.imgDir="/img/"
    this.themePrefix = "inputCalendar";

    this.gotoString = "Go To Current Month";
    this.todayString = "Today is";
    this.todayDateFormat = "yyyy/MM/dd";
    this.weekString = "WK";
    this.scrollLeftMessage = "Click to scroll to previous month.";
    this.scrollRightMessage = "Click to scroll to next month."
    this.scrollLeftYearMessage = "Click to scroll to previous year.";
    this.scrollRightYearMessage = "Click to scroll to next year."
    this.selectMonthMessage = "Click to select a month."
    this.selectYearMessage = "Click to select a year."
    this.selectDateMessage = "Select [date] as date." // do not replace [date], it will be replaced by date.
	this.invalidMessage = "Invalid date.";

    this.popupLeft=false;

    this.monthName = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
    this.dayName = this.startAt == 0 ? new Array("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat") : new Array("Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun");
	this.renderAsPopup = true;
	// Select month only option
	this.monthSelect=false;
	this.selectType="date";
	this.validMin = null;
	this.validMax = null;
}

com_tmax_prowave_DateParts = function(sec, min, hour, date, month, year)
{
    this.sec = sec;
    this.min = min;
    this.hour = hour;
    this.date = date;
    this.month = month;
    this.year = year;
}

com_tmax_prowave_HolidayRec = function(d, m, y, desc)
{
    this.d = d;
    this.m = m;
    this.y = y;
    this.desc = desc;
}

com_tmax_prowave_PopupCalendar = function(date)
{
    this.idPrefix = "com_tmax_prowave_PopupCalendar";

    this.selectedDate = new com_tmax_prowave_DateParts(0, 0, 0, 0, 0, 0);
    this.saveSelectedDate = new com_tmax_prowave_DateParts(0, 0, 0, 0, 0, 0);

    this.monthConstructed = false;
    this.yearConstructed = false;
    this.intervalID1;
    this.intervalID2;
    this.timeoutID1;
    this.timeoutID2;
    this.ctlToPlaceValue;
    this.ctlNow;
    this.containerCtl;
    this.dateFormat="yyyy/MM/dd";
    this.nStartingYear;
    this.bPageLoaded = false;
    this.dom = document.getElementById;
    this.ns4 = document.layers;
    this.dateFormatSymbols = new com_tmax_prowave_DateFormatSymbols();
    this.initData = new com_tmax_prowave_CalendarInitData();
    this.today = date;
    this.dateNow = this.today.getDate();
    this.monthNow = this.today.getMonth();
    this.yearNow = this.today.getYear();
    this.hourNow = this.today.getHours();
    this.minuteNow = this.today.getMinutes();
    this.secondNow = this.today.getSeconds();
    this.imgSrc = new Array("drop1.gif", "drop2.gif", "prev1.gif", "prev2.gif", "next1.gif", "next2.gif");
    this.img = new Array();

    //elements which need to change their dynamical
    //representation over time
    this.calendarDiv;
    this.selectMonthDiv;
    this.selectYearDiv;
	this.titleMonthCell = null;
    this.changeMonthImg = null;
	this.titleYearCell = null;
    this.changeYearImg = null;
    this.closeCalendarSpan = null;
	this.contentCell = null;
    this.todaySpan = null;

    this.holidaysCounter = 0;
    this.holidays = new Array();

    this.myFacesCtlType = "x:inputCalendar";
    this.inputDateClientId;
    
    this.ie = window.ActiveXObject ? true : false;

	this.validMinDate = null;
	this.validMaxDate = null;
}

com_tmax_prowave_PopupCalendar.prototype.addHoliday = function(d, m, y, desc)
{
    this.holidays[this.holidaysCounter++] = new com_tmax_prowave_HolidayRec (d, m, y, desc);
}

com_tmax_prowave_PopupCalendar.prototype._swapImage = function(srcImg, destImg)
{

    if (srcImg)
        srcImg.setAttribute("src", this.initData.imgDir + destImg);
}

com_tmax_prowave_PopupCalendar.prototype.init = function(calendarId)
{
	// for support absolute position	
	var inputText = $(calendarId);
	var inputContainer = $(calendarId+":container");
	
	var pos = Element.getStyle(inputText, 'position');
	if (pos == 'relative' || pos == 'absolute'){
		Element.setStyle(inputContainer, {position:pos});
		Element.setStyle(inputText,  {position:'static'})
		var topPos = Element.getStyle(inputText, 'top');
		if(topPos != null){
			Element.setStyle(inputContainer, {top:topPos});
			Element.setStyle(inputText, {top:null});
		}
		var leftPos = Element.getStyle(inputText, 'left');
		if(leftPos != null){
			Element.setStyle(inputContainer, {left:leftPos});
			Element.setStyle(inputText, {left:null});
		}
		var rightPos = Element.getStyle(inputText, 'right');
		if(rightPos != null){
			Element.setStyle(inputContainer, {right:rightPos});
			Element.setStyle(inputText, {right:null});
		}
		var bottomPos = Element.getStyle(inputText, 'bottom');
		if(bottomPos != null){
			Element.setStyle(inputContainer, {bottom:bottomPos});
			Element.setStyle(inputText, {bottom:null});
		}
		var margin = Element.getStyle(inputText, 'margin');
		if(margin != null){
			Element.setStyle(inputContainer, {margin:margin});
			Element.setStyle(inputText, {margin:null});
		}
	}
	
	var popupButton = $(calendarId+":popupButton");
	if(popupButton && Element.getStyle(popupButton, 'display') != 'none'){
		var inputTextWidth = parseInt(Element.getStyle(inputText, 'width'));
		var popupButtonWidth =  parseInt(Element.getStyle(popupButton, 'width'));
		if(inputTextWidth > popupButtonWidth){
			Element.setStyle(inputText, {width:(inputTextWidth-(popupButtonWidth+2))+"px"});
		}
	}

    if (this.dom)
    {
        if (!this.calendarDiv)
        {
            for (i = 0; i < this.imgSrc.length; i++)
                this.img[i] = new Image;

            this.containerCtl = $(calendarId+":containerCtl");

			
			// start calendar div
			this.calendarDiv = document.getElementById(this.containerCtl.id + "_calendarDiv");
			if (this.calendarDiv) {
				this._removeAllChildren(this.calendarDiv);
				this.calendarDiv.bClickOnCalendar = false;
				this.calendarDiv.className = this.initData.themePrefix + "-div-style";
				this.calendarDiv.style.visibility = (this.dom || this.ie)? "visible" : "show"; //예전 css때문
				if(this.initData.renderAsPopup){
					this.calendarDiv.style.position="absolute";
					this.calendarDiv.style.display="none";
				}else{
					this.calendarDiv.style.position="static";
					this.calendarDiv.style.zIndex=1;
				}
			} else {
				this.calendarDiv = document.createElement("div");
				this.calendarDiv.id = this.containerCtl.id + "_calendarDiv";
				this.calendarDiv._hideCalendar = function() {
					var selectMonthDiv = document.getElementById(this.id + "_selectMonthDiv");
					var selectYearDiv = document.getElementById(this.id + "_selectYearDiv");
					if (selectMonthDiv.style != null) {
						selectMonthDiv.style.display = "none";
					}
					if (selectYearDiv.style != null)
					{
						selectYearDiv.style.display = "none";
					}

//					if (ProWave.oldIE) {
						ProWave.showMSCtl(selectYearDiv,this);
						ProWave.showMSCtl(selectMonthDiv,this);
						ProWave.showMSCtl(this,pwInputCalendar.ctl,true);
//					}

					this.style.display = "none";
				}
				this.containerCtl.appendChild(this.calendarDiv);
				this.calendarDiv.bClickOnCalendar = false;
				this.calendarDiv.className = this.initData.themePrefix + "-div-style";
				this.calendarDiv.style.visibility = (this.dom || this.ie)? "visible" : "show"; //예전 css때문
				if(this.initData.renderAsPopup){
					this.calendarDiv.renderAsPopup = true;
					this.calendarDiv.style.position="absolute";
					this.calendarDiv.style.display="none";
					Event.observe(this.calendarDiv, "click", function(event)
					{
						Event.stop(event);
					}.bind(this), false);
					pwInputCalendar.addPopupCalendar(this.calendarDiv);
					Event.observe(document, "keypress", pwInputCalendar._keypresshandler.bindAsEventListener(this.calendarDiv), false);
					Event.observe(document, "click", pwInputCalendar._clickhandler.bindAsEventListener(this.calendarDiv), false);
					Event.observe(document, "pw:closeWindow", pwInputCalendar._clickhandler.bindAsEventListener(this.calendarDiv), false);
				}else{
					this.calendarDiv.style.position="static";
					this.calendarDiv.style.zIndex=1;
					Event.observe(this.calendarDiv, "click", function()
					{
						this.calendarDiv.bClickOnCalendar = true;
					}.bind(this), false);
				}
			}

			// main table
			//  -----------------
			// | Title Controls  |
			//  -----------------
			// | Wk | Calendar   |
			// | :  |   :        |
			//  -----------------
			// | Today Message   |
			//  -----------------
            var mainTable = document.createElement("table");
            //mainTable.setAttribute("style", "width:" + ((this.initData.showWeekNumber == 1)?250:200) + "px;");
            mainTable.setAttribute("cellpadding","0px");
            mainTable.setAttribute("cellspacing","0px");
            mainTable.className = this.initData.themePrefix + "-table-style";

            this.calendarDiv.appendChild(mainTable);

            //This is necessary for IE. If you don't create a tbody element, the table will never show up!
            var mainBody = document.createElement("tbody");
            mainTable.appendChild(mainBody);

			// Title Controls (buttons + month list + year list)
			//  --------------------------------------------------
			// | prev | month | year | monthSelect | next | Close |
			//  --------------------------------------------------
            var mainRow = document.createElement("tr");
            mainRow.className = this.initData.themePrefix + "-title-background-style";
				
            mainBody.appendChild(mainRow);

            var mainCell = document.createElement("td");
            mainCell.className = this.initData.themePrefix + "-title-style";

            mainRow.appendChild(mainCell);

            var contentTable = document.createElement("table");
            //contentTable.setAttribute("style", "width:" + ((this.initData.showWeekNumber == 1)?248:198) + "px;");
            contentTable.className = this.initData.themePrefix + "-title-style";
            mainCell.appendChild(contentTable);
            var contentBody = document.createElement("tbody");
            contentTable.appendChild(contentBody);

            var headerRow = document.createElement("tr");
            contentBody.appendChild(headerRow);

			// prev Month Button Cell
			var prevButtonCell = document.createElement("td");
			headerRow.appendChild(prevButtonCell);
			this._appendNavButton("prev",prevButtonCell);

			if (this.initData.selectType == "year") {
				// yearSet list Cell
				this.titleYearSetCell = document.createElement("td");
				headerRow.appendChild(this.titleYearSetCell);
			} else {
				// month list Cell
				this.titleMonthCell = document.createElement("td");
				headerRow.appendChild(this.titleMonthCell);
				this._appendMonthToCell();
				// year list Cell
				this.titleYearCell = document.createElement("td");
				headerRow.appendChild(this.titleYearCell);
				this._appendYearToCell();
				if (this.initData.selectType == "month") {
					this.initData.monthSelect = true;
				}
			}

			// next Month Button Cell
			var nextButtonCell = document.createElement("td");
			headerRow.appendChild(nextButtonCell);
			this._appendNavButton("next",nextButtonCell);
			
			// close button
            var closeButtonCell = document.createElement("td");
            closeButtonCell.setAttribute("style", "text-align:right;");
            headerRow.appendChild(closeButtonCell);

            var closeCalendarLink = document.createElement("a");
            closeCalendarLink.setAttribute("href", "#");
            Event.observe(closeCalendarLink, "click", function(event)
            {
                if(this.initData.renderAsPopup){
                	this.calendarDiv._hideCalendar();
                }
                Event.stop(event);
            }.bindAsEventListener(this), false);

            closeButtonCell.appendChild(closeCalendarLink);

            this.closeCalendarSpan = document.createElement("span");

            closeCalendarLink.appendChild(this.closeCalendarSpan);
			// end close button end

			// Calendar > Week + Calendar
            var contentRow = document.createElement("tr");
            
            mainBody.appendChild(contentRow);

            this.contentCell = document.createElement("td");
            this.contentCell.className = this.initData.themePrefix + "-body-style";
            contentRow.appendChild(this.contentCell);

			// Calendar > Today Message
            if (this.initData.showToday == 1)
            {
                var todayRow = document.createElement("tr");
                todayRow.className = this.initData.themePrefix + "-today-style";
                mainBody.appendChild(todayRow);

                var todayCell = document.createElement("td");
                todayCell.className = this.initData.themePrefix + "-today-lbl-style";
                todayRow.appendChild(todayCell);

                this.todaySpan = document.createElement("span");
                todayCell.appendChild(this.todaySpan);
            }
			// end calendar div

			// month selectlist div
            this.selectMonthDiv = document.createElement("div");
            this.selectMonthDiv.id = this.calendarDiv.id + "_selectMonthDiv";
            this.selectMonthDiv.className = this.initData.themePrefix + "-div-style";
			this.calendarDiv.appendChild(this.selectMonthDiv);

			// year selectlist div
            this.selectYearDiv = document.createElement("div");
            this.selectYearDiv.id = this.calendarDiv.id + "_selectYearDiv";
            this.selectYearDiv.className = this.initData.themePrefix + "-div-style";
            this.calendarDiv.appendChild(this.selectYearDiv);
            
			//Time Selection
			if (this.initData.selectType == "datetime" || this.initData.selectType == "time") {
						
				// if selectType is "time"
				if (this.initData.selectType == "time") {
					mainRow.style.display = "none";
					contentRow.style.display = "none";
				}	

			  	var timeSelectRow = document.createElement("tr");
			  	timeSelectRow.setAttribute("align", "center");
	            mainBody.appendChild(timeSelectRow);
	
	            var timeSelectCell = document.createElement("td");
	            
	            if (this.initData.selectType != "time") {
	            	timeSelectCell.className =  this.initData.themePrefix + "-time-cell";
	            }
	            
	            timeSelectRow.appendChild(timeSelectCell);
	
	            var timeSelectSpan = document.createElement("span");
	            timeSelectCell.appendChild(timeSelectSpan);
	            
				var timeTable = document.createElement("table");
				timeTable.className =  this.initData.themePrefix + "-time-table";
				timeSelectCell.appendChild(timeTable);
				var timeBody = document.createElement("tbody");
				timeTable.appendChild(timeBody);
				var timeRow = document.createElement("tr");
				timeBody.appendChild(timeRow);
				var ampmCell = document.createElement("td");
				timeRow.appendChild(ampmCell);
				ampmCell.innerHTML = this._createCalendarSpinner(this.containerCtl.id + "_ampm", "ampm");
				
				var hourCell = document.createElement("td");
				timeRow.appendChild(hourCell);
				hourCell.innerHTML = this._createCalendarSpinner(this.containerCtl.id + "_hour");
				
				var divisionCell1 =  document.createElement("td");
				timeRow.appendChild(divisionCell1);
				divisionCell1.appendChild(document.createTextNode(":"));
				
				var minuteCell = document.createElement("td");
				timeRow.appendChild(minuteCell);
				minuteCell.innerHTML = this._createCalendarSpinner(this.containerCtl.id + "_minute");
				
				var divisionCell2 =  document.createElement("td");
				timeRow.appendChild(divisionCell2);
				divisionCell2.appendChild(document.createTextNode(":"));
				
				var secondCell = document.createElement("td");
				timeRow.appendChild(secondCell);
				secondCell.innerHTML = this._createCalendarSpinner(this.containerCtl.id + "_second");
				
				$(this.containerCtl.id + "_ampm_input").value=(this.hourNow <= 12)?this.dateFormatSymbols.ampms[0]:this.dateFormatSymbols.ampms[1];
				$(this.containerCtl.id + "_hour_input").value = (this.hourNow <= 12)?this.hourNow:this.hourNow-12;
				$(this.containerCtl.id + "_minute_input").value=this.minuteNow;
				$(this.containerCtl.id + "_second_input").value=this.secondNow;
			
				new ProWaveSpinner(this.containerCtl.id + '_ampm_input', this.containerCtl.id + '_ampm_spinner_up', this.containerCtl.id + '_ampm_spinner_down', {data: this.dateFormatSymbols.ampms});
				new ProWaveSpinner(this.containerCtl.id + '_hour_input', this.containerCtl.id + '_hour_spinner_up', this.containerCtl.id + '_hour_spinner_down', {interval: 1, min:1, max:12});
				new ProWaveSpinner(this.containerCtl.id + '_minute_input', this.containerCtl.id + '_minute_spinner_up', this.containerCtl.id + '_minute_spinner_down', {interval: 1, min:0, max:59});
				new ProWaveSpinner(this.containerCtl.id + '_second_input', this.containerCtl.id + '_second_spinner_up', this.containerCtl.id + '_second_spinner_down', {interval: 1, min:0, max:59});

				if(!this.initData.renderAsPopup){
					Event.observe($(this.containerCtl.id + "_ampm_input"), "change", function(event) {
						this._setSelectedTime();
						this._applyCalendarInput();
						this._closeCalendar();
                		Event.stop(event);
            		}.bindAsEventListener(this), false);
            		
            		Event.observe($(this.containerCtl.id + "_hour_input"), "change", function(event) {
						this._setSelectedTime();
						this._applyCalendarInput();
						this._closeCalendar();
                		Event.stop(event);
            		}.bindAsEventListener(this), false);
            		
            		Event.observe($(this.containerCtl.id + "_minute_input"), "change", function(event) {
						this._setSelectedTime();
						this._applyCalendarInput();
						this._closeCalendar();
                		Event.stop(event);
            		}.bindAsEventListener(this), false);
            		
              		Event.observe($(this.containerCtl.id + "_second_input"), "change", function(event) {
						this._setSelectedTime();
						this._applyCalendarInput();
						this._closeCalendar();
                		Event.stop(event);
            		}.bindAsEventListener(this), false);
            		
            		Event.observe($(this.containerCtl.id + "_ampm_spinner_up"), "click", function(event) {
            			this._setSelectedTime();
						this._applyCalendarInput();
						this._closeCalendar();
                		Event.stop(event);
            		}.bindAsEventListener(this), false);     

            		Event.observe($(this.containerCtl.id + "_ampm_spinner_down"), "click", function(event) {
            			this._setSelectedTime();
						this._applyCalendarInput();
						this._closeCalendar();
                		Event.stop(event);
            		}.bindAsEventListener(this), false);
            		
            		Event.observe($(this.containerCtl.id + "_hour_spinner_up"), "click", function(event) {
            			this._setSelectedTime();
						this._applyCalendarInput();
						this._closeCalendar();
                		Event.stop(event);
            		}.bindAsEventListener(this), false);     

            		Event.observe($(this.containerCtl.id + "_hour_spinner_down"), "click", function(event) {
            			this._setSelectedTime();
						this._applyCalendarInput();
						this._closeCalendar();
                		Event.stop(event);
            		}.bindAsEventListener(this), false);    
            		
            		Event.observe($(this.containerCtl.id + "_minute_spinner_up"), "click", function(event) {
            			this._setSelectedTime();
						this._applyCalendarInput();
						this._closeCalendar();
                		Event.stop(event);
            		}.bindAsEventListener(this), false);     

            		Event.observe($(this.containerCtl.id + "_minute_spinner_down"), "click", function(event) {
            			this._setSelectedTime();
						this._applyCalendarInput();
						this._closeCalendar();
                		Event.stop(event);
            		}.bindAsEventListener(this), false);    
            		
            	    Event.observe($(this.containerCtl.id + "_second_spinner_up"), "click", function(event) {
            			this._setSelectedTime();
						this._applyCalendarInput();
						this._closeCalendar();
                		Event.stop(event);
            		}.bindAsEventListener(this), false);     

            		Event.observe($(this.containerCtl.id + "_second_spinner_down"), "click", function(event) {
            			this._setSelectedTime();
						this._applyCalendarInput();
						this._closeCalendar();
                		Event.stop(event);
            		}.bindAsEventListener(this), false);    
         		}				
								
				if(this.initData.renderAsPopup){
					var saveButtonCell = document.createElement("td");
					timeRow.appendChild(saveButtonCell);
					var saveButton = document.createElement("a");
					saveButton.className =  this.initData.themePrefix+ "-time-save";
					saveButton.setAttribute("href", "javascript:;");
					saveButtonCell.appendChild(saveButton);
					Event.observe(saveButtonCell, "click", function(event) {
							this._setSelectedTime();
							this._applyCalendarInput();
							this._closeCalendar();
                		Event.stop(event);
            		}.bindAsEventListener(this), false);
					
					if (this.initData.selectType == "time") {
						var cancelButtonCell = document.createElement("td");
						timeRow.appendChild(cancelButtonCell);
						var cancelButton = document.createElement("a");
						cancelButton.className =  this.initData.themePrefix+ "-time-cancel";
						cancelButton.setAttribute("href", "javascript:;");
						cancelButtonCell.appendChild(cancelButton);
						Event.observe(cancelButton, "click", function(event) {
                			if(this.initData.renderAsPopup){
                				this.calendarDiv._hideCalendar();
                			}
                			Event.stop(event);
            			}.bindAsEventListener(this), false);
					}
				}
			}
        }
    }


    if (!this.ns4)
    {
        if (!this.ie)
            this.yearNow += 1900;
		if (this.initData.validMin) {
			var simpleDateFormat = new com_tmax_prowave_SimpleDateFormat(this.dateFormat, this.dateFormatSymbols);
			this.validMinDate = simpleDateFormat.parse(this.initData.validMin);
		}
		if (this.initData.validMax) {
			var simpleDateFormat = new com_tmax_prowave_SimpleDateFormat(this.dateFormat, this.dateFormatSymbols);
			this.validMaxDate = simpleDateFormat.parse(this.initData.validMax);
		}

        this.monthConstructed = false;
        this.yearConstructed = false;

        if (this.initData.showToday == 1)
        {
            this.todaySpan.appendChild(document.createTextNode(this.initData.todayString + " "))

            var todayLink = document.createElement("a");
            todayLink.className = this.initData.themePrefix + "-today-style";
            todayLink.setAttribute("title", this.initData.gotoString);
            todayLink.setAttribute("href", "#")
            todayLink.appendChild(document.createTextNode(this._todayIsDate()));
            Event.observe(todayLink, "click", function(event)
            {
                this.selectedDate.month = this.monthNow;
                this.selectedDate.year = this.yearNow;
				this.selectedDate.yearSet = null;
                this._constructCalendar();
                Event.stop(event);
            }.bindAsEventListener(this), false);
            Event.observe(todayLink, "mousemove", function()
            {
                window.status = this.initData.gotoString;
            }.bind(this), false);
            Event.observe(todayLink, "mouseout", function()
            {
                window.status = "";
            }.bind(this), false);

            this.todaySpan.appendChild(todayLink);
        }

        this.bPageLoaded = true;

    }
}

// Title Month
com_tmax_prowave_PopupCalendar.prototype._appendMonthToCell = function()
{
	this.titleMonthCell.className = this.initData.themePrefix + "-title-control-normal-style";
	
	Event.observe(this.titleMonthCell, "mouseover", function(event)
	{
	    this._swapImage(this.changeMonthImg, "drop2.gif");
	    this.titleMonthCell.className = this.initData.themePrefix + "-title-control-select-style";
	    window.status = this.initData.selectMonthMessage;
	}.bindAsEventListener(this), false);
	
	Event.observe(this.titleMonthCell, "mouseout", function(event)
	{
	    this._swapImage(this.changeMonthImg, "drop1.gif");
	    this.titleMonthCell.className = this.initData.themePrefix + "-title-control-normal-style";
	    window.status = "";
	}.bindAsEventListener(this), false);
	
	Event.observe(this.titleMonthCell, "click", function(event)
	{
	    this._popUpMonth();
	    Event.stop(event);
	}.bind(this), false);
}
// Title Year
com_tmax_prowave_PopupCalendar.prototype._appendYearToCell = function()
{
	this.titleYearCell.className = this.initData.themePrefix + "-title-control-normal-style";
	
	Event.observe(this.titleYearCell, "mouseover", function(event)
	{
	    this._swapImage(this.changeYearImg, "drop2.gif");
	    this.titleYearCell.className = this.initData.themePrefix + "-title-control-select-style";
	    window.status = this.initData.selectYearMessage;
	}.bindAsEventListener(this), false);
	
	Event.observe(this.titleYearCell, "mouseout", function(event)
	{
	    this._swapImage(this.changeYearImg, "drop1.gif");
	    this.titleYearCell.className = this.initData.themePrefix + "-title-control-normal-style";
	    window.status = "";
	}.bindAsEventListener(this), false);
	
	Event.observe(this.titleYearCell, "click", function(event)
	{
	    this._popUpYear();
	    Event.stop(event);
	}.bind(this), false);
}
// prev/next Button
com_tmax_prowave_PopupCalendar.prototype._appendNavButton = function(direction, buttonCell)
{
    var imgButton = document.createElement("img");
    imgButton.setAttribute("src", this.initData.imgDir + direction + "1.gif");
    imgButton.className = this.initData.themePrefix + "-" + direction + "-button-style";

    this._createControl(direction, imgButton);

    buttonCell.appendChild(imgButton);
}
com_tmax_prowave_PopupCalendar.prototype._createControl = function(direction, imgButton)
{
    Event.observe(imgButton, "mouseover", function(event)
    {
        this._swapImage(imgButton, direction + "2.gif");
        if (direction == "prev")
        {
        	if(this.initData.monthSelect)
        		 window.status = this.initData.scrollLeftYearMessage;
        	else
            	window.status = this.initData.scrollLeftMessage;
        }
        else
        {
            if(this.initData.monthSelect)
            	window.status = this.initData.scrollRightYearMessage;
            else
            	window.status = this.initData.scrollRightMessage;
        }
    }.bindAsEventListener(this), false);
    Event.observe(imgButton, "click", function()
    {
        if (direction == "prev")
        {
			if (this.initData.selectType == "year") {
				this._decYearSet();
			} else {
				if(this.initData.monthSelect)
					this._decreaseYear();
				else
					this._decMonth();
			}
        }
        else
        {
			if (this.initData.selectType == "year") {
				this._incYearSet();
			} else {
				if(this.initData.monthSelect)
					this._increaseYear();
				else
					this._incMonth();
			}
        }
    }.bind(this), false);
    Event.observe(imgButton, "mouseout", function(event)
    {
        clearInterval(this.intervalID1);
        this._swapImage(imgButton, direction + "1.gif");
        window.status = "";
    }.bindAsEventListener(this), false);
    Event.observe(imgButton, "mousedown", function()
    {
        clearTimeout(this.timeoutID1);
        this.timeoutID1 = setTimeout((function()
        {
            if (direction == "prev")
            {
                this._startDecMonth();
            }
            else
            {
                this._startIncMonth();
            }
        }).bind(this), 500)
    }.bind(this), false);
    Event.observe(imgButton, "mouseup", function()
    {
        clearTimeout(this.timeoutID1);
        clearInterval(this.intervalID1);
    }.bind(this), false);
}

com_tmax_prowave_PopupCalendar.prototype._appendNbsp = function(element)
{
    if (element)
        element.appendChild(document.createTextNode(String.fromCharCode(160)));
}

com_tmax_prowave_PopupCalendar.prototype._todayIsDate = function()
{
    var format = new com_tmax_prowave_SimpleDateFormat(this.initData.todayDateFormat?
                                                         this.initData.todayDateFormat:this.dateFormat,
                                                         this.dateFormatSymbols);
    return format.format(this.today);
}

com_tmax_prowave_PopupCalendar.prototype._padZero = function(num)
{
    return (num < 10)? '0' + num : num;
}

com_tmax_prowave_PopupCalendar.prototype._constructDate = function(d, M, y, h, m, s)
{
	if(!h)
		h =  this.selectedDate.hour;
	if(!m)
		m = this.selectedDate.min;
	if(!s)
		s = this.selectedDate.sec;
		
    var format = new com_tmax_prowave_SimpleDateFormat(this.dateFormat, this.dateFormatSymbols);
    return format.format(new Date(y, M, d, h, m, s));
}

com_tmax_prowave_PopupCalendar.prototype._applyCalendarInput = function()
{

    if (this.myFacesCtlType != "x:inputDate")
    {
    	this.ctlToPlaceValue.value = this._constructDate(this.selectedDate.date, this.selectedDate.month, this.selectedDate.year, this.selectedDate.hour, this.selectedDate.min, this.selectedDate.sec)
    	//2009/02/17: ajaxSupport에서 onchange이벤트를 받을 수 있도록 수정
    	ProWave.fireEvent(this.ctlToPlaceValue,"change");
/*    	
        var onchange = this.ctlToPlaceValue.getAttribute("onchange");
        if (onchange)
        {
            this.ctlToPlaceValue.onchange();
        }
*/        
    }
    else
    {
        document.getElementById(this.myFacesInputDateClientId + ".day").value = this.selectedDate.date;
        document.getElementById(this.myFacesInputDateClientId + ".month").value = this.selectedDate.month + 1;
        document.getElementById(this.myFacesInputDateClientId + ".year").value = this.selectedDate.year;
    }
    
	if(this.initData.renderAsPopup){
    	this.calendarDiv._hideCalendar();
    }
}

com_tmax_prowave_PopupCalendar.prototype._closeCalendar = function()
{
	if(this.initData.renderAsPopup){
    	this.calendarDiv._hideCalendar();
    }
}

/*** Month Pulldown	***/

com_tmax_prowave_PopupCalendar.prototype._startDecMonth = function()
{
    this.intervalID1 = setInterval((function()
    {
        this._decMonth
    }).bind(this), 80);
}

com_tmax_prowave_PopupCalendar.prototype._startIncMonth = function()
{
    this.intervalID1 = setInterval((function()
    {
        this._incMonth
    }).bind(this), 80);
}

com_tmax_prowave_PopupCalendar.prototype._incMonth = function()
{
    this.selectedDate.month = this.selectedDate.month + 1;
    if (this.selectedDate.month > 11)
    {
        this.selectedDate.month = 0;
        this.selectedDate.year++;
    }
    this._constructCalendar();
}

com_tmax_prowave_PopupCalendar.prototype._decMonth = function()
{
    this.selectedDate.month = this.selectedDate.month - 1;
    if (this.selectedDate.month < 0)
    {
        this.selectedDate.month = 11
        this.selectedDate.year--
    }
    this._constructCalendar()
}

com_tmax_prowave_PopupCalendar.prototype._increaseYear = function()
{
    this.selectedDate.year++;
    this._constructCalendar();
}

com_tmax_prowave_PopupCalendar.prototype._decreaseYear = function()
{
	this.selectedDate.year--;
    this._constructCalendar();
}

com_tmax_prowave_PopupCalendar.prototype._incYearSet = function()
{
    this.selectedDate.yearSet++;
    this._constructCalendar();
}

com_tmax_prowave_PopupCalendar.prototype._decYearSet = function()
{
	this.selectedDate.yearSet--;
    this._constructCalendar();
}


com_tmax_prowave_PopupCalendar.prototype._removeAllChildren = function(element)
{
    while (element && element.hasChildNodes())
        element.removeChild(element.lastChild);
}

com_tmax_prowave_PopupCalendar.prototype._constructMonth = function()
{
    this._popDownYear();
    if (!this.monthConstructed)
    {

        var selectMonthTable = document.createElement("table");
        //selectMonthTable.setAttribute("style", "width:70px;border-collapse:collapse;")
        selectMonthTable.setAttribute("style", "border-collapse:collapse;")
        selectMonthTable.className = this.initData.themePrefix + "-dropdown-style";

        this._removeAllChildren(this.selectMonthDiv);

        this.selectMonthDiv.appendChild(selectMonthTable);

        Event.observe(selectMonthTable, "mouseover", function()
        {
            clearTimeout(this.timeoutID1);
        }.bind(this), false);
        Event.observe(selectMonthTable, "mouseout", function(event)
        {
            clearTimeout(this.timeoutID1);
            this.timeoutID1 = setTimeout((function()
            {
                this._popDownMonth()
            }).bind(this), 100);
            Event.stop(event);
        }.bindAsEventListener(this), false);

        var selectMonthTableBody = document.createElement("tbody");
        selectMonthTable.appendChild(selectMonthTableBody);

        for (i = 0; i < 12; i++)
        {
            var sName = this.initData.monthName[i];

            var sNameNode = null;

            if (i == this.selectedDate.month)
            {
                sNameNode = document.createElement("span");
                sNameNode.setAttribute("style", "font-weight:bold;");
                sNameNode.appendChild(document.createTextNode(sName));
                sNameNode.setAttribute("userData",i);
            }
            else
            {
                sNameNode = document.createTextNode(sName);
            }

            var monthRow = document.createElement("tr");
            selectMonthTableBody.appendChild(monthRow);

            var monthCell = document.createElement("td");
            monthCell.setAttribute("userData",i);
            monthCell.className = this.initData.themePrefix + "-dropdown-normal-style";
            monthRow.appendChild(monthCell);

            Event.observe(monthCell, "mouseover", function(event)
            {
                Event.element(event).className = this.initData.themePrefix + "-dropdown-select-style";
            }.bind(this), false);

            Event.observe(monthCell, "mouseout", function(event)
            {
                Event.element(event).className = this.initData.themePrefix + "-dropdown-normal-style";
            }.bind(this), false);

            Event.observe(monthCell, "click", function(event)
            {
                this.monthConstructed = false;
                this.selectedDate.month = parseInt(Event.element(event).getAttribute("userData"),10);
                this._constructCalendar();
                this._popDownMonth();
                Event.stop(event);
            }.bindAsEventListener(this), false);

            this._appendNbsp(monthCell);
            monthCell.appendChild(sNameNode);
            this._appendNbsp(monthCell);
        }

        this.monthConstructed = true;
    }
}

com_tmax_prowave_PopupCalendar.prototype.positionedOffset = function(element) {
    var valueT = 0, valueL = 0;
    do {
      valueT += element.offsetTop  || 0;
      valueL += element.offsetLeft || 0;
      element = element.offsetParent;
      if (element) {
        if (element.tagName == 'BODY') break;
        var p = Element.getStyle(element, 'position');
        if (p == 'relative' || p == 'absolute') break;
      }
    } while (element);
    return [valueL, valueT];
}
com_tmax_prowave_PopupCalendar.prototype._popUpMonth = function()
{
    this._constructMonth();
    this.selectMonthDiv.style.display = "block";
    this.selectMonthDiv.style.visibility = (this.dom || this.ie)? "visible" : "show"; //예전 css때문
	if(this.initData.renderAsPopup) {
		this.selectMonthDiv.style.left = this.titleMonthCell.offsetLeft + "px";
		this.selectMonthDiv.style.top = this.titleMonthCell.offsetTop + this.titleMonthCell.offsetHeight + "px";
	} else {
		var poffset = this.positionedOffset(this.calendarDiv);
		if (this.ie) {
			this.selectMonthDiv.style.left = document.body.offsetLeft + poffset[0] + this.titleMonthCell.offsetLeft + "px";
			this.selectMonthDiv.style.top = document.body.offsetTop + poffset[1] + this.titleMonthCell.offsetTop + this.titleMonthCell.offsetHeight + "px";
		} else {
			this.selectMonthDiv.style.left = poffset[0] + this.titleMonthCell.offsetLeft + "px";
			this.selectMonthDiv.style.top = poffset[1] + this.titleMonthCell.offsetTop + this.titleMonthCell.offsetHeight + "px";
		}
	}
//	if (ProWave.oldIE) {
		ProWave.hideMSCtl(this.selectMonthDiv,this.calendarDiv);
//	}
}

com_tmax_prowave_PopupCalendar.prototype._popDownMonth = function()
{
//	this.selectMonthDiv.style.visibility = "hidden";
	this.selectMonthDiv.style.display = "none";
//	if (ProWave.oldIE) {
		ProWave.showMSCtl(this.selectMonthDiv,this.calendarDiv);
//	}
}

/*** Year Pulldown ***/

com_tmax_prowave_PopupCalendar.prototype._incYear = function()
{
    for (i = 0; i < 7; i++)
    {
        newYear = (i + this.nStartingYear) + 1;

        this._createAndAddYear(newYear, i);
    }
    this.nStartingYear++;
    this.calendarDiv.bClickOnCalendar = true;
}

com_tmax_prowave_PopupCalendar.prototype._createAndAddYear = function(newYear, i)
{
    var parentNode = document.getElementById(this.containerCtl.getAttribute("id")+"y" + i);
	this._removeAllChildren(parentNode);

    if (newYear == this.selectedDate.year)
    {
        this._appendNbsp(parentNode);
        var newYearSpan = document.createElement("span");
        newYearSpan.setAttribute("userData",newYear);
        newYearSpan.appendChild(document.createTextNode(newYear));
        parentNode.appendChild(newYearSpan);
        this._appendNbsp(parentNode);
    }
    else
    {
        this._appendNbsp(parentNode);
        parentNode.appendChild(document.createTextNode(newYear));
        this._appendNbsp(parentNode);
    }

    parentNode.setAttribute("userData",newYear);
}


com_tmax_prowave_PopupCalendar.prototype._decYear = function()
{
    for (i = 0; i < 7; i++)
    {
        newYear = (i + this.nStartingYear) - 1;

        this._createAndAddYear(newYear, i);
    }
    this.nStartingYear--;
    this.calendarDiv.bClickOnCalendar = true;
}

com_tmax_prowave_PopupCalendar.prototype._constructYear = function()
{
    this._popDownMonth();
    var sHTML = "";
    if (!this.yearConstructed)
    {

        var selectYearTable = document.createElement("table");
        //selectYearTable.setAttribute("style", "width:44px;border-collapse:collapse;")
        selectYearTable.setAttribute("style", "border-collapse:collapse;")
        selectYearTable.className = this.initData.themePrefix + "-dropdown-style";

        this._removeAllChildren(this.selectYearDiv);

        this.selectYearDiv.appendChild(selectYearTable);

        Event.observe(selectYearTable, "mouseover", function()
        {
            clearTimeout(this.timeoutID2);
        }.bind(this), false);
        Event.observe(selectYearTable, "mouseout", function(event)
        {
            clearTimeout(this.timeoutID2);
            this.timeoutID2 = setTimeout((function()
            {
                this._popDownYear()
            }).bind(this), 100);
            Event.stop(event);
        }.bindAsEventListener(this), false);


        var selectYearTableBody = document.createElement("tbody");
        selectYearTable.appendChild(selectYearTableBody);

        var selectYearRowMinus = document.createElement("tr");
        selectYearTableBody.appendChild(selectYearRowMinus);

        var selectYearCellMinus = document.createElement("td");
        selectYearCellMinus.setAttribute("align", "center");

        selectYearCellMinus.appendChild(document.createTextNode("-"));

        selectYearRowMinus.appendChild(selectYearCellMinus);

        Event.observe(selectYearCellMinus, "mouseover", function(event)
        {
            Event.element(event).className = this.initData.themePrefix + "-dropdown-select-style";
        }.bindAsEventListener(this), false);

        Event.observe(selectYearCellMinus, "mouseout", function(event)
        {
            clearInterval(this.intervalID1);
            Event.element(event).className = this.initData.themePrefix + "-dropdown-normal-style";
        }.bindAsEventListener(this), false);

        Event.observe(selectYearCellMinus, "mousedown", function(event)
        {
            clearInterval(this.intervalID1);
            this.intervalID1 = setInterval((function()
            {
                this._decYear();
            }).bind(this), 30);
            Event.stop(event);
        }.bindAsEventListener(this), false);

        Event.observe(selectYearCellMinus, "mouseup", function(event)
        {
            clearInterval(this.intervalID1);
            Event.stop(event);
        }.bindAsEventListener(this), false);


        //sHTML =	"<tr><td align='center'	onmouseover='this.className=\""+this.initData.themePrefix+"-dropdown-select-style\"' onmouseout='clearInterval(this.intervalID1); this.className=\""+this.initData.themePrefix+"-dropdown-normal-style\"' onmousedown='clearInterval(this.intervalID1);this.intervalID1=setInterval(\"_decYear()\",30)' onmouseup='clearInterval(this.intervalID1)'>-</td></tr>";

        this.nStartingYear = this.selectedDate.year - 3;
        var j = 0;
        for (i = this.selectedDate.year - 3; i <= (this.selectedDate.year + 3); i++)
        {
            var sName = i;

            var sNameNode = null;

            if (i == this.selectedDate.year)
            {
                sNameNode = document.createElement("span");
                sNameNode.setAttribute("style", "font-weight:bold;");
                sNameNode.appendChild(document.createTextNode(sName));
                sNameNode.setAttribute("userData", sName);
            }
            else
            {
                sNameNode = document.createTextNode(sName);
            }

            var yearRow = document.createElement("tr");
            selectYearTableBody.appendChild(yearRow);

            var yearCell = document.createElement("td");
            yearCell.setAttribute("userData",sName);
            yearCell.setAttribute("id",this.containerCtl.getAttribute("id")+"y" + j);
            yearCell.className = this.initData.themePrefix + "-dropdown-normal-style";
            yearRow.appendChild(yearCell);

            Event.observe(yearCell, "mouseover", function(event)
            {
                Event.element(event).className = this.initData.themePrefix + "-dropdown-select-style";
            }.bind(this), false);

            Event.observe(yearCell, "mouseout", function(event)
            {
                Event.element(event).className = this.initData.themePrefix + "-dropdown-normal-style";
            }.bind(this), false);

            Event.observe(yearCell, "click", function(event)
            {
                var elem = Event.element(event);
                var sYear = null;
                this.selectedDate.year = parseInt(this._formatInt(elem.getAttribute("userData"),10));
                this.yearConstructed = false;
                this._popDownYear();
                this._constructCalendar();
                Event.stop(event);
            }.bindAsEventListener(this), false);

            this._appendNbsp(yearCell);
            yearCell.appendChild(sNameNode);
            this._appendNbsp(yearCell);
            j++;
        }

        var selectYearRowPlus = document.createElement("tr");
        selectYearTableBody.appendChild(selectYearRowPlus);

        var selectYearCellPlus = document.createElement("td");
        selectYearCellPlus.setAttribute("align", "center");

        selectYearCellPlus.appendChild(document.createTextNode("+"));

        selectYearRowPlus.appendChild(selectYearCellPlus);

        Event.observe(selectYearCellPlus, "mouseover", function(event)
        {
            Event.element(event).className = this.initData.themePrefix + "-dropdown-select-style";
        }.bindAsEventListener(this), false);

        Event.observe(selectYearCellPlus, "mouseout", function(event)
        {
            clearInterval(this.intervalID2);
            Event.element(event).className = this.initData.themePrefix + "-dropdown-normal-style";
        }.bindAsEventListener(this), false);

        Event.observe(selectYearCellPlus, "mousedown", function(event)
        {
            clearInterval(this.intervalID2);
            this.intervalID2 = setInterval((function()
            {
                this._incYear();
            }).bind(this), 30);
        }.bindAsEventListener(this), false);

        Event.observe(selectYearCellPlus, "mouseup", function(event)
        {
            clearInterval(this.intervalID2);
        }.bindAsEventListener(this), false);

        this.yearConstructed = true;
    }
}

com_tmax_prowave_PopupCalendar.prototype._popDownYear = function()
{
    clearInterval(this.intervalID1);
    clearTimeout(this.timeoutID1);
    clearInterval(this.intervalID2);
    clearTimeout(this.timeoutID2);
//    this.selectYearDiv.style.visibility = "hidden";
    this.selectYearDiv.style.display = "none";
//	if (ProWave.oldIE) {
		ProWave.showMSCtl(this.selectYearDiv,this.calendarDiv);
//	}
}

com_tmax_prowave_PopupCalendar.prototype._popUpYear = function()
{
    this._constructYear();
    this.selectYearDiv.style.display = "block";
    this.selectYearDiv.style.visibility = (this.dom || this.ie) ? "visible" : "show"; //예전 css때문
	if(this.initData.renderAsPopup) {
		this.selectYearDiv.style.left = this.titleYearCell.offsetLeft + "px";
		this.selectYearDiv.style.top = this.titleYearCell.offsetTop + this.titleYearCell.offsetHeight + "px";
	} else {
		var poffset = this.positionedOffset(this.calendarDiv);
		if (this.ie) {
			this.selectYearDiv.style.left = document.body.offsetLeft + poffset[0] + this.titleYearCell.offsetLeft + "px";
			this.selectYearDiv.style.top = document.body.offsetTop + poffset[1] + this.titleYearCell.offsetTop + this.titleYearCell.offsetHeight + "px";
		} else {
			this.selectYearDiv.style.left = poffset[0] + this.titleYearCell.offsetLeft + "px";
			this.selectYearDiv.style.top = poffset[1] + this.titleYearCell.offsetTop + this.titleYearCell.offsetHeight + "px";
		}
	}
//	if (ProWave.oldIE) {
		ProWave.hideMSCtl(this.selectYearDiv,this.calendarDiv);
//	}
}

/*** calendar ***/
com_tmax_prowave_PopupCalendar.prototype._weekNbr = function(n)
{
    // Algorithm used:
    // From Klaus Tondering's Calendar document (The Authority/Guru)
    // hhtp://www.tondering.dk/claus/calendar.html
    // a = (14-month) / 12
    // y = year + 4800 - a
    // m = month + 12a - 3
    // J = day + (153m + 2) / 5 + 365y + y / 4 - y / 100 + y / 400 - 32045
    // d4 = (J + 31741 - (J mod 7)) mod 146097 mod 36524 mod 1461
    // L = d4 / 1460
    // d1 = ((d4 - L) mod 365) + L
    // WeekNumber = d1 / 7 + 1

    year = n.getFullYear();
    month = n.getMonth() + 1;
    if (this.initData.startAt == 0)
        day = n.getDate() + 1;
    else
        day = n.getDate();

    a = Math.floor((14 - month) / 12);
    y = year + 4800 - a;
    m = month + 12 * a - 3;
    b = Math.floor(y / 4) - Math.floor(y / 100) + Math.floor(y / 400);
    J = day + Math.floor((153 * m + 2) / 5) + 365 * y + b - 32045;
    d4 = (((J + 31741 - (J % 7)) % 146097) % 36524) % 1461;
    L = Math.floor(d4 / 1460);
    d1 = ((d4 - L) % 365) + L;
    week = Math.floor(d1 / 7) + 1;

    return week;
}

com_tmax_prowave_PopupCalendar.prototype._appendCell = function(parentElement, value)
{
    var cell = document.createElement("td");
    cell.setAttribute("style", "text-align:right;");

    if (value && value != "")
    {
        cell.appendChild(document.createTextNode(value));
    }
    else
    {
        this._appendNbsp(cell);
    }

    parentElement.appendChild(cell);
}

com_tmax_prowave_PopupCalendar.prototype._getDateStyle = function(datePointer)
{
    var sStyle = this.initData.themePrefix + "-normal-day-style";
    //regular day

    if ((datePointer == this.dateNow) &&
        (this.selectedDate.month == this.monthNow) && (this.selectedDate.year == this.yearNow)) //today
    {
        sStyle = this.initData.themePrefix + "-current-day-style";
    }
    else if (dayPointer % 7 == (this.initData.startAt * -1) + 1) //end-of-the-week day
    {
        sStyle = this.initData.themePrefix + "-end-of-weekday-style";
    }

 	//selected day
	if ((datePointer == this.saveSelectedDate.date) &&
		(this.selectedDate.month == this.saveSelectedDate.month) &&
		(this.selectedDate.year == this.saveSelectedDate.year))
	{
		sStyle += " " + this.initData.themePrefix + "-selected-day-style";
	}
    for (k = 0; k < this.holidaysCounter; k++)
    {
        if ((parseInt(this._formatInt(this.holidays[k].d), 10) == datePointer) && (parseInt(this._formatInt(this.holidays[k].m), 10) == (this.selectedDate.month + 1)))
        {
            if ((parseInt(this._formatInt(this.holidays[k].y), 10) == 0) || ((parseInt(this._formatInt(this.holidays[k].y), 10) == this.selectedDate.year) && (parseInt(this._formatInt(this.holidays[k].y), 10) != 0)))
            {
                sStyle += " " + this.initData.themePrefix + "-holiday-style";
            }
        }
    }

    return sStyle;
}

com_tmax_prowave_PopupCalendar.prototype._getMonthStyle = function(monthPointer)
{
    var sStyle = this.initData.themePrefix + "-normal-day-style";
    //regular day

    if ((monthPointer == this.monthNow) && (this.selectedDate.year == this.yearNow)) //this month
    {
        sStyle = this.initData.themePrefix + "-current-day-style";
    }
    
    if ((monthPointer == this.saveSelectedDate.month)  &&
		(this.selectedDate.year == this.saveSelectedDate.year))
	{
		sStyle += " " + this.initData.themePrefix + "-selected-day-style";
	}
	
    return sStyle;
}

com_tmax_prowave_PopupCalendar.prototype._getYearStyle = function(yearPointer)
{
    var sStyle = this.initData.themePrefix + "-normal-day-style";
    //regular day

    if (yearPointer == this.yearNow) //this year
    {
        sStyle = this.initData.themePrefix + "-current-day-style";
    }
    
    if (yearPointer == this.saveSelectedDate.year)
	{
		sStyle += " " + this.initData.themePrefix + "-selected-day-style";
	}
	
    return sStyle;
}

com_tmax_prowave_PopupCalendar.prototype._getHolidayHint = function(datePointer)
{
    var sHint = "";
    for (k = 0; k < this.holidaysCounter; k++)
    {
        if ((parseInt(this._formatInt(this.holidays[k].d), 10) == datePointer) && (parseInt(this._formatInt(this.holidays[k].m), 10) == (this.selectedDate.month + 1)))
        {
            if ((parseInt(this._formatInt(this.holidays[k].y), 10) == 0) || ((parseInt(this._formatInt(this.holidays[k].y), 10) == this.selectedDate.year) && (parseInt(this._formatInt(this.holidays[k].y), 10) != 0)))
            {
                sHint += sHint == ""?this.holidays[k].desc:"\n" + this.holidays[k].desc;
            }
        }
    }

    return sHint;
}


com_tmax_prowave_PopupCalendar.prototype._constructCalendar = function()
{
    var aNumDays = Array(31, 0, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);

    var dateMessage;
    var startDate = new    Date (this.selectedDate.year, this.selectedDate.month, 1);
    var endDate;

    if (this.selectedDate.month == 1)
    {
        endDate = new Date (this.selectedDate.year, this.selectedDate.month + 1, 1);
        endDate = new Date (endDate - (24 * 60 * 60 * 1000));
        numDaysInMonth = endDate.getDate();
    }
    else
    {
		endDate = new Date (this.selectedDate.year, this.selectedDate.month, aNumDays[this.selectedDate.month]);
        numDaysInMonth = aNumDays[this.selectedDate.month];
    }

    datePointer = 0;
    dayPointer = startDate.getDay() - this.initData.startAt;

    if (dayPointer < 0)
        dayPointer = 6;

    this._removeAllChildren(this.contentCell);

    var contentTable = document.createElement("table");
    contentTable.setAttribute("style", "border:0px;")
    contentTable.className = this.initData.themePrefix + "-body-style";

    this.contentCell.appendChild(contentTable);

    var contentBody = document.createElement("tbody");
    contentTable.appendChild(contentBody);

	if (this.initData.selectType == "year") {
		var yearSet = 0;
		var offsetYear = this.yearNow - 7;
		if (this.selectedDate.yearSet == null) {
			if (this.selectedDate.year < offsetYear) {
				yearSet = parseInt((this.selectedDate.year - offsetYear + 1)/15)||0;
				yearSet--;
			} else {
				yearSet = parseInt((this.selectedDate.year - offsetYear)/15)||0;
			}
			this.selectedDate.yearSet = yearSet;
		} else {
			yearSet = this.selectedDate.yearSet;
		}
		var yearPointer = yearSet*15 + offsetYear;
		for (i=0; i<3; i++) {
			var currentRow = document.createElement("tr");
			contentBody.appendChild(currentRow);
			for (j=0;j<5;j++){
				var yearCell = document.createElement("td");
				currentRow.appendChild(yearCell);
				var sStyle = this._getYearStyle(yearPointer);
				var sSelectStyle = sStyle + " " + this.initData.themePrefix + "-would-be-selected-day-style";
				var sNormalStyle = sStyle;
				var sInvalidStyle = sStyle + " " + this.initData.themePrefix + "-invalid-day-style";
				var isInvalid = false;
				if (this.validMinDate) {
					if (this.validMinDate.getFullYear() > yearPointer) {
						isInvalid = true;
					} else {
						isInvalid = false;
					}
				}
				if (this.validMaxDate && !isInvalid) {
					if (this.validMaxDate.getFullYear() < yearPointer) {
						isInvalid = true;
					} else {
						isInvalid = false;
					}
				}

				if (!isInvalid) {
					var yearLink;
					yearLink = document.createElement("a");
					yearLink.setAttribute("href", "#");
					yearLink.className = sStyle;
					yearLink.sNormalStyle = sNormalStyle;
					yearLink.sSelectStyle = sSelectStyle;
					yearLink.yearPointer = yearPointer;
					yearCell.appendChild(yearLink);
					
					Event.observe(yearLink, "mousemove", function(event)
					{
						var elem = Event.element(event);
						window.status = this.initData.selectYearMessage;
					}.bindAsEventListener(this), false);
					Event.observe(yearLink, "mouseout", function(event)
					{
						var elem = Event.element(event);
						elem.className = elem.sNormalStyle;
						window.status = "";
					}.bindAsEventListener(this), false);
					Event.observe(yearLink, "click", function(event)
					{
						var elem = Event.element(event);
						this.selectedDate.year = elem.yearPointer;
						if (!this.initData.renderAsPopup) {
							this.saveSelectedDate.date = this.selectedDate.date;
							this.saveSelectedDate.month = this.selectedDate.month;
							this.saveSelectedDate.year = this.selectedDate.year;
							this._constructCalendar();
						}
						this._applyCalendarInput();
						this._closeCalendar();
						Event.stop(event);
					}.bindAsEventListener(this), false);
					Event.observe(yearLink, "mouseover", function(event)
					{
						var elem = Event.element(event);
						elem.className = elem.sSelectStyle;
					}.bindAsEventListener(this), false);
					
					this._appendNbsp(yearLink);
					yearLink.appendChild(document.createTextNode(yearPointer));
					this._appendNbsp(yearLink);
				} else {
					var yearLink;
					yearLink = document.createElement("span");
					yearLink.setAttribute("title", "");
					yearLink.className = sInvalidStyle;
					yearLink.yearPointer = yearPointer;
					yearCell.appendChild(yearLink);
					
					Event.observe(yearLink, "mousemove", function(event)
					{
						var elem = Event.element(event);
						window.status = this.initData.invalidMessage;
					}.bindAsEventListener(this), false);
					Event.observe(yearLink, "mouseout", function(event)
					{
						var elem = Event.element(event);
						window.status = "";
					}.bindAsEventListener(this), false);

					this._appendNbsp(yearLink);
					yearLink.appendChild(document.createTextNode(yearPointer));
					this._appendNbsp(yearLink);
				}
				yearPointer++;
			}
		}
		this._removeAllChildren(this.titleYearSetCell);
		this._appendNbsp(this.titleYearSetCell);
		this.titleYearSetCell.appendChild(document.createTextNode((yearPointer-15)+"~"+(yearPointer-1)));
		this._appendNbsp(this.titleYearSetCell);
	} else {
		if(this.initData.monthSelect){
			var monthPointer = 0;
			for( i=1; i<=2; i++){
				var currentRow = document.createElement("tr");
				contentBody.appendChild(currentRow);
				for (j = 1; j <= 6; j++){
					var monthCell = document.createElement("td");
					currentRow.appendChild(monthCell);
					var sStyle = this._getMonthStyle(monthPointer);
					var sSelectStyle = sStyle + " " + this.initData.themePrefix + "-would-be-selected-day-style";
					var sNormalStyle = sStyle;
					var sInvalidStyle = sStyle + " " + this.initData.themePrefix + "-invalid-day-style";

					var isInvalid = false;

					if (this.validMinDate) {
						if (this.validMinDate.getFullYear() == this.selectedDate.year) {
							if (this.validMinDate.getMonth() > monthPointer) {
								isInvalid = true;
							} else {
								isInvalid = false;
							}
						} else if (this.validMinDate.getFullYear() > this.selectedDate.year) {
							isInvalid = true;
						} else {
							isInvalid = false;
						}
					}
					if (this.validMaxDate && !isInvalid) {
						if (this.validMaxDate.getFullYear() == this.selectedDate.year) {
							if (this.validMaxDate.getMonth() < monthPointer) {
								isInvalid = true;
							} else {
								isInvalid = false;
							}
						} else if (this.validMaxDate.getFullYear() < this.selectedDate.year) {
							isInvalid = true;
						} else {
							isInvalid = false;
						}
					}

					if (!isInvalid) {
						var monthLink;
						monthLink = document.createElement("a");
						monthLink.setAttribute("href", "#");
						monthLink.className = sStyle;
						monthLink.sNormalStyle = sNormalStyle;
						monthLink.sSelectStyle = sSelectStyle;
						monthLink.monthPointer = monthPointer;
						monthCell.appendChild(monthLink);
						
						Event.observe(monthLink, "mousemove", function(event)
						{
							var elem = Event.element(event);
							window.status = this.initData.selectMonthMessage;
						}.bindAsEventListener(this), false);
						Event.observe(monthLink, "mouseout", function(event)
						{
							var elem = Event.element(event);
							elem.className = elem.sNormalStyle;
							window.status = "";
						}.bindAsEventListener(this), false);
						Event.observe(monthLink, "click", function(event)
						{
							var elem = Event.element(event);
							this.selectedDate.month = elem.monthPointer;
							if (!this.initData.renderAsPopup) {
								this.saveSelectedDate.date = this.selectedDate.date;
								this.saveSelectedDate.month = this.selectedDate.month;
								this.saveSelectedDate.year = this.selectedDate.year;
								this._constructCalendar();
							}
							this._applyCalendarInput();
							this._closeCalendar();
							Event.stop(event);
						}.bindAsEventListener(this), false);
						Event.observe(monthLink, "mouseover", function(event)
						{
							var elem = Event.element(event);
							elem.className = elem.sSelectStyle;
						}.bindAsEventListener(this), false);
						
						this._appendNbsp(monthLink);
						monthLink.appendChild(document.createTextNode(this.initData.monthName[monthPointer]));
						this._appendNbsp(monthLink);
					} else {
						var monthLink;
						monthLink = document.createElement("span");
						monthLink.setAttribute("title", "");
						monthLink.className = sInvalidStyle;
						monthLink.monthPointer = monthPointer;
						monthCell.appendChild(monthLink);
						
						Event.observe(monthLink, "mousemove", function(event)
						{
							var elem = Event.element(event);
							window.status = this.initData.invalidMessage;
						}.bindAsEventListener(this), false);
						Event.observe(monthLink, "mouseout", function(event)
						{
							var elem = Event.element(event);
							window.status = "";
						}.bindAsEventListener(this), false);

						this._appendNbsp(monthLink);
						monthLink.appendChild(document.createTextNode(this.initData.monthName[monthPointer]));
						this._appendNbsp(monthLink);
					}
					monthPointer++;
				 }
			  }
		}else{
			var contentRow = document.createElement("tr");
			contentBody.appendChild(contentRow);

			if (this.initData.showWeekNumber == 1)
			{
				var showWeekNumberCell = document.createElement("td");
				showWeekNumberCell.setAttribute("style", "width:27px;font-weight:bold;");
		
				contentRow.appendChild(showWeekNumberCell);
		
				showWeekNumberCell.appendChild(document.createTextNode(this.initData.weekString));
		
				var dividerCell = document.createElement("td");
				dividerCell.setAttribute("style", "width:1px;")
				dividerCell.setAttribute("rowSpan", "7");
				dividerCell.className = this.initData.themePrefix + "-weeknumber-div-style";
		
				contentRow.appendChild(dividerCell);
		
				var dividerImg = document.createElement("img");
				dividerImg.setAttribute("src", this.initData.imgDir + "divider.gif");
				dividerImg.setAttribute("style", "width:1px;");
				dividerCell.appendChild(dividerImg);
			}


			for (i = 0; i < 7; i++)
			{
				var dayNameCell = document.createElement("td");
				dayNameCell.className = this.initData.themePrefix + "-weekday-name-style";
				contentRow.appendChild(dayNameCell);
		
				dayNameCell.appendChild(document.createTextNode(this.initData.dayName[i]));
			}
		
			var currentRow = document.createElement("tr");
			contentBody.appendChild(currentRow);
		
			if (this.initData.showWeekNumber == 1)
			{
				this._appendCell(currentRow, this._weekNbr(startDate) + " ");
			}
		
			for (var i = 1; i <= dayPointer; i++)
			{
				this._appendCell(currentRow);
			}
		
			for (datePointer = 1; datePointer <= numDaysInMonth; datePointer++)
			{
				dayPointer++;
				var dateCell = document.createElement("td");
		
				currentRow.appendChild(dateCell);
		
				var sStyle = this._getDateStyle(datePointer);
				var sHint = this._getHolidayHint(datePointer);
		
				var sSelectStyle = sStyle + " " + this.initData.themePrefix + "-would-be-selected-day-style";
				var sNormalStyle = sStyle;
				var sInvalidStyle = sStyle + " " + this.initData.themePrefix + "-invalid-day-style";
		
				var isInvalid = false;
				if (this.validMinDate) {
					if (this.validMinDate.getTime() <= startDate.getTime()) {
						isInvalid = false;
					} else if (this.validMinDate.getTime() > endDate.getTime()) {
						isInvalid = true;
					} else if (this.validMinDate.getDate() > datePointer) {
						isInvalid = true;
					}
				}
				if (this.validMaxDate && !isInvalid) {
					if (this.validMaxDate.getTime() >= endDate.getTime()) {
						isInvalid = false;
					} else if (this.validMaxDate.getTime() < startDate.getTime()) {
						isInvalid = true;
					} else if (this.validMaxDate.getDate() < datePointer) {
						isInvalid = true;
					}
				}

				if (!isInvalid) {
					var dateLink;
					dateLink = document.createElement("a");
					dateLink.setAttribute("href", "#");
					dateLink.className = sStyle;
					dateLink.setAttribute("title", sHint);
					dateLink.sNormalStyle = sNormalStyle;
					dateLink.sSelectStyle = sSelectStyle;
					dateLink.datePointer = datePointer;
			
					dateCell.appendChild(dateLink);
			
					Event.observe(dateLink, "mousemove", function(event)
					{
						var elem = Event.element(event);
						window.status = this.initData.selectDateMessage.replace("[date]", this._constructDate(elem.datePointer, this.selectedDate.month, this.selectedDate.year));
					}.bindAsEventListener(this), false);
					Event.observe(dateLink, "mouseout", function(event)
					{
						var elem = Event.element(event);
						elem.className = elem.sNormalStyle;
						window.status = "";
					}.bindAsEventListener(this), false);
					Event.observe(dateLink, "click", function(event)
					{
						var elem = Event.element(event);
						this.selectedDate.date = elem.datePointer;
						if (!this.initData.renderAsPopup || this.initData.selectType == "datetime") {
							this.saveSelectedDate.date = this.selectedDate.date;
							this.saveSelectedDate.month = this.selectedDate.month;
							this.saveSelectedDate.year = this.selectedDate.year;
							
							if (this.initData.selectType == "datetime") {
								this._setSelectedTime();
							}
							this._constructCalendar();
						}
						
						if(!this.initData.renderAsPopup || this.initData.selectType != "datetime")
							this._applyCalendarInput();
						
						if (this.initData.selectType != "datetime") 
							this._closeCalendar();
						
						Event.stop(event);
					}.bindAsEventListener(this), false);
					Event.observe(dateLink, "mouseover", function(event)
					{
						var elem = Event.element(event);
						elem.className = elem.sSelectStyle;
					}.bindAsEventListener(this), false);
					this._appendNbsp(dateLink);
			  
					dateLink.appendChild(document.createTextNode(datePointer));
					this._appendNbsp(dateLink);

				} else {
					var dateLink;
					dateLink = document.createElement("span");
					dateLink.className = sInvalidStyle;
					dateLink.setAttribute("title", sHint);
					dateLink.datePointer = datePointer;
					dateCell.appendChild(dateLink);

					Event.observe(dateLink, "mousemove", function(event)
					{
						var elem = Event.element(event);
						window.status = this.initData.invalidMessage;
					}.bindAsEventListener(this), false);
					this._appendNbsp(dateLink);
					Event.observe(dateLink, "mouseout", function(event)
					{
						var elem = Event.element(event);
						window.status = "";
					}.bindAsEventListener(this), false);

					dateLink.appendChild(document.createTextNode(datePointer));
					this._appendNbsp(dateLink);
				}

				if ((dayPointer + this.initData.startAt) % 7 == this.initData.startAt)
				{
					currentRow = document.createElement("tr");
					contentBody.appendChild(currentRow);
		
					if ((this.initData.showWeekNumber == 1) && (datePointer < numDaysInMonth))
					{
						this._appendCell(currentRow, this._weekNbr(new Date(this.selectedDate.year, this.selectedDate.month, datePointer + 1)) + " ");
					}
		
				}
			}
		}
		this._removeAllChildren(this.titleMonthCell);

		if(!this.initData.monthSelect){
			this._appendNbsp(this.titleMonthCell);
			this.titleMonthCell.appendChild(document.createTextNode(this.initData.monthName[this.selectedDate.month]));
			this._appendNbsp(this.titleMonthCell);
			this.changeMonthImg = document.createElement("img");
			this.changeMonthImg.setAttribute("src", this.initData.imgDir + "drop1.gif");
			this.changeMonthImg.className = this.initData.themePrefix + "-drop-button-style";
			this.titleMonthCell.appendChild(this.changeMonthImg);
		
		}
		
		this._removeAllChildren(this.titleYearCell);

		this._appendNbsp(this.titleYearCell);
		this.titleYearCell.appendChild(document.createTextNode(this.selectedDate.year));
		this._appendNbsp(this.titleYearCell);

		this.changeYearImg = document.createElement("img");
		this.changeYearImg.setAttribute("src", this.initData.imgDir + "drop1.gif");
		this.changeYearImg.className = this.initData.themePrefix + "-drop-button-style";

		this.titleYearCell.appendChild(this.changeYearImg);
	}

	if(this.initData.renderAsPopup){
		this._removeAllChildren(this.closeCalendarSpan);
	    var closeButtonImg = document.createElement("img");
	    closeButtonImg.setAttribute("src", this.initData.imgDir + "close.gif");
	    closeButtonImg.setAttribute("alt", "Close the calendar");
		closeButtonImg.className = this.initData.themePrefix + "-close-button-style";
	    this.closeCalendarSpan.appendChild(closeButtonImg);
	}
}

com_tmax_prowave_PopupCalendar.prototype._popUpCalendar = function(ctl, ctl2, format)
{
    if (this.bPageLoaded)
    {
        if (this.calendarDiv.style.display == "none")
        {
            this.ctlToPlaceValue = ctl2;
            this.dateFormat = format;

            var simpleDateFormat = new com_tmax_prowave_SimpleDateFormat(this.dateFormat, this.dateFormatSymbols);
            var dateSelected = simpleDateFormat.parse(ctl2.value);
            if (dateSelected)
            {
                this.selectedDate.sec = dateSelected.getSeconds();
                this.selectedDate.min = dateSelected.getMinutes();
                this.selectedDate.hour = dateSelected.getHours();
                this.selectedDate.date = dateSelected.getDate();
                this.selectedDate.month = dateSelected.getMonth();

                var yearStr = dateSelected.getYear() + "";

                if (yearStr.length < 4)
                {
                    yearStr = (parseInt(yearStr, 10) + 1900) + "";
                }

                this.selectedDate.year = parseInt(yearStr, 10);
            }
            else
            {
                this.selectedDate.date = this.dateNow;
                this.selectedDate.month = this.monthNow;
                this.selectedDate.year = this.yearNow;
            }

            this._popUpCalendar_Show(ctl);
        }
        else
        {
          	this.calendarDiv._hideCalendar();
            if (this.ctlNow != ctl)
                this._popUpCalendar(ctl, ctl2, format);
        }
        this.ctlNow = ctl;
    }
}

com_tmax_prowave_PopupCalendar.prototype._popUpCalendarForInputDate = function(clientId, format)
{
    if (this.bPageLoaded)
    {
        this.myFacesCtlType = "x:inputDate";
        this.myFacesInputDateClientId = clientId;
        this.dateFormat = format;

        this.selectedDate.date = document.getElementById(clientId + ".day").value != "" ? parseInt(this._formatInt(document.getElementById(clientId + ".day").value), 10) : this.dateNow;
        this.selectedDate.month = document.getElementById(clientId + ".month").value != "-1" ? parseInt(this._formatInt(document.getElementById(clientId + ".month").value), 10) - 1 : this.monthNow;
        this.selectedDate.year = document.getElementById(clientId + ".year").value != "" ? parseInt(this._formatInt(document.getElementById(clientId + ".year").value), 10) : this.yearNow;
        this.ctlNow = document.getElementById(clientId + ".day");
        this._popUpCalendar_Show(document.getElementById(clientId + ".day"));
    }
}

com_tmax_prowave_PopupCalendar.prototype._popUpCalendar_Show = function(ctl)
{
    this.saveSelectedDate.date = this.selectedDate.date;
    this.saveSelectedDate.month = this.selectedDate.month;
    this.saveSelectedDate.year = this.selectedDate.year;
    this.saveSelectedDate.hour = this.selectedDate.hour;
    this.saveSelectedDate.min = this.selectedDate.min;
    this.saveSelectedDate.sec = this.selectedDate.sec;    
	this._constructCalendar(1, this.selectedDate.month, this.selectedDate.year);
	this._calcCalendarPosition(ctl);
	this.calendarDiv.bClickOnCalendar = true;
}

com_tmax_prowave_PopupCalendar.prototype._calcCalendarPosition = function(ctl) {
	this.calendarDiv.style.display = "block";

	if (this.initData.renderAsPopup) {
		pwInputCalendar.addPopupCalendar(this.calendarDiv);
		this.calendarDiv.clonePosition(ctl,{setWidth:false,setHeight:false,offsetTop:(ctl.offsetHeight+2)});
		var left = parseInt(this.calendarDiv.style.left);
		var top = parseInt(this.calendarDiv.style.top);
		if (this.ie) { // 2009/01/07: modified by kyungil (Element scroll이 있는 경우 IE보정 [ims-35705])
			Position.prepare();
			var offsets = Position.realOffset(ctl);
			left += offsets[0]-Position.deltaX;
			top += offsets[1]-Position.deltaY;
		//alert(offsets[0]+","+offsets[1]+","+Position.deltaX+","+Position.deltaY+","+left+","+top+","+ctl.offsetHeight);
		}
		var bodyRect = ProWave.getVisibleRect();
		// recalc position
		if(this.initData.popupLeft)
		{
			left-=this.calendarDiv.offsetWidth;
		}
		if (left + this.calendarDiv.offsetWidth > bodyRect.right)
		{
			left = bodyRect.right - this.calendarDiv.offsetWidth;
		}
		if (top + this.calendarDiv.offsetHeight > bodyRect.bottom)
		{
			top = bodyRect.bottom - this.calendarDiv.offsetHeight;
		}
		if (left < bodyRect.left)
		{
			left = bodyRect.left;
		}
		if (top < bodyRect.top)
		{
			top = bodyRect.top;
		}

		this.calendarDiv.style.left = this.initData.fixedX == -1 ? left + "px": this.initData.fixedX;
		this.calendarDiv.style.top = this.initData.fixedY == -1 ? top + "px": this.initData.fixedY;
		this.calendarDiv.style.visibility = (this.dom || this.ie)? "visible" : "show"; //예전 css때문
//		if (ProWave.oldIE) {
			ProWave.hideMSCtl(this.calendarDiv,pwInputCalendar.ctl,true);
//		}
	} else {
		this.calendarDiv.clonePosition(ctl,{setWidth:false,setHeight:false,offsetTop:(ctl.offsetHeight+2)});
		var left = parseInt(this.calendarDiv.style.left);
		var top = parseInt(this.calendarDiv.style.top);
		this.calendarDiv.style.left = this.initData.fixedX == -1 ? left + "px": this.initData.fixedX;
		this.calendarDiv.style.top = this.initData.fixedY == -1 ? top + "px": this.initData.fixedY;
		this.calendarDiv.style.visibility = (this.dom || this.ie)? "visible" : "show"; //예전 css때문
	}
}

com_tmax_prowave_PopupCalendar.prototype._formatInt = function(str)
{

    if (typeof str == 'string')
    {

        //truncate 0 for number less than 10
        if (str.charAt && str.charAt(0) == "0")
        { // <----- Change, added str.charAt for method availability detection (MYFACES)
            return str.charAt(1);
        }

    }
    return str;

}
com_tmax_prowave_PopupCalendar.prototype._setSelectedTime = function(){
	this.selectedDate.hour =  $(this.containerCtl.id + '_hour_input').value;
	if($(this.containerCtl.id + '_ampm_input').value==this.dateFormatSymbols.ampms[1])
		this.selectedDate.hour = this.selectedDate.hour*1+12;
	this.selectedDate.min =  $(this.containerCtl.id + '_minute_input').value;
	this.selectedDate.sec =  $(this.containerCtl.id + '_second_input').value;
}								

com_tmax_prowave_PopupCalendar.prototype._createCalendarSpinner = function(calendarId, type){
	var spinnerTypeClass =  this.initData.themePrefix+"-spin-decimal";
		if(type == "ampm")
		spinnerTypeClass =  this.initData.themePrefix+"-spin-ampm";
	return "<div class='"+ this.initData.themePrefix+"-spin-outline'><table cellspacing='0' cellpadding='0' border='0'><tbody><tr><td rowspan='2'><input type='text' class='"+spinnerTypeClass+"' maxlength='2' id='"+calendarId+"_input'/></td><td><a id='"+calendarId+"_spinner_up' href='javascript:;' class='"+ this.initData.themePrefix +"-spin-up'/></td></tr><tr><td><a id='"+calendarId+"_spinner_down' href='javascript:;' class='"+ this.initData.themePrefix +"-spin-dn'/></td></tr></tbody></table></div>";
}
