/*
This file contains javascript functions for use with Michael Soth's Website - LATER REPLACE NTL ADDRESS !!!!!
*/

function makeVisible(name_of_div) {

// the first test we do is a shortcut test.
// If the div we want to display is already visible
// then we can simply do nothing at all!

if (document.getElementById(name_of_div).className == 'dynamic_div_visible')
{
return;
}

// get two arrays. The first is an arrary
// of all the div elements on the page
var x = document.getElementsByTagName('div');

// the second is an array of all the table cells (tds)
var y = document.getElementsByTagName('th');

// now set all the div elements whose name begins with
// 'front_page' to be invisible

for (var i=0;i<x.length;i++)
{

if(x[i].id.substring(0,10) == 'front_page')
	{
	x[i].className = 'dynamic_div_invisible';
	}
}


// now set the one div element we want to be visible
// to belong to the visible class
document.getElementById(name_of_div).className='dynamic_div_visible';

// now set the all the "header_cell" table cells to a normal background color
//
for (var i=0;i<y.length;i++)
{
if(y[i].id.substring(0,9) == 'head_cell')
	{
	y[i].className = '';
	}
}

// finally we set the header cell that is selected to have a different
// background colour
// NB we get the number of the header cell we need by taking the last character
// from the element in name of div

var z = document.getElementById(name_of_div).id.charAt(10);
var selected_td = 'head_cell' + z;
document.getElementById(selected_td).className = 'selected';

}


function makeInVisible(name_of_div) {

// the first test we do is a shortcut test.
// If the div we want to display is already visible
// then we can simply do nothing at all!

if (document.getElementById(name_of_div).className == 'dynamic_div_invisible')
{
return;
}

// get two arrays. The first is an arrary
// of all the div elements on the page
var x = document.getElementsByTagName('div');

// the second is an array of all the table cells (tds)
var y = document.getElementsByTagName('th');

// now set all the div elements whose name begins with
// 'front_page' to be invisible

for (var i=0;i<x.length;i++)
{

if(x[i].id.substring(0,10) == 'front_page')
	{
	x[i].className = 'dynamic_div_invisible';
	}
}


// now set the one div element we want to be visible
// to belong to the visible class
document.getElementById(name_of_div).className='dynamic_div_invisible';

// now set the all the "header_cell" table cells to a normal background color
//
for (var i=0;i<y.length;i++)
{
if(y[i].id.substring(0,9) == 'head_cell')
	{
	y[i].className = '';
	}
}

// finally we set the header cell that is selected to have a different
// background colour
// NB we get the number of the header cell we need by taking the last character
// from the element in name of div

var z = document.getElementById(name_of_div).id.charAt(10);
var selected_td = 'head_cell' + z;
document.getElementById(selected_td).className = 'selected';

}

function makeSpecificObjVisible(name_of_div) {

// the first test we do is a shortcut test.
// If the div we want to display is already visible
// then we can simply do nothing at all!

if (document.getElementById(name_of_div).className == 'dynamic_div_visible')
{
return;
}

// get two arrays. The first is an arrary
// of all the div elements on the page
var x = document.getElementsByTagName('div');

// the second is an array of all the table cells (tds)
var y = document.getElementsByTagName('th');

// now set all the div elements whose name begins with
// 'front_page' to be invisible
/*
for (var i=0;i<x.length;i++)
{

if(x[i].id.substring(0,10) == 'front_page')
	{
	x[i].className = 'dynamic_div_invisible';
	}
}
*/

// now set the one div element we want to be visible
// to belong to the visible class
document.getElementById(name_of_div).className='dynamic_div_visible';

// now set the all the "header_cell" table cells to a normal background color
//
for (var i=0;i<y.length;i++)
{
if(y[i].id.substring(0,9) == 'head_cell')
	{
	y[i].className = '';
	}
}

// finally we set the header cell that is selected to have a different
// background colour
// NB we get the number of the header cell we need by taking the last character
// from the element in name of div

var z = document.getElementById(name_of_div).id.charAt(10);
var selected_td = 'head_cell' + z;
document.getElementById(selected_td).className = 'selected';

}


function makeSpecificObjInVisible(name_of_div) {

// the first test we do is a shortcut test.
// If the div we want to display is already visible
// then we can simply do nothing at all!

if (document.getElementById(name_of_div).className == 'dynamic_div_invisible')
{
return;
}

// get two arrays. The first is an arrary
// of all the div elements on the page
var x = document.getElementsByTagName('div');

// the second is an array of all the table cells (tds)
var y = document.getElementsByTagName('th');

// now set all the div elements whose name begins with
// 'front_page' to be invisible
/*
for (var i=0;i<x.length;i++)
{

if(x[i].id.substring(0,10) == 'front_page')
	{
	x[i].className = 'dynamic_div_invisible';
	}
}
*/

// now set the one div element we want to be visible
// to belong to the visible class
document.getElementById(name_of_div).className='dynamic_div_invisible';

// now set the all the "header_cell" table cells to a normal background color
//
for (var i=0;i<y.length;i++)
{
if(y[i].id.substring(0,9) == 'head_cell')
	{
	y[i].className = '';
	}
}

// finally we set the header cell that is selected to have a different
// background colour
// NB we get the number of the header cell we need by taking the last character
// from the element in name of div

var z = document.getElementById(name_of_div).id.charAt(10);
var selected_td = 'head_cell' + z;
document.getElementById(selected_td).className = 'selected';

}

function highlightNavigationCells(state) {
// this function is used to highlight and de-highlight the navigation cells
// of the dynamic front page table. If 'state' is true, it switches
// highlighting on. If 'state' is false, it switches the highlighting on.
// Since we only want the highlighting accessible from the front page, i.e.
// the page when the first table cell "What I offer" is the only one 
// highlighted, we can simply highlight all the cells and then return to a fixed 
// state.

var name_prefix = 'head_cell';
if(state == 'true')
{
	for(var i = 0; i<=7; i++)
		{	
			if(document.getElementById(name_prefix + i))
			{
			document.getElementById(name_prefix + i).className = 'highlighted';
		}
		}

// now we show the detailed instructions
	document.getElementById('instructions_for_front_page').className='show';

} else {
	
	document.getElementById('head_cell1').className = 'selected';
	
	for (var i = 1; i<=7; i++)
		{
			if(document.getElementById(name_prefix + i))
			{
			document.getElementById(name_prefix + i).className = '';
		}
		}
		
		// now we hide the detailed instructions
	document.getElementById('instructions_for_front_page').className='hide';
}}



function soth_show_instructions () {
	
	if(document.getElementById('instructions_for_front_page'))
	{
	
	highlightNavigationCells('true');	
	
	document.getElementById('instructions_for_front_page').className="visible";
	
	
	
	setTimeout("highlightNavigationCells('false')",3000);	
	setTimeout("document.getElementById('instructions_for_front_page').className=''",3000);
		
	
}
}
