// --- popover new --- start
function popOver(menuNum, itemNum) {
//alert(menuNum + ',' + itemNum);
clearTimeout(popTimer);
hideAllBut(menuNum);
hideAllButL(0);
hideAllButLT(0);
litNow = getTree(menuNum, itemNum);
changeCol(litNow, true);
targetNum = menu[menuNum][itemNum].target;
//dbg(document.body.scrollTop);
if (targetNum > 0) {
vOrientationUp = false;
//Check vertical orientation
clientWindowHeight = document.body.clientHeight;
//alert(findPosY(getRef('menuL' + menuNum + 'item' + (itemNum )))+ menuL[targetNum][0].y);
leftOfCurrent = findPosX(getRef('menu' + menuNum + 'item'+ itemNum));
//alert(leftofCurrent);
if ((findPosY(getRef('menu' + menuNum + 'item' + (itemNum ))) + menu[targetNum][0].obj.offsetHeight) > clientWindowHeight +document.body.scrollTop) {
vOrientationUp=true;
bottomOfCurrent = findPosY(getRef('menu' + menuNum + 'item0')) + menu[menuNum][0].obj.offsetHeight;
}
//alert(vOrientationUp);
if (vOrientationUp) {

	if (menu[menuNum].length == itemNum + 1) {
	thisTop=bottomOfCurrent;
	}
	else {
	thisRef = getRef('menu' + menuNum + 'item' + (itemNum + 1));
	thisTop = findPosY(thisRef);
	}

}
else {
thisRef = getRef('menu' + menuNum + 'item' + (itemNum ));
thisTop = findPosY(thisRef);
}


//thisX = parseInt(menu[menuNum][0].ref.left) + parseInt(menu[menuNum][itemNum].ref.left);
thisX = parseInt(menu[menuNum][0].ref.left);
//alert('thisX: ' + thisX);
//thisY = parseInt(menuL[menuNum][0].ref.top) + parseInt(menuL[menuNum][itemNum].ref.top);
thisY = thisTop;
//alert('thisY: ' + thisY);
divHeight = menu[targetNum][0].obj.offsetHeight;
with (menu[targetNum][0].ref) {
//alert("Vural");
//alert(menuL[menuNum][1].length);
if (!menu[menuNum][0].isVert) {
	left = leftOfCurrent - 1 ;
	}
else {
	left = parseInt(thisX + menu[targetNum][0].x);
}
top = (vOrientationUp ? parseInt(thisY + menu[targetNum][0].y - divHeight) : parseInt(thisY + menu[targetNum][0].y));
visibility = 'visible';
      }
   }
}

// --- popover new --- end


// --- popout new --- start

function popOut(menuNum, itemNum) {
if ((menuNum == 0) && !menu[menuNum][itemNum].target)
hideAllBut(0);
else
popTimer = setTimeout('hideAllBut(0)', 500);
//hideAllButL(menuNum);
}


// --- popout new --- end


// --- gettree new --- start

function getTree(menuNum, itemNum) {
//alert('getTree start');

// Array index is the menu number. The contents are null (if that menu is not a parent)
// or the item number in that menu that is an ancestor (to light it up).
itemArray = new Array(menu.length);
//alert(6);
while(1) {
itemArray[menuNum] = itemNum;
//alert(itemArray[menuNum]);
// If we've reached the top of the hierarchy, return.
if (menuNum == 0) return itemArray;
itemNum = menu[menuNum][0].parentItem;
menuNum = menu[menuNum][0].parentMenu;
   }
//alert('getTree end');
}
// --- gettree new --- end


// --- changecol new --- start

// Pass an array and a boolean to specify colour change, true = over colour.
function changeCol(changeArray, isOver) {
//alert('changeCol start');
//alert(31);
for (menuCount = 0; menuCount < changeArray.length; menuCount++) {
//alert('32 - ' + menuCount);
if (changeArray[menuCount]) {
newCol = isOver ? menu[menuCount][0].overCol : menu[menuCount][0].backCol;
overclass = isOver ? menu[menuCount][0].textClass + 'ovr' : menu[menuCount][0].textClass;
// Change the colours of the div/layer background.
//alert(newCol);
with (menu[menuCount][changeArray[menuCount]].ref) {
if (isNS4) bgColor = newCol;
else 		{
		backgroundColor = newCol;
		textobj = getRef('menu' + menuCount + 'item' + changeArray[menuCount] + 'txt');
//		alert(textobj.className);
		textobj.className = overclass;
//		alert(textobj.className);
		}
         }
if (!isNS4) menu[menuCount][changeArray[menuCount]].reftd.style.backgroundColor = newCol;
      }
   }
//alert('changeCol end');
}

