// ----------------------------------------------------------------------------------------------------

	var ie4 = false;
	var pageID = "";
	var vPartner = 4;

// ----------------------------------------------------------------------------------------------------
// Load all images into the browser when it loads the home page.

function FP_preloadImgs()
{
 var a = arguments;
 
 if(!document.FP_imgs) document.FP_imgs=new Array();
 
 for(var i=0; i <a.length; i++)
 {
 	document.FP_imgs[i]     = new Image;
 	document.FP_imgs[i].src = a[i];
 }
}
// ----------------------------------------------------------------------------------------------------
// Turn the main menu item on or off when the menu image is moused-over/off and swap the
// image source.

function menuitem(menuID, newClass, imageID, newImage, txtID, txtImage)
{
	// Change the menu item's class name ..
	
	if (menuID != '' && newClass != '')
	{
		document.getElementById(menuID).className=newClass;
	}

	// If we're not on the home page the images won't be available so stop here ..
	
	if (pageID != "index")
	{
		return;
	}

	// Change the image source ..
	
	if (imageID != '' && newImage != '')
	{
		document.getElementById(imageID).src="images/" + newImage;
	}

	// Switch the text image source between a blank image and a visible text image ..
	
	if (txtID != '')
	{
		if (txtImage != '')
		{
			document.getElementById(txtID).src="images/" + txtImage;
		}
		else
		{
			document.getElementById(txtID).src="images/blank.gif";
		}
	}
}
// ----------------------------------------------------------------------------------------------------

function init()
{
	   // Get the filename without the directory information ..
	
	   var lastOccurs; // the position of the last (whatever) in the path

	   lastOccurs = location.pathname.lastIndexOf("/");
	   pageID = location.pathname.substring(lastOccurs + 1, location.pathname.length);

	   // Now get the file name without the extension ..
	   
	   lastOccurs = pageID.lastIndexOf(".");
	   pageID = pageID.substring(0, lastOccurs);
	   
	   if (pageID == '')
	   {
	      pageID = "index";
	   }
	   /*
	   for (var i=1; i < 4; i++)
	   {
	   	document.styleSheets[i].disabled = true; // Disable all stylesheets except the first
	   }
	   
	   // Which browser is this? ..
*/
	   if (navigator.appName == "Microsoft Internet Explorer")
	   {
	   	  ie4 = true;
	   }
	   /*
	  	   if (screen.height <= 600)
	  	   {
			  document.styleSheets[1].disabled = false;
	 	  	  document.getElementById("band").src = "images/headerbar800.jpg";
	  	   }
	  	}
	  	else
	  	{
		   document.styleSheets[2].disabled = false;	  	
	  	   if (screen.height <= 600)
	  	   {
			  document.styleSheets[3].disabled = false;
	 	  	  document.getElementById("band").src = "images/headerbar800.jpg";
	  	   }
	  	 }
		*/
		// Preload all of the images on the index page ..
		  	   
  	   if (pageID == "index")
  	   {
  	   		//document.getElementById("tbMenu").id = "tbMenuIndex";
  	   
			if (document.images)
  	   		{
	  			FP_preloadImgs(	'images/torrefiedon.jpg',
	   							'images/dryeron.jpg',
	   		 					'images/productson.jpg',
	   							'images/galleryon.jpg',
	   							'images/carbonisedon.jpg',
	   							'images/devhiston.jpg',
	   							'images/projparton.jpg',
	   							'images/testingon.jpg',
	   							'images/contacton.jpg',
	   							'images/dryingsystems.jpg',
	   							'images/txtTorrefied.jpg',
	   							'images/txtCarbonised.jpg',
	   							'images/txtDevHist.jpg',
	   							'images/txtProjPart.jpg',	   					
	   							'images/txtGallery.jpg',
	   							'images/txtProducts.jpg',
	   							'images/txtTesting.jpg',
	   							'images/txtOverview.jpg',	   						
	   							'images/txtContact.jpg');
	   		}
	   	}

/*
	   	if (pageID == "gallery")
	   	{
	  			FP_preloadImgs(	'images/gallery/fullsize/2.jpg',
	   							'images/gallery/fullsize/3.jpg',
	   		 					'images/gallery/fullsize/4.jpg',
	   							'images/gallery/fullsize/5.jpg',
	   							'images/gallery/fullsize/6.jpg',
	   							'images/gallery/fullsize/7.jpg',
	   							'images/gallery/fullsize/8.jpg',
	   							'images/gallery/fullsize/9.jpg',
	   							'images/gallery/fullsize/10.jpg',
	   							'images/gallery/fullsize/11.jpg',
	   							'images/gallery/fullsize/12.jpg',
	   							'images/gallery/fullsize/13.jpg',
	   							'images/gallery/fullsize/14.jpg',
	   							'images/gallery/fullsize/15.jpg',	   					
	   							'images/gallery/fullsize/16.jpg');
	   	}
*/
}

// ----------------------------------------------------------------------------------------------------

function NextImage(direction)
{

// Checks the currently displayed image and moves to the next ..
// d = 1 for forward, -1 for backward navigation.
//
// To add pictures to the gallery, simply change maxImages to the greatest value
// available and name the images in the list sequentially, eg 1.jpg, 2.jpg ..

  var fn, ffn;
  var maxImages = 16;
  var imPath, imPathLen;
  
  if (screen.height <= 600)
  {
  	imPath = 'images/gallery/800/';
  }
  else
  {
  	imPath = 'images/gallery/';
  }
  
  imPathLen = imPath.length;
  
  if (ie4)
  {
  	fn = imGalleryPic.src.substring(imGalleryPic.src.lastIndexOf(imPath) + imPathLen);
  }
  else
  {
  	ffn = eval("document.imGalleryPic.src");
  	fn = ffn.substring( ffn.lastIndexOf(imPath) + imPathLen);
  	ffn = ffn.substring(0, ffn.lastIndexOf(imPath) + imPathLen);
  }
  
  imNum = fn.substring(0, fn.lastIndexOf('.'));

  if (direction == 1)
  {
  	imNum++;
  }
  else
  {
  	imNum--;
  }
  
  if (imNum > maxImages)
  {
  	imNum = 1;
  }
  
  if (imNum == 0)
  {
  	imNum = maxImages;
  }
  
  fn = imNum + '.jpg';
  
  if (ie4)
  {
  	imGalleryPic.src = imPath + fn;
  }
  else
  {
	document.imGalleryPic.src = ffn + fn;  // NB: This doesn't work !!!!
  }
  

}

// ----------------------------------------------------------------------------------------------------

function fullImage(fn)
{
	var path = fn.substring(0, fn.lastIndexOf("/"));
	var filename = fn.substring(fn.lastIndexOf("/") + 1);
	var fullfn = path + '/fullsize/' + filename;
	document.getElementById("imGalleryPic").src=fullfn;	
	return true;
}
// ----------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------


//-->