function SubMenu(text,linktarget,desctext,imagecontent,lines)
{
	this.id = getNewID();
	this.y; // init vom menu aus
	this.z; // init vom menu aus
	
	
	this.lines=lines;
	this.text=text;
	this.target=linktarget;
	this.imagecontent=imagecontent;
	
	this.picleft=new Image();
	this.picright=new Image();
	this.piccent=new Image();
	this.piccentactv=new Image();
	
	this.picleft.src = PICPATH+'sub_left.gif';
	this.picright.src = PICPATH+'sub_right.gif';
	this.piccent.src = PICPATH+'sub_cnt.png';
	this.piccentactv.src = PICPATH+'sub_cnt_actv.png';
	
	this.desccontent = new ContentText(DESC_WIDTH,DESC_HEIGHT,desctext,'left_text_content','#000000');
	var desccontents = new Array();
	desccontents.push(this.desccontent);
	this.descfield = new DynField ('light',DESC_CX,DESC_CY,DESC_WIDTH,DESC_HEIGHT,1,desccontents);
	
	//methoden
	this.create = SubMenuCreate;
	this.show = SubMenuShow;
	this.hide = SubMenuHide;
	this.activate = SubMenuActivate;
	this.deactivate = SubMenuDeactivate;
	this.getHeight = SubMenuGetHeight;
}

function SubMenuCreate(cx)
{ 
	var left = cx - ( MENU_WIDTH/2 ); 
	
	document.write('<div class="sub_menu" id="'+this.id+'" style="position:absolute; top:'+this.y+'px; left:'+left+'px; width:'+MENU_WIDTH+'px; height:'+MENU_HEIGHT+'px; z-index:'+this.z+';"');	
	
	document.write('onmouseover="menuMouseOver('+this.id+')"');
	document.write('onmouseout="menuMouseOut('+this.id+')"');
	
	if (this.target != null)
		document.write('onclick="link(\''+this.target+'\')"');
		
	document.write('>');
	
	document.write('<div style="position:absolute;top:0px;left:0px;"><img src="'+this.picleft.src+'" height="'+(16*this.lines+4)+'px" width="3px"/></div>');
	document.write('<div style="position:absolute;top:0px;left:3px;"><img src="'+this.piccent.src+'" width="'+(MENU_WIDTH)+'px" height="'+(16*this.lines+4)+'px"/></div>');
	document.write('<div style="position:absolute;top:0px;left:'+(MENU_WIDTH+3)+'px;"><img src="'+this.picright.src+'" height="'+(16*this.lines+4)+'px" width="3px"/></div>');
	
	document.write('<div style="position:absolute;top:3px;left:5px;">'+this.text+'</div>');
	
	document.write('</div>');
	
	this.descfield.create();
	this.descfield.hide();
	
	if (this.imagecontent != null)
	{
		this.imagecontent.create();
		this.imagecontent.hide();
	}
}

function SubMenuShow()
{
	var node = document.getElementById(this.id);
	node.style.visibility = 'visible';
}

function SubMenuHide()
{
	var node = document.getElementById(this.id);
	node.style.visibility = 'hidden';
}

function SubMenuActivate()
{
	var node = document.getElementById(this.id);
	node.childNodes[1].firstChild.src = this.piccentactv.src;
	node.style.color = '#FFFFFF'
	
	this.descfield.show();
	
	if (this.imagecontent != null)
	{
		this.imagecontent.show();
	}
}

function SubMenuDeactivate()
{
	var node = document.getElementById(this.id);
	node.childNodes[1].firstChild.src = this.piccent.src;
	node.style.color = '#000000'
	
	this.descfield.hide();
	
	if (this.imagecontent != null)
	{
		this.imagecontent.hide();
	}
}

function SubMenuGetHeight()
{
	return (15*this.lines)-(2*(this.lines-1));
}