// --- changecol new --- end

// --- hideall new --- start

function hideAllBut(menuNum) {
//alert('HideAllBut start');
var keepMenus = getTree(menuNum, 1);
for (count = 0; count < menu.length; count++)
if (!keepMenus[count])
menu[count][0].ref.visibility = 'hidden';
changeCol(litNow, false);
changeCol(selectedItem,true);
//alert('HideAllBut end');
}

// --- hideall new --- end

// --- writemenus new --- start

function writeMenus() {

if (!isDOM && !isIE4 && !isNS4) return;

for (currMenu = 0; currMenu < menu.length; currMenu++) with (menu[currMenu][0]) {
// Variable for holding HTML for items and positions of next item.
var str = '', itemX = 0, itemY = 0;
currItem = 0;
// Remember, items start from 1 in the array (0 is menu object itself, above).
// Also use properties of each item nested in the other with() for construction.
//if (isNS4) {
//var newLayerID = 'menu' + currMenu + 'item0'; 
//str='<ilayer id="'+ newLayerID +'">';
//}
if (!isNS4) str+='<table cellspacing="0" cellpadding="0">';
if (!isVert) str+='<tr>';
for (currItem = 1; currItem < menu[currMenu].length; currItem++) with (menu[currMenu][currItem]) {
var itemID = 'menu' + currMenu + 'item' + currItem;


// The width and height of the menu item - dependent on orientation!
var w = (isVert ? width : length);
var h = (isVert ? length : width);
var ttt = (currItem == 1 ? 't' : '');
// Create a div or layer text string with appropriate styles/properties.
// Thanks to Paul Maden (www.paulmaden.com) for helping debug this in IE4, apparently
// the width must be a miniumum of 3 for it to work in that browser.
if (isDOM || isIE4) {
if (isVert) str+='<tr>'
str += '<td id="'+ itemID +'td" style="background: '+ backCol + ';width: ' + w + ';" class="' + borderClass +ttt+ '"><div id="' + itemID + '" style="width: ' + w + '; visibility: inherit; ';
if (backCol) str += 'background: ' + backCol + '; ';
str += '" ';
}
if (isNS4) {
//str += '<tr><td id="'+ itemID +'td" style="background: '+ backCol + ';" class="' + borderClass +ttt+ '"><ilayer id="' + itemID + '" left="' + itemX + '" top="' + itemY + '" width="' +  w + '" height="' + h + '" visibility="inherit" ';
str += '<layer id="' + itemID + '" left="' + itemX + '" top="' + itemY + '" width="' +  w + '" height="' + h + '" visibility="inherit" ';
if (backCol) str += 'bgcolor="' + backCol + '" ';
}
//if (borderClass) str += 'class="' + borderClass + '" ';

// Add mouseover handlers and finish div/layer.
str += 'onMouseOver="popOver(' + currMenu + ',' + currItem + ')" onMouseOut="popOut(' + currMenu + ',' + currItem + ')">';

// Add contents of item (default: table with link inside).
// In IE/NS6+, add padding if there's a border to emulate NS4's layer padding.
// If a target frame is specified, also add that to the <a> tag.
var hh = '<a id="'+ itemID +'txt" class="' + textClass + '" href="' + href + '"' + (frame ? ' target="' + frame + '">' : '>');
var hn = '<span id="'+ itemID +'txt" class="' + textClass + '">';
var topbarheight = (currMenu == 0 ? 2 :3);
str += '<table width="' + (w - 8) + '" height="' + (h - 7) + '" border="0" cellspacing="0" cellpadding="' + (!isNS4 && borderClass ? topbarheight : 0) + '"><tr><td align="left" height="' + (h - 7) + '">' + (href ?  hh : hn) + text + (href ? '</a>': '</span>') + '</td>';
//str += '<table width="' + (w - 8) + '" border="0" cellspacing="0" cellpadding="' + (!isNS4 && borderClass ? 3 : 0) + '"><tr><td align="left" height="' + (h - 7) + '">' + '<a class="' + textClass + '" href="' + href + '"' + (frame ? ' target="' + frame + '">' : '>') + text + '</a></td>';
if (target > 0) {

// Set target's parents to this menu item.
menu[target][0].parentMenu = currMenu;
menu[target][0].parentItem = currItem;

// Add a popout indicator.
if (popInd) str += '<td class="' + textClass + '" align="right" valign="bottom">' + popInd + '</td>';
}
//str += '</tr></table>' + (isNS4 ? '</ilayer></td></tr>' : '</div></td></tr>');
str += '</tr></table>' + (isNS4 ? '</layer>' : '</div></td>');
if (isVert) str+= '</tr>';
olditemX = itemX;
olditemY = itemY;
if (isVert) itemY += length + spacing;
else itemX += length + spacing;
}
if (!isVert) str+= '</tr>';
if (!isNS4) str += '</table>';

if (isDOM) {
//alert(str);
var newDiv = document.createElement('div');
var newDivID = 'menu' + currMenu + 'item0'; 
document.getElementsByTagName('body').item(0).appendChild(newDiv);
newDiv.innerHTML = str;
//alert(newDivID);
newDiv.id = newDivID;
//alert(newDiv.offsetHeight);
obj = newDiv;
ref = newDiv.style;
ref.top= olditemY;
ref.left= olditemX;
ref.position = 'absolute';
ref.visibility = 'hidden';
}

// Insert a div tag to the end of the BODY with menu HTML in place for IE4.
if (isIE4) {
document.body.insertAdjacentHTML('beforeEnd', '<div id="menu' + currMenu + 'div" ' + 'style="position: absolute; visibility: hidden">' + str + '</div>');
ref = getSty('menu' + currMenu + 'div');
}

// In NS4, create a reference to a new layer and write the items to it.
if (isNS4) {
ref = new Layer(0);
var newLayerID = 'menu' + currMenu + 'item0';
//dbg(ref.id);
nsArray[currMenu] = ref.id; 
//dbg('<layer>');
//dbg(str);
//dbg('</layer>');
ref.document.write(str);
ref.document.close();
}

for (currItem = 0; currItem < menu[currMenu].length; currItem++) {
// vural
itemName = 'menu' + currMenu + 'item' + currItem;
if (isNS4 && currItem == 0) {
itemName = nsArray[currMenu];
prnt = itemName;
}
//dbg('itemName: ' + itemName);
//itemName = 'menu' + currMenu;
//alert(getSty(itemName).top);
if (isDOM || isIE4) {
					menu[currMenu][currItem].ref = getSty(itemName);
					menu[currMenu][currItem].reftd = getRef(itemName+'td');
					}
//if (isNS4) menuL[currMenu][currItem].ref = ref.document[itemName];
if (isNS4) {
dbg(currItem + ' -- ' + itemName);
dbg(ref);
menu[currMenu][currItem].ref = (currItem > 0 ? ref.document[itemName]: ref);
menu[currMenu][currItem].reftd = getRef(itemName+'td');
}
//alert(getSty(itemName));
   }
}
with(menu[0][0]) {
ref.left = x+xcoor;
ref.top = y;
ref.visibility = 'visible';
   }
}



