
/***********************************
Static Properties
***********************************/

var PAGE_ICON_LOCATION = "images/"; // Location of all page icons.

/*
Page icons in order of page appearance.
*/
var PAGE_ICONS = [
	PAGE_ICON_LOCATION + "page_icon_home.jpg",
	PAGE_ICON_LOCATION + "page_icon_hazardous_waste.jpg",
	PAGE_ICON_LOCATION + "page_icon_ind_services.jpg",
	PAGE_ICON_LOCATION + "page_icon_other_services.jpg",
	PAGE_ICON_LOCATION + "page_icon_news.jpg",
	PAGE_ICON_LOCATION + "page_icon_downloads.jpg",
	PAGE_ICON_LOCATION + "page_icon_contact.jpg"
];
	
var FLASH_NAV_DATA_LOCATION = "data/flashNavConfig.xml"; // Data source for Flash navigation in relation to the web page.

/***********************************
Properties
***********************************/

var aPages; // Page data.
var aPageIds; // Page ids

/***********************************
Functions
***********************************/

/*
Initiation function.
*/

function init()
	{
		configurePages();
		defineImages();
	}
	
/*
Resizes the fisherman flash movie.
*/

function resizeFisherman()
	{
		var mainPage = $("#mainPage");
		var fisherman = $("#fisherman");
		var mainPageHeight = Number(mainPage.css("height").substring(0, mainPage.css("height").length - 2));
		// increase the movie by 40px as we have moved it up 40px
		var newHeight = mainPageHeight + 88 + 40;
		fisherman.css("height", String(newHeight) + "px");
	}
	
/*
Informs the fisherman flash movie to load the boxes.
*/

function loadFishermanBoxes()
	{
		var fisherman = $("#fisherman").get(0);
		fisherman.loadBoxes();
	}

/*
Initiates the loading of the image blender base but not the content; that will load
after the navigational images have completely downloaded.
Called from the web page onload.
*/

function loadImageBlender()
	{
		embedImageBlender(aPageIds[PAGE_NUM]);
	}
	
/*
Called from the flash navigation once all images are loaded.
Informs the image blender to load the images for display.
*/

function navLoaded()
	{
 		//getFlashMovieObject("imageBlender").SetVariable("webPageLoaded", "true");
 		loadFishermanBoxes();
	}
	
/*
Called from the flash fisherman once all boxes have been reeled in.
Informs the image blender to load the images for display.
*/

function fishermanGotCatch()
	{
 		getFlashMovieObject("imageBlender").SetVariable("webPageLoaded", "true");
	}
		
/*
Returns the query part of the location string.
window.loaction.search is the url query including the '?'.
*/

function getQuery()
	{
		return window.location.search.substring(1);
	}
	
/*
Returns an object containing name value pairs from the url query (e.g. myObject.myName = myValue).
window.loaction.search is the url query including the '?'.
*/

function getQueryData()
	{
		var aCurrPair; // Current name value pair being assessed.
		var aQueries = getQuery().split("&");
		var oData = {}; // Holds the return data
		
		for (var i = 0; i < aQueries.length; i++)
		{
			aCurrPair = aQueries[i].split("=");
			oData[aCurrPair[0]] = aCurrPair[1];
		}
		
		return oData;
	}

/*

*/

function configurePages()
	{
		aPages = [
			{pageLocation:"index.html"},
			{pageLocation:"hazardous_waste.html"},
			{pageLocation:"industrial_services.html"},
			{pageLocation:"other_services.html"},
			{pageLocation:"news.html"},
			{pageLocation:"downloads.html"},
			{pageLocation:"contact_us.html"}
		];
		
		aPageIds = [
			"home",
			"hazardous_waste",
			"industrial_services",
			"other_services",
			"news",
			"downloads",
			"contact"
		];
	}

/*
Called by Flash navigation on selection of a button.
	@navItem:Number			Navigation index (page number).
*/

function onFlashNavSelect(navItem)
	{
		location = findPageLocation(navItem);
	}

/*
Returns the page location corresponding to the specified index.
	@index:Number				Page index.
	@return:String			Page location.
*/

function findPageLocation(index)
	{
		//alert("general : findPageLocation : " + index);
		//alert(aPages[index].pageLocation);
		return aPages[index].pageLocation;
	}

/*
Declares all images for use with rollovers.
*/

function defineImages()
	{
		oContactButtonImage = {out:{}, over:{}};
		oContactButtonImage.out.src = "images/contact_up.jpg";
		oContactButtonImage.over.src = "images/contact_over.jpg";
	}

/*
Displays the page icon for the page number specified.
	@pageNum:Number				Page number in order of appearance.
*/

function displayPageIcon(pageNum)
	{
		document.getElementById("pageTitleIcon").style.backgroundImage = "url('" + PAGE_ICONS[pageNum] + "')";
	}

