// .
// Please ALWAYS replace this _hasTimeOut with the length of the pre-content ad movie:
// It is required in some cases (in milliseconds! 20000ms == 20s).
// The timeout is used only in the following two scenarios:
//    (1) if the pre-content ad is a third-party ad; the timeout should be the length of
//        the pre-content ad.
//    (2) if the pre-content ad is WMV _and_ the content is NOT WMV but is either MOV or FLV,
//        then the timeout should be the length of the pre-content ad.
// . 
// In the case where the content is WMV and the pre-content ad is WMV, a WMV playlist is
// used.  In the case where the pre-content ad is SWF, a widget which explicitly invokes
// the content object is used, so a timeout is not required.
// .
var _hasTimeOut = 1000;

// Define LBhasThirdParty below to reference a JAVASCRIPT (.js) that will serve the
// third party Leave-Behind, if you want to use a third-party Leave-Behind.  If not,
// just leave it defined false.
var LBhasThirdParty = false;
//var LBhasThirdParty = "http://somedomain/some_tag/some_leavebehind.js";

// Define ADhasThirdParty below to reference either a JAVASCRIPT (.js) that will serve
// the third-party pre-content Ad, if you want to use a third-party pre-content ad.  You
// can also define a SWF (.swf) reference OR a WMV (.wmv) reference for the pre-content
// ad.  If you do not wish to use a third-party pre-content ad, leave this false.
// Please note that if you are using a .swf pre-content ad, that the ad MUST absolutely
// have a final frame (and not loop), otherwise we will not be able to detect its end.
var ADhasThirdParty = "NONE";
//var ADhasThirdParty = "http://somedomain/some_tag/some_precontent_ad.js";
//var ADhasThirdParty = "http://somedomain/some_pre_content_ad.wmv";
//var ADhasThirdParty = "http://somedomain/some_pre_content_ad.swf";

// WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING !!!!!!
// ......................................................................................
// Please do not touch anything below this line.
// ......................................................................................

var _third_party_type = false;
if ((ADhasThirdParty != false) && (ADhasThirdParty != true)) {
  if ((ADhasThirdParty.indexOf('.wmv') != -1) || (ADhasThirdParty.indexOf('.WMV') != -1)) {
    _third_party_type = "WMV";
  } else if ((ADhasThirdParty.indexOf('.swf') != -1) || (ADhasThirdParty.indexOf('.SWF') != -1)) {
    _third_party_type = "SWF";
  }
}

if (LBhasThirdParty != false) {
  document.write('<IFRAME SRC="http://pubs.branchez-vous.com/BVTV/gen_tp_js.cgi?url=' + LBhasThirdParty + '" WIDTH=350 HEIGHT=280 FRAMEBORDER=0></IFRAME>');
}
document.write('</div>');
document.write(_inbetween_html);
document.write('<div id="adc_rich_content">');
if ((ADhasThirdParty != false) && (_third_party_type == false)) {
  document.write('<IFRAME SRC="http://pubs.branchez-vous.com/BVTV/gen_tp_js.cgi?url=' + ADhasThirdParty + '" WIDTH=350 HEIGHT=280 FRAMEBORDER=0></IFRAME>');
}


var type_content = 'WMV';
if ((url_content.indexOf('.mov') != -1) || (url_content.indexOf('.MOV') != -1)) {
  type_content = 'MOV';
} else if ((url_content.indexOf('.m4v') != -1) || (url_content.indexOf('.M4V') != -1)) {
  type_content = 'M4V';
} else if ((url_content.indexOf('.flv') != -1) || (url_content.indexOf('.FLV') != -1)) {
  type_content = 'FLV';
}

var hasFlash = (false);
var hasWMV = (false);

