function ShowSub(mid, sid)
{
	var mtarget = document.getElementById(mid);
	var starget = document.getElementById(sid);
	mtarget.className     = mtarget.className + (' '+mtarget.className + 'Act');
	starget.style.left    = getABS(mtarget) + 'px';
	starget.style.visibility = 'inherit';
}

function HideSub(mid, sid, number)
{
	var mtarget = document.getElementById(mid);
	var starget = document.getElementById(sid);
	mtarget.className     = menu[number][2];
	starget.style.visibility = 'hidden';
}


function BuildMenu(activeId, isInner)
{
	var mItem   = '';
	var sItem   = '';
	var active  = activeId;
	var mtarget = document.getElementById('menu');
	var starget = document.getElementById('submenu');
	var subMenu = (isInner)? 'subMenuInner' : 'subMenu';
	
	for(x = 0; x < menu.length; x++){
		
		_href  = menu[x][1];
		_class = (active == x)? (menu[x][2] + ' ' +'menuCurrent') : menu[x][2];
		//_class = menu[x][2];
		//alert(_class);
		_text  = menu[x][0];
		_mid    = 'm'+x;
		_sid    = 's'+x;
		
		
		/* menu item without submenu data */
		if(menu[x][4].length == 0){
			mItem += '<div><a href="'+_url+_href+'" class="'+_class+'">'+_text+'</a></div>';
			continue;
		}
		
		/* menu item with submenu data */
		mItem += '<div><a href="'+_url+_href+'" class="'+_class+'" id="'+_mid+'" onmouseover="ShowSub(\''+_mid+'\',\''+_sid+'\')" onmouseout="HideSub(\''+_mid+'\',\''+_sid+'\', '+x+')" >'+_text+'</a></div>';
		
		sItem += '<div class="' + subMenu + '" style="width:'+menu[x][3]+'px; padding-top:10px; position:absolute; visibility:hidden" id="'+_sid+'" onmouseover="ShowSub(\''+_mid+'\',\''+_sid+'\')" onmouseout="HideSub(\''+_mid+'\',\''+_sid+'\', '+x+')">';
		sItem += '<div class="sMenuContainer subMenuBg">';
		sItem += '<div class="sMenuLinks">';
		
		var _target	=	'';
		
		for(y = 0; y < menu[x][4].length; y++){
			_shref = menu[x][4][y][1];
			_stext = menu[x][4][y][0];
			
			if (menu[x][4][y][2] != undefined)
				_target	=	" target = '" + menu[x][4][y][2] + "'";
			
			sItem += '<a href="'+_url+_shref+'"'+_target+'>'+_stext+'</a><br />';
		}
		
		sItem += '</div>';
		sItem += '</div>';
		sItem += '<table border="0" width="100%" cellpadding="0" cellspacing="0">';
		sItem += '<tr>';
		sItem += '<td width="17" height="18"><img src="'+_path+'images/menu_sub_left.gif" alt="" width="17" height="18" /></td>';
		sItem += '<td class="subMenuBg" width="100%"></td>';
		sItem += '<td width="17"><img src="'+_path+'images/menu_sub_right.gif" alt="" width="17" height="18" /></td>';
		sItem += '</tr>';
		sItem += '</table>';
		sItem += '</div>';
		
		
	}
	mtarget.innerHTML = mItem;
	starget.innerHTML = sItem;
}



function getABS(Obj)
{
	var left = 0;
	while(Obj.offsetParent){
		left += Obj.offsetLeft;
		Obj   = Obj.offsetParent;
	}
	return left;
}