/*
**  site.js   -   site-wide Javascript code for TheSoftwareMaster.com
**
**    Usage:
**      This file should be included for each Javascript file that 
**      uses the createXmlDoc() function, the xmlhttp global obj,
**      or any of the included utility functions for manipulation 
**      of the XML or XHTML DOM, respectively.
**
**    paul@thesoftwaremaster.com 2009-12-15
*/
/*
** ************************************************************************
**  XML DOM functions 
** ************************************************************************
*/
var xmlhttp = null;
/* 
**  function xmlCreateDoc() 
**
**     Set the xmlhttp global object variable and return it.
*/
function xmlCreateDoc()
{
    if (window.XMLHttpRequest)
    {// code for IE7, Firefox, Mozilla, etc.
	xmlhttp=new XMLHttpRequest();
    }
    else if (window.ActiveXObject)
    {// code for IE5, IE6
	xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
    if (xmlhttp==null)
    {
	alert("Your browser does not support XMLHTTP.");
	return false;
    }
    return true;
}
/*
**  function xmlFirstElemByName(tn) 
**
**    Returns a reference to the first element in the XML document object 
**    which has tag name T or null if no such element exists
*/
function xmlGetFirstElemByName(T)
{
    var elem = null;
    elem=xmlhttp.responseXML.documentElement.getElementsByTagName(T)[0];
    return elem;
}
/*
**  function xmlGetElemById(id)
**
**     Returns a reference to the XML document object which has 
**     the ID attribute set to id.
*/
function xmlGetElemById(id)
{
    var elem = null;
   
    try 
    {
	elem = xmlhttp.getElementById(id)
    }
    catch(er) 
    { 
	alert("xmlGetElemById("+id+"): "+er) 
    }
    return elem;
}
/*
** ************************************************************************
**  HTML DOM functions 
** ************************************************************************
*/
/*
**  htGetElemByID(id)
**
**    Returns a reference to the HTML document object element which has 
**    ID attribute set to id, or null if no such object exists
*/
function htGetElemByID(id)
{
    return document.getElementById(id);
}
/* 
**  function jsWindowWidth()
**
**    From the example at 
**      http://www.tipsntutorials.com/tips/Javascript/44
**
**    This functino returns the interior width of the current browser
**    window in either "Netscape" or IE.  The navigator.appName should
**    probably include "Mozilla" somewhere...
*/
function jsWindowWidth()
{
    if(navigator.appName == "Netscape") 
    {  
	return( window.innerWidth );
    } 
    else if(navigator.appName == "Microsoft Internet Explorer") 
    {  
	return( document.body.clientWidth );
    }
    return null;
}

