var silverlightControl;
var xmlDoc;
var forLocalUse;
var currentPlayingVid;
var vidTimelineID;
var objectFadingInID;
var objectFadingOutID;
var currentVidSource;
var vidInitialized = false;
var doDragTime = false;
var doDragVol = false;
var playerLoop;
var CCOn = false;
var _global = this;
var musicLoopInitialized = false;
var playlistXMLArray = new Array();
var navItemXMLArray = new Array();
var openSubNavLevel = -1;
var playMode = "all";
var isPaused = false;
if (!window.Silverlight) {
	window.Silverlight = {};
}
if (!window.DemoPlayerEngine) {
	window.DemoPlayerEngine = {};
}
createSilverlight = function(sourceXAML, versionNumber) {
	var scene = new DemoPlayerEngine.Page();
	Silverlight.createObjectEx({source: sourceXAML, parentElement: document.getElementById("SilverlightControlHost"), id: "SilverlightControl", properties: { width: "100%", height: "100%", version: versionNumber }, events: { onLoad: Silverlight.createDelegate( scene, scene.handleLoad )}});
};
Silverlight.createDelegate = function(instance, method) {
	return function() {
		return method.apply(instance, arguments);
	}
}
DemoPlayerEngine.Page = function() {
}
DemoPlayerEngine.Page.prototype = {
	handleLoad: function(control, userContext, rootElement) 
	{
		silverlightControl = control;
		silverlightControl.content.findName("DemoPlayer").addEventListener("KeyUp", keyboardEvents);
		silverlightControl.content.onResize = onResized;
		silverlightControl.content.onFullScreenChange = onBodyResized;
		loadXMLDoc('JeannineDemoPlaylist.xml');
	}
}
loadXMLDoc = function() {
	if (location.protocol == "http:") {
		forLocalUse = false;
	} else {
		forLocalUse = true;
	}
	if (forLocalUse) {
		if (document.implementation && document.implementation.createDocument) {
			xmlDoc = document.implementation.createDocument('', '', null);
			xmlDoc.onload = compileXML;
		} else if (window.ActiveXObject) {
			xmlDoc = new ActiveXObject('Microsoft.XMLDOM');
			xmlDoc.async = "false";
			xmlDoc.onreadystatechange = xmlLoadStatus;
	 	} else {
			alert('This browser does not support some or all the technology this page uses. Please use another browser.');
			return;
		}
		xmlDoc.load(xmlURL);
	} else {
		if(window.XMLHttpRequest && !(window.ActiveXObject)) {
				xmlDoc = new XMLHttpRequest();
			}
		 else if(window.ActiveXObject) {
			try {
				xmlDoc = new ActiveXObject('Msxml2.XMLHTTP');
			} catch(e) {
				try {
					xmlDoc = new ActiveXObject('Microsoft.XMLHTTP');
				} catch(e) {
					xmlDoc = false;
				}
			}
		}
		if(xmlDoc) {
			xmlDoc.onreadystatechange = xmlLoadStatus;
			xmlDoc.open('GET', xmlURL, true);
			xmlDoc.send('');
		}
	}	
}
xmlLoadStatus = function() {
	if (xmlDoc.readyState == 4) {
		compileXML();
	}
}
compileXML = function() {
	if (!forLocalUse){
		if (!window.ActiveXObject){
			cleanWhiteSpace(xmlDoc.responseXML.documentElement);
		}
	}
	else {
		 cleanWhiteSpace(xmlDoc.documentElement);		
	}

	var totalItems = 0;
	var ccItems = 0;
	if (forLocalUse) {
		for (var x=0; x<xmlDoc.documentElement.childNodes.length; x++) {
			if (xmlDoc.documentElement.childNodes[x].nodeType == 1) {
				
				/*playlistXMLArray[totalItems] = new Array(3);
				playlistXMLArray[totalItems][0] = xmlDoc.documentElement.childNodes[x].getAttribute("name");
				playlistXMLArray[totalItems][1] = xmlDoc.documentElement.childNodes[x].getAttribute("src");
				playlistXMLArray[totalItems][2] = new Array();
				ccItems = 0;
				for (var c=0; c<xmlDoc.documentElement.childNodes[x].childNodes.length; c++) {
					if (xmlDoc.documentElement.childNodes[x].childNodes[c].nodeType == 1) {
						playlistXMLArray[totalItems][2][ccItems] = new Array();
						playlistXMLArray[totalItems][2][ccItems][0] = xmlDoc.documentElement.childNodes[x].childNodes[c].getAttribute("start");
						playlistXMLArray[totalItems][2][ccItems][1] = xmlDoc.documentElement.childNodes[x].childNodes[c].firstChild.nodeValue;
						ccItems++;
					}
				}*/
				navItemXMLArray[totalItems] = new Array(4);
				
				navItemXMLArray[totalItems][0] = xmlDoc.documentElement.childNodes[x].getAttribute("displaytext");
				if(xmlDoc.documentElement.childNodes[x].childNodes[0].getAttribute("src") != null){
				    navItemXMLArray[totalItems][1] = xmlDoc.documentElement.childNodes[x].childNodes[0].getAttribute("src");
				    ccItems = 0
				    navItemXMLArray[totalItems][2] = new Array();
				    for (var c=0; c<xmlDoc.documentElement.childNodes[x].childNodes[0].childNodes.length; c++) {
					    if (xmlDoc.documentElement.childNodes[x].childNodes[0].childNodes[c].nodeType == 1) {
						    navItemXMLArray[totalItems][2][ccItems] = new Array();
						    navItemXMLArray[totalItems][2][ccItems][0] = xmlDoc.documentElement.childNodes[x].childNodes[0].childNodes[c].getAttribute("start");
						    navItemXMLArray[totalItems][2][ccItems][1] = xmlDoc.documentElement.childNodes[x].childNodes[0].childNodes[c].firstChild.nodeValue;
						    ccItems++;
					    }
				    }
				}
				//add subnav items if they exist
				if(xmlDoc.documentElement.childNodes[x].getElementsByTagName("Level2Item").length > 0){
				    navItemXMLArray[totalItems][3] = new Array();
				    for (var n=0; n < xmlDoc.documentElement.childNodes[x].getElementsByTagName("Level2Item").length; n++){
				        navItemXMLArray[totalItems][3][n] = new Array(3);
				        navItemXMLArray[totalItems][3][n][0] = xmlDoc.documentElement.childNodes[x].getElementsByTagName("Level2Item")[n].getAttribute("displaytext");
				        if(xmlDoc.documentElement.childNodes[x].getElementsByTagName("Level2Item")[n].childNodes[0].getAttribute("src") != null){
				            navItemXMLArray[totalItems][3][n][1] = xmlDoc.documentElement.childNodes[x].getElementsByTagName("Level2Item")[n].childNodes[0].getAttribute("src");
				            ccItems = 0
				            navItemXMLArray[totalItems][3][n][2] = new Array();
				            for (var c=0; c<xmlDoc.documentElement.childNodes[x].getElementsByTagName("Level2Item")[n].childNodes[0].childNodes.length; c++) {
					            if (xmlDoc.documentElement.childNodes[x].getElementsByTagName("Level2Item")[n].childNodes[0].childNodes[c].nodeType == 1) {
						         navItemXMLArray[totalItems][3][n][2][ccItems] = new Array();
						               navItemXMLArray[totalItems][3][n][2][ccItems][0] = xmlDoc.documentElement.childNodes[x].getElementsByTagName("Level2Item")[n].childNodes[0].childNodes[c].getAttribute("start");
						            navItemXMLArray[totalItems][3][n][2][ccItems][1] = xmlDoc.documentElement.childNodes[x].getElementsByTagName("Level2Item")[n].childNodes[0].childNodes[c].firstChild.nodeValue;
						            ccItems++;
					            }
				            }
				         }
				    }
			    }
				totalItems++;
			}
		}
	} else {
	    
		for (var x=0; x<xmlDoc.responseXML.documentElement.childNodes.length; x++) {
			if (xmlDoc.responseXML.documentElement.childNodes[x].nodeType == 1) {
			    
				navItemXMLArray[totalItems] = new Array(4);
				
				navItemXMLArray[totalItems][0] = xmlDoc.responseXML.documentElement.childNodes[x].getAttribute("displaytext");
				if(xmlDoc.responseXML.documentElement.childNodes[x].childNodes[0].getAttribute("src") != null){
				    navItemXMLArray[totalItems][1] = xmlDoc.responseXML.documentElement.childNodes[x].childNodes[0].getAttribute("src");
				    ccItems = 0
				    navItemXMLArray[totalItems][2] = new Array();
				    for (var c=0; c<xmlDoc.responseXML.documentElement.childNodes[x].childNodes[0].childNodes.length; c++) {
					    if (xmlDoc.responseXML.documentElement.childNodes[x].childNodes[0].childNodes[c].nodeType == 1) {
						    navItemXMLArray[totalItems][2][ccItems] = new Array();
						    navItemXMLArray[totalItems][2][ccItems][0] = xmlDoc.responseXML.documentElement.childNodes[x].childNodes[0].childNodes[c].getAttribute("start");
						    navItemXMLArray[totalItems][2][ccItems][1] = xmlDoc.responseXML.documentElement.childNodes[x].childNodes[0].childNodes[c].firstChild.nodeValue;
						    ccItems++;
					    }
				    }
				}
				//add subnav items if they exist
				if(xmlDoc.responseXML.documentElement.childNodes[x].getElementsByTagName("Level2Item").length > 0){
				    navItemXMLArray[totalItems][3] = new Array();
				    for (var n=0; n < xmlDoc.responseXML.documentElement.childNodes[x].getElementsByTagName("Level2Item").length; n++){
				        navItemXMLArray[totalItems][3][n] = new Array(3);
				        navItemXMLArray[totalItems][3][n][0] = xmlDoc.responseXML.documentElement.childNodes[x].getElementsByTagName("Level2Item")[n].getAttribute("displaytext");
				        if(xmlDoc.responseXML.documentElement.childNodes[x].getElementsByTagName("Level2Item")[n].childNodes[0].getAttribute("src") != null){
				            navItemXMLArray[totalItems][3][n][1] = xmlDoc.responseXML.documentElement.childNodes[x].getElementsByTagName("Level2Item")[n].childNodes[0].getAttribute("src");
				            ccItems = 0
				            navItemXMLArray[totalItems][3][n][2] = new Array();
				            for (var c=0; c<xmlDoc.responseXML.documentElement.childNodes[x].getElementsByTagName("Level2Item")[n].childNodes[0].childNodes.length; c++) {
					            if (xmlDoc.responseXML.documentElement.childNodes[x].getElementsByTagName("Level2Item")[n].childNodes[0].childNodes[c].nodeType == 1) {
						         navItemXMLArray[totalItems][3][n][2][ccItems] = new Array();
						               navItemXMLArray[totalItems][3][n][2][ccItems][0] = xmlDoc.responseXML.documentElement.childNodes[x].getElementsByTagName("Level2Item")[n].childNodes[0].childNodes[c].getAttribute("start");
						            navItemXMLArray[totalItems][3][n][2][ccItems][1] = xmlDoc.responseXML.documentElement.childNodes[x].getElementsByTagName("Level2Item")[n].childNodes[0].childNodes[c].firstChild.nodeValue;
						            ccItems++;
					            }
				            }
				         }
				    }
			    }
			    else{
			        navItemXMLArray[totalItems][3] = null;
			    }
				totalItems++;
			}
		}
	}
	if (musicLoopURL != null && musicLoopURL != "" && silverlightControl.content.findName("MusicLoop")) {
		silverlightControl.content.findName("MusicLoop").Source = musicLoopURL;
	}
	musicLoopInitialized = true;
	startSilverlightDemo();
}
startSilverlightDemo = function() {
	currentPlayingVid = 0;
	clearInterval(vidTimelineID);
	vidTimelineID = setInterval(vidTimeline, 1);
	setVolumeManual(1);
	unmuteAll();
	createDemoNavigation();
	startVid(currentPlayingVid);
}
createDemoNavigation = function() {
    //alert(silverlightControl.content.findName("NavButtonMove1")["Storyboard.TargetName"] = "NavigationButtonOff1");
    //var navAnimationStoryboard = silverlightControl.content.findName("LeftNavButton_Move");
    
	/*if (silverlightControl.content.findName("NavigationWindow")) {
		var w = Math.round(silverlightControl.content.findName("NavigationWindow").Width);
		var h = Math.round(silverlightControl.content.findName("NavigationWindow").Height/playlistXMLArray.length);
		//calculate Canvas.top for the first button based on number of buttons and height of the buttons
		var t = navigationWindowHeight - (playlistXMLArray.length   * navigationButtonHeight);
		for (var x=0; x<playlistXMLArray.length; x++) {
			var txt = playlistXMLArray[x][0];
			var xamlString = eval(navigationButtonXAML);
			xamlAdd = silverlightControl.content.createFromXaml(xamlString);
		  silverlightControl.content.findName("NavigationWindow").children.insert(x, xamlAdd);
		  setFont("NavigationTxt"+x, txt, navigationButtonTextAlignment);
		}
	}*/
	//silverlightControl.content.findName("NavButtonMove1")["Storyboard.TargetName"] = "NavigationButton0"
}
navButtonExpand_click = function(sender, mouseEventArgs){
    sender.findName("LeftNavButton_Move").begin();
}
demoNavigationReturnID = function(sender) {
	var senderName = sender.name;
	var buttonID = senderName.replace("NavItem","");
	return buttonID;
}
demoNavigationClick = function(sender, mouseEventArgs) {
    //if subnav items exist, open up subnav and move other items above accordingly
    //alert(sender.name);
    if (silverlightControl.content.findName("Sub" + sender.name)) {
        var levelID = demoNavigationReturnID(sender);

        //close sub nav if same nav is clicked
        if (levelID == openSubNavLevel) {
            for (var x = 0; x < 3; x++) {
                silverlightControl.content.findName("SubNavText" + levelID + "_" + x).Foreground = subNavInactiveFontColor;
            }            
            silverlightControl.content.findName("NavItems_MoveDownForSubNav" + levelID).begin();
            openSubNavLevel = -1;
            //if close the subnav, start the first video clip
            startVid(0);
        }
        //close other subnav if new subnav is selected
        else if (openSubNavLevel != -1) {
            for (var x = 0; x < 3; x++) {
                silverlightControl.content.findName("SubNavText" + openSubNavLevel + "_" + x).Foreground = subNavInactiveFontColor;
            }
            silverlightControl.content.findName("NavItems_MoveDownForSubNav" + openSubNavLevel).begin();
            silverlightControl.content.findName("NavItems_MoveUpForSubNav" + levelID).begin();
            rollOver(sender, mouseEventArgs);
            openSubNavLevel = levelID;
            //check if nav item has a video associated with top level
            if (navItemXMLArray[levelID][1] != null) {
                startVid(levelID);
            }
            else {
                startVidFromSubNavItem(levelID + "_0");
            }
        }
        else {
            //alert(levelID);
            silverlightControl.content.findName("NavItems_MoveUpForSubNav" + levelID).begin();
            //rollOver(sender, mouseEventArgs);
            //openSubNavLevel = levelID;
            //check if nav item has a video associated with top level
            if (navItemXMLArray[levelID][1] != null) {
                startVid(levelID);
            }
            else {
                startVidFromSubNavItem(levelID + "_0");
            }
            openSubNavLevel = levelID;
        }
    }
    else {
        //close open sub nav if applicable
        if (openSubNavLevel > -1) {
            silverlightControl.content.findName("NavItems_MoveDownForSubNav" + openSubNavLevel).begin();
        }
        openSubNavLevel = -1;
        startVid(demoNavigationReturnID(sender));
    }
}
demoNavigationRollOver = function(sender, mouseEventArgs) {
	if (currentPlayingVid != demoNavigationReturnID(sender)) {
		rollOver(sender, mouseEventArgs);
	}
}
demoNavigationRollOut = function(sender, mouseEventArgs) {
    if(openSubNavLevel == -1){
	    if (currentPlayingVid != demoNavigationReturnID(sender)) {
		    rollOut(sender, mouseEventArgs);
	    }
	}
	else{
	    if (demoSubNavigationReturnLevelID(currentPlayingVid) != demoNavigationReturnID(sender)) {
		    rollOut(sender, mouseEventArgs);
	    }
	}
}
demoSubNavigationLevelFromVid = function(vid){
        var tempArray = new Array();
	    tempArray = currentPlayingVid.split("_");
	    return tempArray[1];
}

