var QUICKTIME_PLAYER = 13;
var FLASH_PLAYER = 12;
var WINDOWSMEDIA_PLAYER = 11;
var FLASH_PLAYER_SLIDE_SHOW = 16;
var FLASH_PLAYER_PLAYLIST = 18;
var FLASH_PLAYER_AUDIO = 14;
var FLASH_PLAYER_AUDIO_PLAYLIST = 141;
var silverlightPlayerObjectTag = '';
var showBuyDRMPlayerInstallButton = false;
var showSLCaptions = false;

var iOS = (navigator.platform.indexOf("iPhone") != -1) ||
        (navigator.platform.indexOf("iPad") != -1) ? true : false;
        
       
        
 var Player = null;
 function onPlayerReady(player) {
    Player = player;
	if(Player != null && showSLCaptions)
	Player.ShowCaptions(true);    
  }  
  

function onPlayerInstalled()
{   
    $('#installPlayerDiv').hide();    
}



if (!height)
    height = 480;

if (playerType == QUICKTIME_PLAYER && iOS) {


    if (QTNEXT.length > 0) {

        height = 310;
        QTNEXT = QTNEXT.replace(/320/g, width);
        QTNEXT = QTNEXT.replace(/240/g, height);

        document.write('<OBJECT CLASSID="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" CODEBASE="http://www.apple.com/qtactivex/qtplugin.cab" HEIGHT="' + height + '" WIDTH=' + width + ' > ');
        document.write('<PARAM NAME="controller" VALUE="true" /> ');
        document.write('<PARAM NAME="SCALE" VALUE="tofit" /> ');
        document.write('<PARAM NAME="AUTOPLAY" VALUE="true"/> ');
        document.write('<PARAM NAME="VOLUME" VALUE="100"/> ');
        document.write(QTNEXT);
        document.write('</OBJECT>');
    }
    else {
        if (isAudio) {
            height = 15;
            document.write('<img src="' + coverart + '" height="285" width="350"/>');
        }

        if (isMAC && isMAC == 'true') {
            document.write('<OBJECT CLASSID="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" CODEBASE="http://www.apple.com/qtactivex/qtplugin.cab" HEIGHT="' + height + '" WIDTH=' + width + ' > ');
            document.write('<PARAM NAME="src" VALUE="' + mediaSrc + '" > ');
            document.write('<PARAM NAME="controller" VALUE="true" /> ');
            document.write('<PARAM NAME="SCALE" VALUE="tofit" /> ');
            document.write('<PARAM NAME="AUTOPLAY" VALUE="' + flvAutoStart + '"/> ');
            document.write('<PARAM NAME="VOLUME" VALUE="100"/> ');

            document.write('<EMBED SRC="' + mediaSrc + '" HEIGHT="' + height + '" WIDTH="' + width + '" AUTOPLAY="' + flvAutoStart + '" CONROLLER="true" SCALE="tofit" TYPE="video/quicktime" PLUGINSPAGE="http://www.apple.com/quicktime/download/" /> ');
            document.write('</OBJECT>');
        }
        else {
            if (width > 0) {
                mediaSrc = mediaSrc.replace('rtsp', 'http');
                document.write('<OBJECT');
                document.write('CLASSID="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" ');

                if (isAudio) {
                    document.write('WIDTH="350" ');
                    document.write('HEIGHT="15" ');
                } else {
                    document.write('WIDTH="350" ');
                    document.write('HEIGHT="355" ');
                }
                document.write('CODEBASE="http://www.apple.com/qtactivex/qtplugin.cab">');
                document.write('<PARAM name="SRC"        VALUE = "' + mediaSrc + '" >');
                document.write('<PARAM name="QTSRC"      VALUE = "' + mediaSrc + '" >');
                document.write('<PARAM name="HREF"      VALUE = "' + closeCaptionFile + '">');
                document.write('<PARAM name="AUTOPLAY"   VALUE = "true">');
                document.write('<PARAM name="CONTROLLER" VALUE = "true">');
                document.write('<PARAM name="TYPE"       VALUE = "video/quicktime">');
                document.write('<PARAM NAME="SCALE"      VALUE = "tofit" >');
                document.write('<PARAM name="TARGET"     VALUE = "myself">');
                document.write('<EMBED ');
                document.write('SRC        = "' + mediaSrc + '" ');
                document.write('QTSRC      = "' + mediaSrc + '"');
                document.write('HREF       = "' + closeCaptionFile + '"');
                document.write('TARGET     = "myself"');
                document.write('CONTROLLER = "true"');
                if (isAudio) {
                    document.write('WIDTH      = "350" ');
                    document.write('HEIGHT     = "15" ');
                } else {
                    document.write('WIDTH      = "350" ');
                    document.write('HEIGHT     = "310" ');
                }
                document.write('LOOP       = "false" ');
                document.write('AUTOPLAY   = "true" ');
                document.write('PLUGIN     = "quicktimeplugin" ');
                document.write('TYPE       = "video/quicktime" ');
                document.write('CACHE      = "false" ');
                document.write('SCALE      = "tofit" ');
                document.write('bgcolor    = "000000"');
                document.write('PLUGINSPAGE= "http://www.apple.com/quicktime/download/" >');
                document.write('</EMBED>');
                document.write('</OBJECT>');

            }
            else {
                document.write('<script type="text/javascript">AC_AX_RunContent("classid","clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B","codebase","http://www.apple.com/qtactivex/qtplugin.cab#version=7,3,0,0", "height","' + height + '","src","' + mediaSrc + '","type","image/x-macpaint","pluginspage","http://www.apple.com/quicktime/download","qtsrc","' + mediaSrc + '","autoplay","' + flvAutoStart + '", "scale", "tofit", "id", "insertedVideoPlayer", "name", "insertedVideoPlayer", "enablejavascript", "true");</script>');
            }
        }
    }
}
else if ((playerType == FLASH_PLAYER ||  playerType == QUICKTIME_PLAYER ) && mediaFilePathProtocol !='' ) {


    var hasReqestedVersion = DetectFlashVer(9, 0, 0);
    if (hasReqestedVersion) {
        if (isAudio) {
        
        
          document.write('<img src="' + coverart + '" height="' + height + '" width="'+ width + '"/>');
            height = 20;
            document.write('<div id=\"player\">Learn360</div>');
            document.write('<script type="text/javascript">');
            document.write('var so = new SWFObject("swf/jwplayer.swf", "smhPlayer", "' + width + '", "' + height + '", "9.0.28", "#000000");');
        }
        else {
       
            document.write('<div id=\"player\">Learn360</div>');
            document.write('<script type="text/javascript">');
            document.write('var so = new SWFObject("swf/jwplayer.swf", "smhPlayer", "' + width + '", "' + height + '", "9.0.28", "#000000");');
        }
      
        var flashvars = "";
        // Loading both Captions and Google Analytics plug-ins.
        if (closeCaptionFile.length > 0) {
        
       // document.write('so.addVariable("allowscriptaccess", "always");');
        //  flashvars = "&amp;allowscriptaccess=always";
        
        
        document.write('so.addVariable("plugins", "captions-2,gapro-1");');
         
         //Captions Text Properties
           document.write('so.addVariable("captions.files","'+closeCaptionFile+'");');
         flashvars = "&amp;plugins=captions-2,gapro-1&amp;captions.files="+closeCaptionFile;
        
           document.write('so.addVariable("captions.labels", "'+mediaFileLanguage+'");');      
         flashvars += "&amp;captions.labels="+mediaFileLanguage; 
         
            document.write('so.addVariable("captions.state", "false");');
        flashvars+="&amp;captions.state=false";
        
           document.write('so.addVariable("captions.fontsize", "17");');
        flashvars+="&amp;captions.fontSize=17";
        
         //Google Analytics version-2 Properties
          document.write('so.addVariable("gapro.accountid", "UA-4941359-10");');
        flashvars+="&amp;gapro.accountid=UA-4941359-10"; 
         
           document.write('so.addVariable("gapro.trackstarts", "true");');
        flashvars+="&amp;gapro.trackstarts=true"; 

           document.write('so.addVariable("gapro.trackpercentage", "true");');
        flashvars+="&amp;gapro.trackpercentage=true";

           document.write('so.addVariable("gapro.tracktime", "true");');
        flashvars+="&amp;gapro.tracktime=true";
          
        }
        else  //when videos doesn't have captions text file then we need to load Google Analytics plug-in only..
        {
      
        //Enable Script Access
       // document.write('so.addVariable("allowscriptaccess", "always");');
        //  flashvars = "&amp;allowscriptaccess=always";
        
        
        document.write('so.addVariable("plugins", "gapro-1");');
          flashvars = "&amp;plugins=gapro-1";
        
        
         //Google Analytics version-2 Properties
           document.write('so.addVariable("gapro.accountid", "UA-4941359-10");');
        flashvars+="&amp;gapro.accountid=UA-4941359-10"; 
         
           document.write('so.addVariable("gapro.trackstarts", "true");');
        flashvars+="&amp;gapro.trackstarts=true"; 

           document.write('so.addVariable("trackpercentage", "true");');
        flashvars+="&amp;gapro.trackpercentage=true";

           document.write('so.addVariable("tracktime", "true");');
        flashvars+="&amp;gapro.tracktime=true";
        
        }


        if (mediaFilePathProtocol == 'rtmp') {

            if (mediaFilePathWithoutName.length > 1) {
                document.write('so.addParam("streamer", "' + mediaFilePathWithoutName.substring(0, mediaFilePathWithoutName.length - 1) + '");');
                flashvars += "&amp;streamer=" + mediaFilePathWithoutName.substring(0, mediaFilePathWithoutName.length - 1);
            }
                      
            document.write('so.addParam("file", "' + mediaFileName.replace("&", "%26") + '");');
            flashvars += "&amp;file=" + mediaFileName.replace("&", "%26");
          

        }
        else if (mediaFilePathProtocol == 'http') {

            document.write('so.addParam("file", "' + mediaSrc.replace("&", "%26") + '");');
            flashvars += "&amp;file=" + mediaSrc.replace("&", "%26");

        }

        document.write('so.addParam("allowfullscreen", "true");');
        flashvars += "&amp;allowfullscreen=true";

        
//         flashvars += "&amp;modes: [ { type: 'html5' }];";          
      //   document.write('so.addParam("modes", "[ { type: html5 }]");');  
  

        document.write('so.addParam("autostart", "' + flvAutoStart + '");');
        flashvars += "&amp;autostart=" + flvAutoStart;


        if (typeof (image) != "undefined") {
            document.write('so.addParam("image", "' + image + '");');
            flashvars += "&amp;image=" + image;

        }
       
      
       document.write('so.addParam("flashvars", "' + flashvars + '");');

        document.write('so.write("player");');
        document.write('</script>');


    }
    else {
        var alternateContent = '<div style="height:354px; width:350px; background-color:Black; color: #FFFFFF; text-align:center;">';
        alternateContent += '<br/><br/><br/><br/><br/><br/><br/><br/><p>This content requires the Adobe Flash Player version 9.<br />';
        alternateContent += '<a href=http://www.adobe.com/go/getflash/>Get Flash</a></p></div>';
        document.write(alternateContent);
    }
}

