var DFMT = ''; var ACTMN = '';

if 	(document.getElementById)	var DOMS = 3	// Supports Web Standard (getElementById)
else if	(document.all)		 	var DOMS = 2	// Supports MS document.all
else if	(document.layers)	 	var DOMS = 1	// Supports NS layers
else				 	var DOMS = 0;	// No DOM gateway support

function analOut(s) {
  var WANAL = window.open('','ANALYZE','height=400,width=400')
  WANAL.focus();
  WANAL.document.open();
  WANAL.document.write('<pre>' + s + '</pre>');
  WANAL.document.close();
  this.focus;
}

// Return DOM Handle for specified DOM object ID
function getObj(oid) {
  switch(DOMS) {					// Check for various browsers
    case 1: return(document[oid]);			// Supports Layers (NS4)
    case 2: return(document.all[oid]);			// Supports document.all (ie4)
    case 3: return( ((document.getElementById(oid))?document.getElementById(oid):'') );	// Supports getElementById
  }
}

function defLnk(s1,s2,s3) { this.dmf=s1; this.txt=s2; this.url=s3; this.smf=0; if (s1) this.dm = new Object(); }

function nlnk() { return }

// Define navbar menu system:  s = menu object name;  fmt = navbar layout ( 0 = horizontal bar; 1 = vertical bar )
function genNbar(s,fmt) { var OUT1 = '';  var OUT2 = '';  DMNAME = s;  var obj = eval(DMNAME);  DFMT=fmt;
  switch(DOMS) {
     case 0:  { OUT1 = '<div id="BERR">Incompatible browser detected. An up-to-date browser is required to continue.' +
		'&nbsp;&nbsp;<a href="http://home.netscape.com/computing/download/index.html?cp=hophb2">Download Netscape 6</a>' +
		'&nbsp;&nbsp;<a href="http://www.microsoft.com/windows/ie/downloads/ie6/default.asp?FinishURL=%2Fdownloads%2Frelease%2Easp%3Freleaseid%3D32210%26PopList%3D1%26redirect%3Dno">Download IE 6</a></div>';
		break;
              }
     case 1:  { OUT1 = '<div id="BERR">Incompatible browser detected. An up-to-date browser is required to continue.' +
		'&nbsp;&nbsp;<a href="http://home.netscape.com/computing/download/index.html?cp=hophb2">Download Netscape 6</a>' +
		'&nbsp;&nbsp;<a href="http://www.microsoft.com/windows/ie/downloads/ie6/default.asp?FinishURL=%2Fdownloads%2Frelease%2Easp%3Freleaseid%3D32210%26PopList%3D1%26redirect%3Dno">Download IE 6</a></div>';
		break;
              }
     default: { var OUT1 = '<div id="' + DMNAME + '" class="NBAR">\n<table class="NAVBAR" border="0" cellspacing="0" cellpadding="0">' + ((DFMT)?'':'<tr>') + '\n';
                for (var i in obj) {
                    OUT1 += ((DFMT)?'<tr>':'') + '<td nowrap id="' + DMNAME + i + '" class="NB"><a class="' + ((obj[i].url=='')?'HRF':'LNK') + '" onMouseOver="moOver(\'' + DMNAME + '\',\'' + DMNAME + i + '\',0,' + obj[i].dmf + ')" ' +
                    ((obj[i].url=='')?'href ="javascript:nlnk()">':'href ="' + obj[i].url + '">') + obj[i].txt + '</a></td>' + ((DFMT)?'</tr>\n':'\n');

		    if (obj[i].dmf) { OUT2 += genDmenu(DMNAME + i,obj[i],fmt,1); }
                }
                OUT1 += ((DFMT)?'':'</tr>') + '\n</table></div>\n'
              }
  }
  document.write( ((0)?'<plaintext>':'') + '<div id="' + DMNAME + '_c' + '" class="NBC" onMouseOut="closeAll(event,\'' + DMNAME + '_c' + '\')">' + OUT1 + '\n<div id="DMAR" style="position:absolute;">\n' + OUT2 + '\n</div>\n</div>\n');
}

