
/*
*
* COPYRIGHT (c) BYSANT AS
*
* This code was developed by Bysant AS (www.bysant.com)
* The code is owned by Bysant and can only be used by Bysants' customers!
* Unauthorized use of this code will be prosecuted to the maximum extent possible by law!
* Unauthoirzed distribution of this code is strongly prohibited.
* The code cannot be modified in any way unless written permission is given by Bysant AS.
* 
* Denne programkoden ble utviklet av Bysant AS (www.bysant.com)
* Programkoden eies av Bysant AS og kan kun benyttes av Bysant sine kunder!
* Ikke autorisert brukt av denne programkoden vil bli strafferetslig forfulgt!
* Alle uautorisert distribusjon av denne programkoden er strengt forbudt.
* Programkoden kan ikke modifiseres med mindre skriftlig tillatelse er gitt av Bysant AS
* 
*/

function MFXrunMenu(myName,newspeed)
{
	ieStep=0;
	thereS=false;
	thereC=false;
	if(newspeed>0){mySpeed=newspeed;}
	first=myName;
	if(whichOpen==-1&&!running&&MFXmain[myName]&&!(whichOpen==myName))
	{
		running=true;
		if(NN)
		{
			myLayer[myName+1].clip.height=0;
			myLayer[myName+1].visibility=VISIBLE;
		}

		if(IE)
		{

			myLayer[myName+1].clip= "rect(" + ("auto") +" "+ ("auto") +" "+ (0) +" "+ ("auto") +")";
			myLayer[myName+1].visibility=VISIBLE;		
		}

		if(DOM1)
		{
			myLayer[myName+1].clip.height=0;			
			myLayer[myName+1].visibility=VISIBLE;			
		}

		MFXopenMenuS(myName);
		MFXopenMenuC(myName);
	}

	if(whichOpen>=0&&!running&&!(whichOpen==myName))
	{

		running=true;
		second=whichOpen;
		ieStep1=myHeight[second+1];
		thereCS=false;
		thereCC=false;
		MFXcloseMenuS(second);
		MFXcloseMenuC(second);
	}

	if(whichOpen>=0&&!running&&whichOpen==myName&&closes)
	{

		running=true;
		second=whichOpen;
		ieStep1=myHeight[second+1];
		thereCS=false;
		thereCC=false;
		MFXcloseMenuS(second);
		MFXcloseMenuC(second);

	}

}

function MFXstopCloseS(myName)
{

	running=false;
	thereCS=true;
	if(closes&&first==whichOpen){whichOpen=-1;}
	else
	{
		whichOpen=-1;
		MFXrunMenu(first);
	}

}

function MFXstopOpenS(myName)
{
	running=false;
	thereS=true;
	if(IE)
	{
		myLayer[myName+1].clip= "rect(" + ("auto") +" "+ ("auto") +" "+ ("auto") +" "+ ("auto") +")";
	}
	whichOpen=myName;

}

function MFXopenMenuS(myName)
{
	myStep=mySpeed;
	if(NN&&!thereS&&!(first==lastMain))
	{
		if(myLayer[first+2].top+myStep>mySlide[first+1])
		{
			myStep=mySlide[first+1]-myLayer[first+2].top;
		}

		for(i=first+2; i < myLayer.length; i+=2)
		{
			myLayer[i].top+=myStep;			
		}

		if(myLayer[first+2].top==mySlide[first+1])
		{
			MFXstopOpenS(first)
		}		

		if(running)setTimeout('MFXopenMenuS(first)',10);

	}

	if(IE&&!thereS&&!(first==lastMain))
	{
		if(myLayer[first+2].pixelTop+myStep>mySlide[first+1])
		{
			myStep=mySlide[first+1]-myLayer[first+2].pixelTop;
		}

		for(i=first+2; i < myLayer.length; i+=2)
		{
			myLayer[i].pixelTop+=myStep;
		}

		if(myLayer[first+2].pixelTop==mySlide[first+1])
		{
			MFXstopOpenS(first)
		}

		if(running)setTimeout('MFXopenMenuS(first)',10);
	}

	if(DOM1&&!thereS&&!(first==lastMain))
	{
		
		if((eval((myLayer[first+2].top).slice(0, -2))+myStep)>mySlide[first+1])
		{		
			myStep=mySlide[first+1]-(eval((myLayer[first+2].top).slice(0, -2)));
		}

		for(i=first+2; i < myLayer.length; i+=2)
		{			
			temp = eval((myLayer[i].top).slice(0, -2));
			temp += myStep;
			
			setPosY(("MFX"+i),temp);
		}

		
		if(eval((myLayer[first+2].top).slice(0, -2)) == mySlide[first+1])
		{
			MFXstopOpenS(first)
		}

		if(running)setTimeout('MFXopenMenuS(first)',10);

	}
}

