

/*var images=new Array()

images[0] = "Helps_you_communicate";
images[1] = "liberates_your_thinking";
images[2] = "develops_your_people";
images[3] = "Frees_power_in_brand";
images[4] = "keeps_it_human_scale";
images[5] = "takes_an_objective_view";
images[6] = "listens_carefully_to_you";
images[7] = "gets_everyone_thinking";
images[8] = "coaches_and_counsels";
images[9] = "energises_your_team";
images[10] = "helps_you_to_innovate";
images[11] = "opens_up_possibilities";
images[12] = "clarifies_your_thinking";
images[13] = "supports_business_leaders";
/**/

shuffle(images) ;
// Set slideShowSpeed (milliseconds)
var slideShowSpeed = 5000

// Duration of crossfade (seconds)
var crossFadeDuration = 3

// =======================================
// do not edit anything below this line
// =======================================

var t
var j = 0
var p = images.length

var preLoad = new Array()
for (i = 0; i < p; i++){
   preLoad[i] = new Image()
   preLoad[i] = images[i]
}



if(!(document.getElementById&&!document.all)) 
{
document.write('<link rel=\"stylesheet\" type=\"text\/css\" href=\"style_ie.css\" \/>');
}else
{
document.write('<link rel=\"stylesheet\" type=\"text\/css\" href=\"style_non_ie.css\" \/>');
}




var content_images=new Array()

/*
content_images[0] = "images/content/optimised/Simon-MRJ-003824";  
content_images[1] = "images/content/optimised/Simon-MRJ-003826";  
content_images[2] = "images/content/optimised/Simon-MRJ-003828";  
content_images[3] = "images/content/optimised/Simon-MRJ-003833";  
content_images[4] = "images/content/optimised/Simon-MRJ-003834";  
content_images[5] = "images/content/optimised/Simon-MRJ-003837";  
content_images[6] = "images/content/optimised/Simon-MRJ-003839";  
content_images[7] = "images/content/optimised/Simon-MRJ-003844";  
content_images[8] = "images/content/optimised/Simon-MRJ-003845";  
content_images[9] = "images/content/optimised/Simon-MRJ-003859";  
content_images[10] = "images/content/optimised/Simon-MRJ-003861";  
content_images[11] = "images/content/optimised/Simon-MRJ-003864";  
content_images[12] = "images/content/optimised/Simon-MRJ-003869";  
content_images[13] = "images/content/optimised/Simon-MRJ-003874";  
content_images[14] = "images/content/optimised/Simon-MRJ-003876";  
content_images[15] = "images/content/optimised/Simon-MRJ-003877";  
content_images[16] = "images/content/optimised/Simon-MRJ-003878";  
content_images[17] = "images/content/optimised/Simon-MRJ-003881";  
content_images[18] = "images/content/optimised/Simon-MRJ-003883";  
content_images[19] = "images/content/optimised/Simon-MRJ-003889";  
content_images[20] = "images/content/optimised/Simon-MRJ-003894";  
content_images[21] = "images/content/optimised/Simon-MRJ-003895";  
content_images[22] = "images/content/optimised/Simon-MRJ-003896";  
content_images[23] = "images/content/optimised/Simon-MRJ-003906";  
content_images[24] = "images/content/optimised/Simon-MRJ-003911";  
content_images[25] = "images/content/optimised/Simon-MRJ-003914";  
content_images[26] = "images/content/optimised/Simon-MRJ-003915";  
content_images[27] = "images/content/optimised/Simon-MRJ-003916";  
content_images[28] = "images/content/optimised/Simon-MRJ-003927";  
content_images[29] = "images/content/optimised/Simon-MRJ-003931";  
content_images[30] = "images/content/optimised/Simon-MRJ-003933";  
content_images[31] = "images/content/optimised/Simon-MRJ-003935";  
content_images[32] = "images/content/optimised/Simon-MRJ-003938";  
content_images[33] = "images/content/optimised/Simon-MRJ-003941";  
content_images[34] = "images/content/optimised/Simon-MRJ-003942";  
content_images[35] = "images/content/optimised/Simon-MRJ-003949";  
content_images[36] = "images/content/optimised/Simon-MRJ-003950";  
content_images[37] = "images/content/optimised/Simon-MRJ-003951";  
content_images[38] = "images/content/optimised/Simon-MRJ-003956";  
*/
content_images[0] = "images/content/optimised/Simon_Web_01 ";  
content_images[1] = "images/content/optimised/Simon_Web_02 ";  
content_images[2] = "images/content/optimised/Simon_Web_03 ";  
content_images[3] = "images/content/optimised/Simon_Web_04 ";  
content_images[4] = "images/content/optimised/Simon_Web_05 ";  
content_images[5] = "images/content/optimised/Simon_Web_06 ";  
content_images[6] = "images/content/optimised/Simon_Web_07 ";  
content_images[7] = "images/content/optimised/Simon_Web_08 ";
content_images[8] = "images/content/optimised/Simon_Web_09 ";

