// Global variables to determine the users position in the site
var mainSection;	// Top level position on main navigation
var subSection;		// Position with in the second level navigation	
	
var imagePath = 'images/topnav/';
var leftImagePath = 'flash/img/';
var leftMainImageAlts = new Array (new Array('home', 'Image of a woman looking over products on a shelf'), 
								   new Array('abouteyc', 'Image of products in a shopping basket'), 
								   new Array('abouteyc_values', 'Image of a shopping trolley'), 
   								   new Array('abouteyc_recruitment', 'Image of a person selecting paint swatches'), 
   								   new Array('abouteyc_recruitment_together', 'Image of a woman and girl choosing sweets'), 	
   								   new Array('abouteyc_recruitment_recruiters', 'Image of a woman and her laptop screen'), 								   							   
								   new Array('ourwork', 'Image of a trolley and shopper'), 
								   new Array('ourwork_planning', 'Image of online shopping'), 
								   new Array('ourwork_planning_growth', 'Image of a girl choosing cereal on a shelf'),	
								   new Array('ourwork_planning_assessment', 'Image of a man calculating prices in an aisle'),
								   new Array('ourwork_planning_investment', 'Image of a man with a PDA in an aisle'),
								   new Array('ourwork_value', 'Image of women looking at the deli counter'), 
								   new Array('ourwork_value_pricing', 'Image of a shopping receipt'), 
								   new Array('ourwork_value_efficient', 'Image of fish for sale'), 	
								   new Array('ourwork_value_primotion', 'Image of a person selecting produce off a shelf'),
								   new Array('ourwork_value_marketing', 'Image of a woman selecting an apple'),	
								   new Array('ourwork_insight', 'Image of a child in a trolley'), 		
								   new Array('ourwork_insight_segmentation', 'Image of coat hangers'), 	
								   new Array('ourwork_insight_substitution', 'Image of apples in the produce aisle'), 
								   new Array('ourwork_insight_trees', 'Image of a woman looking at products on the shelves'),
								   new Array('ourwork_choices', 'Image of a man and boy in an aisle'),
								   new Array('ourwork_choices_rightplace', 'Image of milk in a fridge'),	
								   new Array('ourwork_choices_availability', 'Image of bread in the bakery'),
								   new Array('ourwork_choices_positioning', 'Image of a woman selecting a carton of milk'), // This image is the same as 'ourwork', new image TBD	
								   new Array('ourwork_choices_development', 'Image of cans of food'),	
								   new Array('ourwork_infrastructure', 'Image of shopping trolleys'),
								   new Array('ourwork_infrastructure_management', 'Image of shop sales results'),	
								   new Array('ourwork_infrastructure_metrics', 'Image of a red pepper on scales'),	
								   new Array('ourwork_infrastructure_clustering', 'Image of stacked shopping baskets'),
								   new Array('ourwork_infrastructure_architecture', 'Image of network cables'),	
								   new Array('ourwork_infrastructure_collaboration', 'Image of two people looking over sales figures'),									   
								   new Array('ourpeople', 'Image of a boardroom meeting'), 
								   new Array('ourpeople_dublin', 'Image of a boardroom meeting'), 
								   new Array('ourpeople_richmond', 'Image of a boardroom meeting'), 
							   	   new Array('ourpeople_dosanjh', 'Has Dosanjh'), 
								   new Array('ourpeople_coy', 'Adrian Coy'), 
								   new Array('ourpeople_patel', 'Jateen Patel'), 
								   new Array('ourpeople_vegting', 'Penny Vegting'), 
								   new Array('ourpeople_cole', 'Withiel Cole'), 
								   new Array('ourpeople_haughan', 'Craig Haughan'),	
								   new Array('ourpeople_dunn', 'Nick Dunn'),	
								   new Array('ourpeople_jheeta', 'Jagpal Jheeta'),	
								   new Array('ourpeople_cohn', 'Howard Cohn'),	
								   new Array('ourpeople_mcneill', 'Bruce McNeill'), 
								   new Array('ourpeople_massey', 'Simon Massey'), 
								   new Array('contact', 'Image of a man and boy shopping for fruit'), 
								   new Array('contact_inforequest', 'Image of a car park trolley sign'), 
								   new Array('ourclients', ''), 
								   new Array('login', 'Image of a card in a POS machine')
								  );

<!-- javascript code for our people -->
var me; //represents the SWF id
//get the correct reference
function getIDtoFlash(swfID) {
   if (navigator.appName.indexOf("Microsoft") > -1) {
	  me = window[swfID];
   } else {
	  me = document[swfID];
   }
}
//this will call the onChange event back in Flash
function loadFlashImage(jpg, swf){
	//alert('loadFlashImage(' + jpg + ', ' + swf + ')');
	me.loadImage(jpg, swf);
}

function initialiseHTML()
{
	loadMainFrame('home');	
	getIDtoFlash('flashImages');
	calculateGMT();		
}

// Main function called from the Flash nav using XML
function loadMainFrame(section)
{	
	var prevMainSection;
	
	// Set the level of the navigation	
	var navSection = section.split("_");
	
	if(mainSection == null && navSection[0] == 'ourwork') prevMainSection = navSection[0];
	else prevMainSection = mainSection;
	
	mainSection = navSection[0];
	subSection = navSection[1];	
	
	clearPage(); // Clear the content area	
	changeMainContent(section); // Load the HTML page into the iFrame

	// Set the left hand image and alt tag for the flash alternative
	setLeftHTML(section, prevMainSection, mainSection);	
	
	//loadFlashImage(section + '.jpg', 'flash/' + mainSection + '.swf');
	
	// Replace the if statement below with this one once the new images have been added
	if(subSection != null || section == 'abouteyc' || section == 'ourwork')
	{
		loadFlashImage(section + '.jpg', 'flash/' + mainSection + '.swf');
	}
}

// Clear the iFrames on the main.html template
function clearPage()
{
	changeMainContent('blank');	
}

// Load in iFrames on the main.html template
function changeMainContent(toLoad)
{
	parent.rightCopy.location.href = 'frame_' + toLoad + '.html';
}

function getCurrentSection()
{
	return mainSection;
}

function resetHTMLNav(prevSection)
{
	var topNavImageUp = getElement(prevSection + 'Link');
	if(topNavImageUp) topNavImageUp.src = imagePath + prevSection + '.gif';	
}

function setHTMLImages()
{	
	// Set the needed top nav image to down	
	var topNavImageDown = getElement(mainSection + 'Link');
	if(topNavImageDown)	topNavImageDown.src = imagePath + mainSection + '_down.gif';
}

function setLeftHTML(section, prevMainSection, mainSection)
{		
	var image = getElement('mainImage');	
	
	if(image)
	{
		image.src = leftImagePath + section + '.jpg'; // Set the image source
			
		// Set the alt tag
		for(i = 0; i < leftMainImageAlts.length; i++)
		{
			if(leftMainImageAlts[i][0] == section)
			{
				image.alt = leftMainImageAlts[i][1];
				image.title = leftMainImageAlts[i][1];
			}
		}	
	}
	
	if(prevMainSection != mainSection && prevMainSection != null) resetHTMLNav(prevMainSection); // Set the previous section image to up
	setHTMLImages(); // Set the HTML images	
}

function popUp(href)
{
	var rand = 'window' + Math.floor(Math.random()*9999999999);
	var newWin = window.open(href, rand, 'width=537,height=500,titlebar=no,scrollbars=yes');
	newWin.focus();
	return false;	
}
