﻿// The code below contains functions that run active content. The functions
// assemble an OBJECT/EMBED tag string, and then perform a document.write of 
// this string in the calling html document.
//   AC_RunFlContent() - build tags to display Flash content.
//   AC_RunFlContentX() - build XHTML formatted tags to display Flash content.
//   AC_RunSWContent() - build tags to display Shockwave content.
//   AC_RunSWContentX()  - build XHTML formatted tags to display Shockwave content.
//
// To call one of these functions, pass all the attributes and values that you would 
// otherwise specify for the object, param, and embed tags in the following form:
//   AC_RunFlContent(
//     "attrName1", "attrValue1"
//     "attrName2", "attrValue2"
//     ...
//     "attrNamen", "attrValuen"
//   )
//
// When passing in the src or movie attributes, do not include the file extension.
// Note, these functions use default values for several standard tag attributes, 
// including classid, codebase, pluginsPage, and mimeType, depending on the function
// you call. So, you should not pass in values for these attributes. If you require
// an alternate values for these attributes, you'll need to modify the default values 
// used in the 'Run' function implementations below. However, you may pass in an
// alternate version for the codebase value, as in AC_RunFlContent("codebase","6,0,0,0",...).
// Note that you should only pass in the version string rather than the full
// codebase URL.
//
// You must include AC_RunActiveContent.js for these functions to work.

function AC_RunFlContent()
{
  // First, look for a "movie" and "src" params, and if either exists, add a ".swf" to the end
  // if it doesn't already have one (this function will only run swf files)
  AC_AddExtension(arguments, "movie", ".swf");
  AC_AddExtension(arguments, "src", ".swf");

  // Build the codebase value. If user passed in a version for the codebase, add the version
  // to the base codebase url. Otherwise, use the default version.
  var codebase = AC_GetCodebase
                 (  "http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version="
                  , "7,0,0,0", arguments 
                 );
	
  AC_GenerateObj
  (  "AC_RunFlContent()", false, "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
   , codebase
   , "http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"
   , "application/x-shockwave-flash", arguments
  );
}

function AC_RunFlContentX()
{
  // Get Cookie Flash and test
  flashcookie = get_cookie("Flash")
  if (flashcookie == "Off" || flash_test() == "No") {
	imagefile = AC_GetArguments(arguments, "src")
    document.write("<img src='");
    document.write(imagefile);
    document.write(".jpg' alt='' border='0'>");
  }
  else{
    // First, look for a "movie" and "src" params, and if either exists, add a ".swf" to the end
    // if it doesn't already have one (this function will only run swf files)
    AC_AddExtension(arguments, "movie", ".swf");
    AC_AddExtension(arguments, "src", ".swf");

    // Build the codebase value. If user passed in a version for the codebase, add the version
    // to the base codebase url. Otherwise, use the default version.
    var codebase = AC_GetCodebase
                   (  "http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version="
                    , "7,0,0,0", arguments 
                   );
	
    AC_GenerateObj
    (  "AC_RunFlContentX()", true, "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
     , codebase
     , "http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"
     , "application/x-shockwave-flash", arguments
    );
  }	
}

function AC_RunSWContent()
{
  // First, look for a "src" param, and if it exists, add a ".dcr" to the end
  // if it doesn't already have one (this function will only run dcr files)
  AC_AddExtension(arguments, "src", ".dcr");

  // Build the codebase value. If user passed in a version for the codebase, add the version
  // to the base codebase url. Otherwise, use the default version.
  var codebase = AC_GetCodebase
                 (  "http://fpdownload.macromedia.com/pub/shockwave/cabs/director/sw.cab#version="
                  , "8,5,0,0", arguments 
                 );
	
  AC_GenerateObj
  (  "AC_RunSWContent()", false, "clsid:166B1BCA-3F9C-11CF-8075-444553540000"
   , codebase
   , "http://www.macromedia.com/shockwave/download/", null, arguments
  );
}
	
