///////////////////////////////////////////////////////////////////
// Definition der Domainvariablen (Michael Hochgartz)            //
///////////////////////////////////////////////////////////////////

var host = window.location.hostname.split(".");

  if(host[1] == "ruhrnachrichten") {
    var ga_id = 1; var domain_prefix="rn";
    var print_title = "Ruhr Nachrichten";
  } else if(host[1] == "muensterschezeitung") {
    var ga_id = 4; var domain_prefix="mz";
    var print_title = "Münstersche Zeitung";

  } else if(host[1] == "grevenerzeitung") {
    var ga_id = 10; var domain_prefix="gz";
    var print_title = "Grevener Zeitung";

  } else if(host[1] == "emsdettenervolkszeitung") {
    var ga_id = 11; var domain_prefix="ez";
    var print_title = "Emsdettener Volkszeitung";

  } else if(host[1] == "muensterlandzeitung") {
    var ga_id = 13; var domain_prefix="ml";
    var print_title = "Münsterland Zeitung";

  } else if(host[1] == "halternerzeitung") {
    var ga_id = 7; var domain_prefix="hz";
    var print_title = "Halterner Zeitung";

  } else if(host[1] == "dorstenerzeitung") {
    var ga_id = 6; var domain_prefix="dz";
    var print_title = "Dorstener Zeitung";

  } else {
    var ga_id = 1; var domain_prefix="rn";
    var print_title = "Ruhr Nachrichten";

  }

///////////////////////////////////////////////////////////////////
// teaser_anreissertext (Dennis Bohn)                            //
//                                                               //
// Dieses Script überprüft, ob es einen Anreissertext gibt. Gibt //
// es diesen nicht, wird der Anfang des Volltextes für den       //
// Anreissertext verwendet.                                      //
///////////////////////////////////////////////////////////////////

function teaser_anreissertext (ar_id,zeichen){
  if(document.getElementById("short"+ar_id).innerHTML.length < 10){
    content = document.getElementById("text"+ar_id).value;
    tablestart = content.indexOf("<table");
    if (tablestart != -1) {
      tableend = content.indexOf("</table>");
      if (tableend != -1) {
        if(tablestart > 0) {
          beforetable = content.substring(0,tablestart);
        } else {
          beforetable = "";
        }
        if(tableend < content.length) {
          aftertable = content.substring(tableend);
        } else {
          aftertable = "";
        }
        content = beforetable+aftertable;
      }
    }
    content = content.replace(/(<([^>]+)>)/ig, "");
    content = content.substr(0,zeichen)+"...";
    lastspace = content.lastIndexOf(" ");  
    document.getElementById("short"+ar_id).innerHTML = content.substr(0,lastspace)+"...";
  }
}

///////////////////////////////////////////////////////////////////
// teaserdynamizer (Dennis Bohn)                                 //
//                                                               //
// Mit Hilfe dieses Scripts ist es Möglich, Artikel ohne         //
// Volltextseite auszugeben. Neben dem Mehr-Link werden auch     //
// Überschrift und Bild berücksichtigt.                          //
///////////////////////////////////////////////////////////////////

function teaserdynamizer (id,template) {
  teaser = document.getElementById(id);
  teaserlink = teaser.getElementsByTagName('A')[0].href;
  if(document.location.href == teaser.getElementsByTagName('A')[0].href){
    teaserthumb = teaser.getElementsByTagName('IMG')[0];
    if(typeof(teaserthumb)!="undefined"){
      teaserthumbsrc = teaserthumb.src;
      teaserthumbwidth = teaserthumb.width;
      teaserthumbheight = teaserthumb.height;
      teaserthumb = '<img src="'+teaserthumbsrc+'" width="'+teaserthumbwidth+'" height="'+teaserthumbheight+'" align="left">';
    } else {
      teaserthumb = '';
    }
    headline = teaser.getElementsByTagName('DIV')[0].getElementsByTagName('SPAN')[0].innerHTML;
    fliess = teaser.getElementsByTagName('DIV')[1].getElementsByTagName('SPAN')[0].innerHTML;
    if(template == 0){ // Aufmacher ohne Ressort
      teaser.innerHTML = teaserthumb+'<div class="c_headline"><span class="headline">'+headline+'</span></div><div class="shorttext">'+fliess+'</div>';
    }
  }
}

///////////////////////////////////////////////////////////////////
// open_popup (Dennis Bohn)                                      //
//                                                               //
// Öffnet ein Popup                                              //
///////////////////////////////////////////////////////////////////

function open_popup (url,width,height) {
  if(typeof width  != "undefined" && typeof height == "undefined"){
    height = Math.round(width/4*3);
  } else if(typeof width  == "undefined" && typeof height != "undefined"){
    width = Math.round(height/3*4);
  } else if(typeof width  != "undefined" && typeof height != "undefined"){
    width = 780;
    height = 540;
  }
  fenster=window.open(url,"unipopup","left=0,top=0,width="+width+",height="+height+",location=no,menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no");
  fenster.focus();
}

///////////////////////////////////////////////////////////////////
// resize_window (Dennis Bohn)                                   //
//                                                               //
// Bringt ein Fenster auf die passende Größe unter               //
// Berücksichtigung der Browserleisten                           //
///////////////////////////////////////////////////////////////////

function resize_window (width,height) {
  if (document.all) {
    if(document.documentElement.offsetWidth < width || document.documentElement.offsetHeight < height) {
      resizeTo(width,height);
      fensterbreite = width-document.documentElement.offsetWidth;
      fensterhoehe = height-document.documentElement.offsetHeight;
    }
  } else {
    fensterhoehe = window.outerHeight-window.innerHeight;
    fensterbreite = window.outerWidth-window.innerWidth;
  }
  width += fensterbreite;
  height += fensterhoehe;
  resizeTo(width,height);
}

///////////////////////////////////////////////////////////////////
// gotourl (Dennis Bohn)                                         //
//                                                               //
// Aufruf einer URL per JavaScript                               //
///////////////////////////////////////////////////////////////////

function gotourl(x) {
  document.location.href = x;
}

///////////////////////////////////////////////////////////////////
// [show/hide]_overlaytext (Dennis Bohn)                         //
//                                                               //
// Blendet Text auf Bildern ein uns aus                          //
///////////////////////////////////////////////////////////////////

function show_overlaytext (obj) {
  obj.style.visibility = "visible";
}

function hide_overlaytext (obj) {
  obj.style.visibility = "hidden";
}

///////////////////////////////////////////////////////////////////
// extract_path (Dennis Bohn)                                    //
//                                                               //
// Holt sich den Ordnernamen aus einer beliebigen Ebene aus      //
// einer URL                                                     //
///////////////////////////////////////////////////////////////////

function extract_path (url,position) {
  urlarray = url.split("/");
  return urlarray[position];
}

///////////////////////////////////////////////////////////////////
// str2url (Dennis Bohn)                                         //
//                                                               //
// Verändert einen String nach bestimmten Kriterien so, dass er  //
// innerhalb der Pfadangabe einer URL stehen kann                //
///////////////////////////////////////////////////////////////////

function str2url (str) {
  newstr = str.toLowerCase();
  vorher = Array (/ä/g,/ö/g,/ü/g,/ß/g,/ /g);
  nachher = Array ('ae','oe','ue','ss','_');
  for(i=0;i<vorher.length;i++){
    if(typeof(nachher[i]) != "undefined"){
      newstr = newstr.replace(vorher[i],nachher[i]);
    }
  }
  return newstr;
}

///////////////////////////////////////////////////////////////////
// shorter (Dennis Bohn)                                         //
//                                                               //
// Kürzt Texte, wenn diese zu lang sind                          //
///////////////////////////////////////////////////////////////////

function shorter(obj,zeichen) {
  text = obj.innerHTML;
  if(text.length > zeichen){
    text = text.substr(0,zeichen)+"...";
    var lastspace = text.lastIndexOf(" ");  
    obj.innerHTML = text.substr(0,lastspace)+"...";
  }
}

///////////////////////////////////////////////////////////////////
// mcbacklink (Dennis Bohn)                                      //
//                                                               //
// Erzeugt einen Zurück-Button auf Basis des Referrers           //
///////////////////////////////////////////////////////////////////

function mcbacklink() {
  letzteseite = document.referrer;
  if(letzteseite.length > 0 && letzteseite != document.location.href){
    refarray = letzteseite.split("/");
    refarray.reverse();
    if(refarray[0].substr(0,3) == "sts") {
      backlinktext = "zurück zum letzten Medienelement";
    } else if(refarray[0].substr(0,3) == "art") {
      backlinktext = "zurück zum Artikel";
    } else if(refarray[0].substr(0,3) == "cme") {
      backlinktext = "zurück zur letzten Fotostrecke";
    } else if(refarray[0].length == 0) {
      backlinktext = "zurück zur Übersichtsseite";
    } else {
      backlinktext = "zurück";
    }
    document.write('<div style="margin-bottom:5px;padding-bottom:6px;font-size:9px;border-bottom:1px solid #CCCCCC" id="backlink">');
    document.write('<a href="'+letzteseite+'"><img src="/pics/ruhr/mcback.gif" width="7" height="9" align="absmiddle" border="0"> '+backlinktext+'</a>');
    document.write('</div>');
  }
}

///////////////////////////////////////////////////////////////////
// voting_ranking (Dennis Bohn)                                  //
//                                                               //
// Ermittelt die Positionsnummer einer Bild-ID auf Basis des     //
// Arrays "picid_array".                                         //
///////////////////////////////////////////////////////////////////


function voting_ranking (this_pic) {
  if(typeof(voting_ranknumber) == "undefined"){
    for (i=0;i<picid_array.length;i++) {
      if(picid_array[i] == this_pic){
        voting_ranknumber = i+1;
      }
    }
  } else {
    voting_ranknumber++;
  }
  document.write(voting_ranknumber);
}

