    dojo.require("dijit.Dialog");
    dojo.addOnLoad( function() {
        dojo.addClass(dojo.body(), "tundra");
		Page.PopupPrefix = dojo.byId("_divVideoContainer") == null ? "" : "_";
    } );
	
	function getInnerHTML( p_strID ) {
		return( dojo.byId(p_strID) == null ? "" : dojo.byId(p_strID).innerHTML );
	}
	function getFlashRequiredMessage() {
	    return( "<div class='center' style='width:90%;height:90%;overflow:auto;margin:0px auto;'>" +
					"<br /><br /><h4 class='heading center'>This Video Requires Flash Player</h4><br />" +
					"<p class='center'>You do not appear to have the flash player installed.<br />" +
					"Please install the latest flash player by <a href='http://get.adobe.com/flashplayer/' target='_blank'>clicking here</a></p>" +
				"</div>" );
	}
    function openVideo(p_iID, p_strDate, p_strVimeoID, p_strFilePath) {
        var strName     = getInnerHTML("Video" + p_iID + "_Name");
        var strDescr    = getInnerHTML("Video" + p_iID + "_Description");
		var strURL		= window.location.href.replace(/^(.*\/)[^\/]*$/,"$1") + "multimedia.aspx?media=" + p_iID;
        
        dojo.byId(Page.PopupPrefix+"divVideoDate").innerHTML  = p_strDate;
        dojo.byId(Page.PopupPrefix+"divVideoTitle").innerHTML = strName;
		if( dojo.byId(Page.PopupPrefix+"divDirectLink") != null ) {
        	dojo.byId(Page.PopupPrefix+"divDirectLink").innerHTML = "Direct Link: <a href='" + strURL + "'>" + strURL + "</a>";
		}

        if( p_strVimeoID != "" ) {
			if( Tao.User.HasFlash ) {
				dojo.byId(Page.PopupPrefix+"divVideoContainer").innerHTML = "<div style='width:765px;height:350px;overflow:auto;margin:0px auto;'><div class='center'>"+
				  "<object id=\"player\" width='548' height='304'>" +
					"<param name='allowfullscreen' value='true'>" +
					"<param name='allowscriptaccess' value='always'>" +
					"<param name='movie' value='http://vimeo.com/moogaloop.swf?clip_id=" + p_strVimeoID + "&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=cccccc&amp;fullscreen=1'>" +
					"<embed id=\"player_child\" src='http://vimeo.com/moogaloop.swf?clip_id=" + p_strVimeoID + "&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=cccccc&amp;fullscreen=1' type='application/x-shockwave-flash' allowfullscreen='true' allowscriptaccess='always' width='548' height='304'>" +
				  "</object>" +
					"</div><div style='padding:8px 8px 8px 8px;'>" +
					"<p class='center'>" + strDescr + "</p>" +
				"</div></div>";
			}
			else {
				dojo.byId(Page.PopupPrefix+"divVideoContainer").innerHTML = getFlashRequiredMessage();
			}
        }
        else {
            dojo.byId(Page.PopupPrefix+"divVideoContainer").innerHTML = "<div style='width:765px;height:350px;overflow:auto;margin:0px auto;'<div class='center'>" +
				"<object id=\"player\" classid=\"CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6\" width=\"320\" height=\"280\">" +
					"<param name=\"url\" value=\"" + p_strFilePath + "\" />" +
					"<param name=\"src\" value=\"" + p_strFilePath + "\" />" +
					"<param name=\"showcontrols\" value=\"true\" />" +
					"<param name=\"autostart\" value=\"true\" />" +
					"<!--[if !IE]>-->" +
					"<object id='player_child' type=\"video/x-ms-wmv\" data=\"" + p_strFilePath + "\" width=\"320\" height=\"280\">" +
					"<param name=\"src\" value=\"" + p_strFilePath + "\" />" +
					"<param name=\"controller\" value=\"true\" />" +
					"<param name=\"autostart\" value=\"true\" />" +
					"</object>" +
					"<!--<![endif]-->" +
                "</object>" +
				"</div><div class='center' style='padding:8px 8px 8px 8px;'>" +
				"<p class='center'>" + strDescr + "</p>" +
				"</div></div>";
        }
        dijit.byId(Page.PopupPrefix+"divVideoPopup").show();
        //alert("DATE: " + p_strDate + "\nNAME: " + p_strName + "\nID: " + p_strVimeoID);
		
		var oDialog		= dijit.byId(Page.PopupPrefix+"divVideoPopup");
		dojo.connect( oDialog, "hide", function() {
			var Player = dojo.byId("player");
			var PlayerChild = dojo.byId("player_child");
			if( Player != null && Player.controls != null ) {
				Player.controls.pause();
			}
			else if( Player != null && PlayerChild != null ) {
				Player.removeChild( PlayerChild );
				Player.parentNode.removeChild( Player );
			}
		} );
    }
	
	var Tao 			= new Object();
	Tao.User			= new Object();
	Tao.User.Flash		= new Object();
	Tao.User.HasFlash	= false;
	
(function() {
  /**
   * Derived from Apple's suggested sniffer.
   * @param {String} desc e.g. Shockwave Flash 7.0 r61
   * @return {String} 7.0.61
   */
  function getFlashVersion(desc) {
    var matches = desc.match(/[\d]+/g);
    matches.length = 3;  // To standardize IE vs FF
    return matches.join('.');
  }

  var hasFlash = false;
  var flashVersion = '';

  if (navigator.plugins && navigator.plugins.length) {
    var plugin = navigator.plugins['Shockwave Flash'];
    if (plugin) {
      hasFlash = true;
      if (plugin.description) {
        flashVersion = getFlashVersion(plugin.description);
      }
    }

    if (navigator.plugins['Shockwave Flash 2.0']) {
      hasFlash = true;
      flashVersion = '2.0.0.11';
    }

  } else if (navigator.mimeTypes && navigator.mimeTypes.length) {
    var mimeType = navigator.mimeTypes['application/x-shockwave-flash'];
    hasFlash = mimeType && mimeType.enabledPlugin;
    if (hasFlash) {
      flashVersion = getFlashVersion(mimeType.enabledPlugin.description);
    }

  } else {
    try {
      // Try 7 first, since we know we can use GetVariable with it
      var ax = new ActiveXObject('ShockwaveFlash.ShockwaveFlash.7');
      hasFlash = true;
      flashVersion = getFlashVersion(ax.GetVariable('$version'));
    } catch (e) {
      // Try 6 next, some versions are known to crash with GetVariable calls
      try {
        var ax = new ActiveXObject('ShockwaveFlash.ShockwaveFlash.6');
        hasFlash = true;
        flashVersion = '6.0.21';  // First public version of Flash 6
      } catch (e) {
        try {
          // Try the default activeX
          var ax = new ActiveXObject('ShockwaveFlash.ShockwaveFlash');
          hasFlash = true;
          flashVersion = getFlashVersion(ax.GetVariable('$version'));
        } catch (e) {
          // No flash
        }
      }
    }
  }
  
  Tao.User.HasFlash			= hasFlash;
  Tao.User.Flash.Version 	= flashVersion;

})();