var popupWindow = null;

function setOpacity(objectId, opacity)
{
  var object = document.getElementById(objectId);
  if (!object) {
    object = top.document.getElementById(objectId);
  }
  if (object && object.style) {
    if (navigator.userAgent.indexOf("Firefox") != -1) {
      if (opacity == 100) { opacity = 99.9999; }
    }
    object.style.opacity = (opacity / 100);
    object.style.MozOpacity = (opacity / 100);
    object.style.KhtmlOpacity = (opacity / 100);
    object.style.filter = 'alpha(opacity=' + opacity + ')';
  }
}

function changeOpacity(objectId, startValue, endValue, milliSec)
{
  var speed = Math.round(milliSec / 100);
  var timer = 0;

  if (startValue > endValue) {
    for (var i = startValue; i >= endValue; i--) {
      setTimeout("setOpacity('" + objectId + "'," + i + ")",(timer * speed));
      timer++;
    }
  } else if (startValue < endValue) {
    for (var i = startValue; i <= endValue; i++) {
      setTimeout("setOpacity('" + objectId + "'," + i + ")",(timer * speed));
      timer++;
    }
  }
}

function fadeIn(objectId, milliSec)
{
  changeOpacity(objectId, 0, 100, milliSec);
}

function fadeOut(objectId, milliSec)
{
  changeOpacity(objectId, 100, 0, milliSec);
}

function showToolTip(name)
{
  var container = document.getElementById('bandleden');
  if (!container) { return null; }

  clearToolTip();

  var div = document.createElement('div');
  div.id  = 'tooltip';
  div.style.position  = 'absolute';
  div.style.overflow  = 'hidden';
  div.style.textAlign = 'center';
  div.style.zIndex    = '99';
  div.appendChild(document.createTextNode(name));

  container.appendChild(div);
}

function clearToolTip()
{
  var tooltip = document.getElementById('tooltip');
  if (tooltip) {
    tooltip.parentNode.removeChild(tooltip);
  }
}

function createCenteredWindow(url,width,height)
{
  var xOffset,yOffset;
  var xMax,yMax;
  var popupWindow;
  var left = parseInt((screen.availWidth/2) - (width/2));
  var top = parseInt((screen.availHeight/2) - (height/2));
  var windowFeatures = 
    'width=' + width + ',height=' + height + 
    ',left=' + left + ',top=' + top + 
    ',screenX=' + left + ',screenY=' + top + 
    ',scrollbars=yes,resizable';

  if (popupWindow != null) {
    popupWindow.close();
  }
  popupWindow = window.open(url, 'PopupWindow', windowFeatures);
  popupWindow.focus();
  return false;
}

function showNieuwsbrief(href)
{
  if (href == null) {
    var box = document.forms[0].nbselector;
    href = box.options[box.selectedIndex].value;
  }
  if (popupWindow) {
    popupWindow.close();
  }
  if (href && href.length > 0) {
    createCenteredWindow(href, 800, 800);
  }
  return false;
}

function checkFrameset()
{
  if (parent == window) {
    var pathArray = location.href.split("/");
    var page = pathArray[pathArray.length-1];
    if (location.replace) {
      location.replace('index.html');
    } else {
      location.href = 'index.html';
    }
  } else if (document.images) {
    img1 = new Image();
    img1.src = "http://www.kleinkracht.nl/php/log.php?" + document.URL;
  } 
}

function startSession() {
  if (document.images) {
    img1 = new Image();
    img1.src = 'http://www.kleinkracht.nl/php/start.php?wdt=' + screen.width + '&hgt=' + screen.height;
    img2 = new Image();
    img2.src = "http://www.kleinkracht.nl/php/log.php?index.html";
  } 
}



