/**
* Approach Method Page JavaScript Definitions
*
* @author				Matt Gifford
* @copyright			2006 Timeshifting Interactive Limited
* @version			1.0
*/


approach = new ApproachMethodPage();
window.onload = new Function("xhtml.init(); approach.init();");


/**
* Creates a new ApproachMethodPage object with methods used by the main approach section landing page
*
* @author				Matt Gifford
* @copyright			2006 Timeshifting Interactive Limited
* @version			1.0
*/
function ApproachMethodPage()
	{
	// Step 1. Define Properties

	this.initialized = false;
	this.debug = false;


	// Step 2. Define Public Methods

	/**
	* Sets up the initial page state and event handlers
	*/
	this.init = function()
		{
		this.initEventHandlers();
		this.initClickableRegions();

		// Set class as initialized
		this.initialized = true;
		}


	/**
	* Adds rollover event handlers to the columns
	*/
	this.initEventHandlers = function()
		{
		// 1. Preload rollover images
		var images = new Array('approach-method-body-suitable-bg-top-green.gif' ,'approach-method-body-suitable-bg-bottom-green.gif' ,'approach-method-body-differentiate-bg-top-orange.gif' ,'approach-method-body-differentiate-bg-bottom-orange.gif' ,'approach-method-body-benefits-bg-top-blue.gif' ,'approach-method-body-benefits-bg-bottom-blue.gif');
		var cache = new Array();
		for (var x = 0; x < images.length; x++)
			{
			cache[x] = new Image();
			cache[x].src = 'images/' + images[x];
			}

		// 2. Add event handlers to columns
		document.getElementById('approachMethodBodySuitable').onmouseover = function()
			{
			this.className += ' suitableOver';
			}
		document.getElementById('approachMethodBodySuitable').onmouseout = function()
			{
			this.className = this.className.replace(/\s?suitableOver/g, '');
			}
		document.getElementById('approachMethodBodyDifferentiate').onmouseover = function()
			{
			this.className += ' differentiateOver';
			}
		document.getElementById('approachMethodBodyDifferentiate').onmouseout = function()
			{
			this.className = this.className.replace(/\s?differentiateOver/g, '');
			}
		document.getElementById('approachMethodBodyBenefits').onmouseover = function()
			{
			this.className += ' benefitsOver';
			}
		document.getElementById('approachMethodBodyBenefits').onmouseout = function()
			{
			this.className = this.className.replace(/\s?benefitsOver/g, '');
			}
		}

	
	/**
	* Adds onclick handlers to the three regions on the page
	*/

	this.initClickableRegions = function()
		{
		document.getElementById('approachMethodBodySuitable').onclick = function()
			{
			var anchors = document.getElementById('approachMethodBodySuitable').getElementsByTagName('a');
			window.location = anchors[anchors.length-1].href;
			}
		document.getElementById('approachMethodBodyDifferentiate').onclick = function()
			{
			var anchors = document.getElementById('approachMethodBodyDifferentiate').getElementsByTagName('a');
			window.location = anchors[anchors.length-1].href;
			}
		document.getElementById('approachMethodBodyBenefits').onclick = function()
			{
			var anchors = document.getElementById('approachMethodBodyBenefits').getElementsByTagName('a');
			window.location = anchors[anchors.length-1].href;
			}
		}
	}
