
function createclip(clipid, swffile, file, w, h, extra)
{
    var data = swffile + '?file=' + file + '&autoStart=false';
    var x = document.getElementById(clipid).innerHTML;
    if (x.indexOf(file) !== -1)
      document.getElementById(clipid).innerHTML = "";
    else
    {
      if (arguments.length < 6) extra = '';

      var mp4file = file.replace('.flv', '.mp4');
    document.getElementById(clipid).innerHTML = ('\
<object align=center type="application/x-shockwave-flash" data="'+data +'" width="'+w + '" height="' + (h+20) + '" wmode="transparent">\
  <param name="movie" value="' + data + '" \/>\
  <param name="wmode" value="transparent" \/>\
<\/object>' + extra);
  }
}
function createclip_html5(clipid, swffile, file, w, h, extra)
{
    var data = swffile + '?file=' + file + '&autoStart=false';
    var x = document.getElementById(clipid).innerHTML;
    if (x.indexOf(file) !== -1)
      document.getElementById(clipid).innerHTML = "";
    else
    {
      if (arguments.length < 6) extra = '';
      var mp4file = file.replace('.flv', '.mp4');
      var ogvfile = file.replace('.flv', '.ogv');
      var videofile = ogvfile;
      if (navigator.userAgent.toLowerCase().indexOf('safari') != -1)
        videofile = mp4file;
    document.getElementById(clipid).innerHTML = ('\
<video src="'+videofile+'" controls="controls">\
<object align=center type="application/x-shockwave-flash" data="'+data +'" width="'+w + '" height="' + (h+20) + '" wmode="transparent">\
  <param name="movie" value="' + data + '" \/>\
  <param name="wmode" value="transparent" \/>\
<\/object>' + extra + '\
</video>');
/*
<object align=center type="application/x-shockwave-flash" data="'+data +'" width="'+w + '" height="' + (h+20) + '" wmode="transparent">\
  <param name="movie" value="' + data + '" \/>\
  <param name="wmode" value="transparent" \/>\
<\/object>' + extra);
*/
  }
}


// [[www.resturl text]] url
// [[http://resturl text]] url
// [[en:page text]] wikipedia page (page with _ instead of spaces)
function wikipedia(id, idistext, imgwidth)
{
  var x = id;
  if (arguments.length < 3)
    imgwidth = '';
  else
    imgwidth = " \\width="+imgwidth+"\\'";

  if (arguments.length == 1 || !idistext)
    x = document.getElementById(id).innerHTML;

  // Generate mouseovers for dynamic drive pics
  // MUST USE single quotes for text !!!
  // Quotes in tags (e.g. <a href) should be escaped by \'  !!!
  // Untagged IMAGES should NOT be quoted !!!
  var re = /:::(.+?):::/mg;
  var a;
  var img_re = /^(.+?\.(gif|jpe?g|png))$/;
  while( a = re.exec(x))
  {
    a[1] = a[1].replace(img_re, "'<img src=\\'$1\\'"+imgwidth+" alt=\\'missing $1\\' />'");
    a[1] = a[1].replace(/"/gm, "'");

    var repl =

  " onmouseover=\"ddrivetip("+a[1]+");\"  onmouseout=\"hideddrivetip();\"";
    x = x.replace(a[0], repl);
  }

  x = x.replace(/\[\[(https?:\/\/[\S]+)\s+([^\]]+)\]\]/mg, '<a href="$1" target="_wiki">$2<\/a>');
  x = x.replace(/\[\[(www\.\S+)\s+([^\]]+)\]\]/mg, '<a href="http://$1" target="_wiki">$2<\/a>');
  x = x.replace(/\[\[([a-z][a-z]):([^\]: \t]+)\s+([^\]]+)\]\]/mg, '<a href="http://$1.wikipedia.org/wiki/$2" target="_wiki">$3<\/a>');
  x = x.replace(/\[\[([a-z][a-z])::([^\]]+)\]\]/mg, '<a href="http://$1.wikipedia.org/wiki/$2" target="_wiki">$2<\/a>');

  // replace spaces generating >onmouseover outside <A...> tag
  x = x.replace(/>(onmouseover.+?onmouseout="hideddrivetip\(\);")/gm, "$1>");;

  if (x != id)
  document.getElementById(id).innerHTML = x;
  return x;
}

//Show or Hide a Table when a link is clicked.
function showhide(theTable, on)
{
if (typeof(on) == 'undefined' || on == -1) on = (document.getElementById(theTable).style.display == 'none');
if (on)
  {
  document.getElementById(theTable).style.display = 'block';
  }
  else
  {
  document.getElementById(theTable).style.display = 'none';
  }
}


//  sourceID : ID of source div
//  help: ID of target div
//  title: title of link
//   out += helptext('xxx', 'help', 'info...');

function text2html(sourceID, targetID, title)
{
  var text2html = document.getElementById(sourceID).innerHTML;

  // Kopjes met twee :: worden haadrietjes
  text2html = text2html.replace(/(.+?)::(\r?\n)+/g, '<h3>$1<\/h3>');
  // Kopjes met een : worden haaviertjes
  text2html = text2html.replace(/(.+?):(\r?\n)+/g, '<h4>$1<\/h4>');
  // Bug in JS regexp handler : maak andere tag van linefeeds
  text2html = text2html.replace(/\r?\n/g, '__LF__');

  text2html = text2html.replace(/__LF__</g,'<');


  // verwijder HTML commentaar
  text2html = text2html.replace(/<!\-\-(.+?)\-\->/g, '$1');
  // dubbele LF wordt een peetje
  text2html = text2html.replace(/__LF__\s*__LF__/g, '<p>');
  // enkele LF wordt een brrr...
  text2html = text2html.replace(/__LF__/g, '<br />');

  document.getElementById(targetID).innerHTML = text2html;
  return '<a href="javascript:showhide(\'' + targetID + '\')"><b>&nbsp;' + title + '&nbsp;<\/b><\/a>';

}


function makeEmail(subject)
{
   var myname = "jk``r" + "?" + "udko";
   var s = "";
   for (i=0; i<myname.length; i++)
   {
      n = myname.charCodeAt(i);
      s += String.fromCharCode(n+1);
   }
   myname = "mailto:" + s;
   myname += ".info?subject=" + subject;
   location.href = myname;
}
