﻿/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
* FAQ/REASONS Healine SWF Swapping
============================================ */
aczone.swfSwap = function() {
    this.flashSrc = "";
    this.appDivID = "";
    this.shContainerID = "showhideall";
};
aczone.swfSwap.prototype.getMyFAQs = function(faqDiv, flashSource) {
    this.flashSrc = flashSource;
    this.appDivID = faqDiv;
    //var myFAQs = document.getElementById(faqDiv).getElementsByTagName('a');
    var myFAQs = $jq('a.question');

    for (i = 0, faq_len = myFAQs.length; i < faq_len; i++) {
        var thisFAQ = myFAQs[i];
        var thisID = i + 1;
        var label = thisFAQ.innerHTML;
        label = label.replace('&amp;', '%26');
        label = label.replace('&', '%26');

        //write the showhide div out on the last entry
        if (i == (myFAQs.length - 1)) {
            this.writeQuestion(thisFAQ.id, thisID, label, true);
        } else {
            this.writeQuestion(thisFAQ.id, thisID, label, false);
        }
    }
};
aczone.swfSwap.prototype.writeQuestion = function(containerID, thisID, label, isLast) {
    //alert(thisLabel + ": " + thisLabel.length);
    flashId = 'aczone_faq' + thisID;
    flashSrcWidth = 455;
    flashSrcHeight = 40;

    // swfobject.embedSWF(this.flashSrc, containerID, flashSrcWidth, flashSrcHeight, "9.0.0","expressInstall.swf", {Numbr:thisID,Title:label}, {menu:"false",wmode:"transparent"}, {id:flashId,name:flashId});
    // swfobject 1.5 code:
    
    flashVars = 'Numbr=' + thisID + '&Title=' + label;
    var so = new SWFObject(this.flashSrc, flashId, flashSrcWidth, flashSrcHeight, "9.0.0.0", "#7D7067");
    so.addParam("allowScriptAccess", "sameDomain");
    so.addParam("wmode", "transparent");
    so.addParam("flashVars", flashVars);
    document.getElementById(containerID).style.padding = "0";
    document.getElementById(containerID).style.background = "none";
    document.getElementById(containerID).style.height = flashSrcHeight + "px";

    if (!isLast) {
        so.write(containerID);
    } else {
        if (so.write(containerID)) {
            this.writeShowHide(this.appDivID);
        }
    }

};
aczone.swfSwap.prototype.writeShowHide = function(cntID) {
    var tmpContainer = document.getElementById(this.shContainerID);
    //tmpContainer.className = "faq";
    aczone.swfSwap.showHideSwap(true, cntID, this.shContainerID);
};
aczone.swfSwap.showHideSwap = function(sh, cntID, shContainerID) {
    var tmpContainer = document.getElementById(shContainerID);
    tmpContainer.innerHTML = "";
    var tmpAnchor = document.createElement("a");
    tmpAnchor.href = "#";
    if (sh) { // show 'open all'
        $jq(tmpAnchor).click(function() {
            aczone.swfSwap.openALL(cntID);
        });
        tmpAnchor.appendChild(document.createTextNode("Show all"));
        //tmpAnchor.style.backgroundImage = "url(/images/faq_plus.gif)";
    } else { // show 'close all'
        $jq(tmpAnchor).click(function() {
            aczone.swfSwap.closeALL(cntID);
        });
        tmpAnchor.appendChild(document.createTextNode("Close all"));
        //tmpAnchor.style.backgroundImage = "url(/images/faq_minus.gif)";
    }
    tmpContainer.appendChild(tmpAnchor);
};
aczone.swfSwap.getMovie = function(movieName) {
    //this only works in all browsers if using swfobject
    return document.getElementById(movieName);
};
aczone.swfSwap.openALL = function(secID) {
    //myFAQs = document.getElementById(secID).getElementsByTagName('a');
    var myFAQs = $jq('a.question');
    var ii;
    var a;
    for (i = 0; i < myFAQs.length; i++) {
        ii = i + 1;
        var flash = aczone.swfSwap.getMovie('aczone_faq' + ii);
        try {
            flash.sHeadline(2);
        } catch (e) {
            // set interval on toggle flash headline
        }
        a = document.getElementById("A" + ii);
        a.style.display = "block";
    }
    aczone.swfSwap.showHideSwap(false, secID, "showhideall");
    return false;
};
aczone.swfSwap.closeALL = function(secID) {
    myFAQs = document.getElementById(secID).getElementsByTagName('a');
    var ii;
    var a;
    for (i = 0; i < myFAQs.length; i++) {
        var ii = i + 1;
        var flash = aczone.swfSwap.getMovie('aczone_faq' + ii);
        try {
            flash.sHeadline(1);
        } catch (e) {
            // set interval on toggle flash headline
        }
        a = document.getElementById("A" + ii);
        if(a){
                a.style.display = "none";
        }
    }
    aczone.swfSwap.showHideSwap(true, secID, "showhideall");
    return false;
};
function displayAnswer(answer) {
    a = document.getElementById("A" + answer);
    if (a.style.display == "none") {
        $jq("#A" + answer).slideDown("slow");
    } else if (a.style.display == "block") {
        $jq("#A" + answer).slideUp("slow");
    }
}