﻿var images = new Array();
var captions = new Array();
var links = new Array();
var currentImage = 0;
        
$(document).ready(function () {

    initImages();

    $(function () {
        $('#slider').anythingSlider({

            autoPlay: true,
            enableNavigation: false,
            delay: 3500,
            pauseOnHover: false,
            buildArrows: false,
            enableArrows: false,
            buildNavigation: false,
            buildStartStop: false,
            expand: true,
            startPanel : Math.floor(Math.random() * $('#slider li').length),
                    
            onSlideBegin: function (slider) {

                nextImage();
            }

        });
    });


});

function initImages() {

    images[0] = '/img/handshake250.jpg';
    captions[0] = 'Welcome';
    links[0] = 'services.aspx';
    
    images[1] = '/img/accountdesk250.jpg';
    captions[1] = 'Bookkeeping, VAT and Accounts';
    links[1] = 'services.aspx#bookkeeping_vat_management_accounts';

    images[2] = '/img/limited250.jpg';
    captions[2] = 'Limited Companies';
    links[2] = 'services.aspx#limited_companies';

    images[3] = '/img/money250.jpg';
    captions[3] = 'Payroll';
    links[3] = 'services.aspx#payroll';

    images[4] = '/img/moneylock250.jpg';
    captions[4] = 'Fee Protection Scheme';
    links[4] = 'services.aspx#fee_protection';

    images[5] = '/img/property250.jpg';
    captions[5] = 'Property Management Accounts';
    links[5] = 'services.aspx#property_management_accounts';

    images[6] = '/img/tax250.jpg';
    captions[6] = 'Tax Advice';
    links[6] = 'services.aspx#tax_advice';

    images[7] = '/img/david250.jpg';
    captions[7]='David Seddon, Managing Director'
    links[7] = 'our_team.aspx#david';

    images[8] = '/img/seymour2250.jpg';
    captions[8] = 'Seymour Griffiths, Director'
    links[8] = 'our_team.aspx#seymour';
   
    currentImage = Math.floor(Math.random() * images.length)

    if (currentImage == 0) { currentImage = 1; }

}

function nextImage() {

    if (currentImage == images.length) { currentImage = 0; }

    document.getElementById('GraphicImg').src = images[currentImage];
    document.getElementById('GraphicCaption').innerHTML = captions[currentImage];
    document.getElementById('GraphicLink').href = links[currentImage];
            
    currentImage += 1;

}

