

m_PlayerMode = SetPlayerMode();




function SetPlayerMode()
{
	var boolSilverlight = isSilverlightInstalled();
	if(boolSilverlight==true)
	{
		return "SilverLight";
	}
	else
	{
		return "Html";
	}
	
	//return "Html";
}

function LoadCorrectPlayer() {

   
	// show html
	if(m_PlayerMode=="Html")
	{
		
		document.getElementById('silverlightControlHost').style.display='none';
		document.getElementById('htmlControlHost').style.visibility='visible';
		
		// write out player
		WriteWindowsMediaPlayer(sStreamsource);
	
		// show info that they should get silverlight
		document.getElementById('getSilverlighControlHost').style.visibility = 'visible';

	}
	// show silverlight
	else
	{
		//alert("show silverlight");
		 document.getElementById('htmlControlHost').style.display='none'
		 document.getElementById('getSilverlighControlHost').style.display = 'none';
	}
}

	 
    function isSilverlightInstalled()
        {
            var isSilverlightInstalled = false;
            
            try
            {
                //check on IE
                try
                {
                    var slControl = new ActiveXObject('AgControl.AgControl');
                    isSilverlightInstalled = true;
                }
                catch (e)
                {
                    //either not installed or not IE. Check Firefox
                    if ( navigator.plugins["Silverlight Plug-In"] )
                    {
                        isSilverlightInstalled = true;
                    }
                }
            }
            catch (e)
            {
                //we don't want to leak exceptions. However, you may want
                //to add exception tracking code here.
            }
            return isSilverlightInstalled;
        }

function ExpandSilverInfo() {
    document.getElementById('getSilverlighControlHost').style.height='200px';
    //AddClassToDiv('getSilverlighControlHost', 'mouseOver');
}

function CloseSilverInfo()
{
    document.getElementById('getSilverlighControlHost').style.height='45px';
    //AddClassToDiv('getSilverlighControlHost', 'mouseOut');
}

// ---------------------------------------------------------------------
// Methods for writing out embeded players
// ---------------------------------------------------------------------

function WriteWindowsMediaPlayer(VideoSource) {

    is_wm = true;

    var ObjectTag = "<OBJECT ID=\"MediaPlayer\" name=\"MediaPlayer\" WIDTH=\"" + iWidth + "\" HEIGHT=\"" + iHeight + "\" CLASSID=\"CLSID:22D6f312-B0F6-11D0-94AB-0080C74C7E95\" CODEBASE=\"http://www.microsoft.com/ntserver/netshow/download/en/nsmp2inf.cab#Version=5,1,51,415\" standby=\"Loading Microsoft Media Player components...\" type=\"application/x-oleobject\">";
    ObjectTag += "<PARAM NAME=\"AutoStart\" VALUE=\"1\">";
    ObjectTag += "<PARAM NAME=\"FileName\" VALUE=\"" + VideoSource + "\">";
    ObjectTag += "<PARAM NAME=\"ShowControls\" VALUE=\"" + Controls + "\">";
    ObjectTag += "<PARAM NAME=\"ShowPositionControls\" VALUE=\"0\">";
    ObjectTag += "<PARAM NAME=\"ShowStatusBar\" VALUE=\"" + StatusBar + "\">";
    ObjectTag += "<PARAM NAME=\"AutoSize\" VALUE=\"0\">";
    ObjectTag += "<PARAM NAME=\"ControlType\" VALUE=\"0\">";
    ObjectTag += "<PARAM NAME=\"ShowTracker\" VALUE=\"" + Tracker + "\">";
    ObjectTag += "<PARAM NAME=\"InvokeURLs\" VALUE=\"1\">";
    ObjectTag += "<EMBED Type=\"video/x-ms-asf-plugin\" pluginspage=\"http://www.microsoft.com/windows/mediaplayer/download/default.asp\" src=\"" + VideoSource + "\" name=\"MediaPlayer\" AutoStart=\"1\" ShowPositionControls=\"0\" ShowControls=\"" + Controls + "\" ShowStatusBar=\"" + StatusBar + "\" AutoSize=\"0\" width=\"" + iWidth + "\" height=\"" + iHeight + "\" DefaultFrame=\"script\" ShowTracker=\"" + Tracker + "\">";
    ObjectTag += "</OBJECT>";

    //videoDiv.innerHTML = ObjectTag;
   
    document.write(ObjectTag);
}

