tab_hide = new Array();
tabs_list = new Array('tabEducation','tabAchievements','tabPress','tabEvents');

tab_hide['Education'] = 'Achievements';
tab_hide['Achievements'] = 'Education';

tab_hide['Press'] = 'Events';
tab_hide['Events'] = 'Press';

periodic_td_class = new Array();
div_feature_list = new Array();
div_feature_count = 0;

/////////////////////////////////////////////////////////////////////

function create_periodic_window(_this)
{
	var abrev = _this.getElementsByTagName('strong').item(0).lastChild.nodeValue;
	var HttpMethod = 'POST';
	var url = '/json.php?client=js&page=professionals';
	var req = getXMLHTTPRequest();

	var params = 'title=' + abrev;

	if(req)
	{
		req.onreadystatechange = function()
		{
			if(req.readyState == 4 && req.status == 200)
			{
				eval(req.responseText);

				if(!isUndefined(content))
				{
					// create elements
					var div_feature = document.createElement('div');
					var a_close = document.createElement('a');
					var img_close = document.createElement('img');
					var div_narrative_text = document.createElement('div');
					var h3 = document.createElement('h3');
				
					// apply appropriate attributes
					div_feature.className = 'proFeature';
					div_narrative_text.className = 'narrativeText';
					img_close.className = 'popClose';
				
					img_close.title = 'Close';
					img_close.alt = 'Close';
					img_close.src = '/media/images/professionals/button_pop_close.gif';
				
					a_close.title = 'Close';
					a_close.href = 'javascript:;';
					a_close.onclick = function() { periodic_window_close(this); }

					// set text nodes
					var text = document.createTextNode(content.title);
					h3.appendChild(text);
					div_narrative_text.appendChild(h3);

					div_narrative_text.innerHTML+=content.narrative_text;
					//html.innerHTML = html;
			
					// set data
					a_close.appendChild(img_close);
					div_feature.appendChild(a_close);
					div_feature.appendChild(div_narrative_text);
			
					div_feature.id = 'featureID'+div_feature_count;
					div_feature.style.display = 'block';
			
					_this.parentNode.appendChild(div_feature);
					div_feature_count++;
				}
			}
		}

		req.open(HttpMethod,url,true);
		req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		req.send(params);
	}
}

/////////////////////////////////////////////////////////////////////

function periodic_window_close(_this)
{
	var abrev = _this.parentNode.parentNode.getElementsByTagName('strong').item(0).lastChild.nodeValue;

	_this.parentNode.style.display = 'none';
	_this.parentNode.parentNode.className = periodic_td_class[abrev];
}

/////////////////////////////////////////////////////////////////////

function periodic_window_close_all()
{
	for(var i=0;div_feature_count>i;i++)
	{
		var div = document.getElementById('featureID'+i);
		var td = div.parentNode;
		var abrev = td.getElementsByTagName('strong').item(0).lastChild.nodeValue;

		div.style.display = 'none';
		td.className = periodic_td_class[abrev];
	}
}

/////////////////////////////////////////////////////////////////////

function periodic_window_open(_this)
{
	var td = _this.parentNode;
	var div = td.getElementsByTagName('div');
	var div_count = div.length;
	var div_exists = false;
	var abrev = _this.getElementsByTagName('strong').item(0).lastChild.nodeValue;

	if(td.className != 'active')
	{
		if(isUndefined(periodic_td_class[abrev]))
			periodic_td_class[abrev] = td.className;

		for(var i=0;div_count>i;i++)
		{
			if(div.item(i).className == 'proFeature')
			{
				div_exists = true;
				periodic_window_close_all();
				div.item(i).style.display = 'block';
				break;
			}
		}

		td.className = 'active';

		if(!div_exists)
		{
			periodic_window_close_all();
			create_periodic_window(_this);
		}
	}

	return false;
}

/////////////////////////////////////////////////////////////////////

function periodic_window_data(_this)
{
	var abrev = _this.getElementsByTagName('strong').item(0).lastChild.nodeValue;
	var HttpMethod = 'POST';
	var url = '/json.php?client=js&page=professionals';
	var req = getXMLHTTPRequest();

	var params = 'title=' + abrev;

	if(req)
	{
		req.onreadystatechange = function()
		{
			if(req.readyState == 4 && req.status == 200)
				eval(req.responseText);
		}

		req.open(HttpMethod,url,true);
		req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		req.send(params);
	}
}

/////////////////////////////////////////////////////////////////////

function periodic_window_set()
{
	if(document.getElementById('proTable'))
	{
		var a_links = document.getElementById('proTable').getElementsByTagName('a');
		var a_count = a_links.length;

		for(var i=0;a_count>i;i++)
			a_links.item(i).onclick = function() { periodic_window_open(this); }
	}

	return;
}

/////////////////////////////////////////////////////////////////////

addLoadEvent(periodic_window_set);
addLoadEvent(tabs);

