// preload the main images

img1 = new Image();
img1.src = "/img/background.gif";

img2 = new Image();
img2.src = "/img/header.jpg";

img3 = new Image();
img3.src = "/img/menu6.gif";


/* And all that Malarkey // Trimming form elements

Please feel free to use this JavaScript file in any way that you like, although please
keep the comments intact and a link back to http://www.stuffandnonsense.co.uk/archives/trimming_form_fields.html
would be appreciated.

If you come up with a stunning design based on this technique, it would be really nice
if you would post a comment containing a URL on 
http://www.stuffandnonsense.co.uk/archives/trimming_form_fields.html#Comments 

Thanks to Brothercake (http://www.brothercake.com/) for his help with the Javascript.
His fantastic UDM 4 fully-featured and accessible website menu system is a must!
(http://www.udm4.com/) */

window.onload = function()
{
	if(document.getElementById)
	{
		var linkContainer = document.getElementById('toggleformfields');
		
		if(!linkContainer)
		{
			return false;	
		}
		
		var toggle = linkContainer.appendChild(document.createElement('a'));
		toggle.href = '#';
		toggle.appendChild(document.createTextNode('Remove optional fields?'));
		toggle.onclick = function()
		{
			var linkText = this.firstChild.nodeValue;
			this.firstChild.nodeValue = (linkText == 'Remove optional fields?') ? 'Display optional fields?' : 'Remove optional fields?';
			
			var tmp = document.getElementsByTagName('div');
			for (var i=0;i<tmp.length;i++)
			{
				if(tmp[i].className.indexOf('optional') != -1)
				{
					tmp[i].style.display = (tmp[i].style.display == 'none') ? 'block' : 'none';
				}
			}
			
			var tmp = document.getElementsByTagName('fieldset');
			for (var i=0;i<tmp.length;i++)
			{
				if(tmp[i].className.indexOf('optional') != -1)
				{
					tmp[i].style.display = (tmp[i].style.display == 'none') ? 'block' : 'none';
				}
			}
			
			return false;
		}
	}
}

// converts standards compliant rel="external" to target="_blank" 
// also converts rel="pagehelp" for opening help pages in a new window
/*
function externalLinks()
{ 
 if (!document.getElementsByTagName) return; 
 var anchors = document.getElementsByTagName("a"); 
 for (var i=0; i<anchors.length; i++)
 { 
   var anchor = anchors[i]; 
   if (anchor.getAttribute("href") && 
       (anchor.getAttribute("rel") == "external" || anchor.getAttribute("rel") == "pagehelp" || anchor.getAttribute("rel") == "previewpage")) 
	{
     anchor.target = "_blank";
	}
 } 
}

window.onload = externalLinks();
*/

function makeInvisible(id)
{
	document.getElementById(id).style.visibility='hidden';
	document.getElementById(id).style.display='none';
}

function toggle( targetId ) {
   if ( document.getElementById ) {
    target = document.getElementById( targetId );
    if ( target.style.display == "none" ) {
     target.style.display = "";
    } else {
     target.style.display = "none";
    }
   }
}
