//=============================================================================
// global variables
var flashPlayer;
var so;
var myVar;
//=============================================================================
// initialize called with body.onload
function initialize()
{
	so = new SWFObject("dynamics.swf", "dynamics_swf", "899", "442", "8", "#C5BA9C", false, "high");
	so.addParam("wmode", "transparent");
	so.addParam("allowScriptAccess", "always");
	so.write("flashContainer");
	// get a reference to the swf for ExternalInterface
	flashPlayer = document.getElementById("dynamics_swf");
}

function preload(imageArray) {
	var cImage;
	for(i=0; i<imageArray.length; i++){
		cImage = new Image();
		cImage.src = imageArray[i];
		imageArray[i] = cImage;
	}
	return imageArray;
}

function swapImage(obj, imgSrc){
	var cNode = ms.util.getNode(obj);
	//var node = document.getElementById(obj);
	cNode.src = imgSrc;
}

function swapLogo(){
	var cNode = ms.util.getNode(msviFooter);
	var cImage = cNode.getElementByTagName("img");
	cImage.src = "/library/toolbar/3.0/text.aspx?text=TQ%3d%3d%26fore=FFFFFF%26b=162D4E%26font=Microsoft+Logo+95%2c+13pt%26w=105%26h=29%26a=0%26l=0%26v=0%26c=C4rPBmn9tFVJph6xlbaG2tk%2fmxw%3d";
}


//=============================================================================
function callFlashLoadRole(num)
{
	flashPlayer.flashLoadRole(num);
	ms.util.changeClass('nav1container', 'hidden');
	flashPlayer.flashCallTracking('topnavRole'+num);
}
function callFlashLoadIndustry(num)
{
	flashPlayer.flashLoadIndustry(num);
	flashPlayer.flashCallTracking('topnavIndustry'+num);
}
function callFlashResetIntro(){
	flashPlayer.flashResetIntro();
	ms.hideOffscreen();
}
function callFlashTracking(id){
	//flashPlayer.flashCallTracking(id);
}

//=============================================================================
// tracking functions called by flash 

// webtrends
function wtTrack(obj){
	//alert(obj[1]);
	//if(obj[1] == "Start of Flash"){
		//alert(obj[1]);
		myVar = "set";
	//}
	// calls the webtrends tracking function found in wt.js file.
	// obj[2] refers to whether it's a vid play button calling the function
	if(obj[2] == true){
		//alert("DCSext.egi_vid = " + obj[1]);
		dcsMultiTrack('DCS.dcsuri', obj[0],'DCSext.egi_vid', obj[1],'WT.ti', '','WT.dl','6');
	}else{
		dcsMultiTrack('DCS.dcsuri', obj[0],'DCSext.egi_vid', '', 'WT.ti', obj[1],'WT.dl','6');	
	}
}

// atlas DMT
//	obj has 2 parameters: obj[0] is the string, obj[1] is the type (either javascript or 1-pixel gif)
function atlasTrack(obj){
	alert("type = " + obj[1]);
	// if type is image, we replace the src (found in tracking.xml) of a 1-pixel gif with id of "action_tag", which is located in the index page
	if(obj[1]=="image"){
		var tag = obj[0];
		//alert("atlas tag = " + tag);
		document.action_tag.src = tag;
	}else if(obj[1]=="javascript"){
		// if type is js, we use the DOM to create a script object with src = path found in tracking.xml doc
		var tracking = document.getElementById("tracking");
		var script = document.createElement("script");
		script.setAttribute("language", "JavaScript");
		script.setAttribute("src", obj[0]);
		tracking.appendChild(script);
	}
}

function atlasTrackNav(url){
	document.action_tag.src = url;
}

//=============================================================================
// create singleton object
if(typeof ms =="undefined"){var ms = {};}
//=============================================================================
// public methods
ms =
{
	//==========================================================================
	CURRENT_SCREEN : String(),
	//==========================================================================
	init : function	()
	{
		this.CURRENT_SCREEN = "empty";
	},
	//==========================================================================
	showOffscreen : function(inIdName)
	{
		//if(myVar == "set"){
		ms.hideOffscreen();
		this.CURRENT_SCREEN = inIdName;
		ms.util.changeClass(this.CURRENT_SCREEN, 'onscreen');
		//flashPlayer.disableFlash(true);
		//}
	},
	hideOffscreen : function()
	{
		if(this.CURRENT_SCREEN!="empty")
		{
			ms.util.changeClass(this.CURRENT_SCREEN, 'offscreen');
			this.CURRENT_SCREEN = "empty";
			//flashPlayer.disableFlash(false);
		}
	},
	showOverlay : function(inIdName){
		//ms.hideOverlay();
		//this.CURRENT_SCREEN = inIdName;
		//flashPlayer.disableFlash(true);
		//flashPlayer.showOverlay(inIdName);
	},
	hideOverlay : function(){
		//if(this.CURRENT_SCREEN!="empty"){
			//this.CURRENT_SCREEN = "empty";
			//flashPlayer.disableFlash(false);
			//flashPlayer.hideOverlay();
		//}
	}
}
//==============================================================================
// private utility methods
ms.util =
{
	//==========================================================================
	
	//==========================================================================
	// use
	// ms.util.changeClass("someIdName", "class1");
	// ms.util.changeClass("someIdName", "class1 class2 class3");
	changeClass : function(inIdName, inClass)
	{
		try{
			var cNode = this.getNode(inIdName);
		}catch(e){
			//alert("1: " + e + " | " + node);
		}
		try{
			cNode.className = inClass;
		}catch(e){
			//alert("2: " + node + " | " + document.embeds + " | " + document.embeds[inElement]);
		}
	},
	//==========================================================================
	//	use
	//	ms.util.setStyle("body", "backgroundColor", "#222222");
	//	ms.util.setStyle("container", "height", 100, "px");
	setStyle : function(inIdName, inAttribute, inValue, inSuffix)
	{
		var cNode = this.getNode(inIdName);
		var value = (inSuffix != undefined)? inValue + inSuffix : inValue;
		cNode.style[inAttribute] = value;
	},
	//==========================================================================
	// use
	// ms.util.createNode("someParentIdName", "newIdName", "class1");
	// ms.util.createNode("someParentIdName", "newIdName", "class1 class2 class3");
	createNode : function(inParentNode, inIdName, inClassName)
	{
		// create div
		var newNode = document.createElement('div');
		// assign class to div
		newNode.className = inClassName;
		// assign id to div
		newNode.id = inIdName;
		// get reference to parent div
		var parentNode = this.getNode(inParentNode);
		// append new div to parent div
		parentNode.appendChild(newNode);
	},
	//==========================================================================
	// checks for multiple browser types and returns
	// the correct Flash object reference
	// use
	// var nodeReference = ms.util.getNode("someIdName")
	getNode : function(inIdName)
	{
		if(window.document[inIdName])
		{
			return window.document[inIdName];
		}
		if(navigator.appName.indexOf("Microsoft Internet")==-1)
		{
			if(document.embeds && document.embeds[inIdName])
				return document.embeds[inIdName];
			else
				return document.getElementById(inIdName);
		}
		else
		{
			return document.getElementById(inIdName);
		}
	}
}

	
ms.init();