var currentWidth = 0;

function updateLayout()
{
    if (window.innerWidth != currentWidth)
    {
        currentWidth = window.innerWidth;

        var orient = currentWidth == 320 ? "profile" : "landscape";
        document.body.setAttribute("orient", orient);
        setTimeout(function()
        {
            window.scrollTo(0, 1);
        }, 100);
    }
}

/**
 * Initialisierung nach dem Laden des Inhaltes.
 */
addEventListener("load", function()
{
    setTimeout(updateLayout, 0);
}, false);

/**
 * Optimierung wärend des Betriebes.
 */
//setInterval(updateLayout, 1000);



var touchPositionX;
var touchPositionY;

var touched = false;

function TouchStart(e)
{
  touchPositionX = e.touches[0].pageX;
  touchPositionY = e.touches[0].pageY;
  touched = false;
}

function TouchMove(e)
{
  if (touched) return;

  if ((e.touches[0].pageX + 25) < touchPositionX)
  {
    touched = true;
    ScrollAPI.next();
  }
  else if ((e.touches[0].pageX - 25) > touchPositionX)
  {
    touched = true;
    ScrollAPI.prev();
  }
}
