/* **************************************************************************
*** GreyWyvern's HTML Block Scroller & Marquee ******************************
*****************************************************************************
* HTML Block Scroller & Marquee JavaScript - v1.6 - Coded by GreyWyvern
*  - Copyright 2006 - Licenced for free distribution under the BSDL
*  -     http://www.opensource.org/licenses/bsd-license.php
*
* Have one or more scrolling blocks of HTML anywhere on your screen, and
* all infinitely adjustable!  Scroller will even pause on mouseover and
* resume on mouseout.
*
* Version 1.6
*   - Specifying variable name in argument list no longer required
*   - scrollObject ARGUMENT LIST HAS CHANGED
*
* Version 1.5
*   - Added pause-on-mouseover
*   - Added patch from Vincent Driessen:
*      - Disables scrolling when scrollObject has only one block
*
*****************************************************************************/

// ***** Sample scroller #1
// var scObj1 = new scrollObject("scroll1", 225, 180, "white", "right", 1.45, 3, 30, 5000, "scrollClass", (Math.floor(Math.random() * 6) ) );

var scObj1 = new scrollObject("scroll1", 225, 180, "white", "right", 1.45, 3, 30, 6000, "scrollClass", 0 );


scObj1.block[0] = '<div style="text-align:center; padding:10px;"><font size="2"><font face="Trebuchet MS"><font color="#0c4da2"><strong>Provence Counselling.  Person-Centred counselling for the English-speaking community.</strong></div>';

scObj1.block[1] = '<div style="text-align:center; padding:10px;"><font size="2"><font face="Trebuchet MS"><font color="#0c4da2"><strong>&#8220;The good life is a process, not a state of being. It is a direction not a destination.&#8221;</strong><br><i>Carl Rogers</i></div>';

// scObj1.block[2] = '<div style="text-align:center; padding:10px;"><font size="1"><font face="Trebuchet MS"><font color="#0c4da2"> <strong>&#8220;The truth is that our finest moments are most likely to occur when we are feeling deeply uncomfortable, unhappy, or unfulfilled. For it is only in such moments, propelled by our discomfort, that we are likely to step out of our ruts and start searching for different ways or truer answers.&#8221;</strong> <br><i>M Scott Peck</i></div>';


scObj1.block[2] = '<div style="text-align:center; padding:10px;"><font size="2"><font face="Trebuchet MS"><font color="#0c4da2"> <strong>&#8220;It is the client who knows what hurts, what directions to go, what problems are crucial, what experiences have been deeply buried.&#8221;</strong> <br><i>Carl Rogers</i></div>';

scObj1.block[3] = '<div style="text-align:center; padding:10px;"><font size="2"><font face="Trebuchet MS"><font color="#0c4da2"> <strong>&#8220;An unexamined life is not worth living.&#8221;</strong> <br><i>Socrates</i></div>';

scObj1.block[4] = '<div style="text-align:center; padding:10px;"><font size="2"><font face="Trebuchet MS"><font color="#0c4da2"> <strong>&#8220;I believe that a different therapy must be constructed for each patient because each has a unique story.&#8221;</strong> <br><i>Irvin D Yalom</i></div>';




// scObj1.block[0] = '<div style="text-align:center; padding:10px;"><font size="2"><font face="Trebuchet MS"><font color="#0c4da2"><strong>&#8220;The facts are always friendly, every bit of evidence one can acquire, in any area, leads one that much closer to what is true.&#8221;</strong></div>';


// scObj1.block[2] = '<div style="text-align:center; padding:10px;"><font size="2"><font face="Trebuchet MS"><font color="#0c4da2"><strong>&#8220;The only person who is educated is the one who has learned how to learn and change.&#8221;</strong></div>';

// scObj1.block[3] = '<div style="text-align:center; padding:10px;"><font size="2"><font face="Trebuchet MS"><font color="#0c4da2"><strong>&#8220;The very essence of the creative is its novelty, and hence we have no standard by which to judge it.&#8221;</strong></div>';

// scObj1.block[4] = '<div style="text-align:center; padding:10px;"><font size="2"><font face="Trebuchet MS"><font color="#0c4da2"><strong>&#8220;When I look at the world I\'m pessimistic, but when I look at people I am optimistic.&#8221;</strong></div>';

// scObj1.block[5] = '<div style="text-align:center; padding:10px;"><font size="2"><font face="Trebuchet MS"><font color="#0c4da2"><strong>&#8220;With the price of life these days, you\'ve got to get everything for free if you can. &#8221;</strong></div>';

// scObj1.block[6] = '<div style="text-align:center; padding:10px;"><font size="2"><font face="Trebuchet MS"><font color="#0c4da2"><strong>&#8220;If you have waited this long for another quote, then you need help.  Call 0778 996 3095 now!&#8221;</strong></div>';




