﻿///////////////////////////////////////////////////////////////////////////////
//
//  wcoPositioningLibrary.js
// 
// © 2007-2008 Wco iEnterprise Solutions. All Rights Reserved.
// This file is licensed as part of the DataPortal 2.0 Managed Web Presence Solution, for details look here: http://www.wco.com.au
//
///////////////////////////////////////////////////////////////////////////////

var positioning = {
  _sliderTarget: null,
  _sliderTargetWidth: -1000,
  _sliderStartX: 0,
  _sliderStartY: 0,
  _sliderEndX: 0,
  _sliderEndY: 0,
  _sliderStartH: 0,
  _sliderEndH: 0,
  _sliderDirection: -1,
  _sliderDistanceToTravel: 0,
  _sliderCurrentDistanceTravelled: 0,
  _sliderSnapFactor: 0.1,
  _sliderTimerId: null,
  _sliderTimerInterval: 0.5,
  _sliderTimerMoveOffset: 0,
  _sliderTimerFactor: 0.15,
  _sliderCallback: null,
  
  _sliderQueue: {
    id: null,
    x: 0,
    y: 0,
    speed: 'normal',
    w: 0,
    callback: null
  },
  
  _slider2Target: null,
  _slider2TargetWidth: -1000,
  _slider2StartX: 0,
  _slider2StartY: 0,
  _slider2EndX: 0,
  _slider2EndY: 0,
  _slider2StartH: 0,
  _slider2EndH: 0,
  _slider2Direction: -1,
  _slider2DistanceToTravel: 0,
  _slider2CurrentDistanceTravelled: 0,
  _slider2SnapFactor: 0.1,
  _slider2TimerId: null,
  _slider2TimerInterval: 0.5,
  _slider2TimerMoveOffset: 0,
  _slider2TimerFactor: 0.15,
  _slider2Callback: null,
  
  _slider2Queue: {
    id: null,
    x: 0,
    y: 0,
    speed: 'normal',
    w: 0,
    callback: null
  },
  
  _faderTarget: null,
  _faderDirection: 1,
  _faderDifferential: 2,
  _faderTimerId: null,
  _faderTimerInterval: 0.5,
  _faderAlpha: 0,
  _faderCallback: null,

  _fader2Target: null,
  _fader2Direction: 1,
  _fader2Differential: 2,
  _fader2TimerId: null,
  _fader2TimerInterval: 0.5,
  _fader2Alpha: 0,
  _fader2Callback: null

};

positioning.createDelegate = function(instance, method) {
  return function() {
    return method.apply(instance, arguments);
  }
}

positioning.getBrowserLanguage = function() {
  var language = 'en-AU';
    if (navigator) {
      if (navigator.userLanguage) {
        language = navigator.userLanguage;
      }
      else {
        if (navigator.language) {
          language = navigator.language;
        }
      }
    }
  
  return (language);
}

positioning.getObject = function(id) {
  if (typeof id == 'string') {
    if (document.getElementById) {
      return(document.getElementById(id));
    }
    else if (document.all) {
      return(document.all[id]);
    }
    else if (document.layers) {
      return(document.layers[id]);
    }
    else {
      return(null);
    }
  }
  else {
    return(id);
  }
}

positioning.showObject = function(id) {
  var thisObject = this.getObject(id);
  
  if (thisObject != null) {
    thisObject.style.display = 'block';
  }
}

positioning.hideObject = function(id) {
  var thisObject = this.getObject(id);
  
  if (thisObject != null) {
    thisObject.style.display = 'none';
  }
}

positioning.isObjectHidden = function(id) {
  var thisObject = this.getObject(id);
  
  if (thisObject.currentStyle != null) {
    return (thisObject.currentStyle.display == 'none');
  }
  else {
    return (thisObject.style.display == 'none');
  }
}

// position the specified object in the center of the current window viewport width
positioning.centerObjectInViewport = function(id) {
  var thisObject = this.getObject(id);
  if (thisObject != null) {
    var centerX = windowGeometry.getViewportWidth() / 2;
    var offsetX = this.getObjectWidth(thisObject) / 2;
    this.shiftObjectTo(thisObject, (centerX - offsetX), this.getObjectTop(thisObject));
  }
}

// retrieve the pixel width of the specified object
positioning.getObjectHeight = function(id) {
  var thisObject = this.getObject(id);
  var result = 0;
  
  if (thisObject != null) {
    if (thisObject.offsetHeight) {
      result = thisObject.offsetHeight;
    }
    else if (thisObject.clip && thisObject.clip.height) {
      result = thisObject.clip.height;
    }
    else if (thisObject.style && thisObject.style.height) {
      result = thisObject.style.height;
    }
  }
  
  return parseInt(result, 10);
}

