/*-----------------------------------------------*/
/* Some global initialization                    */
/*-----------------------------------------------*/

function navigatorInfo(tableSize, col1Width, col2Width, col3Width, col4Width) {
  var agent = navigator.userAgent.toLowerCase();
  this.ver = navigator.appVersion;
  this.agent = navigator.userAgent;
  this.dom = document.getElementById ? 1 : 0;
  this.ie5 = (this.ver.indexOf("MSIE 5") > -1 && this.dom) ? 1 : 0;
  this.ie6 = (this.ver.indexOf("MSIE 6") > -1 && this.dom) ? 1 : 0;
  this.ie4 = (document.all && !this.dom) ? 1 : 0;
  this.ie = this.ie4 || this.ie5 || this.ie6;
  this.mac = this.agent.indexOf("Mac") > -1;
  this.ns6 = (this.dom && parseInt(this.ver) >= 5) ? 1 : 0;
  this.ns4 = (document.layers && !this.dom) ? 1 : 0;
  this.bw = (this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns6);
  this.op = (agent.indexOf("opera") != -1);
  this.unix = (agent.indexOf("x11") != -1);
  this.win = (agent.indexOf("win") != -1);
  this.width = screen.width;
  this.lowRes = (screen.width <= 800);
  this.medRes = (screen.width > 800 && screen.width <= 1024);
  this.highRes = (screen.width > 1024);
  this.progTblSize = tableSize;
  this.auditColSize = col1Width;
  this.partNoColSize = col2Width;
  this.titleColSize = col3Width;
  this.perfColSize = col4Width;
  return this;
}

browser = new navigatorInfo(760, 5, 8, 65, 22);

px = browser.ns4 ? "" : "px";

var timerID = null;
var timerOn = false;
var timecount = 1000;
var what = null;
var newbrowser = true;
var check = false;

lang = "";

if (document.layers) {
 scrX= innerWidth; scrY= innerHeight;
  onresize= function() { if (scrX != innerWidth || scrY != innerHeight) { history.go(0) }}
}

