﻿// Function to embed a quicktime movie into a document. Used to route around annoying eolas patent crap
// Copyright (c) 2006 Thought Equity. All Rights Reserved

//	Embed a QuickTime Movie
//
//	src - source URL of movie
//	width - Width or zero if unknown
//	height - Height, or zero if unknown
function embedQuicktime(src, width, height, aWriteDoc, aElemId) {
 //   var str = QT_GenerateOBJECTText(src, width, height, '', 'obj#id', 'objQTPlayer', 'emb#id', 'emQTPlayer', 'autoplay', 'true', 'scale', 'tofit', 'type', 'video/quicktime', 'name', 'emQTPlayer', 'align', 'middle');

    var lFixSource = src;
//    lFixSource = lFixSource.replace("&", "&amp;");
   var str = "<object classid='clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B' name='emQTPlayer' width='" + width + "' height='" + height + "'";
   str += " codebase='http://www.apple.com/qtactivex/qtplugin.cab' align='middle'>";
   str += " <param name='src' value='" + src + "' />";
   str += " <param name='autoplay' value='true' />";
   str += " <param name='controller' value='true' />";
   str += " <param name='scale' value='tofit' />";
   str += " <param name='type' value='video/quicktime' />";
   var str = " <embed src='" + src + "' width='" + width + "' height='" + height + "' name='emQTPlayer' type='video/quicktime' controller='true'"; 
   str += "  pluginspage=http://www.apple.com/quicktime/download/ align='middle' autoplay='true' bgcolor='white' scale='TOFIT' ></embed>";
   str += "</object>";

/*
  var str = '<embed  src="' + src + '" ';
  if (width > 0) {
      str += 'width="' + width + '" ';
      if (height > 0) {
          str += 'height="' + height + '" ';
      }
  }
  str += 'scale="tofit" ';
  str += 'autoplay="true" name="embQTPlayer" controller="true" loop="false" pluginspage="http://www.apple.com/quicktime/download/" />';
*/
  if (aWriteDoc) {
      if (aElemId)
        lElement = document.getElementById(aElemId);
        if ( lElement )
            lElement.innerHTML = str;
  }
    //document.write(str);
    return str;
/*
ele = document.getElementById('video');
if(ele != null)
ele.innerHTML = str;*/
}

//	Embeds a Windows Media movie
//	src - URL of movie
//	width - Width, or zero if unknown
//	height - Height or zero if unknown
function embedWindowsMedia(src,width,height) {
	embedWindowsMediaInternal(src,false,width,height, true, 'null');
}

//	Embeds a Windows Media Stream
//	src - URL of movie
//	width - Width, or zero if unknown
//	height - Height or zero if unknown
function embedWindowsMediaStream(src,width,height) {
	embedWindowsMediaInternal(src,true,width,height, true, 'null');
}

//	Swiss-army knife to embed a Windows Media thingy
function embedWindowsMediaInternal(src,isStream,width,height, aWriteDoc, aElemId) {
	var str = '<object id=\"MediaPlayer1\" ';
	str += 'classid="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95" '
	str += 'codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,7,1112" '
	str += 'standby="Loading Microsoft WindowsÂ® Media Player components..." '
	str += 'type="application/x-oleobject" '
	if (width > 0) {
		str += 'width="' + width + '" ';
		if (height > 0) {
			str += 'height="' + height + '" ';
		}
	}
	str += '>';
	
	if (isStream) {
		str += '<param name="fileName" value="' + src + '"/>';
		str += '<param name="showStatusBar" value="1" />';
		str += '<param name="autoSize" value="1" />';
	}
	else {
		str += '<param name="fileName" value="' + src + '"/>';
	}
	str += '<param name=\"animationatStart\" value=\"1\"/>';
	str += '<param name=\"transparentatStart\" value=\"1\"/>';
	str += '<param name=\"autoStart\" value=\"1\"/>';
	str += '<param name=\"showControls\" value=\"1\"/>';
	str += '<param name=\"Volume\" value=\"-450\"/>';
	str += '<embed type=\"application/x-mplayer2\" ';
	str += 'pluginspage=\"http://www.microsoft.com/Windows/MediaPlayer/\" ';
	if (isStream) {
		str += 'src="' + src + '" showstatusbar="1" autosize="1" ';
	}
	else {
		str += 'src="' + src + '" ';
	}
	str += 'name="MediaPlayer1" ';
	if (width > 0) {
		str += 'width="' + width + '" ';
		if (height > 0) {
			str += 'height="' + height + '" ';
		}
	}

	str += 'autostart="1" ';
	str += 'showcontrols="1" ';
	str += 'animationatstart="1" ';
	str += 'volume="-450">';
	str += '</embed>';
	str += '</object>';

	if (aWriteDoc) {
	    lElement = document.getElementById(aElemId);
	    if (lElement)
	        lElement.innerHTML = str;
//	    document.write(str);
	}
	return str;
}
// -----------------------------------------------------------------------------
// Globals
// Major version of Flash required
//var requiredMajorVersion = 9;
// Minor version of Flash required
//var requiredMinorVersion = 0;
// Minor version of Flash required
//var requiredRevision = 124;
// -----------------------------------------------------------------------------

