//Banner img rotator
var BANNER_SLIDER = {};
    BANNER_SLIDER.slider = (function () {
	    var imageWidth = $(".feature_item").width();
	    var imageSum = $("#slider .slides .feature_item").size();
	    var imageReelWidth = imageWidth * imageSum;
	    var $active,play,
		  		$prev = $('#previous'),
		  		$next = $('#next'),
		  		clicked = 'no';

	    function init() {
		    $("#paging").show();
		    $prev.show();
		    $next.show();
		    $("#paging a:first").addClass("active");
		    $("#slider .slides").css({'width' : imageReelWidth});
		    $("#paging a").click(function(e) {    
		        e.preventDefault();
		        $active = $(this);
		        rotate();
		    });
		    $next.click(function(e) {    
		        e.preventDefault();
		        $active = ($('#paging a.active').next().length == 0) ? $('#paging a').first() : $('#paging a.active').next();
		        rotate();
		    });
		    $prev.click(function(e) {    
		        e.preventDefault();
		        $active = ($('#paging a.active').prev().length == 0) ? $('#paging a').last() : $('#paging a.active').prev();
		        rotate();
		    });
	    }
	    	    
	    rotate = function(){    
	        var triggerID = $active.attr("rel") - 1;
	        var image_reelPosition = triggerID * imageWidth;
	        $("#paging a").removeClass('active');
	        $active.addClass('active');
	        $("#slider .slides").stop().animate({
	            left: -image_reelPosition
	        }, 500 );	        
	    };
	    
  return {
    init: init
  };
  
})();    
//end


$(document).ready(function() {
	//Banner img rotator
	if($('html.ie6').length != 1) {	
		if($('#slider .feature_item').length > 1){
			BANNER_SLIDER.slider.init();
		}
	}	   
});
