
//This path is used to connect to the Web Service by other javascript files.
var WebServicePath = "http://" + document.location.host + "/MessageWebService/";



//reloads the window if Nav4 resized
function MM_reloadPage(init)
{  
  if (init==true) with (navigator) 
  {
    if ((appName=="Netscape")&&(parseInt(appVersion)==4)) 
      {
        document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage;
      }
  }
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) 
    location.reload();
}
MM_reloadPage(true);



//This function reads the contents of the Main Body.  
//Then builds a new window with the contents and is sent a print command.
function PrintPage()
{
	var startMainBody = document.body.innerHTML.indexOf("InstanceBeginEditable name=\"Main Body\"") - 5;
	var beefMainBody = document.body.innerHTML.substring(startMainBody, document.body.innerHTML.indexOf("InstanceEndEditable", startMainBody) - 5);
	while(beefMainBody.toUpperCase().indexOf("<SCRIPT") > 0)
	{
		var startTagPos =	beefMainBody.toUpperCase().indexOf("<SCRIPT");
		var endTagPos =	beefMainBody.toUpperCase().indexOf("</SCRIPT>", startTagPos);
		beefMainBody = beefMainBody.substring(0, startTagPos) + beefMainBody.substring(endTagPos + 9);
	}
	var printWin = window.open("", "");

	printWin.document.open("text/html");
	printWin.document.write(beefMainBody);
	printWin.document.close();
	printWin.print();
	printWin.close();  //If you don't want the window to close automatically when done printing, take this line out.
}



//This is function is used for any links that go external to our website.
//It displays an intermediate disclaimer page that redirects to the request url.
function GoExternal(link)
{
  window.location.href = "/goexternal.html?"+link;  
}



//This function is used for the expandable menus.
//It toggles the list's display property.
function toggle(list, force)
{
  var openMenuValues = document.getElementById("openMenus");
  var listElementStyle=document.getElementById(list).style; 
  if (force == true  || listElementStyle.display=="none")
  { 
    listElementStyle.display="block"; 
    if( openMenuValues.value.indexOf(list) == -1)
       openMenuValues.value += list + ";";
  }
  else
  { 
    listElementStyle.display="none"; 
    var valueParts = openMenuValues.value.split(list + ";");
    openMenuValues.value = "";
    for(var z=0; z < valueParts.length; z++)
      openMenuValues.value += valueParts[z];
  } 
} 



//This function is used for the expandable menus.
//It toggles all menus to either all be expanded or all closed.
function ToggleAll()
{
 var openMenuValues = document.getElementById("openMenus");
 var MaxListSize = 50;
 var ToggleLink;
 var DisplayChange;
 if(window.event == undefined)
  ToggleLink = arguments.callee.caller.arguments[0].target;
 else
  ToggleLink = window.event.srcElement;

 if(ToggleLink.innerHTML == "Expand All")
 {
   ToggleLink.innerHTML = "Collapse All";
   DisplayChange = "block";
 }
 else
 {
   ToggleLink.innerHTML = "Expand All";
   DisplayChange = "none";
 }
 for(var x=1; x < MaxListSize; x++)
 {
   var mainMenu = document.getElementById("menu" + x);
   if(mainMenu != null)
   {
     document.getElementById("menu" + x + "cnt").style.display = DisplayChange;
     if(DisplayChange == "block")
     {
       if( openMenuValues.value.indexOf("menu" + x + "cnt") == -1)
         openMenuValues.value += "menu" + x + "cnt;";
     }
     else
     {
       var valueParts = openMenuValues.value.split("menu" + x + "cnt;");
       openMenuValues.value = "";
       for(var z=0; z<valueParts.length; z++)
         openMenuValues.value += valueParts[z];
     }
     for(var y=1; y < MaxListSize; y++)
     {
       var subMenu = document.getElementById("menu" + x + "sub" + y);
       if(subMenu != null)
       {
          subMenu.style.display = DisplayChange;
          if(DisplayChange == "block")
          {
            if(openMenuValues.value.indexOf("menu" + x + "sub" + y) == -1)
              openMenuValues.value += "menu" + x + "sub" + y + ";";
          }
          else
          {
            var valueParts = openMenuValues.value.split("menu" + x + "sub" + y + ";");
            openMenuValues.value = "";
            for(var z=0; z<valueParts.length; z++)
              openMenuValues.value += valueParts[z];
          }
       }
       else
          break;
     }
   }
   else
     break;
 }
}



//This function is used for the expandable menus.
//It restores the menu back to it's display setting before a link was clicked.
//This is run on the Body onLoad command so that the "backForm" fields are filled.
var netscapebug = 0;
function RestoreMenu()
{
  if(netscapebug == 1)
     return;
  if(document.forms["opnBackForm"] != null)
  {
    RestoreOpinionsMenu();
  }
  else if(document.forms["wnBackForm"] != null || document.forms["jcBackForm"] != null)
  {
	  var msgType = 'wn';
	  if(document.forms["jcBackForm"] != null)
	     msgType = 'jc'
	  var selectedYear = document.getElementById('yearSelect').value;
	  if(selectedYear != 'Current')
	  {
		  document.getElementById('archLink').style.display='none'
		  document.getElementById('archiveForm').style.display='inline'
	  	  initXML(msgType, selectedYear);
	  }
  }
  else
  {
     var openMenuValues = document.getElementById("openMenus");
     var link = new Array();
     link = window.location.href.split('#');
     if (link.length > 1)
	    openMenuValues.value = "";

    var visibleMenus = document.getElementById("openMenus").value.split(";");
    for(var x = 0; x < visibleMenus.length; x++)
    {
      if (visibleMenus[x].length > 0)
      {
        
        toggle(visibleMenus[x]);
      }
    }
  }
  netscapebug++;
}