function FlashVideoPreview(aSrc)
{
    // Version check for the Flash Player that has the ability to start Player Product Install (6.0r65)
    var hasProductInstall = DetectFlashVer(6, 0, 65);

    // Version check based upon the values defined in globals
    var requiredMajorVersion;
    var requiredMinorVersion;
    var requiredRevision;
    var hasRequestedVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);

    if (hasRequestedVersion) {
        // if we've detected an acceptable version
        // embed the Flash Content SWF when all tests are passed
        var content = 'AC_FL_RunContent( ';
        content += '"src", "FlexVidPlayer", ';
        content += '"width", "167", ';
        content += '"height", "105", ';
        content += '"align", "middle", ';
        content += '"id", "FlexVidPlayer", ';
        content += '"quality", "high", ';
        content += '"wmode", "opaque", ';
        content += '"bgcolor", "#ffffff", ';
        content += '"name", "FlexVidPlayer", ';
        content += '"allowScriptAccess","sameDomain", ';
        content += '"type", "application/x-shockwave-flash", ';
        content += '"flashVars", "VideoUrl=' + aSrc + '", ';
        content += '"pluginspage", "http://www.adobe.com/go/getflashplayer" ';
        content += '); ';
        document.write(content);
      } else {  // flash is too old or we can't detect the plugin
        var alternateContent = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ';
        alternateContent += 'id="FlexVidPlayer" width="160" height="105" ';
        alternateContent += 'codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab"> ';
        alternateContent += '<param name="movie" value="FlexVidPlayer.swf" /> ';
        alternateContent += '<param name="quality" value="high" /> ';
        alternateContent += '<param name="wmode" value="opaque" /> ';
        alternateContent += '<param name="bgcolor" value="#ffffff" /> ';
        alternateContent += '<param name="allowScriptAccess" value="sameDomain" /> ';
        alternateContent += '<param name="flashVars" value="VideoUrl=' + aSrc + ' " /> ';
        alternateContent += '<embed src="FlexVidPlayer.swf" quality="high" bgcolor="#ffffff" ';
        alternateContent += 'width="160" height="105" name="FlexVidPlayer" align="middle" ';
        alternateContent += 'play="true" ';
        alternateContent += 'loop="false" ';
        alternateContent += 'quality="high" ';
        alternateContent += 'allowScriptAccess="sameDomain" ';
        alternateContent += 'flashVars="VideoUrl=' + aSrc + ' " ';
        alternateContent += 'type="application/x-shockwave-flash" ';
        alternateContent += 'pluginspage="http://www.adobe.com/go/getflashplayer"> ';
        alternateContent += '</embed> ';
        alternateContent += '</object> ';
   	    
        document.write(alternateContent);  // insert non-flash content
      }
}

function FlashVideoDetail(aSrc, aThumbnail, aWidth, aHeight, aWriteDoc, aElemId) {
    // Version check for the Flash Player that has the ability to start Player Product Install (6.0r65)
    var hasProductInstall = DetectFlashVer(6, 0, 65);
    var requiredMajorVersion;
    var requiredMinorVersion;
    var requiredRevision;

    // Version check based upon the values defined in globals
    var hasRequestedVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);
    var content = "";
    if (hasRequestedVersion) {
        // if we've detected an acceptable version
        // embed the Flash Content SWF when all tests are passed
        content = 'AC_FL_RunContent( ';
        content += '"src", "FlexVidPlayerSize", ';
        content += '"width", "' + aWidth + '", ';
        if ( aHeight.length > 0 )
            content += '"height", "' + aHeight + '", ';
        content += '"align", "middle", ';
        content += '"id", "FlexVidPlayer", ';
        content += '"quality", "high", ';
        content += '"wmode", "opaque", ';
        content += '"bgcolor", "#ffffff", ';
        content += '"name", "FlexVidPlayerSize", ';
        content += '"allowScriptAccess","sameDomain", ';
        content += '"type", "application/x-shockwave-flash", ';
        content += '"flashVars", "VideoUrl=' + aSrc + '&ThumbUrl=' + aThumbnail + '", ';
        content += '"pluginspage", "http://www.adobe.com/go/getflashplayer" ';
        content += '); ';
        if ( aWriteDoc )
            document.write(content);
    } else {  // flash is too old or we can't detect the plugin
        content = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ';
        content += 'id="FlexVidPlayerSize" width="' + aWidth + '" height="' + aHeight + '" ';
        content += 'codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab"> ';
        content += '<param name="movie" value="FlexVidPlayerSize.swf" /> ';
        content += '<param name="quality" value="high" /> ';
        content += '<param name="bgcolor" value="#ffffff" /> ';
        content += '<param name="wmode" value="opaque" /> ';
        content += '<param name="allowScriptAccess" value="sameDomain" /> ';
        content += '<param name="flashVars" value="VideoUrl=' + aSrc + '&ThumbUrl=' + aThumbnail + ' " /> ';
        content += '<embed src="FlexVidPlayerSize.swf" quality="high" bgcolor="#ffffff" ';
        content += 'width=' + aWidth + ' ';
        if ( aHeight.length > 0 )
            content += 'height=' + aHeight + ' '; 
        content += 'name="FlexVidPlayerSize" align="middle" ';
        content += 'play="true" ';
        content += 'loop="false" ';
        content += 'quality="high" ';
        content += 'allowScriptAccess="sameDomain" ';
        content += 'type="application/x-shockwave-flash" ';
        content += 'flashVars="VideoUrl=' + aSrc + '&ThumbUrl=' + aThumbnail + '" ';
        content += 'pluginspage="http://www.adobe.com/go/getflashplayer"> ';
        content += '</embed> ';
        content += '</object> ';

        if (aWriteDoc) {
            lElement = document.getElementById(aElemId);
            if (lElement)
                lElement.innerHTML = content;
/*            document.write(content);  // insert non-flash content */
        }
    }
    return content;
}
