var OQP = false;
var Hauteur_Objet;
var Hauteur_Sens;
var Hauteur_Final;

var Timer_ID;
var Timer_Vitesse = "10";

var Alpha_Objet;
var Alpha_Sens;
var Alpha_Final;
var Alpha_Valeur;

var Top_Objet;
var Top_Sens;
var Top_Final;

var k = 0.1;
var f = 0.5;
var vx = 0;

function Box_Recherche_Langue_Afficher()
{
	if (OQP == true) { return false; }
	
	OQP = true;
	
	Hauteur_Max = 50;
	
	//Ajuste la div
	divLeft = parseInt((document.body.clientWidth - 960) / 2);
	divLeft += 723; //Bandeau
	divLeft += 28;	
	document.getElementById('divBox_Rechercher_Langue').style.left = divLeft;
	
	
	if (parseInt(Hauteur_Max) != parseInt(document.getElementById('divBox_Rechercher_Langue').style.height))
	{
		//Ouvre la boite
		document.getElementById('divBox_Rechercher_Langue').style.visibility = 'visible';
		Afficher('divBox_Rechercher_Langue','tabBox_Rechercher_Langue', 0, Hauteur_Max, 'Box_Recherche_Langue_Afficher');
	} else {
		//Masque
		Masquer('divBox_Rechercher_Langue','tabBox_Rechercher_Langue', 0, Hauteur_Max, 'Box_Recherche_Langue_Masquer');
	}
}

function Box_Login_Init()
{
	//Ajuste la div
	divLeft = parseInt((document.body.clientWidth - 960) / 2);
	divLeft += 404;
	document.getElementById('divBox_Login').style.left = divLeft;	
	document.getElementById('divBox_Login').style.top = '-47px';
}

function Box_Login_Afficher()
{
	if (OQP == true) { return false; }
	
	OQP = true;
	
	Top_Min = -47;
	Top_Max = 0;
	
	if (parseInt(Top_Max) != parseInt(document.getElementById('divBox_Login').style.top))
	{
		//Ouvre la boite
		Top_Objet = document.getElementById('divBox_Login');
		Top_Final = Top_Max;
		Top_Sens = 1;		
	} else {
		//Ferme la boite
		Top_Objet = document.getElementById('divBox_Login');
		Top_Final = Top_Min;
		Top_Sens = -1;		
	}
	
	setTop('');
}

function Afficher(Container_ID, Content_ID, Hauteur_Min, Hauteur_Max, Action)
{
	//Masque le contenu
	document.getElementById(Content_ID).style.display = 'none';
		
	//Prépare la mise à la hauteur du container
	Hauteur_Objet = document.getElementById(Container_ID);
	Hauteur_Final = Hauteur_Max;

	if (Hauteur_Final > parseInt(Number(document.getElementById(Container_ID).style.height.split("px")[0])))
	{
		Hauteur_Sens = 1;
	} else {
		Hauteur_Sens = -1;
	}
		
	//Prépare l'affichage du content
	Alpha_Objet = document.getElementById(Content_ID);
	Alpha_Sens = 1;
	Alpha_Final = 100;
	Alpha_Valeur = 0;

	//Redimensionne le container
	setHauteur(Action);
}

function Masquer(Container_ID, Content_ID, Hauteur_Min, Hauteur_Max, Action)
{
	//Masque la boite

	//Fait un Alpha sur le container
	Alpha_Objet = document.getElementById(Container_ID);
	Alpha_Sens = -1;
	Alpha_Final = 0;
	Alpha_Valeur = 100;
		
	Hauteur_Final = Hauteur_Min;
		
	//Redimensionne le container
	setAlpha(Action);	
}

function Masquer_Terminer()
{
	//Masque le container 
	Alpha_Objet.style.visibility = 'hidden';

	//Mets le container à la hauteur initiale
	Alpha_Objet.style.height = Hauteur_Final + "px";
	
	//Mets le Alpha normal su le box
	Alpha(Alpha_Objet,100);

	OQP = false;
}

