/* Javascript geschreven door Krijn Hoetmer ~ http://ktk.xs4all.nl/ voor SQR Amsterdam .. En met wat hulp van PPK (http://www.quirksmode.org/js/fixedmenu.html) */

var popped = false;
var DOMsupport = document.getElementById && document.getElementsByTagName && document.createElement;

function moveImg() {
  if (popped) {
    if (window.innerHeight) {
      pos = window.pageYOffset
    } else if (document.documentElement && document.documentElement.scrollTop) {
      pos = document.documentElement.scrollTop
    } else if (document.body) {
      pos = document.body.scrollTop
    }
    if (pos < 190) {
      pos = 190;
    } else {
      pos += 30;
    }
    document.getElementById('example').style.top = pos + 'px';
  }
}

function renderImg(that, s) {
  
  var i = document.createElement('img');
  i.setAttribute('src', s);
  i.setAttribute('title', 'Close');
  i.onclick = function() {
    this.parentNode.parentNode.removeChild(this.parentNode);
    popped = false;
  }
  
  var e = document.createElement('div');
  e.setAttribute('id', 'example');
  e.appendChild(i);
  
  e.style.width = i.width + 'px';
  e.style.height = i.height + 'px';
  
  document.getElementsByTagName('body')[0].appendChild(e);
  popped = true;
  moveImg();
}

if (DOMsupport) {
  window.onload = function() {
    var menu = document.getElementById('menu');
    var submenus = menu.getElementsByTagName('li');
    var arrImages = Array('home', 'company', 'crew', 'crew-minnemijn', 'crew-associates', 'services', 'services-maritime', 'services-onshore', 'planofapproach', 'projects', 'press', 'contact');
    var pics = new Array();
    for (var i = 0; i < 11; i++) {
      pics[i] = new Image;
      pics[i].src = '/projecten/boart/img/menu/' + arrImages[i] + '-hov.gif';
    }
    for (var i = 0; i < submenus.length; i++) {
      submenus[i].onmouseover = function() {
        var thisSrc = this.getElementsByTagName('img')[0].src;
        if (thisSrc.indexOf('-hov') == -1) {
          // Opera fix
          this.getElementsByTagName('img')[0].src = thisSrc.substr(0, thisSrc.length - 4) + '-hov.gif';
        }
      }
      submenus[i].onmouseout = function() {
        var thisSrc = this.getElementsByTagName('img')[0].src;
        if (thisSrc.indexOf('-hov') != -1 && this.className.indexOf('nochange') == -1) {
          // Meteen een fix voor Opera
          this.getElementsByTagName('img')[0].src = thisSrc.substr(0, thisSrc.length - 8) + '.gif';
        }
      }
    }
    var imgs = document.getElementsByTagName('img');
    for (var i = 0; i < imgs.length; i++) {
      if (imgs[i].getAttribute('longdesc') && imgs[i].getAttribute('longdesc') != '') {
        try { // IE5 kent 'pointer' niet
          imgs[i].style.cursor = 'pointer';
        } catch(e) {
          imgs[i].style.cursor = 'hand';
        }
        imgs[i].setAttribute('title', 'Enlarge');
        imgs[i].onclick = function() {
          if (!popped) {
            var i = new Image();
            i.src = this.getAttribute('longdesc');
            var s = this.getAttribute('longdesc');
            renderImg(this, s);
          }
        }
      }
    }
    
    var areas = document.getElementsByTagName('area');
    for (var m = 0; m < areas.length; m++) {
      areas[m].setAttribute('title', 'Enlarge');
      areas[m].onclick = function() {
        if (!popped) {
          var i = new Image();
          i.src = this.getAttribute('href');
          var s = this.getAttribute('href');
          renderImg(this, s);
          return false;
        } else { 
          return false;
        }
      }
    }
  }
}

var w = null
var url = null
function dopopup(url)
{
	if (w==null || w.closed)
	{
		w = window.open(url,"popup","toolbar=0,location=0,status=0,menubar=0,scrollbars=1,resizable=0,width=617,height=700");
	}
	else
	{
		w.location = url;
	}
	w.focus();
}
