var tvbgX = 1024;
var tvbgY = 768;
var videoT = 102;
var videoL = 78;
var videoX = 640;
var videoY = 480;
var videoS = 1.1;
function doResize(player) {
  var p = player.getParent();
  var w = p.clientWidth;
  var h = p.clientHeight;
  var fw = w / tvbgX;
  var fh = h / tvbgY;
  var f = fw;
  if (fh < fw) {
    f = fh;
  }
  var cw = tvbgX * f;
  var ch = tvbgY * f;
  var sw = videoX * f * videoS;
  var sh = videoY * f * videoS;
  var ct = h / 2 - ch / 2;
  var cl = w / 2 - cw / 2;
  if (ct < cl) {
    ct = 0;
  } else {
    cl = 0;
  }
  var st = videoT * f + ct;
  var sl = videoL * f + cl;
  player.getScreen().css({top:st,left:sl,width:sw,height:sh});
  var p = player.getPlugin("content");
  p.setHtml('<img src="/images/tvbg.png" width="' + cw + '" height="' + ch + '" />');
  p.css({top:ct,left:cl});
}
function doRequest() {
  $.getScript('live.js');
}
$f("player", "/flowplayer/flowplayer-3.1.5.swf",  {
onLoad: function() {
  doResize(this);  
},
clip: {
  baseUrl: 'http://www.westfernsehen.net/video', 
  autoPlay: true,
  autoBuffering: true
},
play: null,
canvas: {
  backgroundColor: '#000000',
  backgroundGradient: 'none'
},
plugins:  {
  controls: null,
  content: {
    url: '/flowplayer/flowplayer.content-3.1.0.swf',
    backgroundColor: 'transparent',
    backgroundGradient: 'none',
    border: 0, borderRadius: 0, opacity: 1,
    top: 0, left: 0, width: '100%', height: '100%'
  }
},
playlist: [{
  url: '/images/blank.png', duration: 10,
  onStart: function() { doRequest(); },
  onBeforeFinish: function() { return false; }
}]
});

$(window).resize(function() {
  doResize($f("player"));
});

