function GetFlashPlayer(url1, url2)
{
    // jrc, new code using swfobject
    var version = deconcept.SWFObjectUtil.getPlayerVersion();
    var majorVersion = version['major'];
    
    if (majorVersion >= 8)
    {
        var so1 = new SWFObject(url1, "FlashPlay", "445", "369", "8", "#FFFFFF");
        so1.addParam("allowScriptAccess", "always");
        so1.addParam("loop", "false");
        so1.addParam("autoplay", "true");
        so1.addParam("wmode", "transparent");
        so1.addParam("flashvars", "afv_videoPublisherId=ca-video-pub-3514338521707944&afv_videoId=515260011274566220&afv_videoFlvUrl=http://www.livevideo.com/flvplayer/flvplayer.swf&afv_videoDescriptionUrl=http://www.livevideo.com");
        var return1 = so1.write("flashcontent");
        document.write(return1);
    }
    else if (majorVersion >= 7)
    {
        var so2 = new SWFObject(url2, "FlashPlay", "445", "369", "7", "#FFFFFF");
        so2.addParam("allowScriptAccess", "always");
        so2.addParam("loop", "false");
        so2.addParam("autoplay", "true");
        so2.addParam("wmode", "transparent");
        so2.addParam("flashvars", "afv_videoPublisherId=ca-video-pub-3514338521707944&afv_videoId=515260011274566220&afv_videoFlvUrl=http://www.livevideo.com/flvplayer/flvplayer.swf&afv_videoDescriptionUrl=http://www.livevideo.com");        var return2 = so2.write("flashcontent");
        document.write(return2);
    }
    else
    {
        alert('You either have JavaScript turned off, or you need to upgrade to the current version of Flash Player.'); 
        document.write("<br /><br /><b><font color=red>You either have JavaScript turned off, or you need to upgrade to the current version of Flash Player.</font><br /><br />");
        document.write("Our detection engine shows that you currently have Flash version " + version['major'] + " installed.<br /><br />");
        document.write("<a href=http://www.macromedia.com/go/getflashplayer/>Click here</a>&nbsp;to get the latest version of Flash Player.");
    }
}
function GetFlashPlayerFs(url1, url2)
{
    // jrc, new code using swfobject
    var version = deconcept.SWFObjectUtil.getPlayerVersion();
    var majorVersion = version['major'];
    
    if (majorVersion >= 8)
    {
        var so1 = new SWFObject(url1, "FlashPlay", "100%", screen.availHeight-185, "8", "#FFFFFF");
        so1.addParam("allowScriptAccess", "always");
        so1.addParam("loop", "false");
        so1.addParam("autoplay", "true");
        so1.addParam("flashvars", "afv_videoPublisherId=ca-video-pub-3514338521707944&afv_videoId=515260011274566220&afv_videoFlvUrl=http://www.livevideo.com/flvplayer/flvplayer.swf&afv_videoDescriptionUrl=http://www.livevideo.com");
        var return1 = so1.write("flashcontent");
        document.write(return1);
    }
    else if (majorVersion >= 7)
    {
        var so2 = new SWFObject(url2, "FlashPlay", "100%", screen.availHeight-185, "7", "#FFFFFF");
        so2.addParam("allowScriptAccess", "always");
        so2.addParam("loop", "false");
        so2.addParam("autoplay", "true");
        so2.addParam("flashvars", "afv_videoPublisherId=ca-video-pub-3514338521707944&afv_videoId=515260011274566220&afv_videoFlvUrl=http://www.livevideo.com/flvplayer/flvplayer.swf&afv_videoDescriptionUrl=http://www.livevideo.com");
        var return2 = so2.write("flashcontent");
        document.write(return2);
    }
    else
    {
        alert('You either have JavaScript turned off, or you need to upgrade to the current version of Flash Player.'); 
        document.write("<br /><br /><b><font color=red>You either have JavaScript turned off, or you need to upgrade to the current version of Flash Player.</font><br /><br />");
        document.write("Our detection engine shows that you currently have Flash version " + version['major'] + " installed.<br /><br />");
        document.write("<a href=http://www.macromedia.com/go/getflashplayer/>Click here</a>&nbsp;to get the latest version of Flash Player.");
    }
}
function GetWMVPlayer(url)
{
    document.write("<object ID=WMPlay width=461 height=380 classid=\"CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6\"");
    document.write("codebase=\"http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701\"");
    document.write(" standby=\"Loading Microsoft Windows Media Player components...\" type=\"application/x-oleobject\">");
    document.write("<PARAM name=URL value=\"");
    document.write(url);
    document.write("\">");
    document.write("<PARAM name=AllowChangeDisplaySize value=True>");
    document.write("<PARAM NAME=ShowControls VALUE=1>");
    document.write("<PARAM NAME=ShowDisplay VALUE=1>");
    document.write("<PARAM NAME=ShowStatusBar VALUE=1>");
    document.write("<PARAM NAME=AutoStart VALUE=TRUE>");
    document.write("<embed name=WMplay width=461 height=380 type=\"application/x-mplayer2\"");
    document.write("pluginspage=\"http://www.microsoft.com/Windows/Downloads/Contents/Products/MediaPlayer/\" ");
    document.write("src=\"");
    document.write(url);
    document.write("\" AutoStart=True></embed>");
    document.write("</object>");	        
}

