﻿// see http://kpumuk.info/asp-net/using-panel-defaultbutton-property-with-linkbutton-control-in-asp-net/
function clickButton(e, buttonid) {
  if (e.keyCode == 13) {
    var b = document.getElementById(buttonid);
    if (b) {
      if (typeof (b.click) == 'undefined') {
        b.click = function() {
          var result = true;
          if (b.onclick) result = b.onclick();
          if (typeof (result) == 'undefined' || result) {
            eval(b.getAttribute('href'));
          }
        }
      }

      if (typeof (b.click) != "undefined") {
        b.click();
        e.cancelBubble = true;
        if (e.stopPropagation) e.stopPropagation();
        return false;
      }
    }
  }
  return true;
}

// Functions for JW flv player
function deleteJWPlayer(theWrapper, thePlaceholder, thePlayerId) { 
  swfobject.removeSWF(thePlayerId);
  var tmp=document.getElementById(theWrapper);
  if (tmp) { tmp.innerHTML = "<div id=" + thePlaceholder + "><p>Flash content: video\/audio player.<br \/><br \/>You need to upgrade your Flash Player to view this. <a href=\"http:\/\/get.adobe.com\/flashplayer\/\">Get Adobe Flash Player<\/a><\/p><\/div>"; }
}

function createJWPlayer(thePlaceholder, thePlayerId, theFile) {
  var flashvars = {
    file:theFile
    ,autostart:"true"
    ,screencolor:"#1a1a1a"
  }
  var params = {
    allowfullscreen:"true"
    ,allowscriptaccess:"always"
    ,wmode:"transparent"
    ,bgcolor:"#000000"
  }
  var attributes = {
    id:thePlayerId
    ,name:thePlayerId
  }
  // height is 180px (video) + 20px (control bar) = 200px
  swfobject.embedSWF("/Style%20Library/Winchester/scripts/player.swf", thePlaceholder, "280", "200", "9.0.0", "", flashvars, params, attributes);
}


function createWMVPlayer(thePlaceholder, theFile, theHeight, theWidth, theAutostart) {
  var src = '/Style%20Library/Winchester/scripts/wmvplayer.xaml';
  if (!theFile) theFile='';
  if (!theHeight) theHeight='200';
  if (!theWidth) theWidth='280';
  if (!theAutostart) theAutostart='true';
  var cfg = {
      file:theFile
    , width:theWidth
    , height:theHeight
    , backgroundcolor:'000000'
    , screencolor:'303030'
    , windowless:'true'
    , autostart:theAutostart
  };
  var ply = new jeroenwijering.Player(document.getElementById(thePlaceholder), src, cfg);
  return ply;
}

// Generic SWF
function showGenericSWF(thePlaceholder, theFile, theWidth, theHeight) {
    swfobject.embedSWF(theFile, thePlaceholder, theWidth, theHeight, "9.0.0", "", {}, { wmode:"transparent", bgcolor:"#000000" }, {});
}
