/****************************************************************************
Basic JavaScript Function Library that holds functions common to all pages
in a Web site. 

Copyright (c) 2003 Robert Plates All Rights Reserved.

****************************************************************************/

/****************************************************************************
****************************************************************************/
function IEBrowser()
{
  if (navigator.appName.indexOf("Microsoft") != -1)
    return true;
  else
    return false;
}

/****************************************************************************
****************************************************************************/
function getListSelectionValue(theObj)
{
   for(var s=0; s<theObj.length; s++)
      if(theObj[s].selected)
         return theObj[s].value;
}


/****************************************************************************
****************************************************************************/
function getListSelectionText(theObj)
{
   for(var s=0; s<theObj.length; s++)
      if(theObj[s].selected)
         return theObj[s].text;
}


/****************************************************************************
****************************************************************************/
function getSelectedRadioButton(theObj)
{
   for(var s=0; s<theObj.length; s++)
      if(theObj[s].checked)
         return theObj[s].value;
}

/****************************************************************************
****************************************************************************/
function OpenWin(sUrl, Height, Width, Top, Left, Name)
{
    var MyHeight;
    var MyWidth;
    var MyTop;
    var MyLeft;
    var Features;
    var WinName;

    //Capture the Window Name or Set the Default
    if(Name==null)
        {WinName="GenWindow";}
    else
        {WinName=Name;}

	// Capture the Height or Set the Default
  	if(isNaN(parseInt(Height)))	
		{
		//window.alert("No Height Given."); //For Testing Only
		//Set a Default Height
		MyHeight=250;
		}
	else
		MyHeight=Height;
	// Capture the Width or Set the default
	if(isNaN(parseInt(Width)))
		{
		//window.alert("No Width Given."); //For testing Only
		MyWidth=500;
		}
	else
		MyWidth=Width;

	//Calculate the Top Value
	if(isNaN(parseInt(Top)))
		MyTop=(screen.height-MyHeight)/2;
	else
		MyTop=Top;

	//Calculate Left Value
	if(isNaN(parseInt(Left)))
		MyLeft=(screen.width-MyWidth)/2;
	else
		MyLeft=Left;

	//For testing Only
	//alert("Top=" + MyTop + "\nLeft=" + MyLeft + "\nHeight=" + MyHeight + "\nWidth=" + MyWidth);
  	if (IEBrowser())
		{
		Features="height=" + MyHeight + ", width=" + MyWidth + ", left=" + MyLeft + ", top=" + MyTop+", resizeable=yes";
		}
	else
		{
		Features="height=" + MyHeight + ",width=" + MyWidth + ",screenX=" + MyLeft + ",screenY=" + MyTop+",resizeable=yes";
		}
        return window.open(sUrl, WinName, Features);
}

/****************************************************************************
****************************************************************************/
function OpenScrollWin(sUrl, Height, Width, Top, Left, Name)
{
    var MyHeight;
    var MyWidth;
    var MyTop;
    var MyLeft;
    var Features;
    var WinName;

    //Capture the Window Name or Set the Default
    if(Name==null)
        {WinName="GenWindow";}
    else
        {WinName=Name;}

	// Capture the Height or Set the Default
  	if(isNaN(parseInt(Height)))	
		{
		//window.alert("No Height Given."); //For Testing Only
		//Set a Default Height
		MyHeight=250;
		}
	else
		MyHeight=Height;
	// Capture the Width or Set the default
	if(isNaN(parseInt(Width)))
		{
		//window.alert("No Width Given."); //For testing Only
		MyWidth=500;
		}
	else
		MyWidth=Width;

	//Calculate the Top Value
	if(isNaN(parseInt(Top)))
		MyTop=(screen.height-MyHeight)/2;
	else
		MyTop=Top;

	//Calculate Left Value
	if(isNaN(parseInt(Left)))
		MyLeft=(screen.width-MyWidth)/2;
	else
		MyLeft=Left;

	//For testing Only
	//alert("Top=" + MyTop + "\nLeft=" + MyLeft + "\nHeight=" + MyHeight + "\nWidth=" + MyWidth);
  	if (IEBrowser())
		{
		Features="height=" + MyHeight + ", width=" + MyWidth + ", left=" + MyLeft + ", top=" + MyTop + ", scrollbar=yes, resizeable=yes";
		}
	else
		{
		Features="height=" + MyHeight + ",width=" + MyWidth + ",screenX=" + MyLeft + ",screenY=" + MyTop + ",scrollbar=yes,resizeable=yes";
		}
        return window.open(sUrl, WinName, Features);
}

/*******************************************************************************************************************
*******************************************************************************************************************/
function setElementText(sElementID, sTextToDisplay)
{
	if(sElementID=="")
		return;
	var el=document.getElementById(sElementID);
	if(el==undefined)
		return;
	if(el.type=="text" || el.type=="hidden")
		el.value=sTextToDisplay;
	else
		el.innerHTML=sTextToDisplay;
}

/*******************************************************************************************************************
*******************************************************************************************************************/
function setElementStyle(sElementID, sStyleAttribute, sStyleValue)
{
	if(sElementID=="")
		return;
	var el=document.getElementById(sElementID);
	if(el==undefined)
		return;
	switch(sStyleAttribute.toLowerCase())
		{
		case "display":
			el.style.display=sStyleValue.toLowerCase();
			break;
		case "visibility":
			el.style.visibility=sStyleValue.toLowerCase();
			break;
		case "font-size":
			el.style.fontSize=sStyleValue.toLowerCase();
			break;
		case "font-weight":
			el.style.fontWeight=sStyleValue.toLowerCase();
			break;
		}
}

/*******************************************************************************************************************
*******************************************************************************************************************/
function getElementName(sElementID)
{
	if(sElementID=="")
		return;
	var el=document.getElementById(sElementID);
	return el.name;
}

/*******************************************************************************************************************
*******************************************************************************************************************/
function getElementText(sElementID)
{
	if(sElementID=="")
		return "";
	var el=document.getElementById(sElementID);
	if(el==undefined)
		return "";
	else
		{
		if(el.type=="text" || el.type=="hidden")
			return el.value;
		else
			return el.innerHTML;
		}
}

/*******************************************************************************************************************
*******************************************************************************************************************/
function loadXMLString(txt) 
{
try //Internet Explorer
  {
  xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
  xmlDoc.async="false";
  xmlDoc.loadXML(txt);
  return xmlDoc; 
  }
catch(e)
  {
  try //Firefox, Mozilla, Opera, etc.
    {
    parser=new DOMParser();
    xmlDoc=parser.parseFromString(txt,"text/xml");
    return xmlDoc;
    }
  catch(e) {alert(e.message)}
  }
return null;
}