window.onload = function () {
  var LB_SWF_CLICK = ("http://pubs.branchez-vous.com/adcentric/click/78/1/1450;id=10800");
  var LB_GIF_CLICK = ("http://pubs.branchez-vous.com/adcentric/click/78/1/1450;id=10799");
  var AD_SWF_CLICK = ("http://pubs.branchez-vous.com/adcentric/click/78/1/1450;id=10801");
  var AD_WMV_CLICK = ("http://pubs.branchez-vous.com/adcentric/click/78/1/1450;id=10802");

 if (LBhasThirdParty == false) {
  if (!hasFlash) {
    var gif = "<table border=\"0\" width=\"305\" height=\"280\" bgcolor='#000099' cellspacing=\"0\" cellpadding=\"0\">" +
      "<tr><td align=\"center\">";
      if (LB_GIF_CLICK) {
           gif += "<a href='#'><img src='http://pub2.branchez-vous.com/images/bvtv_default_new.gif' width='300' height='250' border='0'></a>";
      } else {
           gif += "<img src='http://pub2.branchez-vous.com/images/bvtv_default_new.gif' border='0' width='300' height='250'>";
      }
      gif += "</td></tr></table>";
    var o = document.getElementById('adc_rich_lb');
    o.innerHTML = gif;
  } else {
    var swf = "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\"" +
      " codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0\"" +
      " WIDTH=\"305\" HEIGHT=\"280\" id=\"LBPlayer\">" +
      "<PARAM NAME=movie VALUE=\"http://pubs.branchez-vous.com/adcentric/direct/all_creatives/?clickTAG=http://pubs.branchez-vous.com/adcentric/click/78/1/1450;id=10800\">" +
      "<PARAM NAME=bgcolor VALUE=\"#000000\">" +
      "<EMBED src=\"http://pubs.branchez-vous.com/adcentric/direct/all_creatives/?clickTAG=http://pubs.branchez-vous.com/adcentric/click/78/1/1450;id=10800\"" +
      " BGCOLOR=\"#000000\" WIDTH=\"305\" HEIGHT=\"280\"" +
      " NAME=\"LBPlayer\" TYPE=\"application/x-shockwave-flash\"" +
      " PLUGINSPAGE=\"http://www.macromedia.com/go/getflashplayer\"></EMBED>" +
      "</object>";
      var o = document.getElementById('adc_rich_lb');
      o.innerHTML = swf;
  }
 }

 if ((ADhasThirdParty == false) || (_third_party_type == "WMV") || (_third_party_type == "SWF")) {
  if (((!hasWMV) && (_third_party_type != "WMV")) || (_third_party_type == "SWF")) {
    var _the_swf_ad_file = ("http://pubs.branchez-vous.com/adcentric/direct/all_creatives/");
    if (_third_party_type == "SWF") {
      _the_swf_ad_file = ADhasThirdParty;
    }
    var swf = "<OBJECT classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" " +
      "codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0\" " +
      "WIDTH=\"330\" HEIGHT=\"280\" id=\"bootstrapPlayer\">" +
      "<PARAM NAME=movie VALUE=\"http://pubs.branchez-vous.com/BVTV/player_16-9.swf?" +
      "url_ad_swf=" + _the_swf_ad_file + "&url_content=" + url_content +
      "&play_track_interval=0&url_play_pixel=0\">" +
      "<PARAM NAME=bgcolor VALUE=\"#000000\">" +
      "<EMBED src=\"http://pubs.branchez-vous.com/BVTV/player_16-9.swf?" +
      "url_ad_swf=" + _the_swf_ad_file + "&url_content=" + url_content +
      "&play_track_interval=0&url_play_pixel=0\" bgcolor=\"#000000\" " +
      "WIDTH=\"330\" HEIGHT=\"280\" " +
      "NAME=\"bootstrapPlayer\" ALIGN=\"\" TYPE=\"application/x-shockwave-flash\"" +
      " PLUGINSPAGE=\"http://www.macromedia.com/go/getflashplayer\"></EMBED></OBJECT>";
    var o = document.getElementById('adc_rich_content');
    o.innerHTML = swf;
  } else {
    var _the_wmv_ad_file = ("http://pubs.branchez-vous.com/adcentric/direct/all_creatives/");
    if (_third_party_type == "WMV") {
      _the_wmv_ad_file = ADhasThirdParty;
    }

    var url_playlist = "http://angelina.branchez-vous.net/cgi-bin/gen_playlist.cgi?url_ad=" + _the_wmv_ad_file + "&url_content=" + url_content;
    if (type_content != "WMV") {
      url_playlist = _the_wmv_ad_file;
    }

    var wmv = "<OBJECT ID=\"MediaPlayerContent\" WIDTH=330 HEIGHT=280" +
      " CLASSID=\"CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95\" " +
      "CODEBASE=\"http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701\"" +
      " STANDBY=\"Loading Windows Media Player components...\"" +
      " TYPE=\"application/x-oleobject\">" +
      "<PARAM NAME=\"FileName\" VALUE=\"" + url_playlist + "\">" +
      "<PARAM NAME=\"autoStart\" VALUE=\"true\">" +
      "<PARAM NAME=\"showControls\" VALUE=\"true\">" +
      "<PARAM NAME=\"animationStart\" VALUE=\"true\">" +
      "<PARAM NAME=\"transparentatStart\" VALUE=\"true\">" +
      "<EMBED TYPE=\"application/x-mplayer2\"" +
      " SRC=\"" + url_playlist + "\" NAME=\"MediaPlayerContent\"" +
      " WIDTH=330 HEIGHT=280></EMBED></OBJECT>";
    var o = document.getElementById('adc_rich_content');
    o.innerHTML = wmv;
  }
 }
}