// --- writemenus new --- end



// #################### LEFT MENU

function writeLMenu() {

if (!isDOM && !isIE4 && !isNS4) return;

for (currMenu = 0; currMenu < menuL.length; currMenu++) with (menuL[currMenu][0]) {
// Variable for holding HTML for items and positions of next item.
var str = '', itemX = 0, itemY = 0;
currItem = 0;
// Remember, items start from 1 in the array (0 is menu object itself, above).
// Also use properties of each item nested in the other with() for construction.
//if (isNS4) {
//var newLayerID = 'menuL' + currMenu + 'item0'; 
//str='<ilayer id="'+ newLayerID +'">';
//}
if (!isNS4) str+='<table cellspacing="0" cellpadding="0">'
for (currItem = 1; currItem < menuL[currMenu].length; currItem++) with (menuL[currMenu][currItem]) {
var itemID = 'menuL' + currMenu + 'item' + currItem;


// The width and height of the menu item - dependent on orientation!
var w = (isVert ? width : length);
var h = (isVert ? length : width);
var ttt = (currItem == 1 ? 't' : '');
// Create a div or layer text string with appropriate styles/properties.
// Thanks to Paul Maden (www.paulmaden.com) for helping debug this in IE4, apparently
// the width must be a miniumum of 3 for it to work in that browser.
if (isDOM || isIE4) {
str += '<tr><td id="'+ itemID +'td" style="background: '+ backCol + ';width: ' + w + ';" class="' + borderClass +ttt+ '"><div id="' + itemID + '" style="width: ' + w + '; visibility: inherit; ';
if (backCol) str += 'background: ' + backCol + '; ';
str += '" ';
}
if (isNS4) {
//str += '<tr><td id="'+ itemID +'td" style="background: '+ backCol + ';" class="' + borderClass +ttt+ '"><ilayer id="' + itemID + '" left="' + itemX + '" top="' + itemY + '" width="' +  w + '" height="' + h + '" visibility="inherit" ';
str += '<layer id="' + itemID + '" left="' + itemX + '" top="' + itemY + '" width="' +  w + '" height="' + h + '" visibility="inherit" ';
if (backCol) str += 'bgcolor="' + backCol + '" ';
}
//if (borderClass) str += 'class="' + borderClass + '" ';

// Add mouseover handlers and finish div/layer.
str += 'onMouseOver="popOverL(' + currMenu + ',' + currItem + ')" onMouseOut="popOutL(' + currMenu + ',' + currItem + ')">';

// Add contents of item (default: table with link inside).
// In IE/NS6+, add padding if there's a border to emulate NS4's layer padding.
// If a target frame is specified, also add that to the <a> tag.
var hh = '<a id="'+ itemID +'txt" class="' + textClass + '" href="' + href + '"' + (frame ? ' target="' + frame + '">' : '>');
var hn = '<span id="'+ itemID +'txt" class="' + textClass + '">';
str += '<table width="' + (w - 8) + '" height="' + (h - 7) + '" border="0" cellspacing="0" cellpadding="' + (!isNS4 && borderClass ? 3 : 0) + '"><tr><td align="left" height="' + (h - 7) + '">' + (href ?  hh : hn) + text + (href ? '</a>': '</span>') + '</td>';
//str += '<table width="' + (w - 8) + '" border="0" cellspacing="0" cellpadding="' + (!isNS4 && borderClass ? 3 : 0) + '"><tr><td align="left" height="' + (h - 7) + '">' + '<a class="' + textClass + '" href="' + href + '"' + (frame ? ' target="' + frame + '">' : '>') + text + '</a></td>';
if (target > 0) {

// Set target's parents to this menu item.
menuL[target][0].parentMenu = currMenu;
menuL[target][0].parentItem = currItem;

// Add a popout indicator.
if (popInd) str += '<td class="' + textClass + '" align="right" valign="bottom">' + popInd + '</td>';
}
//str += '</tr></table>' + (isNS4 ? '</ilayer></td></tr>' : '</div></td></tr>');
str += '</tr></table>' + (isNS4 ? '</layer>' : '</div></td></tr>');
olditemX = itemX;
olditemY = itemY;
if (isVert) itemY += length + spacing;
else itemX += length + spacing;
}
if (!isNS4) str += '</table>';

if (isDOM) {
//alert(str);
var newDiv = document.createElement('div');
var newDivID = 'menuL' + currMenu + 'item0'; 
document.getElementsByTagName('body').item(0).appendChild(newDiv);
newDiv.innerHTML = str;
//alert(newDivID);
newDiv.id = newDivID;
//alert(newDiv.offsetHeight);
obj = newDiv;
ref = newDiv.style;
ref.top= olditemY;
ref.left= olditemX;
ref.position = 'absolute';
ref.visibility = 'hidden';
}

// Insert a div tag to the end of the BODY with menu HTML in place for IE4.
if (isIE4) {
document.body.insertAdjacentHTML('beforeEnd', '<div id="menuL' + currMenu + 'div" ' + 'style="position: absolute; visibility: hidden">' + str + '</div>');
ref = getSty('menuL' + currMenu + 'div');
}

// In NS4, create a reference to a new layer and write the items to it.
if (isNS4) {
ref = new Layer(0);
var newLayerID = 'menuL' + currMenu + 'item0';
//dbg(ref.id);
nsArray[currMenu] = ref.id; 
//dbg('<layer>');
//dbg(str);
//dbg('</layer>');
ref.document.write(str);
ref.document.close();
}

for (currItem = 0; currItem < menuL[currMenu].length; currItem++) {
// vural
itemName = 'menuL' + currMenu + 'item' + currItem;
if (isNS4 && currItem == 0) {
itemName = nsArray[currMenu];
prnt = itemName;
}
//dbg('itemName: ' + itemName);
//itemName = 'menuL' + currMenu;
//alert(getSty(itemName).top);
if (isDOM || isIE4) {
					menuL[currMenu][currItem].ref = getSty(itemName);
					menuL[currMenu][currItem].reftd = getRef(itemName+'td');
					}
//if (isNS4) menuL[currMenu][currItem].ref = ref.document[itemName];
if (isNS4) {
dbg(currItem + ' -- ' + itemName);
dbg(ref);
menuL[currMenu][currItem].ref = (currItem > 0 ? ref.document[itemName]: ref);
menuL[currMenu][currItem].reftd = getRef(itemName+'td');
}
//alert(getSty(itemName));
   }
}
with(menuL[0][0]) {
ref.left = x+xcoor;
ref.top = y;
ref.visibility = 'visible';
   }
}

