/**
 * Show a blocklevel element
 * @param string div Name of ID of the document element to show
 * @return void
 */
function showDiv(div)
{
	try
	{
		document.getElementById(div).style.visibility = "visible";
		document.getElementById(div).style.display    = "block";
	}
	catch(err)
	{
		//Handle errors here
	}
}

/**
 * Hide a blocklevel element
 * @param string div Name of ID of the document element to hide
 * @return void
 */
function hideDiv(div)
{
	try
	{
		document.getElementById(div).style.visibility = "hidden";
		document.getElementById(div).style.display    = "none";
	}
	catch(err)
	{
		//Handle errors here
	}
}

function showThrobber()
{
	showDiv("throbber",'iframeFixIE6ForThrobber');
}

function hideThrobber()
{
	closeDiv("throbber",'iframeFixIE6ForThrobber');
}


// Define variables
var offsetxpoint=-70 //Customize x offset of tooltip
var offsetypoint=-120 //Customize y offset of tooltip
var enabletooltip=false // Tooltips are disabled until page loads
var posx = 0;
var posy = 0;

/* works with IE 4+, NS4, NS6 and other Gecko, OmniWeb, Opera (4) 5+,
iCab, IceBrowser, Esape 4, HotJava 3, Konqueror and, as long as they
follow the standards, loads more */

function mouseTrack(e)
{
	if (!e) var e = window.event;
	if (e.pageX || e.pageY)
	{
		posx = e.pageX;
		posy = e.pageY;
	}
	else if (e.clientX || e.clientY)
	{
		posx = e.clientX + document.body.scrollLeft;
		posy = e.clientY + document.body.scrollTop;
	}
	posx = posx + offsetxpoint;
	posy = posy + offsetypoint;	
	if (enabletooltip==true)
	{
		document.getElementById("tooltip").style.left = posx+"px";
		document.getElementById("tooltip").style.top = posy+"px";
		
		document.getElementById("tooltip2").style.left = posx+"px";
		document.getElementById("tooltip2").style.top = posy+"px";
	}
}

var tooltipID = null;
		
function showTooltip(message)
{
	if (enabletooltip == true)
	{
		if (tooltipID != null)
		{
			clearTimeout(tooltipID);
			tooltipID = null;
		}
		showDiv("tooltip")
		document.getElementById("tooltip").innerHTML = message;
		// tooltipID = setTimeout("tooltipID=null;hideDiv('tooltip');",7000);
	}
}
function hideTooltip()
{
	if (enabletooltip == true)
	{
		hideDiv("tooltip")
	}
}

function initaliseTooltip()
{
		enabletooltip=true;
		var elm = document.createElement("div");
		elm.innerHTML="";
		elm.id = "tooltip"
		elm.className="tooltip";
		document.body.appendChild(elm);
		hideDiv("tooltip")
		if (document.layers) document.captureEvents(Event.MOUSEMOVE);
		document.onmousemove=mouseTrack;
}


var tooltipID2 = null;
function showTooltip2(message)
{
	if (enabletooltip == true)
	{
		if (tooltipID2 != null)
		{
			clearTimeout(tooltipID2);
			tooltipID2 = null;
		}
		showDiv("tooltip2")
		document.getElementById("tooltip2").innerHTML = message;
		// tooltipID = setTimeout("tooltipID=null;hideDiv('tooltip');",7000);
	}
}
function hideTooltip2()
{
	if (enabletooltip == true)
	{
		hideDiv("tooltip2")
	}
}

function initaliseTooltip2()
{
		enabletooltip=true;
		var elm = document.createElement("div");
		elm.innerHTML="";
		elm.id = "tooltip2"
		elm.className="tooltip2";
		document.body.appendChild(elm);
		hideDiv("tooltip2")
		if (document.layers) document.captureEvents(Event.MOUSEMOVE);
		document.onmousemove=mouseTrack;
}





function switchPeople(mode)
{
	//alert(mode)
	switch(mode)
		{
			case 1:
				showDiv("clientContent");
				hideDiv("fieldContent");
				hideDiv("officeContent");
				
				
				document.getElementById("clientL").src = "images/links/clientsa.png";
				document.getElementById("fieldL").src = "images/links/field.png";
				document.getElementById("officeL").src = "images/links/office.png";
				//alert(1)
			  break;
			case 2:
				showDiv("fieldContent");
				hideDiv("clientContent");
				hideDiv("officeContent");
				
				
				document.getElementById("clientL").src = "images/links/clients.png";
				document.getElementById("fieldL").src = "images/links/fielda.png";
				document.getElementById("officeL").src = "images/links/office.png";
				//alert(2)
			  break;
			case 3:
				showDiv("officeContent");
				hideDiv("clientContent");
				hideDiv("fieldContent");
				
				
				document.getElementById("clientL").src = "images/links/clients.png";
				document.getElementById("fieldL").src = "images/links/field.png";
				document.getElementById("officeL").src = "images/links/officea.png";
				//alert(3)
			  break;
			
			default:
				showDiv("clientContent");
				hideDiv("fieldContent");
				hideDiv("officeContent");
		}
}

