/* $Id: bob.js,v 1.1 2014/03/19 14:46:36 tessmann Exp $
 *
 * PROJEKT:      K3
 * KOMPONENTE:   Elektronische Betriebsanleitung On-board
 * AUFGABE:      Javascript Stylesheet
 * ERSTELLER:    DOSCO Document Systems Consulting GmbH
 *               Heidelberg, Tel. 06221-14860
 * ERSTELLDATUM: 01.2011
 * AUTOR:        Franz Fackelmann
 *
 * Copyright (C) 2011 DOSCO GmbH
 *
 */

// var softScroll = window.innerHeight < 480 ? false : true;
var softScroll = true;
var scrollSpeed = 1500;

// offset to top position
var posTop = 0;

/* Scroll to absolute position */
function scroll_to_xy(x, y)
{
  if (softScroll) {
    new Fx.Scroll(window).start(x, y);
  }
  else {
    window.scrollTo(x, y);
  }
  return true;
}


/* scroll to id in given URL */
function scroll_to(url, offset, set) 
{
  var hash = url.lastIndexOf("#");
  var id;
  if (hash != -1) id = url.substring(hash + 1);
  else id = url;
  if (id && id.length > 0) {
    var block = document.getElementById(id);
    if (block) {
      var winScroller;
      if (set) {
        winScroller = new Fx.Scroll(window, {duration: scrollSpeed});
      }
      else {
        winScroller = new Fx.Scroll(window);
      }
      if (offset != 0) {
        winScroller.start(0, (block.offsetTop - lastYOffset)).chain(function (){block.focus()});
      }
      else {
        winScroller.toElement(id).chain(function (){block.focus()});
      }
    }
  }
  return true;
}
