var $j = jQuery.noConflict();
	
	
	function imprime_zone()
	{
		
		//var zi = '../v1.jpg';

		// Ouvre une nouvelle fenetre
		var f = window.open("img.html", "ZoneImpr", "height=200, width=600,toolbar=0, menubar=0, scrollbars=0, resizable=1,status=0, location=0, left=10, top=10");

		// Definit le Style de la page
		f.document.body.style.color = '#000000';
		f.document.body.style.backgroundColor = '#FFFFFF';
		f.document.body.style.padding = "10px";
		f.document.body.style.font = "10px Arial";

		// Ajoute les Donnees
		//f.document.title = '';
		//f.document.body.innerHTML = '<img src="../v1.jpg" />';

		// Imprime et ferme la fenetre
		
		f.window.print();
		f.window.close();
		return true;
	}
	
	function valider(theForm) {	
	
		return (
			isRadioButtonChecked(theForm.elements["Q1"], mPrefix2) &&
			isRadioButtonChecked(theForm.elements["Q2"], mPrefix2) &&
			true
		);
	
	}
			
	function submitformPa() {
		if(document.frm1.onsubmit()) {
			//this check triggers the validations
			document.frm1.submit();
		}
	}

	var mPrefix2 = "Merci de bien vouloir compléter ce court questionnaire pour obtenir vos 3 Preuves d'Achat JOKER";
	var mSuffix = "";

	function warnInvalidRadio (radio, s){	
		radio[0].focus();
		alert(s);
		return false;
	}

	//Verify that radio is Checked Whithout Prompt alert if false.
	function isRadioButtonChecked (radio, s){
		var rtn=false;
		
		for (var i = 0; i < radio.length; i++){  
			if (radio[i].checked) { rtn=true; }
		}
		
		if (!rtn) 
			return warnInvalidRadio (radio, s);
		else return true;
	}


	
	//fonction pour la page de stat ( quiz )
	function changeStat(idRol, monId, lib) {
	
		
		//var monIdOk = (monId-1);
		
		var node = document.getElementById('mesLiens');
		
		var childrenNumber = node.childNodes.length;
		//alert(childrenNumber);
		
		//alert(monIdOk);

		
		for (var i = 0; i < childrenNumber; i++) {
					
			node.childNodes[i].className = "none";
			//alert(node.childNodes[i].id);
			//node.childNodes[i].style.color = "#666";
		}
		
		node.childNodes[idRol].className = "active";
		//node.childNodes[idRol].style.color = "#fff";
		
		
		if(window.XMLHttpRequest){
			req = new XMLHttpRequest(); //on test les navigateurs
		}
		else if (window.ActiveXObject){
			req  = new ActiveXObject("Microsoft.XMLHTTP"); 
		}
		

		req.open("POST", "inc/reponseRequestQuiz.inc.php", true); //initialisation de la requete
	

			req.onreadystatechange = function() { 

				if(req.readyState == 4){
				
					obj = document.getElementById("reponseRequest");
					obj.innerHTML = (req.responseText);
					
				}
			}

		req.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); 
		
		var data="id="+monId+"&lib="+lib; 
		req.send(data); //ce que j' envois
		
		
		
	}


	
// fonction liée au menu
  // cache les ssmenu
  function hide_ssmenu(){
    $j("div.ssmenu1").hide();
    $j("div.ssmenu2").hide();
    $j("div.ssmenu3").hide();
  }
  
  // cache ou affiche les select dans .content
  function show_select(){ $j(".content select").css("visibility","visible"); }
  function hide_select(){ $j(".content select").css("visibility","hidden"); }
  
  // au chargement de la page
  $j(document).ready(function(){
    hide_ssmenu();
    // au rollover sur le contenu
    $j(".content").mouseover( function() {
            hide_ssmenu();
            show_select();
    } );
	// cas du jeu
	$j("#flashcontent").mouseover( function() {
            hide_ssmenu();
            show_select();
    } );
    // au rollover sur un menu
    $j(".menu a.menu_item").mouseover( function() {
			hide_ssmenu();
            show_select();
            $j("."+(this.id)).show(); // affiche le sous menu
    } );
  });
  

 


// fonction liée à la FAQ
function SwitchFAQ(index){


	

	
	var table_faq=document.getElementById('table_faq');
	
	var td = table_faq.getElementsByTagName('td');
	var indice=1;
	
	for(var i=0; i<td.length; i++){
		if( td[i].className =="td_on"){
			td[i].className="";
			indice=(i+2)/2;
		}
	}
	
		
	if(indice!=index){
	
		td[2*index-2].className="td_on";
		document.getElementById('faq_'+index).className="texte_scroll";
		document.getElementById('faq_'+indice).className="invisible";

		document.getElementById("div_right").scrollTop = -8000;
	
	}
	
	
}

function SwitchMentions(index){
	var table_faq=document.getElementById('table_mentions');
	var td = table_faq.getElementsByTagName('td');
	var indice=0;
	for(var i=0; i<td.length; i++){
		if( td[i].className =="td_on"){
			td[i].className="";
			indice=(i+2)/2;
		}
	}
	
		td[2*index-2].className="td_on";
		document.getElementById('mentions_'+index).className="texte_scroll";
		document.getElementById('mentions_'+indice).className="invisible";

}

