function addTooltips(){
	var areas = document.getElementsByTagName("area");
	for(i = 0;i < areas.length;i++)
	{
		var area = areas[i];
		area.onclick = function () { showToolTip(this); return false; };
	}
}
function showToolTip(elem){
	hideTooltips();
	var mapCoords = findElementPos(document.getElementById('map'));
	var arrayPageSize = getPageSize();
	var tooltip = $(elem.hash.substring(1));
	if(tooltip)
	{
		tooltip.style.display = 'block';
		
		var left = parseInt(mapCoords[0]) + parseInt(elem.coords.split(',')[0]) + 10;
		var top = parseInt(mapCoords[1]) + parseInt(elem.coords.split(',')[1]) + 10;
		
		tooltip.style.top = ((top+tooltip.offsetHeight) < arrayPageSize[3]-35) ? 
			top + 'px' : (top-tooltip.offsetHeight) + 'px';
		tooltip.style.left = ((left+200) < arrayPageSize[0]) ? 
			left + 'px' : (left - 200) + 'px';
	}
}
function showBio(elem){
	hideTooltips();
	var tooltip = $(elem.hash.substring(1));
	var img = $(tooltip.id + 'Image');
	if(tooltip && img)
	{
		var coords = findElementPos(img);
		tooltip.style.display = 'block';
		tooltip.style.top = parseInt(coords[1]) + 'px';
		tooltip.style.left = parseInt(coords[0] - 330) + 'px';
	}
}
function hideTooltips(){
	var tooltips = document.getElementsByTagName("div");
	for(i=0;i<tooltips.length;i++)
	{
		var tooltip = tooltips[i];
		if(tooltip.className == "tooltip")
			tooltip.style.display = 'none';
	}
}
function findElementPos(obj){
	var curleft = curtop = 0;
	if(obj.offsetParent)
	{
		do {
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
		} while (obj = obj.offsetParent);
	}
	return [curleft,curtop];
}
function addLoadEvent(func){	
	var oldonload = window.onload;
	if (typeof window.onload != 'function'){
    	window.onload = func;
	} else {
		window.onload = function(){
		oldonload();
		func();
		}
	}
}
function openDialog(height, width)
{
	var mainRoleList = $('mainRoleList');
	if(mainRoleList)
	{
		if(mainRoleList.selectedIndex != 0)
		{
			hideAll();
			var panel = $(mainRoleList.options[mainRoleList.selectedIndex].value);
			if(panel) panel.style.display = 'block';
			
			var arrayPageSize = getPageSize();
			var arrayPageScroll = getPageScroll();
	
			var module = $('module');
			if(module)
			{
				module.style.top = (arrayPageScroll[1] + ((arrayPageSize[3] - 35 - height) / 2) + 'px');
				module.style.left = (((arrayPageSize[0] - 20 - width) / 2) + 'px');
				module.style.display = 'block';
			}
		}
	}
}
function showSelectedRole()
{
	var roleList = $('roleList');
	if(roleList)
	{
		if(roleList.selectedIndex != 0)
		{
			hideAll();
			var panel = $(roleList.options[roleList.selectedIndex].value);
			if(panel) panel.style.display = 'block';
		}
	}
}
function hideAll()
{
	var mainRoleList = $('mainRoleList');
	if(mainRoleList)
	{
		for(i=1;i<mainRoleList.options.length;i++)
		{
			var panel = $(mainRoleList[i].value);
			if(panel) panel.style.display = 'none';
		}
	}
}
function closeDialog()
{
	var module = $('module');
	var mainRoleList = $('mainRoleList');
	var roleList = $('roleList');
	
	if(module) module.style.display = 'none';
	if(mainRoleList) mainRoleList.selectedIndex = 0;	
	if(roleList) roleList.selectedIndex = 0;
}
// Returns array with x,y page scroll values.
function getPageScroll(){
	var yScroll;
	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){
		yScroll = document.documentElement.scrollTop;
	} else if (document.body) {
		yScroll = document.body.scrollTop;
	}
	arrayPageScroll = new Array('',yScroll) 
	return arrayPageScroll;
}
// Returns array with page width, height and window width, height
function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { 
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { 
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { 
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}
	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}
function $(id){return document.getElementById(id);}