

// ---
var arrQandAs = new Array();
function initFAQ()
{

    var arrQuestions = getElementsByClassName(document, "span", "question");
    var oQandASection;
    for(var i=0; i<arrQuestions.length; i++)
    {
        oQandASection = arrQuestions[i];
        while(oQandASection && oQandASection.parentNode && oQandASection.nodeName.search(/li/i) == -1)
            oQandASection = oQandASection.parentNode;
        
        arrQandAs.push(oQandASection);
    }
   
    var oExpandImage;
    var oQuestionSpan;
    var oSiblingDiv;
    for(var j=0; j<arrQandAs.length; j++)
    {
		
        oExpandImage = document.createElement("img");
        oExpandImage.setAttribute("src", KNOWIT_EPiServerRootDir + "util_/images/minus.gif");
        oQuestionSpan = getElementsByClassName(arrQandAs[j], "span", "question")[0];
        oQuestionSpan.insertBefore(oExpandImage, oQuestionSpan.firstChild);
        oQuestionSpan.style.cursor = "pointer";
        oSiblingDiv = getElementsByClassName(oQandASection, "div", "answer")[0];
        oSiblingDiv.className = oSiblingDiv.className + " answer-hide";

        
        hideShowAnswer(oQuestionSpan, "none");
        
        oQuestionSpan.onclick = function (){
            hideShowAnswer(this);
        };    
    }
}
// ---

// ---
function hideShowAnswer(oElm, bShowHide)
{
	
    var oNextSib = oElm.nextSibling;
    if(oNextSib){
		
        var strDisplay = (typeof bShowHide != "undefined")?bShowHide : (oNextSib.style.display == "none")?"block" : "none";
        var oExpandImage = oElm.getElementsByTagName("img")[0];
        var strImgSrc = (strDisplay == "block")? "minus" : "plus";
        oExpandImage.setAttribute("src", oExpandImage.getAttribute("src").replace(/\w+([.]gif)/i, (strImgSrc + "$1")));
        
        oNextSib.style.display = strDisplay;
    };
}
// ---

// ---
function getElementsByClassName(oElm, strTagName, strClassName){
	var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);
	var arrReturnElements = new Array();
	strClassName = strClassName.replace(/\-/g, "\\-");
	var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)");
	var oElement;
	for(var i=0; i<arrElements.length; i++){
		oElement = arrElements[i];		
		if(oRegExp.test(oElement.className)){
			arrReturnElements.push(oElement);
		}	
	}
	return (arrReturnElements)
}
// ---


// ---
ELO.functionsToCallOnload.push("initFAQ()");

// ---