// fonction d'ajout à la liste de course
    function suppProduit(idProduit) {
      document.formDelete.idProduit.value=idProduit;
      document.formDelete.submit();
    }

    if(window.XMLHttpRequest)
      var objR = new XMLHttpRequest();
    else if(window.ActiveXObject)
      var objR = new ActiveXObject("Microsoft.XMLHTTP");

    function ajoutListe(idProduit) {
      objR.open('get','php/addListe.php?idProduit='+idProduit,true);
      objR.onreadystatechange = ajoutOk;
      objR.send(null);
    }
    
    function ajoutOk() {
      if(objR.readyState == 4)
        alert('Ce produit a bien été ajouté à votre liste de courses.');
    }

// fonctions liées au moteur de recherche produits/pa
    if(window.XMLHttpRequest) {
      var objXHR_s = new XMLHttpRequest();
      var objXHR_c = new XMLHttpRequest();
      var objXHR_m = new XMLHttpRequest();
      var objXHR_p = new XMLHttpRequest();
	  var objXHR_l = new XMLHttpRequest();
	  var objXHR_t = new XMLHttpRequest();
    } else if(window.ActiveXObject) {
      var objXHR_s = new ActiveXObject("Microsoft.XMLHTTP");
      var objXHR_c = new ActiveXObject("Microsoft.XMLHTTP");
      var objXHR_m = new ActiveXObject("Microsoft.XMLHTTP");
      var objXHR_p = new ActiveXObject("Microsoft.XMLHTTP");
	  var objXHR_l = new ActiveXObject("Microsoft.XMLHTTP");
	  var objXHR_t = new ActiveXObject("Microsoft.XMLHTTP");
    }

    function changeSelect(val) {
	
	  waitingMessage();
	
	  objXHR_s.open('get','php/select.php?choix='+val,true);
      objXHR_s.onreadystatechange = fillChoix;
      objXHR_s.send(null);

	  objXHR_l.open('get','php/listeProduit.php?liste=1',true);
      objXHR_l.onreadystatechange = fillListDescProduit;
      objXHR_l.send(null);
	 	  
      document.getElementById("_marques").innerHTML = '<select class="liste_recherche" size="1"><option>-</option></select>';
      document.getElementById("_produits").innerHTML = '<select class="liste_recherche" size="1"><option>-</option></select>';
	  
	  if (2 == val) document.getElementById("txt_recherche").innerHTML = '<strong>Rechercher par :</strong> <a href="#" onclick="changeSelect(1);">produit</a> | <a href="#" onclick="changeSelect(2);" id="active">page collecteur</a>';
	  else document.getElementById("txt_recherche").innerHTML = '<strong>Rechercher par :</strong> <a href="#" onclick="changeSelect(1);" id="active">produit</a> | <a href="#" onclick="changeSelect(2);">page collecteur</a>';

      return true;
    }
    
    function changePage(val) {
	
	  waitingMessage();
	  
      objXHR_c.open('get','php/select.php?page='+val,true);
      objXHR_c.onreadystatechange = fillMarques;
      objXHR_c.send(null);
	  
	  objXHR_l.open('get','php/listeProduit.php?liste=2&page='+val,true);
      objXHR_l.onreadystatechange = fillListDescProduit;
      objXHR_l.send(null);
	
      document.getElementById("_produits").innerHTML = '<select class="liste_recherche" size="1"><option>-</option></select>';

      return true;
    }
    
    function changeBu(val) {
	
	  waitingMessage();
	  
      objXHR_c.open('get','php/select.php?bu='+val,true);
      objXHR_c.onreadystatechange = fillMarques;
      objXHR_c.send(null);

	  objXHR_l.open('get','php/listeProduit.php?liste=2&bu='+val,true);
      objXHR_l.onreadystatechange = fillListDescProduit;
      objXHR_l.send(null);
	  
      document.getElementById("_produits").innerHTML = '<select class="liste_recherche" size="1"><option>-</option></select>';

      return true;
    }
    
    function changeMarques(val, page) {
	
	  waitingMessage();
	
      objXHR_m.open('get','php/select.php?marque='+val+'&page='+page,true);
      objXHR_m.onreadystatechange = fillProduits;
      objXHR_m.send(null);
	  
	  objXHR_l.open('get','php/listeProduit.php?liste=3&marque='+val+'&page='+page,true);
      objXHR_l.onreadystatechange = fillListDescProduit;
      objXHR_l.send(null);

      return true;
    }

    function changeProduit(val) {
	  
	  objXHR_p.open('get','php/select.php?produit='+val,true);
      objXHR_p.onreadystatechange = fillDescProduit;
      objXHR_p.send(null);

      return true;
    }

    function fillChoix() {
      if(objXHR_s.readyState == 4)
        document.getElementById("_choix").innerHTML = objXHR_s.responseText;
    }

    function fillMarques() {
      if(objXHR_c.readyState == 4)
        document.getElementById("_marques").innerHTML = objXHR_c.responseText;
    }
    
    function fillProduits() {
      if(objXHR_m.readyState == 4)
        document.getElementById("_produits").innerHTML = objXHR_m.responseText;
    }
    
    function fillDescProduit() {
      if(objXHR_p.readyState == 4)
        document.getElementById("_descProduit").innerHTML = objXHR_p.responseText;
    }
	
	function fillListDescProduit() {
	  if(objXHR_l.readyState == 4)
        document.getElementById("_descProduit").innerHTML = objXHR_l.responseText;
	}
	
	function fillWaitingMessage() {
	  if(objXHR_t.readyState == 4)
        document.getElementById("_descProduit").innerHTML = objXHR_t.responseText;
	}
	
	function waitingMessage() {
	   objXHR_t.open('get','php/waitingMessage.php',true);
       objXHR_t.onreadystatechange = fillWaitingMessage;
       objXHR_t.send(null);
	
	}
	
	function initialisation() {
	   //document.getElementById('choix1').checked = true;
	   changeSelect(1);
	}