var currentMessage = 0;
var siteMessages = new Array("Speaker at conferences across the globe<br>Unique and practical insights into organisational culture", "Creator of the concept of UGRs<br> A tool to understand and boost culture", "Unique and practical insights into customer service<br> through Steve's 'Discretionary Service' concept", "No hype.<br> Just result-driven insights and strategies that work. ");

var currentSmallPhoto = Math.floor(Math.random()*2);
var imageSmallArray = new Array("page_1.jpg", "page_2.jpg");

var clientArray = new Array ("Barrick","Bayer","GoldFields","KFC", "ACE","ACHSM","AIM","AHRI","post","cipd","combank","dover","gartner","gmac","hdi","home","jhi","kmart","knauf","latrobe","legalgeneral","lexus","lion","nab","nie","northwest","royalyatch","rbs","socap","toyota","lego","optus","airport","ceo","rend","alcoa","rcsa","stgeorge","williams","zurich");

function clear_menu()
{
	$("#dropdown_1").stop().animate({	opacity: 0}, 250);
}

function select_menu(menu, flag)
{	
	if (flag==1)	{
		menu.style.backgroundImage='url(http://www.steve-simpson.com/images/template/menu_arrow.png)';
		menu.style.backgroundRepeat='no-repeat';
		menu.style.backgroundPosition='bottom';
		
		if (menu.childNodes[2].innerHTML!='')
			$("#dropdown_"+menu.getAttribute('id')).stop().show().animate({	opacity: 1}, 250);

	}	else	{
		menu.style.backgroundImage='none';
		$("#dropdown_"+menu.getAttribute('id')).stop().animate({	opacity: 0}, 250, function () {
			$("#dropdown_"+menu.getAttribute('id')).hide();
		});
	}			
}

function hide_menu(menu)
{
	$(menu).stop().animate({	opacity: 0}, 250).hide();
	//menu.style.display="none";
}

var currentPhoto = 0;
var secondPhoto = 1;

var currentOpacity = new Array();
var imageArray = new Array("banner_1.jpg", "banner_2.jpg");

var FADE_STEP = 2;
var FADE_INTERVAL = 40;
var pause = false;

function next()	{
	mInterval = setInterval("crossFade()",FADE_INTERVAL);
}

function init_client()
{
	/*
	
	
	var h = document.getElementById('page_title');
	if (returnDocument() == "auto-planners.html")		{
		h.style.backgroundImage="url(/images/template/h1.png)";
		h.style.paddingLeft="30px";
		h.style.backgroundRepeat="no-repeat";
		h.style.backgroundPosition="5px center";
	} else 	if (returnDocument() == "bottom_line.html")		{ 
		h.style.backgroundImage="url(/images/template/h2.png)";
		h.style.paddingLeft="30px";
		h.style.backgroundRepeat="no-repeat";
		h.style.backgroundPosition="5px center";
	} else 	if (returnDocument() == "full_disclosure.html")		{ 
		h.style.backgroundImage="url(/images/template/h3.png)";
		h.style.paddingLeft="30px";
		h.style.backgroundRepeat="no-repeat";
		h.style.backgroundPosition="5px center";
	} else 	if (returnDocument() == "lost.html")		{ 
		h.style.backgroundImage="url(/images/template/h4.png)";
		h.style.paddingLeft="30px";
		h.style.backgroundRepeat="no-repeat";
		h.style.backgroundPosition="5px center";
	}
	*/
	
	var currentClient = Math.floor(Math.random()*clientArray.length);
	var f = document.getElementById("site_endorsement");

	f.style.backgroundImage="url('http://www.steve-simpson.com/images/logos/"+clientArray[currentClient]+".jpg')";
	f.style.backgroundPosition="center 40%";
	f.style.backgroundRepeat ="no-repeat";

	cSInterval = setInterval("cycleClient()",8000);
	
	//	Insert the site copy template bottom image
	var bot = document.getElementById("copy_bottom");
	
	if (document.getElementById("site_copy"))
	{
		insertAfter(bot, document.getElementById("site_copy"));
		bot.style.display='block';
	}

}