/*-----------------------------------------------*/
function drawHeader(menuitem){
  var lang = getLang();

  var strGastenboek = "Gastenboek"; if (lang == "en") strGastenboek = "Guestbook";
  var strInfo = "Info";

  var hdr = "";
  hdr += "<table border=0 cellpadding=0 cellspacing=0 width=100% align=center>";
  hdr += "<tr valign=top>";
  hdr += "  <td align=center valign=center width='250'><a href='../index.html'><img src='../img/capvoclogo.jpg' border=0></a></td>";
  hdr += "  <td valign=middle align=right nowrap>";
  hdr += "    <img src='../img/gastenboek.gif' border=0 align=top alt=> <a href='http://server.scripthost.com/guestbook?bogaertb' target='_blank' class=topmenu>" + strGastenboek + "</a>&nbsp;&nbsp";
  hdr += "    <img src='../img/mail.gif' border=0 align=top> <a href='mailto:bartaf.bogaert@skynet.be' class=topmenu>" + strInfo + "</a>&nbsp;<br>";
  hdr += "    <div class=mainmenu>";
  hdr += drawMenu(menuitem);
  hdr += "    </div>";
  hdr += "  </td>";
  hdr += "</tr>";
  hdr += "</table>";

  document.write(hdr);
}
/*-----------------------------------------------*/
function getLang() {
  return lang;
}
/*-----------------------------------------------*/
function getImgPrefix() {
  var imgPrefix = "";
  var path = window.location.pathname;
  if (((path.indexOf("/nl/") != -1) || (path.indexOf("/en/") != -1)) ||
      ((path.indexOf("\\nl\\") != -1) || (path.indexOf("\\en\\") != -1))) {
    imgPrefix = "../img/";
  } else {
    imgPrefix = "img/";
  }
//  alert("getImgPrefix - path = '" + path + "'\n, imgPrefix = '" + imgPrefix + "'");
  return imgPrefix;
}
/*-----------------------------------------------*/
function getTxtPrefix() {
  var txtPrefix = "";
  var path = window.location.pathname;
  if (((path.indexOf("/nl/") != -1) || (path.indexOf("/en/") != -1)) ||
      ((path.indexOf("\\nl\\") != -1) || (path.indexOf("\\en\\") != -1))) {
    txtPrefix = "";
  } else {
    txtPrefix = getLang() + "/";
  }
//  alert("getTxtPrefix - path = '" + path + "'\n, txtPrefix = '" + txtPrefix + "'");
  return txtPrefix;
}
/*-----------------------------------------------*/
function calcSize() {

  winW = (browser.ns4)? window.innerWidth-16:document.body.offsetWidth-20
  winH = (browser.ns4)? window.innerHeight:document.body.offsetHeight

  winoW = (browser.ns4)? window.outerWidth:999;
  winoH = (browser.ns4)? window.outerHeight:999;

  scrW = (browser.ns4)? screen.width:screen.width;
  scrH = (browser.ns4)? screen.height:screen.height;

  /*
  document.write("Window WidthxHeight: " + winW + "x" + winH + " / " +  winoW + "x" + winoH + "<br>");
  document.write("Screen WidthxHeight: " + scrW + "x" + scrH);
   */

  winH -= 165;
	return(winH);
}
/*-----------------------------------------------*/
function calcDate(){
  var lastMod = new Date();
  lastMod.setTime(Date.parse(document.lastModified));
  return("" + lastMod.toLocaleString());
}
/*-----------------------------------------------*/
function setLang(selectedLang) {
  lang = selectedLang;
}
/*-----------------------------------------------*/
function init() {
  if (document.layers) {
    //  alert ("Running Netscape 4");
    layerRef = "document.layers";
    styleSwitch = "";
    visibleVar = "show";
    screenSize = window.innerWidth;
    what = "ns4";
  } else if (document.all) {
    //  alert ("Running IE");
    layerRef = "document.all";
    styleSwitch = ".style";
    visibleVar = "visible";
    screenSize = document.body.clientWidth + 18;
    what ="ie";
  } else if (document.getElementById) {
    //  alert ("Running Netscape 6");
    layerRef = "document.getElementByID";
    styleSwitch = ".style";
    visibleVar = "visible";
    what = "moz";
  } else {
    //alert("Older than 4.0 browser.");
    what = "none";
    newbrowser = false;
  }
  check = true;
}
/*-----------------------------------------------*/
function getTableSize() {
  return(browser.progTblSize);
}
/*-----------------------------------------------*/
function getAuditColSize() {
  return(browser.auditColSize);
}
/*-----------------------------------------------*/
function getTitleColSize() {
  return(browser.titleColSize);
}
/*-----------------------------------------------*/
function getPartNoColSize() {
  return(browser.partNoColSize);
}
/*-----------------------------------------------*/
function getPerfColSize() {
  return(browser.perfColSize);
}
/*-----------------------------------------------*/
function getColHeight() {
  var colHeight = 0;
  var i = 0;
  
  while ((i < sizes.length) &&
  	 (sizes[i].screenWidth != browser.width)) {
    i++;
  }
  colHeight = (i < sizes.length) ? sizes[i].colHeight : sizes[0].colHeight;
  return(colHeight);
}

// Turns the layers on and off
function showLayer(layerName) {
  if (check) {
    if (what =="none") {
      return;
    } else if (what == "moz") {
      document.getElementById(layerName).style.visibility="visible";
    } else {
      eval(layerRef+'["'+layerName+'"]'+styleSwitch+'.visibility="visible"');
    }
  } else {
    // alert ("Please wait for the page to finish loading.");
    return;
  }
}

function hideLayer(layerName) {
  if(check) {
    if (what =="none") {
      return;
    } else if (what == "moz") {
      document.getElementById(layerName).style.visibility="hidden";
    } else {
      eval(layerRef+'["'+layerName+'"]'+styleSwitch+'.visibility="hidden"');
    }
  } else {
    // alert ("Please wait for the page to finish loading.");
    return;
  }
}

function hideAll() {
//  alert("hideAll - timerID = '" + timerID + "'");
  hideLayer('voorstelling');
  hideLayer('historiek');
  //  hideLayer('programma');
  hideLayer('multi');
  //  hideLayer('persmap');
  //  hideLayer('pers');
  if (timerOn == 1) {
    stopTime();
  }
}

function startTime() {
//  alert("startTime in - timerID = '" + timerID + "'");
  if (timerOn == 0) {
    timerID = setTimeout("hideAll()", timecount);
    timerOn = 1;
  }
//  alert("startTime out - timerID = '" + timerID + "'");
}

function stopTime () {
//  alert("stopTime in - timerID = '" + timerID + "'");
  if (timerOn == 1) {
    clearTimeout(timerID);
    timerID = null;
    timerOn = 0;
  }
//  alert("stopTime out - timerID = '" + timerID + "'");
}
