(function($){

	$.fn.fgxStoreFocus = function(options){

		
		var opts = $.fn.extend({}, $.fn.fgxStoreFocus.defaults, options);
		var count = 1;
		
		return this.each(function(){
		
			$this = $(this);
			$this.attr("id","fgxStoreFocus" + count);
			$this.find(opts.prevButton).attr("id","prev" + count);
			$this.find(opts.nextButton).attr("id","next" + count);
		
			
			$(opts.focusArea + ":eq("+(count-1)+")").cycle({
				 	fx: opts.fx,
					prev: "#prev" + count,
					next: "#next" + count,
					timeout: opts.timeout,
					speed: opts.speed,
					pager:  opts.controls + " div", 
					easing: 'easeOutQuad',
					before:  function(currSlideElement, nextSlideElement, options, forwardFlag){
						//alert($(nextSlideElement).attr("title"));
						//alert(options.toSource());
						if(opts.showTitle ){
							//alert(options.toSource());
							//var slideCount = options.currSlide;
							//alert(options.currSlide + ">>" + options.nextSlide);
							//slideCount = slideCount + 1;
							//$(opts.title).html($(nextSlideElement).attr("title") + "&nbsp;&nbsp;&nbsp;" + slideCount + "/" + options.slideCount);
							$(opts.title).html($(nextSlideElement).attr("title"));
						}//if
					}
				  });	
			
			$this.find(opts.pauseButton).click(function(){
				
				if($(this).hasClass("paused")){
					$this.find(opts.focusArea).cycle("resume",true);
					$(this).removeClass("paused");
				}else{
					$this.find(opts.focusArea).cycle("pause");
					$(this).addClass("paused");
				}
				
			});
			count++;
		});
	
	};//fgxStoreFocus
	
	$.fn.fgxStoreFocus.makeEditable = function(map_x,map_y,alertOnDrop){
		
	};
		
  $.fn.fgxStoreFocus.defaults = {
		  controls: ".galleryControls",
		  prevButton: ".prev",
		  nextButton: ".next",
		  pauseButton: ".pause",			  
		  focusArea: ".imageHolder",
		  coverImg: ".galleryImg",
		  width: 412,
		  height: 471,
		  timeout: 5000,
		  speed: 1500,
		  fx: "scrollLeft"
  };//defaults

	
})(jQuery);

