preloadImages = function(imglist) {
	var imgs = new Array();
	var count;
	if (document.images) {
		for (count=0; count<imglist.length; count++) {
			imgs[count]=new Image(); imgs[count].src=imglist[count];
		}
	}
}

sfHover = function(idList, tagList) {
	var count;
	for (count=0; count<idList.length; count++) {
		var sfEls = document.getElementById(idList[count]).getElementsByTagName(tagList[count]);
		for (var i=0; i<sfEls.length; i++) {
			sfEls[i].onmouseover=function() {
				this.className+=' sfhover';
			}
			sfEls[i].onmouseout=function() {
				this.className=this.className.replace(new RegExp(' sfhover\\b'), '');
			}
		}
	}	
}

/* HIDE AND UNHIDE OBJECTS */


var oldElem = null; //last manipulated element

// toggle the visibility of the element given by it's name
function toggleElement(/*string*/ elemName)
{
	// is there a visible element yet?
	if(oldElem && oldElem.style)
	{
		oldElem.style.display = "none";
	}

	var elem = document.getElementById(elemName);

	if(elem && elem.style)
	{
		// remember the currently visible element,
		// so that whe have just one single element
		// visible
		oldElem = elem;
		elem.style.display = "block";
	}
}


// hides/shows all child elements in the given element (container).
// the visibility parameter says if the elements will be hidden (false) or
// shown (true).
function mkMulVisible(/*string*/ container, /*boolean*/ visibility)
{
	var celem = document.getElementById(container);
	var dispValue = visibility ? "block" : "none";

	// are there any child elements
	if(celem && celem.childNodes)
	{
		for(var i=0; i < celem.childNodes.length; ++i)
		{
			// nodeType 1 describes any html-tags,
			// so the following code isn't applied to
			// any text nodes, since it would raise
			// an error (simply beceause text elements
			// don't have any attributes)
			if(celem.childNodes[i].nodeType == 1)
			{
				var elem = celem.childNodes[i];

				if(elem && elem.style && elem.nodeName != "A")
				{
					elem.style.display = dispValue;
				}
			}
		}
	}
}


function writeEM (uname, dname, tld)
{
	var em=uname + "@" + dname + "." + tld;
	document.write('<a href=mailto:' + em + '>' + em + '</a>');
}

function writeEMtxt(uname, dname, tld)
{
	document.write('Email: ');
	writeEM(uname, dname, tld);
}

// preloads all images that are given in the argument list
// this procedure can be called multiple times
function preloadImages()
{
	// set up our preload image list if necessary 
	if(!document.pli)
		document.pli = new Array();

	// starting offset in the image array
	var so = document.pli.length;

	for(var i = 0; i < preloadImages.arguments.length; ++i)
	{
		document.pli[so + i] = new Image;
		document.pli[so + i].src = preloadImages.arguments[i];
	}
}

// swaps the image source of the given image-element
function swapImage(/*string*/ imgId, /*string*/ newImgFile)
{
	var obj = document.getElementById(imgId);

	if(obj && obj.src)
	{
		// remember the original image-source
		if(!obj.oSrc)
			obj.oSrc = obj.src;
		obj.src = newImgFile;
	}
}

// restores the image's original source id if it was previously
// changed by swapImage()
function restoreImage(/*string*/ imgId)
{
	var obj = document.getElementById(imgId);

	if(obj && obj.src && obj.oSrc)
		obj.src = obj.oSrc;
}

// shortcuts to save some bytes
var resImg = restoreImage;
var swImg = swapImage;
var tgEl = toggleElement;