function genDmenu(Pid,Pobj,fmt,z) { var Dobj = Pobj.dm;  var Did = Pid + 'D';
  var OUT1 = '\n<div id="' + Did + '" style="visibility:hidden;" class="DM"' + ( (z==1) ? ' onMouseOut="closeAll(event,\'' + Did + '\')"' : '') + '>\n' +
             '<table id="' + Did + 'T' + '" class="DMT" border="0" cellspacing="0" cellpadding="0">\n'
  var OUT2 = '';
  for (var i in Dobj) {
       OUT1 += '<tr><td nowrap id="' + Did + i + '" class="NB"><a class="' + ((Dobj[i].url=='')?'HRF':'LNK') + '" onMouseOver="moOver(\'' + DMNAME + '\',\'' + ((Dobj[i].dmf)?Did + i:Pid) + '\',' + ((Dobj[i].dmf)?1:fmt) + ',' + Dobj[i].dmf + ')" ' +
               ((Dobj[i].url=='')?'href ="javascript:nlnk()">':'href ="' + Dobj[i].url + '">') +
                 Dobj[i].txt + ((Dobj[i].dmf)?'&nbsp&nbsp =>':'') + '</a></td></tr>\n'
       if (Dobj[i].dmf) { Pobj.smf=1 ;  OUT2 += genDmenu(Did+i,Dobj[i],1,++z); }
  }
  OUT1 += "</table>";
  return(OUT1 + OUT2 + '</div>\n')
}

// Position DOM object:  obj = DOM object handle;  x = left coord;  y = top coord.
function setPos(obj,x,y) {
  switch(DOMS) {
    case 1:  obj.moveTo(x,y);			    break;	// NS 4
    default: obj.style.left = x; obj.style.top = y; break;	// IE4+,NS6+
  }
}

// Set DOM object visibility:  obj = DOM object handle;  s = visibility option
function setVis(obj,s) {
  switch(DOMS) {
    case 1:  obj.visibility       = s; break;		// layers
    default: obj.style.visibility = s; break;		// IE4+ and NS6+
  }
}

// Return display area of specified DOM object in format 'left : top : right : bottom
function getPos(obj,f) { 
  switch(DOMS) {
     case 1:  { var X = obj.pageX;  var Y = obj.pageY;  var W = obj.clip.width; var H = obj.clip.height;  break; } 
     default: { var X = obj.offsetLeft;   var Y = obj.offsetTop;
		var W = obj.offsetWidth;  var H = obj.offsetHeight;
                break;
              }
  }
  return( X + ':' + Y + ":" + W + ":" + H );
}


function getOff(oid) { var X = 0; var Y = 0;
  Oar = oid.split('D');					// Get menu array
  for (var i in Oar) {					// Process each menus
       Oar[0] += ((i>0)?Oar[i]:'') + 'D';		// Define current menu id
       obj = getObj(Oar[0]) 				// Get menu obj handle
       X += obj.offsetLeft;       			// Get X offset
  }
  return(X)
}

// Process mouseover: oid = mouse over object id;  f = object type (0=nav bar, 1=drop down)
function moOver(NID,oid,f,df) {
  if (oid == ACTMN) return;
  Aar = ACTMN.split('D');				// Get current submenu array
  Oar = oid.split('D');					// Get mouse over submenu array
  if (Aar[0]!='') {					// Hide existing menu list
     for (var i in Aar) {				// Process each menus
       Aar[0] += ((i>0)?Aar[i]:'') + 'D';		// Define current menu id
       Oar[0] += ((i>0)?Oar[i]:'') + 'D';		// Define new menu ID
       if (Aar[0] != Oar[0]) {				// if IDs don'ts match AND old ID exists
           var obj = getObj(Aar[0])
           if (obj != '') {
		setVis(obj,'hidden');     		// If different, hide menu current menu
        	setPos(obj,0,0)
           }
       }
     }
  }
  //  if ( ACTMN.indexOf(oid+'D') == 0 ) return;
  ACTMN = oid;						// Remember active menu id

  if (df) {
     MAXWD = getObj(NID).offsetWidth			// Total NAVBAR width
     var obj    = getObj(oid);				// Get button DOM handle
     var Xoff   = getOff(oid); 				// Get total X offset to mouseover button
     var pos    = getPos(obj,f);			// Get coords for mouseover object
     pa         = pos.split(':');			// Parse coords into array
     var soid   = oid+'D';				// Def. submenu ID
     var sobj   = getObj(soid);				// Get submenu DOM handle
     var stoid  = oid+'DT';				// Def. submenu table ID
     var stobj  = getObj(stoid);			// Get submenu table DOM handle
     var spos   = getPos(stobj,f);			// Get coords for mouseover object
     ps         = spos.split(':');			// Parse coords into array
     var stpos  = getPos(stobj,f);			// Get coords for mouseover object
     pst       = spos.split(':');			// Parse coords into array
   
     // (f=0) Set submenu position to navbar;  (f=1) Set submenu position to parent submenu
     if (f==0) setPos(sobj,((MAXWD<(parseInt(pa[0])+parseInt(pst[2])))?parseInt(pa[0])+parseInt(pa[2])-parseInt(pst[2]):pa[0]),pa[1] )		
     else      setPos(sobj,((MAXWD<(Xoff+parseInt(pa[2])+parseInt(pst[2])))?parseInt(pa[0])-parseInt(pst[2]):pa[2]),pa[1] )
   
     ACTMN = oid;					// Remember active menu id
     setVis(sobj,'visible')				// Display submenu
   }
return
}

