﻿	var tab_lg = new Array();
	 
	
	
	var SelectDate = function (id_os,deb_ou_fin,nom_var){
	    this._id_os = id_os;
	    this._div = "calendar_"+deb_ou_fin+"_"+id_os;
	    this._tb = "tb_"+deb_ou_fin+"_"+id_os;
	    this._over_cal = false;
	    this._calendar_sup = null;//calendar dont la date doti tjr etre > a this.getdate()
	    this._nom = nom_var;
	    this.init();
	    
	    //this.cal1.cfg.configMinDate();
	}
	
	SelectDate.prototype.init = function() { 
	
	
	    this.cal1 = new YAHOO.widget.Calendar(this._nom+".cal1",this._div); 
	    
	    if(langue == 'FR'){
	        this.cal1.cfg.setProperty('MONTHS_SHORT',['jan', 'fév', 'mar', 'avr', 'mai', 'jun', 'jui', 'aoû', 'sep', 'oct', 'nov', 'déc']);
	        this.cal1.cfg.setProperty('MONTHS_LONG',['janvier', 'février', 'mars', 'avril', 'mai', 'juin', 'juillet', 'août', 'septembre', 'octobre', 'novembre', 'décembre']);
	        this.cal1.cfg.setProperty('WEEKDAYS_1CHAR',["D","L", "M", "M", "J", "V", "S"]);
	        this.cal1.cfg.setProperty('WEEKDAYS_SHORT',["Di","Lu", "Ma", "Me", "Je", "Ve", "Sa"]);
	        this.cal1.cfg.setProperty('WEEKDAYS_MEDIUM',['dim', 'lun', 'mar', 'mer', 'jeu', 'ven', 'sam']);
	        this.cal1.cfg.setProperty('WEEKDAYS_LONG',['dimanche', 'lundi', 'mardi', 'mercredi', 'jeudi', 'vendredi', 'samedi']);	    
	        this.cal1.cfg.setProperty('START_WEEKDAY',1);	    
	     }
	     this.cal1.cfg.setProperty('PAGES',1);
	     this.cal1.cfg.setProperty('mindate',new Date());
	    this.cal1.selectEvent.subscribe(getDate, this,true); 
	    this.cal1.renderEvent.subscribe(setupListeners, this, true); 
	    YAHOO.util.Event.addListener(this._tb, 'focus', showCal,this); 
	    YAHOO.util.Event.addListener(this._tb, 'blur', hideCal,this); 
	    YAHOO.util.Event.addListener(this._div, 'blur', hideCal,this); 
        this.cal1.render();         
        hideCal("blur",this);
	} 
	 
	function setupListeners() { 
	    YAHOO.util.Event.addListener(this._div, 'mouseover', overCal,this); 
	    YAHOO.util.Event.addListener(this._div, 'mouseout', outCal,this); 
	} 
	 
	function getDate() { 
        var calDate = this.cal1.getSelectedDates()[0]; 
        if(this._calendar_sup){
            this._calendar_sup.cal1.cfg.setProperty('mindate',calDate);
            var date = this._calendar_sup.cal1.getSelectedDates()[0];
            if(!date)
                date = new Date(calDate);
            if(date <= calDate){
                date = new Date(calDate.getFullYear(),calDate.getMonth(),calDate.getDay() + 1);
                this._calendar_sup.cal1.select(date);
            }
        }
	        calDate = calDate.print("d/m/Y"); 
	        YAHOO.util.Dom.get(this._tb).value = calDate; 
	        this._over_cal = false; 
        hideCal("blur",this); 
	} 
	 
	function showCal(event,sd) { 
        var xy = YAHOO.util.Dom.getXY(sd._tb); 
	    var date = YAHOO.util.Dom.get(sd._tb).value; 
	    if (date) { 
	        var date_info = date.split('/');
	        var date_obj = new Date(date_info[2],parseInt(date_info[1]) - 1,date_info[0]);
	        sd.cal1.select(date_obj); 
	        sd.cal1.setMonth(parseInt(date_info[1])-1);
	        sd.cal1.setYear(date_info[2]);
          //  sd.cal1.cfg.setProperty('pagedate', new Date(date_obj), true); 
	        
	    } 
	    sd.cal1.render(); 
	    YAHOO.util.Dom.setStyle(sd._div, 'display', 'block'); 
	    xy[1] = xy[1] + 20; 
	    YAHOO.util.Dom.setXY(sd._div, xy); 
    } 
    
    
 
	function hideCal (event,sd) { 
	    if (!sd._over_cal) { 
	        YAHOO.util.Dom.setStyle(sd._div, 'display', 'none'); 
	    } 
} 
	 
	function overCal(event,sd) { 
	    sd._over_cal = true; 
} 
	 
	function outCal(event,sd) { 
    sd._over_cal = false; 
	} 