///////////////////////////////////////////////////////////////////
// addslashes (Dennis Bohn)                                      //
///////////////////////////////////////////////////////////////////

function addslashes(str) {
  str=str.replace(/\'/g,'\\\'');
  str=str.replace(/\"/g,'\\"');
  str=str.replace(/\\/g,'\\\\');
  str=str.replace(/\0/g,'\\0');
  return str;
}

///////////////////////////////////////////////////////////////////
// Ein paar Scripts zur Darstellung von Bubbles (Dennis Bohn)    //
// Diese Scripts wurden speziell an das neue Mediencenter        //
// angepasst                                                     //
///////////////////////////////////////////////////////////////////

var bubblefader;
var bubblefade = 0;
function movebubble (Ereignis) {
  if(document.getElementById('bubble').style.display != "none"){
    var rahmenhoehe = 24;
    var bubblepin = 11;
    if(navigator.appName != "Netscape"){ 
      Ereignis = window.event;
    }
    var texthoehe = document.getElementById('bubble').getElementsByTagName('div')[1].offsetHeight;
    var scrolly = document.documentElement.scrollTop;
    var mausy = Ereignis.clientY;
    var mausx = Ereignis.clientX;
    document.getElementById('bubble').style.left = mausx-bubblepin+"px" ;
    document.getElementById('bubble').style.top = mausy+scrolly-rahmenhoehe-texthoehe+"px";
  }
} 
function showbubble (objid) {
  if(typeof(objid) == "undefined"){
    if(typeof(bubblefader) != "undefined"){
      clearInterval(bubblefader);
    }
    bubblefade = 90;
    bubblefader = window.setInterval("fadebubbleout()",30);
  } else if(document.getElementById(objid).innerHTML.length > 1){
    document.getElementById('bubble').style.opacity = 0;
    document.getElementById('bubble').style.filter = "alpha(opacity=0)";
    document.getElementById('bubble').style.display = "block";
    document.getElementById('bubbletext').innerHTML = document.getElementById(objid).innerHTML;
    if(bubblefader){
      clearInterval(bubblefader);
    }
    bubblefade = 0;
    bubblefader = window.setInterval("fadebubblein()",15);
  }
}
function fadebubblein () {
  if(document.getElementById('bubble').style.left != "0px" && document.getElementById('bubble').style.top != "0px"){
    if(bubblefade < 90){
      bubblefade += 10;
      document.getElementById('bubble').style.opacity = bubblefade/100;
      document.getElementById('bubble').style.filter = "alpha(opacity="+bubblefade+")";
    } else {
      clearInterval(bubblefader);
    }
  }
}
function fadebubbleout () {
  if(bubblefade > 0){
    bubblefade -= 10;
    document.getElementById('bubble').style.opacity = bubblefade/100;
    document.getElementById('bubble').style.filter = "alpha(opacity="+bubblefade+")";
  } else {
    document.getElementById('bubble').style.opacity = 0;
    document.getElementById('bubble').style.filter = "alpha(opacity=0)";
    document.getElementById('bubble').style.display = "none";
    document.getElementById('bubble').style.left = "0px";
    document.getElementById('bubble').style.top = "0px";
    clearInterval(bubblefader);
  }
}

///////////////////////////////////////////////////////////////////
// afp_thumbscaler (Nils Lindenstrauß, Dennis Bohn)              //
//                                                               //
// Reduziert die Größe der Thumbnails für die AFP Infografiken   //
// um 50%.                                                       //
///////////////////////////////////////////////////////////////////

function afp_thumbscaler (ar_id) {
  var afp_infothumb = document.getElementById("thumb"+ar_id).getElementsByTagName("IMG")[0];
  var afp_infothumb_width = Math.round(afp_infothumb.width/2);
  var afp_infothumb_height = Math.round(afp_infothumb.height/2);
  if(afp_infothumb_width>=60 && afp_infothumb_height >= 60){
    document.getElementById("thumb"+ar_id).getElementsByTagName("IMG")[0].width = afp_infothumb_width;
    document.getElementById("thumb"+ar_id).getElementsByTagName("IMG")[0].height = afp_infothumb_height;
  }
}

///////////////////////////////////////////////////////////////////
// open_gallery (Dennis Bohn)                                    //
//                                                               //
// Öffnet eine Fotostrecke im Mediencenter als Popup             //
///////////////////////////////////////////////////////////////////

function open_gallery (x) {
  fenster=window.open(x,"mediacenter","left=0,top=0,width=1000,height=680,location=no,menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no");
}

///////////////////////////////////////////////////////////////////
// makecmelink (Dennis Bohn)                                     //
//                                                               //
// Generiert aus einem Link einen CME-Link                       //
///////////////////////////////////////////////////////////////////

function makecmelink (link) {
  var stringpart = link.split(",");
  var cmetree = stringpart[0].substr(3);
  var cmelink = "/_/tools/diaview.html?_CMTREE="+cmetree+"&list=1";
  return cmelink;
}

///////////////////////////////////////////////////////////////////
// galleryteaser_colorchanger (Dennis Bohn)                      //
//                                                               //
// Ändert die Farbe der Gallery-Teaser-Box beim Überfahren mit   //
// der Maus                                                      //
///////////////////////////////////////////////////////////////////

function galleryteaser_colorchanger(obj,on){
  if(on == 1){
    obj.style.color = "#000000";
    obj.style.backgroundImage = "url(/pics/ruhr/galleryteaser_back.gif)";
  } else {
    obj.style.color = "#999999";
    obj.style.backgroundImage = "none";
  }
}

///////////////////////////////////////////////////////////////////
// setgalleryteaser (Dennis Bohn)                                //
//                                                               //
// Erstellt den Galleryteaser für den Inhaltsbereich             //
///////////////////////////////////////////////////////////////////

function setgalleryteaser(id){
  if ( typeof ( gallerystart ) == "undefined" ) gallerystart = new Array ( );
  if ( typeof ( gallerystart[id] ) == "undefined" ) gallerystart[id] = 0;
  td_gallerys = '<table cellspacing="2" cellpadding="0" border="0"><tr>';
  if ( gallerystart[id] > all_gallerys[id].length-1 ) {
    gallerystart[id] = 0;
  } else if ( gallerystart[id] < 0 ){
    gallerystart[id] = all_gallerys[id].length-1;
  }
  for( i = gallerystart[id]; i < gallerystart[id] + 3; i++ ) {
    var element = i;
    while( element >= all_gallerys[id].length ) {
      element -= all_gallerys[id].length;
    }
    cmelink = makecmelink(all_gallerys[id][element][2]);
    td_gallerys += '<td><img src="/pics/ruhr/galleryteaser_trenner.gif" width="1" height="140"></td>';
    td_gallerys += '<td style="font-size:10px;color:#999999;cursor:pointer;background-repeat:repeat-x" valign="top" width="143" id="galleryteaserelement'+i+'" onMouseOver="galleryteaser_colorchanger(this,1);" onMouseOut="galleryteaser_colorchanger(this,0);" onClick="return open_gallery(\''+cmelink+'\')" align="center"><table cellspacing="0" cellpadding="0" border="0" width="143" height="100" style="margin-bottom:4px"><tr><td align="center"><img src="'+all_gallerys[id][element][1]+'" style="border:1px solid #FFFFFF"></td></tr></table>'+all_gallerys[id][element][0]+'</td>';
  }
  td_gallerys += '<td><img src="/pics/ruhr/galleryteaser_trenner.gif" width="1" height="140"></td>';
  td_gallerys += '</tr></table>';
  document.getElementById('gallerys' + id).innerHTML = td_gallerys;
}

///////////////////////////////////////////////////////////////////
// create_gallery_teaser (Dennis Bohn)                           //
//                                                               //
// Erstellt eine dynamische Gallery-Teaser-Box                   //
///////////////////////////////////////////////////////////////////

function create_gallery_teaser () {
  if ( typeof ( gallery_id ) == "undefined" ) {
    gallery_id = 0;
  } else {
    gallery_id++;
  }
  document.write('<table cellspacing="0" cellpadding="0" border="0" align="center" style="background-image:url(/pics/ruhr/galleryteaser_brightback.gif);background-repeat:repeat-x;border:1px solid #9bbcbc">');
  document.write('<tr>');
  document.write('<td style="padding-top:2px;cursor:pointer" valign="top" onmousedown="gallerystart['+gallery_id+']--;setgalleryteaser('+gallery_id+')" onMouseOver="this.getElementsByTagName(\'img\')[0].src=\'/pics/ruhr/pfeil_links.gif\'" onMouseOut="this.getElementsByTagName(\'img\')[0].src=\'/pics/ruhr/pfeil_links_inaktiv.gif\'">');
  document.write('<img src="/pics/ruhr/pfeil_links_inaktiv.gif" id="galleryteaser_pfeillinks" width="17" height="100">');
  document.write('</td>');
  document.write('<td id="gallerys' + gallery_id + '" valign="top">&nbsp;</td>');
  document.write('<td style="padding-top:2px;cursor:pointer" valign="top" onmousedown="gallerystart['+gallery_id+']++;setgalleryteaser('+gallery_id+')" onMouseOver="this.getElementsByTagName(\'img\')[0].src=\'/pics/ruhr/pfeil_rechts.gif\'" onMouseOut="this.getElementsByTagName(\'img\')[0].src=\'/pics/ruhr/pfeil_rechts_inaktiv.gif\'"><img src="/pics/ruhr/pfeil_rechts_inaktiv.gif" id="galleryteaser_pfeilrechts" width="17" height="100">');
  document.write('</td>');
  document.write('</tr>');
  document.write('</table>');
  setgalleryteaser(gallery_id);
}

///////////////////////////////////////////////////////////////////
// rel_link (Dennis Bohn)                                        //
//                                                               //
// Öffnet den Volltext immer im jeweiligen Übersichtsressort     //
///////////////////////////////////////////////////////////////////

function rel_link (obj) {
  var thislocation = window.location.href;
  thislocation = thislocation.substr(0,thislocation.lastIndexOf("/")+1);
  var newarticle = obj.href;
  if(newarticle.indexOf("/index.html") == -1){
    newarticle = newarticle.substr(newarticle.lastIndexOf("/")+1);
    obj.href = thislocation+newarticle;
  }
}

///////////////////////////////////////////////////////////////////
// link_mod (Dennis Bohn)                                        //
//                                                               //
// Modifiziert Links                                             //
///////////////////////////////////////////////////////////////////

function link_mod (id,rel) {

  var article = document.getElementById('ar'+id);
  var link = article.getElementsByTagName('a');
  for (i=0;i<link.length;i++){
    if (link[i].href == window.location.href || link[i].href+"index.html" == window.location.href) {
      if (article.className == "link" ) {
        article.style.display = "none";
      } else {
        link[i].removeAttribute("href");
        if (link[i].className == "mehr") link[i].style.display = "none";
      }
    } else if (rel == 1) {
      rel_link(link[i]);
    }
  }
}

///////////////////////////////////////////////////////////////////
// content_video (Dennis Bohn)                                   //
//                                                               //
// Erzeugt ein Brightcove-Video im Contentbereich                //
///////////////////////////////////////////////////////////////////

function content_video () {
  var checknumber = Math.round((content_video.arguments.length-1)/5);
  if((content_video.arguments.length-1)/5 == checknumber) {
    var article = content_video.arguments[0];
    var bc_linkbox = "";
    for(i=1;i<content_video.arguments.length;i+=5){
      var title = content_video.arguments[i];
      var playerId = content_video.arguments[i+1];
      var playlistId = content_video.arguments[i+2];
      var videoId = content_video.arguments[i+3];
      var sPlayerId = content_video.arguments[i+4];
      if(content_video.arguments[0] == 0) {
        bc_widget_single({'token':'gPVgciZpiW8xZzAfOe8t6W0uP9xs6Y_gLbNA4ZH5LaQ.','postfix':'','width':485,'dir':'','playerIds':[sPlayerId],'videoIds':[videoId]});
      } else {
        bc_linkbox += '<div class="lbx_link">Video: <a href="/videos/index.html?bcpid='+playerId+'&bctid='+videoId+'">'+title+'</a></div>';
      }
    }

    if (typeof(output) != "undefined"){
      document.write(output+"</table>");
    } else if (bc_linkbox.length > 0) {
      var linkbox = document.getElementById('lbx'+article);
      var linkspan = linkbox.getElementsByTagName('span');
      if(linkspan.length == 1){
        linkspan[0].innerHTML = bc_linkbox+linkspan[0].innerHTML;
      } else {
        linkbox.innerHTML = '<div class="lbx_headline">Mehr zu diesem Thema</div>'+bc_linkbox;
      }
      linkbox.getElementsByTagName('div')[0].style.display = "block";
    }
  }
}

///////////////////////////////////////////////////////////////////
// init_diashow (Dennis Bohn)                                    //
//                                                               //
// Erzeugt eine Diashow                                          //
///////////////////////////////////////////////////////////////////

function init_diashow () {

  diashow = new Object();

  diashow["name"] = escape(document.getElementById('diashow_headline').innerHTML);
  diashow["id"] = window.location.href.substr(window.location.href.lastIndexOf("/")).match(/[0-9]+/);
  diashow["position"] = 0;
  diashow["thumbposition"] = 0;
  diashow["scrolling"] = "";
  diashow["thumbscrolling"] = "";
  diashow["loadimg"] = new Image();
  diashow["loadimg"].src = "/pics/ruhr/diashow/diashow_loading.gif";
  diashow["thumbloadimg"] = new Image();
  diashow["thumbloadimg"].src = "/pics/ruhr/diashow/thumbnail_loading.gif";
  diashow["thumbspacing"] = 4;
  
  var str = '<table cellspacing="0" cellpadding="0" border="0" id="diatable"><tr>';

  var thumb_str = '<table cellspacing="0" cellpadding="0" border="0" id="diashow_thumbnailbox">';
  thumb_str += '<tr>';

  thumb_str += '<td style="padding: 4px 0px 4px 4px" id="diashow_links"><img width="11" height="60" onmouseout="this.src=\'/pics/ruhr/diashow/diashow_thumbpfeil_links_inaktiv.gif\'" onmouseover="this.src=\'/pics/ruhr/diashow/diashow_thumbpfeil_links_aktiv.gif\'" src="/pics/ruhr/diashow/diashow_thumbpfeil_links_inaktiv.gif" style="cursor: pointer" onClick="scroll_diathumbs(\'left\')"/></td>';
  thumb_str += '<td><div id="diashow_thumbnails">';
  thumb_str += '<table cellspacing="'+diashow["thumbspacing"]+'" cellpadding="0" border="0" id="thumbtable"><tr>';

  fotostrecke = divTreeReader("clickme");

  if(typeof(fotostrecke) != "undefined"){
    for(i=0;i<fotostrecke.length;i++){
      str += '<td><img src="t.gif" style="width:482px;height:362px;cursor:pointer" onClick="scroll_diashow(\'right\')"></td>';
      thumb_str += '<td>';
      thumb_str += '<div style="width:60px;height:60px;opacity:0.5;filter:alpha(opacity=50)">';
      thumb_str += '<img src="t.gif" style="width:60px;height:60px;cursor:pointer" onClick="open_dia('+i+')" onMouseOver="thumb_alpha('+i+')" onMouseOut="thumb_alpha()">';
      thumb_str += '</div>';
      thumb_str += '</td>';
    }
  }

  thumb_str += '</tr></table>';
  thumb_str += '</div></td>';
  thumb_str += '<td style="padding: 4px 4px 4px 0px" id="diashow_rechts"><img width="11" height="60" onmouseout="this.src=\'/pics/ruhr/diashow/diashow_thumbpfeil_rechts_inaktiv.gif\'" onmouseover="this.src=\'/pics/ruhr/diashow/diashow_thumbpfeil_rechts_aktiv.gif\'" src="/pics/ruhr/diashow/diashow_thumbpfeil_rechts_inaktiv.gif" style="cursor: pointer" onClick="scroll_diathumbs(\'right\')"/></td>';
  thumb_str += '</tr>';
  thumb_str += '</table>';


  str += "</tr></table>";

  document.getElementById('diathumb_container').innerHTML = thumb_str;
  document.getElementById('diashow_images').innerHTML = str;
  document.getElementById('diashow_pager').innerHTML = "1/"+fotostrecke.length;

  diashow["cellwidth"] = document.getElementById('diatable').getElementsByTagName('TD')[0].offsetWidth;
  diashow["thumbwidth"] = document.getElementById('thumbtable').getElementsByTagName('TD')[0].offsetWidth+diashow["thumbspacing"];

  document.getElementById('diashow_text').innerHTML = fotostrecke[diashow["position"]]["text"];

  if ( fotostrecke[diashow["position"]]["author"].length > 3 ) { 
    document.getElementById('diashow_text').innerHTML += " <nobr><i>("+fotostrecke[diashow["position"]]["author"]+")</i></nobr>";
  }

  thumb_alpha();
  loaddia(diashow["position"]);
  loadthumbs(diashow["thumbposition"]);

  if(fotostrecke.length <= 7){
    document.getElementById('diashow_links').innerHTML = '<img src="t.gif" width="11" height="60">';
    document.getElementById('diashow_rechts').innerHTML = '<img src="t.gif" width="11" height="60">';
    document.getElementById('diathumb_pager').style.display = 'none';
  } else {
    var thumbnail_pager_length = Math.ceil(fotostrecke.length/7);
    var thumbnail_pager_str = '<span onClick="goto_thumbnail(0)" style="color:#000000">&nbsp;1&nbsp;</span>';
    for (i=1;i<thumbnail_pager_length;i++){
      var thumbnail_pager_nr = i+1;
      thumbnail_pager_str += '<span onClick="goto_thumbnail('+i+')">&nbsp;'+thumbnail_pager_nr+'&nbsp;</span>';
    }
    document.getElementById('diathumb_pager').innerHTML = thumbnail_pager_str;
  }
  var gallery_text = document.getElementById('gal_text').innerHTML.split(":");
  gallery_text[0] = gallery_text[0].split(",");
  if(gallery_text[0][0].length > 0 && gallery_text[0][1].length > 0){
    gallery_text[0] = gallery_text[0][0]+", "+gallery_text[0][1];
  } else if (gallery_text[0][0].length + gallery_text[0][1].length > 0) {
    gallery_text[0] = gallery_text[0][0]+gallery_text[0][1];
  } else {
    gallery_text[0] = "";
  }
  gallery_text[1] = gallery_text.slice(1).join(":");
  if(gallery_text[0].length > 0 && gallery_text[1].length > 0){
    gallery_text = gallery_text[0]+": "+gallery_text[1];
  } else if(gallery_text[0].length + gallery_text[1].length > 0){
    gallery_text = gallery_text[0]+gallery_text[1];
  } else {
    gallery_text = "";
  }
  if(gallery_text == "") {
    document.getElementById('gal_text').style.display = "none";
  } else {  
    document.getElementById('gal_text').innerHTML = gallery_text;
  }
  countDiaClick();

}

///////////////////////////////////////////////////////////////////
// scroll_diashow (Dennis Bohn)                                  //
//                                                               //
// Scrollt die Diashow                                           //
///////////////////////////////////////////////////////////////////

function scroll_diashow ( position ) {
  if (position == "left" || position == "right") {
      if ( typeof(get_ivw) != "undefined" ) get_ivw();
      if ( diashow["scrolling"] != "" ) window.clearInterval(diashow["scrolling"]);
      diashow["scrolling"] = "";
  }
  if (position == "right") {
    document.getElementById('diashow_text').innerHTML = ""; 
    if (diashow["position"]+1 >= fotostrecke.length) {
      diashow["position"]=0;
    } else {
      diashow["position"]++;
    }
    thumb_alpha();
    document.getElementById('diashow_pager').innerHTML = diashow["position"]+1+"/"+fotostrecke.length;
    var scroll_position = diashow["position"]*diashow["cellwidth"];
    document.getElementById('diashow_images').scrollLeft = Math.ceil((document.getElementById('diashow_images').scrollLeft*2+scroll_position)/3);
    diashow["scrolling"] = window.setInterval("scroll_diashow("+scroll_position+")", 50);
    loaddia(diashow["position"]);
    if (diashow["position"] < diashow["thumbposition"] || diashow["position"] > diashow["thumbposition"]+6) goto_thumbnail(Math.floor(diashow["position"]/7)); 
    countDiaClick();
  } else if (position == "left") {
    document.getElementById('diashow_text').innerHTML = ""; 
    if (diashow["position"] == 0) {
      diashow["position"] = fotostrecke.length-1;
    } else {
      diashow["position"]--;
    }
    thumb_alpha();
    document.getElementById('diashow_pager').innerHTML = diashow["position"]+1+"/"+fotostrecke.length;
    var scroll_position = diashow["position"]*diashow["cellwidth"];
    document.getElementById('diashow_images').scrollLeft = Math.floor((document.getElementById('diashow_images').scrollLeft*2+scroll_position)/3);
    diashow["scrolling"] = window.setInterval("scroll_diashow("+scroll_position+")", 50);
    loaddia(diashow["position"]);
    if (diashow["position"] < diashow["thumbposition"] || diashow["position"] > diashow["thumbposition"]+6) goto_thumbnail(Math.floor(diashow["position"]/7)); 
    countDiaClick();
  } else if(position > document.getElementById('diashow_images').scrollLeft){
    document.getElementById('diashow_images').scrollLeft = Math.ceil((document.getElementById('diashow_images').scrollLeft*2+position)/3);
  } else if(position < document.getElementById('diashow_images').scrollLeft){
    document.getElementById('diashow_images').scrollLeft = Math.floor((document.getElementById('diashow_images').scrollLeft*2+position)/3);
  } else {
    document.getElementById('diashow_text').innerHTML = fotostrecke[diashow["position"]]["text"]; 
    if ( fotostrecke[diashow["position"]]["author"].length > 3 ) { 
      document.getElementById('diashow_text').innerHTML += " <nobr><i>("+fotostrecke[diashow["position"]]["author"]+")</i></nobr>";
    }
    document.getElementById('diashow_images').scrollLeft = position;
    if ( diashow["scrolling"] != "" ) window.clearInterval(diashow["scrolling"]);
    diashow["scrolling"] = "";
  }
}

///////////////////////////////////////////////////////////////////
// scroll_diathumbs (Dennis Bohn)                                //
//                                                               //
// Scrollt die Diashow Thumbnails                                //
///////////////////////////////////////////////////////////////////

function scroll_diathumbs ( position ) {
  if (position == "left" || position == "right") {
      if ( diashow["thumbscrolling"] != "" ) window.clearInterval(diashow["thumbscrolling"]);
      diashow["thumbscrolling"] = "";
  }
  if (position == "right") {
    if (fotostrecke.length > 7) {
      if (diashow["thumbposition"] < fotostrecke.length-13){
        diashow["thumbposition"] += 7;
      } else if (diashow["thumbposition"] < fotostrecke.length-7){
        diashow["thumbposition"] = fotostrecke.length-7;
      } else {
        diashow["thumbposition"]=0;        
      }
    }
    var scroll_position = diashow["thumbposition"]*diashow["thumbwidth"];
    document.getElementById('diashow_thumbnails').scrollLeft = Math.ceil((document.getElementById('diashow_thumbnails').scrollLeft*2+scroll_position)/3);
    diashow["thumbscrolling"] = window.setInterval("scroll_diathumbs("+scroll_position+")", 50);
    loadthumbs(diashow["thumbposition"]);
    change_thumbnumber(diashow["thumbposition"]);
  } else if (position == "left") {
    if (fotostrecke.length > 7) {
      if (diashow["thumbposition"] == 0){
        diashow["thumbposition"] = fotostrecke.length-7;
      } else if (diashow["thumbposition"] > 6){
        diashow["thumbposition"] -= 7;
      } else {
        diashow["thumbposition"]=0;
      }
    }
    var scroll_position = diashow["thumbposition"]*diashow["thumbwidth"];
    document.getElementById('diashow_thumbnails').scrollLeft = Math.floor((document.getElementById('diashow_thumbnails').scrollLeft*2+scroll_position)/3);
    diashow["thumbscrolling"] = window.setInterval("scroll_diathumbs("+scroll_position+")", 50);
    loadthumbs(diashow["thumbposition"]);
    change_thumbnumber(diashow["thumbposition"]);
  } else if(position > document.getElementById('diashow_thumbnails').scrollLeft){
    document.getElementById('diashow_thumbnails').scrollLeft = Math.ceil((document.getElementById('diashow_thumbnails').scrollLeft*2+position)/3);
  } else if(position < document.getElementById('diashow_thumbnails').scrollLeft){
    document.getElementById('diashow_thumbnails').scrollLeft = Math.floor((document.getElementById('diashow_thumbnails').scrollLeft*2+position)/3);
  } else {
    document.getElementById('diashow_thumbnails').scrollLeft = position;
    if ( diashow["thumbscrolling"] != "" ) window.clearInterval(diashow["thumbscrolling"]);
    diashow["thumbscrolling"] = "";
  }
}

///////////////////////////////////////////////////////////////////
// open_dia (Dennis Bohn)                                        //
//                                                               //
// Öffnet Bild in einer Fotostrecke                              //
///////////////////////////////////////////////////////////////////

function open_dia (dia) {
  if ( typeof(get_ivw) != "undefined" ) get_ivw();
  diashow["position"] = dia;
  thumb_alpha();
  document.getElementById('diashow_pager').innerHTML = diashow["position"]+1+"/"+fotostrecke.length;
  document.getElementById('diashow_text').innerHTML = ""; 
  var position = diashow["position"]*diashow["cellwidth"];
  scroll_diashow(position);
  if ( diashow["scrolling"] != "" ) window.clearInterval(diashow["scrolling"]);
  diashow["scrolling"] = "";
  diashow["scrolling"] = window.setInterval("scroll_diashow("+position+")", 50);
  loaddia(diashow["position"]);
  countDiaClick();
}

///////////////////////////////////////////////////////////////////
// thumb_alpha (Dennis Bohn)                                     //
//                                                               //
// Ändert die Transparenz der Thumbnails                         //
///////////////////////////////////////////////////////////////////

function thumb_alpha () {
  var thumbnails = document.getElementById('thumbtable').getElementsByTagName('div');
  for(i=0;i<thumbnails.length;i++){
    if(i == diashow["position"]) {
      thumbnails[i].style.opacity = 1;
      thumbnails[i].style.filter = "alpha(opacity=100)";
    } else {
      thumbnails[i].style.opacity = 0.5;
      thumbnails[i].style.filter = "alpha(opacity=50)";
    }
  }
  if(typeof(thumb_alpha.arguments[0]) != "undefined") {
      thumbnails[thumb_alpha.arguments[0]].style.opacity = 1;
      thumbnails[thumb_alpha.arguments[0]].style.filter = "alpha(opacity=100)";
  }
}

///////////////////////////////////////////////////////////////////
// loaddia (Dennis Bohn)                                         //
//                                                               //
// Lädt das Bild einer Fotostrecke                               //
///////////////////////////////////////////////////////////////////

function loaddia(pos) {
    if(typeof(fotostrecke[pos]["pic"]) == "undefined") {
      document.getElementById('diatable').getElementsByTagName('td')[pos].style.backgroundImage = "url("+diashow["loadimg"].src+")";
      fotostrecke[pos]["pic"] = new Image();
      fotostrecke[pos]["pic"].src = fotostrecke[pos]["picurl"];
      fotostrecke[pos]["picloader"] = window.setInterval("loaddiacheck("+pos+")",50);
    }
    
}

///////////////////////////////////////////////////////////////////
// loadthumbs (Dennis Bohn)                                      //
//                                                               //
// Lädt Thumbnails für die Bildauswahl                           //
///////////////////////////////////////////////////////////////////

function loadthumbs(pos) {
  for(i=pos;i<pos+7;i++){
    if(i==fotostrecke.length) break;
    if(typeof(fotostrecke[i]["thumb"]) == "undefined") {
      document.getElementById('thumbtable').getElementsByTagName('div')[i].style.backgroundImage = "url("+diashow["thumbloadimg"].src+")";
      fotostrecke[i]["thumb"] = new Image();
      fotostrecke[i]["thumb"].src = fotostrecke[i]["thumburl"];
      fotostrecke[i]["thumbloader"] = window.setInterval("loadthumbscheck("+i+")",50);
    }
  }
}

///////////////////////////////////////////////////////////////////
// loaddiacheck (Dennis Bohn)                                    //
//                                                               //
// Prüft, ob das Bild geladen wurde                              //
///////////////////////////////////////////////////////////////////

function loaddiacheck (pos) {
    if(fotostrecke[pos]["pic"].complete){
      window.clearInterval(fotostrecke[pos]["picloader"]);
      document.getElementById('diatable').getElementsByTagName('td')[pos].style.backgroundImage = "url("+fotostrecke[pos]["pic"].src+")";
    }
}

///////////////////////////////////////////////////////////////////
// loadthumbscheck (Dennis Bohn)                                 //
//                                                               //
// Prüft, ob das Thumb geladen wurde                             //
///////////////////////////////////////////////////////////////////

function loadthumbscheck (pos) {
    if(fotostrecke[pos]["thumb"].complete){
      window.clearInterval(fotostrecke[pos]["thumbloader"]);
      document.getElementById('thumbtable').getElementsByTagName('div')[pos].style.backgroundImage = "url("+fotostrecke[pos]["thumb"].src+")";
      document.getElementById('thumbtable').getElementsByTagName('div')[pos].style.backgroundPosition = "center";
    }
}

///////////////////////////////////////////////////////////////////
// goto_thumbnail (Dennis Bohn)                                  //
//                                                               //
// Springt über den Thumbnail-Pager zu bestimmten Thumbnails     //
///////////////////////////////////////////////////////////////////

function goto_thumbnail (pos) {
  diashow["thumbposition"] = pos*7;
  if (diashow["thumbposition"] > fotostrecke.length-7) diashow["thumbposition"] = fotostrecke.length-7;
  var scroll_position = diashow["thumbposition"]*diashow["thumbwidth"];
  document.getElementById('diashow_thumbnails').scrollLeft = Math.round((document.getElementById('diashow_thumbnails').scrollLeft*2+scroll_position)/3);
  if(diashow["thumbscrolling"] != ""){
    window.clearInterval(diashow["thumbscrolling"]);
    diashow["thumbscrolling"] = "";
  }
  diashow["thumbscrolling"] = window.setInterval("scroll_diathumbs("+scroll_position+")", 50);
  loadthumbs(diashow["thumbposition"]);
  change_thumbnumber(diashow["thumbposition"]);
}

///////////////////////////////////////////////////////////////////
// change_thumbnumber (Dennis Bohn)                              //
//                                                               //
// Ändert die Hervorhebung der Pagernummern                      //
///////////////////////////////////////////////////////////////////

function change_thumbnumber (pos) {
  var pagernumbers = document.getElementById('diathumb_pager').getElementsByTagName('span');
  var pager = Math.ceil(pos/7);
  for (i=0;i<pagernumbers.length;i++){
    if(i==pager){
      pagernumbers[i].style.color = "#000000";
    } else {
      pagernumbers[i].style.color = "#999999";      
    }
  }
}

///////////////////////////////////////////////////////////////////
// init_fotostrecken (Dennis Bohn)                               //
//                                                               //
// Erzeugt Ansicht für weitere Fotostrecken                      //
///////////////////////////////////////////////////////////////////

function init_fotostrecken(title) {

  if (typeof(gallerylist) == "undefined") { 
    fotostrecken_scrolling = new Array();
    gallerylist = new Array();
  }
  var glid = gallerylist.length;

  gallerylist.push(divTreeReader("dia_auswahl"))

  document.getElementById('dia_auswahl').id = 'dia_auswahl_'+glid;

  var str = '<table cellspacing="0" cellpadding="0" border="0" id="fotostrecken_auswahl_'+glid+'" class="fotostrecken_auswahl">';
  str += '<tr>';
  str += '<th valign="center">'+title+'</th>';
  str += '<th valign="center" class="fotostrecken_auswahl_pager">';

  var pages = Math.ceil(gallerylist[glid].length/6);

  str += '<table cellspacing="3" cellpadding="0" border="0" align="right" id="fotostrecken_auswahl_pages_'+glid+'">';
  str += '<tr>';
  str += '<td style="color:#7aa5a5" onClick="goto_fotostrecken(0,'+glid+')">1</td>';
  for (i=1;i<pages;i++){
    var page_label = i+1;
    str += '<td onClick="goto_fotostrecken('+i+','+glid+')">'+page_label+'</td>';
  }
  str += '</tr>';
  str += '</table>';
  str += '</th>';
  str += '</tr>';
  str += '<tr>';
  str += '<td colspan="2" id="fotostrecken_auswahl_box_'+glid+'" class="fotostrecken_auswahl_box">';
  str += '<div style="width:483px;overflow:hidden" id="fotostrecke_auswahl_div_'+glid+'">';
  str += '<table cellspacing="0" cellpadding="0" border="0" id="fotostrecke_auswahl_page_'+glid+'">';
  for(i=0;i<gallerylist[glid].length;i+=6){
    str += '<td width="483" align="center">';
    str += '<table cellspacing="12" cellpadding="0" border="0" class="fotostrecke_auswahl_block">';
    str += '<tr>';
    for(x=0;x<6;x++){
      if (x==3) str += '</tr><tr>';
      if(i+x<gallerylist[glid].length){
        var picid = gallerylist[glid][i+x]["thumb_url"].substring( gallerylist[glid][i+x]["thumb_url"].lastIndexOf("/") + 1 );
        picid = picid.substring(0,picid.indexOf("_"));
        var link = 'cme'+gallerylist[glid][i+x]["id"]+','+picid+'.html';
        str += '<td class="gallerylist_element" align="center" valign="top" onMouseOver="fotostrecken_show_icon(this)" onMouseOut="fotostrecken_hide_icon(this)" onClick="window.location.href=this.getElementsByTagName(\'a\')[0].href">';
        str += '<div class="fotostrecken_auswahl_bild"><a href="'+link+'"><img src="/pics/ruhr/diashow/fotostrecken_icon.gif" width="133" height="100" border="0"></a></div>';
        str += '<div class="fotostrecken_auswahl_label">'+gallerylist[glid][i+x]["label"]+'</div>';
      } else {
        str += '<td style="cursor:default;border-color:#eff4f4"><img src="/pics/ruhr/diashow/t.gif" width="143" height="143">';
      }
      str += '</td>';
    }
    str += '</tr>';
    str += '</table>';
    str += '</td>';
  }
  str += '</table>';
  str += '</div>';
  str += '</td>';
  str += '</tr>';
  str += '</table>';

  document.write(str);

  fotostrecken_scrolling.push("");

  loadFotostreckenThumbs(0,glid);

}

///////////////////////////////////////////////////////////////////
// fotostrecken_show_icon (Dennis Bohn)                          //
//                                                               //
// Blendet das Fotostrecken-Icon ein                             //
///////////////////////////////////////////////////////////////////

function fotostrecken_show_icon (obj) {
  obj.getElementsByTagName('img')[0].style.visibility = "visible";
}

///////////////////////////////////////////////////////////////////
// fotostrecken_hide_icon (Dennis Bohn)                          //
//                                                               //
// Blendet das Fotostrecken-Icon aus                             //
///////////////////////////////////////////////////////////////////

function fotostrecken_hide_icon (obj) {
  obj.getElementsByTagName('img')[0].style.visibility = "hidden";
}

///////////////////////////////////////////////////////////////////
// goto_fotostrecken (Dennis Bohn)                               //
//                                                               //
// Springt in Fotostreckenauswahl auf eine bestimmte Seite       //
///////////////////////////////////////////////////////////////////

function goto_fotostrecken (page,glid) {
  var pagewidth = document.getElementById('fotostrecke_auswahl_page_'+glid).getElementsByTagName('td')[0].offsetWidth;
  var position = pagewidth*page;
  document.getElementById('fotostrecke_auswahl_div_'+glid).scrollLeft = Math.round((document.getElementById('fotostrecke_auswahl_div_'+glid).scrollLeft*2+position)/3);
  if(fotostrecken_scrolling[glid] != ""){
    window.clearInterval(fotostrecken_scrolling[glid]);
    fotostrecken_scrolling[glid] = "";
  }
  fotostrecken_scrolling[glid] = window.setInterval("fotostrecken_scroller("+position+","+glid+")",50);
  var pages = document.getElementById('fotostrecken_auswahl_pages_'+glid).getElementsByTagName('TD');
  for(i=0;i<pages.length;i++){
    if(i==page){
      pages[i].style.color = "#7aa5a5";
    } else {
      pages[i].style.color = "#b8cccc";
    }
  }
  loadFotostreckenThumbs(page,glid);
}

///////////////////////////////////////////////////////////////////
// fotostrecken_scroller (Dennis Bohn)                           //
//                                                               //
// Scrollt an die gewünschte Stelle der Fotostrecken-Auswahl     //
///////////////////////////////////////////////////////////////////

function fotostrecken_scroller (position,glid) {
  if(position > document.getElementById('fotostrecke_auswahl_div_'+glid).scrollLeft) {
    document.getElementById('fotostrecke_auswahl_div_'+glid).scrollLeft = Math.floor((document.getElementById('fotostrecke_auswahl_div_'+glid).scrollLeft*2+position)/3);
  } else if(position < document.getElementById('fotostrecke_auswahl_div_'+glid).scrollLeft){
    document.getElementById('fotostrecke_auswahl_div_'+glid).scrollLeft = Math.ceil((document.getElementById('fotostrecke_auswahl_div_'+glid).scrollLeft*2+position)/3);
  } else {
    window.clearInterval(fotostrecken_scrolling[glid]);
    fotostrecken_scrolling[glid] = "";    
  }
}

///////////////////////////////////////////////////////////////////
// loadFotostreckenThumbs (Dennis Bohn)                          //
//                                                               //
// Lädt Thumbnails für die Bildauswahl in der                    //
// Fotostreckenübersicht                                         //
///////////////////////////////////////////////////////////////////

function loadFotostreckenThumbs (page,glid) {
  for(i=0;i<6;i++){
    var element = page*6+i;
    if(element==gallerylist[glid].length) break;
    if(typeof(gallerylist[glid][element]["thumb"]) == "undefined") {
      var object = document.getElementById('fotostrecke_auswahl_page_'+glid).getElementsByTagName('table')[page].getElementsByTagName('td')[i].getElementsByTagName('div')[0];
      object.style.backgroundImage = "url("+diashow["thumbloadimg"].src+")";
      gallerylist[glid][element]["thumb"] = new Image();
      gallerylist[glid][element]["thumb"].src = gallerylist[glid][element]["thumb_url"];
      gallerylist[glid][element]["thumbloader"] = window.setInterval("loadFotostreckenThumbsCheck("+page+","+i+","+glid+")",50);
    }
  }
}

///////////////////////////////////////////////////////////////////
// loadFotostreckenThumbsCheck (Dennis Bohn)                     //
//                                                               //
// Checkt ob die Thumbs für die Fotostreckenauswahl geladen sind //
///////////////////////////////////////////////////////////////////

function loadFotostreckenThumbsCheck (page,pic,glid) {
    var pos = page*6+pic;
    if(gallerylist[glid][pos]["thumb"].complete){
      var obj = document.getElementById('fotostrecke_auswahl_page_'+glid).getElementsByTagName('table')[page].getElementsByTagName('td')[pic].getElementsByTagName('div')[0];
      window.clearInterval(gallerylist[glid][pos]["thumbloader"]);
      obj.style.backgroundImage = "url("+gallerylist[glid][pos]["thumb"].src+")";
      obj.style.backgroundPosition = "center";
    }
}

///////////////////////////////////////////////////////////////////
// countDiaClick (Michael Hochgartz, Dennis Bohn)                //
//                                                               //
// Zählt einen Klick in einer Diashow                            //
///////////////////////////////////////////////////////////////////

function countDiaClick() {
  if(typeof(diashow) != "undefined"){
    var cmeClick = new Image();
    cmeClick.src = "http://admin.ruhrnachrichten.de/_CPiX/cme-"+fotostrecke[diashow["position"]]["id"]+"-"+diashow["id"]+"/pixel.gif";
    var picClick = new Image();
    picClick.src = "http://admin.ruhrnachrichten.de/_CPiX/pic-"+fotostrecke[diashow["position"]]["id"]+"-"+diashow["id"]+"/pixel.gif";
    document.getElementById('fcmspixel').innerHTML = '<img src="'+cmeClick.src+'"><img src="'+picClick.src+'">';
  }
}

///////////////////////////////////////////////////////////////////
// init_diaindex (Dennis Bohn)                                   //
//                                                               //
// Generiert einen Pager                                         //
///////////////////////////////////////////////////////////////////

function init_diaindex(len,pos,page,glid) {
  var pg = 1;
  if ( init_diaindex.arguments.length == 5 ) {
    pg = init_diaindex.arguments[4];
  }
  var str = '<table id="fotostrecken_auswahl_pages" align="right" border="0" cellpadding="0" cellspacing="3">';
  str += '<tr>';
  if (len <= 9) {
    for(i=0; i<len; i++){
      var number = i+1;
      if (i == page) {
        str += '<td style="color: rgb(122, 165, 165);">'+number+'</td>';
      } else {
        var link = 'art'+id+',,'+pg+'-pg'+i;
        str += '<td onClick="window.location.href=\''+link+'\'">'+number+'</td>';
     }
    }    
  } else {
    if (pos >= len) pos = page-3;
    if (pos < 0) pos = 0;
    if (pos > len-7) pos = len-7;
    if(len > 7 && pos > 0) {
      var prev = pos-1;
      str += '<td onClick="init_diaindex('+len+','+prev+','+page+','+glid+')">&laquo;</td>';
    } else {
      str += '<td>&nbsp;</td>';
    }
    for(i=pos; i<pos+7; i++){
      var number = i+1;
      if (i == page) {
        str += '<td style="color: rgb(122, 165, 165);">'+number+'</td>';
      } else {
        var link = 'art'+id+',,'+pg+'-pg'+i;
        str += '<td onClick="window.location.href=\''+link+'\'">'+number+'</td>';
     }
    }
    if(len > 7 && pos < len-7) {
      var next = pos+1;
      str += '<td onClick="init_diaindex('+len+','+next+','+page+','+glid+')">&raquo;</td>';
    } else {
      str += '<td>&nbsp;</td>';
    }
  }
  str += '</tr>';
  str += '</table>';
  document.getElementById('pager_'+glid).innerHTML = str;
}

///////////////////////////////////////////////////////////////////
// divTreeReader (Dennis Bohn)                                   //
//                                                               //
// Hilft bei der Erzeugung von JS-Objekten                       //
///////////////////////////////////////////////////////////////////

function divTreeReader(id) {
  var arr = new Array();
  var tree = document.getElementById(id).getElementsByTagName('div');
  for(i=0;i<tree.length;i++){
    if(tree[i].getAttribute("name") == "fields") {
      var fields = tree[i].innerHTML.split(",");
    } else if(typeof(fields) != "undefined"){
      if(tree[i].getAttribute("name") == "element"){
        if(typeof(obj) != "undefined") {
          arr.push(obj);
          delete obj;
        }
        var field = 0;
        var obj = new Object();
        i++;
      }
      obj[fields[field]] = tree[i].innerHTML;
      field++;
    }
  }
  arr.push(obj);
  return arr;
}

// Ressortauswahl-Funktionen für die Diashow

function init_DiaRessortBox ( id, speed ) {
  DiaRessortBox = new Object();
  DiaRessortBox["interval"] = "";
  DiaRessortBox["obj"] = document.getElementById(id);
  DiaRessortBox["height"] = DiaRessortBox["obj"].offsetHeight;
  DiaRessortBox["speed"] = speed;
  DiaRessortBox["pos"] = 0;
  DiaRessortBox["obj"].style.height = "0px";
  DiaRessortBox["alpha"] = 0;
}


function showDiaRessorts() {
  if(DiaRessortBox["interval"] != ""){
    if (DiaRessortBox["pos"] < DiaRessortBox["speed"]) {
      DiaRessortBox["pos"]++;
      var form = DiaRessortBox["height"]*((Math.cos(Math.PI*(DiaRessortBox["pos"]/DiaRessortBox["speed"]-1))+1)/2);
      DiaRessortBox["obj"].style.height = form+"px";
    } else if (DiaRessortBox["alpha"] < 100) {
      DiaRessortBox["alpha"] += 5;
      DiaRessortBox["obj"].style.opacity = DiaRessortBox["alpha"]/100;
      DiaRessortBox["obj"].style.filter = 'alpha(opacity='+DiaRessortBox["alpha"]+')';
    } else {
      var form = DiaRessortBox["height"];
      window.clearInterval(DiaRessortBox["interval"]);
      DiaRessortBox["interval"] = "";
    }
  } else {
    if (DiaRessortBox["alpha"] != 0) {
      DiaRessortBox["interval"] = window.setInterval("hideDiaRessorts()",33);
      DiaRessortBox["alpha"] = 100;
      DiaRessortBox["obj"].style.opacity = DiaRessortBox["alpha"];
      DiaRessortBox["obj"].style.filter = 'alpha(opacity='+DiaRessortBox["alpha"]+')';
      DiaRessortBox["obj"].style.height = DiaRessortBox["height"]+"px";
    } else {
      DiaRessortBox["interval"] = window.setInterval("showDiaRessorts()",33);
      DiaRessortBox["alpha"] = 0;
      DiaRessortBox["obj"].style.opacity = DiaRessortBox["alpha"];
      DiaRessortBox["obj"].style.filter = 'alpha(opacity='+DiaRessortBox["alpha"]+')';
      DiaRessortBox["obj"].style.height = "0px";
    }
  }
}

function hideDiaRessorts() {
  if (DiaRessortBox["alpha"] > 0) {
    DiaRessortBox["alpha"] -= 5;
    DiaRessortBox["obj"].style.opacity = DiaRessortBox["alpha"]/100;
    DiaRessortBox["obj"].style.filter = 'alpha(opacity='+DiaRessortBox["alpha"]+')';
  } else if (DiaRessortBox["pos"] > 0) {
    DiaRessortBox["pos"]--;
    var form = DiaRessortBox["height"]*((Math.cos(Math.PI*(DiaRessortBox["pos"]/DiaRessortBox["speed"]-1))+1)/2);
    DiaRessortBox["obj"].style.height = form+"px";
  } else {
    window.clearInterval(DiaRessortBox["interval"]);
    DiaRessortBox["interval"] = "";
  }
}

///////////////////////////////////////////////////////////////////
// lbxCmeMod (Dennis Bohn)                                       //
//                                                               //
// Modifiziert CME-Links in Linkboxen um auf Fotostrecken im     //
// Inhaltsbereich zu verlinken                                   //
///////////////////////////////////////////////////////////////////

function lbxCmeMod(id) {
  var lbx_links = document.getElementById(id).getElementsByTagName('a');
  var cmeSearchString = "_CMTREE=";
  var cmeLinkRoot = "/bilder/fotostrecken";
  for(i=0;i<lbx_links.length;i++){
    var lbxlink = lbx_links[i].href;
    var cmeIndex = lbxlink.indexOf(cmeSearchString);
    if (cmeIndex != -1) {
      var cmeLinkStart = cmeIndex+cmeSearchString.length;
      var cmeLinkEnd = lbxlink.indexOf("&");
      if(cmeLinkStart < cmeLinkEnd) {
        var cmeId = lbxlink.substring(cmeLinkStart,cmeLinkEnd);
      } else {
        var cmeId = lbxlink.substring(cmeLinkStart);
      }
      for(x=0;x<document.getElementsByTagName('meta').length;x++){
        var metatag = document.getElementsByTagName('meta')[x];
        if (metatag.getAttribute('name') == "diatag") var cmePath = metatag.getAttribute('content');
      }
      var ref = window.location.href.substr(window.location.href.lastIndexOf("/"));
      if(ref.indexOf("/art") != -1 || ref.indexOf(";art") != -1) ref = "art";
      if(typeof(cmePath) != "undefined"){
        lbx_links[i].href = cmeLinkRoot+"/"+cmePath+"/cme"+cmeId+",1.html?ref="+ref;
      } else {
        lbx_links[i].href = cmeLinkRoot+"/cme"+cmeId+",1.html?ref="+ref;
      }
      lbx_links[i].setAttribute("onclick", "", 0);
      lbx_links[i].setAttribute("target", "_top", 0);
    }
    var cmeVoting = lbxlink.indexOf("/voting/");
    if ( cmeVoting == -1 ) lbx_links[i].href = lbx_links[i].href.replace(",0.html",",1.html");
  }
  if(document.getElementById(id+'_0')){
    var lbxCount = 1;
    while(document.getElementById(id+'_'+lbxCount)){
      lbxCount++;
    }
    document.getElementById(id).id = id+'_'+lbxCount;
  } else {
    document.getElementById(id).id = id+'_0';    
  }
}

///////////////////////////////////////////////////////////////////
// anzeigenLoader (Dennis Bohn)                                  //
//                                                               //
// Funktion zur Einbindung von Flash-Animationen als digitale    //
// Anzeige                                                       //
///////////////////////////////////////////////////////////////////

function anzeigenLoader(id){
  obj = document.getElementById(id).getElementsByTagName('td');
  for(i=0;i<obj.length;i++){
    var unterzeile = obj[i].getElementsByTagName('div')[0].innerHTML;
    if(unterzeile.indexOf('.swf') != -1){
      var link = obj[i].getElementsByTagName('a')[0].href;
      var str = '<div style="width: 150px; text-align: ';
      if(i==0) {
        str += 'left';
      } else {
        str += 'right';
      }
      str += '">';
      str += '<object classid="CLSID:D27CDB6E-AE6D-11cf-96B8-444553540000" width="140" height="140" codebase="http://active.macromedia.com/flash2/cabs/swflash.cab#version=4,0,0,0">';
      str += '<param name="movie" value="/storage/med/ruhrnachrichten/flash/3556_anzeigenLoader.swf?flashmovie='+unterzeile+'&link='+link+'">';
      str += '<param name="quality" value="high">';
      str += '<param name="scale" value="exactfit">';
      str += '<param name="menu" value="false">';
      str += '<param name="bgcolor" value="#FFFFFF">';
      str += '<embed src="/storage/med/ruhrnachrichten/flash/3556_anzeigenLoader.swf?flashmovie='+unterzeile+'&link='+link+'" quality="high" scale="exactfit" menu="false" bgcolor="#000000" width="140" height="140" swLiveConnect="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash">';
      str += '</embed>';
      str += '</object>';
      str += '</div>';
      obj[i].innerHTML = str;
    }
  }
}

function winOpen(url, breite, hoehe) {
  // Errechnet Koordinaten, um das Popup zentriert zu platzieren
  links = (screen.width/2)-(breite/2);
  oben = (screen.height/2)-(hoehe/2);
  window.open(url,"popup","height="+hoehe+",width="+breite+",status = no,toolbar = no,menubar = no,location = no,resizable = no,titlebar = no,scrollbars = no,fullscreen = no,top ="+oben+",left ="+links);
} 

///////////////////////////////////////////////////////////////////
// show_schlaglicht (Dennis Bohn)                                //
//                                                               //
// Blendet das DPA-Schlaglicht auf der Übersichtsseite ein       //
///////////////////////////////////////////////////////////////////

function show_schlaglicht (article_id) {
  var content_container = document.getElementById('main_page_left').getElementsByTagName('div');
  for(i=0;i<content_container.length;i++){
    if (content_container[i].id == "art"+article_id) {
      content_container[i].className = "ar_teaser_schlaglichter";
    } else {
      content_container[i].className = "ar_teaser_schlaglichter_hidden";
    }
  }
}

// Diashow-Link-Anpasser

  $(document).ready(function(){

    $("DIV[name='dialink']").each(function(){

      // Aus dem Link wird die Tree-ID ermittelt
      var link = $(this).find("A").eq(0).attr("href");
      var tree_id = link.substring(link.indexOf("CMTREE=")+7,link.lastIndexOf("&"));

      // Aus dem versteckten Thumbnail wird die ID des ersten Bildes ermittelt

      if ( $(this).find("IMG").length > 0 && link.indexOf("CMTREE=") != -1 ) {

        var thumb = $(this).find("IMG").eq(0).attr("src");
        var pic_id = thumb.substring(thumb.lastIndexOf("/")+1);
        pic_id = pic_id.substring(0,pic_id.indexOf("_"));
        $(this).find("A").eq(0).attr("href","/bilder/fotostrecken/cme"+tree_id+","+pic_id+".html");
        $(this).find("A").eq(0).attr("onclick","");
        $(this).find("A").eq(0).attr("target","_top");

        $(this).css("display","block");

      }

    });

    $("TD[name='dialink']").each(function(){

      // Aus dem Link wird die Tree-ID ermittelt
      var link = $(this).find("A").eq(0).attr("href");
      var tree_id = link.substring(link.indexOf("CMTREE=")+7,link.lastIndexOf("&"));

      // Aus dem versteckten Thumbnail wird die ID des ersten Bildes ermittelt

      if ( $(this).find("IMG").length > 0 && link.indexOf("CMTREE=") != -1 ) {

        var thumb = $(this).find("IMG").eq(0).attr("src");
        var pic_id = thumb.substring(thumb.lastIndexOf("/")+1);
        pic_id = pic_id.substring(0,pic_id.indexOf("_"));
        $(this).find("A").eq(0).attr("href","/bilder/fotostrecken/cme"+tree_id+","+pic_id+".html");
        $(this).find("A").eq(0).attr("onclick","");
        $(this).find("A").eq(0).attr("target","_top");
        
      }

    });

  });

var bc_pids = new Object();

bc_pids["ruhrnachrichten"] = new Object();
bc_pids["ruhrnachrichten"]["neueste-videos"] = 8557953001;
bc_pids["ruhrnachrichten"]["lokales"]        = 8812006001;
bc_pids["ruhrnachrichten"]["nachrichten"]    = 8823603001;
bc_pids["ruhrnachrichten"]["vermischtes"]    = 8812004001;
bc_pids["ruhrnachrichten"]["sport"]          = 8812005001;
bc_pids["ruhrnachrichten"]["sport-live"]     = 8804039001;
bc_pids["ruhrnachrichten"]["kino"]           = 8823602001;
bc_pids["ruhrnachrichten"]["auto"]           = 8812003001;
bc_pids["ruhrnachrichten"]["literatur"]      = 36565856001;
bc_pids["ruhrnachrichten"]["top-videos"]     = 8812002001;
bc_pids["ruhrnachrichten"]["aktuelles"]      = 8557953001;

bc_pids["dorstenerzeitung"] = new Object();
bc_pids["dorstenerzeitung"]["neueste-videos"] = 10512648001;
bc_pids["dorstenerzeitung"]["lokales"]        = 10506299001;
bc_pids["dorstenerzeitung"]["nachrichten"]    = 10609658001;
bc_pids["dorstenerzeitung"]["vermischtes"]    = 10506309001;
bc_pids["dorstenerzeitung"]["sport"]          = 10609660001;
bc_pids["dorstenerzeitung"]["kino"]           = 10609651001;
bc_pids["dorstenerzeitung"]["auto"]           = 10506296001;
bc_pids["dorstenerzeitung"]["literatur"]      = 36565855001;
bc_pids["dorstenerzeitung"]["top-videos"]     = 10506306001;
bc_pids["dorstenerzeitung"]["aktuelles"]      = 10512648001;

bc_pids["halternerzeitung"] = new Object();
bc_pids["halternerzeitung"]["neueste-videos"] = 10609646001;
bc_pids["halternerzeitung"]["lokales"]        = 10512654001;
bc_pids["halternerzeitung"]["nachrichten"]    = 10506300001;
bc_pids["halternerzeitung"]["vermischtes"]    = 10506310001;
bc_pids["halternerzeitung"]["sport"]          = 10506303001;
bc_pids["halternerzeitung"]["kino"]           = 10512652001;
bc_pids["halternerzeitung"]["auto"]           = 10609649001;
bc_pids["halternerzeitung"]["literatur"]      = 36546184001;
bc_pids["halternerzeitung"]["top-videos"]     = 10512661001;
bc_pids["halternerzeitung"]["aktuelles"]      = 10609646001;

bc_pids["muensterschezeitung"] = new Object();
bc_pids["muensterschezeitung"]["neueste-videos"] = 10512649001;
bc_pids["muensterschezeitung"]["lokales"]        = 10609656001;
bc_pids["muensterschezeitung"]["nachrichten"]    = 10506301001;
bc_pids["muensterschezeitung"]["vermischtes"]    = 10609666001;
bc_pids["muensterschezeitung"]["sport"]          = 10506304001;
bc_pids["muensterschezeitung"]["kino"]           = 10512653001;
bc_pids["muensterschezeitung"]["auto"]           = 10609650001;
bc_pids["muensterschezeitung"]["literatur"]      = 36546186001;
bc_pids["muensterschezeitung"]["top-videos"]     = 10512662001;
bc_pids["muensterschezeitung"]["aktuelles"]      = 10512649001;

bc_pids["grevenerzeitung"] = new Object();
bc_pids["grevenerzeitung"]["neueste-videos"] = 10506295001;
bc_pids["grevenerzeitung"]["lokales"]        = 10609654001;
bc_pids["grevenerzeitung"]["nachrichten"]    = 10512655001;
bc_pids["grevenerzeitung"]["vermischtes"]    = 10609665001;
bc_pids["grevenerzeitung"]["sport"]          = 10506302001;
bc_pids["grevenerzeitung"]["kino"]           = 10512651001;
bc_pids["grevenerzeitung"]["auto"]           = 10609648001;
bc_pids["grevenerzeitung"]["literatur"]      = 36509168001;
bc_pids["grevenerzeitung"]["top-videos"]     = 10506307001;
bc_pids["grevenerzeitung"]["aktuelles"]      = 10506295001;

bc_pids["emsdettenervolkszeitung"] = new Object();
bc_pids["emsdettenervolkszeitung"]["neueste-videos"] = 10506294001;
bc_pids["emsdettenervolkszeitung"]["lokales"]        = 10609653001;
bc_pids["emsdettenervolkszeitung"]["nachrichten"]    = 10609657001;
bc_pids["emsdettenervolkszeitung"]["vermischtes"]    = 10506311001;
bc_pids["emsdettenervolkszeitung"]["sport"]          = 10512656001;
bc_pids["emsdettenervolkszeitung"]["kino"]           = 10506298001;
bc_pids["emsdettenervolkszeitung"]["auto"]           = 10512650001;
bc_pids["emsdettenervolkszeitung"]["literatur"]      = 36496822001;
bc_pids["emsdettenervolkszeitung"]["top-videos"]     = 10506305001;
bc_pids["emsdettenervolkszeitung"]["aktuelles"]      = 10506294001;

bc_pids["muensterlandzeitung"] = new Object();
bc_pids["muensterlandzeitung"]["neueste-videos"] = 10609647001;
bc_pids["muensterlandzeitung"]["lokales"]        = 10609655001;
bc_pids["muensterlandzeitung"]["nachrichten"]    = 10609659001;
bc_pids["muensterlandzeitung"]["vermischtes"]    = 10512663001;
bc_pids["muensterlandzeitung"]["sport"]          = 10609661001;
bc_pids["muensterlandzeitung"]["kino"]           = 10609652001;
bc_pids["muensterlandzeitung"]["auto"]           = 10506297001;
bc_pids["muensterlandzeitung"]["literatur"]      = 36546185001;
bc_pids["muensterlandzeitung"]["top-videos"]     = 10609664001;
bc_pids["muensterlandzeitung"]["aktuelles"]      = 10609647001;

function response(data) {

  if ( typeof ( data.items ) != "undefined" ) {
    var header = "Neueste Videos";
    var items = data.items;
  }
  if ( typeof ( data.videos ) != "undefined" ) {
    var bclid = data.id;
    var header = "Videos: "+data.name;
    var items = data.videos;
  }

  var image = '<img src="'+items[0].videoStillURL+'" width="300" />';
  var name = items[0].name;

  $("#videowidget td").eq(0).append('<img src="'+image+'" width="300" />');
  $("#videowidget h3").html(items[0].name);

  var hwsBox = '<div class="hws_box">';
  hwsBox += '<div class="header">' + header + '</div>';
  hwsBox += '<div class="videowidget">';
  hwsBox += '<table cellspacing="0" cellpadding="0" border="0" width="300">';
  hwsBox += '<tr>';
  hwsBox += '<td height="222" valign="middle" style="background-color:#3080A0">';
  hwsBox += '<div class="video">';
  hwsBox += '<div class="title">';
  hwsBox += '<h3>';
  hwsBox += name;
  hwsBox += '</h3>';
  hwsBox += '</div>';
  hwsBox += image;
  hwsBox += '</div>';
  hwsBox += '</td>';
  hwsBox += '</tr>';
  hwsBox += '<tr>';
  hwsBox += '<td>';
  hwsBox += '<img src="/pics/ruhr/videowidget_left.gif" width="14" height="14" class="vw_button">';
  hwsBox += '<div class="thumbs">';
  hwsBox += '<table cellspacing="2" cellpadding="3" border="0"><tr>'
  for( i=0; i<items.length; i++ ){
    if ( i >= 12 ) break;
    if ( i == 0 ) {
      hwsBox += '<td class="active">';
    } else {
      hwsBox += '<td>';
    }
    if ( bclid ) {
      var link = '/videos/?bctid='+items[i].id+'&bclid='+bclid+'&bcpid='+bcpid;
    } else {
      var link = '/videos/?bctid='+items[i].id;
    }
    hwsBox += '<a href="'+link+'">';
    hwsBox += '<img src="'+items[i].thumbnailURL+'" />';
    hwsBox += '</a>';
    hwsBox += '<span name="title">'+items[i].name+'</span>';
    hwsBox += '<span name="image">'+items[i].videoStillURL+'</span>';
    hwsBox += '</td>';
  }
  hwsBox += '</tr></table>';
  hwsBox += '</div>';
  hwsBox += '<img src="/pics/ruhr/videowidget_right.gif" width="14" height="14" class="vw_button">';
  hwsBox += '</td>';
  hwsBox += '</tr>';
  hwsBox += '</table>';
  hwsBox += '</div>';
  hwsBox += '<div class="uebersichtslink">';
  hwsBox += '<a href="/videos">Alle Videos »</a>';
  hwsBox += '</div>';
  hwsBox += '</div>';
  document.write(hwsBox);

  $(".videowidget:last .title").click(function() { window.location.href = $(".videowidget:last .thumbs A").eq(0).attr("href"); });
  $(".videowidget:last .thumbs").css("scrollLeft",0);

  $(".videowidget:last .thumbs TD").mouseover(function(){
    videoDiv = $(this).parents(".videowidget").find(".video");
    thisTr = $(this);
    $(this).parent().find("td").removeClass();
    $(this).addClass("active");
    if ( $(this).parents(".videowidget").find("img").eq(0).attr("src") != thisTr.find("SPAN[name='image']").html() ) {
      videoDiv.stop().fadeTo('fast',0,function () {
        var image = thisTr.find("SPAN[name='image']").html();
        var name = thisTr.find("SPAN[name='title']").html();
        var img = new Image();
        $(img).load(function () {
          videoDiv.find("img").eq(0).attr("src",image);
          videoDiv.find("h3").eq(0).html(name);        
          videoDiv.fadeTo('fast',1);
        }).attr('src',image);
      });
      $(this).parents(".videowidget").find(".title").click(function(){
        window.location.href = thisTr.find("a").attr("href");
      });
    }
  });

  $(".videowidget:last .vw_button").eq(0).click(function(){
    var offset1 = $(this).parents(".videowidget").find(".thumbs TD").eq(0).offset();
    var offset2 = $(this).parents(".videowidget").find(".thumbs TD").eq(1).offset();
    var offset = offset2.left - offset1.left;
    var bc_scrollpos = $(this).parents(".videowidget").find(".thumbs TABLE").css("margin-left");
    if ( bc_scrollpos == "auto" ) bc_scrollpos = 0;
    bc_scrollpos = Math.round(parseInt(bc_scrollpos)*(-1)/offset);
    if ( bc_scrollpos <= 0 ) {
      bc_scrollpos = $(this).parents(".videowidget").find(".thumbs TD").length - 3;
    } else if ( bc_scrollpos <= 2 ) {
      bc_scrollpos = 0;
    } else {
      bc_scrollpos -= 3;
    }
    if ( bc_scrollpos < 0 ) bc_scrollpos = $(this).parents(".videowidget").find(".thumbs TD").length-3;
    bcvwleft = bc_scrollpos * offset * (-1);
    $(this).parents(".videowidget").find(".thumbs TABLE").animate({"marginLeft":bcvwleft},300);
  });

  $(".videowidget:last .vw_button").eq(1).click(function(){
    var offset1 = $(this).parents(".videowidget").find(".thumbs TD").eq(0).offset();
    var offset2 = $(this).parents(".videowidget").find(".thumbs TD").eq(1).offset();
    var offset = offset2.left - offset1.left;
    var bc_scrollpos = $(this).parents(".videowidget").find(".thumbs TABLE").css("margin-left");
    if ( bc_scrollpos == "auto" ) bc_scrollpos = 0;
    bc_scrollpos = Math.round(parseInt(bc_scrollpos)*(-1)/offset);
    if ( bc_scrollpos >= $(this).parents(".videowidget").find(".thumbs TD").length - 3 ) {
      bc_scrollpos = 0;
    } else if ( bc_scrollpos >= $(this).parents(".videowidget").find(".thumbs TD").length - 5 ) {
      bc_scrollpos = $(this).parents(".videowidget").find(".thumbs TD").length - 3;
    } else {
      bc_scrollpos += 3;
    }
    bcvwleft = bc_scrollpos * offset * (-1);
    $(this).parents(".videowidget").find(".thumbs TABLE").animate({"marginLeft":bcvwleft},300);
  });

}

function videowidget () {

  var bc_api = "http://api.brightcove.com/services/library";
  var bc_token = "gPVgciZpiW8xZzAfOe8t6W0uP9xs6Y_gLbNA4ZH5LaQ.";
  var bc_fields = "id,name,thumbnailURL,videoStillURL,playsTrailingWeek";
  var bc_sort = "PUBLISH_DATE";

  var bc_command = videowidget.arguments[0];
  var bc_pagesize = 12;

  if ( bc_command == 'find_all_videos') {
    var bc_src = bc_api+'?command='+bc_command+'&token='+bc_token+'&fields='+bc_fields+'&sort_by='+bc_sort+'&page_size='+bc_pagesize+'&callback=response';
    document.write('<scr'+'ipt type="text/javascript" src="'+bc_src+'"></scr'+'ipt>');
  } else if ( bc_command == 'find_playlist_by_id') {
    var playlist_id = videowidget.arguments[1];
    var domain = window.location.hostname.split(".")[1];
    domain = domain.replace("-","");
    bcpid = bc_pids[domain][videowidget.arguments[2]];
    var bc_src = bc_api+'?command='+bc_command+'&playlist_id='+playlist_id+'&token='+bc_token+'&callback=response';
    document.write('<scr'+'ipt type="text/javascript" src="'+bc_src+'"></scr'+'ipt>');
  }

}