
// Continious ScrollerII (01-November-2008)
// by: Vic Phillips http://www.vicsjavascripts.org.uk


// Application Notes
// The effect is initialised and controlled by event calls to function
// zxcScroller('h','tst2','start',1,100,200);
// where:
//  parameter 0 = the mode, for vertical 'v', for horizontal 'h'.                                (string 'v' or 'h')
//  parameter 1 = the unique id name of the scroll container.                                    (string)
//  parameter 2 = (optional) to scroll up/left = negative digit or down/right = positive digit.  (digit, default = -1)
//                may also be used to control the scroll speed.
//  parameter 3 = (optional) the scroll speed (milli seconds).                                   (digits, default = 100)
//  parameter 4 = (optional) the hold delay speed (milli seconds),                               (digits, default = no hold)
//                           may only be used if parameter 3 is 1 or -1.
//  parameter 5 = (optional) the hold position from the left/top (px).                           (digits, default = 0)
//  parameter 6 = (optional) the initial delay before scrolling (milli seconds).                 (digits, default = no auto start)
//
// The first call will initialise the effect.
// Subsequent calls may be used control the effect by updating parameters 2, 3

// To Stop & Start the Scroller
// Function zxcScrollerSS('tst1','v',true) may be used to stop and start the scroller.
// where:
//  parameter 0 = the mode, for vertical 'v', for horizontal 'h'. (string 'v' or 'h')
//  parameter 1 = the unique id name of the scroll container.     (string)
//  parameter 2 = (string) to toggle the rotation between stop and start the scroller. (string)
//  parameter 2 = true to start or false to stop the scroller.    (boolen, default = false)


// Functional Code size =  about 3.3k

function zxcScroller(zxcmde,zxcid,zxcud,zxcspd,zxchold,zxcholdpos,zxcsrt){
 var zxcp=document.getElementById(zxcid);
 zxcmde=(typeof(zxcmde)=='string'?(zxcmde+' '):' ').charAt(0).toLowerCase();
 if ((zxcmde!='v'&&zxcmde!='h')||!zxcp) return;
 if (!zxcp[zxcmde+'scroll']) return zxcp[zxcmde+'scroll']=new zxcScrollerOOP(zxcmde,zxcp,zxcud,zxcspd,zxchold,zxcholdpos,zxcsrt);
 var zxcoop=zxcp[zxcmde+'scroll']
 clearTimeout(zxcp.to);
 zxcoop.spd=zxcspd||zxcoop.spd;
 zxcoop.ud=zxcud||-zxcoop.ud;
}

function zxcScrollerSS(zxcp,zxcmde,zxcrun){
 if (typeof(zxcp)=='string') zxcp=document.getElementById(zxcp);
 zxcmde=(typeof(zxcmde)=='string'?(zxcmde+' '):' ').charAt(0).toLowerCase();
 if ((zxcmde!='v'&&zxcmde!='h')||!zxcp) return;
 var zxcoop=zxcp[zxcmde+'scroll'];
 if (zxcoop){
  zxcrun=zxcrun||false;
  clearTimeout(zxcoop.to);
  if (typeof(zxcrun)=='boolean') zxcoop.run=zxcrun||false;
  else zxcoop.run=!zxcoop.run;
  if (zxcoop.run) zxcoop.scroll();
 }
}

function zxcScrollerOOP(zxcmde,zxcp,zxcud,zxcspd,zxchold,zxcholdpos,zxcsrt){
 zxcp.style.overflow='hidden';
 this.p=zxcp;
 this.mde=zxcmde;
 this.vh=zxcmde=='v'?'top':'left';
 var zxcos=zxcmde=='v'?['offsetHeight','offsetTop','height']:['offsetWidth','offsetLeft','width'];
 var zxcc=zxcp.getElementsByTagName('DIV')[0];
 var zxcclds=zxcc.childNodes;
 for (var zxc0=0;zxc0<zxcclds.length;zxc0++){
  if (zxcclds[zxc0].nodeType==1){
   this.wh=zxcclds[zxc0][zxcos[0]]+zxcclds[zxc0][zxcos[1]];
  }
 }
 zxcholdpos=(typeof(zxcholdpos)=='number'?zxcholdpos:0)-this.wh;
 zxcc.style.position='absolute';
 zxcc.style[this.vh]=zxcholdpos+'px';
 zxcc.style[zxcos[2]]=this.wh+'px';
 var zxcmax=(zxcc[zxcos[0]]+zxcp[zxcos[0]]);
 var zxcpos=0;
 this.ary=[[zxcc,0,[]]];
 while (zxcpos<zxcmax){
  var zxc1=this.ary.length;
  this.ary[zxc1]=[zxcc.cloneNode(true),zxcpos+=this.wh,[]];
  this.ary[zxc1][0].style[this.vh]=this.ary[zxc1][1]+zxcholdpos+'px';
  zxcp.appendChild(this.ary[zxc1][0]);
 }
 for (var zxcclds,zxc2=0;zxc2<this.ary.length;zxc2++){
  zxcclds=this.ary[zxc2][0].childNodes;
  for (var zxc2a=0;zxc2a<zxcclds.length;zxc2a++){
   if (zxcclds[zxc2a].nodeType==1) this.ary[zxc2][2].push(zxcclds[zxc2a][zxcos[1]]);
  }
 }
 this.ud=zxcud||-1;
 this.spd=zxcspd||100;
 this.hold=typeof(zxchold)=='number'?zxchold:false;
 this.holdpos=typeof(zxchold)=='number'?zxcholdpos:0;
 this.to=null;
 this.data=[zxcpos,-this.wh];
 this.run=false;
 if (typeof(zxcsrt)=='number'){
  this.run=true;
  this.to=setTimeout(function(zxcoop){return function(){zxcoop.scroll();}}(this),zxcsrt);
 }
}

