
var soc=soc||{};soc.plugins=soc.plugins||{};soc.createPlugin=function(name){jQuery.fn[name]=function(options){var args=Array.prototype.slice.call(arguments,1);if(this.length){return this.each(function(){var instance=jQuery.data(this,name)||jQuery.data(this,name,new soc.plugins[name](this,options)._init());if(typeof options==="string"){options=options.replace(/^_/,"");if(instance[options]){instance[options].apply(instance,args);}}});}
return this;};};(function($){soc.plugins.socCycle=function(ele,options){this.$this=$(ele);this.options=$.extend({},this.defaults,options);};soc.plugins.socCycle.prototype={defaults:{initial:2000,delay:4000,cb:$.noop,controls:"",anispeed:"slow",chWidth:null},_init:function(){var that=this,$that=this.$this,children=$that.children().css({"float":"left",position:"relative"});this.w=this.options.chWidth||children.width();if(this.w===0){if(this.options.initial){this.options.initial=Math.abs(this.options.initial-1000);}
return setTimeout(function(){that._init();},1000);}
this.t=children.length;$that.css({width:this.w,overflow:"hidden",position:"relative"}).wrapInner($('<div class="sc_swrap" style="overflow:hidden;width:9999px;"><div class="sc_swrapi" style="position:relative"></div></div>'));this.iwrap=$that.find(".sc_swrapi");this.ci=0;$that.children(".sc_swrap").width((this.t+1)*this.w);$(children[0]).clone().appendTo(this.iwrap);if(this.options.controls&&$(this.options.controls).length){$(this.options.controls).each(function(i){$(this).click(function(e){that.go(i);e.preventDefault();});});}
if($(".scPrev").length||$(".scNext").length){$(".scNext").appendTo($that).hide().fadeIn('slow');$(".scPrev").prependTo($that).hide().fadeIn('slow');$that.delegate(".scPrev,.scNext",'click',function(e){e.preventDefault();var next=$(this).hasClass("scNext"),going=that.ci;if(going===0&&!next){that.clone=$(children[(that.t-1)]).clone().addClass('clone').hide().prependTo(that.iwrap);that.iwrap.css('left',that.w*-1);that.clone.show();that.ci=1;going=0;}else if(next){going++;}else{going--;}
that._move(going);});}
this.to=setTimeout(function(){that.start();},this.options.initial);return this;},_move:function(i){var l,that=this;if(!i&&isNaN(i)){l="-="+this.w;this.ci++;}else{if(this.ci==i||i<0||i>this.t){return;}
this.stop();l="-"+this.w*i;this.ci=i;}
this.iwrap.animate({left:l+"px"},this.options.anispeed,function(){that.options.cb(that.ci);if(that.ci===0&&that.clone){that.ci=that.t-1;that.iwrap.css("left",that.ci*that.w*-1);that.clone.remove();delete that.clone;}});if(this.ci==this.t){this.iwrap.queue(function(nxt){that.iwrap.css("left",0);that.ci=0;nxt();});}},go:function(i){this._move(i);},start:function(){var that=this;this.ival=setInterval(function(){that._move();},this.options.delay);},stop:function(){this.iwrap.stop(true);clearTimeout(this.to);clearInterval(this.ival);}};soc.createPlugin('socCycle');soc.plugins.socHover=function(ele,options){this.$this=$(ele);this.options=$.extend({},this.defaults,options);};soc.plugins.socHover.prototype={defaults:{cb:$.noop,cls:'',target:'',type:'image'},_init:function(){var cb=this.options.cb;if(this.options.type=='image'){cb=soc.plugins.socHover.imageSrc;window._hcache=[];$('.'+this.options.cls,this.$this).each(function(i,e){var a=$(e),href=a.attr('href'),src=href.split('#')[1];if(!/^http/.test(src)&&!/^media\//.test(src)){src='media/'+src;}
a.attr('href',href.replace(/#.*$/,'')).data('imgsrc',src);window._hcache.push($('<img src="'+src+'" />'));});}
this.$this.delegate('.'+this.options.cls,'hover',this.options,cb);return this;}};soc.plugins.socHover.imageSrc=function(e){if(e.type=='mouseenter'){$(e.data.target).attr('src',$(this).data('imgsrc'));}};soc.createPlugin('socHover');})(jQuery);
