/*
* Copyright 2006 Ronny Engelmann
* This code is free; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation
* Contact Ronny Engelmann at ronny.engelmann [at] knoxmic [dot] net
*
* Description: vertikal and horizontal scrolling with javascript
*/

function scroll(objElement, intHeight, intWidth, posimg) {
  var self = this;
  //this._x = posimg;
  this._x = 0;
  this._y = 0;
  objElement.style.left = this._x +"px";
  objElement.style.top = this._y +"px";

  this.setPosition = function(strDirection, intPos, x) {
    if (intPos > 0) intPos = 0;
    switch (strDirection) {
      case 'x':
        if (intPos < intWidth - objElement.offsetWidth)
          intPos = intWidth - objElement.offsetWidth;
        this._x = intPos;
        objElement.style.left = this._x +"px";
        break;
      case 'y':
        if (intPos < intHeight - objElement.offsetHeight)
          intPos = intHeight - objElement.offsetHeight;
        this._y = intPos;
        objElement.style.top = this._y +"px";
        break;
    }
  };

  this.scrollX = function(x) { this.setPosition('x', this._x + x, x); };
  this.scrollY = function(y) { this.setPosition('y', this._y + y, y); };

  this.startX = function(x) {
	//alert(this._x+','+objElement.style.left+','+posimg);
    this.scrollTimer = window.setInterval(
      function() { self.scrollX(x); }, 1 );
  };

  this.startY = function(y) {
    this.scrollTimer = window.setInterval(
      function() { self.scrollY(y); }, 1 );
  };

  this.stop = function() {
    if (this.scrollTimer) window.clearInterval(this.scrollTimer); };
};

var srollObject = null;

function initPage() {
	var objElement = document.getElementById('boxinnerrightproject');
	var posimg = getCookie('posimg');
	if (posimg!=null && posimg!="") {
		posimg = posimg.replace(/px/, "");
	} else {
		posimg = 0;
	}
	//alert(posimg);
	srollObject = new scroll(objElement, 383, 768, posimg);
  
  //if (posimg!=null && posimg!="") {
	  //alert(document.getElementById('boxinnerrightproject').style.left+';'+posimg);
	  //document.getElementById('boxinnerrightproject').style.left = posimg+"px";
	  //posimg = posimg.replace(/px/, "");
	  //alert(posimg);
	  //srollObject.scrollX(posimg);
	  //srollObject._x = posimg;
	  //posimg = posimg.replace(/-/, "");
	  //objElement.style.left = posimg+"px";
  //}
}

