    var timeout	= 500;
    var closetimer	= 0;
    var ddmenuitem	= 0;
    
    // open hidden layer
    function mopen(id)
    {	
        // cancel close timer
        mcancelclosetime();
    
        // close old layer
        if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';
    
        // get new layer and show it
        ddmenuitem = document.getElementById(id);
        ddmenuitem.style.visibility = 'visible';
    
    }
    // close showed layer
    function mclose()
    {
        if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';
    }
    
    // go close timer
    function mclosetime()
    {
        closetimer = window.setTimeout(mclose, timeout);
    }
    
    function imgopen(id)
    {	
        var imgitem = document.getElementById(id);
        imgitem.style.visibility = 'visible';
    }
    // close showed layer
    function imgclose(id)
    {
        var imgitem = document.getElementById(id);
        imgitem.style.visibility = 'hidden';
    }
    
    // cancel close timer
    function mcancelclosetime()
    {
        if(closetimer)
        {
            window.clearTimeout(closetimer);
            closetimer = 0;
        }
    }
  
  // engage to init rotation etc.
  function engage(newimg, imgindex) {
      if (newimg != -1) {
          Rotate(newimg, 1);
      }
      if (imgindex > 0) {
          index = imgindex;
          showImages();
      }
  }
  
  // rotate an image...
  function Rotate(Nr, step) {
    if (step < 10) {
  		window.document.images[Nr].src = "ifc/knob_" + step + ".png";
  		window.setTimeout("Rotate("+Nr+","+(step+1)+")",50);
    }
    else {
  		window.document.images[Nr].src="ifc/knob_h.png";
    }
  }

  var index_base = 8;
  var index = 0;
  
  function nextImage(offset) {
    if (index + offset <= image_count) {
      index+=offset;
      showImages();
    }
    else {
      index-=offset;
    }
  } 
  function prevImage(offset) {
    if (index - offset >= 1) {
      index-=offset;
      showImages();
    }
  }
  function showImages() {
    if (index == 1) {
      // previous images
      window.document.images[index_base].src = "ifc/blank.png";
      window.document.images[index_base + 1].src = "ifc/blank.png";
      // actual image
      window.document.images[index_base + 2].src = image_base + "/" + image_base_name + "_small.jpg";
      // actual big image
      window.document.images[index_base + 5].src = image_base + "/" + image_base_name + ".jpg";
    }
    else if (index == 2) {
      // previous images
      window.document.images[index_base].src = "ifc/blank.png";
      window.document.images[index_base + 1].src = image_base + "/" + image_base_name + "_small.jpg";
      // actual image
      window.document.images[index_base + 2].src = image_base + "/" + image_base_name + "2_small.jpg";
      // actual big image
      window.document.images[index_base + 5].src = image_base + "/" + image_base_name + "2.jpg";
    }
    else if (index == 3) {
      // previous images
      window.document.images[index_base].src = image_base + "/" + image_base_name + "_small.jpg";
      window.document.images[index_base + 1].src = image_base + "/" + image_base_name + "2_small.jpg";
      // actual image
      window.document.images[index_base + 2].src = image_base + "/" + image_base_name + "3_small.jpg";
      // actual big image
      window.document.images[index_base + 5].src = image_base + "/" + image_base_name + "3.jpg";
    }
    else {
      // previous images
      window.document.images[index_base].src = image_base + "/" + image_base_name + (index-2) + "_small.jpg";
      window.document.images[index_base + 1].src = image_base + "/" + image_base_name + (index-1) + "_small.jpg";
      // actual image
      window.document.images[index_base + 2].src = image_base + "/" + image_base_name + index + "_small.jpg";
      // actual big image
      window.document.images[index_base + 5].src = image_base + "/" + image_base_name + (index) + ".jpg";
    }
    if (index == image_count) {
      // next images
      window.document.images[index_base + 3].src = "ifc/blank.png";
      window.document.images[index_base + 4].src = "ifc/blank.png";
    }
    else if (index == image_count - 1) {
      // next images
      window.document.images[index_base + 3].src = image_base + "/" + image_base_name + (image_count) + "_small.jpg";
      window.document.images[index_base + 4].src = "ifc/blank.png";
    }
    else {
      // next images
      window.document.images[index_base + 3].src = image_base + "/" + image_base_name + (index+1) + "_small.jpg";
      window.document.images[index_base + 4].src = image_base + "/" + image_base_name + (index+2) + "_small.jpg";
    }
    document.getElementsByTagName("h4")[0].firstChild.data = image_base_name + " " + index;
  }