demoSubNavigationReturnLevelID = function(vid) {

    if (vid.replace != null) {
        var buttonID = vid.replace("SubNavItem", "");
        var tempArray = new Array();

        tempArray = buttonID.split("_");
        var levelID = tempArray[0];
        return levelID;
    }
    else {
        return currentPlayingVid;
    }

}

demoSubNavigationReturnID = function(sender) {
	var senderName = sender.name;
	var buttonID = senderName.replace("SubNavItem","");
	return buttonID;
}
demoSubNavigationClick = function(sender, mouseEventArgs) {
	startVidFromSubNavItem(demoSubNavigationReturnID(sender));
}
demoSubNavigationRollOver = function(sender, mouseEventArgs) {
	if (currentPlayingVid != demoNavigationReturnID(sender)) {
	    sender.findName("SubNavText" + demoSubNavigationReturnID(sender)).Foreground = subNavActiveFontColor;
	}
}
demoSubNavigationRollOut = function(sender, mouseEventArgs) {
	if (currentPlayingVid != demoSubNavigationReturnID(sender)) {
		sender.findName("SubNavText" + demoSubNavigationReturnID(sender)).Foreground = subNavInactiveFontColor;
	}
}
onBodyResized = function() {
	var w = document.body.clientWidth;
	var h = document.body.clientHeight;
	var silverlightObj = document.getElementById('SilverlightControlHost');
	silverlightObj.style.minWidth = silverlightObjWidth+'px';
	silverlightObj.style.minHeight = silverlightObjHeight+'px';
	if(w < (silverlightObjWidth)) {
		silverlightObj.style.width = silverlightObjWidth+'px';
	} else {
		silverlightObj.style.width = "100%";
	}
	if(h < (silverlightObjHeight)) {
		silverlightObj.style.height = silverlightObjHeight+'px';
	} else {
		silverlightObj.style.height = "100%";
	}
	updateLayoutSize(silverlightControl.content.actualWidth, silverlightControl.content.actualHeight);
}
onResized = function(sender, eventArgs) {
	var silverlightObj = document.getElementById('SilverlightControlHost');
	var w = silverlightObj.style.width;
	var h = silverlightObj.style.height;
	if(w.indexOf('px') != -1){
		w = w.slice(0,-2);
	}
	if(h.indexOf('px') != -1){
		h = h.slice(0,-2);
	}
	if(w == "100%"){
		w = document.body.clientWidth;
	}
	if(h == "100%"){
		h = document.body.clientHeight;
	}
	updateLayoutSize(w, h);
}
updateLayoutSize = function(w, h) {
	silverlightControl.content.findName('DemoPlayer').Width = w;
	silverlightControl.content.findName('DemoPlayer').Height = h;
	silverlightControl.content.findName('Main')['Canvas.Left'] = Math.round((w-(silverlightObjWidth))/2);
	silverlightControl.content.findName('Main')['Canvas.Top'] = Math.round((h-(silverlightObjHeight))/2);
	if (silverlightControl.content.findName('DemoBackground')) {
		silverlightControl.content.findName('DemoBackground').Width = w;
		silverlightControl.content.findName('DemoBackground').Height = h;
	}
}
startVid = function(vid) {
    vidInitialized = true;
    if (silverlightControl.content.findName("PlayerEndButton")) {
        silverlightControl.content.findName("PlayerEndButton").Visibility = "Collapsed";
    }
    if (silverlightControl.content.findName("SolutionsMenu")) {
        silverlightControl.content.findName("SolutionsMenu").Visibility = "Collapsed";
    }
    clearInterval(window["NavItem" + vid + "Roll"]);
    currentPlayingVid = vid;
    if (silverlightControl.content.findName("NavigationWindow")) {
        for (var x = 0; x < navItemXMLArray.length; x++) {
            silverlightControl.content.findName("NavItem" + x + "Roll").Opacity = 0;
        }
        silverlightControl.content.findName("NavItem" + vid + "Roll").Opacity = 1;
    }
    var vidSource = navItemXMLArray[vid][1];
    if (vidSource != null && vidSource != "") {
        currentVidSource = vidSource;
        silverlightControl.content.findName("PlayerWindow").Source = vidSource;
        vidPlay();
        //silverlightControl.content.findName("PlayerWindow").Visibility = "Visible";
    }
}
startVidFromSubNavItem = function(vid) {
    var tempArray = new Array();
    tempArray = vid.split("_");
    var navButtonID = tempArray[0];

    vidInitialized = true;
    if (silverlightControl.content.findName("PlayerEndButton")) {
        silverlightControl.content.findName("PlayerEndButton").Visibility = "Collapsed";
    }
    clearInterval(window["NavItem" + navButtonID + "Roll"]);
    currentPlayingVid = vid;
    if (silverlightControl.content.findName("NavigationWindow")) {
        for (var x = 0; x < navItemXMLArray.length; x++) {
            silverlightControl.content.findName("NavItem" + x + "Roll").Opacity = 0;
        }
        for (var x = 0; x < 5; x++) {
            if (silverlightControl.content.findName("SubNavText" + navButtonID + "_" + x) != null) {
                silverlightControl.content.findName("SubNavText" + navButtonID + "_" + x).Foreground = subNavInactiveFontColor;
            }
        }
        silverlightControl.content.findName("NavItem" + navButtonID + "Roll").Opacity = 1;
        if (silverlightControl.content.findName("SubNavText" + vid) != null) {
            silverlightControl.content.findName("SubNavText" + vid).Foreground = subNavActiveFontColor;
        }
    }

    if (vid == "4_0") {
        currentPlayingVid = 4;
        openSubNavLevel = -1;
        nextVid();
    }
    else {
        var vidSource = navItemXMLArray[navButtonID][3][tempArray[1]][1];
        if (vidSource != null && vidSource != "") {
            currentVidSource = vidSource;
            silverlightControl.content.findName("PlayerWindow").Source = vidSource;
            vidPlay();
        }
    }
}
prevVid = function(){
	if(openSubNavLevel == -1){
	    if(currentPlayingVid != 0) {
	       
		    currentPlayingVid--;
		    //need to check if the new vid has subnav items.
		    if(navItemXMLArray[currentPlayingVid][3] != null){
		        openSubNavLevel = currentPlayingVid;
		        silverlightControl.content.findName("NavItems_MoveUpForSubNav" + currentPlayingVid).begin();
		        if(navItemXMLArray[currentPlayingVid][1] != null){
		            startVid(currentPlayingVid);
		        }
		        else{
		            currentPlayingVid = currentPlayingVid + "_0";
		            startVidFromSubNavItem(currentPlayingVid);
		        }
		    }
		    else{
		        startVid(currentPlayingVid);
		    }
	    }
	}
	 else{
	    //if the current Vid is not a subnavitem, it is the top level of the subnav
	    if(currentPlayingVid.toString().indexOf("_") == -1){
	        currentPlayingVid = openSubNavLevel - 1;
            silverlightControl.content.findName("NavItems_MoveDownForSubNav" + openSubNavLevel).begin();
	         //need to check if the new vid has subnav items.
	        openSubNavLevel = -1;
	        if(navItemXMLArray[currentPlayingVid][3] != null){
	            openSubNavLevel = currentPlayingVid;
	            silverlightControl.content.findName("NavItems_MoveUpForSubNav" + currentPlayingVid).begin();
	            if(navItemXMLArray[currentPlayingVid][1] != null){
		            startVid(currentPlayingVid);
		        }
		        else{
		            currentPlayingVid = currentPlayingVid + "_0";
		            startVidFromSubNavItem(currentPlayingVid);
		        }
	        }
	        else{
	            startVid(currentPlayingVid);
	        }
        }
	    //check if there are more items in the subnav to be played
	    else if(parseInt(demoSubNavigationLevelFromVid(currentPlayingVid)) > 0){
	            currentPlayingVid = demoSubNavigationReturnLevelID(currentPlayingVid) + "_" + (parseInt(demoSubNavigationLevelFromVid(currentPlayingVid)) - 1);
	            startVidFromSubNavItem(currentPlayingVid);
	      }
	      //check if there is a top level item to be played
	      else if(navItemXMLArray[openSubNavLevel][1] != null){
	        currentPlayingVid = openSubNavLevel;
	        //reset rollover state for subnav items
	        for (var x=0; x<3; x++) {
		            silverlightControl.content.findName("SubNavText"+ openSubNavLevel + "_" + x).Foreground = subNavInactiveFontColor;
	        }
	        startVid(currentPlayingVid);
	      }
	      else{
	         silverlightControl.content.findName("NavItems_MoveDownForSubNav" + demoSubNavigationReturnLevelID(currentPlayingVid)).begin();
	         openSubNavLevel = -1;
             currentPlayingVid = parseInt(demoSubNavigationReturnLevelID(currentPlayingVid)) - 1;
            //need to check if the new vid has subnav items.
	        if(navItemXMLArray[currentPlayingVid][3] != null){
	            openSubNavLevel = currentPlayingVid;
	            silverlightControl.content.findName("NavItems_MoveUpForSubNav" + currentPlayingVid).begin();
	            if(navItemXMLArray[currentPlayingVid][1] != null){
		            startVid(currentPlayingVid);
		        }
		        else{
		            currentPlayingVid = currentPlayingVid + "_0";
		            startVidFromSubNavItem(currentPlayingVid);
		        }
	        }
	        else{
	            startVid(currentPlayingVid);
	        }
	    }
	 }
}
nextVid = function() {
    //verify that the current playing is not from a section that has a subnav
    if (openSubNavLevel == -1) {
        if (currentPlayingVid < navItemXMLArray.length - 1) {
            currentPlayingVid++;
            if (navItemXMLArray[currentPlayingVid][3] != null) {
                openSubNavLevel = currentPlayingVid;
                silverlightControl.content.findName("NavItems_MoveUpForSubNav" + currentPlayingVid).begin();
                if (navItemXMLArray[currentPlayingVid][1] != null) {
                    startVid(currentPlayingVid);
                }
                else {
                    currentPlayingVid = currentPlayingVid + "_0";
                    //                    alert(currentPlayingVid);
                    startVidFromSubNavItem(currentPlayingVid);
                }
            }
            else {
                //need to check if the previous item also contains subnav items.  if so, need to open up the subnav
                //                alert(currentPlayingVid);
                startVid(currentPlayingVid);

            }
        }
    }
    //current item is from a section that has a subnav. 
    else {
        //if the current Vid is not a subnavitem, it is the top level of the subnav
        if (currentPlayingVid.toString().indexOf("_") == -1) {
            currentPlayingVid = currentPlayingVid + "_0";
            //            alert(currentPlayingVid);
            startVidFromSubNavItem(currentPlayingVid);
        }
        //check if the subnav item has any more subnav items after it
        else if (demoSubNavigationLevelFromVid(currentPlayingVid) < navItemXMLArray[demoSubNavigationReturnLevelID(currentPlayingVid)][3].length - 1) {
            var subNavLevel = parseInt(demoSubNavigationLevelFromVid(currentPlayingVid)) + 1;
            currentPlayingVid = demoSubNavigationReturnLevelID(currentPlayingVid) + "_" + subNavLevel;
            //            alert(currentPlayingVid);
            startVidFromSubNavItem(currentPlayingVid);
        }
        //if no more subnav items, go to the next main nav item
        else {
            if (demoSubNavigationReturnLevelID(currentPlayingVid) < navItemXMLArray.length - 1) {
                var navItemID = demoSubNavigationReturnLevelID(currentPlayingVid);
                currentPlayingVid = parseInt(navItemID) + 1;
                silverlightControl.content.findName("NavItems_MoveDownForSubNav" + navItemID).begin();
                //reset rollover state for subnav items
                for (var x = 0; x < 3; x++) {
                    silverlightControl.content.findName("SubNavText" + navItemID + "_" + x).Foreground = subNavInactiveFontColor;
                }
                openSubNavLevel = -1;
                //need to check if next main item has subnav items
                if (navItemXMLArray[currentPlayingVid][3] != null) {
                    if (currentPlayingVid == 3 && playMode == "admin") {
                        currentPlayingVid++;
                    }
                    openSubNavLevel = currentPlayingVid;
                    if (silverlightControl.content.findName("NavItems_MoveUpForSubNav" + currentPlayingVid) != null) {
                        silverlightControl.content.findName("NavItems_MoveUpForSubNav" + currentPlayingVid).begin();
                    }
                    //need to check if main item has a video associated with it.  If so, start there.
                    if (navItemXMLArray[currentPlayingVid][1] != null) {
                        startVid(currentPlayingVid);
                    }
                    else {
                        currentPlayingVid = currentPlayingVid + "_0";
                        startVidFromSubNavItem(currentPlayingVid);
                    }
                }
                else {
                    startVid(currentPlayingVid);
                }
            }
        }
    }
}
vidPlay = function(){
	silverlightControl.content.findName("PlayerWindow").play();
	if (silverlightControl.content.findName("MusicLoop")) {
		silverlightControl.content.findName("MusicLoop").play();
	}
	if (silverlightControl.content.findName("PauseButton")) {
		silverlightControl.content.findName("PauseButton").Visibility = "Visible";
	}
	if (silverlightControl.content.findName("PauseIcon")) {
		silverlightControl.content.findName("PauseIcon").Visibility = "Visible";
	}
	if (silverlightControl.content.findName("PlayButton")) {
		silverlightControl.content.findName("PlayButton").Visibility = "Collapsed";
	}
	if (silverlightControl.content.findName("PlayIcon")) {
		silverlightControl.content.findName("PlayIcon").Visibility = "Collapsed";
	}
}
vidPause = function(){
	silverlightControl.content.findName("PlayerWindow").pause();
	if (silverlightControl.content.findName("MusicLoop")) {
		silverlightControl.content.findName("MusicLoop").pause();
	}
	if (silverlightControl.content.findName("PauseButton")) {
		silverlightControl.content.findName("PauseButton").Visibility = "Collapsed";
	}
	if (silverlightControl.content.findName("PauseIcon")) {
		silverlightControl.content.findName("PauseIcon").Visibility = "Collapsed";
	}
	if (silverlightControl.content.findName("PlayButton")) {
		silverlightControl.content.findName("PlayButton").Visibility = "Visible";
	}
	if (silverlightControl.content.findName("PlayIcon")) {
		silverlightControl.content.findName("PlayIcon").Visibility = "Visible";
	}
}
vidEnd = function() {
    //silverlightControl.content.findName("PlayerWindow").Visibility = "Collapsed";
    //alert("videEnd: " + currentPlayingVid);
    if (vidInitialized) {
        if (currentPlayingVid == navItemXMLArray.length - 1) {
            if (playerLoop == true) {
                startVid(0);
            } else {
                if (silverlightControl.content.findName("PlayerEndButton")) {
                    silverlightControl.content.findName("PlayerEndButton").Visibility = "Visible";
                }
            }
        } else {
            nextVid();
        }
    }
}
vidTimeline = function() {
    var p = silverlightControl.content.findName("PlayerWindow").position.seconds;
    if (doDragTime == false && silverlightControl.content.findName("TimeIndicatorEmpty")) {
        var d = silverlightControl.content.findName("PlayerWindow").naturalDuration.seconds;
        var w = silverlightControl.content.findName("TimeIndicatorEmpty").Width - silverlightControl.content.findName("TimeSliderGripper").Width;
        if (d != 0 && p < d) {
            silverlightControl.content.findName("TimeSliderGripper")["Canvas.Left"] = ((p * w) / d) + (silverlightControl.content.findName("TimeIndicatorEmpty")["Canvas.Left"]);
            silverlightControl.content.findName("TimeIndicatorFull").Width = ((p * w) / d);
        }
    }
    //check if subnav item is playing.  If so, pull cc items from SubNav level
    if ((openSubNavLevel == -1) || (openSubNavLevel != -1 && currentPlayingVid.toString().indexOf("_") == -1)) {
        for (var cc = 0; cc < navItemXMLArray[currentPlayingVid][2].length; cc++) {
            var syncStart = navItemXMLArray[currentPlayingVid][2][cc][0];
            if (syncStart <= p) {
                var passTxt = navItemXMLArray[currentPlayingVid][2][cc][1];
                setFont("CCText", passTxt, "center");
            }
        }
    }
    else {

        var tempArray = new Array();
        tempArray = currentPlayingVid.split("_");
        for (var cc = 0; cc < navItemXMLArray[demoSubNavigationReturnLevelID(currentPlayingVid)][3][tempArray[1]][2].length; cc++) {
            var syncStart = navItemXMLArray[demoSubNavigationReturnLevelID(currentPlayingVid)][3][tempArray[1]][2][cc][0];
            if (syncStart <= p) {
                var passTxt = navItemXMLArray[demoSubNavigationReturnLevelID(currentPlayingVid)][3][tempArray[1]][2][cc][1];
                setFont("CCText", passTxt, "center");
            }
        }
    }
    if (silverlightControl.content.findName("PlayerCurrentTime")) {
        silverlightControl.content.findName("PlayerCurrentTime").Text = returnTimeMinutes(p) + ":" + returnTimeSeconds(p);
    }
    if (silverlightControl.content.findName("PlayerTotalTime")) {
        silverlightControl.content.findName("PlayerTotalTime").Text = returnTimeMinutes(d) + ":" + returnTimeSeconds(d);
    }
    if (currentPlayingVid == 1 && returnTimeMinutes(p) == 1 && returnTimeSeconds(p) == 50 && isPaused == false) {
        if (silverlightControl.content.findName("PlayerWindow") != null) {
            silverlightControl.content.findName("PlayerWindow").Pause();
            isPaused = true;
            ShowSolutionLandingPage();
        }
    }

    if (currentPlayingVid == 5 && returnTimeMinutes(p) == 0 && returnTimeSeconds(p) == 20 && isPaused == false) {
        if (silverlightControl.content.findName("PlayerWindow") != null) {
            silverlightControl.content.findName("PlayerWindow").Pause();
            isPaused = true;
            ShowConclusionLandingPage();
        }
    }

}