function popOutL(menuNum, itemNum) {
if ((menuNum == 0) && !menuL[menuNum][itemNum].target)
hideAllButL(0)
else
popTimer = setTimeout('hideAllButL(0)', 500);
//hideAllButL(menuNum);
}

function popOverL(menuNum, itemNum) {
clearTimeout(popTimer);
hideAllButL(menuNum);
hideAllBut(0);
hideAllButLT(0);
litNowL = getTreeL(menuNum, itemNum);
changeColL(litNowL, true);
targetNum = menuL[menuNum][itemNum].target;
//dbg(document.body.scrollTop);
if (targetNum > 0) {
vOrientationUp = false;
//Check vertical orientation
clientWindowHeight = document.body.clientHeight;
//alert(findPosY(getRef('menuL' + menuNum + 'item' + (itemNum )))+ menuL[targetNum][0].y);
if ((findPosY(getRef('menuL' + menuNum + 'item' + (itemNum ))) + menuL[targetNum][0].obj.offsetHeight) > clientWindowHeight +document.body.scrollTop) {
vOrientationUp=true;
bottomOfCurrent = findPosY(getRef('menuL' + menuNum + 'item0')) + menuL[menuNum][0].obj.offsetHeight;
}
//alert(vOrientationUp);
if (vOrientationUp) {

	if (menuL[menuNum].length == itemNum + 1) {
	thisTop=bottomOfCurrent;
	}
	else {
	thisRef = getRef('menuL' + menuNum + 'item' + (itemNum + 1));
	thisTop = findPosY(thisRef);
	}

}
else {
thisRef = getRef('menuL' + menuNum + 'item' + (itemNum ));
thisTop = findPosY(thisRef);
}


//thisX = parseInt(menuL[menuNum][0].ref.left) + parseInt(menuL[menuNum][itemNum].ref.left);
thisX = parseInt(menuL[menuNum][0].ref.left);
var bordersz=0;
if (menuNum > 0) bordersz = 1;
//alert(border); 
//alert('thisX: ' + thisX);
//thisY = parseInt(menuL[menuNum][0].ref.top) + parseInt(menuL[menuNum][itemNum].ref.top);
thisY = thisTop;
//alert('thisY: ' + thisY);
divHeight = menuL[targetNum][0].obj.offsetHeight;
with (menuL[targetNum][0].ref) {
//alert("Vural");
//alert(menuL[menuNum][1].length);
//alert (border);
left = parseInt(thisX + menuL[targetNum][0].x + bordersz);
top = (vOrientationUp ? parseInt(thisY + menuL[targetNum][0].y - divHeight) : parseInt(thisY + menuL[targetNum][0].y));
visibility = 'visible';
      }
   }
}
function hideAllButL(menuNum) {
//alert('HideAllBut start');
var keepMenus = getTreeL(menuNum, 1);
for (count = 0; count < menuL.length; count++)
if (!keepMenus[count])
menuL[count][0].ref.visibility = 'hidden';
changeColL(litNowL, false);
changeColL(selectedItemL,true);
//alert('HideAllBut end');
}

