// 2002.03.26 - Mark Rovendro
// Copyright Mark Rovendro
// File: functions.js

// Simply:
//  Nav4/IE4-5 document.elementName
//	NS4:	document.<objecttype>.<name>
//	IE4/5:	document.all[]
//	IE6+:	document.getElementById()
//	NS7+:	document.getElementById() (and I think for NS6)
// NOTE: This requires the use of the "id" and "name" tag.
function findElement( id ) {
	// NS4 has to be directly accessed - if this exists then just return it.
	var ns4id = "document." + id ;
	if( eval(ns4id) ) return eval(ns4id) ;
	// This should take care of all other versions including the W3C DOM Level1 standard.
	if( !document.all && !document.getElementById ) return "" ;
	return document.all ? document.all[id] : document.getElementById(id) ;
} //findElement


function y2k(number){
	return (number < 1000) ? number + 1900 : number;
} // y2k


function printDate() {
	var now = new Date();
	var days = new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');
	var months = new Array('January','February','March','April','May','June','July','August','September','October','November','December');
	var date = ((now.getDate()<10) ? "0" : "")+ now.getDate();
	mod = "" //"<font face=\"Verdana,Arial\" size=\"2\">"
	mod +=  days[now.getDay()] + ", " + months[now.getMonth()] + " " 
	mod += date  +  ", " + (y2k(now.getYear())) 
	document.write(mod)
	//document.write("</font>")
} //printDate


function breakOut() {
	if (parent.frames.length > 0) {
	    parent.location.href = self.document.location
	}
} //breakOut


function lastUpdated() {
  // Netscape 4.7 lastModified is in the format "Friday, December 01, 2000 00:35:05
  // IE 5.0 lastModified is in the format "12/01/2000 00:35:05"
  if ( navigator.appName == "Netscape" )
      document.writeln( 'Last updated ' + document.lastModified.substring(0,document.lastModified.length-9) ) ;
  else
      document.writeln( 'Last updated ' + document.lastModified.substring(0,10) ) ;
} //lastUpdated 


// Got this off the internet at http://www.howtocreate.co.uk/tutorials/index.php?tut=0&part=16
// Made a slight modification to the code.
// dimension = WIDTH, HEIGHT
function getBrowserSize( dimension ) {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement &&
      ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  if ( dimension == "WIDTH" ) {
  	return myWidth ;
  } else {
  	return myHeight ;
  }
} //getBrowserSize


// main image rollover
//var menuImg = new Array() ;
//menuImg[1] = new Image() ;
//menuImg[1].src = "images/btwbd2001-5.jpg" ;
//menuImg[2] = new Image() ;
//menuImg[2].src = "images/btwbd2001-4.jpg" ;
function loadImage(name,index) {
  if ( document.images && name != "" ) {
    document.images[name].src = menuImg[index].src ;
  }
  if ( arguments.length == 3 ) {
    window.status = arguments[2] ;
  } else {
    window.status = '' ;
  }
  return true ;  // THIS IS REQUIRED FOR THE WINDOW.STATUS CHANGE TO OCCUR
} //loadImage


var showWin = "" ;	// Handler to Midi window
function openSlideShowWindow(page) {
  if ( showWin != "" && showWin.closed == 0 ) {
    showWin.focus() ;
  } else {
    showWin = window.open(page,"slideshow","toolbar=no,scrollbars=no,height=445,width=580,resizable=no")
  }
} //openSlideShowWindow


// Inorder for the check to work on IE we need to have this object created 
document.write( "<OBJECT id=Pdf1 height=0 width=0 classid=clsid:CA8A9780-280D-11CF-A24D-444553540000></OBJECT>" ) ;

// Return true if installed, false if not.
function acrobatPluginCheck()
{
	var agt=navigator.userAgent.toLowerCase();
	if(agt.indexOf("msie") != -1)
	{
		return acrobatPluginCheckIE();
	}
	else if(agt.indexOf("mozilla") != -1 || ((agt.indexOf("netscape") != -1) || (agt.indexOf("; nav") != -1)))
	{
		return acrobatPluginCheckNN();
	}
} // acrobatPluginCheck


function acrobatPluginCheckNN()
{
	if (navigator.plugins && navigator.plugins["Adobe Acrobat"].description != "") 
	{
		var description = navigator.plugins["Adobe Acrobat"].description; 
		var regEx = /(\d+)/;
		var version = 0;
		if(regEx.test(description))
		{
			version = RegExp.$1;
		}
		return true ;
	}
	else
	{
		return false ;
	}
} // acrobatPluginCheckNN


function acrobatPluginCheckIE()
{
	// Call the ActiveX Object and get the Version Information
	var versionData = Pdf1.GetVersions();
	if ( versionData )
	{
		return true ;
	} else
	{
		return false ;
	}
} //acrobatPluginCheckIE


function setMenuActive( menuId ) {
	// Find the menu id, if valid change the background color
	// var element = document.getElementById? document.getElementById(menuId): document.all? document.all[menuId]: null;
	var element = findElement( menuId ) ;
	if ( element ) {
	    element.style.backgroundColor = "#fc6";  // #d9eaff
	}
} //setMenuActive
	

// End: functions.js