// Next function is a Subroutine to display the SWFs ---------------------------------------------- 
function Swf_Display(filename,width,height,id_name)
{
reveal
document.write("<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\"");
document.write("codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0\"");
document.write("width=\"" + width + "\" height=\"" + height + "\" border=\"0\" id=\"" + id_name + "\">");
document.write("<param name=\"movie\" value=\"" + filename + "\">");
document.write("<param name=\"quality\" value=\"high\">");
// document.write("<param name=bgcolor value=#00ff00>");	// overwrites background color in TEXTFADE SWF in IE7
document.write("<embed src=\"" + filename + "\" quality=\"high\"");
// document.write("bgcolor=\"#ffffff\"");	// overwrites background color in TEXTFADE SWF in FIREFOX 3.0
document.write("width=\"" + width + "\" height=\"" + height + "\" name=\"" + id_name + "\" align=\"center\" type=\"application/x-shockwave-flash\"");
document.write("pluginspage=\"http://www.macromedia.com/go/getflashplayer\">");
document.write("</embed>");
document.write("</object>");
}

// Next function controls the display of the Divs ------------------------------------------------- 
function unhide(divID)
{
var item = document.getElementById(divID);
if (item)
{
var x;
var div_ids = new Array();
div_ids[0] = "home-page";
div_ids[1] = "about-us";
div_ids[2] = "cars";
div_ids[3] = "vans";
div_ids[4] = "minibus";
div_ids[5] = "terms";
div_ids[6] = "contact-us";
div_ids[7] = "links";

for (x in div_ids)
{
document.getElementById(div_ids[x]).style.display="none";
}
item.style.display="block";
}
}

// Next function hides the SWF for the first 100msec to mask out the flash at the start of display 
function reveal()
{
var x;
swf_ids = new Array();	// Variable declared with GLOBAL SCOPE
swf_ids[0] = "car-swf-title";
swf_ids[1] = "car-swf-info";
swf_ids[2] = "van-swf-title";
swf_ids[3] = "van-swf-info";
swf_ids[4] = "minibus-swf-title";
swf_ids[5] = "minibus-swf-info";
for (x in swf_ids)
{
document.getElementById(swf_ids[x]).style.visibility='hidden';
}
var zzz=setTimeout("reveal_zzz()",500);
}

// Next function is called by the above function to make the SWFs visible after the 100msecs ---------
function reveal_zzz()
{
var x;
for (x in swf_ids)
{
document.getElementById(swf_ids[x]).style.visibility='visible';
}
}

// ------------------------------------------------------------------------------------------------

{
//	Configuration variables
display_secs = 4000;	// time image is displayed for in milliseconds
fade_secs = 2000;	// time image takes to fade in for in milliseconds
image_count = 11;	// number of images used
image_ids = new Array();
image_ids[0] = "images/mondeo-1.jpg";
image_ids[1] = "images/fiesta-1.jpg";
image_ids[2] = "images/transit-1.jpg";
image_ids[3] = "images/ldv_minibus-1.jpg";
image_ids[4] = "images/galaxy-1.jpg";
image_ids[5] = "images/mondeo-2.jpg";
image_ids[6] = "images/fiesta-2.jpg";
image_ids[7] = "images/galaxy-2.jpg";
image_ids[8] = "images/ldv_minibus-2.jpg";
image_ids[9] = "images/mondeo-est.jpg";
image_ids[10] = "images/transit-2.jpg";

}
if (fade_secs > display_secs)
{
fade_secs = display_secs;
}

// ------------------------------------------------------------------------------------------------

function start()
{
image_number = 0;

RunImageFader();
}

// ------------------------------------------------------------------------------------------------

function RunImageFader()
{
if (image_number == image_count)
{
image_number=0;
}

var nextImage = image_ids[image_number];

swapImageFade(nextImage);

setTimeout("RunImageFader()",display_secs);

image_number++
}

// ------------------------------------------------------------------------------------------------

function changeOpacity(opacity_index) 
{
var object = document.getElementById("fading-images").style; 
object.opacity = (opacity_index / 100); 
object.MozOpacity = (opacity_index / 100); 
object.KhtmlOpacity = (opacity_index / 100); 
object.filter = "alpha(opacity=" + opacity_index + ")"; 
} 

// ------------------------------------------------------------------------------------------------

function swapImageFade(imagefile) 
{ 
var speed = Math.round(fade_secs / 100);
var timer = 0; 

document.getElementById("pictures").style.backgroundImage = "url(" + document.getElementById("fading-images").src + ")"; 
// reveal();

changeOpacity(0); 

document.getElementById("fading-images").src = imagefile; 

for(i = 0; i <= 100; i++) 
{ 
setTimeout("changeOpacity(" + i + ")",(timer * speed));
timer++; 
} 
} 

// ------------------------------------------------------------------------------------------------

// calls the start function when everything else has been loaded 
window.onload=start;	// note if () parentheses are included the function runs in sequence of loading 
