  Brandwire = {

    BaseUrl : '/Brandwire',

    CustomInfo: '',

    Banner : {
      b1 : {
  end: true
}
,
      b2 : {
  end: true
}
,
      b3 : {
  end: true
}

    },

    Videos : {
      
      v9251785 : {
        videoId: 9195975,
        videoUrl: "http://res.brandwire.tv/scdn/content/brandwire/resources/res20100804/v1280915280420.mp4",
        imgUrl: "http://res.brandwire.tv/scdn/content/brandwire/resources/res20100804/i1280915392476.jpeg",
        facadeUrl: "http://res.brandwire.tv/scdn/content/brandwire/resources/res20101007/f1286449798581.swf",
        title: 'Pressemitteilung August',
        subtitle: '',
        external: false,
        b1: {
  end: true
}
,
        noAds: false
      },
      
      
      end : true
    },

    selectedCat : -1,
    selectedVid : -1,
    prerollId : -1,
    postrollId : -1,
    bannerId : -1,
    autostart : false,
    muted : false,
    SessionID : '464056769124920756',
    ClientSessionID : false,
    RefDomain : 'www.notare.bayern.de',
    RefBannerID : 0,
    videoPlayerCount : 0,
    thirdPartyTrackingUrl: '',

    showCategory : function(n) {
      var el,i;
      if (Brandwire.selectedCat != -1) {
        el = document.getElementById('bw_ce_' + Brandwire.selectedCat);
        el.setAttribute('class', 'category_entry');
        el.className = 'category_entry';
        el = document.getElementById('bw_pl_' + Brandwire.selectedCat);
        el.setAttribute('class', 'hidden');
        el.className = 'hidden';
      }
      Brandwire.selectedCat = n;
      el = document.getElementById('bw_ce_' + n);
      el.setAttribute('class', 'category_entry bwselect');
      el.className = 'category_entry bwselect';
      el = document.getElementById('bw_pl_' + n);
      el.setAttribute('class', 'show');
      el.className = 'show';
      var images = document.getElementsByTagName("img");
      for (i=0; i<images.length; i++) {
        el = images[i];
        if (el.getAttribute('catId') == n) el.src = el.getAttribute('srcUrl');
      }
    },

    sendStatsRequest : function(bannerId, viewRate) {
      if (bannerId != -1) {
        if (viewRate == 1) Brandwire.startedBannerId = bannerId;
        else {
          if (bannerId != Brandwire.startedBannerId) viewRate = 0
          Brandwire.startedBannerId = -1
        }
      }
      if (document.getElementById('stats_img') && viewRate > 0)
        document.getElementById('stats_img').src = Brandwire.BaseUrl + '/player/stats?mc=1599&ch=' + Brandwire.selectedCat + '&vi=' + Brandwire.selectedVid + '&b1=' + Brandwire.bannerId + '&b2=' + bannerId + '&vr=' + viewRate + '&se=' + Brandwire.SessionID + '&do=' + Brandwire.RefDomain + '&rb=' + Brandwire.RefBannerID + '&ci=' + Brandwire.CustomInfo + '&cc=' + ((new Date()).getTime());
    },
    sendThirdPartyRequest: function() {
      if (Brandwire.thirdPartyTrackingUrl && Brandwire.thirdPartyTrackingUrl.length > 0 && document.getElementById('thirdparty_stats_img'))
        document.getElementById('thirdparty_stats_img').src = Brandwire.thirdPartyTrackingUrl;
    },

    getPlayerImageTag: function(url) {
      if (!url) url = 'http://res.brandwire.tv/scdn/content/brandwire/bw_testbild.png';
      return '<img width="494" height="278" src="' + url + '" />';
    },

    showVideo : function(n) {
      if (!Brandwire.ClientSessionID) Brandwire.ClientSessionID = ((new Date()).getTime()) & 0x7fffffff;
      Brandwire.videoPlayerCount++;
      if (!swfobject.hasFlashPlayerVersion('10.0.0') && document.getElementById('stats_img')) {
          document.getElementById('stats_img').src = Brandwire.BaseUrl + '/player/playerLog?mc=1599&pc=' + Brandwire.videoPlayerCount + '&vi=' + Brandwire.selectedVid + '&st=1&et=9&se=' + Brandwire.SessionID + '&cs=' + Brandwire.ClientSessionID + '&do=' + Brandwire.RefDomain + '&ci=' + Brandwire.CustomInfo + '&ud=' + ((new Date()).getTime());
      }
      if (document.getElementById('player')) document.getElementById('player').innerHTML = '<div id="bwPlayerDiv">' + Brandwire.getPlayerImageTag() + '</div>';
      var cf = Brandwire.Videos['v' + n];
      if (cf.external) {
        document.getElementById('bwPlayerDiv').innerHTML = Brandwire.getPlayerImageTag(cf.imgUrl);
        if (Brandwire.selectedVid != -1) {
          var nw = window.open(cf.videoUrl, 'bwb_external_player_' + n);
          nw.focus();
        }
      } else {
        var bwFlashBaseUrl = 'http://res.brandwire.tv/scdn/content/brandwire/';
        var playerSwf = (cf.facadeUrl ? cf.facadeUrl : (bwFlashBaseUrl+'BrandwirePreloader.swf'));
        var autoPlay = (Brandwire.selectedVid != -1) || Brandwire.autostart;
        var flashvars = {
          src: escape(cf.videoUrl),
          autostart: '' + autoPlay,
          muted: Brandwire.muted,
//          mutedIcon: 'true',
          sessionId: '1599',
          themeColor: '264FB9',
          mode: "overlay",
          scaleMode: "fit",
          frameColor: "ffffff",
          fontColor: "DDDDDD",
          link: "",
          embed: "",

          skinUrl: bwFlashBaseUrl + 'BrandwireSkin_1.5.swf',
          playerUrl: bwFlashBaseUrl+'BrandwirePlayer.swf',
          width:"494",
          height:"278",
          bw_headline: escape(cf.title),
          bw_subline: escape(cf.subtitle),
          bw_image: escape(cf.imgUrl),
          bwac: 'false',
          userId: Brandwire.SessionID,
          trackerUrl: bwFlashBaseUrl+'BrandwireSO.swf',
          logUrl: escape(Brandwire.BaseUrl + '/player/playerLog?mc=1599&pc='+Brandwire.videoPlayerCount+'&se='+Brandwire.SessionID+'&cs='+Brandwire.ClientSessionID+'&vi='+cf.videoId)
        };
        Brandwire.prerollId = -1;
        Brandwire.postrollId = -1;
        Brandwire.bannerId = -1;
        if (!cf.noAds) {
          if (cf.b1 && cf.b1.bannerId)
            Brandwire.addInStreamBanner(flashvars, cf);
          else
            Brandwire.addInStreamBanner(flashvars, Brandwire.Banner);
        }
        var params = {
          allowfullscreen: "true",
          allowscriptaccess: "always",
          wmode: 'transparent',
          salign: 'tl',
          scale: 'noscale'
        };
        var attributes = {
          id: "movadPl",
          name: "movadPl"
        };
        swfobject.embedSWF(playerSwf, "bwPlayerDiv", "494", "278", "10.0.0", "/Brandwire/flash/expressInstall.swf", flashvars, params, attributes);
      }
      if (Brandwire.selectedVid != -1) {
        var el = document.getElementById('bw_pe_' + Brandwire.selectedVid);
        if (el) {
          el.setAttribute('class', 'playlist_entry');
          el.className = 'playlist_entry';
        }
      }
      Brandwire.selectedVid = n;
      var el = document.getElementById('bw_pe_' + n);
      if (el) {
        el.setAttribute('class', 'playlist_entry bwselect2');
        el.className = 'playlist_entry bwselect2';
      }
    },

    addInStreamBanner: function(flashvars, banners) {
      var banner;
      flashvars.overlayDelay = 10;
      if (banners.b1 && banners.b1.bannerId) {
        banner = banners.b1;
      Brandwire.bannerId = banner.bannerId;
      if (banner.preroll) {
        flashvars.preroll = escape(banner.preroll);
        flashvars.prerollId = banner.prerollId;
        Brandwire.prerollId = banner.prerollId;
      }
      if (banner.overlay) {
        flashvars.overlay = escape(banner.overlay);
        flashvars.overlayId = banner.overlayId;
      }
      if (banner.postroll) {
        flashvars.postroll = escape(banner.postroll);
        flashvars.postrollId = banner.postrollId;
        Brandwire.postrollId = banner.postrollId;
      }
    }
      if (banners.b2 && banners.b2.bannerId) {
        banner = banners.b2;
        if (banner.preroll) {
          flashvars.preroll2 = escape(banner.preroll);
          flashvars.preroll2Id = banner.prerollId;
        }
        if (banner.postroll) {
          flashvars.postroll2 = escape(banner.postroll);
          flashvars.postroll2Id = banner.postrollId;
        }
      }
      if (banners.b3 && banners.b3.bannerId) {
        banner = banners.b3;
        if (banner.preroll) {
          flashvars.preroll3 = escape(banner.preroll);
          flashvars.preroll3Id = banner.prerollId;
        }
        if (banner.postroll) {
          flashvars.postroll3 = escape(banner.postroll);
          flashvars.postroll3Id = banner.postrollId;
        }
      }
    }

  };

  /**
   * this is being called by the start of
   *  - an ad
   *  - a video
   *
   * parameter: args[0] = typ; "ad" = advertisment, "item" = content video
   *            args[1] = index; in case of "item" = 0, in case of "ad" = preroll, postroll
   */
  function onStart(type, index) {
    if (type == 'ad') {
      if (index == 'preroll') {
        Brandwire.sendStatsRequest(Brandwire.prerollId, 1);
        Brandwire.sendThirdPartyRequest();
      } else if (index == 'postroll')
        Brandwire.sendStatsRequest(Brandwire.postrollId, 1);
    } else if (type == 'item')
      Brandwire.sendStatsRequest(-1, 1);
  }

  /**
   * this is being called at the end of
   *  - an ad
   *  - a video
   *
   * parameter: args[0] = typ; "ad" = advertisment, "item" = content video
   *            args[1] = index; in case of "item" = 0, in case of "ad" = preroll, postroll
   */
  function onFinish(type, index) {
    if (type == 'ad') {
      if (index == 'preroll')
        Brandwire.sendStatsRequest(Brandwire.prerollId, 100);
      else if (index == 'postroll')
        Brandwire.sendStatsRequest(Brandwire.postrollId, 100);
    } else if (type == 'item')
      Brandwire.sendStatsRequest(-1, 100);
  }