function PrintSilverlightMissing(ShowClose) {
	
	document.getElementById('getSilverlighControlHost').style.width=iWidth +"px";
	
	var ObjectTag = "<!-- this will show if they do not have silverlight and our custom check has failed-->";
	ObjectTag += "	I Internet Explorer med Windows Media Player, p&aring; en dator med Windows XP, Vista eller Windows 7, kan man se v&aring;ra s&auml;ndningar utan <a href=\"http://go.microsoft.com/fwlink/?LinkID=124807\" style=\"text-decoration: none;\">Microsoft Silverlight</a>.<br />";
			ObjectTag += "<a href=\"http://go.microsoft.com/fwlink/?LinkID=124807\" style=\"text-decoration: none;\">Microsoft Silverlight</a> &auml;r den plugin vi rekommenderar f&ouml;r att ta del av v&aring;ra s&auml;ndningar.";
			ObjectTag += "<br /><br />";
			ObjectTag += "Med Microsoft Silverlight kan v&aring;ra s&auml;ndningar ses i ex. Firefox, Safari (&auml;ven under Mac Os X) och Google Chrome f&ouml;rutom Internet Explorer.";
			ObjectTag += "<br /><br />";
			ObjectTag += "Genom att klicka p&aring; nedanst&aring;ende bild kan du ladda hem <a href=\"http://go.microsoft.com/fwlink/?LinkID=124807\" style=\"text-decoration: none;\">Microsoft Silverlight</a>";
			ObjectTag += "<br /><br />";
			ObjectTag += "Efter att du har installerat <a href=\"http://go.microsoft.com/fwlink/?LinkID=124807\" style=\"text-decoration: none;\">Microsoft Silverlight</a> kan du beh&ouml;va starta om webbl&auml;saren.";
			ObjectTag += "<br /><br />";
			ObjectTag += "<a href=\"http://go.microsoft.com/fwlink/?LinkID=124807\" style=\"text-decoration: none;\">";
     		ObjectTag += "	<img src=\"Video/_Images/InstallSilverlight.png\" alt=\"Get Microsoft Silverlight\" style=\"border-style: none\"/>";
			ObjectTag += "</a>";
			ObjectTag += "<!-- this will show if they do not have silverlight and our custom check has failed-->";
			ObjectTag += "<br /><br />";
			if(ShowClose=="true")
			{
			    ObjectTag += "<a href=\"javascript:;\" onclick=\"document.getElementById('getSilverlighControlHost').style.display='none'\">St&auml;ng denna information</a>";
			    ObjectTag += "<br /><br />";
			  }
			document.write(ObjectTag);
   }

function WriteSilverlightMediaPlayer() {

    // show html
	if(m_PlayerMode!="Html")
	{
    var ObjectTag = "<object data=\"data:application/x-silverlight-2,\" type=\"application/x-silverlight-2\" width=\""+ iWidth +"\" height=\""+ iHeight +"\" id=\"StreamsyncSilverlight\">";
    ObjectTag += "<param name=\"source\" value=\"Video/Silverlight.xap\"/>";
    ObjectTag += "<param name=\"onerror\" value=\"onSilverlightError\" />";
    ObjectTag += "<param name=\"background\" value=\"black\" />";
    ObjectTag += "<param name=\"minRuntimeVersion\" value=\"2.0.31005.0\" />";
    ObjectTag += "<param name=\"autoUpgrade\" value=\"true\" />";
    ObjectTag += "<param name=\"initparams\" value=\"asx=" + sStreamsource + ",width=" + iWidth + ",height=" + iHeight + ",autostart=" + AutoStart + "\" />";
   ObjectTag += "<div>";
   document.write(ObjectTag);
    // show missing silverlight message"
   // PrintSilverlightMissing("false");
        
    ObjectTag = "</div></object>";
    document.write(ObjectTag);
}
}