(function($){
  $.fn.shuffle = function() {
    return this.each(function(){
      var items = $(this).children();
      return (items.length)
        ? $(this).html($.shuffle(items))
        : this;
    });
  }
 
  $.shuffle = function(arr) {
    for(
      var j, x, i = arr.length; i;
      j = parseInt(Math.random() * i),
      x = arr[--i], arr[i] = arr[j], arr[j] = x
    );
    return arr;
  }
})(jQuery);

	//This function requires JQuery
	function createSpotlight(Spot)
		{
			Spot = $.shuffle(Spot);
			var soonerLawSpotlight;
			var li,a,img;
			if (typeof(Spot) == "object")
				{
					var num = Spot.length;
					for (x = 0; x < num; x++)
						{
							if (x ==1)
								{
								li = $("<li></li>").css({'display':'', 'overflow':'hidden'});
								}
							else
								{	
								li = $("<li></li>").css({'display':'none', 'overflow':'hidden'});
								}								
							a = $("<a></a>").attr({href:Spot[x][1]});
							img = $("<img>").attr({alt:Spot[x][1],src:Spot[x][2]});
							$(a).append(img);
							$(li).append(a);
							$("#soonerlawspotlight").append(li);
							
						}
				}
		}
	var spotlights = [["Emily Wilson", "http://www.law.ou.edu/spotlight/wilson.shtml", "http://www.law.ou.edu/spotlight/img/wilson1.jpg"],["Charlie Wolfe", "http://www.law.ou.edu/spotlight/wolfe.shtml", "http://www.law.ou.edu/spotlight/img/wolfe1.jpg"],["Christopher Staine","http://www.law.ou.edu/spotlight/staine.shtml","http://www.law.ou.edu/spotlight/img/staine1.jpg"],["Lindy Hawes Collins","http://www.law.ou.edu/spotlight/collins.shtml","http://www.law.ou.edu/spotlight/img/collins1.jpg"],["Michael Brooks","http://www.law.ou.edu/spotlight/brooks.shtml", "http://www.law.ou.edu/spotlight/img/brooks1.jpg"],["Jonathan Forman","http://www.law.ou.edu/spotlight/forman.shtml","http://www.law.ou.edu/spotlight/img/forman.jpg"],["Nathan Aduddell","http://www.law.ou.edu/spotlight/aduddell.shtml","http://www.law.ou.edu/spotlight/img/aduddell1.jpg"]];
	
	
	
	//
	$(function(){
			$('#soonerlawspotlight').hide();
			createSpotlight(spotlights);
		 	$('#soonerlawspotlight noscript').remove();
			$('#soonerlawspotlight').cycle({fx:'fade',random:1,speed:1500,timeout:5000,delay:-2000});
			$('#soonerlawspotlight').show(); 
			
		});