// JavaScript Document

var staffProfile = {
	
	addListeners: function () {
		
		for (i=0;i<staffProfile.arrStaff.length;i++) {
			var objLink = document.getElementById("stf_" + staffProfile.arrStaff[i]);
			rwScript.addEvent(objLink, 'click', staffProfile.getClick(objLink), false);
			
			// Hide images
			var objImage = document.getElementById("stf_" + staffProfile.arrStaff[i] + "_Image");
			if (staffProfile.arrStaff[i] != "Michael") {
				objImage.style.display = 'none';
			} else {
				objImage.style.display = 'block';
			}
		}
		
	},
	
	staffClick: function (e, targetElement) {
		var el = window.event ? targetElement : e ? e.currentTarget : null;
		if (!el) return;
		
		// get detail object
		var objStaffDetail = document.getElementById(el.id + '_Detail');
		var objStaffImage = document.getElementById(el.id + '_Image');
		
		if (objStaffDetail.style.display == 'none' || objStaffDetail.style.display == '') {
			objStaffDetail.style.display = 'inline';
			objStaffImage.style.display = 'block';
			
			for (i=0;i<staffProfile.arrStaff.length;i++) {
				if (el.id != "stf_" + staffProfile.arrStaff[i]) {
					var objOtherStaff = document.getElementById("stf_" + staffProfile.arrStaff[i] + "_Detail");
					var objOtherImage = document.getElementById("stf_" + staffProfile.arrStaff[i] + "_Image");
					objOtherStaff.style.display = 'none';
					objOtherImage.style.display = 'none';
				}
			}
		} else {
			objStaffDetail.style.display = 'none';
			objStaffImage.style.display = 'none';
		}
		
	},
	
	getClick: function (node) { return function(e) { staffProfile.staffClick(e, node); }; },
	
	arrStaff: ["Michael","Alfons","Renata","Alex","Judi","Victor"]
	
};

rwScript.addEvent(window, 'load', staffProfile.addListeners, false);
rwScript.addEvent(window, 'unload', EventCache.flush, false);
