// FOR REQUEST.QUERYSTRING
/* Andrew Urquhart : Client-Side Request Object for javascript : www.andrewu.co.uk/tools/request/
COPYRIGHT:You are free to use this script for any use you wish if this comment is left intact. Feel free to enhance the script and send me the updated version. Please don't redistribute. This script is provided as is,with no warranty of any kind. Use it at your own risk. Copyright Andrew R Urquhart; VERSION:#1.2 2004-02-18 18:48 UTC*/
function RObj(ea){var LS="";var QS=new Object();var un="undefined";var f="function";var n="number";var r="string";var e1="ERROR:Index out of range in\r\nRequest.QueryString";var e2="ERROR:Wrong number of arguments or invalid property assignment\r\nRequest.QueryString";var e3="ERROR:Object doesn't support this property or method\r\nRequest.QueryString.Key";function Err(arg){if(ea)alert("Request Object:\r\n"+arg)};function URID(t){var d="";if(t){for(var i=0;i<t.length;++i){var c=t.charAt(i);d+=(c=="+"?" ":c);};};return unescape(d);};function OL(o){var l=0;for(var i in o){if(typeof(o[i])!=f) l++;};return l;};function AK(key){var auk=true;for(var u in QS){if(typeof(QS[u])!=f&&u.toString().toLowerCase()==key.toLowerCase()){auk=false;return u;}};if(auk){QS[key]=new Object();QS[key].toString=function(){return TS(QS[key])};QS[key].Count=function(){return OL(QS[key])};QS[key].Count.toString=function(){return OL(QS[key]).toString()};QS[key].Item=function(e){if(typeof(e)==un) return QS[key];else {if(typeof(e)==n){var a=QS[key][Math.ceil(e)];if(typeof(a)==un) Err(e1+"(\""+key+"\").Item("+e+")");return a;}else Err("ERROR:Expecting numeric input in\r\nRequest.QueryString(\""+key+"\").Item(\""+e+"\")");}};QS[key].Item.toString=function(e){if(typeof(e)==un) return QS[key].toString();else {var a=QS[key][e];if(typeof(a)==un) Err(e1+"(\""+key+"\").Item("+e+")");return a.toString();};};QS[key].Key=function(e){var t=typeof(e);if(t==r){var a=QS[key][e];return(typeof(a)!=un&&a&&a.toString()?e:"");}else Err(e3+"("+(e?e:"")+")");};QS[key].Key.toString=function(){return un};};return key};function AVTK(key,val){if(key!=""){var key=AK(key);var l=OL(QS[key]);QS[key][l+1]=val;}};function TS(o){var s="";for(var i in o){var ty=typeof(o[i]);if(ty=="object") s+=TS(o[i]);else if(ty!=f) s+=o[i]+", ";};var l=s.length;if(l>1)return(s.substring(0,l-2));return(s==""?un:s);};function KM(k,o){var k=k.toLowerCase();for(var u in o){if(typeof(o[u])!=f&&u.toString().toLowerCase()==k) return u;};}if(window.location&&window.location.search){LS=window.location.search;var l=LS.length;if(l>0){LS=LS.substring(1,l);var preAmpAt=0;var ampAt=-1;var eqAt=-1;var k=0;var skip=false;for(var i=0;i<l;++i){var c=LS.charAt(i);if(LS.charAt(preAmpAt)=="="||(preAmpAt==0&&i==0&&c=="=")) skip=true;if(c=="="&&eqAt==-1&&!skip) eqAt=i;if(c=="&"&&ampAt==-1){if(eqAt!=-1) ampAt=i;if(skip) preAmpAt=i+1;skip=false;};if(ampAt>eqAt){AVTK(URID(LS.substring(preAmpAt,eqAt)),URID(LS.substring(eqAt+1,ampAt)));preAmpAt=ampAt+1;eqAt=ampAt=-1;++k;};};if(LS.charAt(preAmpAt)!="="&&(preAmpAt!=0||i!=0||c!="=")){if(preAmpAt!=l){if(eqAt!=-1) AVTK(URID(LS.substring(preAmpAt,eqAt)),URID(LS.substring(eqAt+1,l)));else if(preAmpAt!=l-1) AVTK(URID(LS.substring(preAmpAt,l)),"");};if(l==1) AVTK(LS.substring(0,1),"");};};};var TC=OL(QS);if(!TC) TC=0;QS.toString=function(){return LS.toString()};QS.Count=function(){return(TC?TC:0)};QS.Count.toString=function(){return(TC?TC.toString():"0")};QS.Item=function(e){if(typeof(e)==un) return LS;else {if(typeof(e)==n){var e=Math.ceil(e);var c=0;for(var i in QS){if(typeof(QS[i])!=f&&++c==e) return QS[i];};Err(e1+"().Item("+e+")");}else return QS[KM(e,QS)];};return un;};QS.Item.toString=function(){return LS.toString()};QS.Key=function(e){var t=typeof(e);if(t==n){var e=Math.ceil(e);var c=0;for(var i in QS){if(typeof(QS[i])!=f&&++c==e) return i;}}else if(t==r){var e=KM(e,QS);var a=QS[e];return(typeof(a)!=un&&a&&a.toString()?e:"");}else Err(e2+"().Key("+(e?e:"")+")");Err(e1+"().Item("+e+")");};QS.Key.toString=function(){Err(e2+"().Key");};this.QueryString=function(k){if(typeof(k)==un) return QS;else {var k=KM(k,QS);if(typeof(QS[k])==un){t=new Object();t.Count=function(){return 0};t.Count.toString=function(){return "0"};t.toString=function(){return un};t.Item=function(e){return un};t.Item.toString=function(){return un};t.Key=function(e){Err(e3+"("+(e?e:"")+")");};t.Key.toString=function(){return un};return t;}if(typeof(k)==n) return QS.Item(k);else return QS[k];}};this.QueryString.toString=function(){return LS.toString();};this.QueryString.Count=function(){return(TC?TC:0)};this.QueryString.Count.toString=function(){return(TC?TC.toString():"0")};this.QueryString.Item=function(e){if(typeof(e)==un) return LS.toString();else {if(typeof(e)==n){var e=Math.ceil(e);var c=0;for(var i in QS){if(typeof(QS[i])!=f&&++c==e) return QS[i];};Err(e1+".Item("+e+")");}else return QS[KM(e,QS)];}if(typeof(e)==(n)) Err(e1+".Item("+e+")");return un;};this.QueryString.Item.toString=function(){return LS.toString()};this.QueryString.Key=function(e){var t=typeof(e);if(t==n){var e=Math.ceil(e);var c=0;for(var i in QS){if(typeof(QS[i])=="object"&&(++c==e)){return i;}}}else if(t==r){var e=KM(e,QS);var a=QS[e];return(typeof(a)!=un&&a&&a.toString()?e:"");}else Err(e2+".Key("+(e?e:"")+")");Err(e1+".Item("+e+")");};this.QueryString.Key.toString=function(){Err(e2+".Key");};this.Version=1.2;this.Author="Andrew Urquhart (www.andrewu.co.uk)";};var Request=new RObj(false);


