/*
* ------------------------------------------------------------------------------------------------
*
* This is an unpublished work, the copyright in which vests in Experian Limited. All rights 
* reserved.
*
* The information contained herein is confidential and the property of Experian Limited, and is 
* supplied without liability for errors or ommisions. No part may be reproduced, disclosed or 
* used except as authorised by contract or other written permission. The copyright and
* foregoing restrictions on reproduction and use extend to all media in which the information 
* may be embodied.
* ------------------------------------------------------------------------------------------------
* Title: Interactive Guide
*
* Filename: 	aninmation.js
* File created:	11/03/09
*
* Description:	Implementation of the functions for the animation page of the Interactive
*               Guide. 
*
* Written by:	Russell Ballaam, Marketing Services Global Product Development & Delivery.
*
* Revision:	0.1
*
* Revision history:
*
* Revision 0.1 11/03/09
* ------------------------------------------------------------------------------------------------
*
* First release.
*/

// Include the Dojo modules required for local storage of settings and custom variables: 
dojo.require("dojo.dom");
dojo.require("dojo.io.*");
dojo.require("dojo.event.*");
dojo.require("dojo.html.*");
dojo.require("dojo.lfx.*");
dojo.require("dojo.storage.*");

// Define and instantiate global variables:
var szAnimID = "anim"									// The ID of the animation object.
var szStartpage = "html/visualisation.htm"				// Name of the page to display after the animation page.
var szVideoanimdir = "data/" + szMainfoldername + "/video/animation/";	// Fragment of the path to the directory that holds the animation video file.
var szVideoext = ".swf";								// Name of the extension to be used for video links.

// Initialise the custom storage object:
objCustomstorage = {
	currentProvider: "default",
	
	initialiseStorage: function()
	{		
		if (bLangsupport)
		getLang();
		else
		setLocalisation(); 
	},
			
	saveKey: function(szKey, szValue)
	{
		var self = this;
		try
		{
			dojo.storage.put(szKey, szValue, storageStatus);
		}
		catch(exp)
		{
			alert(exp);
		}
	}
};

// Wait until the storage system has finished loading:
if(dojo.storage.manager.isInitialized() == false)
{ 
	// Storage might already be loaded when we get here:
	dojo.event.connect(dojo.storage.manager, "loaded", objCustomstorage, objCustomstorage.initialiseStorage);
}
else
{
	dojo.event.connect(dojo, "loaded", objCustomstorage, objCustomstorage.initialiseStorage);
}

/*
 * ------------------------------------------------------------------------------------------------
 * FUNCTION: displayStartpage
 * ------------------------------------------------------------------------------------------------
 * 
 * Displays the start page after onclick, onkeypress, or onkeydown events; or after the animation 
 * video (if supplied with the project) has finished playing.
 *
 * Parameters:  None.
 *
 * Returns: None.
 * ------------------------------------------------------------------------------------------------
*/
function displayStartpage() 
{
	if(bModalshown || bClose)
	return;
			
	// Display the designated start page and remove the animation page from the browser's 
	// History list:
	if (bDonechecks == true)
	location.replace(szDomain + szStartpage + "?" + szSupport);
}

/*
 * ------------------------------------------------------------------------------------------------
 * FUNCTION: writeAnimationcontrol
 * ------------------------------------------------------------------------------------------------
 * 
 * Writes an embedded Macromedia/Adobe Flash Player control object into the animation page.
 *
 * Parameters:  None.
 *
 * Returns: None.
 * ------------------------------------------------------------------------------------------------
*/
function writeAnimationcontrol()
{
	var szHTML = "";		// String to be written into the page.

	// Build the HTML to write into the page:
  	szHTML = '<object id="' + szAnimID + '" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"  codebase="http://active.macromedia.com/flash7/cabs/ swflash.cab#version=9,0,0,0" onclick="alert(\'Hello\');" hspace="0" width="1008" height="727" type="application/x-oleobject">'
  	szHTML += '<param name="movie" value="' + szDomain + szVideoanimdir + 'animation' + szVideoext + '">';
    szHTML += '<param name="play" value="true">';
  	szHTML += '<param name="loop" value="false">';
  	szHTML += '<param name="quality" value="high">';
  	szHTML += '<embed id="' + szAnimID + '2" src=" ' + + szDomain + szVideoanimdir + 'animation' + szVideoext + ' width="1008" hspace="0" height="727" play="true" loop="false" quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></embed>';
	szHTML += '</object>';
	
	 // Write the HTML into the page:
	$("#outerframe").html(szHTML); 
	
	// Fade in the screen:
	$("#init").css("display", "none");
	$("#outerframe").fadeIn("slow");
	$("#body").fadeIn("slow");
	$("#copyright").fadeIn("slow");		
}

/*
 * ------------------------------------------------------------------------------------------------
 * FUNCTION: writeImage
 * ------------------------------------------------------------------------------------------------
 * 
 * Writes a static image into the animation page. This is used if the user's browser does not
 * support Macromedia/Adobe Flash Player 6 or later, or if an animation file is not supplied with 
 * the project.
 *
 * Parameters:  None.
 *
 * Returns: None.
 * ------------------------------------------------------------------------------------------------
*/
function writeImage()
{
	var szHTML = "";		// String to be written into the page.	
		
	// Build the HTML to write into the page:
	szHTML = '<img id="static" class="static" src="' + szDomain + szMainimgdir + 'staticimage.jpg"' +  ' />';
	
    // Write the HTML into the page:
	$("#outerframe").html(szHTML); 	
	
	// Fade in the screen:
	$("#init").css("display", "none");
	$("#outerframe").fadeIn("slow");
	$("#body").fadeIn("slow");
	$("#copyright").fadeIn("slow");	          
}

