	
	var macMenuEnabled = false;
	
	window.addEvent('domready',initMacMenu);

	function initMacMenu()
	{
		$('macMenuHeading').set({'morph':{duration:500, transition:Fx.Transitions.Sine.easeInOut}, 'opacity':0});

		$$('#macMenu a').each(function(el)
		{
			el.href='javascript:jumpTo("'+el.href+'")';	
		});
		showMacMenu();
	}
	
	function showMacMenu()
	{
		(function(){$('macMenuHeading').morph({'top':0, 'opacity':1})}).delay(0);

		var intLp=0;
		$$('#macMenu a').each(function(el)
		{
			el.getChildren()[0].set({'morph':{duration:500, transition:Fx.Transitions.Sine.easeOut}});
			el.getChildren()[1].set({'morph':{duration:500, transition:Fx.Transitions.Sine.easeOut}});
			(function(){el.getChildren()[0].morph({'top':150})}).delay(intLp*100);
			intLp++;
		});
		(function(){document.addEvent('mousemove',function(event){updateMacMenu(event)})}).delay((intLp*100)+500);
		macMenuEnabled = true;
	}
	
	function hideMacMenu()
	{
		(function(){$('macMenuHeading').morph({'top':-50, 'opacity':0})}).delay(0);

		var intLp=0;

		macMenuEnabled = false;
		$$('#macMenu a').each(function(el)
		{
			el.getChildren()[0].set({'morph':{duration:500, transition:Fx.Transitions.Sine.easeIn}});
			el.getChildren()[1].set({'morph':{duration:500, transition:Fx.Transitions.Sine.easeIn}});
			(function(){el.getChildren()[0].morph({'top':-180})}).delay(intLp*100);
			(function(){el.getChildren()[1].morph({'top':-250})}).delay(intLp*100);
			intLp++;
		});
	}

	function updateMacMenu(e)
	{
		var imageContainer = 'macMenu';	
		var imageCount =  $$('#macMenu a').length;
		var imageWidth =  100;
		var imageHeight = 145;
		var imageGap =    10;
		var imageTop =    150;
		var labels = new Array(imageCount+1);
		
		if (macMenuEnabled)
		{
				
			labels[0] = '/ index';
			for(var i=1; i<=imageCount; i++)
			{
				labels[i]=$$('#macMenu a')[i-1].getChildren()[0].getAttribute('alt');
			}
					
			var imageLeft, totalWidth, mouseX, mouseY, scrollAmount, cursorX;
			var objContainer, distanceX, distanceY, zoomX, zoomY, zoom, doScroll, maxWidth, nearest;
	
			mouseX   = e.client.x;
			mouseY   = e.client.y;

			objContainer = $(imageContainer);
			totalWidth = ((imageCount+2)*imageWidth)+((imageCount)*imageGap);
			doScroll = ((((imageCount)*imageWidth)+((imageCount-1)*imageWidth))>objContainer.offsetWidth);
			cursorX = totalWidth*(mouseX-objContainer.offsetParent.offsetLeft-objContainer.offsetLeft)/(objContainer.offsetWidth);
			scrollAmount = ((cursorX/totalWidth)*(totalWidth-objContainer.offsetWidth)*-1);
			maxWidth = 0;
			nearest  = 0;

			
			distanceY=Math.abs(mouseY-objContainer.offsetParent.offsetTop-objContainer.offsetTop-imageTop-(imageHeight/3));
			zoomY=(1-((distanceY*2)/objContainer.offsetHeight));
			if(zoomY<0) zoomY=0;
	
			for(var i=1; i<=imageCount; i++)
			{
				if(zoomY>0)
				{
					if(doScroll) { imageLeft=((i)*imageWidth)+((i-1)*imageGap)+scrollAmount; }
					else 		 { imageLeft=((i-1)*imageWidth)+((i-2)*+imageGap)+(((9-imageCount)/2)*110); }

					distanceX=Math.round(Math.abs((imageLeft-scrollAmount-cursorX+(imageWidth/2))));
					zoomX=(1-((distanceX*5)/objContainer.offsetWidth));
					if(zoomX<0) zoomX=0;
		
					if(zoomX<zoomY) { zoom=zoomX; }
					else 	        { zoom=zoomY; }
	
					imageLeft = imageLeft-(zoom*50);
	
					if(zoom>0.4)
					{
						document.getElementById('macMenuLarge'+i).style.left=imageLeft+'px';
						document.getElementById('macMenuLarge'+i).style.top=imageTop-(zoom*50)+'px';
						document.getElementById('macMenuLarge'+i).style.width=imageWidth+(zoom*imageWidth)+'px';
						document.getElementById('macMenuLarge'+i).style.height=imageHeight+(zoom*imageHeight)+'px';
						document.getElementById('macMenuLarge'+i).style.zIndex=Math.round(zoom*120);
						document.getElementById('macMenuLarge'+i).style.visibility='visible';		
						document.getElementById('macMenuSmall'+i).style.visibility='hidden';		
					}
					else
					{
						document.getElementById('macMenuSmall'+i).style.left=imageLeft+'px';
						document.getElementById('macMenuSmall'+i).style.top=imageTop-(zoom*50)+'px';
						document.getElementById('macMenuSmall'+i).style.width=imageWidth+(zoom*imageWidth)+'px';
						document.getElementById('macMenuSmall'+i).style.height=imageHeight+(zoom*imageHeight)+'px';
						document.getElementById('macMenuSmall'+i).style.zIndex=Math.round(zoom*120);
						document.getElementById('macMenuLarge'+i).style.visibility='hidden';		
						document.getElementById('macMenuSmall'+i).style.visibility='visible';		
					}
					
					if((Math.round(zoom*120))>maxWidth)
					{
						maxWidth = Math.round(zoom*120);
						nearest = i;
					}
	
				}
				else
				{
	
					document.getElementById('macMenuLarge'+i).style.visibility='hidden';		
					document.getElementById('macMenuSmall'+i).style.visibility='visible';		
					document.getElementById('macMenuSmall'+i).style.left=((i-1)*imageWidth)+((i-1)*imageGap)+(((9-imageCount)/2)*110)+'px';
					document.getElementById('macMenuSmall'+i).style.top=imageTop+'px';
					document.getElementById('macMenuSmall'+i).style.width=imageWidth+'px';
					document.getElementById('macMenuSmall'+i).style.height=imageHeight+'px';
					document.getElementById('macMenuSmall'+i).style.zIndex=0;		
				}
	
			}
			//document.getElementById('macMenuHeading').innerHTML = labels[nearest];		
		}
	}
	

