// JavaScript Document

var scroller = new scrollObject("scroller", "quotes", 200, 160, "white", "up", 1.35, 2.7, 30, 6000, "scroll");

scroller.block[0] = "<span class=\"red\">&quot;</span><span class=\"quotewords\">Shed-loads of art magazines come out which rapidly end up lining the recycling box. Latest Art has content and street cred you can't buy and which should be  making other magz writhe with envy.<span class=\"red\">&quot;</span></span><br /><span class=\"quotewho1\">Aladin</span><br /><span class=\"quotewho2\">Trouble-maker and cultural strategist</span>";

scroller.block[1] = "<span class=\"red\">&quot;</span><span class=\"quotewords\">Art hasn't amused me this much since I saw my last Jack Vettriano painting.<span class=\"red\">&quot;</span></span><br /><span class=\"quotewho1\">Julie Burchill</span>";

scroller.block[2] = "<span class=\"red\">&quot;</span><span class=\"quotewords\">We loved Stella's cover portrait for Latest Art and we love Latest Art.<span class=\"red\">&quot;</span></span><br /><span class=\"quotewho1\">Preston</span><br /><span class=\"quotewho2\">The Ordinary Boys</span>";

scroller.block[3] = "<span class=\"red\">&quot;</span><span class=\"quotewords\">Bloody great idea, this is the best magazine in the world, ever!<span class=\"red\">&quot;</span></span><br /><span class=\"quotewho1\">Kentak&eacute; Chinyelu-Hope</span><br /><span class=\"quotewho2\">Chair, Arts Council England South East</span>";

scroller.block[4] = "<span class=\"red\">&quot;</span><span class=\"quotewords\">A very exciting project - and long overdue.<span class=\"red\">&quot;</span></span><br /><span class=\"quotewho1\">Phil Grabsky</span><br /><span class=\"quotewho2\">7th Art Productions, Producer / Director of over 80 arts documentaries for Channel 5</span>";

scroller.block[5] = "<span class=\"red\">&quot;</span><span class=\"quotewords\">A no-nonsense gallery showcase of diverse work with some genuinely interesting articles. Refreshingly free from twee polemic or academe, I can see this catching on in a big&nbsp;way.<span class=\"red\">&quot;</span></span><br /><span class=\"quotewho1\">John May</span><br /><span class=\"quotewho2\">Journalist and curator of Rodin In Lewes exhibition</span>";

scroller.block[6] = "<span class=\"red\">&quot;</span><span class=\"quotewords\">Latest Art is an excellent idea. Quality exposure for artists is essential and this magazine makes it easy for buyers to find them.<span class=\"red\">&quot;</span></span><br /><span class=\"quotewho1\">Holly Payton</span><br /><span class=\"quotewho2\">Operations Manager, Brighton Festival Fringe</span>";

scroller.block[7] = "<span class=\"red\">&quot;</span><span class=\"quotewords\">At last, an art magazine that you actually want to read from cover to cover! I've had an absolutely great reaction to my ad - the original painting flew out the door.<span class=\"red\">&quot;</span></span><br /><span class=\"quotewho1\">Karren Urben</span><br /><span class=\"quotewho2\">Artist</span>";


function scrollObject(objName, main, width, height, bkgcol, direct, deccel, begin, speed, pause, classname) {
  this.objName = objName;
  this.main = main;
  this.one = main + "Block1";
  this.two = main + "Block2";
  this.block = new Array();
  this.blockup = 1;
  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.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";
        } divList[i].innerHTML = this.table + this.block[i - 1] + "</td></tr></table>";
      } else {
        divList[i].style.position = "relative";
        divList[i].style.background = this.bkgcol;
        if (this.block.length > 1) {
          divList[i].onmouseover = new Function("if (" + this.objName + ".active) setTimeout(\"" + this.objName + ".scrollWait();\", " + this.objName + ".pause); " + this.objName + ".active = false; " + this.objName + ".mouse = true;");
          divList[i].onmouseout = new Function(this.objName + ".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(this.objName + ".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(this.objName + ".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(this.objName + ".scrollLoop();", this.speed);
    }
  }
  this.scrollWait = function() {
    clearTimeout(this.process);
    if (this.active) return false;
    if (!this.mouse) {
      this.active = true;
      this.process = setTimeout(this.objName + ".scrollLoop();", this.pause / 2);
    } else this.process = setTimeout(this.objName + ".scrollWait();", this.pause);
  }
}