function showObj(obj, iNumElements) {
	var iCount = 0;
	var str = "";
	if (iNumElements == null)
		iNumElements = 20;
	for (var a in obj) {
		str += a + " => " + obj[a] + "\n";
		if (iCount == iNumElements) {
			alert(str);
			str = "";
			iCount = 0;
		}
		iCount++;
	}
	if (str.length) {
		top.alert(str);
	}

}

function init_dom2_dropdown_menu1b() {
	var objMMTable = document.getElementById("mainMenuTable");
	if(objMMTable != null) {
		arrPosition["mm"] = new Array();
		arrPosition["mm"]["top"] = iSMoffsetY - objMMTable.offsetHeight + 5;
		arrPosition["mm"]["left"] = iSMOffsetX + 5 + getXPosOffset();
		arrPosition["mm"]["bottom"] = iSMoffsetY + 5;
		arrPosition["mm"]["right"] = iSMOffsetX + objMMTable.offsetWidth + 5 + getXPosOffset();
	}

	arrPosition["sm"] = new Array();
	arrPosition["sm"]["top"] = -1;
	arrPosition["sm"]["left"] = -1;
	arrPosition["sm"]["bottom"] = -1;
	arrPosition["sm"]["right"] = -1;

	//arrSMoffsetX[0] = getXPosOffset()+iSMOffsetX;
	arrSMoffsetX[0] = getXPosOffset()+iSMOffsetX;
	var iTmpSMOffsetX = iSMOffsetX;
	for(i=1;i<iMMCount+1;i++) {
		var imgNum = i -1;
		var objMMImgSep = document.getElementById("mainMenuImgSep" + imgNum);
		var objMMTD = document.getElementById("mainMenuTD" + i);
		if(objMMImgSep != null && objMMTD != null) {
			var iMMWidth = iImageSepWidth + objMMTD.offsetWidth;
			iTmpSMOffsetX = iTmpSMOffsetX + iMMWidth;
			arrSMWidth[i] = iMMWidth;
			arrSMoffsetX[i] = getXPosOffset()+iTmpSMOffsetX;
		}
	}
	document.onmousemove = getMousePosition_dom2_dropdown_menu1b;
	clearService_dom2_dropdown_menu1b();
}

function mmClearItem_dom2_dropdown_menu1b(iItemID, iFolderID) {
	if(iItemID != iItemIsActive) {
		var objMM = document.getElementById("mainMenuTD" + iItemID);
		if(objMM != null)
			objMM.className = "dom2dropdownmenu1mainMenu";
	
		var objMMImgLeft = document.getElementById("mainMenuImgSep" + (iItemID -1));
		if(objMMImgLeft != null) {
			if ((iItemID - 1) != iItemIsActive) {
				if (objMMImgLeft.src.indexOf(mainMenuDefaultImgSeperator) == -1)
					objMMImgLeft.src = mainMenuDefaultImgSeperator;
			} else { 
				if (objMMImgLeft.src.indexOf(mainMenuRigthImgSeperator) == -1)
					objMMImgLeft.src = mainMenuRigthImgSeperator;
			}
		}
		var objMMImgRigth = document.getElementById("mainMenuImgSep" + iItemID);
		if(objMMImgRigth != null) {
			if (iItemID+1 != iItemIsActive) {
				if (objMMImgRigth.src.indexOf(mainMenuDefaultImgSeperator) == -1)
					objMMImgRigth.src = mainMenuDefaultImgSeperator;
			} else { 
				if (objMMImgRigth.src.indexOf(mainMenuLeftImgSeperator) == -1)
					objMMImgRigth.src = mainMenuLeftImgSeperator;
			}
		}
	}
	var objSM = document.getElementById("subMenu" + iFolderID);
	if(objSM != null) {

		var objSMBackground = document.getElementById("subMenuBackground");
		if(objSMBackground != null) {
			objSMBackground.style.left = -100;
			objSMBackground.style.top = -100;
			objSMBackground.style.visibility = "hidden";
		}

		objSM.style.left = -100;
		objSM.style.top = -100;
		objSM.style.visibility = "hidden";
	}
}