// Pass an array and a boolean to specify colour change, true = over colour.
function changeColL(changeArray, isOver) {
//alert('changeCol start');
//alert(31);
for (menuCount = 0; menuCount < changeArray.length; menuCount++) {
//alert('32 - ' + menuCount);
if (changeArray[menuCount]) {
newCol = isOver ? menuL[menuCount][0].overCol : menuL[menuCount][0].backCol;
overclass = isOver ? menuL[menuCount][0].textClass + 'ovr' : menuL[menuCount][0].textClass;
// Change the colours of the div/layer background.
//alert(newCol);
with (menuL[menuCount][changeArray[menuCount]].ref) {
if (isNS4) bgColor = newCol;
else 		{
		backgroundColor = newCol;
		textobj = getRef('menuL' + menuCount + 'item' + changeArray[menuCount] + 'txt');
//		alert(textobj.className);
		textobj.className = overclass;
//		alert(textobj.className);
		}
         }
if (!isNS4) menuL[menuCount][changeArray[menuCount]].reftd.style.backgroundColor = newCol;
      }
   }
//alert('changeCol end');
}

function getTreeL(menuNum, itemNum) {
//alert('getTree start');

// Array index is the menu number. The contents are null (if that menu is not a parent)
// or the item number in that menu that is an ancestor (to light it up).
itemArray = new Array(menuL.length);
//alert(6);
while(1) {
itemArray[menuNum] = itemNum;
//alert(itemArray[menuNum]);
// If we've reached the top of the hierarchy, return.
if (menuNum == 0) return itemArray;
itemNum = menuL[menuNum][0].parentItem;
menuNum = menuL[menuNum][0].parentMenu;
   }
//alert('getTree end');
}

