

var img;
var img_mo;
var img_cl;
img = new Array();
img_mo = new Array();
img_cl = new Array();


if (top.location.href.indexOf('frameid=') != -1 && top.location.href.indexOf('/print=true') == -1) {
  top.location.href = top.location.href.replace('frameid=', 'framenoid=');
}



function setCookie(name, value, expire) {
  if (expire == '') {
    document.cookie = name + "=" + escape(value);
  } else {
    var expires = new Date();
    expires.setTime(expires.getTime() + expire);

    document.cookie = name + "=" + escape(value) + ((expire == null) ? "" : ("; expires=" + expires.toGMTString())) + "; path=/";
  }
}


function getCookie(name) {
   var search = name + "=";
   var val = "";

   if (document.cookie.length > 0) { // if there are any cookies
      offset = document.cookie.indexOf(search) 

      if (offset != -1) { // if cookie exists 
         offset += search.length;

         // set index of beginning of value
         end = document.cookie.indexOf(";", offset) 

         // set index of end of cookie value
         if (end == -1) {
            end = document.cookie.length;
         }

         val = unescape(document.cookie.substring(offset, end));
      } 
   }

   return val;
}



function initMo(uniqueid, origImgSrc, overImgSrc, clickImgSrc) {
  if (origImgSrc != '') {
    img[uniqueid] = new Image();
    img[uniqueid].src = origImgSrc;
  }
  if (overImgSrc != '') {
    img_mo[uniqueid] = new Image();
    img_mo[uniqueid].src = overImgSrc;
  }
  if (clickImgSrc != '') {
    img_cl[uniqueid] = new Image();
    img_cl[uniqueid].src = clickImgSrc;
  }
}


function mov(uniqueid) {
  if (img_mo[uniqueid]) {
    document[uniqueid].src = img_mo[uniqueid].src;
  }
}


function mou(uniqueid) {
  if (img[uniqueid]) {
    document[uniqueid].src = img[uniqueid].src;
  }
}


function md(uniqueid) {
  if (img_cl[uniqueid]) {
    document[uniqueid].src = img_cl[uniqueid].src;
  }
}


function initMouseOver(uniqueid, origImgSrc, overImgSrc, clickImgSrc) {
  img['I' + uniqueid + origImgSrc] = new Image();
  img['I' + uniqueid + origImgSrc].src = origImgSrc;
  img_mo['I' + uniqueid + origImgSrc] = new Image();
  img_mo['I' + uniqueid + origImgSrc].src = overImgSrc;
  img_cl['I' + uniqueid + origImgSrc] = new Image();
  img_cl['I' + uniqueid + origImgSrc].src = clickImgSrc;
}

function MouseOver(imgName) {
  document[imgName].src = img_mo[imgName].src;
}

function MouseOut(imgName) {
  document[imgName].src = img[imgName].src;
}

function MouseDown(imgName) {
  document[imgName].src = img_cl[imgName].src;
}


function encode(num, isopen) {
  var hexChars = "0123456789ABCDEF";
  var i = 0;
  var tmp_num = num;
  var str = "";

  if (!isopen) {
    tmp_num = tmp_num + 2147483648;
  }

  for (i = 0; i < 8; i++) {
    str = hexChars.charAt((tmp_num >> (4 * i)) & 15) + str;
  }

  return str;
}


function maximizeBlock(blockid) {
  maximizeBlock2(blockid,'');
}

function maximizeBlock2(blockid,cookiename) {
  var pre;
  var post;
  var i;

  if (cookiename == '') {
    cookie = getCookie('www.nationaalbrandweermuseum.nl');
  } else {
    cookie = getCookie(cookiename);
  }

  // See if the closed block exists
  i = cookie.indexOf(encode(blockid, false) + ';');

  if (i > -1) {
    pre = cookie.substring(0, i);
    post = ((i + 9) < cookie.length) ? cookie.substring(i + 9, cookie.length) : "";

    // Replace the closed block by an opened block
    cookie = pre + encode(blockid, true) + ';' + post;
  } else {
    // See if the opened block does not already exist
    i = cookie.indexOf(encode(blockid, true) + ';');

    if (i == -1) {
      // Add the opened block
      cookie = cookie + encode(blockid, true) + ';';
    }
  }

  // Reset the cookie
  if (cookiename == '') {
    setCookie('www.nationaalbrandweermuseum.nl', cookie, 1000*60*60*24*365);
  } else {
    setCookie(cookiename, cookie, 1000*60*60*24*365);
  }
  top.open(window.location, '_self');
}


function minimizeBlock(blockid) {
  minimizeBlock2(blockid,'');
}


function minimizeBlock2(blockid,cookiename) {
  var pre;
  var post;
  var i;
  var cookie;

  if (cookiename == '') {
    cookie = getCookie('www.nationaalbrandweermuseum.nl');
  } else {
    cookie = getCookie(cookiename);
  }

  // See if the opened block exists
  i = cookie.indexOf(encode(blockid, true) + ';');

  if (i > -1) {
    pre = cookie.substring(0, i);
    post = ((i + 9) < cookie.length) ? cookie.substring(i + 9, cookie.length) : "";

    // Replace the opened block by the closed block
    cookie = pre + encode(blockid, false) + ';' + post;
  } else {
    // See if the closed block does not already exist
    i = cookie.indexOf(encode(blockid, false) + ';');

    if (i == -1) {
      // Add the closed block
      cookie = cookie + encode(blockid, false) + ';';
    }
  }

  // Reset the cookie
  if (cookiename == '') {
    setCookie('www.nationaalbrandweermuseum.nl', cookie, 1000*60*60*24*365);
  } else {
    setCookie(cookiename, cookie, 1000*60*60*24*365);
  }

  top.open(window.location, '_self');
}

function showWindow(uniqueid,id,qs,width,height) {
  var windowObj;
  windowObj = eval('top.Info' + uniqueid);

  if (windowObj !=null && (windowObj + "" != "undefined") && !windowObj.closed) {
    windowObj.focus();
  } else {
    windowObj = null;
    windowObj = top.open('/cms/show/id=' + id + qs,'Info'+uniqueid,'toolbar=no,width=' + width + ',height=' + height + ',directories=no,status=no,scrollbars=yes,resizable=yes,menubar=no');
    top.name = 'wm';

    if (windowObj != null) {
      windowObj.focus();
    }     
  }
  reload = false;
}