<!-- Begin
/****************************************************************
*
*  Date: 10.01.2008
*  Auhtor: Christoph Stoidner
*
*  Modul: SnickJim.js
*
*  History:
*
*  x.yy   Auhtor    Date      Changes
*  -------------------------------------------------------------
   1.00   cs        10.01.08  create
*
*
******************************************************************/

//////////////////////////////////////////
// The dynamic size fitter implementation
//////////////////////////////////////////
var gNumOfDynSizeFitterObjects = 0;
gDynSizeFitterObjects = { };

  // Mouse position
  var posx = 0;
  var posy = 0;

  function initMouseTracker() {
    // Initialisierung of the mouse tracker to get the mouse position

    document.onmousemove = drag;
    document.onclick = click;
  }

  function drag(ereignis) {
    // will be called when the mouse was moved.

    posx = document.all ? window.event.clientX : ereignis.pageX;
    posy = document.all ? window.event.clientY : ereignis.pageY;
  }

  function click(ereignis) {
    // will be called when the mouse click was done.
    hideNewstickerContent();
  }

function hideNewstickerContent() {
    theNewtickerContentDiv = document.getElementById("newtickerContentDiv");
    if (!theNewtickerContentDiv) {
      theNewtickerContentDiv = parent.document.getElementById("newtickerContentDiv");
      if (!theNewtickerContentDiv) {
        alert("Sorry, newsticker content not found! Please contact webmaster@snickjim.de with this message. Thank you!");
        return;
      }
    }

    theNewtickerContentDiv.style.display = "none";
    
    // force refresh
    theNewtickerContentDiv.outerHTML = theNewtickerContentDiv.outerHTML;
}

function showNewstickerContent(content) {
    theNewtickerContentDiv = document.getElementById("newtickerContentDiv");
    if (!theNewtickerContentDiv) {
      alert("Sorry, newsticker content not found! Please contact webmaster@snickjim.de with this message. Thank you!");
      return;
    }

    if (theNewtickerContentDiv.style.display == ""
     /*&& document.getElementById("newstickerContentSpan").firstChild.nodeValue == content*/) {
       // this newsticker content is already visible, so do nothing.
       return;

    }

    // setup the newstickers content text
    document.getElementById("newstickerContentSpan").firstChild.nodeValue = content;

    // setup display position
    theNewtickerContentDiv.style.bottom = (getWindowSizeY() - posy) + "px"; // bottom start at the window-bottom while posy starts at the window top!
    theNewtickerContentDiv.style.left = posx + "px";

    // make theNewtickerContentDiv visible
    theNewtickerContentDiv.style.display = "";
    
    // force refresh
    theNewtickerContentDiv.outerHTML = theNewtickerContentDiv.outerHTML;
}

function getWindowSizeX () {
  var x,y;
  if (self.innerHeight) // all except Explorer
  {
    x = self.innerWidth;
	y = self.innerHeight;
  }
  else if (document.documentElement && document.documentElement.clientHeight)
  // Explorer 6 Strict Mode
  {
    x = document.documentElement.clientWidth;
    y = document.documentElement.clientHeight;
  }
  else if (document.body) // other Explorers
  {
    x = document.body.clientWidth;
	y = document.body.clientHeight;
  }

  return x;
}

function getWindowSizeY () {
  var x,y;
  if (self.innerHeight) // all except Explorer
  {
  	x = self.innerWidth;
	y = self.innerHeight;
  }
  else if (document.documentElement && document.documentElement.clientHeight)
  // Explorer 6 Strict Mode
  {
 	x = document.documentElement.clientWidth;
	y = document.documentElement.clientHeight;
  }
  else if (document.body) // other Explorers
  {
  	x = document.body.clientWidth;
	y = document.body.clientHeight;
  }

  return y;
}


function dynSizeFitterHandler() {
  // calculate window size
  sizeX = getWindowSizeX();
  sizeY = getWindowSizeY();

  // fit all objects from global fitter list
  for (i=0; i<gNumOfDynSizeFitterObjects; i++) {
    if (gDynSizeFitterObjects[i].obj2fit) {
      gDynSizeFitterObjects[i].fit(sizeX, sizeY);
    }
  }
}

function dynSizeFitterObject(obj2fit, minSizeX, minSizeY, maxSizeX, maxSizeY, percentX, percentY) {

  this.obj2fit  = obj2fit;
  this.minSizeX = minSizeX;
  this.minSizeY = minSizeY;
  this.maxSizeX = maxSizeX;
  this.maxSizeY = maxSizeY;
  this.percentX = percentX;
  this.percentY = percentY;
  this.id       = gNumOfDynSizeFitterObjects;

  gDynSizeFitterObjects[this.id] = this;

  gNumOfDynSizeFitterObjects++;
  return this;
}

dynSizeFitterObject.prototype.fit = function(sizeX, sizeY) {

  // fit X size
  newSizeX = (this.percentX * sizeX) / 100;
  if (newSizeX < this.minSizeX)
  {
    newSizeX = this.minSizeX;
  }
  else if (newSizeX > this.maxSizeX)
  {
    newSizeX = this.maxSizeX;
  }

  // fit Y size
  newSizeY = (this.percentY * sizeY) / 100;
  if (newSizeY < this.minSizeY)
  {
    newSizeY = this.minSizeY;
  }
  else if (newSizeY > this.maxSizeY)
  {
    newSizeY = this.maxSizeY;
  }

  // round the values
  newSizeX += 0.5;
  newSizeY += 0.5;

  // setup new object size
  document.getElementById(this.obj2fit).style.width  = newSizeX + 'px';
  document.getElementById(this.obj2fit).style.height = newSizeY + 'px';
}

// install OnResize handler
//window.onresize = dynSizeFitterHandler;


///////////////////////////////
// The scrollbar impementation
///////////////////////////////
var gNumOfScrollBars = 0;
allScrollBars = { };
function scrollBar(obj2scroll) {

  this.obj2scroll   = obj2scroll;
  this.timerId      = 0;
  this.speed        = 0;
  this.id           = gNumOfScrollBars;

  allScrollBars[this.id] = this;

  gNumOfScrollBars++;
  return this;
}

scrollBar.prototype.scroll = function(direction) {

  if (direction == 'up') {
    this.speed = -3;
  }
  else {
    this.speed = 3;
  }

  this.timerId = window.setTimeout('scrollTimer(' + this.id + ')', 10);
}

function scrollTimer(scrollBarId) {
  allScrollBars[scrollBarId].obj2scroll.scrollBy( 0, allScrollBars[scrollBarId].speed );
  allScrollBars[scrollBarId].timerId = window.setTimeout('scrollTimer(' + scrollBarId + ')', 10);
}

scrollBar.prototype.stop = function () {
  window.clearTimeout(this.timerId);
}

/*
function initScrollBars() {
//  contentFrameScrollBar = new scrollBar(contentFrame);
  contentFrameScrollBar = new scrollBar(mainContentDiv);
}
*/

// global references of all scrollbars
var contentFrameScrollBar = 0;
// End -->