// #################### LEFTTOP MENU

function writeLTMenu() {

if (!isDOM && !isIE4 && !isNS4) return;

for (currMenu = 0; currMenu < menuLT.length; currMenu++) with (menuLT[currMenu][0]) {

var str = '', itemX = 0, itemY = 0;
currItem = 0;

if (!isNS4) str+='<table cellspacing="0" cellpadding="0">'
for (currItem = 1; currItem < menuLT[currMenu].length; currItem++) with (menuLT[currMenu][currItem]) {
var itemID = 'menuLT' + currMenu + 'item' + currItem;


var w = (isVert ? width : length);
var h = (isVert ? length : width);
var ttt = (currItem == 1 ? 't' : '');

if (isDOM || isIE4) {
str += '<tr><td id="'+ itemID +'td" style="background: '+ backCol + ';width: ' + w + '; " class="' + borderClass +ttt+ '"><div id="' + itemID + '" style="width: ' + w + '; visibility: inherit; ';
if (backCol) str += 'background: ' + backCol + '; ';
str += '" ';
}
if (isNS4) {
str += '<layer id="' + itemID + '" left="' + itemX + '" top="' + itemY + '" width="' +  w + '" height="' + h + '" visibility="inherit" ';
if (backCol) str += 'bgcolor="' + backCol + '" ';
}
str += 'onMouseOver="popOverLT(' + currMenu + ',' + currItem + ')" onMouseOut="popOutLT(' + currMenu + ',' + currItem + ')">';

var hh = '<a id="'+ itemID +'txt" class="' + textClass + '" href="' + href + '"' + (frame ? ' target="' + frame + '">' : '>');
var hn = '<span id="'+ itemID +'txt" class="' + textClass + '">';
str += '<table width="' + (w - 8) + '" height="' + (h - 7) + '" border="0" cellspacing="0" cellpadding="' + (!isNS4 && borderClass ? 3 : 0) + '"><tr><td align="left" height="' + (h - 7) + '">' + (href ?  hh : hn) + text + (href ? '</a>': '</span>') + '</td>';

if (target > 0) {

menuLT[target][0].parentMenu = currMenu;
menuLT[target][0].parentItem = currItem;

if (popInd) str += '<td class="' + textClass + '" align="right" valign="bottom">' + popInd + '</td>';
}
str += '</tr></table>' + (isNS4 ? '</layer>' : '</div></td></tr>');
olditemX = itemX;
olditemY = itemY;
if (isVert) itemY += length + spacing;
else itemX += length + spacing;
}
if (!isNS4) str += '</table>';

if (isDOM) {
var newDiv = document.createElement('div');
var newDivID = 'menuLT' + currMenu + 'item0'; 
document.getElementsByTagName('body').item(0).appendChild(newDiv);

newDiv.innerHTML = str;
newDiv.id = newDivID;

obj = newDiv;
ref = newDiv.style;
ref.top= olditemY;
ref.left= olditemX;
ref.position = 'absolute';
ref.visibility = 'hidden';
}

if (isIE4) {
document.body.insertAdjacentHTML('beforeEnd', '<div id="menuLT' + currMenu + 'div" ' + 'style="position: absolute; visibility: hidden">' + str + '</div>');
ref = getSty('menuLT' + currMenu + 'div');
}

if (isNS4) {
ref = new Layer(0);
var newLayerID = 'menuLT' + currMenu + 'item0';
nsArray[currMenu] = ref.id; 

ref.document.write(str);
ref.document.close();
}

for (currItem = 0; currItem < menuLT[currMenu].length; currItem++) {
// vural
itemName = 'menuLT' + currMenu + 'item' + currItem;
if (isNS4 && currItem == 0) {
itemName = nsArray[currMenu];
prnt = itemName;
}
if (isDOM || isIE4) {
					menuLT[currMenu][currItem].ref = getSty(itemName);
					menuLT[currMenu][currItem].reftd = getRef(itemName+'td');
					}
if (isNS4) {
menuLT[currMenu][currItem].ref = (currItem > 0 ? ref.document[itemName]: ref);
menuLT[currMenu][currItem].reftd = getRef(itemName+'td');
}
   }
}
with(menuLT[0][0]) {
ref.left = x+xcoor;
ref.top = y;
ref.visibility = 'visible';
   }
}

