(function($){jQuery.fn.gallSlide=function(_options){var _options=jQuery.extend({duration:700,autoSlide:5000},_options);return this.each(function(){var _hold=$(this);var _speed=_options.duration;var _timer=_options.autoSlide;var _wrap=_hold.find("div.holder > ul");var _el=_hold.find("li.fc_carousel_item");var _swicher=_hold.find("div.switcher .switch_page");var _next=_hold.find("a.link-next");var _prev=_hold.find("a.link-prev");var _count=_el.index(_el.filter(":last"));var _w=_el.outerWidth();var _wrapHolderW=Math.ceil(_wrap.parent().width()/_w);var _t;var _active=_swicher.index(_swicher.filter(".active:eq(0)"));if(_active<0){_active=0}_swicher.removeClass("active").eq(_active).addClass("active");_wrap.eq(0).css({marginLeft:-(_w*_active)+"px"});function scrollEl(){_wrap.eq(0).animate({marginLeft:-(_w*_active)+"px"},{queue:false,duration:_speed});_swicher.removeClass("active").eq(_active).addClass("active")}function runTimer(){_t=setInterval(function(){_active++;if(_active>(_count-_wrapHolderW+1)){_active=0}scrollEl()},_timer)}runTimer();_next.click(function(){_active++;if(_t){clearTimeout(_t)}if(_active>(_count-_wrapHolderW+1)){_active=0}scrollEl();runTimer();return false});_prev.click(function(){_active--;if(_t){clearTimeout(_t)}if(_active<0){_active=_count-_wrapHolderW+1}scrollEl();runTimer();return false});_swicher.click(function(){if(_active!=_swicher.index($(this))){_active=_swicher.index($(this));if(_t){clearTimeout(_t)}scrollEl();runTimer()}return false})})};function initToggle(){$("#more_related_merchants").click(function(){if($("#related_list2").css("display")=="none"){$("#related_list2").show("normal");$("#"+this.id+" a").html(" - Less ")}else{$("#related_list2").hide("normal");$("#"+this.id+" a").html(" + More ")}})}$(document).ready(function(){$("div#carousel").gallSlide({duration:700,autoSlide:10000});initToggle()})})(jQuery)
