function findObj(objName, doc) {
	var p,i,x;
 	if(!doc) doc=document; 
  	if((p=objName.indexOf("?"))>0&&parent.frames.length) {
    	d=parent.frames[objName.substring(p+1)].document; 
		objName=objName.substring(0,p);
	}
  	if(!(x=doc[objName])&&doc.all) 
  		x=doc.all[objName];
	for (i=0;!x&&i<doc.forms.length;i++) 
		x=doc.forms[i][objName];
  	for(i=0;!x&&doc.layers&&i<doc.layers.length;i++) 
		x=findObj(objName,doc.layers[i].document);
  
  	if(!x && document.getElementById)
		x=document.getElementById(objName); 
	
	return x;
}

//=======================================================================

if (document.all) {
	n=0;ie=1;ns6=0;
}
if (document.getElementById&&!document.all) {
	n=0;ie=0;ns6=1;
}
if (document.layers) {
	n=1;ie=0;ns6=0;
}

rightX = 700;
leftX = 140;
topY = 50;
bottomY = 115;

if (ie||ns6) {
	document.onclick=hideAll;
	document.onscroll=hideAll;
	document.onmousemove=updateIt;
}

if (document.layers) {
	// window.captureEvents(Event.MOUSEMOVE);
	window.captureEvents(Event.CLICK);
	// window.onmousemove=updateIt;
	window.onclick=hideAll;
}

//=======================================================================

function changeImages(objName, objUrl) {
	var i,obj;
	if ((obj=findObj(objName))!=null){
		obj.src=objUrl;
	}
}

//=======================================================================

var lastMenu = null;
function displayMenu(objName) {
	var obj;
	var submenu = objName;
	
	//if (lastMenu != null && lastMenu != submenu) {
		hideAll();
		if (primary != 'default') {
			hideSubnav(primary);
		}
	//}
	
	if ((obj=findObj(objName))!=null) {
		if (obj.style) {
			obj.style.visibility = 'visible';	
		} else {
			obj.visibility = 'show';
		}
	}
	lastMenu = submenu;
}

//=======================================================================

function hideAll() {
	if (lastMenu != null) {
		objName = lastMenu;
		if ((obj=findObj(objName))!=null) {
			if (obj.style) {
				obj.style.visibility = 'hidden';
			} else {
				obj.visibility = 'hidden';
			}
		}
	}
}

//=======================================================================

function hideSubnav(obj) {
	if (obj != 'default') {
		if (document.getElementById(obj).style) {
			document.getElementById(obj).style.visibility = 'hidden';
		} else {
			obj.visibility = 'hidden';
		}
	}
}

//=======================================================================

function showSubnav(obj) {
	if (document.getElementById(obj)) {
		if (obj != 'default') {
			if (document.getElementById(obj).style.visibility == 'hidden') {
				document.getElementById(obj).style.visibility = 'visible';
			} else {
				obj.visibility = 'visible';
			}
		}
	} 
}

//=======================================================================
function updateIt(e) {
	if (ie) {
		var x = window.event.clientX;
   		var y = window.event.clientY;
		if (x > rightX || x < leftX) {
			hideAll();
			if (primary != 'default') {
				showSubnav(primary);
			}
		} else if (y > bottomY || y < topY) {
			hideAll();
			if (primary != 'default') {
				showSubnav(primary);
			}
        }
	}
	if (n||ns6) {
		var x = e.pageX;
    	var y = e.pageY;
		if (x > rightX || x < leftX) {
			hideAll();
			if (primary != 'default') {
				showSubnav(primary);
			}
		} else if (y > bottomY || y < topY) {
			hideAll();
			if (primary != 'default') {
				showSubnav(primary);
			}
        }
	}
}

//=======================================================================