// cannot detect end of WMV nor Third Party pre-content ad, so we need to use timeout.
// exception if pre-content ad is WMV _AND_ content is WMV, then we use playlist.
if (((ADhasThirdParty != false) && (_third_party_type == false)) || ((type_content != "WMV") && (hasWMV || (_third_party_type == "WMV")))) {
  setTimeout("loadContent(url_content);", _hasTimeOut);
}

loadContent = function(url_content) {
  if (url_content.indexOf('mms://') == 0) {
        url_content = url_content.replace("mms://", "http://");
  }

  var content = "";

  if (type_content == "FLV") {
    content = "<OBJECT id=\"FlashPlayerContent\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" " +
      "codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0\" " +
      "WIDTH=\"330\" HEIGHT=\"280\">" +
      "<PARAM NAME=\"movie\" VALUE=\"http://angelina.branchez-vous.net/BVTV/FLV_PLAYER/flvplayer.swf?autostart=true&file=" + url_content + "\" />" +
      "<PARAM NAME=\"wmode\" VALUE=\"transparent\" /><embed src=\"http://angelina.branchez-vous.net/BVTV/FLV_PLAYER/flvplayer.swf?file=" + url_content + "&autostart=true\"  type=\"application/x-shockwave-flash\" wmode=\"transparent\" width=\"330\" height=\"280\"></embed></OBJECT>";
  } else if (type_content == "MOV") {
    content = "<OBJECT ID=\"QuicktimePlayerContent\" WIDTH=330 HEIGHT=280" +
      " CLASSID=\"CLSID:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B\" " +
      "CODEBASE=\"http://www.apple.com/qtactivex/qtplugin.cab\">" +
      "<PARAM NAME=\"src\" VALUE=\"" + url_content + "\">" +
      "<PARAM NAME=\"autoplay\" VALUE=\"true\">" +
      "<PARAM NAME=\"autostart\" VALUE=\"true\">" +
      "<PARAM NAME=\"controller\" VALUE=\"true\">" +
      "<EMBED SRC=\"" + url_content + "&autostart=true\" WIDTH=\"330\" HEIGHT=\"280\" AUTOPLAY=\"true\" CONTROLLER=\"true\" PLUGINSPAGE=\"http://www.apple.com/quicktime/download/\">" +
      "</EMBED></OBJECT>";
  } else if (type_content == "M4V") {
    content = "<EMBED QTSRC=\"" + url_content + "\" SRC=\"http://tv.branchez-vous.net/qt-check.qti\" WIDTH=\"330\" HEIGHT=\"280\" TYPE=\"image/x-quicktime\" PLUGINSPAGE=\"http://www.apple.com/quicktime/download/\"></EMBED>";
  } else {
    content = "<OBJECT ID=\"MediaPlayerContent\" WIDTH=330 HEIGHT=280" +
      " CLASSID=\"CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95\" " +
      "CODEBASE=\"http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701\"" +
      " STANDBY=\"Loading Windows Media Player components...\"" +
      " TYPE=\"application/x-oleobject\">" +
      "<PARAM NAME=\"FileName\" VALUE=\"" + url_content + "\">" +
      "<PARAM NAME=\"autoStart\" VALUE=\"true\">" +
      "<PARAM NAME=\"showControls\" VALUE=\"true\">" +
      "<PARAM NAME=\"animationStart\" VALUE=\"true\">" +
      "<PARAM NAME=\"transparentatStart\" VALUE=\"true\">" +
      "<EMBED TYPE=\"application/x-mplayer2\"" +
      " SRC=\"" + url_content + "\" NAME=\"MediaPlayerContent\"" +
      " WIDTH=330 HEIGHT=280></EMBED></OBJECT>";
  }

  var o = document.getElementById('adc_rich_content');
  o.innerHTML = content;
}
