      
      /* These variables hold the browser type */
      var isNS6 = false;
      var isIE  = false;
      var isNS4 = false;

      /* These variables control the submenu position */
      var curr_y = 0;
      var increment = 3;
      var limit = 300;

      /* These variables control the movement of the tractor */
      var curr_x = 0;
      var screenWidth = 0;
      var start_position = 0;
      var timer = 90;
      var increment = 20;
      var timerID;

      /* These variables keep track of the page being displayed */
      var currentPage = 0;
      var parking     = false;
      var oldLayer  = null;
      var newLayer  = null;
      var tracLayer = null;
      var menLayer  = null;
      var homLayer  = null;
      var farLayer  = null;
      var famLayer  = null;
      var lnkLayer  = null;
      var grpLayer  = null;
      var mapLayer  = null;
      var conLayer  = null;
      var fldLayer  = null;

      /* Navigation variables */
      var current_page = "home";
      var nav_images = new Array( "home",
				  "farm",
				  "family", 
				  "group", 
				  "map", 
				  "contact", 
				  "links",
				  "field");

      /* Image variables */
      var farm_norm    	 	 = new Image();
      var farm_select    	 = new Image();
      var family_norm		 = new Image();
      var family_select		 = new Image();
      var group_norm		 = new Image();
      var group_select		 = new Image();
      var field_norm		 = new Image();
      var field_select		 = new Image();
      var map_norm		 = new Image();
      var map_select		 = new Image();
      var contact_norm		 = new Image();
      var contact_select	 = new Image();
      var links_norm		 = new Image();
      var links_select		 = new Image();

      /* These variable hold the reload variables */
      var first_time = true;

      /*
       * Function : detectBrowserType()
       *
       * Description: This function detects the browser type 
       *
       * Parameters: None
       *
       */

      function detectBrowserType() {

	/* Test for Netscape 6 */
        if (document.getElementById && !document.all) 
	  isNS6 = true;

        /* Test for Internet Explorer */
        else if ( document.all )
	  isIE = true;
 
        /* Test for Netscape */
        else if (document.layers) 
	  isNS4 = true;
	  
	return;
      }

      /*
       * Function : findImage( imageName )
       *
       * Description: This function returns the image whose name matches
       *	      the parameter.  It assumes that all image names in 
       * 	      the document are unique (no duplicates within layers).
       *
       * Parameters: imageName - the name of the image to be changed
       *
       */

      function findImage( imageName ) {

	var image = null;
	var h = 0;
	var i = 0;
	var layerIdx;
	var imageIdx;

	/* If browser is IE or NS6 */
	if ( isIE || isNS6 ) {
	
	  /* Find the previously selected submenu item */
	  for ( i=0; i<document.images.length; i++ ) {
	    if ( document.images[i].name == imageName ) 
	      break;
	  }

	  /* Display the image */
	  eval( "image = document.images[" + i + "];" );
	}
	else if ( isNS4 ) {

	  /* Find the previously selected submenu item 
	  for ( h=0; h<document.layers.length; h++ ) {
	    for ( i=0; i<document.layers[h].document.images.length; i++ ) {
	      if ( document.layers[h].document.images[i].name == imageName ) {
		layerIdx = h;
		imageIdx = i;
	        break;
	      }
	    }
	  } */

	  /* Find the previously selected submenu item */
	  for ( i=0; i<document.images.length; i++ ) {
	    if ( document.images[i].name == imageName ) {
	      imageIdx = i;
	      break;
	    }
	  }

	  /* Display the image */
	  eval( "image = document.images[" + imageIdx + "];" );
	}

	return image;
      }
      
      /*
       * Function : initFormat()
       *
       * Description: This function detects the browser type and loads all
       *	      the navigation images.
       *
       * Parameters: None
       *
       */

      function initFormat() {

	/* Detect the browser type */
        detectBrowserType();

	/* Initialize navigation images */
	farm_norm	= "graphics/board_farm%20fresh1.gif";
      	farm_select    	= "graphics/board_farm%20fresh2.gif";
      	family_norm	= "graphics/board_fam%20fun1.gif";
      	family_select	= "graphics/board_fam%20fun2.gif";
      	group_norm	= "graphics/board_group%20fun1.gif";
      	group_select	= "graphics/board_group%20fun2.gif";
        field_norm	= "graphics/board_field1.gif";
	field_select	= "graphics/board_field2.gif";
      	map_norm       	= "graphics/board_map1.gif";
      	map_select     	= "graphics/board_map2.gif";
      	contact_norm   	= "graphics/board_contact1.gif";
      	contact_select 	= "graphics/board_contact2.gif";
      	links_norm	= "graphics/board_links1.gif";
      	links_select	= "graphics/board_links2.gif";

	if ( isNS6 )
	{ 
	  /* Determine the screen position */
          screenWidth = window.innerWidth;
          start_position = (screenWidth - 900) / 2;
	  curr_x = start_position;
	  if ( curr_x < 0 )
	    curr_x = 0;

	  tracLayer = document.getElementById("tractorLayer");
	  if ( tracLayer != null )
          {
	    tracLayer.style.left = curr_x - 20;
	    tracLayer.style.visibility = "visible";
	    var y = 585/* window.innerHeight - 180 */;
	    if ( y < 0 )
	      y = 0;
	    tracLayer.style.top = y;

	    if ( first_time )
	    {
	      /*parent.main.document.location = "home.html";*/
	      first_time = false;
	    }
	  }

	  menLayer = document.getElementById("menuLayer");
	  if (menLayer != null )
	  {
	    menLayer.style.left = curr_x - 20;
	    menLayer.style.visibility = "visible";
	    menLayer.style.top = 5;
	  }

	  homLayer = document.getElementById("homeLayer");
	  if ( homLayer != null )
	  {
	    homLayer.style.left = curr_x + 219;
	    homLayer.style.visibility = "visible";
	  }

	  farLayer = document.getElementById("farmLayer");
	  if ( farLayer != null )
	  {
	    farLayer.style.left = curr_x + 219;
	    farLayer.style.visibility = "hidden";
	  }

	  famLayer = document.getElementById("familyLayer");
	  if ( famLayer != null )
	  {
	    famLayer.style.left = curr_x + 219;
	    famLayer.style.visibility = "hidden";
	  }

	  lnkLayer = document.getElementById("linksLayer");
	  if ( lnkLayer != null )
	  {
	    lnkLayer.style.left = curr_x + 219;
	    lnkLayer.style.visibility = "hidden";
	  }

	  grpLayer = document.getElementById("groupLayer");
	  if ( grpLayer != null )
	  {
	    grpLayer.style.left = curr_x + 219;
	    grpLayer.style.visibility = "hidden";
	  }

	  fldLayer = document.getElementById("fieldLayer");
	  if ( fldLayer != null )
	  {
	    fldLayer.style.left = curr_x + 219;
	    fldLayer.style.visibility = "hidden";
	  }

	  mapLayer = document.getElementById("mapLayer");
	  if ( mapLayer != null )
	  {
	    mapLayer.style.left = curr_x + 219;
	    mapLayer.style.visibility = "hidden";
	  }

	  conLayer = document.getElementById("contactLayer");
	  if ( conLayer != null )
	  {
	    conLayer.style.left = curr_x + 219;
	    conLayer.style.visibility = "hidden";
	  }
	}

        if ( isIE )
	{
	  /* Determine the screen position */
	  screenWidth = document.documentElement.offsetWidth;
          start_position = (screenWidth - 900) / 2;
	  curr_x = start_position;
	  if ( curr_x < 0 )
	      curr_x = 0;
	  
          menLayer = document.all.menuLayer;
	  if ( menLayer != null )
	  {
	    menLayer.style.left = curr_x - 20;
	    menLayer.style.top = 5;    
	    menLayer.style.visibility = "visible";
	  }

	  homLayer = document.all.homeLayer;
	  if ( homLayer != null )
	  {
	    homLayer.style.left = curr_x + 219;
	    homLayer.style.top = 5;    
	    homLayer.style.visibility = "visible";
	  }	  

	  farLayer = document.all.farmLayer;
	  if ( farLayer != null )
	  {
	    farLayer.style.left = curr_x + 239;
	    farLayer.style.top = 5;
	    farLayer.style.visibility = "hidden";
	  } 

	  famLayer = document.all.familyLayer;
	  if ( famLayer != null )
	  {    
	    famLayer.style.left = curr_x + 239;
	    famLayer.style.top = 5;
	    famLayer.style.visibility = "hidden";
	  } 

	  lnkLayer = document.all.linksLayer;
	  if ( lnkLayer != null )
	  {
	    lnkLayer.style.left = curr_x + 239;
	    lnkLayer.style.top = 5;
	    lnkLayer.style.visibility = "hidden";
	  }

	  grpLayer = document.all.groupLayer;
	  if ( grpLayer != null )
	  {
	    grpLayer.style.left = curr_x + 239;
	    grpLayer.style.top = 5;
	    grpLayer.style.visibility = "hidden";
	  }

	  fldLayer = document.all.fieldLayer;
	  if ( fldLayer != null )
	  {
	    fldLayer.style.left = curr_x + 239;
	    fldLayer.style.top = 5;
	    fldLayer.style.visibility = "hidden";
	  }

	  mapLayer = document.all.mapLayer;
	  if ( mapLayer != null )
	  {
	    mapLayer.style.left = curr_x + 239;
	    mapLayer.style.top = 5;
	    mapLayer.style.visibility = "hidden";
	  }

	  conLayer = document.all.contactLayer;
	  if ( conLayer != null )
	  {
	    conLayer.style.left = curr_x + 239;
	    conLayer.style.top = 5;
	    conLayer.style.visibility = "hidden";
	  }

	  tracLayer = document.all.tractorLayer;
	  if ( tracLayer != null )
	  {
	    var y = document.documentElement.offsetHeight - 195;
	    if ( y < 0 )
	      y = 0;
	    tracLayer.style.left = curr_x - 20;
	    tracLayer.style.top = 615;
	    tracLayer.style.visibility = "visible";
	  }
	}

	oldLayer = homLayer;
	  
	return;
      }
      
      /*
       * Function : checkLocation()
       *
       * Description: This function conntinually checks the scrolling position and adjusts
       *              the menu position accordingly.
       *
       * Parameters: None
       *
       */
      function checkLocation()
      {
	var screen_y = 0;
        var submenuLayer = null;

	if ( isNS6 )
	{
	  screen_y = window.pageYOffset;
          submenuLayer = document.getElementById("submenuLayer");
	}
	else
	{
	  screen_y = document.body.scrollTop;
	  submenuLayer = document.all.submenuLayer;
	}

        if ( Math.abs(curr_y - screen_y) > increment)
        {
          if ( screen_y > curr_y )
	  {
	    if ( (screen_y - curr_y) > limit )
	      curr_y = screen_y - limit;
	    else
              curr_y += increment;
	  }
          if ( screen_y < curr_y )
	  {
	    if ( (curr_y - screen_y) > limit )
	      curr_y = screen_y + limit;
	    else
              curr_y -= increment;
	  }
        }

	if ( submenuLayer != null )
	{
	  submenuLayer.style.left = curr_x + 22;
	  submenuLayer.style.top = curr_y + 10;
	}
        
        setTimeout( "checkLocation()", timer );
      }

      /*
       * Function : startTractor()
       *
       * Description: This function starts the movement of the tractor
       *
       * Parameters: None
       *
       */
       function startTractor(page)
       {
	 var i;
	 var img;
	
	 /* Reset all the images */
	 for ( i=1; i<=7; i++ )
	 {
	   img = findImage( nav_images[i] );
	   eval( "img.src = " + nav_images[i] + "_norm;" );
	 }

	 /* Determine which page is becoming current */
	 if (page == '0')
	 {
	   newLayer = homLayer;
	 }
         if (page == '1')
	 {
	   newLayer = farLayer;
	   img = findImage("farm");
	   img.src = farm_select;
	 }
	 if (page == '2')
	 {
	   newLayer = famLayer;
	   img = findImage("family");
	   img.src = family_select;
	 }
	 if (page == '3')
	 {
	   newLayer = lnkLayer;
	   img = findImage("links");
	   img.src = links_select;
	 }
	 if (page == '4')
	 {
	   newLayer = grpLayer;
	   img = findImage("group");
	   img.src = group_select;
	 }
	 if (page == '5')
	 {
	   newLayer = mapLayer;
	   img = findImage("map");
	   img.src = map_select;
	 }
	 if (page == '6')
	 {
	   newLayer = conLayer;
	   img = findImage("contact");
	   img.src = contact_select;
	 }
	 if (page == '7')
	 {
	   newLayer = fldLayer;
	   img = findImage("field");
	   img.src = field_select;
	 }
	 oldLayer.style.visibility = "hidden";
	 newLayer.style.visibility = "visible";
	 oldLayer = newLayer;

	 /* Supress the movement of the tractor for the contact layer */
	 if ( page == '6' )
	 {
	   clearTimeout(timerID);
	   tracLayer.style.left = start_position;
	   /*tracLayer.style.top = 615;*/
	   tracLayer.style.visibility = "visible";
	   curr_x = start_position;
	 }
	 else
	 {
	   clearTimeout(timerID);
	   moveTractor();
	 }

         return(true);
       }

      /*
       * Function : moveTractor()
       *
       * Description: This function moves the tractor across the screen and wraps
       *              to the starting position.
       *
       * Parameters: None
       *
       */
      function moveTractor()
      {
	/* Set the new x position */
        curr_x = curr_x + increment;
	if (curr_x > screenWidth)
	{
	    curr_x = -180;
	    /* oldLayer.style.visibility = "hidden"; */
	    /* oldLayer.style.left = start_position; */
	    parking = true;
	}

	if ( tracLayer != null )
	{
	    tracLayer.style.left = curr_x;
	    oldLayer.style.visibility = "hidden";
        }
	if ( ( oldLayer != null ) && ( curr_x > (219 + start_position) ) )
	{
	    /* oldLayer.style.left = curr_x; */
	    oldLayer.style.visibility = "hidden";
	}
	if ( newLayer != null )
	{
	    if ( parking )
	        /* newLayer.style.left = curr_x + 219; */
		newLayer.style.visibility = "visible";
	    else
	        /* newLayer.style.left = curr_x - screenWidth + 39; */
		newLayer.style.visibility = "visible";
	}
	
	if ( ( parking && (curr_x + increment < start_position) ) || ( !parking ) )
	{
            timerID = setTimeout( "moveTractor()", timer );
	}
	else
	{
	    tracLayer.style.left = start_position;
	    /* newLayer.style.left = start_position + 219; */

	    oldLayer = newLayer;
	    parking = false;
	}

	return;
      }


