Array.prototype.shuffle = function(b)
{
 var i = this.length, j, t;
 while( i )
 {
  j = Math.floor( ( i-- ) * Math.random() );
  t = b && typeof this[i].shuffle!=='undefined' ? this[i].shuffle() : this[i];
  this[i] = this[j];
  this[j] = t;
 }

 return this;
};

$(document).ready(function() {
  var base_staff = new Array();
	base_staff[0] = {
		'name' : 'Daniel Fagg',
		'post' : 'Joint Creative Director',
		'image' : '/img/people/people_mugshot/dan_mugshot.jpg',
		'page' : '/person/daniel_fagg.html'
        }
	base_staff[1] = {
		'name' : 'Miriam Mainwood',
		'post' : 'Account Director',
		'image' : '/img/people/people_mugshot/miriam_mugshot.jpg',
		'page' : '/person/miriam_mainwood.html'
        }
	base_staff[2] = {
		'name' : 'Jason Till',
		'post' : 'Digital Director',
		'image' : '/img/people/people_mugshot/_People_mugshot_jason_till.jpg',
		'page' : '/person/jason_till.html'
        }
	base_staff[3] = {
		'name' : 'Jason Triandafyllou',
		'post' : 'Managing Director',
		'image' : '/img/people/people_mugshot/jason_tri_mugshot.jpg',
		'page' : '/person/jason_triandafyllou.html'
        }
	base_staff[4] = {
		'name' : 'Adam Hill',
		'post' : 'Chairman',
		'image' : '/img/people/people_mugshot/adam_mugshot.jpg',
		'page' : '/person/adam_hill.html'
        }
	base_staff[5] = {
		'name' : 'Anthony Butterfield',
		'post' : 'Head of Digital Design',
		'image' : '/img/people/people_mugshot/anthony_mugshot.jpg',
		'page' : '/person/anthony_butterfield.html'
        }
	base_staff[6] = {
		'name' : 'Kerry Wright',
		'post' : 'Board Account Director Manchester',
		'image' : '/img/people/people_mugshot/kerry_mugshot.jpg',
		'page' : '/person/kerry_wright.html'
        }
	base_staff[7] = {
		'name' : 'Sarah Parham',
		'post' : 'Joint Creative Director',
		'image' : '/img/people/people_mugshot/sarah_mugshot.jpg',
		'page' : '/person/sarah_parham.html'
        }

        var other_staff = new Array();
	other_staff[0] = {
		'name' : 'Jennifer Weston',
		'post' : 'Digital Designer',
		'image' : '/img/people/people_mugshot/jen_mugshot.jpg',
		'page' : '/person/jennifer_weston.html'
        }
	other_staff[1] = {
		'name' : 'Pete Rowden',
		'post' : 'Copywriter',
		'image' : '/img/people/people_mugshot/pete_rowden_mugshot.jpg',
		'page' : '/person/pete_rowden.html'
        }
	other_staff[2] = {
		'name' : 'Rob Marchant',
		'post' : 'Receptionist',
		'image' : '/img/people/people_mugshot/rob_mugshot.jpg',
		'page' : '/person/rob_marchant.html'
        }
	other_staff[3] = {
		'name' : 'Nikki Miller',
		'post' : 'Account Manager',
		'image' : '/img/people/people_mugshot/NIKKI_M_mugshot.jpg',
		'page' : '/person/nikki_miller.html'
        }
	other_staff[4] = {
		'name' : 'Lucy Lefroy',
		'post' : 'Account Manager',
		'image' : '/img/people/people_mugshot/lucy_mugshot.jpg',
		'page' : '/person/lucy_lefroy.html'
        }
	other_staff[5] = {
		'name' : 'James McCarthy',
		'post' : 'IT Manager',
		'image' : '/img/people/people_mugshot/james_mugshot.jpg',
		'page' : '/person/james_mc_carthy.html'
        }
	other_staff[6] = {
		'name' : 'Jeremy Maine',
		'post' : 'Financial Controller',
		'image' : '/img/people/people_mugshot/JEREMY_M_mugshot.jpg',
		'page' : '/person/jeremy_maine.html'
        }
	other_staff[7] = {
		'name' : 'John Shannon',
		'post' : 'Designer',
		'image' : '/img/people/people_mugshot/john_mugshot.jpg',
		'page' : '/person/john_shannon.html'
        }
	other_staff[8] = {
		'name' : 'Stuart Manners',
		'post' : 'Lead Developer',
		'image' : '/img/people/people_mugshot/stuart_mugshot.jpg',
		'page' : '/person/stuart_manners.html'
        }
	other_staff[9] = {
		'name' : 'Camilla Yates',
		'post' : 'Account Manager',
		'image' : '/img/people/people_mugshot/camilla_mugshot.jpg',
		'page' : '/person/camilla_yates.html'
        }
	other_staff[10] = {
		'name' : 'Laraine Geddes',
		'post' : 'Senior Account Manager',
		'image' : '/img/people/people_mugshot/laraine_mugshot.jpg',
		'page' : '/person/laraine_geddes.html'
        }
	other_staff[11] = {
		'name' : 'Becky Grover',
		'post' : 'Account Manager',
		'image' : '/img/people/people_mugshot/becky_mugshot.jpg',
		'page' : '/person/becky_grover.html'
        }
	other_staff[12] = {
		'name' : 'Louise Hill',
		'post' : 'PA',
		'image' : '/img/people/people_mugshot/louise_mugshot.jpg',
		'page' : '/person/louise_hill.html'
        }
    other_staff[13] = {
        'name': 'Andrew Prince',
        'post': 'Senior Creative Artworker',
        'image': '/img/people/people_mugshot/andyp_mugshot.jpg',
        'page': '/person/andrew_prince.html'
        }

	/*
  base_staff.shuffle();
  other_staff.shuffle();

  for(var i = 0; i < base_staff.length; i++) {
    var element;
    element  = '<a href="' + base_staff[i].page + '"><img src="' + base_staff[i].image +'" alt="Picture of ' + base_staff[i].name + ',' + base_staff[i].post + ', at Designate creative advertising agency" /></a>';
    element += '<a href="' + base_staff[i].page + '" class="info" title="Picture of ' + base_staff[i].name + ',' + base_staff[i].post + ', at Designate creative advertising agency">';
    element += '<span class="title">' + base_staff[i].name + '</span>';
    element += '<span class="description">' + base_staff[i].post + '</span>';
    element += '</a>';

    var child = $("<li></li>").append(element);

    $(".peopleList").append(child);
  }
  for(var i = 0; i < other_staff.length; i++) {
    var element;
    element  = '<a href="' + other_staff[i].page + '"><img src="' + other_staff[i].image +'" alt="Picture of ' + other_staff[i].name + ',' + other_staff[i].post + ', at Designate creative advertising agency" /></a>';
    element += '<a href="' + other_staff[i].page + '" class="info" title="Picture of ' + other_staff[i].name + ',' + other_staff[i].post + ', at Designate creative advertising agency">';
    element += '<span class="title">' + other_staff[i].name + '</span>';
    element += '<span class="description">' + other_staff[i].post + '</span>';
    element += '</a>';
 
    var child = $("<li></li>").append(element);

    $(".peopleList").append(child);
  }
  */

  staff = base_staff.concat(other_staff);

  staff.shuffle();

  for(var i = 0; i < 12; i++) {
    var element;
    element  = '<a href="' + staff[i].page + '"><img src="' + staff[i].image +'" alt="Picture of ' + staff[i].name + ',' + staff[i].post + ', at Designate creative advertising agency" /></a>';
    element += '<a href="' + staff[i].page + '" class="info" title="Picture of ' + staff[i].name + ',' + staff[i].post + ', at Designate creative advertising agency">';
    element += '<span class="title">' + staff[i].name + '</span>';
    element += '<span class="description">' + staff[i].post + '</span>';
    element += '</a>';
 
    var child = $("<li></li>").append(element);

    $(".peopleList").append(child);
  }

});
