    function get_cwd(rawloc) {
        if(!rawloc) {
            rawloc = location.href;
        }

        var expl_loc = rawloc.split("/");
        if(expl_loc[expl_loc.length-2]) {
            return expl_loc[expl_loc.length-2];
        }

        return "";
    }

    function init() {
		retrieve_quotes();
		
        var obj = document.getElementById('product_sidebar');
        if(!obj) return false;
        var link_container = obj.getElementsByTagName('ul');
        link_container = link_container[0];

        var all_links = link_container.getElementsByTagName('a');
        var x;
        var linkFound = false;

        for(x = 0; x < all_links.length; x++) {
            if((all_links[x].href) == (location.href)) {
                all_links[x].className = 'selected';
                linkFound = true;
                break;
            }
        }

        if(!linkFound) {    // if link not found, highlight FIRST entry (only if current folder is identical)
            if(all_links.length > 0) {
                if(get_cwd(all_links[0].href) == get_cwd()) {
                    all_links[0].className = 'selected';
					linkFound = true;
                }
            }
        }

		if(!linkFound) {	// link still not found, highlight first link with folder that matches current page
			if(all_links.length > 0) {
				for(x = 0; x < all_links.length; x++) {
					if(get_cwd(all_links[x].href) == get_cwd()) {
						all_links[x].className = 'selected';
						break;
					}
				}
			}
		}
    }

    function xml_request() {
    
        if(window.XMLHttpRequest) {
            try {
                var req = new XMLHttpRequest();
            } catch(e) {
                var req = false;
            }
        } else if(window.ActiveXObject) {
            try {
                var req = new ActiveXObject("Msxml2.XMLHTTP");
            } catch(e) {
                try {
                    var req = new ActiveXObject("Microsoft.XMLHTTP");
                } catch(e) {
                    var req = false;
                }
            }
        }
        return req;
    }
    
    
    function retrieve_quotes() {
        // only run this script if a quote needs to be displayed
        // on this page
    
        // get all divs
        var all_divs = document.getElementsByTagName('div');
        var x;
    
        // go through divs, and check for class named 'quote'
        var foundQuote = false;
        for(x = 0; x < all_divs.length; x++) {
            if(all_divs[x].className == 'quote') {
                foundQuote = true;
                break;
            }
        }
    
        // quote holder not found, die
        if(!foundQuote) { return false; }
    
        var req = xml_request();
    
        req.onreadystatechange = function() {
            if(req.readyState == 4) {
                if(req.status == 200) {
                    display_quote(req.responseXML);
                }
            }
        }
    
        req.open("GET","/general/data/quotes.xml",true);
        req.send("");
    }
    
    function display_quote(xml) {
        // get all divs
        var all_divs = document.getElementsByTagName('div');
        var x;


        var root = xml.documentElement;
        var all_quotes = root.getElementsByTagName('quote');

        // go through quote divs, and insert quote
    
        for(x = 0; x < all_divs.length; x++) {
            if(all_divs[x].className == 'quote') {

                var randChild = Math.floor(Math.random()*all_quotes.length);

                parse_quote(all_divs[x],all_quotes[randChild]);
            }
        }
    
    }

    function parse_quote(quoteObj,quoteNode) {
        // message value
        var quote_message = quoteNode.getElementsByTagName('message');
        quote_message = quote_message[0].childNodes[0].nodeValue;

        // author value
        var quote_author = quoteNode.getElementsByTagName('author');
        quote_author = quote_author[0].childNodes[0].nodeValue;

        var x;
        var did_msg = false;
        var did_aut = false;

        // message container div
        var all_divs = quoteObj.getElementsByTagName('div');
        for(x = 0; x < all_divs.length; x++) {
            if(all_divs[x].className == 'msg') {
                all_divs[x].innerHTML = quote_message;
                did_msg = true;
            }
            if(all_divs[x].className == 'author') {
                all_divs[x].innerHTML = quote_author;
                did_aut = true;
            }
        }

        if((did_msg) && (did_aut)) { 

            quoteObj.style.display = 'block';

        }
    }