// set the pixel width of the specified object
positioning.setObjectHeight = function(id, h) {
  var thisObject = this.getObject(id);
  
  if (thisObject != null && h >= 0) {
    thisObject.style.height = h + 'px';;
  }
}

// retrieve the pixel width of the specified object
positioning.getObjectWidth = function(id) {
  var thisObject = this.getObject(id);
  var result = 0;
  
//  result = thisObject.runtimeStyle.width;
//  return parseInt(result, 10);
  
  if (thisObject != null) {
    if (thisObject.offsetWidth) {
      result = thisObject.offsetWidth;
    }
    else if (thisObject.clip && thisObject.clip.width) {
      result = thisObject.clip.width;
    }
    else if (thisObject.style && thisObject.style.width) {
      result = thisObject.style.width;
    }
  }
  
  return parseInt(result, 10);
}

// set the pixel width of the specified object
positioning.setObjectWidth = function(id, w) {
  var thisObject = this.getObject(id);
  
  if (thisObject != null && w >= 0) {
    thisObject.style.width = w + 'px';;
  }
}

// retrieve the pixel top co-ordinate of the specified object
positioning.getObjectTop = function(id) {
  var thisObject = this.getObject(id);
  var result = 0;
  
  if (thisObject != null) {
    if (thisObject.offsetTop) {
      result = thisObject.offsetTop;
    }
    else if (thisObject.style && thisObject.style.top) {
      result = thisObject.style.top;
    }
  }
  
  return parseInt(result, 10);
}

// set the pixel top co-ordinate of the specified object
positioning.setObjectTop = function(id, y) {
  var thisObject = this.getObject(id);
  
  if (thisObject != null) {
    if (thisObject.style && thisObject.style.top) {
      thisObject.style.top = y + 'px';
    }
  }
}

// retrieve the pixel left co-ordinate of the specified object
positioning.getObjectLeft = function(id) {
  var thisObject = this.getObject(id);
  var result = 0;
  
  if (thisObject != null) {
    if (thisObject.offsetLeft) {
      result = thisObject.offsetLeft;
    }
    else if (thisObject.style && thisObject.style.left) {
      result = thisObject.style.left;
    }
  }
  
  return parseInt(result, 10);
}

// set the pixel left co-ordinate of the specified object
positioning.setObjectLeft = function(id, x) {
  var thisObject = this.getObject(id);
  
  if (thisObject != null) {
    thisObject.style.left = x + 'px';
  }
}

// position the object at the specified pixel X,Y co-ordinate
positioning.shiftObjectTo = function(id, x, y) {
  var thisObject = this.getObject(id);
  
  if (thisObject != null) {
    thisObject.style.left = x + 'px';
    thisObject.style.top = y + 'px';
  }
}

positioning.scrollObjectToTop = function(id) {
  var thisObject = this.getObject(id);
  
  if (thisObject != null) {
    thisObject.scrollTop = 0;
  }
}

// position the specified object ranged flush against the right and top edges of the current window viewport
positioning.rangeObjectRight = function(id) {
  var xOffset = 0;
  var yOffset = 0;
  var thisObject = this.getObject(id);
  if (arguments[1]) {xOffset = arguments[1];}
  if (arguments[2]) {yOffset = arguments[2];}
  var x = windowGeometry.getViewportWidth() - this.getObjectWidth(thisObject);
  var y = this.getObjectTop(thisObject) - yOffset;
  this.shiftObjectTo(thisObject, x + xOffset, y + yOffset);
}

// position the specified object ranged flush against the right and top edges of the current window viewport
positioning.rangeObjectRight2 = function(id) {
  var xOffset = 0;
  var yOffset = 0;
  var thisObject = this.getObject(id);
  if (arguments[1]) {xOffset = arguments[1];}
  if (arguments[2]) {yOffset = arguments[2];}
  var x = windowGeometry.getViewportWidth() - this.getObjectWidth(thisObject);
  var y = this.getObjectTop(thisObject) - yOffset;
//  if (thisObject.id == 'sectionContent') {
//    alert('thisObject = ' + thisObject.id + '\nwindowGeometry.getViewportWidth() = ' + windowGeometry.getViewportWidth() + '\nthis.getObjectWidth(thisObject) = ' + this.getObjectWidth(thisObject) + '\nx = ' + x + '\nxOffset = ' + xOffset + '\nx + xOffset = ' + (x + xOffset));
//  }
  this.shiftObjectTo(thisObject, x + xOffset, y + yOffset);
}

