//
// js code for hotel pod piorem
// by sylvester keil, december 2004
// 

var num_items = 8;
var section_limit = 11;
var pictures = 'pic/';
var photos = 'pic/photos/';
var active_photo = 1;
var scroll_object = null;
var scroll_start = 0;
var scroll_stop = 0;
var scroll_step = 0;
var timeout = null;

var content_left = 235;
var content_width = 314;

var ctop = 0;
var cstep = 0;
var cheight = 0;
var dheight = 0;

var main, more, less, album, content, scrollable, up, down = null;

function go(path, sound) {
  if(parent.frames.length!=0) {
    parent.sound.location.href = (sound == 'on') ? 'sound.html' : 'nosound.html';
  }
  window.location.href = path;
}

function obj(id) {
  if (document.getElementById) {
    this.obj = document.getElementById(id);
    this.style = document.getElementById(id).style;
  }
  else if (document.all) {
    this.obj = document.all[id];
    this.style = document.all[id].style;
  }
}

function swap(id, pic) {
  var image = new obj(id);
  if (image != null) {
    image.obj.src = pictures + pic;
  }
}

function pswap(id, pic) {
  var image = new obj(id);
  if (image != null) {
    image.obj.src = photos + pic;
  }
}

function photo_swap(name, i) {
  pswap('photo', name + '-' + i + '.jpg');
  pswap('th' + active_photo, name + '-' + active_photo + '-th.jpg');
  pswap('th' + i, name + '-' + i + '-th-a.jpg');
  active_photo = i;
}

function photo_over(i,name) {
  if (active_photo != i) {
    pswap('th'+i, name + '-' + i + '-th-a.jpg');
  }
}

function photo_out(i,name) {
  if (active_photo != i) {
    pswap('th'+i, name + '-' + i + '-th.jpg');
  }
}

function photo_up() {
  less.style.visibility = 'hidden';
  more.style.visibility = 'visible';
  scroll_object = album;
  scroll_start = -250;
  scroll_stop = 0;
  scroll_step = 10;
  scroll();
}

function photo_down() {
  less.style.visibility = 'visible';
  more.style.visibility = 'hidden';
  scroll_object = album;
  scroll_start = 0;
  scroll_stop = -250;
  scroll_step = 10;
  scroll();
}

function scroll() {
  if (scroll_object == null || scroll_start == scroll_stop) {
    if (timeout != null) { timeout = null; }
    return;
  }
  else {
    scroll_start = (scroll_start < scroll_stop) ? scroll_start + scroll_step : scroll_start - scroll_step;
    scroll_object.style.top = scroll_start + 'px';
    timeout = window.setTimeout('scroll();',10);
  }
}

function stop_scroll() {
  if (timeout != null) { clearTimeout(timeout); timeout = null; }
}

function content_up() {
  if (scrollable == null) {
    return;
  }
  cstep = 2;
  cscroll();
}

function content_down() {
  if (scrollable == null) {
    return;
  }
  cstep = -2;
  cscroll();
}

function cscroll() {
  ctop += cstep;
  if (ctop < 0 && ctop > cheight - dheight) {
    scrollable.style.top = ctop + 'px';
    timeout = window.setTimeout('cscroll()',10);
  }
}

function preload(lang) {
  for (var i = 1; i <= section_limit; i++) {
    var img = new Image();
    img.src = pictures + 'menu_' + lang + '_' + i + '-a.gif';
  }
}

function init(lang, section, photo_name, num_photos) {

  if (section < 0 || section > section_limit) section = 0;

  if (lang != 'select') {
    preload(lang);
    var items = new Array(section_limit);
    for (var i = 1; i <= num_items; i++) {
      items[i] = new obj('i'+i);
      if (i != section) {
        items[i].obj.onmouseover = new Function ("swap('i"+i+"', 'menu_"+lang+"_"+i+"-a.gif')");
        items[i].obj.onmouseout = new Function ("swap('i"+i+"', 'menu_"+lang+"_"+i+".gif')");
      }
    }
    if (section == 3) {
      for (var i = num_items+1; i <= section_limit; i++) {
        items[i] = new obj('i'+i);
        items[i].obj.onmouseover = new Function ("swap('i"+i+"', 'menu_"+lang+"_"+i+"-a.gif')");
        items[i].obj.onmouseout = new Function ("swap('i"+i+"', 'menu_"+lang+"_"+i+".gif')");
      }
    }
    else {
      for (var i = num_items+1; i <= section_limit; i++) {
        items[i] = null;
      }
    }

    if (num_photos > 0) {
      var photos = new Array(num_photos);
      for (var j = 1; j <= num_photos; j++) {
        photos[j] = new obj('th'+j);
        photos[j].obj.onclick = new Function('photo_swap("'+photo_name+'",'+j+')');
        photos[j].obj.onmouseover = new Function('photo_over("'+j+'", "'+photo_name+'")');
        photos[j].obj.onmouseout = new Function('photo_out("'+j+'", "'+photo_name+'")');
      }
      if (num_photos > 10) {
        more = new obj('more');
        less = new obj('less');
        album = new obj('album');
        more.obj.onclick = new Function('photo_down()');
        less.obj.onclick = new Function('photo_up()');
      }
    }

    content = new obj('content' + section);
    scrollable = new obj('scrollable');

    dheight = scrollable.obj.offsetHeight;
    dheight += 4;
    cheight = content.obj.offsetHeight;

    up = new obj('up' + section);
    down = new obj('down' + section);

    if (dheight < cheight) {
      up.style.visibility = 'hidden';
      down.style.visibility = 'hidden';
    }
    else {
      up.obj.onmouseover = new Function('swap("up'+section+'","pfeil1a.gif")');
      up.obj.onmouseout = new Function('swap("up'+section+'","pfeil1.gif")');
      up.obj.onmousedown = new Function('content_up()');
      up.obj.onmouseup = new Function('stop_scroll()');
      down.obj.onmouseover = new Function('swap("down'+section+'","pfeil2a.gif")');
      down.obj.onmouseout = new Function('swap("down'+section+'","pfeil2.gif")');
      down.obj.onmousedown = new Function('content_down()');
      down.obj.onmouseup = new Function('stop_scroll()');
    }
  }
}

