var activeMenu = null;
var activeButton = null;
var menuTimer = 0;
// 2 funstions are from http://forums.devshed.com/t40400/s.html
function getRealLeft(el) {
    xPos = el.offsetLeft;
    tempEl = el.offsetParent;
    while (tempEl != null) {
        xPos += tempEl.offsetLeft;
        tempEl = tempEl.offsetParent;
    }
    return xPos;
}

function getRealTop(el) {
    yPos = el.offsetTop;
    tempEl = el.offsetParent;
    while(tempEl != null){
        yPos += tempEl.offsetTop;
        tempEl = tempEl.offsetParent;
    }
    return yPos;
}

function shadeForms(){
	for(i=0; i<document.forms.length;i++){
		f = document.forms[i];
		for(j=0; j<f.elements.length; j++){
			el = f.elements[j];
			el.disabled = true;
			//if(el.type=="select-one"){
			//	el.style.visibility = "hidden";
			//}
		}
	}
}

function unShadeForms(){
	for(i=0; i<document.forms.length;i++){
		f = document.forms[i];
		for(j=0; j<f.elements.length; j++){
			el = f.elements[j];
			el.style.visibility = "visible";
			el.disabled = false;
		}
	}
}


//////////////////////////
//show top menu item
function onTopButton(button){
	//"unpress" active button if exists
	if(activeButton != null) activeButton.className = "topButtonOff";
	//hide active menu if exists
	if(activeMenu != null) activeMenu.style.visibility = "hidden";
	clearTimeout(menuTimer);
	//set new button to active
	activeButton = button;
	//and press it
	activeButton.className = "topButtonOn";
	//get menu for this button
	activeMenu = document.getElementById(activeButton.id + 'Items');
	//if menu here - show it
	if(activeMenu != null){
//		activeMenu.style.left = getRealLeft(button) + 135;
//		activeMenu.style.top = getRealTop(button) + 0;
		activeMenu.style.left = getRealLeft(button) + 0;
		activeMenu.style.top = getRealTop(button) + 22;
		activeMenu.style.visibility="visible";
		//shadeForms();
	}
}

function offTopButton(){
	menuTimer = setTimeout("hideMenu()", 300);
}

function hideMenu(){
	if(activeButton != null) activeButton.className = "topButtonOff";
	if(activeMenu != null) activeMenu.style.visibility = "hidden";
	activeButton = null;
	activeMenu = null;

}

///////////////////////////////
//Menu items functions
function onTopMenuItem(item){
	clearTimeout(menuTimer);
	item.className = "topMenuItemOn";
	//window.status = "Admin Area: " + item.statustext;
}

function offTopMenuItem(item){
	item.className = "topMenuItemOff";
	menuTimer = setTimeout("hideMenu()", 600);
}

function gotoTopMenuItem(url){
	document.location = url;
}

///////////////////////////////
//Left Menu items functions
function onLeftMenuItem(item){
	clearTimeout(menuTimer);
	item.className = "LeftMenuItemOn";
	//window.status = "Admin Area: " + item.statustext;
}

function offLeftMenuItem(item){
	item.className = "LeftMenuItemOff";
	menuTimer = setTimeout("hideMenu()", 600);
}

function gotoLeftMenuItem(url){
	document.location = url;
}

