/* * Changebox - jQuery plugin * * vytvori box s prepinanim polozek * * autor: Daniel Repa * * verze: 1.1 (23/08/2010) * vyzaduje: jQuery v1.4+ */(function($) {	function RelatedItems(node,options) {		this.defaults = {			'prev_button'			: false, // Předchozí			'next_button'			: false, // Následující			'counter'				: false // Počítadlo ve tvaru 5/10		};		this.options = $.extend({},this.defaults,options);		this.node = node;		this.index = 1;		this.count = 0;	};	$.extend(RelatedItems.prototype, {		init: function() {			var thisObj = this;			var node = this.node;			// Definice akce pro klinutí na předchozí			if(this.options.prev_button)			{				$(this.options.prev_button).click(function(){					if(!$(this).hasClass("nohover"))					{						node.cycle('prev');													thisObj.index--;						if(thisObj.index < 1)							thisObj.index = thisObj.count;						thisObj.navigationSetup();					}				});			}						//Definice akce pro kliknutí na další			if(this.options.next_button)			{				$(this.options.next_button).click(function(){					if(!$(this).hasClass("nohover"))					{						node.cycle('next');												thisObj.index++;						if(thisObj.index > thisObj.count)							thisObj.index = 1;						thisObj.navigationSetup();					}				});			}						// Inicializace cycle			node.cycle({				fx:		'scrollHorz',				timeout: 0,				pause: 1,				startingSlide: 0			});			this.count = node.children().length;			thisObj.navigationSetup();		},		navigationSetup: function(direction) {			var thisObj = this;						// Následující			if(thisObj.index >= thisObj.count)				$(this.options.next_button).addClass("nohover");			else				$(this.options.next_button).removeClass("nohover");							// Předchozí			if(thisObj.index <= 1)				$(this.options.prev_button).addClass("nohover");			else				$(this.options.prev_button).removeClass("nohover");							if(this.options.counter)			{				$(this.options.counter).text(thisObj.index + "/" + thisObj.count);			}		}	});	$.fn.related_items = function(options) {		var related_items = null;		return this.each(function(){			related_items = new RelatedItems($(this),options);			related_items.init();		});	}})(jQuery);
