//   Note that some javascripts 
//   dealing with the document object model refer to elements  
//   that can't be evaluated until after the body has finished
//   loading.


//////////////////////////
//global variables go here
//////////////////////////

var fullHeight = "123";
var fullWidth = "456";
var FontWeightGlobalVar = '';
var FontSizeGlobalVar = '';
var BorderGlobalVar = '';
var PaddingGlobalVar = '';
var NeedRefresh = '0';
var oldcolor = '3333aa';
checkBrowser();
window.onerror = stopError;


////////////////////////////////////////////////
// Trap javascript browser compatibility errors
function stopError() 
  {
  return true;
  }

function reloadHome() 
  {
  location.reload();
  }

/////////////////////////////
function getSizes()
  {
  fullHeight = document.all.OuterBorderTable.offsetHeight;
  fullWidth = document.all.OuterBorderTable.offsetWidth;
  alert('fullWidth X fullHeight: ' + fullWidth + ' X ' + fullHeight);
  }

////////////////////////////////
function onColor(blah)
	{
		//blah.style.backgroundColor='9999ff';
		blah.style.backgroundColor='eeeeff';
	}
function offColor(blah)
	{
		blah.style.backgroundColor='ddddff';
	}
function onColor2(blah)
	{
		blah.style.backgroundColor='6699ff';
	}
function offColor2(blah)
	{
		blah.style.backgroundColor='333399';
	}

//////////////////////////////////
function color(my,newcolor,newtextcolor)
  {
  my.style.backgroundColor=newcolor;
  my.style.color=newtextcolor;
  }

//////////////////////////////

///////////////////////////////
function Over(blah)
	{
    oldcolor = blah.style.color;
    blah.style.color='#9999cc';
	}
function Out(blah)
	{
    blah.style.color=oldcolor;
	}

///////////////////////////////
function changeclass(blah, classname)
	{
		blah.className=''+classname;
	}


// Needed for ToggleVisibility function
function getStyleClass (className) {
  if (document.all) {
    for (var s = 0; s < document.styleSheets.length; s++)
      for (var r = 0; r < document.styleSheets[s].rules.length; r++)
        if (document.styleSheets[s].rules[r].selectorText == '.' + className)
          return document.styleSheets[s].rules[r];
  }
  else if (document.getElementById) {
    for (var s = 0; s < document.styleSheets.length; s++)
      for (var r = 0; r < document.styleSheets[s].cssRules.length; r++)
        if (document.styleSheets[s].cssRules[r].selectorText == '.' + className)
          return document.styleSheets[s].cssRules[r];
  }
  return null;
}

// Craig's new version of ToggleVisibility
function ToggleVisibility (className)
	{
	var myClass = getStyleClass(className);
	if (document.all)
		{
		if(myClass.style.display == 'none')
			{
			myClass.style.display = '';
			} 
		else 
			{
			myClass.style.display = 'none';
			}
		} 
	else if (document.getElementById)
		{
		if(myClass.style.display == 'none')
			{
			myClass.style.display = 'block';
		    } 
		else 
			{
			myClass.style.display = 'none';
			}
		}
	}

///////////////////////////////////
// BROWSER TEST
// See http://www.it97.de/JavaScript/JS_tutorial/bstat/navobj.html and
// http://www.it97.de/JavaScript/JS_tutorial/bstat/Browseraol.html
// for detailed lists of userAgent strings.
function checkBrowser()
  {
	// convert all characters to lowercase to simplify testing
  var agt=navigator.userAgent.toLowerCase();

  // *** BROWSER VERSION ***
  // Note: On IE5, these return 4, so use is_ie5up to detect IE5.
  var is_major = parseInt(navigator.appVersion);
  var is_minor = parseFloat(navigator.appVersion);
  var is_ie     = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
  var is_ie3    = (is_ie && (is_major < 4));
  var is_ie4    = (is_ie && (is_major == 4) && (agt.indexOf("msie 4")!=-1) );
  var is_ie4up  = (is_ie && (is_major >= 4));
  var is_ie5    = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.0")!=-1) );
  var is_ie5_5  = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.5") !=-1));
  var is_ie5up  = (is_ie && !is_ie3 && !is_ie4);
  var is_ie5_5up =(is_ie && !is_ie3 && !is_ie4 && !is_ie5);
  var is_ie6    = (is_ie && (is_major == 4) && (agt.indexOf("msie 6.")!=-1) );
  var is_ie6up  = (is_ie && !is_ie3 && !is_ie4 && !is_ie5 && !is_ie5_5);
//
//  try relaxing this constraint and see what happens
//  if (!is_ie5up)
//    {
////    window.location.href = "upgrade.htm";
//    }
  }


/////////////////////////////////////////////
// function launch(launchURL)
// Launches a new window positioned just 
// down and to the right of the current window.
// The new window will extend down to the bottom
// of the current window and will be as wide as
// the current window. If that means the new window
// would go off the right side of the screen,
// it is made narrower to fit.
// Soon I'll make it move left before narrowing.
// 
// if parameter newWin == '_blank' then we 
// will not close the previous launched window
// before opening a new one. If we're trying to 
// open a second copy of the same document, 
// winName will be the same, so we'll just bring
// the old window to the top.