function init_banner() {
	
	currentOpacity[0]=99;
	mHTML="";
	
	for(i=1;i<imageArray.length;i++)
		currentOpacity[i]=0;
	
	for(i=0;i<imageArray.length;i++)
		mHTML += "<img id=\"photo\" name=\"photo\" class=\"mPhoto\" src=\"http://www.steve-simpson.com/images/template/" + imageArray[i]  +"\" />";
	
	document.getElementById("site_banner").innerHTML = mHTML;
	document.getElementById("site_small").innerHTML = siteMessages[currentMessage];

	if(document.all) 
		document.getElementsByName("photo")[currentPhoto].style.filter = "alpha(opacity=99)";
	 else 
		document.getElementsByName("photo")[currentPhoto].style.opacity = "0.99";

	nextT = setTimeout("next()",12000);
	mSInterval = setInterval("cycleMessage()",6000);
}

function cycleMessage() {
	currentMessage++;
	if (currentMessage>3)
		currentMessage=0;
	
	document.getElementById("site_small").innerHTML = siteMessages[currentMessage];
}

function cycleClient() 
{
	var currentClient = Math.floor(Math.random()*clientArray.length);
	var f = document.getElementById("site_endorsement");

	f.style.backgroundImage="url('http://www.steve-simpson.com/images/logos/"+clientArray[currentClient]+".jpg')";
	f.style.backgroundPosition="center 40%";
	f.style.backgroundRepeat ="no-repeat";
}

function crossFade() {
	if(pause)return;

	currentOpacity[currentPhoto]-=FADE_STEP;
	currentOpacity[secondPhoto] += FADE_STEP;

	if(document.all) {
		document.getElementsByName("photo")[currentPhoto].style.filter = "alpha(opacity=" + currentOpacity[currentPhoto] + ")";
		document.getElementsByName("photo")[secondPhoto].style.filter = "alpha(opacity=" + currentOpacity[secondPhoto] + ")";
	} else {
		document.getElementsByName("photo")[currentPhoto].style.opacity = currentOpacity[currentPhoto]/100;
		document.getElementsByName("photo")[secondPhoto].style.opacity =currentOpacity[secondPhoto]/100;
	}

	if(currentOpacity[secondPhoto]/100>=0.98) {
		currentPhoto = secondPhoto;
		secondPhoto++;
		if(secondPhoto == imageArray.length)secondPhoto=0;
		pause = true;
		xInterval = setTimeout("pause=false",12000);
	}
}

function overPic(index, flag)
{
	var optionArray = new Array("bomb", "stopclock", "microscope", "signpost");
	var option = document.getElementById('option_'+index);
	var option_over = document.getElementById('option_'+index+'_over');
	if (flag==1)
	{
		option.style.display='none';
		option_over.style.display='block';
	}
	else
	{
		option_over.style.display='none';
		option.style.display='block';
	}
}

function returnDocument() {
	var file_name = document.location.href;
	var end = (file_name.indexOf("?") == -1) ? file_name.length : file_name.indexOf("?");
	return file_name.substring(file_name.lastIndexOf("/")+1);
}

function select_one(flag)
{
	if (flag==1)
	{
		document.getElementById("td_one").style.color="#212222";
		document.getElementById("header_one").style.color="#212222";
		document.getElementById("hover_one").src="http://www.steve-simpson.com/images/template/folder_1.png";
	}
	else
	{
		document.getElementById("td_one").style.color="#FFF";
		document.getElementById("header_one").style.color="#FFF";
		document.getElementById("hover_one").src="http://www.steve-simpson.com/images/template/folder.png";
	}
	
}

function select_two(flag)
{
	if (flag==1)
	{
		document.getElementById("td_two").style.color="#212222";
		document.getElementById("header_two").style.color="#212222";
		document.getElementById("hover_two").src="http://www.steve-simpson.com/images/template/faces_1.png";
	}
	else
	{
		document.getElementById("td_two").style.color="#FFF";
		document.getElementById("header_two").style.color="#FFF";
		document.getElementById("hover_two").src="http://www.steve-simpson.com/images/template/faces.png";
	}
	
}

