
/* - ++resource++easySlider.js - */
(function($) {	$.fn.easySlider = function(options){		var defaults = {						prevId: 		'prevBtn',			prevText: 		'&nbsp',			nextId: 		'nextBtn',				nextText: 		'&nbsp',			controlsShow:	true,			controlsBefore:	'',			controlsAfter:	'',				controlsFade:	true,			firstId: 		'firstBtn',			firstText: 		'First',			firstShow:		false,			lastId: 		'lastBtn',				lastText: 		'Last',			lastShow:		false,							vertical:		false,			speed: 			800,			auto:			false,			pause:			2000,			continuous:		false,			goToButtonId:   'goToButton',			goToRotateAmount:8,			effect: 'Slide',			navigation_type: 'Navigation Buttons'		}; 				var options = $.extend(defaults, options);  						this.each(function() {  			var obj = $(this); 							var s = $("li", obj).length;			var w = $("li", obj).width(); 			var h = $("li", obj).height(); 			obj.width(w); 			obj.height(h); 			obj.css("overflow","hidden");			var ts = s-1;			var t = 0;			$("ul", obj).css('width',s*w);						if(!options.vertical) $("li", obj).css('float','left');									//Navigation...			if(options.navigation_type != "No Buttons"){				var html = options.controlsBefore;				if(options.navigation_type == "Navigation Buttons"){				    html += "<div id='easySlider-goToButtons'>";					html += ' <span id="leftb"><a class="leftright" href=\"javascript:void(0);\">'+ options.prevText +'</a></span>';				    for(var i=0; i < ts+1; i++){ 				        html += "<a id=\"" + options.goToButtonId + i + "\" href=\"javascript:void(0);\">" + (i+1) + "</a> ";				    }					html += ' <span id="rightb"><a class="leftright" href=\"javascript:void(0);\">'+ options.nextText +'</a></span>';				    html += "</div>";				}				if(options.firstShow) html += '<span id="'+ options.firstId +'"><a href=\"javascript:void(0);\">'+ options.firstText +'</a></span>';				if(options.navigation_type == "Big Arrows"){				    html += ' <span id="'+ options.prevId +'"><a href=\"javascript:void(0);\">'+ options.prevText +'</a></span>';				    html += ' <span id="'+ options.nextId +'"><a href=\"javascript:void(0);\">'+ options.nextText +'</a></span>';		        }else if(options.navigation_type == "Small Arrows"){		            html += "<div id='smallButtons'>";				    html += ' <span id="'+ options.prevId +'"><a href=\"javascript:void(0);\">'+ options.prevText +'</a></span>';				    html += ' <span id="'+ options.nextId +'"><a href=\"javascript:void(0);\">'+ options.nextText +'</a></span>';		            html += "</div>";		        }				if(options.lastShow) html += ' <span id="'+ options.lastId +'"><a href=\"javascript:void(0);\">'+ options.lastText +'</a></span>';				html += options.controlsAfter;							$(obj).after(html);													};	        //end nav	        			$("a","#"+options.nextId).click(function(){						animate("next",true);			});			$("a","#"+options.prevId).click(function(){						animate("prev",true);							});				$("span#leftb a").click(function(){						animate("prev",true);							});			$("span#rightb a").click(function(){						animate("next",true);							});			$("a","#"+options.firstId).click(function(){						animate("first",true);			});							$("a","#"+options.lastId).click(function(){						animate("last",true);							});				$("div#easySlider-goToButtons a:not(.leftright)").click(function(){			    animate(parseInt($(this).attr('id').substring(options.goToButtonId.length)), true);			});						if(options.navigation_type == "Navigation Buttons") $("#" + options.goToButtonId + "0").addClass('active');						function update_goToButtons(btns){			    if(btns.size() > options.goToRotateAmount){			        var min = Math.max(t - Math.floor(options.goToRotateAmount/2), 0);			        var max = Math.min(t + Math.floor(options.goToRotateAmount/2), btns.size());			        var diff = max - min;			        if(diff != options.goToRotateAmount) min = Math.max(min - (options.goToRotateAmount - diff), 0);			        diff = max - min;			        if(diff != options.goToRotateAmount) max = Math.min(max + (options.goToRotateAmount - diff), btns.size());			        for(var i = 0; i < min; i++) $("#" + options.goToButtonId + i).hide();			        for(var i = min; i < max; i++) $("#" + options.goToButtonId + i).show();			        for(var i = max; i < btns.size(); i++) $("#" + options.goToButtonId + i).hide();			    }			}						update_goToButtons($("div#easySlider-goToButtons a:not(.leftright)"));						function animate(dir,clicked){				var ot = t;								switch(dir){					case "next":						t = (ot>=ts) ? (options.continuous ? 0 : ts) : t+1;												break; 					case "prev":						t = (t<=0) ? (options.continuous ? ts : 0) : t-1;						break; 					case "first":						t = 0;						break; 					case "last":						t = ts;						break; 					default:					    if(typeof(dir) == "number") t = dir;						break; 				};									if(options.navigation_type == "Navigation Buttons"){				    var btns = $("div#easySlider-goToButtons a:not(.leftright)");				    btns.removeClass("active");				    $("#" + options.goToButtonId + t).addClass('active');				    update_goToButtons(btns);				}								var diff = Math.abs(ot-t);				//var speed = diff*options.speed; //don't like this... too slow for lots of slides				var position = (t*w*-1);				if(options.vertical){				    position = (t*h*-1);				}								if(options.effect == "Slide"){				    var speed = (diff*options.speed)/diff;    				if(!options.vertical) {    					$("ul",obj).animate(    						{ marginLeft: position },     						speed    					);				    				} else {    					p = (t*h*-1);    					$("ul",obj).animate(    						{ marginTop: position },     						speed    					);					    				};				}else if(options.effect == "Fade"){				    var margin = "marginLeft";				    if(options.vertical){ margin = "marginTop"; }			        $("ul", obj).fadeOut(Math.ceil(options.speed/2), function(){			            $(this).css(margin, position).fadeIn(Math.ceil(options.speed/2));                    });				}								if(!options.continuous && options.controlsFade){										if(t==ts){						$("a","#"+options.nextId).hide();						$("a","#"+options.lastId).hide();					} else {						$("a","#"+options.nextId).show();						$("a","#"+options.lastId).show();										};					if(t==0){						$("a","#"+options.prevId).hide();						$("a","#"+options.firstId).hide();					} else {						$("a","#"+options.prevId).show();						$("a","#"+options.firstId).show();					};									};												if(clicked) clearTimeout(timeout);				if(options.auto && dir=="next" && !clicked){					timeout = setTimeout(function(){						animate("next",false);					},diff*options.speed+options.pause);				};							};			// init			var timeout;			if(options.auto){;				timeout = setTimeout(function(){					animate("next",false);				},options.pause);			};							if(!options.continuous && options.controlsFade){									$("a","#"+options.prevId).hide();				$("a","#"+options.firstId).hide();							};									});	  	};})(jQuery);

