/*************************************************************************
  This code is from Dynamic Web Coding at www.dyn-web.com
  Copyright 2001-4 by Sharon Paine 
  See Terms of Use at www.dyn-web.com/bus/terms.html
  regarding conditions under which you may use this code.
  This notice must be retained in the code as is!
*************************************************************************/

/* dw_hoverscroll.js  version date: June 2004 
   mouseover scrolling for dw_scrollObj (in dw_scrollObj.js)  */

var counter=anticount=0;
var init=0
var timeinterval='';
var left=false

dw_scrollObj.stopScroll = function(wnId) {
  if ( dw_scrollObjs[wnId] ) dw_scrollObjs[wnId].endScroll();
}

// increase speed onmousedown of scroll links
dw_scrollObj.doubleSpeed = function(wnId) {
  if ( dw_scrollObjs[wnId] ) dw_scrollObjs[wnId].speed *= 2;
}

dw_scrollObj.resetSpeed = function(wnId) {
  if ( dw_scrollObjs[wnId] ) dw_scrollObjs[wnId].speed /= 2;
}

dw_scrollObj.scrollMe = function(wnId,x,y) {


var browserName=navigator.appName; 
var constnt=40
if (browserName=="Netscape")
{ 
 constnt=80
}
else 
{ 
 if (browserName=="Microsoft Internet Explorer")
 {
  constnt=40
 }
 else
  {
    constnt=40
   }
}


	if(x=='right'){
		
		dw_scrollObjs[wnId].shiftTo(document.getElementById(dw_scrollObjs[wnId].lyrId), -init, 0)
		
		if(init<anticount){
			timeinterval=setTimeout("dw_scrollObj.scrollMe('"+wnId+"','"+x+"','"+y+"')",2)
			init=init+constnt
		}else{
			clearInterval(timeinterval)
			timeinterval=''
		}
	}
	
	else{
		
		dw_scrollObjs[wnId].shiftTo(document.getElementById(dw_scrollObjs[wnId].lyrId), -init, 0)
		
		if(init>anticount){
			timeinterval=setTimeout("dw_scrollObj.scrollMe('"+wnId+"','"+x+"','"+y+"')",2)
			init=init-constnt
		}else{
			clearInterval(timeinterval)
			timeinterval=''
		}
		
	}

}

// algorithms for time-based scrolling and scrolling onmouseover at any angle adapted from youngpup.net
dw_scrollObj.initScroll = function(wnId, deg, sp) {
	
 var z=0
 var chlds=new Array();
 var maintable=document.getElementById('t1_tr')
 var ch=maintable.childNodes

 for(var x=0;x<ch.length;x++){
	if(ch[x].tagName){
		if(ch[x].tagName=='TD'){
			chlds[z]=ch[x]
			z++;
		}
	}
 }



if(deg=='right')
counter+=4
else
counter-=4

var nn=(chlds.length/4).toString().split('.')

if(counter>=nn[0]*4){
	counter=nn[0]*4;
	if(chlds.length%4==0)
	counter=counter-4
}

if(counter<0){
	counter=0;	
}


 var y = this.y + this.fy;
 
 var x=chlds[counter].offsetLeft



anticount=x


setTimeout("dw_scrollObj.scrollMe('"+wnId+"','"+deg+"','"+y+"')",5)

}





// speed (optional) to override default speed (set in dw_scrollObj.speed)
dw_scrollObj.prototype.startScroll = function(speed) {
  if (!this.ready) return; if (this.timerId) clearInterval(this.timerId);
  this.speed = speed || dw_scrollObj.speed;
  this.lyr = document.getElementById(this.lyrId);
  this.lastTime = ( new Date() ).getTime();
  this.on_scroll_start();  
  this.timerId = setInterval(this.animString + ".scroll()", 10); 
}

dw_scrollObj.prototype.scroll = function() {
  var now = ( new Date() ).getTime();
//  var d = (now - this.lastTime)/1000 * this.speed;
var d=96
var in_2nd=false;

  if (d > 0) {
    var x = this.x + this.fx * d; var y = this.y + this.fy * d;
	
    if (this.fx == 0 || this.fy == 0) { // for horizontal or vertical scrolling
      if ( ( this.fx == -1 && x > -this.maxX ) || ( this.fx == 1 && x < 0 ) || 
        ( this.fy == -1 && y > -this.maxY ) || ( this.fy == 1 && y < 0 ) ) {
        this.lastTime = now;
	    this.shiftTo(this.lyr, x, y);
        this.on_scroll(x, y);
		left=false
      } else {
        clearInterval(this.timerId); this.timerId = 0;
        this.shiftTo(this.lyr, this.endX, this.endY);
        this.on_scroll_end(this.endX, this.endY);
		//left=true
		//anticount=counter
		//alert(anticount+' '+'#1')
     }
    } else { // for scrolling at an angle (stop when reach end on one axis)
     if ( ( this.fx < 0 && x >= -this.maxX && this.fy < 0 && y >= -this.maxY ) ||
        ( this.fx > 0 && x <= 0 && this.fy > 0 && y <= 0 ) ||
        ( this.fx < 0 && x >= -this.maxX && this.fy > 0 && y <= 0 ) ||
        ( this.fx > 0 && x <= 0 && this.fy < 0 && y >= -this.maxY ) ) {
        this.lastTime = now;
        this.shiftTo(this.lyr, x, y);
        this.on_scroll(x, y);
      } else {
        clearInterval(this.timerId); this.timerId = 0;
        this.on_scroll_end(this.x, this.y);
      }
    }
  }



if(x%480==0){

counter=counter+d
anticount=anticount+d
 this.endScroll();
}


if(counter%d==0 && counter!=0 ){
//	alert('in 2nd if')
	in_2nd=true
	counter=counter-d
 this.endScroll();
 
}

/*if(anticount%d==0 && this.fx==1){
	alert(anticount)
	alert('in 3rd if')
	anticount=anticount-d
	this.endScroll();
}*/

//alert(anticount+' '+'#4')
//alert(counter)

//  alert(counter%8)
 // if(counter%4==0)
  //{
	 //  clearInterval(this.timerId); this.timerId = 0;
      // this.endScroll();
  //}
  
  //counter++

}

dw_scrollObj.prototype.endScroll = function() {
  if (!this.ready) return;
  if (this.timerId) clearInterval(this.timerId);
  this.timerId = 0;  this.lyr = null;
}

dw_scrollObj.prototype.on_scroll = function() {}
dw_scrollObj.prototype.on_scroll_start = function() {}
dw_scrollObj.prototype.on_scroll_end = function() {}
  
