
//www.yourhtmlsource.com/javascript/advanceddoms.html   DOM overview
//www.mozilla.org/docs/dom/domref/dom_shortTOC.html   DOM reference

var gRoot = ""; // Prefix for converting base url of calling page so that all url's are relative to server root

function BrowserCompatibility()
{
	if (document.getElementById || document.all || document.layers)
		{
  		if (document.getElementById) {
    		// Level 1 DOM code
   			}
   		else if (document.all) {
    		// Microsoft DOM code
   			}
   		else if (document.layers) {
    		// Netscape DOM code
   			}
		}
}

function InitContents(Root, Linkid)
{
	gRoot = Root;
	document.Linkid = Linkid;
	
	Links = document.getElementsByName(Linkid);
	Images = document.getElementsByName(Linkid + "_img");
	
	Links[0].className = "selected_link";
	Images[0].src = gRoot + "images/nav_bullet_select.gif";
	
	if(Links.length == 2)
		{Links[1].className = "selected_link";
		Images[1].src = gRoot + "images/nav_bullet_select.gif";}
}

function MouseOverLink(Linkid, text)
{
	if(document.Linkid != Linkid)
		{
		Links = document.getElementsByName(Linkid);
		Images = document.getElementsByName(Linkid + "_img");

		Links[0].className = "mouseover_nlink";
		Images[0].src = gRoot + "images/nav_bullet_mouseover.gif";

		if(Links.length == 2)
			{Links[1].className = "mouseover_nlink";
			Images[1].src = gRoot + "images/nav_bullet_mouseover.gif";}
		}
		
	window.status = text;
}

function MouseOutLink(Linkid)
{
	if(document.Linkid != Linkid)
		{
		Links = document.getElementsByName(Linkid);
		Images = document.getElementsByName(Linkid + "_img");

		Links[0].className = "normal_link";
		Images[0].src = gRoot + "images/nav_bullet.gif";

		if(Links.length == 2)
			{Links[1].className = "normal_link";
			Images[1].src = gRoot + "images/nav_bullet.gif";}
		}
		
	window.status = "";		
}

function FocusLink(text)
{
	window.status = text;
}

function SelectLink(Linkid)
{
	// Change previous selection back to normal
	OldLinks = document.getElementsByName(document.Linkid);
	OldImages = document.getElementsByName(document.Linkid + "_img");

	OldLinks[0].className = "normal_link";
	OldImages[0].src = gRoot + "images/nav_bullet.gif";
	
	if(OldLinks.length == 2)
		{OldLinks[1].className = "normal_link";
		OldImages[1].src = gRoot + "images/nav_bullet.gif";}
		
	// Show new selection	
	SelLinks = document.getElementsByName(Linkid);
	SelImages = document.getElementsByName(Linkid + "_img");

	SelLinks[0].className = "selected_link";
	SelImages[0].src = gRoot + "images/nav_bullet_select.gif";
	
	if(SelLinks.length == 2)
		{SelLinks[1].className = "selected_link";
		SelImages[1].src = gRoot + "images/nav_bullet_select.gif";}
		
	document.Linkid = Linkid;
}

function MouseOverDirLink(Link, Header)
{
	if(Header == true)
		{Link.className = "mouseover_dirhlink";}
	else
		{Link.className = "mouseover_dirlink";}
}

function MouseOutDirLink(Link, Header)
{
	if(Header == true)
		{Link.className = "normal_dirhlink";}
	else
		{Link.className = "normal_dirlink";}
}

function GoToTopic(Topic)
{
// www.codeproject.com/jscript/autoselect.asp?select1=Value1#Example

	var index = Topic.selectedIndex;
	var value = Topic.options[index].value;
	window.status = value;
	location.href = value;
	
	return true;

}

function ChangeSize(Select)
{
	Select.length=4;
}

function ViewText(Textid, Option)
{
	// Ref: http://aspnet.4guysfromrolla.com/articles/091504-1.aspx   Collapsible regions
	
	var bButton;
	ButtonText = new Array(2);
	var ButtonObject;
	var TextObject = document.getElementById(Textid);
	var bBtnComment;
	BtnComment = new Array(2);
	var BtnCommentObject;
	
	switch(Textid)
		{
		case "DirViewingTips":
		
			bButton = true;
			bBtnComment = true;
			ButtonObject = document.getElementById(Textid + "_btn");
			ButtonText[0] = "Show Viewing Tips";
			ButtonText[1] = "Hide Viewing Tips";
			BtnCommentObject = document.getElementById(Textid + "_btncmt");
			BtnComment[0] = " First time visitors should click button.";
			BtnComment[1] = ""; 
			break;
			
		case "InfoCtrOverview":
		
			bButton = true;
			bBtnComment = true;
			ButtonObject = document.getElementById(Textid + "_btn");
			ButtonText[0] = "Show Overview";
			ButtonText[1] = "Hide Overview";
			BtnCommentObject = document.getElementById(Textid + "_btncmt");
			BtnComment[0] = " First time visitors should click button.";
			BtnComment[1] = ""; 
			break;
			
		case "PrivacyPolicy":
		
			bButton = true;
			bBtnComment = false;
			ButtonObject = document.getElementById(Textid + "_btn");
			ButtonText[0] = "Privacy Policy";
			ButtonText[1] = "Hide Policy";
			break;
			
		default:
		
			bButton = false;
			bBtnComment = false;
			break;
		}

	if(Option == "Show" || (Option == "Toggle" && TextObject.style.visibility == "hidden"))
		{TextObject.style.display = "block";
		TextObject.style.visibility = "visible";
		
		if(bButton)
			{ButtonObject.value = ButtonText[1];}
			
		if(bBtnComment)
			{BtnCommentObject.firstChild.nodeValue = BtnComment[1];}
		}
			
	else
		{TextObject.style.display = "none";
		TextObject.style.visibility = "hidden";
		
		if(bButton)
			{ButtonObject.value = ButtonText[0];}
			
		if(bBtnComment)
			{BtnCommentObject.firstChild.nodeValue = BtnComment[0];}
		}
}

function WriteText(Textid, html)
{
	document.getElementById(Textid).innerHTML=html;
}
