// Fonction qui ouvre et ferme le menu
// ----------------------------------------------------------------------------------
function openTheme(idU,idT)
{
	var xhr = getXhr()
	
	// On défini ce qu'on va faire quand on aura la réponse
	xhr.onreadystatechange = function()
	{
		// On ne fait quelque chose que si on a tout reçu et que le serveur est ok
		if(xhr.readyState == 4 && xhr.status == 200)
		{
			document.getElementById("menuCat").innerHTML = xhr.responseText;
		}
	}
	
	// Objet à remplir
	xhr.open("GET", "http://www.one-blood.com/global/_menuCatalogueAjax.php?idU="+idU+"&idT="+idT , true);
	// Fermeture
	xhr.send(null);		
	
}
// ----------------------------------------------------------------------------------


// Fonction qui affiche la grande image de la fiche produit
// ----------------------------------------------------------------------------------
function grandeImage(idImage)
{
	var xhr = getXhr()
	
	// On défini ce qu'on va faire quand on aura la réponse
	xhr.onreadystatechange = function()
	{
		// On ne fait quelque chose que si on a tout reçu et que le serveur est ok
		if(xhr.readyState == 4 && xhr.status == 200)
		{
			document.getElementById("produitImg").innerHTML = xhr.responseText;
		}
	}

// Objet à remplir
	xhr.open("GET", "http://www.one-blood.com/shop/_grandeImageAjax.php?idImage="+idImage, true);
	// Fermeture
	xhr.send(null);		
	
}
// ----------------------------------------------------------------------------------


// Fonction AJAX
// ----------------------------------------------------------------------------------
function getXhr()
{
	var xhr = null; 
	if(window.XMLHttpRequest) // Firefox et autres
		xhr = new XMLHttpRequest(); 
	else if(window.ActiveXObject)
	{ // Internet Explorer 
		try 
		{
			xhr = new ActiveXObject("Msxml2.XMLHTTP");
		} 
		catch (e) 
		{
			xhr = new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	else 
	{ // XMLHttpRequest non supporté par le navigateur 
		alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest..."); 
		xhr = false; 
	} 
	return xhr
}
// ----------------------------------------------------------------------------------


// Fonction LightBox gradient
// ----------------------------------------------------------------------------------
function gradient(id, level)
{
	var box = document.getElementById(id);
	box.style.opacity = level;
	box.style.MozOpacity = level;
	box.style.KhtmlOpacity = level;
	box.style.filter = "alpha(opacity=" + level * 100 + ")";
	box.style.display="block";
	return;
}
// ----------------------------------------------------------------------------------


// Fonction LightBox fadeIn
// ----------------------------------------------------------------------------------
function fadein(id) 
{
	var level = 0;
	while(level <= 1)
	{
		setTimeout( "gradient('" + id + "'," + level + ")", (level* 1000) + 10);
		level += 0.01;
	}
}
// ----------------------------------------------------------------------------------


// Fonction LightBox Ouvrir
// ----------------------------------------------------------------------------------
function openbox(url, fadin)
{
  var box = document.getElementById('box'); 
  document.getElementById('filter').style.display='block';
  
  var title = document.getElementById('boxtitle');
  title.innerHTML = url;
  
  var content = document.getElementById('boxcontent');
  content.style.padding="0";

  content.innerHTML = "<img src=" + url + " />";

  if(fadin)
  {
	 gradient("box", 0);
	 fadein("box");
  }
  else
  { 	
    box.style.display='block';
  }  	
}	
// ----------------------------------------------------------------------------------


// Fonction LightBox Fermer
// ----------------------------------------------------------------------------------
function closebox()
{
   document.getElementById('box').style.display='none';
   document.getElementById('filter').style.display='none';
}
// ----------------------------------------------------------------------------------


// Fonction qui ouvre le popUp tissus
//-------------------------------------------------------------
function popArticle(page){
	var largeur = 500;
	var hauteur = 350;
	var top=(screen.height-hauteur)/2;     
	//var left=(screen.width-largeur)/2; 
	var left=250;
	window.open(page,"","top="+top+",left="+left+",width="+largeur+",height="+hauteur+",menubar=no,scrollbars=no,statusbar=no"); 
}

// Fonction qui ferifie que la case est coché
// ----------------------------------------------------------------------------------
function chkCgv(champId,formId){
	if(document.getElementById(champId).checked==false){
		alert("Vous devez accepter les conditions générales de vente");	
	}else{
		// Configuration des variables paypal
		document.getElementById('business').value="sales@one-blood.com";
		document.getElementById('return').value="http://"+document.domain+"/paypaloki.php";
		document.getElementById('cancel_return').value="http://"+document.domain+"/client/recap.php";
		document.getElementById('notify_url').value="http://"+document.domain+"/client/autoPayPal.php";
		document.getElementById(formId).action="https://www.paypal.com/fr/cgi-bin/webscr";
		document.getElementById(formId).submit();
	}
}



