var x=0;
var y=0;
var ondiv = [];


//Recup de la position du curseur
function position (e) {
	 e = e || window.event;
  	 x = e.clientX;
  	 y = e.clientY;
}//position

function afficheAgenda(day){
	
	var positionBody = FindPos(document.body);
	document.getElementById('info_'+day).style.left= x - positionBody['X'];
	document.getElementById('info_'+day).style.top= y - positionBody['Y'];

	//Changement du style de la td 
	document.getElementById('td_'+day).className='hover';
	
	//affichage de la div d'info
	document.getElementById('info_'+day).style.visibility='visible';
	
	//Gestion del'affichage de la div sur la largeur
	//Recup de la largeur de la div
	var divWidth = document.getElementById('info_'+day).offsetWidth ;
	
	//Recup de la largeur de la fenetre
	var windowWidth;
	 if (typeof(window.innerWidth) == 'number') { // Netscape
       windowWidth= window.innerWidth;
    } else if (document.documentElement && document.documentElement.clientWidth) {
        windowWidth = document.documentElement.clientWidth;
    } 
	
	
	if(windowWidth < (x + divWidth)){
		document.getElementById('info_'+day).style.marginLeft='-'+divWidth+'px';
	}//if
	
	//Gestion del'affichage de la div sur la hauteur
	//Recup de la largeur de la div
	var divHeight = document.getElementById('info_'+day).offsetHeight ;
	
	//Recup de la largeur de la fenetre
	var windowHeight;
	if (typeof(window.innerHeight) == 'number') { // Netscape
       windowHeight= window.innerHeight;
    } else if (document.documentElement && document.documentElement.clientHeight) {
        windowHeight = document.documentElement.clientHeight;
    } 
	
	if(windowHeight < y + divHeight){
		document.getElementById('info_'+day).style.marginTop='-'+divHeight+'px';
	}//if

	
}//afficheAgenda

function FindPos(AObject)
{
    var posX = 0, posY = 0;
    
    do
    {
        posX += AObject.offsetLeft;
        posY += AObject.offsetTop;
        AObject = AObject.offsetParent;
    }
    while( AObject != null );

    var pos = [];
    pos['X'] = posX;
    pos['Y'] = posY;
    
    return pos;
}

function chgStyleTD(day){
//Changement du style de la td 
	document.getElementById('td_'+day).className='dayon';
}


function cacheAgenda(day){

	if(!ondiv[day]){
		//On cache la div
		document.getElementById('info_'+day).style.visibility='hidden';
	}//if
}//cacheAgenda


function onDiv(day){
ondiv[day]=true;
}

function offDiv(day){
ondiv[day]=false;
}