	var isMoving=false;
	var marker;
	var markerPos;
	var markerPositions = new Array();
	var secWidth = new Array();
	var imgLoaded = 0;

	function calcPositions(inPos, inWid){
		markerPositions = inPos;
		secWidth = inWid;		
	}

	function setMarkerPosition(inSection){
            if (inSection != null) {
				if(markerPositions.length == 0){
					var t = document.getElementById("menusections");			
					var x = t.getElementsByTagName('li');
					var mPos = new Array();
					var mWid = new Array();
					
					var totWidth=15;
					for(var i = 0; i<x.length; i++){
						totWidth = totWidth+x[i].offsetWidth; 
						mPos[mPos.length] = totWidth;
						mWid[mWid.length] = x[i].offsetWidth;
					}		

					calcPositions(mPos, mWid);
				}
				var m = document.getElementById("menumarker");
				var left = (markerPositions[inSection]-parseInt((secWidth[inSection]/2),10));
				//var left= (markerPositions[inSection]-parseInt((secWidth[inSection]-22)/2,10))-14/2;
				//alert("inSection is " + markerPositions[inSection] + "\n" +" secWidth[inSection] is " + secWidth[inSection]);
		        m.style.left = left+"px";
		        m.style.display = "block";
		   }
	}

	function moveNext(){
		if(selectedSection == sectionsX.length -1) return;
		var newSection = parseInt(selectedSection,10) +1;
		moveToSection(newSection);			
	}
	
	function movePrevious(){
		if(selectedSection==0) return;
		var newSection = parseInt(selectedSection,10) -1;
		moveToSection(newSection);
	}		
	
	function createFlash(i){
		createFlashObj(sections[selectedSection][i]);
	}


	function moveToSection(inSection){		
		if(isMoving)return;
		var from, to;
		highlightMenu(inSection);
		if(selectedSection == -1){
			isMoving = true;
			setMarkerPosition(inSection);		
			sectionsX[inSection].style.display="block";					
			for(var i = 0; i<sections[inSection].length;i++){		
				createFlashObj(sections[inSection][i]);
			}
			changeMenu(inSection);	
			selectedSection = inSection;
			isMoving = false;
			return;
		}	
			
		sectionsX[selectedSection].style.display="none";
		sectionsX[inSection].style.display="block";
		if(inSection == selectedSection){setMarkerPosition(selectedSection); return;}
		isMoving = true;
		for(var i = 0; i<sections[selectedSection].length;i++){
			removeE(sections[selectedSection][i]["element"]);
		}
		
		marker = document.getElementById("menumarker");
		from = (markerPositions[selectedSection]-parseInt((secWidth[selectedSection]/2),10));
		to = (markerPositions[inSection]-parseInt((secWidth[inSection]/2),10));
					
		markerPos = to - from;
		new Effect.Move(marker,{y:0, x:markerPos, duration:0.4,afterFinishInternal: function() 
		{
			for(var i = 0; i<sections[inSection].length;i++){		
				createFlashObj(sections[inSection][i]);
				isMoving = false;
			}	
		}
		});
		changeMenu(inSection);
		
		selectedSection = inSection;
	}

	function highlightMenu(inSection){
		
		var u = document.getElementById("menusections");
		//var x = u.getElementsByTagName('LI');
		var x = u.getElementsByTagName('A');
	
		for(var i = 0; i<x.length; i++){
			if(i==inSection){
				x[i].className="selected";	
			}else{
				x[i].className="";
			}
		}		
	}

	function moveMarker(e,x,y){		
		new Effect.Move(e,{queue: { position:'end', scope:'global'},y:y, x:x, duration:0.4,afterFinishInternal: function() 
		{alert("done...")}});
	}
	
	function removeE(e){		
		while(e.hasChildNodes()){e.removeChild(e.lastChild);}
	}


	function createFlashObj(para){
		var e = para["element"];
		while(e.hasChildNodes()){e.removeChild(e.lastChild);}
		
		var element;
		var fSize = e.id.substr(0,1).toUpperCase();
		var fHeight, fWidth, fSrc, fVars;
		if(fSize=="S"){
			fHeight= "328";
			fWidth= "355";
			fSrc = "/furniture/swf/flash_small_355x328";
		}else if(fSize=="M"){
			fHeight="328";
			fWidth="355";
			fSrc = "/furniture/swf/flash_medium_355x328";				
		}else if(fSize=="L"){
			fHeight="328";
			fWidth="721";
			fSrc = "/furniture/swf/flash_large_721x328";
		}else{
			fHeight=0;
			fWidth=0;
			fSrc = "";
		}
		
		fVars = para["vars"];
		
		var html = "";
		var param = new Array();
		
		if(hasRightVersion) {
			param[param.length] = "codebase";
			param[param.length] = "http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,24,0";
			param[param.length] = "width";
			param[param.length] = fWidth;
			param[param.length] = "height";
			param[param.length] = fHeight;
			param[param.length] = "src";
			param[param.length] = fSrc;
			param[param.length] = "quality";
			param[param.length] = "high";
			param[param.length] = "pluginspage";
			param[param.length] = "http://www.macromedia.com/go/getflashplayer";
			param[param.length] = "align";
			param[param.length] = "middle";
			param[param.length] = "play";
			param[param.length] = "true";
			param[param.length] = "loop";
			param[param.length] = "true";
			param[param.length] = "scale";
			param[param.length] = "showall";
			param[param.length] = "wmode";
			param[param.length] = "transparent";
			param[param.length] = "devicefont";
			param[param.length] = "false";
			param[param.length] = "id";
			param[param.length] = e.id + "flash";
			param[param.length] = "bgcolor";
			param[param.length] = "#ffffff";
			param[param.length] = "name";
			param[param.length] = fSrc;
			param[param.length] = "menu";
			param[param.length] = "true";
			param[param.length] = "allowScriptAccess";
			param[param.length] = "always";
			param[param.length] = "allowFullScreen";
			param[param.length] = "false";
			param[param.length] = "movie";
			param[param.length] = fSrc;
			param[param.length] = "salign";
			param[param.length] = "";
			param[param.length] = "flashvars";
			param[param.length] = fVars;
			html = AC_FL_RunContentArray(param);
			
		}else{
			//Render images instead of flash for Wii Console				
			if(fSize == "S"){
				var buffer = new Array();					
				buffer[buffer.length] = "<div class='small_topleft'><img alt='' src='"+para["altimages"][0]+"' /></div>";
				buffer[buffer.length] = "<div class='small_topright'><img alt='' src='"+para["altimages"][1]+"' /></div>";										
				buffer[buffer.length] = "<div class='small_left'><img alt='' src='"+para["altimages"][2]+"' /></div>";
				buffer[buffer.length] = "<div class='small_right'><img alt='' src='"+para["altimages"][3]+"' /></div>";										
				buffer[buffer.length] = "<div class='small_left'><img alt='' src='"+para["altimages"][4]+"' /></div>";
				buffer[buffer.length] = "<div class='small_right'><img alt='' src='"+para["altimages"][5]+"' /></div>";					
				html = buffer.join("");
			}else if(fSize == "M"){
				html = "<img src='"+para["altimages"][0]+"' height='328' width='355' alt='' />";
			}else if(fSize == "L"){				
				html = "<img src='"+para["altimages"][0]+"' height='328' width='721' alt='' />";
			}else{
				html = "<alt>No images</alt>";
			}
		}
		e.innerHTML=html;
	}

	
	function changeMenu(inSec){
		var ref;
		
		for(var i=0; i<menu.length;i++){
			ref = "sub"+menu[i];				
			document.getElementById(ref).style.display = "none";
		}
		
		ref = document.getElementById("sub"+menu[inSec]);
		ref.style.display = "block";
	}