function setBannerRandomly()
{
	index = Math.floor(Math.random() * images.length);
	setStyleByClass("div", "smc2", "background", "url(" +images[index]  + ") no-repeat 0px 0px");
}


function set_main_image(imagename)
{
	setStyleByClass("div", "main_image", "background", "url("+imagename+") no-repeat center top")
}

	
// Copyright © 2001 by Apple Computer, Inc., All Rights Reserved.
//
// You may incorporate this Apple sample code into your own code
// without restriction. This Apple sample code has been provided "AS IS"
// and the responsibility for its operation is yours. You may redistribute
// this code, but you are not permitted to redistribute it as
// "Apple sample code" after having made changes.

// ugly workaround for missing support for selectorText in Netscape6/Mozilla
// call onLoad() or before you need to do anything you would have otherwise used
// selectorText for.
var ugly_selectorText_workaround_flag = false;
var allStyleRules;
// code developed using the following workaround (CVS v1.15) as an example.
// http://lxr.mozilla.org/seamonkey/source/extensions/xmlterm/ui/content/XMLTermCommands.js
function ugly_selectorText_workaround() {
	if((navigator.userAgent.indexOf("Gecko") == -1) ||
	   (ugly_selectorText_workaround_flag)) {
		return; // we've already been here or shouldn't be here
	}
	var styleElements = document.getElementsByTagName("style");
	
	for(var i = 0; i < styleElements.length; i++) {
		var styleText = styleElements[i].firstChild.data;
		// this should be using match(/\b[\w-.]+(?=\s*\{)/g but ?= causes an
		// error in IE5, so we include the open brace and then strip it
		allStyleRules = styleText.match(/\b[\w-.]+(\s*\{)/g);
	}

	for(var i = 0; i < allStyleRules.length; i++) {
		// probably insufficient for people who like random gobs of 
		// whitespace in their styles
		allStyleRules[i] = allStyleRules[i].substr(0, (allStyleRules[i].length - 2));
	}
	ugly_selectorText_workaround_flag = true;
}


// setStyleById: given an element id, style property and 
// value, apply the style.
// args:
//  i - element id
//  p - property
//  v - value
//
function setStyleById(i, p, v) {
	var n = document.getElementById(i);
	n.style[p] = v;
}

// getStyleById: given an element ID and style property
// return the current setting for that property, or null.
// args:
//  i - element id
//  p - property
function getStyleById(i, p) {
	var n = document.getElementById(i);
	var s = eval("n.style." + p);

	// try inline
	if((s != "") && (s != null)) {
		return s;
	}

	// try currentStyle
	if(n.currentStyle) {
		var s = eval("n.currentStyle." + p);
		if((s != "") && (s != null)) {
			return s;
		}
	}
	
	// try styleSheets
	var sheets = document.styleSheets;
	if(sheets.length > 0) {
		// loop over each sheet
		for(var x = 0; x < sheets.length; x++) {
			// grab stylesheet rules
			var rules = sheets[x].cssRules;
			if(rules.length > 0) {
				// check each rule
				for(var y = 0; y < rules.length; y++) {
					var z = rules[y].style;
					// selectorText broken in NS 6/Mozilla: see
					// http://bugzilla.mozilla.org/show_bug.cgi?id=51944
					ugly_selectorText_workaround();
					if(allStyleRules) {
						if(allStyleRules[y] == i) {
							return z[p];
						}			
					} else {
						// use the native selectorText and style stuff
						if(((z[p] != "") && (z[p] != null)) ||
						   (rules[y].selectorText == i)) {
							return z[p];
						}
					}
				}
			}
		}
	}
	return null;
}

// setStyleByClass: given an element type and a class selector,
// style property and value, apply the style.
// args:
//  t - type of tag to check for (e.g., SPAN)
//  c - class name
//  p - CSS property
//  v - value
var ie = (document.all) ? true : false;

function setStyleByClass(t,c,p,v){
	var elements;
	if(t == '*') {
		// '*' not supported by IE/Win 5.5 and below
		elements = (ie) ? document.all : document.getElementsByTagName('*');
	} else {
		elements = document.getElementsByTagName(t);
	}
	for(var i = 0; i < elements.length; i++){
		var node = elements.item(i);
		for(var j = 0; j < node.attributes.length; j++) {
			if(node.attributes.item(j).nodeName == 'class') {
				if(node.attributes.item(j).nodeValue == c) {
					eval('node.style.' + p + " = '" +v + "'");
				}
			}
		}
	}
}

// getStyleByClass: given an element type, a class selector and a property,
// return the value of the property for that element type.
// args:
//  t - element type
//  c - class identifier
//  p - CSS property
function getStyleByClass(t, c, p) {
	// first loop over elements, because if they've been modified they
	// will contain style data more recent than that in the stylesheet
	var elements;
	if(t == '*') {
		// '*' not supported by IE/Win 5.5 and below
		elements = (ie) ? document.all : document.getElementsByTagName('*');
	} else {
		elements = document.getElementsByTagName(t);
	}
	for(var i = 0; i < elements.length; i++){
		var node = elements.item(i);
		for(var j = 0; j < node.attributes.length; j++) {
			if(node.attributes.item(j).nodeName == 'class') {
				if(node.attributes.item(j).nodeValue == c) {
					var theStyle = eval('node.style.' + p);
					if((theStyle != "") && (theStyle != null)) {
						return theStyle;
					}
				}
			}
		}		
	}
	// if we got here it's because we didn't find anything
	// try styleSheets
	var sheets = document.styleSheets;
	if(sheets.length > 0) {
		// loop over each sheet
		for(var x = 0; x < sheets.length; x++) {
			// grab stylesheet rules
			var rules = sheets[x].cssRules;
			if(rules.length > 0) {
				// check each rule
				for(var y = 0; y < rules.length; y++) {
					var z = rules[y].style;
					// selectorText broken in NS 6/Mozilla: see
					// http://bugzilla.mozilla.org/show_bug.cgi?id=51944
					ugly_selectorText_workaround();
					if(allStyleRules) {
						if((allStyleRules[y] == c) ||
						   (allStyleRules[y] == (t + "." + c))) {
							return z[p];
						}			
					} else {
						// use the native selectorText and style stuff
						if(((z[p] != "") && (z[p] != null)) &&
						   ((rules[y].selectorText == c) ||
						    (rules[y].selectorText == (t + "." + c)))) {
							return z[p];
						}
					}
				}
			}
		}
	}

	return null;
}

// setStyleByTag: given an element type, style property and 
// value, and whether the property should override inline styles or
// just global stylesheet preferences, apply the style.
// args:
//  e - element type or id
//  p - property
//  v - value
//  g - boolean 0: modify global only; 1: modify all elements in document
function setStyleByTag(e, p, v, g) {
	if(g) {
		var elements = document.getElementsByTagName(e);
		for(var i = 0; i < elements.length; i++) {
			elements.item(i).style[p] = v;
		}
	} else {
		var sheets = document.styleSheets;
		if(sheets.length > 0) {
			for(var i = 0; i < sheets.length; i++) {
				var rules = sheets[i].cssRules;
				if(rules.length > 0) {
					for(var j = 0; j < rules.length; j++) {
						var s = rules[j].style;
						// selectorText broken in NS 6/Mozilla: see
						// http://bugzilla.mozilla.org/show_bug.cgi?id=51944
						ugly_selectorText_workaround();
						if(allStyleRules) {
							if(allStyleRules[j] == e) {
								s[p] = v;
							}			
						} else {
							// use the native selectorText and style stuff
							if(((s[p] != "") && (s[p] != null)) &&
							   (rules[j].selectorText == e)) {
								s[p] = v;
							}
						}

					}
				}
			}
		}
	}
}

// getStyleByTag: given an element type and style property, return
// the property's value
// args:
//  e - element type
//  p - property
function getStyleByTag(e, p) {
	var sheets = document.styleSheets;
	if(sheets.length > 0) {
		for(var i = 0; i < sheets.length; i++) {
			var rules = sheets[i].cssRules;
			if(rules.length > 0) {
				for(var j = 0; j < rules.length; j++) {
					var s = rules[j].style;
					// selectorText broken in NS 6/Mozilla: see
					// http://bugzilla.mozilla.org/show_bug.cgi?id=51944
					ugly_selectorText_workaround();
					if(allStyleRules) {
						if(allStyleRules[j] == e) {
							return s[p];
						}			
					} else {
						// use the native selectorText and style stuff
						if(((s[p] != "") && (s[p] != null)) &&
						   (rules[j].selectorText == e)) {
							return s[p];
						}
					}

				}
			}
		}
	}




	// if we don't find any style sheets, return the value for the first
	// element of this type we encounter without a CLASS or STYLE attribute
	var elements = document.getElementsByTagName(e);
	var sawClassOrStyleAttribute = false;
	for(var i = 0; i < elements.length; i++) {
		var node = elements.item(i);
		for(var j = 0; j < node.attributes.length; j++) {
			if((node.attributes.item(j).nodeName == 'class') ||
			   (node.attributes.item(j).nodeName == 'style')){
			   sawClassOrStyleAttribute = true;
			}
		}
		if(! sawClassOrStyleAttribute) {
			return elements.item(i).style[p];
		}
	}
}



function runSlideShow(){
  initImage(true, true);
}


function content_initImage() {
  content_ImageID='page_image';
  page_image_image = document.getElementById(content_ImageID);
  intShowImageNumber = Math.floor(Math.random() * content_images.length);
  page_image_image.src = content_images[intShowImageNumber];
  setOpacity(page_image_image, 0);
  page_image_image.style.visibility = 'visible';
  fadeIn(content_ImageID,0, false, false);
}



function initImage(fadeout, loop) {
	imageId = 'quote';
	shuffle(preLoad);
	image = document.getElementById(imageId);
	
	//j = Math.floor(Math.random() * images.length);
	j = 0;
	image.innerHTML = '<h2>&#8220;' + preLoad[j] + '&#8221;</h2>';
	setOpacity(image, 0);
	image.style.visibility = 'visible';
	fadeIn('quote',0, fadeout, loop);

}



function fadeIn(objId,opacity, fadeout, loop) {
  
  if (document.getElementById) {
    obj = document.getElementById(objId);
    if (opacity <= 100) {
      setOpacity(obj, opacity);
      opacity += 10;
      window.setTimeout("fadeIn('"+objId+"',"+opacity+"," + fadeout + "," + loop + ")", 100);
    }
	else if (fadeout)
	{
     	window.setTimeout("fadeOut('"+objId+"',"+opacity+"," + loop + ")", 3000);
	}
  }
}

function shuffle(a) {
     var r, t, l = a.length;
   //  if (!(a instanceof Array) || l < 2) return;
     do {
         r = Math.floor(Math.random() * l--);
         t = a[l];
         a[l] = a[r];
         a[r] = t;
     } while (l>0);
 }



function fadeOut(objId,opacity, fadein) {
    if (opacity > 0) 
	{
      opacity -= 10;
      obj = document.getElementById(objId);
      setOpacity(obj, opacity);
      window.setTimeout("fadeOut('"+objId+"',"+opacity+"," + fadein + ")", 100);
    }
	else if (fadein)
	{

		j = j + 1;
  		if (j > (images.length-1))
			{j=0;}
			
	image.innerHTML = '<h2>&#8220;' + preLoad[j] + '&#8221;</h2>';
	  fadeIn(objId,0, true, true);
	}
}

function setOpacity(obj, opacity) {
  opacity = (opacity == 100)?99.999:opacity;
  
  // IE/Win
  obj.style.filter = "alpha(opacity=" + opacity + ");";

  // Safari<1.2, Konqueror
  obj.style.KHTMLOpacity = opacity/100;
  
  // Older Mozilla and Firefox
  obj.style.MozOpacity = opacity/100;
  
  // Safari 1.2, newer Firefox and Mozilla, CSS3
  obj.style.opacity = opacity/100;
}
