﻿// ARRAY of logos, order doesn't matter as a sort is being applied. Just name them appropriatly //

var mqAry1=[
    'images/logos/clients_ticker/01-DirectEnergy-Large.jpg',
    'images/logos/clients_ticker/02-Acuhoi.jpg',
    'images/logos/clients_ticker/03-LibraryofCongress.jpg',
    'images/logos/clients_ticker/04-Queens.jpg',
    'images/logos/clients_ticker/05-Joseph-Large.jpg',
    'images/logos/clients_ticker/06-TacoBueno-Large.jpg',
    'images/logos/clients_ticker/07-ACCC-Large.jpg',
    'images/logos/clients_ticker/08-ARCA.jpg',
    'images/logos/clients_ticker/09-Miziwe-Biik-Large.jpg',
    'images/logos/clients_ticker/10-Barex.jpg',
    'images/logos/clients_ticker/11-Ryerson.jpg',
    'images/logos/clients_ticker/12-CAE.jpg',
    'images/logos/clients_ticker/13-CSC-Large.jpg',
    'images/logos/clients_ticker/14-GFI.jpg',
    'images/logos/clients_ticker/15-Terumo.jpg',
    'images/logos/clients_ticker/16-HBC.jpg',
    'images/logos/clients_ticker/17-LSU.jpg',
    'images/logos/clients_ticker/18-CGI.jpg',
    'images/logos/clients_ticker/19-Eagle.jpg',
    'images/logos/clients_ticker/20-Ecore.jpg',
    'images/logos/clients_ticker/21-SimsLatham-Large.jpg',
    'images/logos/clients_ticker/22-teranet.jpg',
    'images/logos/clients_ticker/23-Phoenix.jpg',
    'images/logos/clients_ticker/24-FGE.jpg',
    'images/logos/clients_ticker/25-IK.jpg',
    'images/logos/clients_ticker/26-Oreilly.jpg',
    'images/logos/clients_ticker/27-Roofers.jpg',
    'images/logos/clients_ticker/28-McMaster.jpg',
    'images/logos/clients_ticker/29-MagnaCarta-Large.jpg',
    'images/logos/clients_ticker/30-GDA-Large.jpg',
    'images/logos/clients_ticker/31-ONPHA-Large.jpg',
    'images/logos/clients_ticker/32-THRC-Large.jpg'];
var mqr = [];
var marquee = {
    start: function() {
        mqAry1.sort();
        new mq('m1', mqAry1, 140);
        // must come last
    }
};
window.onload = marquee.start;

// Continuous Image Marquee
// copyright 24th July 2008 by Stephen Chapman
// http://javascript.about.com
// permission to use this Javascript on your web page is granted
// provided that all of the code below in this script (including these
// comments) is used without any alteration
function mq(id, ary, wid) {
    this.mqo = document.getElementById(id);   
    var heit = this.mqo.style.height;
    this.mqo.onmouseout = function() {
        mqRotate(mqr);
    };
    this.mqo.onmouseover = function() {
        clearTimeout(mqr[0].TO);
    };
    this.mqo.ary = [];
    var maxw = ary.length;
    for (var i = 0; i < maxw; i++) {
        this.mqo.ary[i] = document.createElement('img');
        this.mqo.ary[i].src = ary[i];
        this.mqo.ary[i].style.position = 'absolute';
        this.mqo.ary[i].style.left = (wid * i) + 'px';
        this.mqo.ary[i].style.width = wid + 'px';
        this.mqo.ary[i].style.height = heit;
        this.mqo.appendChild(this.mqo.ary[i]);
    }
    mqr.push(this.mqo);

    mqRotate(mqr);
    rotator.start();
}

function mqRotate() {
   if (typeof(mqr) == 'undefined') { return; }

    for (var j = mqr.length - 1; j > -1; j--) {
        
        maxa = mqr[j].ary.length;
        for (var i = 0; i < maxa; i++) {
            var x = mqr[j].ary[i].style;
            x.left = (parseInt(x.left, 10) - 1) + 'px';
        }

        var y = mqr[j].ary[0].style;
        if (parseInt(y.left, 10) + parseInt(y.width, 10) < 0) {
            var z = mqr[j].ary.shift();
            z.style.left = (parseInt(z.style.left) + parseInt(z.style.width) * maxa) + 'px';
            mqr[j].ary.push(z);
        }
    }
   mqr[0].TO = setTimeout(mqRotate, 20);
 }