function setHauteur(Action)
{

	Objet_Height = parseInt(Number(Hauteur_Objet.style.height.split("px")[0]));
	Continuer = true;
	
	if (Hauteur_Sens == 1)
	{
		if (parseInt(Hauteur_Final) <= Objet_Height)
		{
			Continuer = false;
		}
	} else {
		if (parseInt(Hauteur_Final) >= Objet_Height)
		{
			Continuer = false;
		}
	}

	if (Continuer == true)
	{				
		ax = k*(Hauteur_Final - Objet_Height);
		vx += ax;
		vx *= f;

		Hauteur_Objet.style.height = parseInt(Objet_Height + vx + Hauteur_Sens) + "px";
		Timer_ID = setTimeout("setHauteur('" + Action + "')", Timer_Vitesse);
	} else {
		setHauteur_Terminer(Action);
	}
}

function setHauteur_Terminer(Action)
{
	Hauteur_Objet.style.height = Hauteur_Final + "px";
	clearTimeout(Timer_ID);
	
	if (Action == 'Box_Recherche_Langue_Afficher')
	{
		//Initialise le alpha de départ
		Alpha(Alpha_Objet, Alpha_Valeur);
			
		//Affiche l'objet sur lequel on va faire l'alpha
		Alpha_Objet.style.display = '';
		
		//Lance le alpha
		setAlpha(Action);
	} else if (Action == 'SetReservation_Accueil') {
		//Prépare l'affichage du content
		Alpha_Objet = document.getElementById(curDiv_ID);
		Alpha_Sens = 1;
		Alpha_Final = 100;
		Alpha_Valeur = 0;
		
		//Initialise le alpha de départ
		Alpha(Alpha_Objet, Alpha_Valeur);

		//Affiche l'objet sur lequel on va faire l'alpha
		Alpha_Objet.style.display = '';
		Alpha_Objet.style.visibility = 'visible';

		//Initialise le alpha de départ
		Alpha(Alpha_Objet, Alpha_Valeur);

		//Lance le alpha
		setAlpha('SetReservation_Accueil_Fin');
	} else  {
		OQP = false;	
	}
}

function Alpha(Objet, Valeur)
{
	Objet_Style = Objet.style;
    Objet_Style.opacity = (Valeur / 100);
    Objet_Style.MozOpacity = (Valeur / 100);
    Objet_Style.KhtmlOpacity = (Valeur / 100);
    Objet_Style.filter = "alpha(opacity=" + Valeur + ")";

}

function setAlpha(Action)
{
	Alpha_Valeur += 5 * Alpha_Sens;
	Alpha(Alpha_Objet, Alpha_Valeur);

	if (parseInt(Alpha_Valeur) != parseInt(Alpha_Final))
	{				
		Timer_ID = setTimeout("setAlpha('" + Action + "')", Timer_Vitesse);
	} else {
		setAlpha_Terminer(Action);	
	}
}

