var objTimer = "";
var openMenu = null;
var bMenuClosable = true;
var IE = ((document.all)&&(navigator.appVersion.indexOf("MSIE")!=-1)) ? true : false;

function clearTimer(){
	window.clearTimeout(objTimer);
}

function closeMenu(){
	var funcToCall = "bMenuClosable = true;"
	objTimer = window.setTimeout(funcToCall, 900);
}

function cleanUpMenu() {
}

function showMenu(id, objPos){

	if(document.getElementById){
		clearTimer();
		setBoxProp('meetingdrop', 'display', 'none');
		setBoxProp('assocdrop', 'display', 'none');
		setBoxProp('clientsdrop', 'display', 'none');
		setBoxProp('resourcesdrop', 'display', 'none');
		setBoxProp('partnerdrop', 'display', 'none');
		setBoxProp('aboutusdrop', 'display', 'none');
		setBoxProp('webDesignRochesterIndaroWebExperts', 'display', 'none');
		openMenu = id;
		bMenuClosable = false

		var x = 0;
		var y = 0;
		
		x = getBoxLeft(objPos) +1;
		y = getBoxBottom(objPos)-1;

		if( id == 'webDesignRochesterIndaroWebExperts' ) {
			y -= 260;
		}
				
		setBoxProp(id, 'display', 'block');
		setBoxProp(id, 'left', x + "px");
		setBoxProp(id, 'top', y + "px");
	}
}

function hideMenu(id){
	setBoxProp(id, 'display', 'none');
	openMenu = null;
}

function getMousePos(event){
	var x, y;
	if(window.event){
		x = window.event.clientX;
		y = window.event.clientY;
		if (document.documentElement && document.documentElement.scrollTop){
			y+=document.documentElement.scrollTop;
		} else {
			y+=document.body.scrollTop;
		}
	} else {
		x = event.pageX;
		y = event.pageY;
	}

	if(openMenu != null){
		var testInside = isOn(x, y, openMenu);
		if(!testInside && bMenuClosable == true){
			hideMenu(openMenu);
		}
		if(testInside){
			bMenuClosable = true;
			clearTimer();
		}
	}
}

function isOn(xCur, yCur, id){
	var retVal = false;
	if( (id != null) && (xCur >= getBoxLeft(id)) 
		&& (xCur <=getBoxRight(id)) && (yCur >= getBoxTop(id)) 
		&& (yCur <= getBoxBottom(id)) ){
		retVal = true;
	} 
	return retVal;
}

window.onload = function() {
	document.onmousemove = getMousePos;
}



/** Box Border Distance Functions */
function getBox(oBox) {
	var box = null;
	if(typeof(oBox) == 'object'){
		box = oBox;
	} else {
		box = document.getElementById(oBox);
	}
	return box;
}

function setBoxProp(oBox, strProp, strVal){
	var box = getBox(oBox);
	if((box != null) && (box.style != null)){
		box = box.style;
		box[ strProp ] = strVal;
	}
}

function getBoxLeft(oBox) {
	var box = getBox(oBox);
	var nDelta = 0;
	while (box != null) {
		nDelta += box.offsetLeft;
		box = box.offsetParent;
	}
	return parseInt(nDelta);
}

function getBoxRight(oBox){
	return getBoxLeft(oBox) + getBoxWidth(oBox);
}

function getBoxTop(oBox) {
	var box = getBox(oBox);
	var nDelta = 0;

	while (box != null) {
		nDelta += box.offsetTop;
		box = box.offsetParent;
	}
	return parseInt(nDelta);
}

function getBoxBottom(oBox){
	return getBoxTop(oBox) + getBoxHeight(oBox);
}

function getBoxWidth(oBox){
	var box = getBox(oBox);
	return parseInt(box.offsetWidth);
}

function getBoxHeight(oBox){
	var box = getBox(oBox);
	return parseInt(box.offsetHeight);
}

function getBoxProp(oBox, strProp){
	var box = getBox(oBox);
	var retVal = null;
	if (box != null){
		box = box.style;
		if(box){
			if(box[strProp]){
				retVal = box[strProp];
			} 
		}
	}
	return retVal;
}

var daWin;
function openIt(p,w,h){
			daWin = window.open(p,'pbs','menubar=0,toolbar=0,location=0,directories=0,status=0,scrollbars=0,resizable=0,hotkeys=0,width='+w+',height='+h+'');
			daWin.focus();
}

function imgFlip(imgDocID,imgObjName) {
  document.images[imgDocID].src = imgObjName
 } // function