ShowSolutionLandingPage = function() {
    if (silverlightControl.content.findName("SolutionsMenu") != null) {
        silverlightControl.content.findName("SolutionsMenu").visibility = "visible";
        if (silverlightControl.content.findName("ShowSolutionsMenu") != null) {
            silverlightControl.content.findName("ShowSolutionsMenu").begin();
        }
        if (silverlightControl.content.findName("imgSolutionBG") != null) {
            silverlightControl.content.findName("imgSolutionBG").opacity = 1;
        }
        if (silverlightControl.content.findName("imgConclusionBG") != null) {
            silverlightControl.content.findName("imgConclusionBG").opacity = 0;
        }
        if (silverlightControl.content.findName("CTA") != null) {
            silverlightControl.content.findName("CTA").visibility = "collapsed";
        }
    }
}

ShowConclusionLandingPage = function() {
    if (silverlightControl.content.findName("SolutionsMenu") != null) {
        silverlightControl.content.findName("SolutionsMenu").visibility = "visible";
        if (silverlightControl.content.findName("ShowSolutionsMenu") != null) {
            silverlightControl.content.findName("ShowSolutionsMenu").begin();
        }
        if (silverlightControl.content.findName("imgSolutionBG") != null) {
            silverlightControl.content.findName("imgSolutionBG").opacity = 0;
        }
        if (silverlightControl.content.findName("imgConclusionBG") != null) {
            silverlightControl.content.findName("imgConclusionBG").opacity = 1;
        }
        if (silverlightControl.content.findName("CTA") != null) {
            silverlightControl.content.findName("CTA").visibility = "visible";
        }
    }
}

