/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

function loadXMLDoc(dname) {
    if (window.XMLHttpRequest) {
        xhttp = new XMLHttpRequest();
    }
    else {
        xhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    xhttp.open("GET", dname, false);
    xhttp.send("");
    return xhttp.responseXML;
}
function getAll(dir, name) {
    //load documents for translation//
    path = dir + "testimonial_files/";
    xml = loadXMLDoc(path + name +".xml");
    xsl = loadXMLDoc(path + "testimonials"+".xsl");

    ////transform document////
    // code for IE
    if (window.ActiveXObject) {
        ex = xml.transformNode(xsl);
        document.getElementById("testimonial").innerHTML = ex;
    }
    // code for Mozilla, Firefox, Opera, etc.
    else if (document.implementation && document.implementation.createDocument) {
        xsltProcessor = new XSLTProcessor();
        xsltProcessor.importStylesheet(xsl);
        resultDocument = xsltProcessor.transformToFragment(xml, document);
        document.getElementById("middleCol").appendChild(resultDocument);
    }
    ////end transform document////
}
function getRandom(dir, name) {
    path=dir +"testimonial_files/";
    xml = loadXMLDoc(path + name + ".xml");
    
    if (window.ActiveXObject) {
        x = xml.getElementsByTagName("case");
        i = Math.floor(Math.random() * x.length)
        document.getElementById("testimonial").innerHTML=x[i].text;//.TextContent;
    }
    else{
        x = xml.getElementsByTagName("case");
        i = Math.floor(Math.random() * x.length)
        document.getElementById("testimonial").innerHTML=x[i].textContent;
    }
}