else if (playerType == WINDOWSMEDIA_PLAYER) {
    if (isAudio) {
        height = 62;
        document.write('<img src="' + coverart + '"height="250" width="350"/>');
    }
//add a srting variable to contain most common tags for SL player. 
//Use this string variable to construct object tags for streaming and download.
 
    
  showBuyDRMPlayerInstallButton = true;
  var silverlightPlayerObjectTagBegin = '<object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="350" height=' + height + '>' ;
  
  silverlightPlayerObjectTag = '<param name="source" value="http://www.learn360.net/ClientBin/BuyDRMKeyOSPlayerTemplate.xap"/>' +
  '<param name="onError" value="onSilverlightError" />' +
  '<param name="background" value="white" />' +
  '<param name="windowless" value="true" />'+
  '<param name="minRuntimeVersion" value="4.0.50826.0" />' +
  '<param name="autoUpgrade" value="false" />' +
  //'<param name="enableHtmlAccess" value="true" />'+
  '<param name="InitParams" value="params =' +
  '<InitParams>' + 
//   '<AuthenticationSettings>'+
//                '<AuthenticationURL>http://www.learn360.net/BuyDRMSilentAuthentication.aspx</AuthenticationURL>'+
//                '<XapLocation>http://keyos.licensekeyserver.com/customer/shared/slauthwin/buydrm.keyos.law.subscription.xap</XapLocation>'+
//                '<Class>buydrm.keyos.law.subscription</Class>'+
//                '<StartPage>MainPage</StartPage>'+
//                '<IsSilentAuthEnabled>true</IsSilentAuthEnabled>'+
//                '<IsNonsilentAuthEnabled>false</IsNonsilentAuthEnabled>'+
//  '</AuthenticationSettings>'+
  '<PlayerSettings>' +
  '<LAUrl>http://sl.licensekeyserver.com/core/rightsmanager.asmx</LAUrl>' +
  '<AutoLoad>true</AutoLoad>' +
  '<AutoPlay>true</AutoPlay>' +
  '<StartMuted>false</StartMuted>' +
  '<IsInstallVisible>true</IsInstallVisible>' +
  '<LogLevel>All</LogLevel>' +
  '<ControlsAutohide>false</ControlsAutohide>' +
  '<ContinuousPlay>false</ContinuousPlay>' +
  '<ScriptableName>Player</ScriptableName>' +
  '</PlayerSettings>' +
  '<PlayList>' +
  '<Item>' ;
  
 

//when download clicked issue persistent license for 60 days
//when not clicked issue license for 60 days but for streaming
//when expired , user needs to visit learn360 again.
var authXML = '';
var authXMLForDownload = '';
var endObjectTag = '';
var silverlightInstallImage = '';
var windowsMediaObject = '';
//document.writeln(silverlightPlayerObjectTag);
    if(isSilverlightDRMEnabled == 'True')
    {
        silverlightPlayerObjectTag += '<IsDRM>'+isSilverlightDRMEnabled+'</IsDRM>' ;
        authXML  = '<AuthXML>'+authenticationXML+'</AuthXML>';
        authXMLForDownload = '<AuthXML>'+authenticationXMLToDownload+'</AuthXML>';
        authXML += '<MediaSource>'+encodedMediaSrc+'</MediaSource>';
        //endObjectTag += '<MediaSource>http://localhost/streams/upload/red_room.pyv</MediaSource>';    
    }
    else
        authXML += '<MediaSource>'+encodedMediaSrc+'</MediaSource>';
        
    endObjectTag += '<DeliveryMethod>progressivedownload</DeliveryMethod>' +
    '<Title>some title</Title>';
    if(typeof silverlightCloseCaptionFile === "undefined")
        silverlightCloseCaptionFile = '';
    if(silverlightCloseCaptionFile != '')
    {
        showSLCaptions = true;
        endObjectTag += ' <MarkerResource>'+
                    '<Format>TTAF1-DFXP</Format>'+
                    '<Source>'+silverlightCloseCaptionFile+'</Source>'+
                    //'<Source>http://localhost/clientbin/1_4157_en.xml</Source>'+
                  '</MarkerResource>';

    }
    
    endObjectTag += '</Item></PlayList>' +
    '</InitParams>" />' ;   
   
//if silverlight is not installed and if video is silverlight drm enabled
//then show the image
		  
//else
//try to play the file in windows media player.

windowsMediaObject += '<object id="insertedVideoPlayer" CLASSID="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6"  width="350" height="' + height + '">' + 
'<param name="URL" value="' + mediaSrc + '">' +
'<param name="autoStart" value="True">' +
'<param name="uimode" value="full">' +
'<param name="captioningID" value="captions">' ;
    if (closeCaptionFile != null) 
    {
    windowsMediaObject += '<param name="SAMIFileName" value="' + closeCaptionFile + '">';
    }
    windowsMediaObject += '<embed type="application/x-mplayer2" pluginspage="http://www.microsoft.com/Windows/MediaPlayer/" width="350" height="' + height + '" src="' + mediaSrc + '" showcontrols="1"> </object>';

    if(isSilverlightDRMEnabled == 'True')
    {
     silverlightInstallImage = '<a href="http://go.microsoft.com/fwlink/?LinkID=149156&v=4.0.50826.0" style="text-decoration:none">' +
 			  '<img src="http://www.learn360.net/images/InstallSilverlight.PNG" alt="Get Microsoft Silverlight" style="border-style:none" /> </a>';
 			   document.writeln(silverlightPlayerObjectTagBegin + silverlightPlayerObjectTag + authXML + endObjectTag + silverlightInstallImage + '</object>');
 	}
    else
        { 
        if(Silverlight.isInstalled())       
            windowsMediaObject = '';
        document.writeln(silverlightPlayerObjectTagBegin + silverlightPlayerObjectTag + authXML + endObjectTag +''+  windowsMediaObject + '</object>');
        }
        //document.writeln(windowsMediaObject);

    
//    document.write('<OBJECT id="insertedVideoPlayer" CLASSID="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6"  width="350" height="' + height + '">');
//    document.write('<param name="URL" value="' + mediaSrc + '">');
//    document.write('<param name="autoStart" value="True">');
//    document.write('<param name="uimode" value="full">');
//    document.write('<param name="captioningID" value="captions">');
//    if (closeCaptionFile != null) {
//        document.write('<param name="SAMIFileName" value="' + closeCaptionFile + '">');
//    }
//    document.write('<embed type="application/x-mplayer2" pluginspage="http://www.microsoft.com/Windows/MediaPlayer/" width="350" height="' + height + '" src="' + mediaSrc + '" showcontrols="1">')
//    document.write('</OBJECT>')
}
else if (playerType == FLASH_PLAYER_PLAYLIST) {

    var hasReqestedVersion = DetectFlashVer(9, 0, 0);

    if (hasReqestedVersion) {
    
        var newHeight = height;        
        mediaSrc = mediaSrc.substring(0, mediaSrc.indexOf('.xml') + 4);
        document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="364" height="485" id="" align="middle">');
        document.write('<param name="allowScriptAccess" value="always" />');
         if(closeCaptionFile.length >0)
        {
        document.write('<param name="plugins" value="captions-2" />');
        }
         document.write('<param name="captions.files" value="' + closeCaptionFile + '" />');
//          document.write('<param name="captions.labels" value="'+ mediaFileLanguage +'" />');       
        
        
        document.write('<param name="flashVars" value="&captions.files='+closeCaptionFile+'&autostart=true&stretching=fill&repeat=always&playlist=bottom&allowfullscreen=true&file=../' + mediaSrc + '" />');
        document.write('<param name="movie" value="http://www.learn360.net/swf/jwplayer.swf" /><param name="quality" value="high" /><param name="allowFullScreen" value="true" /> <param name="stretching" value="fill" />');
        document.write('<param name="bgcolor" value="#000000" />');
        document.write('<embed src="http://www.learn360.net/swf/jwplayer.swf" allowfullscreen="true" captions.files="'+closeCaptionFile+'"  quality="high" bgcolor="#000000" width="364" height="485" name="" align="middle" allowScriptAccess="always" stretching="fill" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashVars="&autostart=true&stretching=fill&captions.files=' + closeCaptionFile + '&allowfullscreen=true&repeat=always&playlist=bottom&file=../' + mediaSrc + '"/>');
        document.write('</object>');

    }
    else {
        var alternateContent = '<div style="height:354px; width:350px; background-color:Black; color: #FFFFFF; text-align:center;">';
        alternateContent += '<br/><br/><br/><br/><br/><br/><br/><br/><p>This content requires the Adobe Flash Player version 9.<br />';
        alternateContent += '<a href=http://www.adobe.com/go/getflash/>Get Flash</a></p></div>';
        document.write(alternateContent);
    }

}