ShowLandingPage = function() {
    if (silverlightControl.content.findName("btnAdmin") != null) {
        silverlightControl.content.findName("btnAdmin").Visibility = "Visible";
    }
    if (silverlightControl.content.findName("btnUser") != null) {
        silverlightControl.content.findName("btnUser").Visibility = "Visible";
    }
    if (silverlightControl.content.findName("btnPlayAll") != null) {
        silverlightControl.content.findName("btnPlayAll").Visibility = "Visible";
    }
}

HideLandingPage = function() {
    if (silverlightControl.content.findName("SolutionsMenu") != null) {
        silverlightControl.content.findName("SolutionsMenu").opacity = 0;
        silverlightControl.content.findName("SolutionsMenu").visibility = "collapsed";
    }
    isPaused = false;
    nextVid();
}


returnTimeMinutes = function (t) {
	var timeString = String(Math.floor((t/60))%60);
	var formattedTime = formatTimeString(timeString);
	return formattedTime;
}
returnTimeSeconds = function (t) {
	var timeString = String(Math.floor(t)%60);
	var formattedTime = formatTimeString(timeString);
	return formattedTime;
}
formatTimeString = function (t) {
	if (t == "NaN") {
		t = "0";
	}
	if (t.length < 2) {
		t = "0"+t;
	}
	return t;
}
musicLoopRepeat = function(sender, args){
	if (musicLoopInitialized == true) {
		var pos = sender.position;
		pos.seconds = 0;
		sender.position = pos;
		sender.play();
	}
}
muteAll = function() {
	silverlightControl.content.findName("PlayerWindow").IsMuted = "True";
	if (silverlightControl.content.findName("MusicLoop")) {
		silverlightControl.content.findName("MusicLoop").IsMuted = "True";
	}
	if (silverlightControl.content.findName("MuteIcon")) {
		silverlightControl.content.findName("MuteIcon").visibility = "Collapsed";
	}
	if (silverlightControl.content.findName("MuteButton")) {
		silverlightControl.content.findName("MuteButton").visibility = "Collapsed";
	}
	if (silverlightControl.content.findName("UnmuteIcon")) {
		silverlightControl.content.findName("UnmuteIcon").visibility = "Visible";
	}
	if (silverlightControl.content.findName("UnmuteButton")) {
		silverlightControl.content.findName("UnmuteButton").visibility = "Visible";
	}
}
unmuteAll = function() {
	silverlightControl.content.findName("PlayerWindow").IsMuted = "False";
	if (silverlightControl.content.findName("MusicLoop")) {
		silverlightControl.content.findName("MusicLoop").IsMuted = "False";
	}
	if (silverlightControl.content.findName("MuteIcon")) {
		silverlightControl.content.findName("MuteIcon").visibility = "Visible";
	}
	if (silverlightControl.content.findName("MuteButton")) {
		silverlightControl.content.findName("MuteButton").visibility = "Visible";
	}
	if (silverlightControl.content.findName("UnmuteIcon")) {
		silverlightControl.content.findName("UnmuteIcon").visibility = "Collapsed";
	}
	if (silverlightControl.content.findName("UnmuteButton")) {
		silverlightControl.content.findName("UnmuteButton").visibility = "Collapsed";
	}
}
setVolumeUp = function () {
	var v = silverlightControl.content.findName("PlayerWindow").Volume;
	v += .1;
	if (v > 1) {
		v = 1;
	}
	setVolumeManual(v);
}
setVolumeDown = function () {
	var v = silverlightControl.content.findName("PlayerWindow").Volume;
	v -= .1;
	if (v < 0) {
		v = 0;
	}
	setVolumeManual(v);
}
setVolumeManual = function(v) {
	silverlightControl.content.findName("PlayerWindow").Volume = v;
	if (silverlightControl.content.findName("MusicLoop")) {
		silverlightControl.content.findName("MusicLoop").Volume = (v)*musicLoopVolumeMultiplier;
	}
	if (silverlightControl.content.findName("VolumeIndicatorEmpty")) {
		var posSet = (((silverlightControl.content.findName("VolumeIndicatorEmpty").Width-silverlightControl.content.findName("VolumeSliderGripper").Width)*v)/1);
		silverlightControl.content.findName("VolumeSliderGripper")["Canvas.Left"] = posSet+silverlightControl.content.findName("VolumeIndicatorEmpty")["Canvas.Left"]
		silverlightControl.content.findName("VolumeIndicatorFull").Width = posSet;
	}
};
setFont = function(textElement, txt, align) {
	if (silverlightControl.content.findName(textElement)) {
		silverlightControl.content.findName(textElement).Text = txt;
		var w = silverlightControl.content.findName(textElement).actualWidth;
		if (align == "right") {
			silverlightControl.content.findName(textElement)["Canvas.Left"] = silverlightControl.content.findName(textElement).width-w;
		} else if (align == "center") {
			silverlightControl.content.findName(textElement)["Canvas.Left"] = (silverlightControl.content.findName(textElement).width-w)/2;
		}
	}
}