positioning.fadeOut = function(id, speed, callback) {
  // first, check is a previous fade-out is already in progress
  if (positioning._faderTarget != null) {
    // stop the existing fade-out, and reset the fade properties
    window.clearTimeout(positioning._faderTimerId);
    positioning.hideObject(positioning._faderTarget);
    positioning._faderTarget = null;
    positioning._faderDirection = 1;
    positioning._faderTimerId = null;
    positioning._faderAlpha = 0;
  }
  
  positioning._faderTarget = this.getObject(id);
  positioning._faderDirection = -1;
  positioning._faderDifferential = 5;
  if (speed != null) {
    if (speed == 'slow') {
      positioning._faderDifferential = 2;
    }
    else if (speed == 'fast') {
      positioning._faderDifferential = 20;
    }
    else {
      positioning._faderDifferential = 10;
    }
  }
  positioning._faderAlpha = 100 - positioning._faderDifferential;
  
  positioning._faderCallback = null;
  if (callback != null) {
    positioning._faderCallback = callback;
  }
  
  if (positioning._faderTarget.filters != undefined) {
    positioning._faderTarget.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=100)';
    positioning._faderTarget.style.display = 'block';
    positioning._faderTimerId = window.setTimeout(positioning._fade, positioning._faderTimerInterval);
  }
  else {
    positioning.hideObject(positioning._faderTarget);
    if (positioning._faderCallback != null) {
      positioning._faderCallback();
    }
  }
  
}

positioning.fadeIn = function(id, speed, callback) {
  // first, check is a previous fade-in is already in progress
  if (positioning._faderTarget != null) {
    // stop the existing fade-in, and reset the fade properties
    window.clearTimeout(positioning._faderTimerId);
    positioning.hideObject(positioning._faderTarget);
    positioning._faderTarget = null;
    positioning._faderDirection = 1;
    positioning._faderTimerId = null;
    positioning._faderAlpha = 0;
  }
  
  positioning._faderTarget = this.getObject(id);
  positioning._faderDirection = 1;
  positioning._faderDifferential = 5;
  if (speed != null) {
    if (speed == 'slow') {
      positioning._faderDifferential = 2;
    }
    else {
      positioning._faderDifferential = 10;
    }
  }
  positioning._faderAlpha = positioning._faderDifferential;
  
  positioning._faderCallback = null;
  if (callback != null) {
    positioning._faderCallback = callback;
  }
  
  if (positioning._faderTarget.filters != null) {
    positioning._faderTarget.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=0)';
    positioning._faderTarget.style.display = 'block';
    positioning._faderTimerId = window.setTimeout(positioning._fade, positioning._faderTimerInterval);
  }
  else {
    positioning.showObject(positioning._faderTarget);
    if (positioning._faderCallback != null) {positioning._faderCallback();};
  }
  
}

positioning.fadeStop = function() {
  if (positioning._faderTimerId != null) {
    // stop the fade
    window.clearTimeout(positioning._faderTimerId);
    if (positioning._faderDirection == -1) {
      positioning.hideObject(positioning._faderTarget);
    }
    positioning._faderTimerId = null;
    positioning._faderTarget = null;
    positioning._faderDirection = 1;
    positioning._faderAlpha = 0;
  }
}

positioning._fade = function() {
  // determine the end alpha value
  var endAlpha = 100;
  if (positioning._faderDirection == -1) {
    endAlpha = 0;
  }
  
  positioning._faderTarget.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=' + positioning._faderAlpha + ')';
  
  if (positioning._faderAlpha == endAlpha) {
    window.clearTimeout(positioning._faderTimerId);
    if (positioning._faderDirection == -1) {
      positioning.hideObject(positioning._faderTarget);
    }
    // stop the fade
    positioning._faderTarget = null;
    positioning._faderDirection = 1;
    positioning._faderTimerId = null;
    positioning._faderAlpha = 0;
    
    // if the calling client passed a pointer to a callback function, then
    // call that function now
    if (positioning._faderCallback != null) {
      positioning._faderCallback();
    }
    
  }
  else {
    // continue to fade
    if (positioning._faderDirection == -1) {
      positioning._faderAlpha = positioning._faderAlpha - positioning._faderDifferential;
    }
    else {
      positioning._faderAlpha += positioning._faderDifferential;
    }
    
    positioning._faderTimerId = window.setTimeout(positioning._fade, positioning._faderTimerInterval);
  }
}