function popOutLT(menuNum, itemNum) {
if ((menuNum == 0) && !menuLT[menuNum][itemNum].target)
hideAllButLT(0)
else
popTimer = setTimeout('hideAllButLT(0)', 500);
}

function popOverLT(menuNum, itemNum) {
clearTimeout(popTimer);
hideAllButLT(menuNum);
hideAllBut(0);
hideAllButL(0);
litNowLT = getTreeLT(menuNum, itemNum);
changeColLT(litNowLT, true);
targetNum = menuLT[menuNum][itemNum].target;
if (targetNum > 0) {
vOrientationUp = false;
//Check vertical orientation
clientWindowHeight = document.body.clientHeight;

if ((findPosY(getRef('menuLT' + menuNum + 'item' + (itemNum ))) + menuLT[targetNum][0].obj.offsetHeight) > clientWindowHeight +document.body.scrollTop) {
vOrientationUp=true;
bottomOfCurrent = findPosY(getRef('menuLT' + menuNum + 'item0')) + menuLT[menuNum][0].obj.offsetHeight;
}
//alert(vOrientationUp);
if (vOrientationUp) {

	if (menuLT[menuNum].length == itemNum + 1) {
	thisTop=bottomOfCurrent;
	}
	else {
	thisRef = getRef('menuLT' + menuNum + 'item' + (itemNum + 1));
	thisTop = findPosY(thisRef);
	}

}
else {
thisRef = getRef('menuLT' + menuNum + 'item' + (itemNum ));
thisTop = findPosY(thisRef);
}


thisX = parseInt(menuLT[menuNum][0].ref.left);
var bordersz=0;
if (menuNum > 0) bordersz = 1;
thisY = thisTop;
divHeight = menuLT[targetNum][0].obj.offsetHeight;
with (menuLT[targetNum][0].ref) {
left = parseInt(thisX + menuLT[targetNum][0].x + bordersz);
top = (vOrientationUp ? parseInt(thisY + menuLT[targetNum][0].y - divHeight) : parseInt(thisY + menuLT[targetNum][0].y));
visibility = 'visible';
      }
   }
}
function hideAllButLT(menuNum) {
var keepMenus = getTreeLT(menuNum, 1);
for (count = 0; count < menuLT.length; count++)
if (!keepMenus[count])
menuLT[count][0].ref.visibility = 'hidden';
changeColLT(litNowLT, false);
}

