function menupopup(menuObj, size)
{
	var thisObj = this;
	this.menuObj = menuObj;
	this.clock = 10;
	this.totalTime = 1000;
	this.state = 0;
	this.size = size;
	this.percent = 0;
	this.t = null;

	
	// opacity
	this.changeOpac = function (opacity) {
		var object = this.menuObj.style;
		object.opacity = (opacity / 100);
		object.MozOpacity = (opacity / 100);
		object.KhtmlOpacity = (opacity / 100);
		object.filter = "alpha(opacity=" + opacity + ")";		
	}
	
	
	// expand
	this.expand = function()
	{		
		var previousPercent =  thisObj.percent;
		
		clearInterval(thisObj.t);
		thisObj.state = 1;
		var date1 = new Date();
		
		thisObj.t = setInterval
		(
				function()
				{
					var date2 = new Date();
					thisObj.percent = (date2.getTime() - date1.getTime()) / (thisObj.totalTime * (1 - previousPercent));
					if (thisObj.percent > 1) {thisObj.percent = 1; clearInterval(thisObj.t);}					
					thisObj.menuObj.style.height = ((previousPercent + ((1- previousPercent) * thisObj.percent)) * thisObj.size) + "px";					
					thisObj.changeOpac((previousPercent + ((1- previousPercent) * thisObj.percent)) * 100);					
				},
				thisObj.clock
		);
	}

	
	// collapse
	this.collapse = function()
	{		
		var previousPercent =  thisObj.percent;
		
		clearInterval(thisObj.t);
		thisObj.state = 0;
		var date1 = new Date();
		
		thisObj.t = setInterval
		(
				function()
				{
					var date2 = new Date();
					thisObj.percent = 1 - ((date2.getTime() - date1.getTime()) / (thisObj.totalTime * previousPercent));
					if (thisObj.percent < 0) {thisObj.percent = 0; clearInterval(thisObj.t);}
					thisObj.menuObj.style.height = (previousPercent * thisObj.size * thisObj.percent) + "px";
					thisObj.changeOpac(previousPercent * thisObj.percent * 100);
				},
				thisObj.clock
		);
	}

	
	// flip
	this.flip = function()
	{
		if (thisObj.state)
			thisObj.collapse();
		else
			thisObj.expand();
	}
	
}