if (typeof (mediaFileName) != "undefined" && typeof (mediaFilePathProtocol) != "undefined" && !DetectFlashVer(9, 0, 0) ) {


    document.write('<input id="btnLoadFlash" type="button" onclick="insertFlashPlayer(\'' + mediaFileName + '\', \'' + mediaFilePathWithoutName + '\', \'' + mediaFilePathProtocol + '\'); return false;" style="display:none;" />');
}

function insertFlashPlayer(mediaFileName, mediaFilePathWithoutName, mediaFilePathProtocol) {

    var so = new SWFObject("swf/jwplayer.swf", "smhPlayer", "354", height, "9.0.28", "#000000");
    if(closeCaptionFile.length>0)
    {
    var flashvars = "&amp;plugins=captions&amp;captions.file=" + closeCaptionFile;
    }
    if (mediaFilePathProtocol == 'rtmp') {

        if (mediaFilePathWithoutName.length > 1) {
            so.addParam("streamer", mediaFilePathWithoutName.substring(0, mediaFilePathWithoutName.length - 1));
            flashvars += "&amp;streamer=" + mediaFilePathWithoutName.substring(0, mediaFilePathWithoutName.length - 1);
        }

        so.addParam("file", mediaFileName.replace("&", "%26"));
        flashvars += "&amp;file=" + mediaFileName.replace("&", "%26");

    } else if (mediaFilePathProtocol == 'http') {

        var mediaSrc = mediaFilePathWithoutName + mediaFileName;
        so.addParam("file", mediaSrc.replace("&", "%26"));
        flashvars += "&amp;file=" + mediaSrc.replace("&", "%26");
    }



    so.addParam("allowfullscreen", "true");
    flashvars += "&amp;allowfullscreen=true";

    so.addParam("autostart", "true");
    flashvars += "&amp;autostart=true";

    so.addParam("flashvars", flashvars);

    so.write("player");

}     

