function getText(objectID){
    var inhalt = document.getElementById(objectID).innerHTML;
    document.getElementById("ausgabe").innerHTML = inhalt;
    var elem = document.getElementById('fullscreen');
    elem.className='full_aktiv';
    window.location.hash = '#player_anker';
}

function getTextprj(IDwoche, IDtitel, IDtext){
    var inhaltwoche = document.getElementById(IDwoche).innerHTML;
    document.getElementById("tv_ausgabe_woche").innerHTML = inhaltwoche;
    var inhalttitel = document.getElementById(IDtitel).innerHTML;
    document.getElementById("tv_ausgabe_titel").innerHTML = inhalttitel;
    var inhalttext = document.getElementById(IDtext).innerHTML;
    document.getElementById("tv_ausgabe_text").innerHTML = inhalttext;
}


function getUriParams() {
  var params = window.location.search.replace(/^\?/, '').split('&');
  var result = new Object();
  for(i=0; i<params.length; i++) {
    var p = params[i].split("=");
    if(p[0] != '') result[p[0]] = (typeof p[1] == 'string' ? p[1] : '');
  }
  return result;
}




function flvplyr(element, opts) {
  // default options
  this.options = {
    'width': 500,
    'height': 300,
    'flashVersion': 7,
    'swfParams': {},
    'swfVariables': {'file':''},
    'swfElement': '',
    'swfPlayerId': element
  }
  this.isValidPlayer = true;
  
  // merge defaults with user options
  for(var o in opts) {
    this.options[o] = opts[o];
  }
  
  // ensure, that element is a player and provides the javascript api
  if(navigator.userAgent.indexOf('Safari') > -1) {
  	this.isValidPlayer = false;
  } else if(!document.getElementById(element).sendEvent) {
    this.isValidPlayer = false;
    // element contains no flashplayer, load one
    if(!SWFObject) alert('SWFObject doesn\'t seem to be available!'); return false;
  }
  
  this.player = document.getElementById(element);
  return this;
}

flvplyr.prototype = {
  '_sendCmd': function(cmd) {
    this.player = document.getElementById(this.options.swfPlayerId);
    this.player.sendEvent(cmd);
    return this;
  },
  'load': function(file) {
    current_file = file;
    if(!this.isValidPlayer) {
      this.createPlayer(file);
      return this;
    }
    this.player.loadFile({
      'file': file
    });
    return this;
  },
  'delayPlay': function() {
    this.player = document.getElementById(this.options.swfPlayerId);
    return this._sendCmd('playpause');
  },
  'play': function() {
    if(!this.isValidPlayer) {
      //console.log("trying delayplay");
      this.isValidPlayer = true;
      setTimeout(function() {player.delayPlay()}, 1000);
      return this;
    }
    return this._sendCmd('playpause');
  },
  'stop': function() {
    if(!this.isValidPlayer) {
      this.createPlayer(file);
      return this;
    }
    return this._sendCmd('stop');  
  },
  'pause': function() {
    return this._sendCmd('playpause');
  },
  'next': function() {},
  'createPlayer': function(videoFile) {
    this.options.swfVariables.file = videoFile;
    //console.log('creating player with file ' + videoFile);
    var swf = new SWFObject(this.options.swfPlayerFile, this.options.swfPlayerId, this.options.width, this.options.height, this.options.flashVersion);
    // add params
    for(var param in this.options.swfParams) swf.addParam(param, this.options.swfParams[param]);
    // add variables
    for(var variable in this.options.swfVariables) swf.addVariable(variable, this.options.swfVariables[variable]);
    swf.write(this.options.swfElement);
    //this.isValidPlayer = true;
    this.player = document.getElementById(this.options.swfPlayerId);
    return this;
  }
}
/**/

var player;
var current_file;
function providePlayerControl() {
  player = new flvplyr('mediaplayer', {
    'width': 500,
    'height': 300,
    'flashVersion': 7,
    'swfElement': 'player_area',
    'swfPlayerFile': 'fileadmin/videos/flashplayer.swf',
    //'swfPlayerFile': 'videos/mediaplayer.swf',
    'swfParams': {
      'allowfullscreen': 'true',
      'allowscriptaccess': 'always',
      'value': 'transparent',
      'wmode': 'transparent'
    },
    'swfVariables': {
      'allowfullscreen': 'true',
      'wmode': 'transparent',
      'width': 500,
      'height': 300,
      'file': '',
      'image': '',
      'enablejs': 'true',
      'backcolor': '0x00000',
      'frontcolor': '0xffffff',
      'lightcolor': '0x57ACEC',
      'screencolor': '0x000000'
    }
  });
}

/*
// onload handling
if(window.attachEvent) { // ie, opera
  window.attachEvent('onload', providePlayerControl);
} else if(window.addEventListener) { // mozilla
  window.addEventListener('load', providePlayerControl, false);
} else { // other crappy browsers
  window.onload = providePlayerControl;
}
/**/