(function($) {// Compliant with jquery.noConflict()
$.fn.jqMovieMister = function(o) {
    o = $.extend({
        speed: 500,
        animation: 'easeOutQuad',
        start: 0,
        scroll: 1
    }, o || {});

    return this.each(function(){
        var div = $(this)//, ul = $("ul", div), tLi = $("li", ul), tl = tLi.size(), v = o.visible;

				var curr = o.start;
				o.atual = o.start;


				// mark : first : item
				// ---------------------------------------------------------------
				$_first = div.find(".pages").find('a:first > img');
				var item = new Number((o.start+1));
				image = "images/numbersUP_"+ item + ".png";
				$_first.attr("src", image)
			

				// pagination : number : click
				// ---------------------------------------------------------------
				o.btnNext = div.find(".pages a");
				var xIndice = $(o.btnNext).click(function(){
					curr = xIndice.index(this);
					var itemAtual = o.atual;
					if( itemAtual == curr) return false;

					var movimentoBase = 566;
					var movimento = 0;

					itemAtual	= new Number(itemAtual);
					curr	= new Number(curr);
					if(curr > itemAtual){
						var resto = (curr - itemAtual);
						movimento = (movimentoBase * resto);
						div.find(".boxer").animate({ "top": "-="+ (movimento) +"px" },{duration: o.speed, easing: o.animation})
					} else {
						var resto = (itemAtual - curr);
						movimento = (movimentoBase * resto);
						div.find(".boxer").animate({ "top": "+="+ (movimento) +"px" },{duration: o.speed, easing: o.animation})
					}
					o.atual = curr;
					$(this).css({outline:0});
					clearPageNumber();
					
					return false;
        });


				// pagination : number : mouseover
				// ---------------------------------------------------------------
				var $aOver = div.find(".pages").find('a > img').mouseover(function() {
					indice = $aOver.index(this);
					if(o.atual == indice) return false;
					indexImg = (indice+1);
					imgOver = "images/numbersUP_"+ indexImg + ".png";
					$(this).attr("src", imgOver);
					$(this).css({ opacity: 0, 
						"-ms-filter":"progid:DXImageTransform.Microsoft.Alpha(Opacity=0)",
						"filter":"alpha(opacity=0)"
					})
					.animate( {opacity:1.0,
						"-ms-filter":"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)",
						"filter":"alpha(opacity=100)"
					}, 300, function() {
						// fix IE ClearType bug
						if($.browser.msie) {
							$(this).css( 'opacity', '' );
							this.style.removeAttribute('filter');
						}
					});
					return false;
				});


				// pagination : number : mouseout
				// ---------------------------------------------------------------
				var $aOut =  div.find(".pages").find('a > img').mouseout(function() {
					indice = $aOut.index(this);
					if(o.atual == indice) return false;
					indexImg = (indice+1);
					imgOut = "images/numbers_"+ indexImg + ".png";
					$(this).attr("src", imgOut)
					$(this).css({ opacity: 0,
						"-ms-filter":"progid:DXImageTransform.Microsoft.Alpha(Opacity=0)",
						"filter":"alpha(opacity=0)"							
					})
					.animate({ opacity: 1,
						"-ms-filter":"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)",
						"filter":"alpha(opacity=100)"
					}, 300, function() {
						// fix IE ClearType bug
						if($.browser.msie) {
							$(this).css( 'opacity', '' );
							this.style.removeAttribute('filter');
						}
					});
					return false;
				});


				// clear : pagination : numbers
				// ---------------------------------------------------------------
				function clearPageNumber(){
					div.find(".pages").find('a > img').each(function(indice){
						if(o.atual != indice){
							var item = new Number((indice+1));
							image = "images/numbers_"+ item + ".png";
							$(this).attr("src", image)
						}
					});
				}


    });// this.each
};
})(jQuery);