function showSilverlightInstallButton()
{
    //if silverlight is installed hide the full screen and launch player buttons. else show.
    if(Silverlight.isInstalled())
        {
            //alert("hi");
            $('#'+fullScreenClientID).hide();
            $('#'+launchPlayerClientID).hide();
            $('#captions').hide();
    //alert('show BuyDRM player Install button ='+showBuyDRMPlayerInstallButton);
        var silverlightInstallButtonTag = '<object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="145" height="47">'+
      		  '<param name="source" value="ClientBin/BuyDRMKeyOSPlayerTemplate.xap"/>'+
      		  '<param name="onError" value="onSilverlightError" />'+
            '<param name="background" value="#00FFFFFF" />'+
            '<param name="windowless" value="true" />'+
      		 ' <param name="minRuntimeVersion" value="4.0.50826.0" />'+
      		  '<param name="autoUpgrade" value="true" />'+
            '<param name="InitParams" value="params ='+
            '<InitParams>'+
              '<InstallSettings>'+
                '<DownloadImage>http://www.learn360.net/images/installplayer.png</DownloadImage>'+
              '</InstallSettings>'+
              '<PlayerSettings>'+
                '<LAUrl>http://sl.licensekeyserver.com/core/rightsmanager.asmx</LAUrl>'+
                '<AutoLoad>true</AutoLoad>'+
                '<AutoPlay>true</AutoPlay>'+
                '<StartMuted>false</StartMuted>'+
                '<IsInstallVisible>true</IsInstallVisible>'+
                '<LogLevel>All</LogLevel>'+
                '<ControlsAutohide>false</ControlsAutohide>'+
              '</PlayerSettings>'+
              '<PlayList>'+
              '</PlayList>'+
            '</InitParams>'+
            '" /> <span> </span>'+
          '</object>';
          //$('#installPlayerDiv').replaceWith('<div id="installPlayerDiv">'+silverlightInstallButtonTag+'</div>');
          $('#installPlayerDiv').append(silverlightInstallButtonTag);
          //document.write(silverlightInstallButtonTag);
          silverlightInstallButtonTag = '';
      }
}