positioning.fadeOut2 = function(id, speed, callback) {
  // first, check is a previous fade-out is already in progress
  if (positioning._fader2Target != null) {
    // stop the existing fade-out, and reset the fade properties
    window.clearTimeout(positioning._fader2TimerId);
    positioning.hideObject(positioning._fader2Target);
    positioning._fader2Target = null;
    positioning._fader2Direction = 1;
    positioning._fader2TimerId = null;
    positioning._fader2Alpha = 0;
  }
  
  positioning._fader2Target = this.getObject(id);
  positioning._fader2Direction = -1;
  positioning._fader2Differential = 5;
  if (speed != null) {
    if (speed == 'slow') {
      positioning._fader2Differential = 2;
    }
    else if (speed == 'fast') {
      positioning._faderDifferential = 200;
    }
    else {
      positioning._fader2Differential = 10;
    }
  }
  positioning._fader2Alpha = 100 - positioning._fader2Differential;
  
  positioning._fader2Callback = null;
  if (callback != null) {
    positioning._fader2Callback = callback;
  }
  
  if (positioning._fader2Target.filters != null) {
    positioning._fader2Target.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=100)';
    positioning._fader2Target.style.display = 'block';
    positioning._fader2TimerId = window.setTimeout(positioning._fade2, positioning._fader2TimerInterval);
  }
  else {
    positioning.hideObject(positioning._fader2Target);
    if (positioning._fader2Callback != null) {positioning._fader2Callback();};
  }
  
}

positioning.fadeIn2 = function(id, speed, callback) {
  // first, check is a previous fade-in is already in progress
  if (positioning._fader2Target != null) {
    // stop the existing fade-in, and reset the fade properties
    window.clearTimeout(positioning._fader2TimerId);
    positioning.hideObject(positioning._fader2Target);
    positioning._fader2Target = null;
    positioning._fader2Direction = 1;
    positioning._fader2TimerId = null;
    positioning._fader2Alpha = 0;
  }
  
  positioning._fader2Target = this.getObject(id);
  positioning._fader2Direction = 1;
  positioning._fader2Differential = 5;
  if (speed != null) {
    if (speed == 'slow') {
      positioning._fader2Differential = 2;
    }
    else {
      positioning._fader2Differential = 10;
    }
  }
  positioning._fader2Alpha = positioning._fader2Differential;
  
  positioning._fader2Callback = null;
  if (callback != null) {
    positioning._fader2Callback = callback;
  }
  
  if (positioning._fader2Target.filters != null) {
    //positioning.showObject(positioning._fader2Target);
    positioning._fader2Target.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=0)';
    positioning._fader2Target.style.display = 'block';
    positioning._fader2TimerId = window.setTimeout(positioning._fade2, positioning._fader2TimerInterval);
  }
  else {
    positioning.showObject(positioning._fader2Target);
    if (positioning._fader2Callback != null) {positioning._fader2Callback();};
  }
  
}

positioning.fade2Stop = function() {
  if (positioning._fader2TimerId != null) {
    // stop the fade
    window.clearTimeout(positioning._fader2TimerId);
    if (positioning._fader2Direction == -1) {
      positioning.hideObject(positioning._fader2Target);
    }
    positioning._fader2TimerId = null;
    positioning._fader2Target = null;
    positioning._fader2Direction = 1;
    positioning._fader2Alpha = 0;
  }
}

positioning._fade2 = function() {
  // determine the end alpha value
  var endAlpha = 100;
  if (positioning._fader2Direction == -1) {
    endAlpha = 0;
  }
  
  positioning._fader2Target.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=' + positioning._fader2Alpha + ')';
  
  if (positioning._fader2Alpha == endAlpha) {
    window.clearTimeout(positioning._fader2TimerId);
    if (positioning._fader2Direction == -1) {
      positioning.hideObject(positioning._fader2Target);
    }
    // stop the fade
    positioning._fader2Target = null;
    positioning._fader2Direction = 1;
    positioning._fader2TimerId = null;
    positioning._fader2Alpha = 0;
    
    // if the calling client passed a pointer to a callback function, then
    // call that function now
    if (positioning._fader2Callback != null) {positioning._fader2Callback();};
    
  }
  else {
    // continue to fade
    if (positioning._fader2Direction == -1) {
      positioning._fader2Alpha = positioning._fader2Alpha - positioning._fader2Differential;
    }
    else {
      positioning._fader2Alpha += positioning._fader2Differential;
    }
    
    positioning._fader2TimerId = window.setTimeout(positioning._fade2, positioning._fader2TimerInterval);
  }
}

