//v1.13
//Copyright 2006 Nick Newton. All rights reserved.

var http_request = new Array();
var xmldoc = new Array();
var root_node = new Array();

//parameters defined onClick
//index = instance of variable set - must be different for each callXml on an event
//url = source of XML, tag_name = tag to look for in XML, item_num = number of tag instance, target = div to load to
function callXml(index, url, tag_name, item_num, target ) 
{
    http_request[index] = false;
    
    if (window.XMLHttpRequest) // Mozilla, Safari,...
    { 
        http_request[index] = new XMLHttpRequest();
        if (http_request[index].overrideMimeType) //name mime type if possible
        {
            http_request[index].overrideMimeType('text/xml');
        }
    } 
    else if (window.ActiveXObject) //IE...
    { 
        try 
        {
        http_request[index] = new ActiveXObject("Msxml2.XMLHTTP");
        } 
        catch (e) 
        {
            try 
            {
                http_request[index] = new ActiveXObject("Microsoft.XMLHTTP");
            } 
            catch (e) 
            {}
        }
    }
	if (!http_request[index]) //no support...
    {
        alert('Please update your browser.');
        return false;
    }
    http_request[index].open('GET', url, true); //true = asynchronous load
    http_request[index].onreadystatechange = function() {loadContents(item_num, tag_name, target, index)};
    http_request[index].send(null);
}

function loadContents(item_num, tag_name, target, index) //load contents to div from XML
{
    if (http_request[index].readyState == 4) //ready state = loaded
    {
        if (http_request[index].status == 200 || http_request[index].status == 0) //status = OK
        {
            xmldoc[index] = http_request[index].responseXML;
            root_node[index] = xmldoc[index].getElementsByTagName(tag_name).item(item_num); //define XML item
            document.getElementById(target).innerHTML = root_node[index].firstChild.data; //get and place XML item into HTML
        } 
        else //status != OK
        {
            alert('Request error '+http_request[index].status+'. If problem persists, contact your network administrator.');
			//who is this "network administrator," anyway? 
        }
    }
	//initiates scrollbar script based on amount of text being loaded
	initScrollLayer();
}