function setAlpha_Terminer(Action)
{
	Alpha(Alpha_Objet, Alpha_Final);
	clearTimeout(Timer_ID);

	if (Action == 'Box_Recherche_Langue_Afficher')
	{
		OQP = false;
	} else if (Action == 'Box_Recherche_Langue_Masquer') {
		Masquer_Terminer();
	} else if (Action == 'SetReservation_Accueil') {		
		//Cache complètement la div précédente
		document.getElementById(curDiv_ID).style.visibility = 'hidden';
		document.getElementById(curDiv_ID).style.display = 'none';
				
		//Mémorise le nouveau div
		curDiv_ID = 'Reservation_' + curSport_ID;
		
		if (curCours_Age_ID != -1)
		{
			curDiv_ID += '_'+ curCours_Age_ID;
		}

		if (curCours_Type_ID != -1)
		{
			curDiv_ID += '_'+ curCours_Type_ID;
		}
		
		if (curCours_Collectif_Niveau_ID != -1)
		{
			curDiv_ID = 'Reservation_' + curCours_Type_ID + '_Calendrier';
		}
		
		if (curCours_Particulier_Duree_ID != -1)
		{
			curDiv_ID = 'Reservation_' + curCours_Type_ID + '_Calendrier';
		}
				
		//Prépare la mise à la hauteur du container
		Hauteur_Objet = document.getElementById('Reservation_Box');
		Hauteur_Final =  parseInt(Number(document.getElementById(curDiv_ID).style.height.split("px")[0]));
	
		if (Hauteur_Final > parseInt(Number(Hauteur_Objet.style.height.split("px")[0])))
		{
			Hauteur_Sens = 1;
		} else {
			Hauteur_Sens = -1;
		}
			
		//Redimensionne le container
		setHauteur(Action);
	} else if (Action == 'SetReservation_Accueil_Fin') {
		OQP = false;
	} else {
		OQP = false;	
	}
}

function setTop(Action)
{

	Objet_Top = parseInt(Number(Top_Objet.style.top.split("px")[0]));

	if (parseInt(Top_Final) != Objet_Top)
	{				
		ax = k*(Top_Final - Objet_Top);
		vx += ax;
		vx *= f;

		Top_Objet.style.top = parseInt(Objet_Top + vx + Top_Sens) + "px";
		Timer_ID = setTimeout("setTop('" + Action + "')", Timer_Vitesse);
	} else {
		setTop_Terminer(Action);
	}
}

function setTop_Terminer(Action)
{
	Top_Objet.style.top = Top_Final + "px";
	clearTimeout(Timer_ID);
	
	if (Action == 'xxx')
	{
		//RAS
	} else  {
		OQP = false;	
	}
}


function RollOver(Objet_ID, Image_Src)
{
	 document.getElementById(Objet_ID).src = Image_Src;
}

function Popup(Page, Width, Height)
{
   window.open(Page, '', 'scrollbars=yes,menubar=no,toolbar=no,resizable=no,width=' + Width + ',height=' + Height);
}


this.document.write('<div id="objPopup_Fond" style="display:none;"><table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">');
this.document.write('        <tr>');
this.document.write('          <td align="center" valign="middle">&nbsp;</td>');
this.document.write('        </tr>');
this.document.write('      </table></div><iframe src="vide.html" frameborder="0" height="100%" hspace="0" id="objPopup_Content" marginheight="0" marginwidth="0" name="objPopup_Content" scrolling="no" vspace="0" width="100%"></iframe>');

function Under_Popup(Page, Width, Height)
{
	Under_Show_Fond();

	document.getElementById('objPopup_Content').src = Page;
	document.getElementById('objPopup_Content').style.left = (document.body.scrollWidth - Width) / 2;
	document.getElementById('objPopup_Content').style.top = document.body.scrollTop + (document.body.clientHeight - Height) / 2;
	document.getElementById('objPopup_Content').style.width = Width;
	document.getElementById('objPopup_Content').style.height = Height;
	document.getElementById('objPopup_Content').style.display = 'inline';
}

function Under_Show_Fond()
{
	Alpha(document.getElementById('objPopup_Fond'),0);
			
	document.getElementById('objPopup_Fond').style.left = 0;
	document.getElementById('objPopup_Fond').style.top = 0;
	document.getElementById('objPopup_Fond').style.width = document.body.scrollWidth;
	document.getElementById('objPopup_Fond').style.height = document.body.scrollHeight;
	document.getElementById('objPopup_Fond').style.display='inline';

	Alpha_Objet = document.getElementById('objPopup_Fond');
	Alpha_Sens = 1;
	Alpha_Final = 70;
	Alpha_Valeur = 0;
	
	setAlpha('');
}
	
function Under_Popup_Loaded()
{
	window.parent.document.getElementById('objPopup_Content').style.display='inline';
}