if (document.all || document.getElementById || document.layers) {
  if (/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent)) {
    var ffversion = new Number(RegExp.$1) // capture x.x portion and store as a number
    if (ffversion < 3) {
      setInterval("initialize()", 20);
    }
    else setInterval("initializeNew()", 20);
  }
  else setInterval("initializeNew()", 20);

}

var speed = 0;
var dw = 0;

function scrollwindow() 
{
  window.scrollBy(speed, 0);
}

function initializeNew() 
{
  if (speed != 0) {
    scrollwindow();

    var scrOfX = 0;
    if (document.body.scrollLeft) {
      scrOfX = document.body.scrollLeft;
    } else if (document.documentElement.scrollLeft) {
      scrOfX = document.documentElement.scrollLeft;
    }

    if (scrOfX == dw) window.scroll(2689 - clientWidth(), 0);
    if (scrOfX == 0) { window.scroll(9999, 0); window.scrollBy(-2689 + clientWidth(), 0); }
  }
}

function initialize() 
{
  if (speed != 0) {
    scrollwindow();
  }
}

function clientWidth() {
  return filterResults (
    window.innerWidth ? window.innerWidth : 0,
    document.documentElement ? document.documentElement.clientWidth : 0,
    document.body ? document.body.clientWidth : 0
  );
}

function filterResults(n_win, n_docel, n_body) {
  var n_result = n_win ? n_win : 0;
  if (n_docel && (!n_result || (n_result > n_docel))) n_result = n_docel;
  return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
}

function adjustwidth()
{
  if (/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent)) {
    var ffversion = new Number(RegExp.$1) // capture x.x portion and store as a number
    if (ffversion < 3) {
      document.getElementById("rightImage").width = "60";
      parent.document.getElementById("leftPan").style.width = (clientWidth() - 420).toString(10) + "px";
    }
  }
  
  dw = document.getElementById("projectsTable").offsetWidth - document.documentElement.clientWidth + 20;
}

function pageload()
{
  showdetails('overview', 'ASM (x86), C, C++, C#, Java, Pascal, Delphi, Haskell...', 'seven years', '2001 - now', 'various (mouse over project<small>...</small>)');
  window.scroll(1340, 0);
  adjustwidth();
}

function showdetails(project, techniques, time, date, customer) 
{
  if (document.getElementById) {
    parent.document.getElementById("project").innerHTML = project;
    parent.document.getElementById("techniques").innerHTML = techniques;
    parent.document.getElementById("time").innerHTML = time;
    parent.document.getElementById("date").innerHTML = date;
    parent.document.getElementById("customer").innerHTML = customer;
  }
}

function popvideo(title, num) 
{
  var links = new Array()
  links[0] = "<embed id='VideoPlayback' src='http://video.google.com/googleplayer.swf?docid=-5566187446942810519&hl=en&fs=true' style='width:400px;height:326px' allowFullScreen='false' allowScriptAccess='always' type='application/x-shockwave-flash'></embed>"
  links[1] = "<embed id='VideoPlayback' src='http://video.google.co.uk/googleplayer.swf?docid=5097216630206570589&hl=en&fs=true' style='width:400px;height:326px' allowFullScreen='false' allowScriptAccess='always'></embed>"
  links[2] = "<embed src='http://d.yimg.com/static.video.yahoo.com/yep/YV_YEP.swf?ver=2.2.40' type='application/x-shockwave-flash' width='512' height='322' allowFullScreen='true' AllowScriptAccess='always' bgcolor='#000000' flashVars='id=13301811&vid=4999605&lang=en-us&intl=us&thumbUrl=http%3A//l.yimg.com/a/p/i/bcst/videosearch/8705/84907828.jpeg&embed=1' ></embed>"
  var width = 400;
  var height = 326;
  var left = parseInt((screen.availWidth/2) - (width/2));
  var top = parseInt((screen.availHeight/2) - (height/2));

  var windowFeatures = "width=" + width + ",height=" + height + ",status=0,resizable=0,scrollbars=0,left=" + left + ",top=" + top + "screenX=" + left + ",screenY=" + top;
  var popwind = window.open("", "", windowFeatures)
  var html = "<html><head><title>"+ title + " Video</title></head>";
  html += "<body style='padding: 0; margin: 0;'>" + links[num] + "</body></html>"
  popwind.document.open()
  popwind.document.write(html)
  popwind.document.close()
}

function popvideoyahoo(title, num)
{
  var links = new Array()
  links[0] = "<embed src='http://d.yimg.com/static.video.yahoo.com/yep/YV_YEP.swf?ver=2.2.40' type='application/x-shockwave-flash' width='512' height='322' allowFullScreen='true' AllowScriptAccess='always' bgcolor='#000000' flashVars='id=13301811&vid=4999605&lang=en-us&intl=us&thumbUrl=http%3A//l.yimg.com/a/p/i/bcst/videosearch/8705/84907828.jpeg&embed=1' ></embed>"
  var width = 512;
  var height = 322;
  var left = parseInt((screen.availWidth/2) - (width/2));
  var top = parseInt((screen.availHeight/2) - (height/2));

  var windowFeatures = "width=" + width + ",height=" + height + ",status=0,resizable=0,scrollbars=0,left=" + left + ",top=" + top + "screenX=" + left + ",screenY=" + top;
  var popwind = window.open("", "", windowFeatures)
  var html = "<html><head><title>"+ title + " Video</title></head>";
  html += "<body style='padding: 0; margin: 0;'>" + links[num] + "</body></html>"
  popwind.document.open()
  popwind.document.write(html)
  popwind.document.close()
}

function popscreenshots(title, name, count, width, height) 
{
  var left = parseInt((screen.availWidth/2) - (width/2));
  var top = parseInt((screen.availHeight/2) - (height/2));

  var scroll = ((screen.availWidth < width) || (screen.availHeight < height)) ? 1 : 0;

  var windowFeatures = "width=" + width + ",height=" + height + ",status=0,resizable=0,scrollbars=" + scroll + ",left=" + left + ",top=" + top + "screenX=" + left + ",screenY=" + top;
  var popwind = window.open("", "", windowFeatures)
  var html = "<html><head><script type='text/javascript' src='screenshots.js'></script>"
  html += "<link href='screenshots.css' rel='stylesheet' type='text/css'/><title>"+ title + " Screenshots</title></head>"
  html += "<body id='body' onload='javascript:init(\"" + name + "\", " + count + ", 1)'></body></html>"
  popwind.document.open()
  popwind.document.write(html)
  popwind.document.close()

}