// LIBRARY
	function xDef() {
		for(var i=0; i<arguments.length; ++i){if(typeof(arguments[i])=='undefined') return false;}
		return true;
	}

	function xStr() {
		for(var i=0; i<arguments.length; ++i){if(typeof(arguments[i])!='string') return false;}
		return true;
	}
	
	function xNum() {
		for(var i=0; i<arguments.length; ++i){if(typeof(arguments[i])!='number') return false;}
		return true;
	}

	function xGetElementById(e) {
		if(typeof(e)!='string') return e;
		if(document.getElementById) e=document.getElementById(e);
		else if(document.all) e=document.all[e];
		else e=null;
		return e;
	}

	function xTop(e,iY) {
		if(!(e=xGetElementById(e))) return 0;
		var css=xDef(e.style);
		if(css && xStr(e.style.top)) {
			if(xNum(iY)) e.style.top=iY+'px';
			else {
			iY=parseInt(e.style.top);
			if(isNaN(iY)) iY=0;
			}
		}
		else if(css && xDef(e.style.pixelTop)) {
			if(xNum(iY)) e.style.pixelTop=iY;
			else iY=e.style.pixelTop;
		}
		return iY;
	}
	
	function xHeight(e,uH) {
		if(!(e=xGetElementById(e))) return 0;
		if (xNum(uH)) {
			if (uH<0) uH = 0;
			else uH=Math.round(uH);
		}
		else uH=-1;
		var css=xDef(e.style);
		if(css && xDef(e.offsetHeight) && xStr(e.style.height)) {
			if(uH>=0) xSetCH(e, uH);
			uH=e.offsetHeight;
		}
		else if(css && xDef(e.style.pixelHeight)) {
			if(uH>=0) e.style.pixelHeight=uH;
			uH=e.style.pixelHeight;
		}
		return uH;
	}

// END LIBRARY
	
