/**
 * @copyright    2008 Delivery.com JJ
 */
function jMenuBarHover(thisEvent, thisObj) {
	if (thisEvent === 'out') {
		thisObj.style.backgroundColor = '';
		thisObj.style.color = '';
		$(thisObj).unbind('mousemove');
		$(thisObj).children('span').css('display', 'none');
	} else {
		thisObj.style.backgroundColor = '#EDEDED';
		thisObj.style.color = 'black';
		
		$(thisObj).mousemove(function(event) {
			var offset = $(thisObj).offsetParent().offset();
			$(thisObj).children('span').css('top', (event.pageY - offset.top) + 15);
			$(thisObj).children('span').css('left', (event.pageX - offset.left) + 15);
			$(thisObj).children('span').css('display', 'block');
		});
	}
}

var openNavBarArea = null;
function jNavBarOpenArea(tabArea) {
	if(openNavBarArea != null) {
		$('#'+openNavBarArea).css('display', 'none');
		$('#'+openNavBarArea+'_l').removeClass('jnd_active_sm');
	}
	
	$('#'+tabArea).css('display', 'block');
	$('#'+tabArea+'_l').addClass('jnd_active_sm');
	openNavBarArea = tabArea;
}

function jVsChangeText(thisObj, newText) {
	thisObj.innerHTML = newText;
}

var openMenu = null;
function showMenu(elID, event, act, thisObj, old) {
	if (document.getElementById('tabs')) {
		thisObj = thisObj.parentNode;  //<-- Sid
    }
	var menudiv = document.getElementById(elID);
	if (!act) {
//		menudiv.style.display = 'hidden';
	} else {
		if (openMenu) {
			var menuToClose = document.getElementById(openMenu);
			menuToClose.style.display = 'none';
			if (elID === openMenu) {
				openMenu = null;
				return;
			}
		}
		openMenu = elID;
        var additionalOffset;
		if (!old) {
			additionalOffset = thisObj.offsetParent ? thisObj.offsetParent.offsetTop : 0;
			//menudiv.style.top = (additionalOffset + thisObj.offsetParent.offsetTop + thisObj.offsetParent.offsetHeight) + "px";
			menudiv.style.top = (thisObj.offsetParent.offsetTop + thisObj.offsetParent.offsetHeight) + "px";
			//alert(thisObj.offsetTop);
			//alert(thisObj.offsetParent.offsetHeight);
			menudiv.style.top = (additionalOffset + thisObj.offsetTop + thisObj.offsetHeight) + "px";
		} else {
			menudiv.style.top = (thisObj.offsetHeight + thisObj.offsetTop) + "px";
		}
//		alert(thisObj.offsetTop+' '+thisObj.clientTop + ' ' + thisObj);
//		alert(thisObj.offsetParent.offsetLeft+' '+thisObj.offsetLeft + ' ' + thisObj);
		if (!old) {
			additionalOffset = thisObj.offsetParent.offsetParent ? thisObj.offsetParent.offsetParent.offsetLeft : 0;
			//menudiv.style.left = (additionalOffset + thisObj.offsetParent.offsetLeft) + "px";
			menudiv.style.left = (additionalOffset + thisObj.offsetLeft) + "px";
		} else {
			menudiv.style.left = (thisObj.offsetLeft) + "px";
		}
		menudiv.style.zIndex = '100';
		//if (menudiv.style.display !== 'none') {
			//menudiv.style.display = 'none';
		//} else {
        menudiv.style.display = 'block';
		//}
//		var linkId = (elID + '_link');
//		var link = document.getElementById(linkId);
//		link.focus();
		//window.alert(event.clientX+" : "+event.clientY);
	}
}
