/* 
 * 31.1.2007 added anchor functionality
 * new var displayBlockIdPrefix
 * added check for hash in setToggleDisplayState() 
 * added set hash in activeStyles()
 */

var displayBlockIdPrefix = 'x_x';
var postFix = 'Button';
var activeButtonClass = 'ititelActive';
var activeDetailClass = 'idetailActive';
var ButtonClass = 'ititelPassive';
var DetailClass = 'idetailPassive';
var displays_array = new Array ();
var state_array = new Array ();
var leftPosition = '0';
var activeDetailHeight = "24em";

function passiveDetailStyles(switch_id) {
	switch_id.style.display="none";

}
function initDetailStyles(switch_id) {
 	switch_id.style.position="absolute";
	switch_id.style.display="none";
}
function activeDetailStyles(switch_id) {
 	switch_id.style.position="absolute";
	switch_id.style.left=leftPosition;
	switch_id.style.top="1.7em";
	switch_id.style.width="44em";
	//~ switch_id.style.height=activeDetailHeight;
	//~ switch_id.style.width="100%";
	//~ switch_id.style.height="20%";
	//~ switch_id.style.overflow="auto";
	switch_id.style.display="block";
	switch_id.style.paddingBottom="100px";
/* 	Effect.Appear(switch_id);  */
}
function passiveTitelStyles(button_id) {
 	button_id.style.position="relative";
	button_id.style.top="3.7em";
	button_id.style.left="-20em";
	button_id.style.width="12em";
 	button_id.style.fontSize="0.9em";
  	button_id.style.fontWeight="500";
  	button_id.style.borderBottom="1px dotted gray";
	button_id.style.cursor="pointer";
}
function activeTitelStyles(button_id) {
 	button_id.style.position="absolute";
	button_id.style.top="0em";
	button_id.style.left=leftPosition;
	button_id.style.width="37.5em";
	button_id.style.fontSize="1.4em";
 	button_id.style.fontWeight="600"; 
  	button_id.style.borderBottom="none";
	button_id.style.cursor="auto";
}
function passiveStyles(switch_id,button_id) {
	passiveDetailStyles(switch_id);
	passiveTitelStyles(button_id);
}

function activeStyles(switch_id,button_id) {
	window.location.hash = switch_id.id.substr(displayBlockIdPrefix.length, switch_id.id.length);
	activeTitelStyles(button_id);
	activeDetailStyles(switch_id);
}
function setArrayStates(aState,myid) {
	displays_array[myid] = aState;
	document.cookie = myid + '=' + aState;	
}
function initHideBlock(switch_id,myid,button_id) {
	passiveTitelStyles(button_id);
	initDetailStyles(switch_id);
	setArrayStates('hide',myid);
}
function defineIds(myid) {
	switch_id = document.getElementById(myid);
	imgid = myid + postFix;
	button_id = document.getElementById(imgid);
}
function toggleDisplay(myid) {
	var aID;
	if (displays_array[myid] != 'show')
	{
		if (document.getElementById)
		{
			for (aID in displays_array)
			{
				defineIds (aID);
				if (button_id)
				{
					passiveStyles(switch_id,button_id);
					setArrayStates('hide',aID);
					if (aID == myid) var showThisOneLater = myid;
				} 
			}
			defineIds (showThisOneLater);
			activeStyles(switch_id,button_id);
			setArrayStates('show',showThisOneLater);
		}
	}
	if(parent.googleListEntry)
	{
		location.reload();
	}
}
function setToggleDisplayState() {
	var aID;
	if (document.getElementById)
	{
		var state;
		for (aID in displays_array)
		{
			defineIds (aID);
			if (button_id)
			{
				if (window.location.hash == "")
				{
					if ( !( state = getCookie(aID) ) ) state = displays_array[aID];
				} else {
					if (aID == displayBlockIdPrefix +window.location.hash.substr(1, window.location.hash.length) )
					{
						state  = 'show';
					} else {
						state = 'hide';
					}
				}
				if ( state == 'show') var showThisOneLater = aID;
				initHideBlock(switch_id,aID,button_id);
			}
		}
		defineIds (showThisOneLater);
		activeStyles(switch_id,button_id);
		setArrayStates('show',showThisOneLater);
	}
}

function getCookie(name) {
	var dc = document.cookie;
	var prefix = name + "=";
	var begin = dc.indexOf("; " + prefix);
	if (begin == -1)
	{
		begin = dc.indexOf(prefix);
		if (begin != 0) return null;
	}
	else begin += 2;
	var end = document.cookie.indexOf(";", begin);
	if (end == -1) end = dc.length;
	return unescape(dc.substring(begin + prefix.length, end));
}