(function($) {
	$.fn.thairaSlider = function (options) {
		// default configuration properties
		var defaults = {
			prevId: 		'prevBtn',
			prevText: 		' ',
			nextId: 		'nextBtn',	
			nextText: 		' '
		}

		options = $.extend(defaults, options);

		return this.each(function() {
			var current = null;
			var prevA = null;
			var nextA = null;
			
			function selectPrev(e) {
				var prev = current.prev();
				current.css('display', 'none');
				prev.css('display', 'block');
				current = prev;
				tooggleButtons();
			}
			
			function selectNext(e) {
				var next = current.next();
				current.css('display', 'none');
				next.css('display', 'block');
				current = next;
				tooggleButtons();
			}
			
			function tooggleButtons() {
				var hasPrev = $(current).prev().get(0);
				var hasNext = $(current).next().get(0);
				if (hasPrev) {
					prevA.css('display', 'inline');
				} else {
					prevA.css('display', 'none');
				}
				if (hasNext) {
					nextA.css('display', 'inline');
				} else {
					nextA.css('display', 'none');
				}
			}
			
			obj = $(this);
			
			// Create the buttons
			obj.after('<span id="'+ options.prevId +'">'
					+ '<a class="png" href="javascript:void(0);">'
					+ options.prevText + '</a></span> <span id="'
					+ options.nextId + '"><a class="png" href="javascript:void(0);">'
					+ options.nextText + '</a></span>');
			
			// Bind functions to buttons
			prevA = $('a', '#' + options.prevId);
			nextA = $('a', '#' + options.nextId);
			prevA.click(selectPrev);
			nextA.click(selectNext);
			
			// Hide other li except the first one
			obj.find('li').css('display', 'none').css('float','left');
			current = obj.find('li:first');
			current.css('display', 'block');
			
			tooggleButtons();
		});
	}
})(jQuery);