var testimonials = [
	['<img src="http://www.olathe.org/images/testimonials/CharMcCallum.gif" width="79" height="128" border="0">', 'http://www.olathe.org/testimonials/char_maccallum.html'],
	['<img src="http://www.olathe.org/images/testimonials/CraigEymann.gif" width="79" height="128" border="0">', 'http://www.olathe.org/testimonials/craig_eymann.html'],
	['<img src="http://www.olathe.org/images/testimonials/DanRichardson.gif" width="79" height="128" border="0">', 'http://www.olathe.org/testimonials/dan_richardson.html'],
	['<img src="http://www.olathe.org/images/testimonials/DickMellinger.gif" width="79" height="128" border="0">', 'http://www.olathe.org/testimonials/dick_mellinger.html'],
	['<img src="http://www.olathe.org/images/testimonials/DyceBonham.gif" width="79" height="128" border="0">', 'http://www.olathe.org/testimonials/dyce_bonham.html'],
	['<img src="http://www.olathe.org/images/testimonials/EdwinRobinson.gif" width="79" height="128" border="0">', 'http://www.olathe.org/testimonials/ed_robinson.html'],
	['<img src="http://www.olathe.org/images/testimonials/MichelleGresselle.gif" width="79" height="128" border="0">', 'http://www.olathe.org/testimonials/michelle_gressel.html'],
	['<img src="http://www.olathe.org/images/testimonials/RonRyckman.gif" width="79" height="128" border="0">', 'http://www.olathe.org/testimonials/ron_ryckman.html'],
	['<img src="http://www.olathe.org/images/testimonials/MichaelCopeland.gif" width="79" height="128" border="0">', 'http://www.olathe.org/testimonials/michael_copeland.html'],
	['<img src="http://www.olathe.org/images/testimonials/KarenMills.gif" width="79" height="128" border="0">', 'http://www.olathe.org/testimonials/karen_mills.html']
];

$(document).ready(function(){
	/* grab a couple of random testimonials from the collection */
	var tests = array_rand(testimonials, 6);
	
	/* display the testimonials */
	var list = '';
	for (var i=0;i<tests.length;i++) {
		list += '<li rel="'+tests[i]+'">'+testimonials[tests[i]][0]+'</li>';
	}
	$('#testimonials').html('<ul id="list">'+list+'</ul>');
	
	/* attach the events */
	$('#list > li').mouseover(function(i){
		var file = testimonials[$(this).attr('rel')][1];
		$('#test_content').load(file);
	});
});

function array_rand(input, num_req) {
    var indexes = [];
    var ticks = num_req || 1;
    var checkDuplicate = function ( input, value ) {
        var exist = false, index = 0;
        while ( index < input.length ) {
            if ( input [ index ] === value ) {
                exist = true;
                break;
            }
            index++;
        }
        return exist;
    };

    if ( input instanceof Array && ticks <= input.length ) {
        while ( true ) {
            var rand = Math.floor( ( Math.random( ) * input.length ) );
            if ( indexes.length === ticks ) { break; }
            if ( !checkDuplicate( indexes, rand ) ) { indexes.push( rand ); }
        }
    } else {
        indexes = null;
    }

    return ( ( ticks == 1 ) ? indexes.join( ) : indexes );
}
