function MenuPoint(text,linktarget,desctext,lines) // ist ein label + ausklappfnkt
{
	this.id = getNewID();
	this.points = new Array();
	
	this.cx; // init vom menu aus
	this.cy; // init vom menu aus
	this.color;// init vom menu aus
	this.menu; // init vom menu aus
	this.idx; // init vom menu aus
	
	this.text=text;
	this.linktarget=linktarget;
	this.desctext=desctext;
	this.lines=lines;
	
	this.label; // bei create()
	
	this.generate= MenuPointGenerate; // weil nicht alle label-parameter mit konstruktor bekannt	
	this.create= MenuPointCreate;	
	this.addLine = MenuPointAddLine;
	this.addPoint = MenuPointAddPoint;
	
	this.activate = MenuPointActivate;
	this.deactivate = MenuPointDeactivate;
	this.deactivate2 = MenuPointDeactivate2;// das richtige deactivate (wegen stehenbleiben der markierung)
	
	this.getSubMenuHeight = MenuPointGetSubMenuHeight;
	this.getHeight = MenuPointGetHeight;
}

function MenuPointGenerate() // init vom menu aus
{
	this.label = new Label(this.cx,this.cy,MENU_WIDTH,MENU_HEIGHT*this.lines,this.color,this.text,'menu_content',this.linktarget,this.desctext);
}

function MenuPointCreate()
{
	document.write('<div id="'+this.id+'" style="position:absolute; top:0px; left:0px;"');	
	document.write('onmouseover="menuMouseOver('+this.id+')"');
	document.write('onmouseout="menuMouseOut('+this.id+')"');
	document.write('>');
	
	this.label.create();
	this.label.hideLines();
	
	document.write('</div>');
	
	var curr_y = this.cy + ( (MENU_HEIGHT*this.lines) / 2);// + i*16;
	for ( var i in this.points )
	{
		this.points[i].y = curr_y;
		curr_y = curr_y + 13 * this.points[i].lines +2;
		this.points[i].z=i;
		this.points[i].create(this.cx-3);
		this.points[i].hide();
	}
}

function MenuPointAddLine(targetx,targety,helpx,helpy,outpos)
{
	this.label.addLine(targetx,targety,helpx,helpy,outpos);
}

function MenuPointActivate()
{
	this.menu.deactvAllPoints(this.idx);
	
	this.label.showLines();
	this.label.activate();
	
	this.menu.moveDownPoints( this.idx,this.getSubMenuHeight());
	
	for ( var i in this.points )
	{
		this.points[i].show();
	}
}

function MenuPointDeactivate() // dummy 
{
	this.label.showLines();
	this.label.activate();
}

function MenuPointDeactivate2()
{
	this.label.hideLines();
	this.label.deactivate();
	
	for ( var i in this.points )
	{
		this.points[i].hide();
	}
	
	this.menu.moveUpPoints(this.idx);
}

function MenuPointAddPoint( pnt )
{
	this.points.push(pnt);	
}

function MenuPointGetSubMenuHeight()
{
	var result = 0; 
	
	for ( var i in this.points )
	{
		result = result + this.points[i].getHeight();
	}
	
	return result+2;
}

function MenuPointGetHeight()
{
	return MENU_HEIGHT*this.lines + 6;
}


////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function Menu(cx,y,height,sep)
{
	this.points = new Array(); // MenuPoints
	
	this.cx=cx;
	this.y=y;
	this.height=height;
	this.sep=sep;
	this.nextcolor='med';
	
	this.addPoint = MenuAddPoint;
	this.create= MenuCreate;	
	this.getNextColor = MenuGetNextColor;
	
	this.moveUpPoints = MenuMoveUpPoints;
	this.moveDownPoints = MenuMoveDownPoints;
	this.deactvAllPoints = MenuDeactvAllPoints;
}

function MenuAddPoint( point )
{
	var y_offset = 0;
	
	for ( var i in this.points )
		y_offset = y_offset + this.points[i].getHeight() + this.sep;
	
	//MenuPoints
	point.cx = this.cx;
	point.cy = this.y + y_offset + (point.lines * MENU_HEIGHT)/2;
	
	point.color = this.getNextColor();
	point.menu = this;
	point.idx = this.points.length;
	point.generate();
	
	this.points.push(point);
}

function MenuCreate()
{
	for ( var i in this.points )
		this.points[i].create();
}

function MenuGetNextColor()
{
	if( this.nextcolor=='med' )
		this.nextcolor='dark';
	else 
		this.nextcolor='med';
		
	return this.nextcolor;
}

function MenuMoveDownPoints(idx,amount)
{
	for ( var i = idx+1; i<this.points.length; i++)	
	{
		document.getElementById( this.points[i].label.id ).style.top = (this.points[i].label.cy - (this.points[i].label.height / 2) + amount)+'px';	
	}
}

function MenuMoveUpPoints(idx)
{
	for ( var i = idx+1; i<this.points.length; i++)	
	{
		document.getElementById( this.points[i].label.id ).style.top = (this.points[i].label.cy - (this.points[i].label.height / 2) )+'px';	
	}
}

function MenuDeactvAllPoints(idx)
{
		for ( var i in this.points )
			if( i != idx)
				this.points[i].deactivate2();
}