function UpdateGeometry(embedCode, newWidth, objCommLinks)
{
    var objEmbedCode = document.getElementById(embedCode);
    var objWidth = document.getElementById(newWidth);
    var enableCommLinks = document.getElementById(objCommLinks).checked;
    var newCode = objEmbedCode.value;
    var newWidthVal = objWidth.value;
    var enabled_reciprocal = 0.910112;    // Reciprocal of 445/405 to calculate the proportional height
    var disabled_reciprocal = 0.829213;  // Reciprocal of 445/369 to calculate the proportional height
    var widthLoc = -1;      // WIDTH=" index location
    var heightLoc = -1;      // HEIGHT=" index location
    var lastQuoteLoc = -1   // The last " of WIDTH
    var prefix = "";        // prefix
    var suffix = "";        // suffix

    if ( isNaN(newWidthVal))
    {
        newWidthVal = newWidthVal.slice(0,newWidthVal.length - 1);
        objWidth.value = newWidthVal;
        alert( "Only numbers are allowed" );
    }
    else
    {
        if (newWidthVal.length==0)
        {
            newWidthVal = 0;
        }
        widthLoc = newCode.indexOf( "WIDTH=\"");
        
        if ( widthLoc != -1 )
        {
            // The first quote is the first " after WIDTH="
            lastQuoteLoc = newCode.indexOf( "\"", widthLoc );
            // The next one will be after that
            lastQuoteLoc = newCode.indexOf( "\"", lastQuoteLoc + 1 );
            if ( lastQuoteLoc != -1 )
            {
                prefix = newCode.substring( 0, widthLoc );
                suffix = newCode.substring( lastQuoteLoc, newCode.length );
                newCode = prefix + "WIDTH=\"" + newWidthVal + suffix;
                
                heightLoc = newCode.indexOf( "HEIGHT=\"");
                // The first quote is the first " after HEIGHT="
                lastQuoteLoc = newCode.indexOf( "\"", heightLoc );
                // The next one will be after that
                lastQuoteLoc = newCode.indexOf( "\"", lastQuoteLoc + 1 );
                
                if ( lastQuoteLoc != -1 )
                {
                    var heigthVal = 0;
                    var newHeightVal = 0;
                    
                    heightVal = newCode.substr(heightLoc+8,lastQuoteLoc);
                    newHeightVal = parseInt(heightVal);
                    if ( enableCommLinks == true )
                    {
                        //newHeightVal = newWidthVal * enabled_reciprocal;
                        newHeightVal = newWidthVal * (405/445);
                    }
                    else
                    {
                        //newHeightVal = newWidthVal * disabled_reciprocal;
                        newHeightVal = newWidthVal * (369/445);
                    }
                    newHeightVal = parseInt(newHeightVal);
                    prefix = newCode.substring( 0, heightLoc );
                    suffix = newCode.substring( lastQuoteLoc, newCode.length );
                    newCode = prefix + "HEIGHT=\"" + newHeightVal + suffix;
                }
            }
        }
    }
    objEmbedCode.style.backgroundColor = 'lightblue';
    objEmbedCode.value = newCode;
    setTimeout( "ChangeColor('" + embedCode + "')", 100);
}

