// CONSTRUCTOR for the CalendarPopup Object
function CalendarPopup_pP() {
	var c;
	if (arguments.length>0) {
		c = new PopupWindow(arguments[0]);
		}
	else {
		c = new PopupWindow();
		c.setSize(150,175);
		}
	c.offsetX = -152;
	c.offsetY = 25;
	c.autoHide();
	// Calendar-specific properties
	c.monthNames = new Array("Janvier","Février","Mars","Avril","Mai","Juin","Juillet","Août","Septembre","Octobre","Novembre","Décembre");
	c.monthAbbreviations = new Array("Jan","Féb","Mar","Avr","Mai","Jui","Jui","Aoû","Sep","Oct","Nov","Déc");
	c.dayHeaders = new Array("D","L","M","M","J","V","S");
	c.returnFunction = "CP_tmpReturnFunction_pP";
	c.returnMonthFunction = "CP_tmpReturnMonthFunction";
	c.returnQuarterFunction = "CP_tmpReturnQuarterFunction";
	c.returnYearFunction = "CP_tmpReturnYearFunction";
	c.weekStartDay = 1;
	c.isShowYearNavigation = false;
	c.displayType = "date";
	c.disabledWeekDays = new Object();
	c.disabledDatesExpression = "";
	c.yearSelectStartOffset = 2;
	c.currentDate = null;
//	c.todayText="Aujourd'hui";
	c.todayText="";
	c.cssPrefix="";
	c.isShowNavigationDropdowns=false;
	c.isShowYearNavigationInput=false;

  
	window.CP_calendarObject = null;
	window.CP_targetInput = null;
	window.CP_targetInputVisible = null;
	window.CP_dateFormat = "dd/MM/yyyy";
	window.CP_dateFormatVisible = "EE dd/MM/yyyy";	

   
	c.copyMonthNamesToWindow = CP_copyMonthNamesToWindow;
	c.setReturnFunction = CP_setReturnFunction;
	c.setReturnMonthFunction = CP_setReturnMonthFunction;
	c.setReturnQuarterFunction = CP_setReturnQuarterFunction;
	c.setReturnYearFunction = CP_setReturnYearFunction;
	c.setMonthNames = CP_setMonthNames;
	c.setMonthAbbreviations = CP_setMonthAbbreviations;
	c.setDayHeaders = CP_setDayHeaders;
	c.setWeekStartDay = CP_setWeekStartDay;
	c.setDisplayType = CP_setDisplayType;
	c.setDisabledWeekDays = CP_setDisabledWeekDays;
	c.addDisabledDates = CP_addDisabledDates;
	c.addBankHolyday = CP_addBankHolyday;
	c.setYearSelectStartOffset = CP_setYearSelectStartOffset;
	c.setTodayText = CP_setTodayText;
	c.showYearNavigation = CP_showYearNavigation;
	c.showCalendar = CP_showCalendar;
	c.hideCalendar = CP_hideCalendar;
	c.getStyles = getCalendarStyles;
	c.refreshCalendar = CP_refreshCalendar;
	c.getCalendar = CP_getCalendar;
	c.select = CP_select_pP;
	c.setCssPrefix = CP_setCssPrefix;
	c.showNavigationDropdowns = CP_showNavigationDropdowns;
	c.showYearNavigationInput = CP_showYearNavigationInput;
	c.copyMonthNamesToWindow();
	// Return the object
	return c;
	}



// Temporary default functions to be called when items clicked, so no error is thrown
function CP_tmpReturnFunction_pP(y,m,d) {
 
    if (window.CP_targetInput!=null) {
        var dt = new Date(y,m-1,d,0,0,0);
        if (window.CP_calendarObject!=null) { window.CP_calendarObject.copyMonthNamesToWindow(); }


        if (y==0 && m == 0 && d== 0 )
        {              
        window.CP_targetInput.value = '';
        window.CP_targetInputVisible.value ='';

        }
        else
        {
        window.CP_targetInput.value = formatDate(dt,window.CP_dateFormat);
        window.CP_targetInputVisible.value = formatDate(dt,window.CP_dateFormatVisible);        
        }

        nombrePixelDate(window.CP_targetInputVisible) ;

    }
    else 
    {
	    alert('Use setReturnFunction() to define which function will get the clicked results!'); 
	}
}


// Simple method to interface popup calendar with a text-entry box

function CP_select_pP(inputobj,inputobjVisible, linkname, format,formatVisible) {

	var selectedDate=(arguments.length>5)?arguments[5]:null;
	if (!window.getDateFromFormat) {
		alert("calendar.select: To use this method you must also include 'date.js' for date formatting");
		return;
		}
	if (this.displayType!="date"&&this.displayType!="week-end") {
		alert("calendar.select: This function can only be used with displayType 'date' or 'week-end'");
		return;
		}
	if (inputobj.type!="text" && inputobj.type!="hidden" && inputobj.type!="textarea") { 
		alert("calendar.select: Input object passed is not a valid form input object"); 
		window.CP_targetInput=null;
		return;
		}
	if (inputobj.disabled) { return; } // Can't use calendar input on disabled form input!
  
	window.CP_targetInput = inputobj;
	

	window.CP_targetInputVisible = inputobjVisible;	
	
	window.CP_calendarObject = this;
	this.currentDate=null;
	var time=0;
	if (selectedDate!=null) {
		time = getDateFromFormat(selectedDate,format)
		}
	else if (inputobj.value!="") {
		time = getDateFromFormat(inputobj.value,format);
		}
	if (selectedDate!=null || inputobj.value!="") {
		if (time==0) { this.currentDate=null; }
		else { this.currentDate=new Date(time); }
		}
	window.CP_dateFormat = format;
	
	window.CP_dateFormatVisible = formatVisible;	
	
	this.showCalendar(linkname);

}