/* ********************************************************************
*** GreyWyvern's HTML Block Scroller & Marquee ************************
***********************************************************************
* HTML Block Scroller & Marquee JavaScript - v1.9
*  - Copyright 2007 - 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 webpages.
* The scroller will even pause on mouseover and resume on mouseout.
*
* Version 1.9
*   - Fixed content flash in Firefox
*   - Code optimization
*
* Version 1.8
*   - Fixed movement in "down" and "right" directions
*   - Added the speed argument back in for customisability
*   - scrollObject ARGUMENT LIST HAS CHANGED
*
* Version 1.7
*   - Significant recode for speed and efficiency
*   - Pause-on-mouseover now works reliably
*   - Now MUCH less complicated to create a scroller
*   - scrollObject ARGUMENT LIST HAS CHANGED
*     - Only five arguments instead of ten :)
*
* 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
*
*
***********************************************************************
*** Instructions ******************************************************
***********************************************************************
* 1. Create the target for the scroller in the body of your HTML:
*
* <div id="scr1">
*   The contents of this block will be displayed if the browser does
*   not support the scroller.
*   It will be overwritten if the scroller is supported.
* </div>
*
* Where "scr1" is any name you choose.  You don't have to use a <div>
* either.  You may use any block level element that can be pixel
* resized; such as a <span> element to which the display:block; CSS
* property has been applied.
*
* To style the scroller container, assign CSS properties to the scr1
* id:
*
* #scr1 {
*   background-color:#f6f6f6;
*   margin:0px auto;
* }
*
* For each of the blocks you add to a scroller, the script will add a
* single-celled <table> inside the target element and insert the
* contents of the block. So to style the blocks of your scroller, you
* can style these table cells as if they were actually part of your
* document source:
*
* #scr1 table tr td {
*   padding:10px;
*   color:#ff0000;
*   text-align:center;
*   vertical-align:middle;
* }
*
***********************************************************************
* 2. Create a new scrollObject:
*
* var scroll1 = new scrollObject("scr1", 120, 120, "up", 5000, 1.4);
*
* The arguments for this object are as follows:
*  a. - ID of the target tag (from step 1)
*  b. - Width (in pixels) of your scroller
*  c. - Height (in pixels) of your scroller
*  d. - Scroll direction: one of "up", "down", "left" or "right"
*  e. - Amount of time to pause before next scroll begins (ms)
*  f. - Slide-in speed of your scroller (1.001 up to width or height)
*
***********************************************************************
* 3. Fill the Scroll Object blocks with HTML:
*
* scroll1.block[0] = "This is block 1";
* scroll1.block[1] = "This is block 2";
* scroll1.block[2] = "Blocks can contain any HTML including:";
* scroll1.block[3] = "Images, tables, links and more";
* scroll1.block[4] = "Easy to configure, easy to run";
* scroll1.block[5] = "Have any number of block scrollers running";
* scroll1.block[6] = "On a single page all with a single JavaScript";
* scroll1.block[7] = "View the source for more info!";
*
* There is no limit to how many blocks or scrollObjects this program
* can hold, as long as you don't skip any integers when numbering the
* blocks. For example, the following setup will cause the scroller to
* throw an error:
*
* scroll1.block[0] = "This is block 1";
* scroll1.block[1] = "This is block 2";
* scroll1.block[3] = "Images, tables, links and more";
*
***********************************************************************
* 4. Add an "onload" command to the <body> tag:
*
* <body onload="scroll1.scroll();">
*
*
***********************************************************************
*** To add more scrollers to the same page: ***************************
***********************************************************************
* 1. Create additional ID'ed targets (with different ID's) in the body
* of your HTML
*
* <div id="scr2">
*   Default content which will not scroll
* </div>
*
* <div id="scr3">
*   Default content which will not scroll
* </div>
*
***********************************************************************
* 2. Create new scrollObjects for each scroller in the <script> tag:
*
* var scroll2 = new scrollObject("scr2", 468, 60, "down", 10000, 1.2);
* var scroll3 = new scrollObject("scr3", 140, 140, "right", 4000, 2);
*
***********************************************************************
* 3. Fill the Scroll Object blocks with HTML:
*
* scroll2.block[0] = '<strong>HTML is allowed too!</strong>';
* scroll2.block[1] = '<img src="/images/mybanner.jpg" alt="">';
* scroll2.block[2] = '<a href="/home">And links!</a>';
* scroll2.block[2] = 'As long as it fits within the dimensions above';
*
* scroll3.block[0] = "Block 1";
* scroll3.block[1] = "Block 2";
* scroll3.block[2] = "Block 3";
* scroll3.block[3] = "Block 4";
*
***********************************************************************
* 4. Add an "onload" command for all scroll objects to the <body> tag:
*
* <body onload="scroll1.scroll();scroll2.scroll();scroll3.scroll();">
*
*
***********************************************************************
*** End Instructions **************************************************
*************************************************** BEGIN CODE ***** */
8


