	function faq_change_cb( data )
	{
		if( !data.question || !data.answer )
		{
			return;
		}
		
		var newQues = document.createTextNode("   " + data.question);
		var newAns = document.createTextNode("   " + data.answer);
		var ques = document.getElementById('faq_question_container');
		var ans = document.getElementById('faq_answer_container');
		
		var quesSpan = document.createElement('span');
		quesSpan.style.fontWeight = 'bold';
		quesSpan.appendChild(document.createTextNode('Q:'));
		
		var ansSpan = document.createElement('span');
		ansSpan.style.fontWeight = 'bold';
		ansSpan.appendChild(document.createTextNode('A:   '));
		
		// remove all the children for the exising question container
		while(ques.childNodes.length != 0 )
		{
			ques.removeChild(ques.childNodes[0]);
		}
		
		// remove all the children for the exising answer container
		while(ans.childNodes.length != 0 )
		{
			ans.removeChild(ans.childNodes[0]);	
		}
		
		ques.appendChild(quesSpan);
		ques.appendChild(newQues);
		
		ans.appendChild(ansSpan);
		// Replace and line returns in the answer with a <br >
		var tmp = data.answer;
		var text;
		var index;
		while( tmp.length != 0 )
		{
			index = tmp.indexOf("\n");
			if( index == -1 )
			{
				ans.appendChild(document.createTextNode(tmp));
				break;
			}
			else
			{
				ans.appendChild(document.createTextNode(tmp.substr(0,index)) );
				ans.appendChild(document.createElement('br'));
				tmp = tmp.substr((index + 1), tmp.length);
			} // end if
		} // wend

	} // end function

	function do_faq_change(e)
	{
		target = findTarget(e);
		x_faq_change(target.getAttribute('id'), faq_change_cb);
	}
	
	function do_faq_cb( data )
	{
		var faq_cont = document.getElementById('faq_ul');
		var faq_questions = faq_cont.getElementsByTagName('li');
		
		// Remove the existing questions
		while( faq_questions.length != 0 )
		{
			var node = faq_questions[0];
			if( node.parentNode )
			{
				node.parentNode.removeChild(node);
				
			} // end if
		} // wend
		
		for( keyVar in data )
		{
			var newQues = document.createElement('li');
			var newLink = document.createElement('a');
			var newText = document.createTextNode(data[keyVar].question);
			newLink.appendChild(newText);
			newLink.href = 'javascript:void(0);';
			newLink.id = '' + data[keyVar].question_id + '';
			addEvent(newLink, 'click', do_faq_change, false);			
			newQues.appendChild(newLink);
			faq_cont.appendChild(newQues);
		} // wend
		
		var cat_sel = document.getElementById('category');
		var cat = document.getElementById('category_name');
		cat.removeChild(cat.firstChild);
		if( cat_sel.selectedIndex != 0 )
		{
			cat.appendChild(document.createTextNode(cat_sel.options[cat_sel.selectedIndex].text))
		}
		else
		{
			cat.appendChild(document.createTextNode('General'))
		}
	} // end function
	
	function do_faq()
	{
		var category = document.getElementById('category');
		var category_id = category.options[category.selectedIndex].value;
		x_faq(category_id, do_faq_cb);
	}
	
	function installListener(e)
	{
		var category = document.getElementById('category');
		addEvent(category, 'change', do_faq, false);
	}
	
	function addEvent(elm, evType, fn, useCapture)
      // cross-browser event handling for IE5+, NS6+ and Mozilla/Gecko
      // By Scott Andrew
      {
        if (elm.addEventListener) {
          elm.addEventListener(evType, fn, useCapture); 
          return true; 
        } else if (elm.attachEvent) {
          var r = elm.attachEvent('on' + evType, fn); 
          return r; 
        } else {
          elm['on' + evType] = fn;
        }
      }
	  
	  function findTarget(e)
	  {
		  var target;
		  
		  if( window.event && window.event.srcElement )
		  {
			  target = window.event.srcElement;
			  return target;
		  }
		  if( e && e.target )
		  {
			  target = e.target;
			  return target;
		  }
		  return;
	  } // end function
	
	addEvent(window,'load', installListener, false);
	addEvent(window, 'load', do_faq, false);