function MFXopenMenuC(myName)
{

	myStep=mySpeed;

	if(NN&&!thereC)
	{

		if ((myLayer[first+1].clip.height+myStep)>myHeight[first+1])
		{
			myLayer[first+1].clip.height=myHeight[first+1]
		}

		if(myLayer[first+1].clip.height==myHeight[first+1])
		{
			thereC=true;
			whichOpen=first;
			MFXstopOpenS(first)
		}
		else
		{
			myLayer[first+1].clip.height+=myStep;
		}

		if(running)setTimeout('MFXopenMenuC(first)',10);
	}

	if(IE&&!thereC)
	{
		ieStep+=myStep;
		myLayer[myName+1].clip= "rect(" + ("auto") +" "+ ("auto") +" "+ (ieStep) +" "+ ("auto") +")";

		if(ieStep>=myHeight[first+1])
		{
			thereC=true;
			whichOpen=first;
			MFXstopOpenS(first)
		}

		if(running)setTimeout('MFXopenMenuC(first)',10);
	}
	
	if(DOM1&&!thereC)
	{
		ieStep+=myStep;
		myLayer[myName+1].clip= "rect(" + ("auto") +" "+ ("auto") +" "+ (ieStep) +" "+ ("auto") +")";

		if(ieStep>=myHeight[first+1])
		{
			thereC=true;
			whichOpen=first;
			MFXstopOpenS(first)
		}

		if(running)setTimeout('MFXopenMenuC(first)',10);
	}
}

function MFXcloseMenuS(myName)
{

	myStep=mySpeed;

	if(NN&&!thereCS&&!(second==lastMain))
	{
		if(myLayer[second+2].top-myStep < myTop[second+2])
		{
			myStep=myLayer[second+2].top-myTop[second+2];
		}

		for(i=second+2; i < myLayer.length; i+=2)
		{
			myLayer[i].top-=myStep;
		}

		if(myLayer[second+2].top==myTop[second+2])
		{
			MFXstopCloseS(second);
		}

		if(running)setTimeout('MFXcloseMenuS(second)',10);
	}

	if(IE&&!thereCS&&!(second==lastMain))
	{

		if(myLayer[second+2].pixelTop-myStep < myTop[second+2])
		{
			myStep=myLayer[second+2].pixelTop-myTop[second+2];
		}

		for(i=second+2; i < myLayer.length; i+=2)
		{
			myLayer[i].pixelTop-=myStep;
		}

		if(myLayer[second+2].pixelTop==myTop[second+2])
		{
			MFXstopCloseS(second);
		}

		if(running)setTimeout('MFXcloseMenuS(second)',10);
	}

	if(DOM1&&!thereCS&&!(second==lastMain))
	{

		if((eval((myLayer[second+2].top).slice(0, -2))-myStep) < myTop[second+2])
		{
			myStep=eval((myLayer[second+2].top).slice(0, -2))-myTop[second+2];
		}

		for(i=second+2; i < myLayer.length; i+=2)
		{
			temp = eval((myLayer[i].top).slice(0, -2));			
			temp -= myStep;
			setPosY(("MFX"+i),temp);
		}		
		
		if(eval((myLayer[second+2].top).slice(0, -2))==myTop[second+2])
		{
			MFXstopCloseS(second);
		}

		if(running)setTimeout('MFXcloseMenuS(second)',10);
	}


}

function MFXcloseMenuC(myName)
{

	myStep=-mySpeed;
	ieStep1-=mySpeed;
	if(NN&&!thereCC)	{

		if ((myLayer[second+1].clip.bottom+myStep) < 0)
		{
			myLayer[second+1].clip.bottom=0;
		}

		if(myLayer[second+1].clip.bottom==0)
		{
			thereCC=true;
			if(second==lastMain)MFXstopCloseS(second);
		}
		else
		{
			myLayer[second+1].clip.bottom+=myStep;
		}

		if(running)setTimeout('MFXcloseMenuC(second)',10);

	}

	if(IE&&!thereCC)
	{

		if(ieStep1 <= 0)
		{
			myLayer[myName+1].clip= "rect(" + ("auto") +" "+ ("auto") +" "+ (0) +" "+ ("auto") +")";
			thereCC=true;
			if(second==lastMain)MFXstopCloseS(second);
		}
		else
		{
			myLayer[myName+1].clip= "rect(" + ("auto") +" "+ ("auto") +" "+ (ieStep1) +" "+ ("auto") +")";
		}

		if(running)setTimeout('MFXcloseMenuC(second)',10);
	}
	if(DOM1&&!thereCC)
	{
		if(ieStep1 <= 0)
		{
			myLayer[myName+1].clip= "rect(" + ("auto") +" "+ ("auto") +" "+ (0) +" "+ ("auto") +")";
			thereCC=true;
			if(second==lastMain)MFXstopCloseS(second);
		}
		else
		{
			myLayer[myName+1].clip= "rect(" + ("auto") +" "+ ("auto") +" "+ (ieStep1) +" "+ ("auto") +")";
		}
		if(running)setTimeout('MFXcloseMenuC(second)',10);
	}
}

var lastclicked=-1
function MFXrunMenu2(id, ms) 
{
	if (lastclicked!=-1) 
	{	
		//lLayer=(NN) ? eval("document.MFX" + (lastclicked+1)) : eval("document.all.MFX" + (lastclicked +1) + ".style")		
		if (document.layers) lLayer = eval("document.MFX"+(lastclicked+1));
			else if (document.all) lLayer = eval("document.all.MFX"+(lastclicked+1) + ".style");
			else if (document.getElementById) lLayer = eval("document.getElementById('MFX"+(lastclicked+1)+"').style");	
  	
  	lLayer.visibility=HIDDEN
	}
 
	MFXrunMenu(id, ms)
	lastclicked=id
}