// ***** Sample scroller #1
var scroll1 = new scrollObject("scr1", 560, 120, "up", 10000, 1.12);
    scroll1.block[0] = "\"<b><font size=\"2\">Ginny is everything you want in a real estate agent - friendly, knowledgeable, hard working and fun.  She has been our  agent since we first moved to Dallas seven years ago.  She is always willing to go the extra mile to make sure she meets her client's expectations and needs.</b>\"<BR> - R.W., Client";
    scroll1.block[1] = "\"<b><font size=\"2\">I have worked with Ginny for the past 15 years and found her to be easy to work with and very knowledgeable. She has a well rounded background in the real estate field which has come in very helpful on more than one occasion. I strongly recommend her to anyone in need of a real estate professional.\"<BR></b>-D.D., Compass Mortgage";
    scroll1.block[2] = "\"<b><font size=\"2\">Being a first time home buyer and unfamiliar to this area, Ginny educated me from ground zero to the point where I felt I knew exactly what I wanted.  She pays great attention to detail and is extremely knowledgeable in her field.  Ginny worked with me daily until we spotted my dream house in Lakewood.  She stayed with me right to the signing and I could not have done it without her.  I have since recommended her to a number of friends who have also purchased a home through her.  No doubt I will buy my next house from Ginny.\"<BR>- D.P., Client";
    scroll1.block[3] = "\"<b><font size=\"2\">My experience working with Ginny Laughlin was a pleasure from the first home we visited through the closing of my new home.  She was professional, thorough and extremely knowledgeable about all aspects of home-buying.\"<BR>- K.L., Client";
    scroll1.block[4] = "\"<b><font size=\"2\">We have purchased eight homes in six states and Ginny was far and above the best realtor we have ever found.  We have been so impressed with her that whenever we hear about someone moving to this area we insist that they take her number and contact her.\"<BR>- S.N., Client";
    scroll1.block[5] = "\"<b><font size=\"2\">My sellers, the lender and I were all talking about you in the closing this morning.  We all agreed that you were the primary reason this transaction went so smoothly.  You were truly one of the best agents I have ever worked with.  Thank you for keeping us all in line!.\"<BR>- K.W., Real Estate Agent";
    scroll1.block[6] = "\"<b><font size=\"2\">Ginny is the ultimate buyer's agent. Her knowledge of the local rental and investment market, as well as current pricing trends of homes for sale, makes her a buyer's best friend. I work with many top producers in the metroplex and Ginny's value approach to real estate sets her above the everyday agent.\"<BR>- C.J., Pulaski Mortgage";
   
   // scroll1.block[3] = "Images, tables, links and more";
   // scroll1.block[4] = "Easy to configure, easy to run, now even easier in version 1.8";
   // scroll1.block[5] = "Have any number of block scrollers running on a single page all with a single JavaScript";
   // scroll1.block[6] = "View the source for more info!";


