// Functions are marked with the following information:
// CROSS-BROWSER: This function should work on various browsers
// GENERIC: This function does not rely on a particular-named object to work

function ShowFooter()
{
// GENERIC
// Problem: Last modified date is always today, because this code, together with any ASP, means that the file the user receives is always from today!
  var modDate = new Date(document.lastModified);
  var modYear = modDate.getFullYear();
  
  // Create email address this way to reduce spam a little
  var txtDomain = "jamie" + "tshaw" + ".co.uk";
  var Addr = "info" + "&#064;" + txtDomain;
  document.write("<p class='footer'>&copy;&nbsp;" + modYear + "&nbsp;Jamie Shaw. <a href='mailto:" + Addr + "' title='Click to send me an email using your email program'>Email<\/a><\/p>");
}


    function ShowHide()
    {
    // CROSS-BROWSER*, GENERIC
    // Hide or show the object - the method used depends on the user's browser.

    // First parameter: name of object to show/hide
    // Second parameter: whether to hide, show or reverse the current status of the object.
    //   Values are: 'hidden', 'visible', 'reverse'
    //   Second param is optional if a third parameter is not supplied. When left out, the
    //   second param defaults to 'reverse'
    // Third parameter: if to affect surrounding content - 'reflow' or 'fixed'
    //   Defaults to 'reflow'
    //   When 'reflow', content below the object moves up or down depending on whether
    //   the object is visible or not. This uses (for W3C) the display style property.
    //   When 'fixed', showing or hiding the object does not affect other parts of the
    //   page. This uses (for W3C) the visibility style propery.
    
    // E.g. ShowHide('divLayer1') or ShowHide('divLayer1','visible') or
    // ShowHide('divLayer1','reverse','chkBox1')
    
    // *Note for old Netscape browsers:
    // The function only works if the item being shown/hidden is a <layer> and the name (not
    //   the ID attribute is passed to the procedure.
    //   The default visibility is to inherit the parent. This procedure doesn't do anything
    //   clever for such cases, merely assuming the parent is currently visible and therefore
    //   hiding the layer.    

      // Get arguments
      Args = ShowHide.arguments;
      
      // Set to false if this function fails, to display an alert
      var Success = true;

      // If the first argument doesn't exist, leave function
      if(Args.length>0) Args = new Array(Args[0], Args[1], Args[2]);
      else return false;

      switch (Args[1])
      {
        
        case 'hidden':
        // If the second argument is 'hidden', hide the object using the method appropriate to the browser
        if(Args[2] == 'fixed')
        {
          // Use the visibility property
          if(document.getElementById) document.getElementById(Args[0]).style.visibility = 'hidden';
          else if(document.all) document.all[Args[0]].style.visibility = "hidden";
          else if(document.layers[Args[0]]) document.layers[Args[0]].visibility = "hide";
          else Success=false;  
        }
        else
        {  
          // Use the display property 
          if(document.getElementById) {document.getElementById(Args[0]).style.display = 'none';}
          else if(document.all) document.all[Args[0]].style.display = "none";
          else if(document.layers[Args[0]]) document.layers[Args[0]].visibility = "hide";
          else Success=false;  
        }
        break;
        
        case 'visible':
          // If the second argument is 'visible', hide the object using the method appropriate to the browser
          if(Args[2] == 'fixed')
        {  
          if(document.getElementById) document.getElementById(Args[0]).style.visibility = 'visible';
          else if(document.all) document.all[Args[0]].style.visibility = "visible";
          else if(document.layers[Args[0]]) document.layers[Args[0]].visibility = "show";
          else Success=false;  
        }
        else
        {
          if(document.getElementById) document.getElementById(Args[0]).style.display = 'block';
          else if(document.all) document.all[Args[0]].style.display = "block";
          else if(document.layers[Args[0]]) document.layers[Args[0]].visibility = "show";
          else Success=false;      
        }
        break;
        
        default:
          // Reverse the visibility of the object
          if(document.getElementById)
          {
            // Use getElementByID method for IE5+ and NS6+ (W3C standard)
            if(Args[2] == 'fixed')
            {
              if(document.getElementById(Args[0]).style.visibility == 'visible') document.getElementById(Args[0]).style.visibility = 'hidden';
              else document.getElementById(Args[0]).style.visibility = 'visible';
            }
            else
            {
              if(document.getElementById(Args[0]).style.display == 'block') document.getElementById(Args[0]).style.display = 'none';
              else document.getElementById(Args[0]).style.display = 'block';
            }
          }
          else 
          {
            if(document.all)
            // Use document.all IE4+ method
            {
              if(Args[2] == 'fixed')
              {
                if(document.all[Args[0]].style.visibility == 'visible') document.all[Args[0]].style.visibility = 'hidden';
                else document.all[Args[0]].style.visibility = 'visible';
              }
        			else
        			{
                if(document.all[Args[0]].style.display == 'block') document.all[Args[0]].style.display = 'none';
                else document.all[Args[0]].style.display = 'block';        
        			}
            }
            else 
            {
              // Try to use NS4 layers
              if(document.layers[Args[0]])
              {
                if(document.layers[Args[0]].visibility=="hide") document.layers[Args[0]].visibility = "show";
                else document.layers[Args[0]].visibility = "hide";
              }
              else
              {
                // Give up
                Success = false;
              }  // give up
            }  // NS
          }  // IE4
      } // end of Switch
      if (Success == false) alert("Cannot show or hide this item. Please upgrade your browser.\r\r(Trying to show/hide a <div> block)");
      return Success;
    } // END FUNCTION


    function ShowHideWinWidth()
    // Show or hide the supplier object depending on the width of the window.
	// Parameter 1: object o hide/show. 
	// Parameter 2: width to hide. If the window width is greater than this, the object is shown.
    // If no object is given, leave. If no width is given, default to 1090px.
	
	// To use, run at some point in the web page:
	// ShowHideWinWidth('layer2','1300');
	// Then make it run whenever the user resizes the window:
	// <script type="text/javascript" for="window" event="onresize">
    // ShowHideWinWidth('layer2','1300');
    // Compat.: NS4 and Safari don't understand scripts for certain events like this one. They just run the
    // code anyway, which means that the ShowHideWinWidth procedure gets run twice in a row when the
    // page is opened then not ever again.
	// There does not seem to be an alternative way around this. The FOR and EVENT attributes seem to be
	// 'reserved' for future use by W3C, but implemented by Microsoft.
    
  

    {
      // Get arguments
      Args = ShowHideWinWidth.arguments;

      // If first object is nothing, leave
      if(Args.length>0) Args = new Array(Args[0], Args[1]);
      else return false;

      // If the second object is nothing, set to 1300
      if(!Args[1]) Args[1] = 1300;

      // Get width of window. Modern browsers understand the first line, NS requires the user of the
      // innerWidth property. Both return the width of the usuable document area in the browser - 
      // i.e. not including scroll bars etc.
      if(document.body) {var WindowWidth = document.body.clientWidth;}
      else if(window.innerWidth) {var WindowWidth = window.innerWidth;}

      if(WindowWidth > Args[1])
      {
        ShowHide(Args[0],'visible');
      }
      else
      {
        ShowHide(Args[0],'hidden');
      }
    }
  
  
  function SetBlueStrip()
  {
    if(document.getElementById) document.getElementById('SideSection').style.height = document.documentElement.scrollHeight;
    else if(document.all.SideSection) document.all.SideSection.style.height = document.body.scrollHeight;
    else if(document.layers) document.layers.SideSection.style.height = document.body.scrollHeight;
  }
  
  function HelpPopup(HelpText, e)
  {
    // Show a div box giving help text and a close option
	// Second parameter, e, holds event information so the popup box can appear near to where the
	//  user clicked. IE doesn't need this, instead using window.event, but other browsers/W3C do.
	//  More information: http://www.xs4all.nl/~ppk/js/events_access.html
	//
	// Example usage of function: onclick="HelpPopup('here is a message',event);"

	 // This function tries to put the box near to where the user clicked. Some browsers report the
	// coordinates with layerY and layerX, others with y and x. Store the appropriate one for later.
	var Ypos = 200, Xpos = 200
	if (!e) 
	{
	  var e = window.event;	   // e now gives access to the event in all browsers
	  Ypos=e.y;
	  Xpos=e.x;
	}
	if (!e.layerY) Ypos=e.y; else Ypos=e.layerY;
	if (!e.layerX) Xpos=e.x; else Xpos=e.layerX;

	Ypos = Ypos + 30;
	Xpos = Xpos + 200;
	
	if(document.getElementById('divHelp'))
	{
	  with(document.getElementById('divHelpTitle').style)
	  {
    	top=Ypos; left=Xpos; display="block";
	  }	
  	  with(document.getElementById('divHelp'))
      {
        innerHTML = "<p>" + HelpText + "</p><a href='JavaScript:void(0)' onclick='document.getElementById(\"divHelp\").style.display=\"none\";document.getElementById(\"divHelpTitle\").style.display=\"none\";'>Close</a>";
		with(style) {display="block";}		
	  }
	  // Remember that divHelpTitle encompasses divHelp, i.e. divHelpTitle's innerHTML contains divHelp
	  //document.getElementById('divHelpTitle').innerHTML = "<p>Popup help</p>" + document.getElementById('divHelpTitle').innerHTML;

	} // Browser doesn't use getElementByID
	else
	{
	  if(divHelp) 
	  {
	    with(divHelp)
        {
          innerHTML = "<p>" + HelpText + "</p><a href='JavaScript:void(0)' onclick='divHelp.style.display=\"none\";divHelpTitle.style.display=\"none\";'>Close</a>";
          //with(style) {top = window.event.y + 20; left = window.event.x + 200; display = "";}
          style.display = "";
		}
		with(divHelpTitle.style){top=Ypos; left=Xpos; display="block";}		
	  }
	  else
	  {
	    if(document.layers) 
		{
		  with(document.layers('divHelp'))
	      {
            innerHTML = "<p>" + HelpText + "</p><a href='JavaScript:void(0)' onclick='document.layers(\"divHelp\").display=\"hide\";document.layers(\"divHelpTitle\").display=\"hide\";'>Close</a>";
            with(style) {top = window.event.y + 20; left = window.event.x + 200;}
            display = "show";
		  }
          with(document.layers('divHelpTitle').style){top=Ypos; left=Xpos; display="block";}		  
	    }
	    else window.alert(HelpText);
	  }
	}

    // Code to allow the box to be moved
	
	if (window.Event) // Navigator 4.0x require events to be 'captured'. Other browsers support events directly, or not at all
      document.captureEvents(Event.MOUSEDOWN | Event.MOUSEMOVE | Event.MOUSEUP);
	
	// Run a function for each of the below mouse events
    document.onmousedown = MD;
    document.onmousemove = MM;
    document.onmouseup = MU;  
  }

var ob;
var over = false;
N = (document.all) ? 0 : 1;  // True if browser is Netscape

function MD(e) 
{
  if (over)
  {
    if (N) 
	{
      ob = document.getElementById("divHelpTitle");
      X=e.layerX;
      Y=e.layerY;
      return false;
    }
    else 
	{
      ob = document.getElementById("divHelpTitle");
      ob = ob.style;
      X=event.offsetX;
      Y=event.offsetY;
    }
  }
}

function MM(e) 
{
  if (ob) 
  {
    if (N) 
	{
      ob.style.top = e.pageY-Y;
      ob.style.left = e.pageX-X;
    }
    else 
	{
      ob.pixelLeft = event.clientX-X + document.body.scrollLeft;
      ob.pixelTop = event.clientY-Y + document.body.scrollTop;
      return false;
	}
  }
}

function MU() 
{ob = null;}
