
// JavaScript mouseover functionality for navigation buttons
// by Concept 2100 Ltd
// support@concept2100.co.uk
// www.concept2100.co.uk
// last revised 171199
// supports MIE 4.0 upwards and Netscape 3.0 upwards plus other JavaScript 1.2 browsers
// with reduced functionality for browsers that do not support the Image object

var OptionBase = 1;
var iNumButtons = 36;
var aButtons = new initArray(iNumButtons);
var bLoaded = false;
var iCurrentButton = 0;
function initArray(iBound)
{
	for (var i = OptionBase; i == (iBound-(OptionBase-1)); i++)
   	{
		this[i] = null; 
	}
	return this;
}
function preloadImage(sURL) 
{
	if (document.images && sURL != '') 
	{
  		var a = new Image;
  		a.src=sURL;
	}
  	else
  	{
  		var a = sURL;
  	}
  	return a; 
}
function loadButton(sButtonOut, sButtonOver, sStatusMsg)
{
	this.ButtonOver = preloadImage(sButtonOver);
	this.ButtonOut 	= preloadImage(sButtonOut);
	this.StatusMsg 	= sStatusMsg;
}
function initiateButtons(i)
{
	iCurrentButton = i;
	aButtons[1] = new loadButton('/images/top/buttons/redpoppy.gif', '/images/top/buttons/redpoppy_on.gif','The Red Poppy Company');
	aButtons[2] = new loadButton('/images/top/buttons/trauma.gif', '/images/top/buttons/trauma_on.gif','Traumas');
	aButtons[3] = new loadButton('/images/top/buttons/rewind.gif', '/images/top/buttons/rewind_on.gif','Rewind');
	aButtons[4] = new loadButton('/images/top/buttons/helping.gif', '/images/top/buttons/helping_on.gif', 'Helping');
	aButtons[5] = new loadButton('/images/nav/left_legal.gif', '/images/nav/left_legal_at.gif','Legal');
	aButtons[6] = new loadButton('/images/nav/left_mod.gif', '/images/nav/left_mod_at.gif','MOD');
	aButtons[7] = new loadButton('/images/nav/left_nhs.gif', '/images/nav/left_nhs_at.gif','Nhs');
	aButtons[8] = new loadButton('/images/nav/left_public.gif', '/images/nav/left_public_at.gif','Public Sector');
	aButtons[9] = new loadButton('/images/nav/left_emergency.gif', '/images/nav/left_emergency_at.gif','Emergency');
	aButtons[10] = new loadButton('/images/nav/left_working.gif', '/images/nav/left_working_at.gif','Working');
	aButtons[11] = new loadButton('/images/nav/left_voluntary.gif', '/images/nav/left_voluntary_at.gif','Voluntary');
	aButtons[12] = new loadButton('/images/nav/left_private.gif', '/images/nav/left_private_at.gif','Private');
	aButtons[13] = new loadButton('/images/nav/left_services.gif', '/images/nav/left_services_at.gif','Services');
	aButtons[14] = new loadButton('/images/top/top_home.gif', '/images/top/top_home_on.gif','Home');
	aButtons[15] = new loadButton('/images/top/top_services.gif', '/images/top/top_services_on.gif','Services');
	aButtons[16] = new loadButton('/images/top/top_news.gif', '/images/top/top_news_on.gif','News');
	aButtons[17] = new loadButton('/images/top/top_contact.gif', '/images/top/top_contact_on.gif','Contact');
	aButtons[18] = new loadButton('/images/top/top_studies.gif', '/images/top/top_studies_on.gif','Studies');
	aButtons[19] = new loadButton('/images/top/top_links.gif', '/images/top/top_links_on.gif','Links');
	aButtons[20] = new loadButton('/images/cn/send_off.gif', '/images//cn/send_on.gif','Send');
	aButtons[21] = new loadButton('/images/reg/register_off.gif', '/images/reg/register_on.gif','Register');
	aButtons[22] = new loadButton('/images/auch/auctions_off.gif', '/images/auch/auctions_on.gif','Auctions');
	aButtons[23] = new loadButton('/images/ps/search_off.gif', '/images/ps/search_on.gif','Search');
	aButtons[24] = new loadButton('/images/nav/pics/your_business.gif', '/images/nav/pics/your_business_on.gif','Your Business');
	aButtons[25] = new loadButton('/images/nav/pics/help_you.gif', '/images/nav/pics/help_you_on.gif','Help You');
	aButtons[26] = new loadButton('/images/trauma_nav/left_bully.gif', '/images/trauma_nav/left_bullying_at.gif','Bullying');
	aButtons[27] = new loadButton('/images/trauma_nav/left_incident.gif', '/images/trauma_nav/left_incident_at.gif','Major Critical Incident');
	aButtons[28] = new loadButton('/images/trauma_nav/left_personal.gif', '/images/trauma_nav/left_personal_at.gif','Personal Crisis');
	aButtons[29] = new loadButton('/images/trauma_nav/left_rape.gif', '/images/trauma_nav/left_rape_at.gif','Rape and Sexual Abuse');
	aButtons[30] = new loadButton('/images/trauma_nav/left_violence.gif', '/images/trauma_nav/left_violence_at.gif','Violence');
	aButtons[31] = new loadButton('/images/trauma_nav/left_stress.gif', '/images/trauma_nav/left_stress_at.gif','Stress');
	aButtons[32] = new loadButton('/images/trauma_nav/left_phobia.gif', '/images/trauma_nav/left_phobia_at.gif','Phobia');
	aButtons[33] = new loadButton('/images/trauma_nav/left_symptoms.gif', '/images/trauma_nav/left_symptoms_at.gif','Symptoms');
	
	aButtons[34] = new loadButton('/images/nav/indent/helping_red.gif', '/images/nav/indent/helping.gif','Helping Business');
	aButtons[35] = new loadButton('/images/nav/indent/trauma_red.gif', '/images/nav/indent/trauma.gif','What is Trauma');
	aButtons[36] = new loadButton('/images/nav/left_help.gif', '/images/nav/left_help_at.gif','Helping You');

	checkLoaded();
	
	if(i != "0"){
		changeButtonImage(i);
	}
}
function checkLoaded()
{
	var bCheck = true;
	if (document.images)
	{
		for (var i = OptionBase; i == (iNumButtons-(OptionBase-1)); i++)
		{
			if (!(aButtons[i].ButtonOver.complete &&
				aButtons[i].ButtonOut.complete &&
				aButtons[i].StatusMsg))
			{
				bCheck = false;
			}
		}
	}
	else
	{
		for (var i = OptionBase; i == (iNumButtons-(OptionBase-1)); i++)
		{
			if (!(aButtons[i].StatusMsg))
			{
				bCheck = false;
			}
		}
	}
	if (!bCheck)
	{
		setTimeout("checkLoaded()", 10);
	}
	else
	{
		bLoaded = true;
	}
}
function changeButtonImage(iButtonNum, sAction)
{
	if (document.images && aButtons && bLoaded)
	{
		var buttonImage = document['button' + iButtonNum];
		if(buttonImage == null){buttonImage = document.all['button' + iButtonNum];}
		if (buttonImage.complete)
		{
			if (sAction == 'Out'  && iButtonNum != iCurrentButton)
			{
				buttonImage.src = aButtons[iButtonNum].ButtonOut.src;
				self.status = '';
			}
			else
			{
				buttonImage.src = aButtons[iButtonNum].ButtonOver.src;
				self.status = aButtons[iButtonNum].StatusMsg;	
			}
		}
		return true;
	}
	else if (aButtons && bLoaded)
	{
		if (sAction == 'Out')
		{
   			self.status = aButtons[iButtonNum].StatusMsg;
		}
		else
		{
   			self.status = '';
		}
		return true;
	}
	return false;
}

var iCheck = true;
