/*
Original copied from http://events.jquery.org/2010/sf-bay-area/
So, give them guys the credit - we just liked the look, and wanted to emulate it.
*/

jQuery(function($){

 $("#headerSponsors ul.sponsors li.photo")
	.nivoSlider(
	{
		effect:'fade',
		directionNav:false,
        directionNavHide:false,
        controlNav:false,
        pauseOnHover:false,
		pauseTime:4000
	});
  $("#adspace-wrapper ul.sponsors li.photo")
    .wrapInner("<div class='slices'></div>")
    .append("<div class='frame'></div>")
    .find("img:not(:first-child)").hide();
  
  $.fn.nivoConfig = function(options){
    return this.nivoSlider($.extend({},{
        effect:'fade',
        slices:10,
        pauseTime:4000,
        directionNav:false, //Next & Prev
        directionNavHide:false, //Only show on hover
        controlNav:false, //1,2,3...
        pauseOnHover:false //Stop animation while hovering
    },options));
  };
  var delay = 1, i_map = { "0":0, "1":1, "2":2, "3":3, "4":4}, slices = $("ul.sponsors li div.slices");
  slices.each(function(i,el){
    window.setTimeout(function(){
      $(slices[i_map[i]]).nivoConfig();
    }, delay);
    delay += 600;
  });
  
});