/* **************************************************************************
*** Don't pass this line ****************************************************
************************************************************************** */
function scrollObject(main, width, height, bkgcol, direct, deccel, begin, speed, pause, classname, start) {
  var self = this;

  this.main = main;
  this.one = main + "Block1";
  this.two = main + "Block2";
  this.block = new Array();
  this.divup = 1;
  this.height = height;
  this.width = width;
  this.bkgcol = bkgcol;
  this.direct = direct;
  this.deccel = Math.max(deccel, 1);
  this.begin = Math.max(Math.min(begin, (direct == "up" || direct == "down") ? height : width), 1);
  this.speed = speed;
  this.pause = pause;
  this.start = start;
  this.blockup = 1;
  this.slide = ((direct == "up" || direct == "down") ? height : width) / this.begin;
  this.table = "<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr><td class=\"" + classname + "\" style=\"width:" + width + "px;height:" + height + "px;\">";
  this.active = false;
  this.moving = false;
  this.process = 0;
  this.mouse = false;
  this.scroll = function() {
    if (!document.getElementById) return false;
    document.getElementById(this.main).innerHTML = "<div id=\"" + this.one + "\"></div><div id=\"" + this.two + "\"></div>";
    var divList = [document.getElementById(this.main), document.getElementById(this.one), document.getElementById(this.two)];
    for (var i = 0; i <= 2; i++) {
      if (i > 0) {
        divList[i].style.position = "absolute";
        if (this.direct == "up" || this.direct == "down") {
          divList[i].style.left = "0px";
          divList[i].style.top = (i == 1) ? "0px" : ((this.direct == "up") ? "" : "-") + this.height + "px";
        } else {
          divList[i].style.left = (i == 1) ? "0px" : ((this.direct == "left") ? "" : "-") + this.width + "px";
          divList[i].style.top = "0px";
        }
		var num=( i % this.block.length) + this.start;
		divList[i].innerHTML = this.table + this.block[num - 1]+"</td></tr></table>";
      } else {
        divList[i].style.position = "relative";
        divList[i].style.background = this.bkgcol;
        if (this.block.length > 1) {
          divList[i].onmouseover = function() {
            if (this.active) {
				setTimeout(function() { self.scrollWait(); }, this.pause);
			}
            this.mouse = true;
          }
          divList[i].onmouseout = function() {
            this.mouse = false;
          }
        }
      } divList[i].style.overflow = "hidden";
      divList[i].style.width = this.width + "px";
      divList[i].style.height = this.height + "px";
    } this.active = true;
    if (this.block.length > 1) this.process = setTimeout(function() { self.scrollLoop(); }, this.pause);
  }
  this.scrollLoop = function() {
    clearTimeout(this.process);
    if (this.moving == false && this.active == false) return false;
    var divList = [document.getElementById(this.main), document.getElementById(this.one), document.getElementById(this.two)];
    this.slide = Math.max(this.slide / this.deccel, 1);
    var slideInc = (this.direct == "up" || this.direct == "left") ? -parseInt(this.slide) : parseInt(this.slide);
    if ((this.direct == "up" && Math.max(parseInt(divList[1].style.top) + slideInc, parseInt(divList[2].style.top) + slideInc) <= 0) ||
        (this.direct == "down" && Math.min(parseInt(divList[1].style.top) + slideInc, parseInt(divList[2].style.top) + slideInc) >= 0) ||
        (this.direct == "left" && Math.max(parseInt(divList[1].style.left) + slideInc, parseInt(divList[2].style.left) + slideInc) <= 0) ||
        (this.direct == "right" && Math.min(parseInt(divList[1].style.left) + slideInc, parseInt(divList[2].style.left) + slideInc) >= 0)) {
      this.slide = ((this.direct == "up" || this.direct == "down") ? this.height : this.width) / this.begin;
      if (++this.blockup >= this.block.length) this.blockup = 0;
      this.divup = (this.divup == 1) ? 2 : 1;
      if (this.direct == "up" || this.direct == "down") {
        divList[3 - this.divup].style.top = ((this.direct == "down") ? "-" : "") + this.height + "px";
        divList[this.divup].style.top = "0px";
      } else {
        divList[3 - this.divup].style.left = ((this.direct == "right") ? "-" : "") + this.width + "px";
        divList[this.divup].style.left = "0px";
      }
	  divList[3 - this.divup].innerHTML = this.table + this.block[this.blockup] + "</td></tr></table>";
      this.moving = false;
      this.process = setTimeout(function() { self.scrollLoop(); }, this.pause);
    } else {
      this.moving = true;
      for (var j = 1; j <= 2; j++) {
        if (this.direct == "up" || this.direct == "down") {
          divList[j].style.top = (parseInt(divList[j].style.top) + slideInc) + "px";
        } else divList[j].style.left = (parseInt(divList[j].style.left) + slideInc) + "px";
      } this.process = setTimeout(function() { self.scrollLoop(); }, this.speed);
    }
  }
  this.scrollWait = function() {
    clearTimeout(this.process);
    if (this.active) return false;
    if (!this.mouse) {
      this.active = true;
      this.process = setTimeout(function() { self.scrollLoop(); }, this.pause / 2);
    } else this.process = setTimeout(function() { self.scrollWait(); }, this.pause);
  }
}