positioning.slideObjectUp = function(id, toY) {
  // retrieve a poiner to the target object of the slide animation
  positioning._sliderTarget = positioning.getObject(id);
  
  // configure the 'snap' factor applied to the slide motion
  if (arguments[2] != null) {
    if (arguments[2] == 'fast') {positioning._sliderSnapFactor = 0.5;}
    else if (arguments[2] == 'slow') {positioning._sliderSnapFactor = 0.0005;}
    else if (arguments[2] == 'very slow') {positioning._sliderSnapFactor = 0.000005;}
  }
  else {
    positioning._sliderSnapFactor = 0.1;
  }
  
  // configure the callback function, if supplied
  positioning._sliderCallback = null;
  if (arguments[3] != null) {
    positioning._sliderCallback = arguments[3];
  }
  
  if (positioning._sliderTarget != null) {
    positioning._sliderStartX = positioning.getObjectLeft(positioning._sliderTarget);
    positioning._sliderEndX = positioning.getObjectLeft(positioning._sliderTarget);
    positioning._sliderStartY = positioning.getObjectTop(positioning._sliderTarget);
    positioning._sliderEndY = toY;
    positioning._sliderDistanceToTravel = Math.abs(positioning._sliderStartY - positioning._sliderEndY);
    positioning._sliderDirection = -1;
    
    positioning._sliderTimerId = window.setTimeout(positioning._slide, positioning._sliderTimerInterval);
  }
}

positioning.slideObjectDown = function(id, toY) {
  // retrieve a pointer to the target object of the slide animation
  positioning._sliderTarget = positioning.getObject(id);
  // ensure that the target object is visible
  positioning.showObject(positioning._sliderTarget);
  
  // configure the 'snap' factor applied to the slide motion
  if (arguments[2] != null) {
    if (arguments[2] == 'fast') {positioning._sliderSnapFactor = 0.5;}
    else if (arguments[2] == 'slow') {positioning._sliderSnapFactor = 0.0005;}
    else if (arguments[2] == 'very slow') {positioning._sliderTimerInterval = 15; positioning._sliderSnapFactor = 0;}
  }
  else {
    positioning._sliderSnapFactor = 0.1;
  }
  
  // configure the callback function, if supplied
  positioning._sliderCallback = null;
  if (arguments[3] != null) {
    positioning._sliderCallback = arguments[3];
  }
  
  if (positioning._sliderTarget != null) {
    positioning._sliderStartX = positioning.getObjectLeft(positioning._sliderTarget);
    positioning._sliderEndX = positioning.getObjectLeft(positioning._sliderTarget);
    positioning._sliderStartY = positioning.getObjectTop(positioning._sliderTarget);
    positioning._sliderEndY = toY;
    positioning._sliderDistanceToTravel = Math.abs(positioning._sliderStartY - positioning._sliderEndY);
    positioning._sliderDirection = 1;
    
    positioning._sliderTimerId = window.setTimeout(positioning._slide, positioning._sliderTimerInterval);
  }
}

positioning.slideObjectRight = function(id, toX) {
  // retrieve a pointer to the target object of the slide animation
  positioning._sliderTarget = positioning.getObject(id);
  // ensure that the target object is visible
  positioning.showObject(positioning._sliderTarget);
  
  // configure the 'snap' factor applied to the slide motion
  if (arguments[2] != null) {
    if (arguments[2] == 'fast') {positioning._sliderSnapFactor = 0.5;}
    else if (arguments[2] == 'slow') {positioning._sliderSnapFactor = 0.0005;}
    else if (arguments[2] == 'very slow') {positioning._sliderTimerInterval = 15; positioning._sliderSnapFactor = 0;}
  }
  else {
    positioning._sliderSnapFactor = 0.1;
  }
  
  // configure the callback function, if supplied
  positioning._sliderCallback = null;
  if (arguments[3] != null) {
    positioning._sliderCallback = arguments[3];
  }
  
  if (positioning._sliderTarget != null) {
    positioning._sliderStartX = positioning.getObjectLeft(positioning._sliderTarget);
    positioning._sliderEndX = toX;
    positioning._sliderStartY = positioning.getObjectTop(positioning._sliderTarget);
    positioning._sliderEndY = positioning.getObjectTop(positioning._sliderTarget);
    positioning._sliderDistanceToTravel = Math.abs(positioning._sliderStartX - positioning._sliderEndX);
    positioning._sliderDirection = 1;
    
    positioning._sliderTimerId = window.setTimeout(positioning._slide, positioning._sliderTimerInterval);
    
  }
}