function ChangeColor(id)
{
    var objToChange = document.getElementById(id);
   objToChange.style.backgroundColor = "white";
}

function ToggleAdvanceOptions(divId, btnId)
{
    var objAdvOpts = document.getElementById(divId);
    var objButton = document.getElementById(btnId);
    
    if ( objAdvOpts.style.display == "none" )
    {
        objAdvOpts.style.display = "block";
        objButton.value = "Hide";
    }
    else
    {
        objAdvOpts.style.display = "none";
        objButton.value = "Options";
    }
}

function UpdateEmbedCodeThumbnail(embedCode, enable)
{
    var objEmbedCode = document.getElementById(embedCode);
    var newCode = objEmbedCode.value;
    var newVal = document.getElementById(enable).checked;
    var newThumbVal = "thumb=";
    var thumbLoc = -1;  // t= index location
    var prefix = "";    // prefix
    var suffix = "";    // suffix

    thumbLoc = newCode.indexOf( "thumb=");
    
    if ( newVal == true )
    {
        newThumbVal += "1";
    }
    else
    {
        newThumbVal += "0";
    }

    if ( thumbLoc != -1 )
    {
        prefix = newCode.substring( 0, thumbLoc );
        suffix = newCode.substring( thumbLoc + 7, newCode.length );
        newCode = prefix + newThumbVal + suffix;           
    }
    else
    {
        var srcLoc = -1;
        var lastQuoteLoc = -1;
        srcLoc = newCode.indexOf( "src=\"");
        lastQuoteLoc = newCode.indexOf( "\"", srcLoc );
        lastQuoteLoc = newCode.indexOf( "\"", lastQuoteLoc + 1 );     
        
        prefix = newCode.substring( 0, lastQuoteLoc );
        suffix = newCode.substring( lastQuoteLoc, newCode.length );
        newCode = prefix + "&" + newThumbVal + suffix;           
    }

    objEmbedCode.style.backgroundColor = 'lightblue';
    objEmbedCode.value = newCode;
    setTimeout( "ChangeColor('" + embedCode + "')", 100);
}

function UpdateEmbedCodeAutoplay(embedCode, enable)
{
    var objEmbedCode = document.getElementById(embedCode);
    var newCode = objEmbedCode.value;
    var newVal = document.getElementById(enable).checked;
    var newAutoStartVal = "autoStart=";
    var autoStartLoc = -1;      // autoStart= index location
    var prefix = "";        // prefix
    var suffix = "";        // suffix
    
    if ( newVal == true )
    {
        newAutoStartVal += "1";
    }
    else
    {
        newAutoStartVal += "0";
    }

    autoStartLoc = newCode.indexOf( "autoStart=");
    if ( autoStartLoc != -1 )
    {
        prefix = newCode.substring( 0, autoStartLoc );
        suffix = newCode.substring( autoStartLoc + 11, newCode.length );
        newCode = prefix + newAutoStartVal + suffix;
    }
    else
    {
        var srcLoc = -1;
        var lastQuoteLoc = -1;
        srcLoc = newCode.indexOf( "src=\"");
        lastQuoteLoc = newCode.indexOf( "\"", srcLoc );
        lastQuoteLoc = newCode.indexOf( "\"", lastQuoteLoc + 1 );        
        
        prefix = newCode.substring( 0, lastQuoteLoc );
        suffix = newCode.substring( lastQuoteLoc, newCode.length );
        newCode = prefix + "&" + newAutoStartVal + suffix;           
    }

    objEmbedCode.style.backgroundColor = 'lightblue';
    objEmbedCode.value = newCode;
    setTimeout( "ChangeColor('" + embedCode + "')", 100);
}