btnAdminClick = function(sender, args) {    
    currentPlayingVid = 1;
    playMode = "admin";
    HideLandingPage();
}

btnAdminOver = function(sender, args) {
    if (silverlightControl.content.findName("AdminOver") != null) {
        silverlightControl.content.findName("AdminOver").Begin();
    }
}

btnAdminLeave = function(sender, args) {
    if (silverlightControl.content.findName("AdminLeave") != null) {
        silverlightControl.content.findName("AdminLeave").Begin();
    }
}

btnUserOver = function(sender, args) {
    if (silverlightControl.content.findName("UserOver") != null) {
        silverlightControl.content.findName("UserOver").Begin();
    }
}

btnUserLeave = function(sender, args) {
    if (silverlightControl.content.findName("UserLeave") != null) {
        silverlightControl.content.findName("UserLeave").Begin();
    }
}

btnUserClick = function(sender, args) {
    playMode = "user";
    currentPlayingVid = 2;
    HideLandingPage();
}

btnPlayAllOver = function(sender, args) {
    if (silverlightControl.content.findName("PlayAllOver") != null) {
        silverlightControl.content.findName("PlayAllOver").Begin();
    }
}

btnPlayAllLeave = function(sender, args) {
    if (silverlightControl.content.findName("PlayAllLeave") != null) {
        silverlightControl.content.findName("PlayAllLeave").Begin();
    }
}