positioning.slideObjectLeft = function(id, toX) {
  // retrieve a pointer to the target object of the slide animation
  positioning._sliderTarget = positioning.getObject(id);
  // ensure that the target object is visible
  positioning.showObject(positioning._sliderTarget);
  
  // configure the 'snap' factor applied to the slide motion
  if (arguments[2] != null) {
    if (arguments[2] == 'fast') {positioning._sliderSnapFactor = 0.5;}
    else if (arguments[2] == 'slow') {positioning._sliderSnapFactor = 0.0005;}
    else if (arguments[2] == 'very slow') {positioning._sliderTimerInterval = 15; positioning._sliderSnapFactor = 0;}
  }
  else {
    positioning._sliderSnapFactor = 0.1;
  }
  
  // configure the callback function, if supplied
  positioning._sliderCallback = null;
  if (arguments[3] != null) {
    positioning._sliderCallback = arguments[3];
  }
  
  if (positioning._sliderTarget != null) {
    positioning._sliderStartX = positioning.getObjectLeft(positioning._sliderTarget);
    positioning._sliderEndX = toX;
    positioning._sliderStartY = positioning.getObjectTop(positioning._sliderTarget);
    positioning._sliderEndY = positioning.getObjectTop(positioning._sliderTarget);
    positioning._sliderDistanceToTravel = Math.abs(positioning._sliderStartX - positioning._sliderEndX);
    positioning._sliderDirection = -1;
    
    positioning._sliderTimerId = window.setTimeout(positioning._slide, positioning._sliderTimerInterval);
    
  }
}

positioning.slideObjectStop = function() {
  if (positioning._sliderTimerId != null) {
    window.clearTimeout(positioning._sliderTimerId);
    positioning._sliderTimerId = null;
    positioning._sliderTimerInterval = 0.5;
    positioning._sliderTimerMoveOffset = 0;
    positioning._sliderTimerFactor = 0.15;

    positioning._sliderTarget = null;
    positioning._sliderTargetWidth = -1000;
    positioning._sliderEndX = 0;
    positioning._sliderEndY = 0;
    positioning._sliderDirection = -1;
    positioning._sliderDistanceToTravel = 0;
    positioning._sliderCurrentDistanceTravelled = 0;
    positioning._sliderSnapFactor = 0.1;
  }
}

positioning._slide = function() {
  // determine whether the current slide is vertical or horizontal
  var slidePlane = 'horizontal';
  if (positioning._sliderStartX == positioning._sliderEndX)
    slidePlane = 'vertical';
  
  // increment the slider action variables
  positioning._sliderTimerMoveOffset += 1;
  positioning._sliderTimerFactor += positioning._sliderSnapFactor;
  
  // determine the next tween position in the slide animation
  var offset = (positioning._sliderTimerFactor * positioning._sliderTimerMoveOffset) * positioning._sliderDirection;
  var x = positioning.getObjectLeft(positioning._sliderTarget);
  var y = positioning.getObjectTop(positioning._sliderTarget);
  if (slidePlane == 'vertical')
    y += offset;
  else
    x += offset;

  positioning.shiftObjectTo(positioning._sliderTarget, x, y);
  positioning._sliderCurrentDistanceTravelled = (slidePlane == 'vertical') ? Math.abs(y - positioning._sliderStartY) : Math.abs(x - positioning._sliderStartX);

  if (positioning._sliderCurrentDistanceTravelled >= positioning._sliderDistanceToTravel) {
    // first, stop the timer
    window.clearTimeout(positioning._sliderTimerId);
    
    // and then position the object at its final coordinates
    positioning.shiftObjectTo(positioning._sliderTarget, positioning._sliderEndX, positioning._sliderEndY);
    
    // and, finally, reset the slide state properties
    positioning._sliderTarget = null;
    positioning._sliderTargetWidth = -1000;
    positioning._sliderEndX = 0;
    positioning._sliderEndY = 0;
    positioning._sliderDirection = -1;
    positioning._sliderDistanceToTravel = 0;
    positioning._sliderCurrentDistanceTravelled = 0;
    positioning._sliderSnapFactor = 0.1;
    
    positioning._sliderTimerId = null;
    positioning._sliderTimerInterval = 0.5;
    positioning._sliderTimerMoveOffset = 0;
    positioning._sliderTimerFactor = 0.15;
    
    // if the calling client passed a pointer to a callback function, then
    // call that function now
    if (positioning._sliderCallback != null) {positioning._sliderCallback();};
  }
  else {
    positioning._sliderTimerId = window.setTimeout(positioning._slide, positioning._sliderTimerInterval);
  }

}