// ***** Sample scroller #2
//var scroll2 = new scrollObject("scr2", 468, 60, "left", 3000, 1.5);
  //  scroll2.block[0] = '<a href="http://www.greywyvern.com"><span style="font:bold 200% fantasy;">Visit GreyWyvern.com!</span></a>';
   // scroll2.block[1] = '<a href="http://www.greywyvern.com/orca"><strong>Home of the Orca Scripts!</strong></a>';
   // scroll2.block[2] = '<a href="http://www.greywyvern.com"><img src="http://www.greywyvern.com/img/jpg/bannerorca468x60.jpg" border="0"></a>';


/* *****
 * Instead of using the onload attribute of the <body> tag, you can
 * also start your scrollers this way.
 *
 */
window.onload = function() {
  if (document.getElementById('scr1')){
  scroll1.scroll();}
 // scroll2.scroll();
}




/* ********************************************************************
 * The Mighty ScrollObject
 *   - Don't edit this if you know what's good for ya!
 *
 */
function scrollObject(main, width, height, direct, pause, speed) {
  var self = this;
  this.main = main;
  this.width = width;
  this.height = height;
  this.direct = direct;
  this.pause = pause;
  this.speed = Math.max(1.001, Math.min((direct == "up" || direct == "down") ? height : width, speed));
  this.block = new Array();
  this.blockprev = this.offset = 0;
  this.blockcurr = 1;
  this.mouse = false;
  this.scroll = function() {
    if (!document.getElementById) return false;
    this.main = document.getElementById(this.main);
    while (this.main.firstChild) this.main.removeChild(this.main.firstChild);
    this.main.style.overflow = "hidden";
    this.main.style.position = "relative";
    this.main.style.width = this.width + "px";
    this.main.style.height = this.height + "px";
    for (var x = 0; x < this.block.length; x++) {
      var table = document.createElement('table');
          table.cellPadding = table.cellSpacing = table.border = "0";
          table.style.position = "absolute";
          table.style.left = table.style.top = "0px";
          table.style.width = this.width + "px";
          table.style.height = this.height + "px";
          table.style.overflow = table.style.visibility = "hidden";
        var tbody = document.createElement('tbody');
          var tr = document.createElement('tr');
            var td = document.createElement('td');
                td.innerHTML = this.block[x];
              tr.appendChild(td);
            tbody.appendChild(tr);
          table.appendChild(tbody);
      this.main.appendChild(this.block[x] = table);
    }
    if (this.block.length > 1) {
      this.main.onmouseover = function() { self.mouse = true; }
      this.main.onmouseout = function() { self.mouse = false; }
      setInterval(function() {
        if (!self.offset && self.scrollLoop()) self.block[self.blockcurr].style.visibility = "visible";
      }, this.pause);
    } this.block[this.blockprev].style.visibility = "visible";
  }
  this.scrollLoop = function() {
    if (!this.offset) {
      if (this.mouse) return false;
      this.offset = (this.direct == "up" || this.direct == "down") ? this.height : this.width;
    } else this.offset = Math.floor(this.offset / this.speed);
    if (this.direct == "up" || this.direct == "down") {
      this.block[this.blockcurr].style.top = ((this.direct == "up") ? this.offset : -this.offset) + "px";
      this.block[this.blockprev].style.top = ((this.direct == "up") ? this.offset - this.height : this.height - this.offset) + "px";
    } else {
      this.block[this.blockcurr].style.left = ((this.direct == "left") ? this.offset : -this.offset) + "px";
      this.block[this.blockprev].style.left = ((this.direct == "left") ? this.offset - this.width : this.width - this.offset) + "px";
    }
    if (!this.offset) {
      this.block[this.blockprev].style.visibility = "hidden";
      this.blockprev = this.blockcurr;
      if (++this.blockcurr >= this.block.length) this.blockcurr = 0;
    } else setTimeout(function() { self.scrollLoop(); }, 30);
    return true;
  }
}
