var currentMessage = 0;
var siteMessages = new Array("Trusted resource for business leaders who are serious about results.", "20 Years of proven results with leading brands everywhere.", "No hype. Just result-driven insights and strategies that work. ", "No hard-sell. If I can't guarantee to meet your expectations,<br />I won't take your booking.", "This website is guaranteed hype-free.<br />So, what you see really is what you get.");

var currentSmallPhoto = Math.floor(Math.random()*3);
var imageSmallArray = new Array("page_banner_1.png","page_banner_2.png","page_banner_3.png");

var clientArray = new Array ("3M","Absa","adcock","African Alliance","Aida","AlexanderForbes","Anglo","Avroy","Barrick","Bayer","Bernina","Bidvest","BOE","DBSA","Defy","Deloitte","DRG gold","Duracell","Eskom","firstUranium","FNB","GoldFields","Grinaker","Implats","Jil","Joburg","JohnDeere","Joy","KFC","LibertyLife","logo_holdings","McCarthy","MDRT","MercedesBenz","metcash","Metropolitan","Mittal","Momentum","MTN","Mugg&Bean","Multiserv","Nedbank","NMMU","Old Mutual","pannar_logo","Pep","Pfizer","PG Bison","Pick n Pay","RCMA","Reebok","Regus","SAA","SABC","Santam","SAPS","Senwes","SouthernSun","Sportron","Standard Bank","TileAfrica","Timbercity","Tsogo Sun","UJ","Wesbank","Xstrata");

function clear_menu()
{
	document.getElementById("dropdown_1").style.display="none";			
	document.getElementById("dropdown_2").style.display="none";			
	document.getElementById("dropdown_3").style.display="none";			
	document.getElementById("dropdown_4").style.display="none";			
	document.getElementById("dropdown_5").style.display="none";			
	document.getElementById("dropdown_6").style.display="none";			
}

function select_menu(menu, flag)
{	
	if (flag==1)	{
		menu.style.backgroundImage='url(images/template/menu_arrow.png)';
		menu.style.backgroundRepeat='no-repeat';
		menu.style.backgroundPosition='bottom';
		menu.style.color='#b2a98b';
	
		document.getElementById("dropdown_1").style.display="none";			
		document.getElementById("dropdown_2").style.display="none";			
		document.getElementById("dropdown_3").style.display="none";			
		document.getElementById("dropdown_4").style.display="none";			
		document.getElementById("dropdown_5").style.display="none";			
		document.getElementById("dropdown_6").style.display="none";			
	
		if (menu.getAttribute('id')=="1")
			document.getElementById("dropdown_1").style.display="block";			
		if (menu.getAttribute('id')=="2")
			document.getElementById("dropdown_2").style.display="block";			
		if (menu.getAttribute('id')=="3")
			document.getElementById("dropdown_3").style.display="block";			
		if (menu.getAttribute('id')=="4")
			document.getElementById("dropdown_4").style.display="block";			
		if (menu.getAttribute('id')=="5")
			document.getElementById("dropdown_5").style.display="block";			
		if (menu.getAttribute('id')=="6")
			document.getElementById("dropdown_6").style.display="block";			

	}	else	{
		menu.style.backgroundImage='none';
		menu.style.color='#FFF';
	}			
}

function hide_menu(menu)
{
	menu.style.display="none";
}

var currentPhoto = 0;
var secondPhoto = 1;

var currentOpacity = new Array();
var imageArray = new Array("banner_1.png","banner_2.png", "banner_3.png");

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.stefduplessis.com/images/logos/"+clientArray[currentClient]+".jpg')";
	f.style.backgroundPosition="center 40%";
	f.style.backgroundRepeat ="no-repeat";

	cSInterval = setInterval("cycleClient()",8000);
}

function init_2client()
{
	
	var currentClient = Math.floor(Math.random()*clientArray.length);
	var f = document.getElementById("endorsement_container");

	f.style.backgroundImage="url('http://www.stefduplessis.com/images/logos/"+clientArray[currentClient]+".jpg')";
	f.style.backgroundPosition="center 40%";
	f.style.backgroundRepeat ="no-repeat";

	//cSInterval = setInterval("cycle2Client()",8000);
}

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=\"/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>4)
		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.stefduplessis.com/images/logos/"+clientArray[currentClient]+".jpg')";
	f.style.backgroundPosition="center 40%";
	f.style.backgroundRepeat ="no-repeat";
}

function cycle2Client() 
{
	var currentClient = Math.floor(Math.random()*clientArray.length);
	var f = document.getElementById("endorsement_container");

	f.style.backgroundImage="url('http://www.stefduplessis.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);
}


