// Class Faq
var instance = null
function Faq()
{
	this.m_qa = new Array()
	this.Add = function( _question, _answer )
	{
		this.m_qa[_question] = _answer;
	}

	// Prints Questions
	this.Questions = function()
	{
		var txt = '<p><strong>'
		var i = 0
		for( question in this.m_qa )
		{
			txt += '<a href="#Q'+i+'">'+question+'</a><br>'
			i++
		}
		txt+= '</strong><br></p>'
		return txt
	}
	
	// Prints Questions and their answers
	this.Answers = function()
	{
		var txt = ""
		var i = 0
		for( question in this.m_qa )
		{
			txt += '<p><strong><a name="Q'+i+'"></a>'+question+'<br></strong>'
			txt += this.m_qa[question]+'</p>'
			i++
		}
		return txt		
	}

	this.Load = function(_file,_callback)
	{
//		alert("loading "+_file)
		instance = this
		this.m_onLoadedCallback = _callback
		this.m_xmldoc = CreateXmlDoc(this.OnLoadedStatic)
		this.m_xmldoc.async = false
		this.m_xmldoc.load(_file)
	}

	this.OnLoaded = function()
	{
		if( this.m_xmldoc==null || this.m_xmldoc.readyState!=4 )
			return
		nodes = this.m_xmldoc.documentElement
		for( i=0; i<NbChildren(nodes); i++ )
		{
			var qa_node = Child(nodes,i)
			q = NodeValue( Child(qa_node,0) )
//			alert("q="+q)
			a = NodeValue( Child(qa_node,1) )
			a = a.replace(/{/g,'<')
			a = a.replace(/}/g,'>')
			a = a.replace(/é/g,'&eacute;')
			a = a.replace(/è/g,'&egrave;')
			a = a.replace(/à/g,'&agrave;')
			this.Add(q, a)
		}
		this.m_onLoadedCallback()
	}
	this.OnLoadedStatic = function()	{ instance.OnLoaded() }
}

