// support functions
	// browser constants
		var ns=false;
		var ie=false;
		var mo=false;
		var op=false;
		var ko=false;
		
		var v3=false;
		var v4=false;
		var v5=false;
		var v6=false;
		
		var dom = false;
		var mc=false;
		
		// version sniff
		if (parseInt(navigator.appVersion)<4)													{v3=true;}
		if (navigator.userAgent.indexOf('4.')>-1)												{v4=true;}
		if (navigator.userAgent.indexOf(' 5.0')>-1)												{v5=true;v4=false;}
		if (navigator.userAgent.indexOf(' 5.5')>-1 || navigator.userAgent.indexOf(' 6.')>-1)	{v6=true;v4=false;v5=false;}
		
		// browser sniff
		if (navigator.appName=="Netscape" && document.getElementById)							{mo=true;}
		if (navigator.appName=="Netscape"&&v4)													{ns=true;}
		if (document.all)																		{ie=true;}
		if (navigator.userAgent.indexOf('Opera')>-1)											{op=true;}
		if (navigator.userAgent.indexOf("Konqueror")>-1)										{ko=true;}
		
		// document object model
		if (document.getElementById)															{dom=true;}

		// mac sniff
		if (navigator.appVersion.indexOf("Mac") != -1)											{mc=true;}

	// DOM functionality
		// configuration/constants
			var booFaderEnabled = ie && v6 && !mc;
			var fltFadeDef = 0.2;

		// manipulate classnames
			// change the class-name assigned to an Id
			function setClassName(strId,strClass,fltFade){
				if(dom){
					// apply the new properties only if there's a change to the old properties
					if(document.getElementById(strId).className!=strClass){
						// initiate the fader-filter
						setFade(strId,false,fltFade);
						// the new properties
						document.getElementById(strId).className=strClass;
						// activate the fader-filter
						setFade(strId,true,fltFade);
					}
				}else if(ie && !dom){
					// the real object
					objId = eval(strId);
					// the new properties
					objId.className = strClass;
				}else if(ns){
					// I wish
						//objId = eval('document.'+strId);
						//objId.className = strClass;
				}
			}
			
			// fetch the class-name
			function getClassName(strId){
				var strClass = '';
				if(dom){
					// the class name
					strClass = document.getElementById(strId).className;
				}else if(ie && !dom){
					// the real object
					objId = eval(strId);
					// the class name
					strClass = objId.className;
				}else if(ns){
					// I wish
						//objId = eval('document.'+strId);
						//strClass = objId.className;
				}
				return strClass;
			}
			
			// fetches the last (digit) character of a class-name
			function getClassSuffix(strId){
				// get the class
				strClass = getClassName(strId);
				// count where the numeric suffix ends
				intSuffixLength = 0;
				while(!isNaN(strClass.substr(strClass.length-intSuffixLength-1,strClass.length)) || strClass.substr(strClass.length-intSuffixLength-1,strClass.length)=='-') intSuffixLength += 1;
				// split the base name
				strClassName = strClass.substr(0,strClass.length-intSuffixLength);
				// split the state
				strClassState = strClass.substr(strClass.length-intSuffixLength,intSuffixLength) * 1;
				// return the split pieces
				return new Array(strClassName,strClassState);
			}
			
			// changes the last (digit) character of a class-name
			function setClassSuffix(strId,intStateOffset,booOffset,fltFade){
				// get the current state
				arrClass = getClassSuffix(strId);
				// check if it's an offset or an absolute value
				if(typeof booOffset == 'undefined') booOffset = false;
				if(!booOffset) arrClass[1] = 0;
				// add the state offset to the current one
				intClassState =  intStateOffset + arrClass[1];
				// apply the new class
				setClassName(strId,arrClass[0]+intClassState,fltFade);
			}

		// fader trigger
			var booFadeUnlock = true;
			function setFade(strId,booGo,fltFade){
				// default fade
				if(typeof fltFade == 'undefined') fltFade = fltFadeDef;
				// only initiate the fade if it's allowed and possible
				if(fltFade>0 && booFaderEnabled && booFadeUnlock){
					// the real object
					objId = eval(strId);
					if(booGo){
						// lock the fader
						booFadeUnlock = false;
						// activate the fader-filter
						objId.filters.blendTrans.Play();
					}else{
						// initiate the fader-filter
						objId.style.filter="blendTrans(duration="+fltFade+")";
						objId.filters.blendTrans.Apply();
						// unlock the fader
						setTimeout('booFadeUnlock=true;',fltFade*1024);
					}
				}
			}

// buttons
	var booImgSrcFade = true;
	var fltImgSrcFade = 0.2;
	// Example image: This image would toggle between "myimage_0.gif" and "myimage_1.gif".
	/*
		<img border="0" alt="" id="myimage" src="/images/myimage_0.gif" 
			onload="cacheImgSrcSuffix(this.id,0,1)" 
			onmouseover="setImgSrcSuffix(this.id,1)" 
			onmouseout="setImgSrcSuffix(this.id,0)"
		>
	*/

	// Caches all versions of the image URL, belonging to the Id, with the last digit substituted by the arguments.
	// for example: 'myimage_0.gif' and 'myimage_1.gif'
	function cacheImgSrcSuffix(strId){
		if(dom){
			// get the picture source name
			strImgUrl = document.getElementById(strId).src;
			// split the url
			strImgUrlPrefix = strImgUrl.substr(0,strImgUrl.length-5);
			strImgUrlSuffix = strImgUrl.substr(strImgUrl.length-4);
			// for all desired suffixes
			for(var intA=1; intA<arguments.length; intA++){
				eval(	""
						+ "obj" + strId + arguments[intA] + " = new Image();"
						+ "obj" + strId + arguments[intA] + ".src = '" + strImgUrlPrefix + arguments[intA] + strImgUrlSuffix + "';"
				);
			}
		}
	}

	// swaps the pre-loaded images around on events
	function setImgSrcSuffix(strId,intState){
		if(dom){
			// make the supposed object Id
			strObj = 'obj' + strId + intState;
			imgObj = eval(strObj);
			// put is back where you found it
			if(typeof(imgObj)!='undefined'){
				if(ie && dom && !mc && booImgSrcFade){
					document.getElementById(strId).style.filter="blendTrans(duration="+fltImgSrcFade+")";
					document.getElementById(strId).filters.blendTrans.Apply();
					document.getElementById(strId).src = imgObj.src;
					document.getElementById(strId).filters.blendTrans.Play();
				}else{
					document.getElementById(strId).src = imgObj.src;
				}
			}
		}
	}

// foldouts
	var intMenuMax = 3;
	var intMenuTimeout = 0;

	function setMenu(intId,intState){
		setImgSrcSuffix('button'+intId,intState);
		setClassSuffix('menu'+intId,intState);
	}

	function suggestMenu(intId,intState){
		clearTimeout(intMenuTimeout);
		if(intState==0){
			intMenuTimeout = setTimeout("setMenu("+intId+",0)",512);
		}else{
			for(var intA=1; intA<=intMenuMax; intA++){
				intNewState = (intId==intA) ? 1 : 0 ;
				setMenu(intA,intNewState);
			}
		}
	}