btnPlayAllClick = function(sender, args) {
    currentPlayingVid = 1;
    playMode = "all";
    HideLandingPage();
}

keyboardEvents = function(sender, keyEventArgs) {
	if (keyEventArgs.key == 64) {
		silverlightControl.content.fullScreen = !silverlightControl.content.fullScreen;
	}
}
clickEvents = function(sender, mouseEventArgs) {
    if (sender.name == "PrevButton") {
        prevVid();
    } else if (sender.name == "NextButton") {
        nextVid();
    } else if (sender.name == "PlayButton") {
        vidPlay();
    } else if (sender.name == "PauseButton") {
        vidPause();
    } else if (sender.name == "TimeSliderButton") {
        doDragTime = false;
    } else if (sender.name == "VolumeSliderButton") {
        doDragVol = false;
    } else if (sender.name == "MuteButton") {
        muteAll();
    } else if (sender.name == "UnmuteButton") {
        unmuteAll();
    } else if (sender.name == "CCButton") {
        if (CCOn == false) {
            CCOn = true;
            silverlightControl.content.findName("TIMELINE_ShowCC").begin();
        } else {
            CCOn = false;
            silverlightControl.content.findName("TIMELINE_HideCC").begin();
        }
    } else if (sender.name == "ToggleFullScreenButton") {
        silverlightControl.content.fullScreen = !silverlightControl.content.fullScreen;
    } else if (sender.name == "ToggleOnLoopPlaybackButton") {
        setLoop(true);
    } else if (sender.name == "ToggleOffLoopPlaybackButton") {
        setLoop(false);
    } else if (sender.name == "VolumeUpButton") {
        setVolumeUp();
    } else if (sender.name == "VolumeDownButton") {
        setVolumeDown();
    }
}
setLoop = function(looping) {
	if (looping == true) {
		if (silverlightControl.content.findName("ToggleOnLoopPlaybackButton")) {
			silverlightControl.content.findName("ToggleOnLoopPlaybackButton").Visibility = "Collapsed";
		}
		if (silverlightControl.content.findName("ToggleOnLoopPlaybackIcon")) {
			silverlightControl.content.findName("ToggleOnLoopPlaybackIcon").Visibility = "Collapsed";
		}
		if (silverlightControl.content.findName("ToggleOffLoopPlaybackButton")) {
			silverlightControl.content.findName("ToggleOffLoopPlaybackButton").Visibility = "Visible";
		}
		if (silverlightControl.content.findName("ToggleOffLoopPlaybackIcon")) {
			silverlightControl.content.findName("ToggleOffLoopPlaybackIcon").Visibility = "Visible";
		}
		playerLoop = true;
	} else {
		if (silverlightControl.content.findName("ToggleOnLoopPlaybackButton")) {
			silverlightControl.content.findName("ToggleOnLoopPlaybackButton").Visibility = "Visible";
		}
		if (silverlightControl.content.findName("ToggleOnLoopPlaybackIcon")) {
			silverlightControl.content.findName("ToggleOnLoopPlaybackIcon").Visibility = "Visible";
		}
		if (silverlightControl.content.findName("ToggleOffLoopPlaybackButton")) {
			silverlightControl.content.findName("ToggleOffLoopPlaybackButton").Visibility = "Collapsed";
		}
		if (silverlightControl.content.findName("ToggleOffLoopPlaybackIcon")) {
			silverlightControl.content.findName("ToggleOffLoopPlaybackIcon").Visibility = "Collapsed";
		}
		playerLoop = false;
	}	
}
rollOver = function(sender, mouseEventArgs) {
	clearInterval(window[sender.name+"Roll"]);
	window[sender.name+"Roll"] = setInterval( function () {
	    var theName = sender.Name;
		silverlightControl.content.findName(sender.name+"Roll").Opacity += 0.05;
		if (silverlightControl.content.findName(sender.name+"Roll").Opacity >= 1) {
			silverlightControl.content.findName(sender.name+"Roll").Opacity = 1;
			clearInterval(window[sender.name+"Roll"]);
		}
	}, 1);
}
rollOut = function(sender, mouseEventArgs) {
	clearInterval(window[sender.name+"Roll"]);
	window[sender.name+"Roll"] = setInterval( function () {
	    var theName = sender.Name;
		silverlightControl.content.findName(sender.name+"Roll").Opacity += -(0.01);
		if (silverlightControl.content.findName(sender.name+"Roll").Opacity <= 0) {
			silverlightControl.content.findName(sender.name+"Roll").Opacity = 0;
			clearInterval(window[sender.name+"Roll"]);
		}
	}, 1);
}
leaveEvents = function(sender, mouseEventArgs) {
	if(sender.name == "TimeSliderButton"){
		doDragTime = false;
	} else if(sender.name == "VolumeSliderButton") {
		doDragVol = false;
	}
	rollOut(sender, mouseEventArgs);
}
outEvents = function(sender, mouseEventArgs){
	if(sender.name == "TimeSliderButton"){
		doDragTime = false;
	} else if(sender.name == "VolumeSliderButton") {
		doDragVol = false;
	}
	rollOut(sender, mouseEventArgs);
}
pressEvents = function(sender, mouseEventArgs) {
	if(sender.name == "TimeSliderButton"){
		doDragTime = true;
	} else if(sender.name == "VolumeSliderButton") {
		doDragVol = true;
	}
}
dragEvents = function(sender, mouseEventArgs) {
	if (sender.name == "TimeSliderButton" && doDragTime == true) {
		var coordinate = mouseEventArgs.getPosition(sender).x;		
		var d = silverlightControl.content.findName("PlayerWindow").naturalDuration.seconds;
		var w = silverlightControl.content.findName("TimeIndicatorEmpty").Width-silverlightControl.content.findName("TimeSliderGripper").Width;
		if (d != 0) {
			var dragPos = coordinate+(silverlightControl.content.findName("TimeIndicatorEmpty")["Canvas.Left"]);
			if (dragPos <= (w+(silverlightControl.content.findName("TimeIndicatorEmpty")["Canvas.Left"]))) {
				silverlightControl.content.findName("TimeSliderGripper")["Canvas.Left"] = dragPos;
				silverlightControl.content.findName("TimeIndicatorFull").Width = coordinate;
				var seconds = ((d*coordinate)/w);
				var pos = silverlightControl.content.findName("PlayerWindow").position;
				pos.seconds = seconds;
				silverlightControl.content.findName("PlayerWindow").position = pos;
			}
		}
	} else if(sender.name == "VolumeSliderButton" && doDragVol == true) {
		var coordinate = mouseEventArgs.getPosition(sender).x+silverlightControl.content.findName("VolumeSliderButton")["Canvas.Left"];
		var dragVolLeftStart = silverlightControl.content.findName("VolumeIndicatorEmpty")["Canvas.Left"];
		var dragVolLeftEnd = silverlightControl.content.findName("VolumeIndicatorEmpty")["Canvas.Left"]+silverlightControl.content.findName("VolumeIndicatorEmpty").Width;
		if (coordinate >= dragVolLeftStart && coordinate <= dragVolLeftEnd) {
			var v = Math.round(((coordinate-dragVolLeftStart)*100)/silverlightControl.content.findName("VolumeIndicatorEmpty").Width);
			setVolumeManual((v/100));
		}
	} 
}
retrySourceMediaElement = function(sender, eventArgs) {
	var pos = sender.position;
	sender.Source = currentVidSource;
	sender.position = pos;
}
endURL = function() {
	open(actionURL,"_blank");
}
cleanWhiteSpace = function(node)
{
    var notWhitespace = /\S/;
    for (var x = 0; x < node.childNodes.length; x++)
    {
        var childNode = node.childNodes[x];
        if ((childNode.nodeType == 3) && (!notWhitespace.test(childNode.nodeValue))){
            node.removeChild(node.childNodes[x]);
            x--;
        }
        if (childNode.nodeType == 1) {
            cleanWhiteSpace(childNode)
        }
    }
}

AdminButtonMouseEnter = function(sender, args) {
    if (silverlightControl.content.findName("AdminButtonEnter") != null) {
        silverlightControl.content.findName("AdminButtonEnter").begin();
    }
}

AdminButtonMouseLeave = function(sender, args) {
    if (silverlightControl.content.findName("AdminButtonLeave") != null) {
        silverlightControl.content.findName("AdminButtonLeave").begin();
    }
}

UserButtonMouseEnter = function(sender, args) {
    if (silverlightControl.content.findName("UserButtonEnter") != null) {
        silverlightControl.content.findName("UserButtonEnter").begin();
    }
}

UserButtonMouseLeave = function(sender, args) {
    if (silverlightControl.content.findName("UserButtonLeave") != null) {
        silverlightControl.content.findName("UserButtonLeave").begin();
    }
}

PlayAllButtonMouseEnter = function(sender, args) {
    if (silverlightControl.content.findName("PlayAllButtonEnter") != null) {
        silverlightControl.content.findName("PlayAllButtonEnter").begin();
    }
}

PlayAllButtonMouseLeave = function(sender, args) {
if (silverlightControl.content.findName("PlayAllButtonLeave") != null) {
    silverlightControl.content.findName("PlayAllButtonLeave").begin();
    }
}