function AC_RunSWContentX()
{
  // First, look for a "src" param, and if it exists, add a ".dcr" to the end
  // if it doesn't already have one (this function will only run dcr files)
  AC_AddExtension(arguments, "src", ".dcr");

  // Build the codebase value. If user passed in a version for the codebase, add the version
  // to the base codebase url. Otherwise, use the default version.
  var codebase = AC_GetCodebase
                 (  "http://fpdownload.macromedia.com/pub/shockwave/cabs/director/sw.cab#version="
                  , "8,5,0,0", arguments 
                 );
	
  AC_GenerateObj
  (  "AC_RunSWContentX()", true, "clsid:166B1BCA-3F9C-11CF-8075-444553540000"
   , codebase
   , "http://www.macromedia.com/shockwave/download/", null, arguments
  );
}

function Flash_Switch(textnoflash,textoff,texton)
{
  // Get Cookie Flash and test
  if (flash_test() == "No") {
    document.write(textnoflash);
    return;
  }
  
  flashcookie = get_cookie("Flash");
  if (flashcookie == "Off") {
    document.write(textoff);
  }
  else{
    document.write(texton);
  }
  return;
}

function Flash_SwitchText(webpageid)
{
  // Get Cookie Flash and test
  if (flash_test() == "No") {
    document.write("<div class='flashLink'>Flash not installed</div>");
    return;
  }
  
  flashcookie = get_cookie("Flash");
  if (flashcookie == "Off") {
    document.write("<a class='flashLinkOff' href='/basic/flashswitch.php?pageid=" + webpageid + "'>Flash Off</a>");
  }
  else{
    document.write("<a class='flashLinkOn' href='/basic/flashswitch.php?pageid=" + webpageid + "'>Flash On</a>");
  }
  return;
}

function showmovie(type,height,width,file,layer) {

	height = height + 20;
	if(type == 'mov'){
		var block = "<OBJECT CLASSID='clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B' WIDTH='"+width+"' HEIGHT='"+height+"' CODEBASE='http://www.apple.com/qtactivex/qtplugin.cab#version=6,0,2,0'>";
		block += "<PARAM NAME='controller' VALUE='TRUE'> <PARAM NAME='type' VALUE='video/quicktime'>";
		block += "<PARAM NAME='autoplay' VALUE='true'>";
		block += "<PARAM NAME='target' VALUE='myself'>";
		block += "<PARAM NAME='src' VALUE='"+file+"'>";
		block += "<PARAM NAME='pluginspage' VALUE='http://www.apple.com/quicktime/download/index.html'>";
		block += "<EMBED WIDTH='"+width+"' HEIGHT='"+height+"' CONTROLLER='TRUE' TARGET='myself' SRC='"+file+"' type='video/quicktime' PLUGINSPAGE='http://www.apple.com/quicktime/download/index.html'></EMBED>";
		block += "</OBJECT>";
	}
	else{
		var block = "<object classid='CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95' width='"+width+"' height='"+height+"' id='mediaplayer1'>";
		block += "<param name='src' value='"+file+"'>";
		block += "<param name='FileName' value='"+file+"'>";
		block += "<param name='AutoStart' value='True'>";
		block += "<param name='ShowControls' value='True'>";
		block += "<param name='ShowStatusBar' value='False'>";
		block += "<param name='ShowDisplay' value='False'>";
		block += "<param name='AutoRewind' value='False'>";
		block += "<embed type='application/x-mplayer2' pluginspage='http://www.microsoft.com/Windows/Downloads/Contents/MediaPlayer/' src='"+file+"' width='"+width+"' height='"+height+"' autostart='True' filename='"+file+"' showcontrols='True' showstatusbar='False' showdisplay='False' autorewind='True'></embed>";
		block += "</object>";
	}
	document.getElementById(layer).innerHTML = block;
}