// Return true if node a contains node b.
function contains(a, b) { if (b==null) return;
  while (b.parentNode) {
	b = b.parentNode;
	if (b.id == a) return true;
  }
  return false;
}

function closeAll(event,mid,f) {
  if (ACTMN=='') return;
  var related = ( (window.event) ? window.event.toElement : event.relatedTarget )
  if (contains(mid, related)) return;
  Aar = ACTMN.split('D');				// Get current submenu array
  for (var i in Aar) {					// Process each menus
      Aar[0] += ((i>0)?Aar[i]:'') + 'D';		// Define current menu id
      var obj = getObj(Aar[0])
      if (obj != '') {
	 setVis(obj,'hidden');				// If different, hide menu current menu
         setPos(obj,0,0)
      }
  }    
  ACTMN = '';
}

// Reset input field color when changed
function fldReset() { this.style.backgroundColor=''; this.style.borderColor='#bbbbbb'; }

// display error message, color error field, set 
function setErm(f,m) {
  alert(m);
  f.onchange = fldReset;
  f.style.backgroundColor="#ff9"; 
  f.style.borderColor="#f00"; 
  f.focus(); 
  return false;
}

// Check mailto form field(s) for required input, When a field is found with missing input,
// alert user, set field pink, and set focus to it.
function chkMailform(s) {
   if (s.Name.value=='')		return setErm(s['Name'],		'You must enter your name to continue.')
   if (s.Contact_How.value=="E-mail") {
     if (s.email.value=='')			return setErm(s['email'],'You have requested to be contacted by email. Please enter an email address to continue.');
     if (s.email.value.indexOf('@')==-1)	return setErm(s['email'],'Your E-mail address appears to be invalid. Plaese check!');
     if (s.email.value.indexOf('.')==-1)	return setErm(s['email'],'Your E-mail address appears to be invalid. Plaese check!');
   }
   if (s.Contact_How.value=="Phone") {
     if ((s.Telephone.value=='') && (s.EveTelephone.value=='')) return setErm(s['Telephone'],	'You have requested to be contacted by phone. You must enter a phone number to continue.')
   }
   return true;
}

function openNwin(name,nurl) {
  window.open(nurl,name,'width=500,height=500,scrollbars,resizable,status,toolbar,location')
  return false
}

// Set DOM object visibility:  obj = DOM object handle;  s = visibility option
function setBor(obj,bs,bc) {
  switch(DOMS) {
//    case 0:  break;									// no DOM
//    case 1:  obj.borderColor = bc;		obj.borderStyle = bs;		break;	// layers
    default: obj.style.borderColor = bc;	obj.style.borderStyle = bs;	break;	// IE4+ and NS6+
  }
}

function molnk(s,oid) {
  obj = getObj(oid);
  switch(s) {
    case 1:  setBor(obj,'outset','#00f'); break;
    case 2:  setBor(obj,'inset', '#00f'); break;
    default: setBor(obj,'solid', '#fff'); break;
  }
}