function downloadLicense(containerdiv)
{
    if(playerType == WINDOWSMEDIA_PLAYER && isSilverlightDRMEnabled == 'True')
    {       
        var beginTag = '<object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="350" height=' + 200 + '>' ; 
        var silverlightDownloadPlayerObjectTag = '<param name="source" value="http://www.learn360.net/ClientBin/BuyDRMKeyOSPlayerTemplate.xap"/>' +
  '<param name="onError" value="onSilverlightError" />' +
  '<param name="background" value="white" />' +
  '<param name="windowless" value="true" />'+
  '<param name="minRuntimeVersion" value="4.0.50826.0" />' +
  '<param name="autoUpgrade" value="false" />' +
  '<param name="InitParams" value="params =' +
  '<InitParams>' + 
//  '<AuthenticationSettings>'+
//                '<AuthenticationURL>http://www.learn360.net/BuyDRMSilentAuthentication.aspx</AuthenticationURL>'+
//                '<XapLocation>http://keyos.licensekeyserver.com/customer/shared/slauthwin/buydrm.keyos.law.subscription.xap</XapLocation>'+
//                '<Class>buydrm.keyos.law.subscription</Class>'+
//                '<StartPage>MainPage</StartPage>'+
//                '<IsSilentAuthEnabled>true</IsSilentAuthEnabled>'+
//                '<IsNonsilentAuthEnabled>false</IsNonsilentAuthEnabled>'+
//              '</AuthenticationSettings>'+
  '<PlayerSettings>' +
  '<LAUrl>http://sl.licensekeyserver.com/core/rightsmanager.asmx</LAUrl>' +
  '<AutoLoad>true</AutoLoad>' +
  '<AutoPlay>true</AutoPlay>' +
  '<StartMuted>true</StartMuted>' +
  '<IsInstallVisible>false</IsInstallVisible>' +
  '<LogLevel>All</LogLevel>' +
  '<ControlsAutohide>false</ControlsAutohide>' +
  '<ContinuousPlay>false</ContinuousPlay>' +
  '<ScriptableName>Player</ScriptableName>' +
  '</PlayerSettings>' +
  '<PlayList>' +
  '<Item><IsDRM>True</IsDRM>' ;
  if(typeof encodedDownloadUrl === "undefined")
    encodedDownloadUrl = encodedMediaSrc;
  if(encodedDownloadUrl == "")
    encodedDownloadUrl = encodedMediaSrc;
    
      authXMLForDownload += '<MediaSource>'+encodedDownloadUrl+'</MediaSource>';
      //authXMLForDownload += '<MediaSource>http://localhost/streams/upload/red_room.pyv</MediaSource>';
        $('#'+containerdiv).append(beginTag + silverlightDownloadPlayerObjectTag + authXMLForDownload + endObjectTag);
        $('#'+containerdiv).load();
        //alert($('#'+containerdiv).html()); 
    }
}


