
var allEvents = new Array()
var activeMenu = null; //defines which menu is currently open
var activeSection = "Default";
menus = new Array("Search","Sections","Regions","Clippings");

function eventSummary(t,state){
	obj = document.getElementById("a" + t);
	obj = obj.nextSibling;
	color = "#666666";
	if (state == 1){
		color="#000000";
	}
	obj.style.color = color;	
}
	
// turns on the visibiliy for a subscection,
// access through the table of contents at the top of a section page
function eventShowSection(t){
	if (activeSection != null){
		document.getElementById("section"+activeSection).style.display = "none";
		if (document.getElementById("index"+activeSection)){
			document.getElementById("index"+activeSection).style.color = "#3360BB";
			document.getElementById("index"+activeSection).style.fontWeight = "normal";
		}
	}
	activeSection = t;
	document.getElementById("section"+activeSection).style.display = "block";
	if (document.getElementById("index"+activeSection)){
		document.getElementById("index"+activeSection).style.color = "#FF6600";
		document.getElementById("index"+activeSection).style.fontWeight = "bold";
	}
}

// returns the child child object as defined by child of t
function findChild(t, child){
	target = null;	
	for (i=0; i < t.childNodes.length; i++){
		if (t.childNodes[i].id == child){
			target = t.childNodes[i];
			i = t.childNodes.length;
		}
	}
	return target;
}

// toggles the display for headlines of page sub sections
function eventShowHeadlines(t){
	t = document.getElementById(t);
	obj = findChild(t,"featureTD");
	obj = findChild(obj,"featureHd");
	if (obj.style.display == "block"){
		obj.style.display = "none";
	} else {
		obj.style.display = "block";
	}
}

function eventShowAllHeadlines(){
	t = document.getElementsByName("featureHd");
	if (t.length > 0){
		for (j=0; j < t.length; j++) t[j].style.display = "block";
	} else { 
		// this is a hack, and possibly slow bu IE5mac and NS6 do 
		// not return a length on Object collections
	 	d = document.getElementsByTagName("DIV");
  		for (i=0; i < d.length; i++){
			if (d[i].id == "featureHd"){
				d[i].style.display = "block";
			}
		}
	}		
}

function eventShowAllSubHeadlines(){
	d = document.getElementsByTagName("DIV");
  	for (i=0; i < d.length; i++){
		if (d[i].id.substring(0,3) == "sub"){
			d[i].style.display = "block";
			obj = document.getElementById(d[i].id + "img");
			obj.src = "/images/icon/selectedD.gif";
		}
	}
}	
	
function menuOver(){
	document.onclick = null;
	if (document.all){
		event.cancelBubble = true;
	}
}

function menuOut(){
	document.onclick = eventHideMenu;
	if (document.all){
		event.cancelBubble = true;
	}
}

//this will display info pop ups, for example art event details
function eventShowPopUp(target){
	if (activeMenu != null){
		eventHideMenu();
	}
	activeMenu = target;
	obj = document.getElementById(activeMenu);
	obj.style.display = "block";
	if (event){
		event.cancelBubble = true;
	}
}

//this will display info pop ups, for example art event details
function eventShowArtPopUp(target){
	if (activeMenu != null){
		eventHideMenu();
	}
	activeMenu = target;
	obj = document.getElementById(activeMenu);
	obj.style.display = "block";
	obj.style.visibility = "visible";
	obj.style.top = -20+mouseY+ihtScreen.scrollTop()+"px";
	if (event){
		event.cancelBubble = true;
	}
}
	
function eventHelp(){
	document.location = "/info/help.html";
}

//turns on the display for nav menus
function eventShowMenu(e){
	if (activeMenu != null){
		eventHideMenu();
	}
	activeMenu = "menu"+this.id.substring(3,this.id.length);
	obj = document.getElementById(activeMenu);
	if (obj){
		obj.style.visibility = "visible";
		//document.ultralingua.language.style.visibility = "hidden";
		if (document.ultralingua){
			document.ultralingua.language.style.visibility = "hidden";
		}
	}
	if (document.all){
		document.onclick = eventHideMenu;
	}
	event.cancelBubble = true;
}

//hides nav menus and pop ups
function eventHideMenu(){
	document.onclick = null;
	if (activeMenu != null){
		obj = document.getElementById(activeMenu);
		obj.style.visibility = "hidden";
		//document.ultralingua.language.style.visibility = "visible";
		if (document.ultralingua){
			document.ultralingua.language.style.visibility = "visible";
		}
	}
}

//adjusts the style.display property of the obj with id defined by inObj
function eventToggleDisplay(inObj){
	obj = document.getElementById(inObj);
	if (obj){
		vis = 'block';
		if (obj.style.display == 'block'){
			vis = 'none';
		}
		obj.style.display = vis;
	}
	obj = document.getElementById(inObj+"img");
	if (obj){
		if (vis == 'block'){
			obj.src = "/images/icon/selectedD.gif";
		} else {
			obj.src = "/images/icon/selected.gif";
		}
	}
}

//adjusts the style.visibility property of the obj with id defined by inObj	
function eventToggleVis(inObj){
	obj = document.getElementById(inObj);
	if (obj){
		vis = 'visible';
		if (obj.style.visibility == 'visible'){
			vis = 'hidden';
		}
		obj.style.visibility = vis;
	}
}	
	
//nav events
function userEventsInit(){
	for (i=0; i < menus.length; i++){
		obj = document.getElementById("nav" + menus[i]);
		obj.onclick = eventShowMenu;		
		obj = document.getElementById("menu" + menus[i]);
		obj.onmouseover = menuOver;
		obj.onmouseout = menuOut;
	}		
	obj = document.getElementById("navClippingsCounter");
	obj.onclick = eventShowNextClipping; //in ihtClippings.js
	obj = document.getElementById("navHelp");
	obj.onclick = eventHelp; //in ihtClippings.js
}