zxcScrollerOOP.prototype.scroll=function(){
 zxcspd=this.spd;
 for (var zxcr=1,zxc1=0;zxc1<this.ary.length;zxc1++){
  this.ary[zxc1][1]+=this.ud;
  this.ary[zxc1][0].style[this.vh]=this.ary[zxc1][1]+this.holdpos+'px'
  if (this.hold&&Math.abs(this.ud)==1){
   for (var zxc1a=0;zxc1a<this.ary[zxc1][2].length;zxc1a++){
    if (parseInt(this.ary[zxc1][0].style[this.vh])+this.ary[zxc1][2][zxc1a]*this.ud==this.holdpos) zxcspd=this.hold;
   }
  }
  if ((this.ud<0&&this.ary[zxc1][1]<=this.data[1])||(this.ud>0&&this.ary[zxc1][1]>this.data[0])) this.ary[zxc1][1]=this.data[(this.ud<0)?0:1]+this.ud;
 }
 this.to=setTimeout(function(zxcoop){return function(){zxcoop.scroll();}}(this),zxcspd);
}





// Continious ScrollerII (01-November-2008)
// by: Vic Phillips http://www.vicsjavascripts.org.uk


// Application Notes
// The effect is initialised and controlled by event calls to function
// zxcScroller('h','tst2','start',1,100,200);
// where:
//  parameter 0 = the mode, for vertical 'v', for horizontal 'h'.                                (string 'v' or 'h')
//  parameter 1 = the unique id name of the scroll container.                                    (string)
//  parameter 2 = (optional) to scroll up/left = negative digit or down/right = positive digit.  (digit, default = -1)
//                may also be used to control the scroll speed.
//  parameter 3 = (optional) the scroll speed (milli seconds).                                   (digits, default = 100)
//  parameter 4 = (optional) the hold delay speed (milli seconds),                               (digits, default = no hold)
//                           may only be used if parameter 3 is 1 or -1.
//  parameter 5 = (optional) the hold position from the left/top (px).                           (digits, default = 0)
//  parameter 6 = (optional) the initial delay before scrolling (milli seconds).                 (digits, default = no auto start)
//
// The first call will initialise the effect.
// Subsequent calls may be used control the effect by updating parameters 2, 3

// To Stop & Start the Scroller
// Function zxcScrollerSS('tst1','v',true) may be used to stop and start the scroller.
// where:
//  parameter 0 = the mode, for vertical 'v', for horizontal 'h'. (string 'v' or 'h')
//  parameter 1 = the unique id name of the scroll container.     (string)
//  parameter 2 = (string) to toggle the rotation between stop and start the scroller. (string)
//  parameter 2 = true to start or false to stop the scroller.    (boolen, default = false)


// Functional Code size =  about 3.3k

function zxcScroller1(zxcmde,zxcid,zxcud,zxcspd,zxchold,zxcholdpos,zxcsrt){
 var zxcp=document.getElementById(zxcid);
 zxcmde=(typeof(zxcmde)=='string'?(zxcmde+' '):' ').charAt(0).toLowerCase();
 if ((zxcmde!='v'&&zxcmde!='h')||!zxcp) return;
 if (!zxcp[zxcmde+'scroll']) return zxcp[zxcmde+'scroll']=new zxcScrollerOOP1(zxcmde,zxcp,zxcud,zxcspd,zxchold,zxcholdpos,zxcsrt);
 var zxcoop=zxcp[zxcmde+'scroll']
 clearTimeout(zxcp.to);
 zxcoop.spd=zxcspd||zxcoop.spd;
 zxcoop.ud=zxcud||-zxcoop.ud;
}

