/*
 Copyright 2010 Jay Kerschner. Originally developed by Jay Kerschner, <jay@venivortex.com>.
 Available under the MIT license.

 ===MIT license===
 Copyright (c) <2010> <Jay Kerschner>

 Permission is hereby granted, free of charge, to any person obtaining a copy
 of this software and associated documentation files (the "Software"), to deal
 in the Software without restriction, including without limitation the rights
 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 copies of the Software, and to permit persons to whom the Software is
 furnished to do so, subject to the following conditions:

 The above copyright notice and this permission notice shall be included in
 all copies or substantial portions of the Software.

 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 THE SOFTWARE.

*/
(function(d){d.fn.rotator=function(p){var a=d.extend({},d.fn.rotator.defaults,p);return this.each(function(k){var o=d(this),l=o.children(),b=false,c=Math.floor(Math.random()*l.length),e=[];if(!o.is("ul")||l.length===0)d.error("jQuery.rotator can only rotate content contained within <ul> tags which contain at least one <li>.");else{switch(a.mode){case "random":b=c;break;case "simplefade":case "crossfade":b=isNaN(a.base_num)?c:parseInt(a.base_num,10)-1;break;case "datetime":c=new Date;c={millisecond:c.getMilliseconds(),
second:c.getSeconds(),minute:c.getMinutes(),hour:c.getHours(),day:c.getDate(),month:c.getMonth(),year:c.getYear()}[a.switch_every];if(!c&&c!==0){d.error('Invalid or missing value for the jQuery.rotator "switch_every" option. Must be one of the following: "millisecond", "second", "minute", "hour", "day", "month", or "year".');b=false}else b=Math.floor(c%l.length);break;case "static":if(isNaN(a.base_num))d.error('When using the "static" mode of jQuery.rotator, the "base_num" option must be set to an integer value.');
else b=parseInt(a.base_num,10)-1;break;default:d.error('Unrecognized mode for jQuery.rotator. Accepted modes are: "random" (default), "simplefade", "crossfade", and "static".')}if(b!==false){l.each(function(g){e[g]=d(this).html()});o.replaceWith("<div class='jquery-rotator-active' style='position:relative;'><div class='jquery-rotator-content' style='margin:0;padding:0;'></div><div class='jquery-rotator-content-temp' style='margin:0;padding:0;'></div></div>");var m=d(".jquery-rotator-active").eq(k),
f=m.children(".jquery-rotator-content"),h=m.children(".jquery-rotator-content-temp"),n=function(g){var i=Math.max(f.height(),h.height()),j=Math.max(f.width(),h.width());g==="slide"?m.animate({height:i,width:j}):m.css({height:i+"px",width:j+"px"})};k={position:"absolute",top:0,left:0};f.html(e[b]).css(k);h.hide().css(k);n("instant");if(a.mode==="simplefade")setInterval(function(){b+=1;if(b>e.length-1)b=0;f.fadeOut(a.fade_time/2,function(){f.html(e[b]).fadeIn(a.fade_time/2);n(a.box_sizechange_mode)})},
a.fade_interval);else a.mode==="crossfade"&&setInterval(function(){var g=false,i=false,j=function(){if(g&&i){f.html(e[b]).show();h.hide();n(a.box_sizechange_mode)}};b+=1;if(b>e.length-1)b=0;h.html(e[b]).fadeIn(a.fade_time,function(){g=true;j()});f.fadeOut(a.fade_time,function(){i=true;j()});n(a.box_sizechange_mode)},a.fade_interval)}else d.error("Invalid value for item number in jQuery.rotator; one or more options may be set incorrectly.")}})};d.fn.rotator.defaults={box_sizechange_mode:"slide",fade_interval:5E3,
fade_time:1E3,mode:"random",switch_every:"day"}})(jQuery);