function mmMouseOver_dom2_dropdown_menu1b(iItemID, iFolderID, vcFolderName) {
	if(iItemIsSelected != null && iItemIsSelected != iItemID)
		mmClearItem_dom2_dropdown_menu1b(iItemIsSelected, iFolderIsSelected);
	if (iSubFolderIsSelected != null) 
		smClearItem_dom2_dropdown_menu1b();
	iItemIsSelected = iItemID;
	iSubFolderIsSelected = null;

	var objMM = document.getElementById("mainMenuTD" + iItemID);
	if(objMM != null) {
		objMM.style.cursor = 'hand';
		objMM.className = "dom2dropdownmenu1mainMenuSelected";
	}

	var objMMImgLeft = document.getElementById("mainMenuImgSep" + (iItemID -1));
	if(objMMImgLeft != null) {
		if ((iItemID - 1) != iItemIsActive)
			objMMImgLeft.src = mainMenuLeftImgSeperator;
		else 
			objMMImgLeft.src = mainMenuMiddleImgSeperator;
	}
	var objMMImgRigth = document.getElementById("mainMenuImgSep" + iItemID);
	if(objMMImgRigth != null) {
		if (iItemID+1 != iItemIsActive)
			objMMImgRigth.src = mainMenuRigthImgSeperator;
		else 
			objMMImgRigth.src = mainMenuMiddleImgSeperator;
	}

	var subMenuTableHeight = null;

	var objSM = document.getElementById("subMenu" + iFolderID);
	var objSMTable = document.getElementById("subMenuTable" + iFolderID);

	if(objSMTable != null) {
		subMenuTableHeight = objSMTable.offsetHeight;
		subMenuTableWidth = objSMTable.offsetWidth;
		if(subMenuTableWidth < arrSMWidth[iItemID]) {
			objSMTable.style.width = arrSMWidth[iItemID];
			subMenuTableWidth = arrSMWidth[iItemID];
		}
	}

	if(objSM != null) {
		iFolderIsSelected = iFolderID;
		var objSMBackgroundTable = document.getElementById("subMenuBackgroundTable");
		if(objSMBackgroundTable != null) {
			objSMBackgroundTable.style.width = subMenuTableWidth;
			objSMBackgroundTable.style.height = subMenuTableHeight;
		}
		var objSMBackground = document.getElementById("subMenuBackground");
		if(objSMBackground != null) {
			objSMBackground.style.left = arrSMoffsetX[iItemID-1];
			objSMBackground.style.top = iSMoffsetY;
			objSMBackground.style.visibility = "visible";
		}

		arrPosition["sm"] = new Array();
		arrPosition["sm"]["top"] = iSMoffsetY;
		arrPosition["sm"]["left"] = arrSMoffsetX[iItemID-1];
		arrPosition["sm"]["bottom"] = iSMoffsetY + subMenuTableHeight;
		arrPosition["sm"]["right"] = arrSMoffsetX[iItemID-1] + subMenuTableWidth;

		objSM.style.left = arrSMoffsetX[iItemID-1];
		objSM.style.top = iSMoffsetY;
		objSM.style.visibility = "visible";
	}
}

function smClearItem_dom2_dropdown_menu1b() {
	var objSM = document.getElementById("subMenuTD" + iSubFolderIsSelected);
	if(objSM != null)
		objSM.className = "dom2dropdownmenu1subMenu";
}

function smMouseOver_dom2_dropdown_menu1b(iFolderID, vcFolderName) {
	if (iSubFolderIsSelected != null) 
		smClearItem_dom2_dropdown_menu1b();
	var objSM = document.getElementById("subMenuTD" + iFolderID);
	if(objSM != null) {
		objSM.style.cursor = 'hand';
		objSM.className = "dom2dropdownmenu1subMenuSelected";
	}
	iSubFolderIsSelected = iFolderID;
}

function clearByPosition_dom2_dropdown_menu1b() {
	if (!(iMouseY >= arrPosition["mm"]["top"] &&
		iMouseY <= arrPosition["mm"]["bottom"] &&
		iMouseX >= arrPosition["mm"]["left"] &&
		iMouseX <= arrPosition["mm"]["right"])) {
		if (!(iMouseY >= arrPosition["sm"]["top"] &&
			iMouseY <= arrPosition["sm"]["bottom"] &&
			iMouseX >= arrPosition["sm"]["left"] &&
			iMouseX <= arrPosition["sm"]["right"])) {
			mmClearItem_dom2_dropdown_menu1b(iItemIsSelected, iFolderIsSelected);
			if (iSubFolderIsSelected != null) {
				smClearItem_dom2_dropdown_menu1b();
			}
		}
	}
}	

function clearService_dom2_dropdown_menu1b() {
	if (iItemIsSelected != null)
		clearByPosition_dom2_dropdown_menu1b();
	setTimeout("clearService_dom2_dropdown_menu1b();", 500);
}

function getMousePosition_dom2_dropdown_menu1b(e) {
	if(isIE) {
	    iMouseX = event.clientX;
	    iMouseY = event.clientY;
	} else {
	    iMouseX = e.clientX;
	    iMouseY = e.clientY;
	}
	return true;
}

function smLink_dom2_dropdown_menu1b(url) {
	document.location = url;
}

function getWindowWidth() {
	if (isIE) {
		if (document.body.clientWidth == document.body.scrollWidth) {
			return document.body.clientWidth;
		} else {
			return document.body.scrollWidth-20;
		}
	} else {
		return window.innerWidth;
	}
}

function setXPos() {
	if (!iRelativeXPos)
		return;
	var objMMTable = document.getElementById("mainMenuTable");
	if(objMMTable != null) {
		arrPosition["mm"] = new Array();
		arrPosition["mm"]["top"] = iSMoffsetY - objMMTable.offsetHeight + 5;
		arrPosition["mm"]["left"] = iSMOffsetX + 5 + getXPosOffset();
		arrPosition["mm"]["bottom"] = iSMoffsetY + 5;
		arrPosition["mm"]["right"] = iSMOffsetX + objMMTable.offsetWidth + 5 + getXPosOffset();
	}
	arrSMoffsetX[0] = getXPosOffset()+iSMOffsetX;
	var iTmpSMOffsetX = iSMOffsetX;
	for(i=1;i<iMMCount+1;i++) {
		var imgNum = i -1;
		var objMMImgSep = document.getElementById("mainMenuImgSep" + imgNum);
		var objMMTD = document.getElementById("mainMenuTD" + i);
		if(objMMImgSep != null && objMMTD != null) {
			var iMMWidth = iImageSepWidth + objMMTD.offsetWidth;
			iTmpSMOffsetX = iTmpSMOffsetX + iMMWidth;
			arrSMWidth[i] = iMMWidth;
			arrSMoffsetX[i] = getXPosOffset()+iTmpSMOffsetX;
		}
	}
}

function getXPosOffset() {
	if (!iRelativeXPos)
		return 0;
	else {
		return parseInt((getWindowWidth()/2)-(iMainMenuWidth/2));
	}
}
window.onresize = setXPos;
