/**
 * Cree un objet XMLHttpRequest
 */
function createXHR ()
{
	try { return new XMLHttpRequest (); } catch (e) {};	
  	try { return new ActiveXObject ("Microsoft.XMLHTTP"); } catch (e) {};
  	try { return new ActiveXObject ("Msxml2.XMLHTTP"); } catch (e) {};
	//alert("avant null");
	
	return null;
}

/**
 * Envoi une requete au serveur
 * Type GET
 */
function httpRequest (xhr, url)
{
	xhr.onreadystatechange = function () {
		if (xhr.readyState == 2) { // requete en cours
			$ ("loading").className = "load";
		}
		if (xhr.readyState == 4) { // requete terminÃ©e
			if (xhr.status == 200) { // requete c bien passÃ©
				$ ("loading").className = "noload";
				$ ("contenu_onglet").innerHTML = xhr.responseText;
			}
		}
	}
	
	xhr.open ("GET", url, true);
	xhr.send (null);
}



function httpRequest2 (xhr, url)
{
	xhr.onreadystatechange = function () {
		if (xhr.readyState == 2) { // requete en cours
			$ ("loading").className = "load";
		}
		if (xhr.readyState == 4) { // requete terminÃ©e
			if (xhr.status == 200) { // requete c bien passÃ©
				$ ("loading").className = "noload";
				$ ("contenu_onglet_bd").innerHTML = xhr.responseText;
			}
		}
	}
	
	xhr.open ("GET", url, true);
	xhr.send (null);
}
/**
 * Gestions des onglets
 * charge dynamiquement
 */
function onglet_dym (num)
{
	var xhr = createXHR ();

	if (num == 1) {
		$ ("onglet-1").className = "actif";
		$ ("onglet-2").className = "";
		$ ("onglet-3").className = "";
		
		// Charge ?
		httpRequest (xhr, "onglet/onglet1.html");
	}
	if (num == 2) {
		$ ("onglet-1").className = "";		
		$ ("onglet-2").className = "actif";
		$ ("onglet-3").className = "";
		
		// Charge ?
		httpRequest (xhr, "onglet/onglet2.html");
	}
	if (num == 3) {
		$ ("onglet-1").className = "";
		$ ("onglet-2").className = "";
		$ ("onglet-3").className = "actif";
		
		// Charge ?
		httpRequest (xhr, "onglet/onglet3.html");
	}
}


function onglet_dym2 (num)
{
	var xhr = createXHR ();

	if (num == 1) {
		$ ("onglet-1_bd").className = "actif";
		$ ("onglet-2_bd").className = "";
		$ ("onglet-3_bd").className = "";
		
		// Charge ?
		httpRequest2 (xhr, "onglet/onglet1_bd.html");
	}
	if (num == 2) {
		$ ("onglet-1_bd").className = "";		
		$ ("onglet-2_bd").className = "actif";
		$ ("onglet-3_bd").className = "";
		
		// Charge ?
		httpRequest2 (xhr, "onglet/onglet2_bd.html");
	}
	if (num == 3) {
		$ ("onglet-1_bd").className = "";
		$ ("onglet-2_bd").className = "";
		$ ("onglet-3_bd").className = "actif";
		
		// Charge ?
		httpRequest2 (xhr, "onglet/onglet3_bd.html");
	}
}