// sliverlight status enumeration
var SilverStatus = { Unknown: 0, Install: 1, Upgrade: 2, Silver: 3 };
// default sliverlight install status
var SilverInstalled = SilverStatus.Unknown;

// Test for SilverlightVersion
function TestSilverVersion(sender) {
// if previous test occured the minium value will be install
 if (!SilverInstalled == SilverStatus.Install) {
     var host = sender.getHost();
     // Silverlight container test
     if (host) {
	 if (host.type == "application/x-silverlight-2" || host.type == "application/x-silverlight") {
	     // we know it is silverlight
	     SilverInstalled = SilverStatus.Silver;
	     // test for a known upgrade requirement (else rely on silverlight internals)
	     for (i = 0; i < host.childNodes.length; i++) {
		 if (host.childNodes[i].name == "minRuntimeVersion") {
		     // test if the plug supports the minium installed
		     if (!host.IsVersionSupported(host.childNodes[i].value)) {

			 SilverInstalled = SilverStatus.Upgrade;

			 // clone and disable the silverlight control
			  var clone = host.cloneNode(true);
			  if (clone) {
			      //remove the type attribute to force fallback
			      clone.removeAttribute("type");
			      // need this to add empty alt content IE glitch
			      clone.altHtml = "";
			      // remove onload event in clone to prevent refiring
			      var s;
			      for (i = 0; i < clone.childNodes.length; i++) {
				  s = clone.childNodes[i];
				  if (clone.childNodes[i].nodeName == "PARAM") {
				      if (clone.childNodes[i].name == "OnLoad") { clone.childNodes[i].value = null; }
				  }
			      }
			      host.parentNode.replaceChild(clone, host);
			  }      
		     }
		 }
	     }
	 } else { SilverInstalled = SilverStatus.Install; }
     } else { SilverInstalled = SilverStatus.Install; }

 }
 //alert(SilverInstalled);
}

function onPhotoWall(sender) {
 TestSilverVersion(sender);
 if (SilverInstalled == SilverStatus.Upgrade) {
     ProcessAltWallContent();
 }
}

function ProcessAltWallContent() {
 var oAlt = document.getElementById("PhotoSilverMsgBox");
 if (oAlt) {
     var oMsg = document.getElementById("SilverMsg");
     oMsg.innerHTML = "You need to upgrade you silverlight version to see this site"
 }
}
function onLogoScroller(sender) {
 //TestSilverVersion(sender);
 //if (SilverInstalled == SilverStatus.Upgrade) {
 //    ProcessAltWallContent();
 //}
}
