/* 
**  services.js  - Javascript for TheSoftwareMaster.com Services page 
**   paul@thesoftwaremaster.com  2009-12-17
*/
var normcolor = '#000000';
var highcolor = '#aa0000';
/* current list item element object reference */
var curr;

/*
**   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(" ");
    for(i=0;i<temp.length;i++) {	
	if ( temp[i].indexOf('&') != -1 ) {
	    temp[i] = "";
	}
    }
    s = temp.join("");
//    s = s.substring(0,5);
    s = s.toLowerCase();
    return s;
}

function displayDynamicContent(elem)
{
    if ( xmlCreateDoc() == false )
    {
	alert("Could not create XML Request Document");
	return;
    }
    s = strToXmlBaseFn( elem.innerHTML );
    url = "xml/services/"+s+".xml";
    url=url+"?"+Math.random()+"="+Math.random();

    // set the XMLResponse handler
    xmlhttp.onreadystatechange = function () {
	/*
            **  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.
            */
	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); }
    } // end of onResponse function 

    // send the GET request for the URL constructed above
    xmlhttp.open("GET",url,true); 
    xmlhttp.send(null);
    
}


function liOnMouseOver()
{
    displayDynamicContent(this);
}
function liOnMouseOut()
{
}

/* 
** ***************************************************** 
**
**  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 = liOnMouseOver;
    x[i].onmouseout = liOnMouseOut;
}

