/*
Reveal/Hide
FairSky Pages Component
-----------------------
Copyright 2004 Joshua Paine
Created by Joshua Paine of FairSky Networks <http://fairsky.us/>
Contact at <http://fairsky.us/contact>
Updated 2004-05-17

The latest version should be available at
<http://demo.fairsky.us/javascript/columns.html>

You may copy, reuse, or produce derivative works of this code
only under the terms of the Linky-Linky License v0.1 or later.
The Linky License can be found at <http://fairsky.us/linky>.
The main points of the license are:
	1) Do not alter or remove this notice.
	2) Notify me of your usage through one of the means listed
	   at <http://fairsky.us/contact>.
*/

function initMoreInfo()
{
	try
	{
		var s = document.getElementsByTagName('a');
		var hide_text = 'Hide';
		if(hide_info_text) hide_text = hide_info_text;
		for(var i=0; i<s.length; i++)
		{
			if(s[i].className == 'click-for-more')
			{
				addEvent(s[i],'click',clickInfo);
			}
		}
		var ds = document.getElementsByTagName('div');
		var de, container, hide_top, hide_bottom, a, t;
		for(i=0; i<ds.length; i++)
		{
			if(ds[i].className == 'more-info')
			{
				container = ds[i];
				hide_top = document.createElement('div');
				hide_top.className = 'more-info-top-bar';
				first_child = container.childNodes[0];
				container.insertBefore(hide_top,first_child);
				a = document.createElement('a');
				a.setAttribute('href','javascript://');
				a.className = 'more-info-hide';
				t = document.createTextNode(hide_text);
				hide_top.appendChild(a);
				a.appendChild(t);
				addEvent(a,'click',hideInfo);
				hide_bottom = document.createElement('div');
				hide_bottom.className = 'more-info-bottom-bar';
				container.appendChild(hide_bottom);
				a = document.createElement('a');
				a.setAttribute('href','javascript://');
				a.className = 'more-info-hide';
				t = document.createTextNode(hide_text);
				hide_bottom.appendChild(a);
				a.appendChild(t);
				addEvent(a,'click',hideInfo);
			}
		}
	}
	catch(e){ }
}

function clickInfo(e)
{
	var c;
	if(this && this.className) c = this;
	else if(e && e.currentTarget && e.currentTarget.className) c = e.currentTarget;
	else if(window.event && window.event.srcElement && window.event.srcElement.className) c = window.event.srcElement;
	var s = document.getElementsByTagName('a');
	var d = document.getElementsByTagName('div');
	var si = 0;
	var di = -1;
	var flag = false;
	while(si<s.length && !flag)
	{
		if("click-for-more" == s[si].className)
		{
			di++;
			while(di<d.length && d[di].className != 'more-info') di++;
		}
		if(s[si]==c) flag = true;
		else si++;
	}
	if(d[di]) d[di].style.display = 'block';
}

function hideInfo(e)
{
	if(this && this.className) t = this;
	else if(e && e.currentTarget && e.currentTarget.className) t = e.currentTarget;
	else if(window.event && window.event.srcElement && window.event.srcElement.className) t = window.event.srcElement;
	while(t.className != 'more-info') t = t.parentNode;
	t.style.display = 'none';
}

// scott andrew (www.scottandrew.com) wrote this function. thanks, scott!
// adds an eventListener for browsers which support it.
function addEvent(obj, evType, fn){
  if (obj.addEventListener){
    obj.addEventListener(evType, fn, true);
    return true;
  } else if (obj.attachEvent){
	var r = obj.attachEvent("on"+evType, fn);
    return r;
  } else {
	return false;
  }
}

addEvent(window,'load',initMoreInfo); 