/**
 * jQuery Shuffle (http://mktgdept.com/jquery-shuffle)
 * A jQuery plugin for shuffling a set of elements
 *
 * v0.0.1 - 13 November 2009
 *
 * Copyright (c) 2009 Chad Smith (http://twitter.com/chadsmith)
 * Dual licensed under the MIT and GPL licenses.
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.opensource.org/licenses/gpl-license.php
 *
 * Shuffle elements using: $(selector).shuffle() or $.shuffle(selector)
 *
 **/
(function(d){d.fn.shuffle=function(c){c=[];return this.each(function(){c.push(d(this).clone(true))}).each(function(a,b){d(b).replaceWith(c[a=Math.floor(Math.random()*c.length)]);c.splice(a,1)})};d.shuffle=function(a){return d(a).shuffle()}})(jQuery);

var imgnum = 0;

function GetRandom( min, max ) {
        if( min > max ) {
                return( -1 );
        }
        if( min == max ) {
                return( min );
        }
        return( min + parseInt( Math.random() * ( max-min+1 ) ) );
}

function randImages() {
    imgnum++; 
    // stop when last element is reached
    if (imgnum >= jQuery("div.imageset").size()) {             
        imgnum = 0;
    }
    
    jQuery("div.imageset").hide();
    jQuery("div.imgset-"+imgnum).show();
}                  

jQuery(function($) {
    $("div.imageset").hide();   
    $('div.imageset').shuffle();
    $("div.imageset").each(function(n) {
        $(this).addClass("imgset-"+n);
    });   
    randImages();    
    
    if (imgnum < 1) {
        $('a#swapImages').hide();
    }
     
});