// INPUT PROCESSING
	function mouseover(i)
	{
	        // If moving onto an unselected bar
			if (!(intSelected == i))
			{
			    // Set extended position
				arrIntDesiredPositions[i] = intExtendedPos;
				setActiveLayout(i);
				
				// Start mover thread if not already running
				if (!boolRunning)
				{
					mover();
				}	
			}	
	}
	
	function mouseout(i)
	{
	        // If moving out of an unselected bar
			if (!(intSelected == i))
			{   
			    // Set retracted position
				arrIntDesiredPositions[i] = intRetractedPos;
				setDimLayout(i);
				
				// Start mover thread if not already running
				if (!boolRunning)
				{
					// Delay to allow mouseover event to trigger, prevent 'shaking' 
					setTimeout("mover()" , 20);
				}
			}		
	}
	
	function mousedown(i)
	{
	        // If new selection
			if (!(intSelected == i))
			{
			    // Drop currently extended bar
				if (!(intSelected == -1))
				{
					setDimLayout(intSelected);
					arrIntDesiredPositions[intSelected] = intRetractedPos;
				}
				
				// Extend newly selected bar
				arrIntDesiredPositions[i] = intExtendedPos;
				setActiveLayout(i);
				
				// Store change in selection
				intSelected = i;
				
				// Start mover thread if it is not already running
				if (!boolRunning)
				{
					mover();
				}
			}
	}
// END INPUT PROCESSING
	
// LAYOUT CHANGING
	function setDimLayout(i)
	{
		var e
		
		// Change previous selection back to dimmed style
		if (!(i == -1))
		{
			e = xGetElementById("tdIntroText" + i);
			e.className = "subMenuIntroTxt" 
			e = xGetElementById("tdMenuTitle" + i);
			e.className = "subMenuTitle" 			
			e = xGetElementById("tdIntroTextHref" + i);
			e.className = "subMenuIntroTxt" 		
			e = xGetElementById("tdMenuButton" + i);
			e.className = "btnSubMenu" 	
		}
	}

	function setActiveLayout(i)
	{
		var e;
		
		// Change new selection to activated style
		e = xGetElementById("tdIntroText" + i);
		e.className = "subMenuIntroTxt smIntroTxtActive" 
		e = xGetElementById("tdIntroTextHref" + i);
		e.className = "subMenuIntroTxt smIntroTxtActive" 
		e = xGetElementById("tdMenuTitle" + i);
		e.className = "subMenuTitle smTitleActive" 		
		e = xGetElementById("tdMenuButton" + i);
		e.className = "btnSubMenu smButtonActive" 	
	}
// END LAYOUT CHANGING
	
// ENGINE
	var intSelected				=    -1; // Currently selected submenu
	var	intRetractedPos			=    20; // Retracted position (pixels from top)
	var intExtendedPos			=	  0; // Extended position (pixels from top)
	var	boolRunning				= false; // Mover thread running or not

	function init()
	{
		// Get extended position (different per brower)
		if (window.navigator.userAgent.indexOf("MSIE") > 0)
		{
			intExtendedPos = -8;
		}
		
		for (var i=0; i < intNumberOfItems; i++) 
		{
			var subMenu = xGetElementById("sub" + i); 
			
			// Make non-emtpy subsubmenu's visible
			reg = new RegExp("[a-zA-Z]");
			if (!(reg.exec(subMenu.innerHTML) == null))
			{
				subMenu.style.visibility = "visible";
			}

			// Test for active menu item
			reg = new RegExp("c[a-zA-Z]{2}" + intActiveItem)
			div = xGetElementById("s" + i);
			if (!(reg.exec(div.innerHTML) == null))
			{
				arrIntDesiredPositions[i] = intExtendedPos;
				subMenu.style.top = intExtendedPos;
				setActiveLayout(i);
				intSelected = i;
			}
			else
			{
				// Retract
				subMenu.style.top = intRetractedPos;
				arrIntDesiredPositions[i] = intRetractedPos;
			}
			
		}
		
	}
	
	function mover()
	{
	
		// Set running to prevent multiple mover threads from running at the same time
		boolRunning = true;
		
		// Default action is to stop, if further moving is neccecary thread will continue
		var boolStop = true;
		
		for (var i=0; i < intNumberOfItems; i++)
		{
		    // Get submenu and its current position
			var subMenu = xGetElementById("sub" + i);
			var curPos = parseInt(xTop(subMenu, null));
			
			// Move submenu
			if (curPos > arrIntDesiredPositions[i])
			{
				subMenu.style.top = (curPos - 1) + "px";
			} 
			else if (curPos < arrIntDesiredPositions[i])
			{
				subMenu.style.top = (curPos + 1) + "px";
			}
			
			// Check to see if further movement is needed
			curPos = parseInt(xTop(subMenu, null));
			if (!(curPos == arrIntDesiredPositions[i]))
			{
				boolStop = false;
			}
		}
		
		if (boolStop)
		{
		    // End thread
			boolRunning = false;
		}
		else
		{
			// Restart function in 20ms
			setTimeout("mover()" , 20);
		}
	}
// END ENGINE