positioning.slide2ObjectUp = function(id, toY) {
  // retrieve a poiner to the target object of the slide animation
  positioning._slider2Target = positioning.getObject(id);
  
  // configure the 'snap' factor applied to the slide motion
  if (arguments[2] != null) {
    if (arguments[2] == 'fast') {positioning._slider2SnapFactor = 0.5;}
    else if (arguments[2] == 'slow') {positioning._slider2SnapFactor = 0.0005;}
    else if (arguments[2] == 'very slow') {positioning._slider2SnapFactor = 0.000005;}
  }
  else {
    positioning._slider2SnapFactor = 0.1;
  }
  
  // configure the callback function, if supplied
  positioning._slider2Callback = null;
  if (arguments[3] != null) {
    positioning._slider2Callback = arguments[3];
  }
  
  if (positioning._slider2Target != null) {
    positioning._slider2StartX = positioning.getObjectLeft(positioning._slider2Target);
    positioning._slider2EndX = positioning.getObjectLeft(positioning._slider2Target);
    positioning._slider2StartY = positioning.getObjectTop(positioning._slider2Target);
    positioning._slider2EndY = toY;
    positioning._slider2DistanceToTravel = Math.abs(positioning._slider2StartY - positioning._slider2EndY);
    positioning._slider2Direction = -1;
    
    positioning._slider2TimerId = window.setTimeout(positioning._slide2, positioning._slider2TimerInterval);
  }
}

positioning.slide2ObjectDown = function(id, toY) {
  // retrieve a pointer to the target object of the slide animation
  positioning._slider2Target = positioning.getObject(id);
  // ensure that the target object is visible
  positioning.showObject(positioning._slider2Target);
  
  // configure the 'snap' factor applied to the slide motion
  if (arguments[2] != null) {
    if (arguments[2] == 'fast') {positioning._slider2SnapFactor = 0.5;}
    else if (arguments[2] == 'slow') {positioning._slider2SnapFactor = 0.0005;}
    else if (arguments[2] == 'very slow') {positioning._slider2TimerInterval = 15; positioning._slider2SnapFactor = 0;}
  }
  else {
    positioning._slider2SnapFactor = 0.1;
  }
  
  // configure the callback function, if supplied
  positioning._slider2Callback = null;
  if (arguments[3] != null) {
    positioning._slider2Callback = arguments[3];
  }
  
  if (positioning._slider2Target != null) {
    positioning._slider2StartX = positioning.getObjectLeft(positioning._slider2Target);
    positioning._slider2EndX = positioning.getObjectLeft(positioning._slider2Target);
    positioning._slider2StartY = positioning.getObjectTop(positioning._slider2Target);
    positioning._slider2EndY = toY;
    positioning._slider2DistanceToTravel = Math.abs(positioning._slider2StartY - positioning._slider2EndY);
    positioning._slider2Direction = 1;
    
    positioning._slider2TimerId = window.setTimeout(positioning._slide2, positioning._slider2TimerInterval);
  }
}

positioning.slide2ObjectRight = function(id, toX) {
  // retrieve a pointer to the target object of the slide animation
  positioning._slider2Target = positioning.getObject(id);
  // ensure that the target object is visible
  positioning.showObject(positioning._slider2Target);
  
  // configure the 'snap' factor applied to the slide motion
  if (arguments[2] != null) {
    if (arguments[2] == 'fast') {positioning._slider2SnapFactor = 0.5;}
    else if (arguments[2] == 'slow') {positioning._slider2SnapFactor = 0.0005;}
    else if (arguments[2] == 'very slow') {positioning._slider2TimerInterval = 15; positioning._slider2SnapFactor = 0;}
  }
  else {
    positioning._slider2SnapFactor = 0.1;
  }
  
  // configure the callback function, if supplied
  positioning._slider2Callback = null;
  if (arguments[3] != null) {
    positioning._slider2Callback = arguments[3];
  }
  
  //alert(positioning._slider2Target.id);
  if (positioning._slider2Target != null) {
    positioning._slider2StartX = positioning.getObjectLeft(positioning._slider2Target);
    positioning._slider2EndX = toX;
    positioning._slider2StartY = positioning.getObjectTop(positioning._slider2Target);
    positioning._slider2EndY = positioning.getObjectTop(positioning._slider2Target);
    positioning._slider2DistanceToTravel = Math.abs(positioning._slider2StartX - positioning._slider2EndX);
    positioning._slider2Direction = 1;
    
    positioning._slider2TimerId = window.setTimeout(positioning._slide2, positioning._slider2TimerInterval);
    
  }
}

