	function writediv(texte,cible){
		document.getElementById(cible).innerHTML = texte;
     }

	function file(fichier)
	{
		 xhr_object = getXhr();
		 xhr_object.open("GET", fichier, false);
		 xhr_object.send(null);
		 if(xhr_object.readyState == 4) return(xhr_object.responseText);
		 else return(false);
    }
     
	function getXhr()
	{   
		var x;
    	try            
    	{    
    		x = new ActiveXObject("Microsoft.XMLHTTP");    
    	}
    	catch (e)  
    	{    
    		try           
    		{    
    			x = new ActiveXObject("Msxml2.XMLHTTP");    
    		}
            catch (e) 
            {    
            	try            
            	{    
            		x = new XMLHttpRequest();    
            	}
                catch (e)  
                {    
                	x = false;    
                }
             }
         }
    	return x;
	}

	
	function QuestionJourCBP($questionnaireid, $categorieid)
	{
		if (document.Quiz.reponse.value != ""){
			file("/data/quiz/questionsuivante_cbp.php?id="+$questionnaireid+"&choix="+document.Quiz.reponse.value);
		}
		
		$graphiquejour = file("/data/quiz/graphiquejour_cbp.php?categorie="+$categorieid);
		writediv($graphiquejour,"questionjour");
	}
	
	function QuestionJourSpeciale($questionnaireid)
	{
		if (document.Quiz.reponse.value != ""){
			file("/data/quiz/questionsuivante_cbp.php?id="+$questionnaireid+"&choix="+document.Quiz.reponse.value);
		}
		
		$apresVote = file("/data/quiz/apresVoteQuestionSpeciale.php");
		writediv($apresVote, "questionjourspeciale");
	}
	
	function QuestionJourPromotion($questionnaireid, redirect)
	{
		if (document.QuizPromotion.reponse.value != "")
		{		
			if (redirect == 1)
			{
				file("/data/quiz/questionsuivante_cbp.php?id="+$questionnaireid+"&choix="+document.QuizPromotion.reponse.value);
				window.location="http://quiz.cyberpresse.ca/promotion/"+$questionnaireid+".php";
			}
			else
			{
				file("http://quiz.cyberpresse.ca/Php/questionsuivante.php?id="+$questionnaireid+"&position=1&choix="+document.QuizPromotion.reponse.value);
				writediv('<img src="http://quiz.cyberpresse.ca/Graphique/graphique.php?id='+$questionnaireid+'">', "questionpromotion"); 
			}
		}		
	}
	
	function ChoisirPromotion(valeur)
	{
		document.QuizPromotion.reponse.value = valeur;
	}
	
	function Choisir(valeur,coche){
		if(document.Quiz.unique.value == "checked"){
			document.Quiz.reponse.value = valeur;
		}else{
			chiffre = 0;
			if (document.getElementsByName("choix1")[0].checked == true)
			{
				chiffre = chiffre + 1;		
			}
			
			if (document.getElementsByName("choix2")[0].checked == true)
			{
				chiffre = chiffre + 2;		
			}
			
			if(document.getElementsByName("choix3")[0])
			{
				if (document.getElementsByName("choix3")[0].checked == true)
				{
					chiffre = chiffre + 4;		
				}	
			}
			
			if(document.getElementsByName("choix4")[0])
			{
				if (document.getElementsByName("choix4")[0].checked == true)
				{
					chiffre = chiffre + 8;		
				}	
			}
			
			if(document.getElementsByName("choix5")[0])
			{
				if (document.getElementsByName("choix5")[0].checked == true)
				{
					chiffre = chiffre + 16;		
				}	
			}
			
			document.Quiz.reponse.value = chiffre;
		}	
	}