function launch(launchURL,winName,newWin) {

self.name = "windowopener";
//alert('Arrived at Launch function with URL: ' + launchURL);
// we use this same code for medbot, which needs an interim message page
// but that message page is not needed for a clean launch of a new site
//launchURL = "medbotwindow.htm?" + escape(launchURL);

// Set up size and position for new window
var newx = 300, newy = 0; // default locations for new window
var neww = 600, newh = 400; // default sizes for new window

if (window.screen) {
   screenh = screen.availHeight-10;   // use this if you want full height
   screenw = screen.availWidth-10;
   }

// ie6 in default mode
if (document.documentElement && document.documentElement.offsetHeight) {
  orgx = window.screenLeft ;     // position of inner display window of browser
  orgy = window.top.screenTop ;  // position of inner display window of browser
  orgw = document.documentElement.offsetWidth;
  orgh = document.documentElement.offsetHeight;
  }
// ie4/5 and ie6 in compat mode
else if (document.body) {
   orgx = window.screenLeft ;     // position of inner display window of browser
   orgy = window.top.screenTop ;  // position of inner display window of browser
   orgw = document.body.offsetWidth;
   orgh = document.body.offsetHeight;
   }
// netscape
else if (document.layers) {
   orgx = window.screenX;
   orgy = window.screenY;
   orgw = window.outerWidth;
   orgh = window.outerHeight;
   }
// unknown
 else {
  orgw = 600;
  orgh = 400;
  orgx = 0;
  orgy = 0;
 }
   
//alert('screenh: ['+screenh+']\n orgh: ['+orgh+']');

if (orgh > screenh) {
  orgh = screenh - orgy;
  }

   // try to offset slightly right and down (up from the inner position)
   newx = orgx + 20;
   newy = orgy - 50;

   // but shift back to the left if needed to get 770 width
	availWidthToRight = screenw-newx;
	if (availWidthToRight < 770) {
		deficit = 770-availWidthToRight;
		newx=newx-deficit;
		if (newx < 0) {
			newx=0;
		}
	}

   // set new window 760 wide x height of main window, 
   // or if available screen is less than 770, set as wide as possible   
   neww = (screenw-newx>770)?770:screenw-newx;
   newh = orgh - 100;

if ((window.remotewin) && (newWin!='_blank')) {
   remotewin.close();
   }

remotewin = window.open(launchURL,winName,'width='+neww+',height='+newh+',top='+newy+',screenY='+newy+',left='+newx+',screenX='+newx+",channelmode=0,dependent=0,directories=0,fullscreen=0,location=1,menubar=1,resizable=1,scrollbars=1,status=1,toolbar=1");

if (remotewin.opener == null)
	{
	remotewin.opener = windowopener;
	}
remotewin.focus();

} 
// end function launch

//////////////////////////////
function changeto(highlightcolor)
  {
  source=event.srcElement
  if (source.tagName=="TR"||source.tagName=="TABLE")
  return
  while(source.tagName!="TD")
  source=source.parentElement
  if (source.style.backgroundColor!=highlightcolor&&source.id!="ignore")
  source.style.backgroundColor=highlightcolor
  }

///////////////////////////
function changeback(originalcolor)
  {
  if (event.fromElement.contains(event.toElement)||source.contains(event.toElement)||source.id=="ignore")
  return
  if (event.toElement!=source)
  source.style.backgroundColor=originalcolor
  }

///////////////////////////
function NewWindow(page, specs, w, h, scroll) 
  {
  window.name = 'main_page';
  var winl = (screen.width - w) / 2;
  var wint = (screen.height - h) / 2;
  winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable'
  win = window.open(page, specs, winprops)
  if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
  }

////////////////////
function swfWin(URL) 
  {
  openwin=window.open(URL,"swf_page","toolbar=0,resizable=1,menubar=0,top=20,left=20");
  }

///////////////////
function newSite() 
  {
  if (navigator.appName == 'Netscape') 
  newWin=window.open("demo_netscape.htm","popup","height=200, width=570, toolbar=0, menubar=0, scrollbars=1, resizable=1,copyhistory=0,location=0,status=0,directories=0");
  else if (navigator.appName == 'Microsoft Internet Explorer')
  location.href = 'demo.htm';
  }
  
// Used in the old version of ncemi
// ** Kill these as soon as possible **
function AlertIt(TheMessage)
{
alert("ANSWER: \n" + TheMessage);
}

function AlertItWindow(TheMessage)
{
remote = window.open("", "remotewin", "width=200,height=200,scrollbars");
if (remote.opener == null) remote.opener = window;
remote.opener.name = "opener";
remote.document.open();
remote.document.writeln("<HTML>");
remote.document.writeln("<HEAD><TITLE>");
remote.document.writeln("Answer!");
remote.document.writeln("</TITLE></HEAD>");
remote.document.writeln("<BODY bgcolor=#C6EFF7>");
remote.document.writeln(TheMessage);
remote.document.writeln("</BODY>");
remote.document.writeln("</HTML>");
remote.document.close();
remote.focus();
}

///////////////////////////////
// end of javascript functions
///////////////////////////////
// onLoad="javascript:getSizes();"
//-->
//</SCRIPT>
<!------------------------------------------------------->
<!-- This is the end of the javascript basefile. -------->
<!------------------------------------------------------->