function changeColLT(changeArray, isOver) {
for (menuCount = 0; menuCount < changeArray.length; menuCount++) {
if (changeArray[menuCount]) {
newCol = isOver ? menuLT[menuCount][0].overCol : menuLT[menuCount][0].backCol;
overclass = isOver ? menuLT[menuCount][0].textClass + 'ovr' : menuLT[menuCount][0].textClass;
with (menuLT[menuCount][changeArray[menuCount]].ref) {
if (isNS4) bgColor = newCol;
else 		{
		backgroundColor = newCol;
		textobj = getRef('menuLT' + menuCount + 'item' + changeArray[menuCount] + 'txt');
		textobj.className = overclass;
		}
         }
if (!isNS4) menuLT[menuCount][changeArray[menuCount]].reftd.style.backgroundColor = newCol;
      }
   }
}

function getTreeLT(menuNum, itemNum) {
itemArray = new Array(menuLT.length);
while(1) {
itemArray[menuNum] = itemNum;
if (menuNum == 0) return itemArray;
itemNum = menuLT[menuNum][0].parentItem;
menuNum = menuLT[menuNum][0].parentMenu;
   }
}



var mnewDiv;
var leftDiv;

function init() {
xcoor = findPosX(getRef("topleftcell"));
var phstr = '<table cellspacing="0" cellpadding="0"><tr><td id="plcholdertd" style="background: #FFFFFF;width: 128; height: 10;"><div id="plcholder" style="width: 128; height: 10; visibility: inherit; background: #FFFFFF; "><table width="120" height="3" border="0" cellspacing="0" cellpadding="2"><tr><td align="center" height="3"><span class="leftText">'+ countryLabel+'</span></td></tr></table></div></td></tr></table>';
mnewDiv = document.createElement('div');
document.getElementsByTagName('body').item(0).appendChild(mnewDiv);
mnewDiv.innerHTML = phstr;
mnewDiv.id = "plch";
mnewDiv.style.position = 'absolute';
mnewDiv.style.visibility = 'visible';
mnewDiv.style.left = xcoor;
mnewDiv.style.top = 176;
writeMenus();
writeLMenu();
writeLTMenu();
createLeftDiv();

changeCol(selectedItem,true);
changeColL(selectedItemL,true);

}

function initx() {
xcoor = findPosX(getRef("topleftcell"));
}

function resizeHandler() {
xcoor = findPosX(getRef("topleftcell"));
menuL[0][0].ref.left = menuL[0][0].x + xcoor;
menu[0][0].ref.left = menu[0][0].x + xcoor;
menuLT[0][0].ref.left = menuL[0][0].x + xcoor;
mnewDiv.style.left = xcoor;
//leftDiv.style.left = xcoor;
}

function resizeHandlerx() {
xcoor = findPosX(getRef("topleftcell"));
menuL[0][0].ref.left = menuL[0][0].x + xcoor;
}

function createLeftDiv() {
var leftdivstr = '<table cellspacing="0" cellpadding="0"><tr><td id="leftdivtd" style="background: #FFFFFF;width: 124;" class="itemBorder3upl"><div id="leftdiv2" style="width: 124; visibility: inherit; background: #FFFFFF; "><table width="120" border="0" cellspacing="0" cellpadding="3"><tr><td align="left" ><span class="itemText3b">'+ secondaryNav+'</span></td></tr></table></div></td></tr></table>';
if (secondaryNav !=''){
leftDiv = document.createElement('div');
document.getElementsByTagName('body').item(0).appendChild(leftDiv);
leftDiv.innerHTML = leftdivstr;
leftDiv.id = "leftdiv";
leftDiv.style.position = 'absolute';
leftDiv.style.visibility = 'visible';
leftDiv.style.left = xcoor;
leftDiv.style.top = 291;
}
}

//edit Productpages

function init_noLeft() {
xcoor = findPosX(getRef("topleftcell"));
var phstr = '';
mnewDiv = document.createElement('div');
document.getElementsByTagName('body').item(0).appendChild(mnewDiv);
mnewDiv.innerHTML = phstr;
mnewDiv.id = "plch";
mnewDiv.style.position = 'absolute';
mnewDiv.style.visibility = 'visible';
mnewDiv.style.left = xcoor;
mnewDiv.style.top = 176;
writeMenus();
changeCol(selectedItem,true);
changeColL(selectedItemL,true);

}