var live_player;
var live_playerpath = 'player.swf';
var live_rtmpt = true;
//var live_rtmpt = false;
var live_enabled = true;
var live_quality = -1;
var live_url = 0;
var live_params = [
    { file: 'stream-low.flv', width: '360', height: '288' },
    { file: 'stream.flv', width: '540', height: '432' },
    { file: 'stream-high.flv', width: '720', height: '576' }];
//var live_params = [
//    { file: 'Beer_fest_low.flv', width: '360', height: '288' },
//    { file: 'Beer_fest_middle.flv', width: '540', height: '432' },
//    { file: 'Beer_fest_middle.flv', width: '720', height: '576' }];
var URL = [ { file: 'stream.flv', streamer: 'rtmp://stream18.techbrothers.tv:1935/datagroup/'},
	    { file: 'stream.flv', streamer: 'rtmp://stream18.techbrothers.tv:1935/dg-edge/'},
	    { file: 'stream.flv', streamer: 'rtmp://stream19.techbrothers.tv:1935/dg-edge/'},
	    { file: 'stream.flv', streamer: 'rtmp://stream20.techbrothers.tv:1935/dg-edge/'},
	    { file: 'stream.flv', streamer: 'rtmp://stream21.techbrothers.tv:1935/dg-edge/'}];

function liveInit(quality) {
//  quality = quality ? 1 : 0;
  var params = {
    allowfullscreen: 'true',
    allowscriptaccess: 'always',
    wmode: 'opaque'
  };
  var flashvars = {
    controlbar: 'over',
    wmode: 'opaque',
    fullscreen: 'true',
    displaywidth: live_params[quality].width,
    displayheight: live_params[quality].height,
    autostart: 'true',
    volume: 50,
//    image: '/images/logo_' + live_params[quality].width + 'x' + live_params[quality].height + '.jpg',
    bufferlength: 2,
//    plugins: 'viral-2d',
    provider: 'rtmp',
    displayclick: 'none',
    stretching: 'uniform',
    streamer: URL[live_url].streamer, 
    file: live_params[quality].file
  };
  var attributes = {
    id: "live_player",
    name: "live_player"
  };

  swfobject.embedSWF(live_playerpath, "live_player", live_params[quality].width, live_params[quality].height, "8.0.0", "expressInstall.swf", flashvars, params, attributes);
//  liveSwitchQuality(quality);

//  var texturl = document.getElementById('URL'+live_url+'');
//  texturl.style = "font-weight:bold; color: red;";
//  alert (texturl);
}

function playerReady(obj) {
  live_player = document.getElementById(obj.id);
//    var id = obj['id'];
//    var version = obj['version'];
//    var client = obj['client'];
//    alert(id+", "+version+", "+client);
}

function liveSwitchQuality(quality) {
  if(live_quality == quality ) return;    
    live_quality = quality;
  if(live_player)	
    live_player.sendEvent('LOAD', live_params[quality]);
//	live_player.style.width=live_params[quality].width;
//	live_player.style.height=live_params[quality].height;

//	jQuery('#live_quality a').removeClass('active');
//	jQuery('#live_quality a.' + (quality ? 'high' : 'low')).addClass('active');
}

function liveSwitchUrl(url) {
//  text_url = document.getElementById("URL"+url);
  if(live_url == url ) return;    
    var texturl = document.getElementById('texturl'+live_url);
    if (texturl.style) { texturl.style.color = "blue"; }
    live_url = url;
  if(live_player){	
    live_player.sendEvent('LOAD', URL[url]); 
//    alert (URL[url].streamer);
    texturl = document.getElementById('texturl'+url);
    if (texturl.style) {texturl.style.color = "red"; }
    }
}