function zxcScrollerSS1(zxcp,zxcmde,zxcrun){
 if (typeof(zxcp)=='string') zxcp=document.getElementById(zxcp);
 zxcmde=(typeof(zxcmde)=='string'?(zxcmde+' '):' ').charAt(0).toLowerCase();
 if ((zxcmde!='v'&&zxcmde!='h')||!zxcp) return;
 var zxcoop=zxcp[zxcmde+'scroll'];
 if (zxcoop){
  zxcrun=zxcrun||false;
  clearTimeout(zxcoop.to);
  if (typeof(zxcrun)=='boolean') zxcoop.run=zxcrun||false;
  else zxcoop.run=!zxcoop.run;
  if (zxcoop.run) zxcoop.scroll();
 }
}

function zxcScrollerOOP1(zxcmde,zxcp,zxcud,zxcspd,zxchold,zxcholdpos,zxcsrt){
 zxcp.style.overflow='hidden';
 this.p=zxcp;
 this.mde=zxcmde;
 this.vh=zxcmde=='v'?'top':'left';
 var zxcos=zxcmde=='v'?['offsetHeight','offsetTop','height']:['offsetWidth','offsetLeft','width'];
 var zxcc=zxcp.getElementsByTagName('DIV')[0];
 var zxcclds=zxcc.childNodes;
 for (var zxc0=0;zxc0<zxcclds.length;zxc0++){
  if (zxcclds[zxc0].nodeType==1){
   this.wh=zxcclds[zxc0][zxcos[0]]+zxcclds[zxc0][zxcos[1]];
  }
 }
 zxcholdpos=(typeof(zxcholdpos)=='number'?zxcholdpos:0)-this.wh;
 zxcc.style.position='absolute';
 zxcc.style[this.vh]=zxcholdpos+'px';
 zxcc.style[zxcos[2]]=this.wh+'px';
 var zxcmax=(zxcc[zxcos[0]]+zxcp[zxcos[0]]);
 var zxcpos=0;
 this.ary=[[zxcc,0,[]]];
 while (zxcpos<zxcmax){
  var zxc1=this.ary.length;
  this.ary[zxc1]=[zxcc.cloneNode(true),zxcpos+=this.wh,[]];
  this.ary[zxc1][0].style[this.vh]=this.ary[zxc1][1]+zxcholdpos+'px';
  zxcp.appendChild(this.ary[zxc1][0]);
 }
 for (var zxcclds,zxc2=0;zxc2<this.ary.length;zxc2++){
  zxcclds=this.ary[zxc2][0].childNodes;
  for (var zxc2a=0;zxc2a<zxcclds.length;zxc2a++){
   if (zxcclds[zxc2a].nodeType==1) this.ary[zxc2][2].push(zxcclds[zxc2a][zxcos[1]]);
  }
 }
 this.ud=zxcud||-1;
 this.spd=zxcspd||100;
 this.hold=typeof(zxchold)=='number'?zxchold:false;
 this.holdpos=typeof(zxchold)=='number'?zxcholdpos:0;
 this.to=null;
 this.data=[zxcpos,-this.wh];
 this.run=false;
 if (typeof(zxcsrt)=='number'){
  this.run=true;
  this.to=setTimeout(function(zxcoop){return function(){zxcoop.scroll();}}(this),zxcsrt);
 }
}

zxcScrollerOOP1.prototype.scroll=function(){
 zxcspd=this.spd;
 for (var zxcr=1,zxc1=0;zxc1<this.ary.length;zxc1++){
  this.ary[zxc1][1]+=this.ud;
  this.ary[zxc1][0].style[this.vh]=this.ary[zxc1][1]+this.holdpos+'px'
  if (this.hold&&Math.abs(this.ud)==1){
   for (var zxc1a=0;zxc1a<this.ary[zxc1][2].length;zxc1a++){
    if (parseInt(this.ary[zxc1][0].style[this.vh])+this.ary[zxc1][2][zxc1a]*this.ud==this.holdpos) zxcspd=this.hold;
   }
  }
  if ((this.ud<0&&this.ary[zxc1][1]<=this.data[1])||(this.ud>0&&this.ary[zxc1][1]>this.data[0])) this.ary[zxc1][1]=this.data[(this.ud<0)?0:1]+this.ud;
 }
 this.to=setTimeout(function(zxcoop){return function(){zxcoop.scroll();}}(this),zxcspd);
}