function moveon(type)
{
	var d = document.getElementById('switcher').value;
	
	if(type=='left')
	{
		switch(d)
		{
			case '0':
				document.getElementById('switcher').value = 2;
				document.getElementById('jobsimg').src = "images/jobs/job3.gif";
			  break;
			case '1':
				document.getElementById('switcher').value = 0;
				document.getElementById('jobsimg').src = "images/jobs/job1.gif";
			  break;
			case '2':
				document.getElementById('switcher').value = 1;
				document.getElementById('jobsimg').src = "images/jobs/job2.gif";
			  break;
		}
	}
	else
	{
		switch(d)
		{
			case '0':
				document.getElementById('switcher').value = 1;
				document.getElementById('jobsimg').src = "images/jobs/job2.gif";
				
			  break;
			case '1':
				document.getElementById('switcher').value = 2;
				document.getElementById('jobsimg').src = "images/jobs/job3.gif";
			  break;
			case '2':
				document.getElementById('switcher').value = 0;
				document.getElementById('jobsimg').src = "images/jobs/job1.gif";
			  break;
		}
	}
}


function changeAward(year)
{
	
	switch (year)
	{
		case '2009':
				showDiv('n_2009');
				hideDiv('n_2008');
		//		hideDiv('2007');
				
				document.getElementById('t_2009').className = "Aon"
				document.getElementById('t_2008').className = "Aoff"
		//		document.getElementById('2007_t').className = ""
				
			break;
			
		case '2008':
				showDiv('n_2008');
				hideDiv('n_2009');
		//		hideDiv('2007');
				
				document.getElementById('t_2008').className = "Aon"
				document.getElementById('t_2009').className = "Aoff"
		//		document.getElementById('2007_t').className = ""
			break;
			
		case '2007':
				showDiv('2007');
				hideDiv('2008');
				hideDiv('2009');
				
				document.getElementById('2007_t').className = "Aon"
				document.getElementById('2008_t').className = "Aoff"
				document.getElementById('2009_t').className = ""
			break;
	}
	

	
}


function CreateRequestObject()
{
	var xrequest = false;
	try 
	{
		xrequest = new XMLHttpRequest();
	} 
	catch (trymicrosoft) 		
	{	
		try
		{
			xrequest = new ActiveXObject("Msxml2.XMLHTTP");	
		}	 
		catch (othermicrosoft) 		
		{
			try
			{
				xrequest = new ActiveXObject("Microsoft.XMLHTTP");
			} 
			catch (failed) 	
			{
				xrequest = false;
			}
		}
	}
	return xrequest;
}

/**
 * Check if a string contains another string
 * @param string needle Substring to search for
 * @param string haystack String to search in
 * @return boolean <ul><li>TRUE if needle in haystack</li><li>FALSE if not</li></ul>
 */
function instr(needle,haystack)
{

	if (haystack.indexOf(needle) == -1)
	{
		return false;
	}
	else
	{
		return true;
	}
}


function randomiseURL(url)
{
	var d = new Date();
	if( instr("?",url) == true )
	{
		url += "&random=" + d.valueOf();
	}
	else
	{
		url += "?random=" + d.valueOf();
	}
	return url;
}

/*
* doAJAX accepts 2 parameters
* ajaxURL is the URL of the file to be called by the http request (REQUIRED)
* targetDiv is the html element that the http response will be placed into (REQUIRED)
* callback is the name of the javascript function to be called when the http request is complete (OPTIONAL)
*/
function doAJAX(ajaxURL,targetDiv,callback,divToShow)
{
	if (typeof(divToShow) == 'undefined')
	{
		divToShow == null;
	}
	// Create a new HTTP Request object
	showThrobber();
	var http = CreateRequestObject(); 
	
	// Append a random argument to the URL to avoid browser caching issues
	var d = new Date();
	//ajaxURL += "&random=" + d.valueOf();
	
	ajaxURL = randomiseURL(ajaxURL);
	
	// Open the http request object using 'get' to the ajaxURL
	http.open('get', ajaxURL);
	
	// Define a function to call when an Http response is received	
	http.onreadystatechange = function()
			{
				/*var today=new Date()
				var h=today.getHours()
				var m=today.getMinutes()
				var s=today.getSeconds()
				document.title = h + ":" + m + ":" + s + "  Ready State = " + http.readyState + new Date();*/
				if (http.readyState == 4)
				{
					//alert(http.responseText);
					//document.title += ", Status = " + http.status
					try
					{
						if (http.status != 200)
						{
							//  http request fails
							// -- ADD ERROR TRAPPING --
							document.getElementById(targetDiv).innerHTML = "Failed to download";
							hideThrobber();
						}
						else
						{
							// Http request succeeds
							//alert('@'+http.responseText)
							document.getElementById(targetDiv).innerHTML = http.responseText;
							if ( (callback != "null") || (callback == '') )
							{
								
								//debug2("Callback = " + callback);
								eval(callback);
							}
							
							if (divToShow != null)
							{
								showDiv(divToShow);
							}
							hideThrobber();
						}
					}
					catch(e)
					{
						alert("An Error Happened");
					}
				}
			}
	//debug2(ajaxURL);
	// Send the http data (null using 'get') 
	http.send(null);
	
	
	document.getElementById(targetDiv).style.visibility = "visible";
	document.getElementById(targetDiv).style.display = "block";
}