function Label(cx,cy,width,height,color,text,csstext,linktarget,desctext)
{
	this.id = getNewID();
	
	this.content = new ContentText(width,height,text,csstext,'#FFFFFF');
	
	var contents = new Array();
	contents.push(this.content);
	
	this.field = new DynField (color,width/2,height/2,width,height,1,contents);
	
	if (desctext != null)
	{
		var desccontent = new ContentText(DESC_WIDTH,DESC_HEIGHT,desctext,'left_text_content','#000000');
		var desccontents = new Array();
		desccontents.push(desccontent);
		this.descfield = new DynField ('light',DESC_CX,DESC_CY,DESC_WIDTH,DESC_HEIGHT,1,desccontents);
	}
	else
		this.descfield = null;
	
	this.color=color;
	this.width=width;
	this.height=height;
	this.cx=cx;
	this.cy=cy;
	this.target=linktarget;
	
	this.lines = new Array();
	
	// methoden
	this.create = LabelCreate;
	this.activate = LabelActivate;
	this.deactivate = LabelDeactivate;
	this.generateLine = LabelGenerateLine;
	this.addLine = LabelAddLine;
	this.showLines = LabelShowLines;
	this.hideLines = LabelHideLines;
}

function LabelCreate()
{
	var left = this.cx - (this.width / 2);
	var top = this.cy - (this.height / 2);
	 
	document.write('<div id="'+this.id+'" style="position:absolute; top:'+top+'px; left:'+left+'px; width:'+this.width+'px; height:'+this.height+'px; z-index:1000;"');	
	
	document.write('onmouseover="menuMouseOver('+this.id+')"');
	document.write('onmouseout="menuMouseOut('+this.id+')"');
	
	if (this.target != null)
		document.write('onclick="link(\''+this.target+'\')"');
		
	document.write('>');
	
	this.field.create();
	
	document.write('</div>');
	
	for (var i in this.lines)
		this.lines[i].create(this.id,this.target);
	
	if (this.descfield != null)
	{	
		this.descfield.create();
		this.descfield.hide();
	}
}

function LabelActivate()
{
	for (var i in this.lines)
		this.lines[i].activate();
	
	this.field.setColor('red');
	
	if (this.descfield != null)
		this.descfield.show();
}

function LabelDeactivate()
{
	for (var i in this.lines)
		this.lines[i].deactivate();
		
	this.field.setColor(this.color);
	
	if (this.descfield != null)
		this.descfield.hide();
}

function LabelGenerateLine(targetx,targety,helpx,helpy,outpos)
{
	var x1,y1,x2,y2,x3,y3,x4,y4;
	
	x1=targetx;
	y1=targety;
	
	switch (outpos)
	{
		case 't': 
			
			if( (helpx != null) && (helpy != null) )
			{
				x2=x1;
				y2=helpy;
				x3=this.cx;
				y3=y2;
				x4= x3;
			  y4= this.cy - (this.height/2)-3;
			}
			else
			{
				x2=this.cx;
				y2=y1;
				x3= this.cx;
				y3= this.cy - (this.height/2)-3;
				x4= null;
				y4= null;
			}
			
			break;
			
		case 'b': 
		
			if( (helpx != null) && (helpy != null) )
			{
				x2=x1;
				y2=helpy;
				x3=this.cx;
				y3=y2;
				x4= x3;
			  y4= this.cy + (this.height/2)+3;
			}
			else
			{
				x2=this.cx;
				y2=y1;
				x3= this.cx;
				y3= this.cy + (this.height/2)+3;
				x4= null;
				y4= null;
			}
			
			break;
			
		case 'l': 
		
			if( (helpx != null) && (helpy != null) )
			{
				x2=helpx;
				y2=y1;
				x3=x2;
				y3=this.cy;
				x4= this.cx - (this.width/2)-3;
			  y4= y3;
			}
			else
			{
				x2=x1;
				y2=this.cy;
				x3= this.cx - (this.width/2)-3;
			  y3= y2;
				x4= null;
				y4= null;
			}
			
			break;
			
		case 'r': 
		
			if( (helpx != null) && (helpy != null) )
			{
				x2=helpx;
				y2=y1;
				x3=x2;
				y3=this.cy;
				x4= this.cx + (this.width/2)+3;
			  y4= y3;
			}
			else
			{
				x2=x1;
				y2=this.cy;
				x3= this.cx + (this.width/2)+3;
			  y3= y2;
				x4= null;
				y4= null;
			}
			
			break;
	}
	
	return new Line(x1,y1,x2,y2,x3,y3,x4,y4);	
}

function LabelAddLine(targetx,targety,helpx,helpy,outpos)
{
	this.lines.push( this.generateLine(targetx,targety,helpx,helpy,outpos) );
}

function LabelShowLines()
{
	for (var i in this.lines)
		this.lines[i].show();
}

function LabelHideLines()
{
	for (var i in this.lines)
		this.lines[i].hide();
}