function insertNewMenuItem(mNum, mPos, mText, link)
{
if(mNum < 0) return false;
mNum = (mNum * 2) + 1;
var ln = 0;
while(document.getElementById('bm_' + mNum + '_' + (++ln))){}
if(mPos > ln) mPos = ln;
var newItem = document.getElementById('bm_' + mNum + '_' + (ln-1)).cloneNode(true);
if(window.ActiveXObject)
{
newItem.id = 'bm_' + mNum + '_' + ln;
newItem.onmouseover = (function(n){  return function(){mi('m_' + mNum + '_' + n, event)}})(ln);
newItem.onmouseout = function(){mo(window.event)};
newItem.onclick = function(){go_abs(link, event)};
}
else
{
newItem.setAttribute('id','bm_' + mNum + '_' + ln);
newItem.setAttribute('onmouseover','mi("m_' + mNum + '_' + ln + '", event)');
newItem.setAttribute('onmouseout','mo(event)');
newItem.setAttribute('onclick','go_abs("' + link + '", event)');
}
newItem.getElementsByTagName('div')[0].innerHTML = mText.replace(/ /g, '&nbsp;');
var ins = document.getElementById('bm_' + mNum + '_1').parentNode;
if(mPos + 1 < ln)
ins.insertBefore(newItem, document.getElementById('bm_' + mNum + '_' + (mPos+1)));
else
ins.appendChild(newItem);
}
function getMenuId(txt)
{
var td;
for(var n = 1,d; td=document.getElementById('bm_' + n); n+=2)
{
d = td.getElementsByTagName('div');
if(d.length && d[0].innerHTML.toLowerCase() == txt.toLowerCase()) return (n-1) / 2;
}
return -1;
}
//
//
jQuery(function($){
//
// Menu separator rows removed
$('td.t_separator_horizontal').parent().css('display', 'none');
//
//
// Remove top items
for(var n=1; n < 30; n+=2)
{
var $bm = $('#bm_' + n);
var mnName = $bm.find('div:first').text().toLowerCase();
if(mnName == 'my area') continue;
if(mnName == 'shop' && $bm.find('td:eq(3) td').length > 0) continue;
$('#bm_' + n + '_1').css('display', 'none');
$('#bm_' + n + '_2 td.t_separator_horizontal:eq(0)').closest('tr').css('display', 'none');
if($bm.find('tr').length < (n == 1 ? 2 : 3)) $bm.find('div:eq(1)').remove();
}
//
//
$('table.boxout_contents_type_Calendar_ascx').find('table:eq(0) > tbody > tr > td:last').css('border-bottom', 'none');
$('table.boxout_contents_type_Media_ascx').find('td.media_box_cell:last').css('border-bottom', 'none');
$('table.boxout_contents_type_Rotas_ascx td td:last').css('border-bottom', 'none');
$('div#birthdaysContainer td.cal_row, div#birthdaysContainer td.cal_altrow').last().css('border-bottom', 'none');
$('table.boxout_contents_type_Rotas_ascx div.smalltext[align="center"]').css('margin-top', '8px');
//
//
// Remove home menu drop-down
$('#bm_1 table:eq(0)').remove();
//
//
var myAreaIdx = getMenuId('my area');
insertNewMenuItem(myAreaIdx, 100, 'Forums', '/Forums/AllForums.aspx');
insertNewMenuItem(myAreaIdx, 101, 'Audio / Video', '/Media/AllMedia.aspx');
insertNewMenuItem(myAreaIdx, 102, 'Address Book', '/Address/AddressBook.aspx');
insertNewMenuItem(myAreaIdx, 103, 'Calendar', '/Calendar/Month.aspx');
//
//
// Fade menus in and out
var oldMo = mo;
var moTo;
$('td.t_horizontal:even > div.t, tr.t,tr.t_disabled').each(function(i,el){
var m = el.onmouseover;
el.onmouseover = function(ev){
$(el).next('div').find('> table.t').fadeIn(400);
$(el).find('> td > div.tav > table.t').fadeIn(400);
clearInterval(moTo);
m(ev);
}});
mo = function(e){
var tgt = $(e.srcElement || e.target);
var start = tgt.closest('table.t').add(tgt.next('div').find('> table.t'));
moTo = setTimeout(function(){start.closest('div.tah').find('table.t').fadeOut(300)}, 245);
oldMo(e);
}
//
//
// Make menu titles link to first item in menu
$('td.t_horizontal:even:gt(0)').each(function(){
var $tr = $(this).find('tr').filter(function(){return !(this.style.display == 'none')}).eq(0);
var c = $tr.attr('onclick');
$tr.parents('td.t_horizontal').find('> div:eq(0)').not(':contains(My Area)').attr('onclick', '').click(function(){eval(c.replace(/event\s*\)/, "''") + ')')});
});
//
//
});
//
if(document.body.id != 'body')
{
document.write('<style type="text/css">h1{margin-bottom:20px}</style>');
}
// Forums fix
if(location.pathname.toLowerCase().indexOf('/forums/threads.aspx') != -1 || location.pathname.toLowerCase().indexOf('/forums/messages.aspx') != -1) document.write('<st' + 'yle type="text/css">td.pageleftcol {display:none}</st' + 'yle>');