positioning.slide2ObjectLeft = function(id, toX) {
  // retrieve a pointer to the target object of the slide animation
  positioning._slider2Target = positioning.getObject(id);
  // ensure that the target object is visible
  positioning.showObject(positioning._slider2Target);
  
  // configure the 'snap' factor applied to the slide motion
  if (arguments[2] != null) {
    if (arguments[2] == 'fast') {positioning._slider2SnapFactor = 0.5;}
    else if (arguments[2] == 'slow') {positioning._slider2SnapFactor = 0.0005;}
    else if (arguments[2] == 'very slow') {positioning._slider2TimerInterval = 15; positioning._slider2SnapFactor = 0;}
  }
  else {
    positioning._slider2SnapFactor = 0.1;
  }
  
  // configure the callback function, if supplied
  positioning._slider2Callback = null;
  if (arguments[3] != null) {
    positioning._slider2Callback = arguments[3];
  }
  
  if (positioning._slider2Target != null) {
    positioning._slider2StartX = positioning.getObjectLeft(positioning._slider2Target);
    positioning._slider2EndX = toX;
    positioning._slider2StartY = positioning.getObjectTop(positioning._slider2Target);
    positioning._slider2EndY = positioning.getObjectTop(positioning._slider2Target);
    positioning._slider2DistanceToTravel = Math.abs(positioning._slider2StartX - positioning._slider2EndX);
    positioning._slider2Direction = -1;
    
    positioning._slider2TimerId = window.setTimeout(positioning._slide2, positioning._slider2TimerInterval);
    
  }
}

positioning.slide2ObjectStop = function() {
  if (positioning._slider2TimerId != null) {
    window.clearTimeout(positioning._slider2TimerId);
    positioning._slider2TimerId = null;
    positioning._slider2TimerInterval = 0.5;
    positioning._slider2TimerMoveOffset = 0;
    positioning._slider2TimerFactor = 0.15;

    positioning._slider2Target = null;
    positioning._slider2TargetWidth = -1000;
    positioning._slider2EndX = 0;
    positioning._slider2EndY = 0;
    positioning._slider2Direction = -1;
    positioning._slider2DistanceToTravel = 0;
    positioning._slider2CurrentDistanceTravelled = 0;
    positioning._slider2SnapFactor = 0.1;
  }
}

positioning._slide2 = function() {
  // determine whether the current slide is vertical or horizontal
  var slidePlane = 'horizontal';
  if (positioning._slider2StartX == positioning._slider2EndX)
    slidePlane = 'vertical';
  
  // increment the slider action variables
  positioning._slider2TimerMoveOffset += 1;
  positioning._slider2TimerFactor += positioning._slider2SnapFactor;
  
  // determine the next tween position in the slide animation
  var offset = (positioning._slider2TimerFactor * positioning._slider2TimerMoveOffset) * positioning._slider2Direction;
  var x = positioning.getObjectLeft(positioning._slider2Target);
  var y = positioning.getObjectTop(positioning._slider2Target);
  if (slidePlane == 'vertical')
    y += offset;
  else
    x += offset;

  positioning.shiftObjectTo(positioning._slider2Target, x, y);
  positioning._slider2CurrentDistanceTravelled = (slidePlane == 'vertical') ? Math.abs(y - positioning._slider2StartY) : Math.abs(x - positioning._slider2StartX);

  if (positioning._slider2CurrentDistanceTravelled >= positioning._slider2DistanceToTravel) {
    // first, stop the timer
    window.clearTimeout(positioning._slider2TimerId);
    
    // and then position the object at its final coordinates
    positioning.shiftObjectTo(positioning._slider2Target, positioning._slider2EndX, positioning._slider2EndY);
    
    // and, finally, reset the slide state properties
    positioning._slider2Target = null;
    positioning._slider2TargetWidth = -1000;
    positioning._slider2EndX = 0;
    positioning._slider2EndY = 0;
    positioning._slider2Direction = -1;
    positioning._slider2DistanceToTravel = 0;
    positioning._slider2CurrentDistanceTravelled = 0;
    positioning._slider2SnapFactor = 0.1;
    
    positioning._slider2TimerId = null;
    positioning._slider2TimerInterval = 0.5;
    positioning._slider2TimerMoveOffset = 0;
    positioning._slider2TimerFactor = 0.15;
    
    // if the calling client passed a pointer to a callback function, then
    // call that function now
    if (positioning._slider2Callback != null) {positioning._slider2Callback();};
  }
  else {
    positioning._slider2TimerId = window.setTimeout(positioning._slide2, positioning._slider2TimerInterval);
  }

}

