// DEFINITION DES VARIABLES ###########################
//#####################################################
var serveur;
serveur = "http://www.ecolechezsoi.com/";
//#####################################################

function afficheReponse(IDFaq, typeQuestion)
{
	if(window.innerHeight)
	{
		// Firefox
		tailleEcranHauteur = window.innerHeight;
	}
	else
	{
		// IE
		tailleEcranHauteur = document.documentElement.clientHeight;
	}
	if(window.innerWidth)
	{
		// Firefox
		tailleEcranLargeur = window.innerWidth;
	}
	else
	{
		// IE
		tailleEcranLargeur = document.documentElement.clientWidth;
	}
	marginHauteur = ((tailleEcranHauteur - 400) / 2);
	marginLargeur = ((tailleEcranLargeur - 625) / 2); 

	document.getElementById("reponseQuestion").style.top = marginHauteur+"px";
	document.getElementById("reponseQuestion").style.left = marginLargeur+"px";
	document.getElementById("reponseQuestion").style.display = "block";
	
	var http_request = false;
	if (window.XMLHttpRequest) // Mozilla, Safari,...
	{ 
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) 
		{
			http_request.overrideMimeType('text/xml');
		}
	} 
	else if (window.ActiveXObject) // IE
	{ 
		try 
		{
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		} 
		catch (e)
		{
			try
			{
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			} 
			catch (e) {}
		}
	}
	
	if (!http_request) 
	{
		document.location.href = 'probleme-navigateur.asp';
		return false;
	}
			
	document.getElementById("reponseQuestion").innerHTML = "<img src='images/chargement.gif' alt='Chargement en cours...' />";
			
	http_request.onreadystatechange = function() { affichageReponseQuestion(http_request); };
	http_request.open('GET', "JS/requeteAjaxJSON.asp?nomRequete=getReponseXML&typeQuestion="+typeQuestion+"&idFaq="+IDFaq, true);
	http_request.send(null);
}

function affichageReponseQuestion(http_request)
{
	if (http_request.readyState == 4)
	{
		if (http_request.status == 200)
		{	
			var doc = eval('(' + http_request.responseText + ')'); 
			variableAfficheReponseXML = "";
			if (doc !== false)
			{
				if(doc.laReponse)
				{
					variableAfficheReponseXML = URLDecode(doc.laReponse[0].reponseXML);
				}
			}
		
			document.getElementById("reponseQuestion").innerHTML = variableAfficheReponseXML;
		}
	}	
}

function URLDecode(psEncodeString)
{
  // Create a regular expression to search all +s in the string
  var lsRegExp = /\+/g;
  // Return the decoded string
  return unescape(String(psEncodeString).replace(lsRegExp, " "));
}

function AddFavori(nomFormulaire, NumeroQuestion, typeQuestion)
{
	nomFormulaire.NumQuestion.value = NumeroQuestion;
	if(typeQuestion == "0")
	{
		nomFormulaire.TypeQuestion.value = "0";
	}
	nomFormulaire.submit();
}
