/* 
**  index.js - Javascript for TheSoftwareMaster.com Home page
*/

var normcolor = '#000000';
var highcolor = '#aa0000';
/* current list item element object reference */
var curr;

/*
**  onResponse()
**
**    The event handler for the XML document object onreadystatechange 
**    event.  The xmlhttp.onreadystatechange handler is set by the 
**    handler for the LI element's onclick or onmouseover event.
**
**    See Also:  function onClickLI(), below
*/
function onResponse()
{
    if(xmlhttp.readyState!=4) return;
    if(xmlhttp.status!=200) {alert("Problem retrieving XML data");return;}
    
    xmlHeadline = xmlGetFirstElemByName("Headline");
    xmlContent = xmlGetFirstElemByName("Content"); 

    htElemHeadline = htGetElemByID('Headline');
    try 
    { 
	htElemHeadline.innerHTML = xmlHeadline.firstChild.nodeValue; 
    }
    catch(er) {	alert("onResponse: "+er); }

    htElemContent = htGetElemByID('Content');
    try
    {
	htElemContent.innerHTML = xmlContent.firstChild.nodeValue;
    }
    catch(er) {	alert("onResponse: "+er); }
}

function displayDynamicContent(elem)
{
    if ( xmlCreateDoc() == false )
    {
	alert("Could not create XML Request Document");
	return;
    }
    s = strToXmlBaseFn( elem.innerHTML );
    switch(s)
    {
    case "accou":
    case "billi":
    case "casem":
    case "conta":
    case "demog":
    case "docum":
    case "human":
    case "inven":
    case "labor":
    case "manyo":
    case "payro":
    case "produ":
    case "sales":
    case "sched":
	url = "xml/"+s+".xml";
	url=url+"?"+Math.random()+"="+Math.random();
	xmlhttp.onreadystatechange=onResponse;
	xmlhttp.open("GET",url,true); 
	xmlhttp.send(null);
	break;	 
    }
}

function onMouseOverLI()
{
    displayDynamicContent(this);
}

/*
**   strToXmlBaseFn(txt) 
**
**     Convert text txt (from the LI element) into 
**     a base filename for the XML file
*/
function strToXmlBaseFn(txt)
{
    var s = "";
    var temp = new Array();
    temp = txt.split(" ");
    s = temp.join("");
    s = s.substring(0,5);
    s = s.toLowerCase();
    return s;
}

/* 
** ***************************************************** 
**
**  Global Code - this code is executed when the script
**  is loaded by the HTML document.
**
** ***************************************************** 
*/
x=document.getElementsByTagName("li"); 

for (i=0;i<x.length;i++)
{
    x[i].onmouseover = onMouseOverLI;
}
