/* header_cat */
$(document).ready(function(){getBodyID=$('#header').attr('class');$('ul.catnav li').each(function(){getNavClass=$(this).attr('class');if(getNavClass==getBodyID){$(this).addClass('active')}});$('ul.catnav > li').hover(function(){$('ul.catnav li').removeClass('active');$(this).addClass('active')},function(){$('ul.catnav li').removeClass('active');$('ul.catnav li').each(function(){getNavClass=$(this).attr('class');if(getNavClass==getBodyID){$(this).addClass('active')}})});});

/* scroll-sidebar */
$(document).ready(function(){if($(".sidebar-l").length>0){var g=$('.sidebar-l').offset().top-parseFloat($('.sidebar-l').css('marginTop').replace(/auto/,0));$(window).scroll(function(a){var y=$(this).scrollTop();if(y>=g){$('.sidebar-l').addClass('fixed-l');$('.scrollbox .backtop').show()}else{$('.sidebar-l').removeClass('fixed-l');$('.scrollbox .backtop').hide()}})}if($(".sidebar-r").length>0){var g=$('.sidebar-r').offset().top-parseFloat($('.sidebar-r').css('marginTop').replace(/auto/,0));$(window).scroll(function(a){var y=$(this).scrollTop();if(y>=g){$('.sidebar-r').addClass('fixed-r');$('.scrollbox .backtop').show()}else{$('.sidebar-r').removeClass('fixed-r');$('.scrollbox .backtop').hide()}})}});

/* scroll_up_down */
jQuery(document).ready(function($){$(window).scroll(function (){$(".maxUpdown1").animate({top:$(window).scrollTop()+230+"px"},{queue:false,duration:500});$(".maxUpdown2").animate({top:$(window).scrollTop()+230+"px"},{queue:false,duration:500});return false;});$('.maxUp1').click(function(){$('html,body').animate({scrollTop: '0px'}, 800);});$('.maxDown1').click(function(){$('html,body').animate({scrollTop:$('#maxFooter').offset().top},800);});$('.maxUp2').click(function(){window.open('/wp-login.php');});});

/* lazy_load */
(function($){$.fn.lazyload=function(options){var settings={threshold:0,failurelimit:0,event:"scroll",effect:"show",container:window};if(options){$.extend(settings,options);}var elements=this;if("scroll"==settings.event){$(settings.container).bind("scroll",function(event){var counter=0;elements.each(function(){if($.abovethetop(this,settings)||$.leftofbegin(this,settings)){}else if(!$.belowthefold(this,settings)&&!$.rightoffold(this,settings)){$(this).trigger("appear");}else{if(counter++>settings.failurelimit){return false;}}});var temp=$.grep(elements,function(element){return!element.loaded;});elements=$(temp);});}this.each(function(){var self=this;if(undefined==$(self).attr("original")){$(self).attr("original",$(self).attr("src"));}if("scroll"!=settings.event||undefined==$(self).attr("src")||settings.placeholder==$(self).attr("src")||($.abovethetop(self,settings)||$.leftofbegin(self,settings)||$.belowthefold(self,settings)||$.rightoffold(self,settings))){if(settings.placeholder){$(self).attr("src",settings.placeholder);}else{$(self).removeAttr("src");}self.loaded=false;}else{self.loaded=true;}$(self).one("appear",function(){if(!this.loaded){$("<img />").bind("load",function(){$(self).hide().attr("src",$(self).attr("original"))[settings.effect](settings.effectspeed);self.loaded=true;}).attr("src",$(self).attr("original"));};});if("scroll"!=settings.event){$(self).bind(settings.event,function(event){if(!self.loaded){$(self).trigger("appear");}});}});$(settings.container).trigger(settings.event);return this;};$.belowthefold=function(element,settings){if(settings.container===undefined||settings.container===window){var fold=$(window).height()+$(window).scrollTop();}else{var fold=$(settings.container).offset().top+$(settings.container).height();}return fold<=$(element).offset().top-settings.threshold;};$.rightoffold=function(element,settings){if(settings.container===undefined||settings.container===window){var fold=$(window).width()+$(window).scrollLeft();}else{var fold=$(settings.container).offset().left+$(settings.container).width();}return fold<=$(element).offset().left-settings.threshold;};$.abovethetop=function(element,settings){if(settings.container===undefined||settings.container===window){var fold=$(window).scrollTop();}else{var fold=$(settings.container).offset().top;}return fold>=$(element).offset().top+settings.threshold+$(element).height();};$.leftofbegin=function(element,settings){if(settings.container===undefined||settings.container===window){var fold=$(window).scrollLeft();}else{var fold=$(settings.container).offset().left;}return fold>=$(element).offset().left+settings.threshold+$(element).width();};$.extend($.expr[':'],{"below-the-fold":"$.belowthefold(a, {threshold : 0, container: window})","above-the-fold":"!$.belowthefold(a, {threshold : 0, container: window})","right-of-fold":"$.rightoffold(a, {threshold : 0, container: window})","left-of-fold":"!$.rightoffold(a, {threshold : 0, container: window})"});})(jQuery);$(document).ready(function(){$("#content img").lazyload({placeholder:"images/gray.png",effect:"fadeIn"});$('.comment_body').hover(function() {$(this).find('.commentmetadata').stop(true,true).show();},function() {$(this).find('.commentmetadata').stop(true,true).show();});});

/* share_buttons */
function shareto(id){var url=encodeURIComponent(document.location.href);var title=encodeURIComponent(document.title);if(id=="fav"){addBookmark(document.title);return;}else if(id=="qzone"){window.open('http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url='+url);return;}else if(id=="sina"){window.open("http://v.t.sina.com.cn/share/share.php?url="+url+"&appkey=610475664&title="+title+"&pic=","_blank","width=615,height=505");return;}else if(id=="baidu"){window.open('http://cang.baidu.com/do/add?it='+title+'&iu='+url+'&fr=ien#nw=1','_blank','scrollbars=no,width=600,height=450,left=75,top=20,status=no,resizable=yes');return;}else if(id=="douban"){var d=document,e=encodeURIComponent,s1=window.getSelection,s2=d.getSelection,s3=d.selection,s=s1?s1():s2?s2():s3?s3.createRange().text:'',r='http://www.douban.com/recommend/?url='+e(d.location.href)+'&title='+e(d.title)+'&sel='+e(s)+'&v=1',x=function(){if(!window.open(r,'douban','toolbar=0,resizable=1,scrollbars=yes,status=1,width=450,height=330'))location.href=r+'&r=1'};if(/Firefox/.test(navigator.userAgent)){setTimeout(x,0)}else{x()}return;}else if(id=="renren"){window.open('http://www.connect.renren.com/share/sharer?url='+url+'&title='+title,'_blank');}else if(id=="xianguo"){window.open('http://xianguo.com/service/submitdigg/?link='+url+'&title='+title,'_blank');}}

/* mouse_wheel */
(function($){$.fn.extend({mousewheel:function(f){if(!f.guid)f.guid=$.event.guid++;if(!$.event._mwCache)$.event._mwCache=[];return this.each(function(){if(this._mwHandlers)return this._mwHandlers.push(f);else this._mwHandlers=[];this._mwHandlers.push(f);var s=this;this._mwHandler=function(e){e=$.event.fix(e||window.event);$.extend(e,this._mwCursorPos||{});var delta=0,returnValue=true;if(e.wheelDelta)delta=e.wheelDelta/120;if(e.detail)delta=-e.detail/3;if(window.opera)delta=-e.wheelDelta;for(var i=0;i<s._mwHandlers.length;i++)if(s._mwHandlers[i])if(s._mwHandlers[i].call(s,e,delta)===false){returnValue=false;e.preventDefault();e.stopPropagation();}return returnValue;};if($.browser.mozilla&&!this._mwFixCursorPos){this._mwFixCursorPos=function(e){this._mwCursorPos={pageX:e.pageX,pageY:e.pageY,clientX:e.clientX,clientY:e.clientY};};$(this).bind('mousemove',this._mwFixCursorPos);}if(this.addEventListener)if($.browser.mozilla)this.addEventListener('DOMMouseScroll',this._mwHandler,false);else this.addEventListener('mousewheel',this._mwHandler,false);else this.onmousewheel=this._mwHandler;$.event._mwCache.push($(this));});},unmousewheel:function(f){return this.each(function(){if(f&&this._mwHandlers){for(var i=0;i<this._mwHandlers.length;i++)if(this._mwHandlers[i]&&this._mwHandlers[i].guid==f.guid)delete this._mwHandlers[i];}else{if($.browser.mozilla&&!this._mwFixCursorPos)$(this).unbind('mousemove',this._mwFixCursorPos);if(this.addEventListener)if($.browser.mozilla)this.removeEventListener('DOMMouseScroll',this._mwHandler,false);else this.removeEventListener('mousewheel',this._mwHandler,false);else this.onmousewheel=null;this._mwHandlers=this._mwHandler=this._mwFixCursorPos=this._mwCursorPos=null;}});}});$(window).one('unload',function(){var els=$.event._mwCache||[];for(var i=0;i<els.length;i++)els[i].unmousewheel();});})(jQuery);

/* auto_slider */
(function($){$.fn.jCarouselLite=function(o){o=$.extend({btnPrev:null,btnNext:null,btnGo:null,mouseWheel:false,auto:null,speed:200,easing:null,vertical:false,circular:true,visible:3,start:0,scroll:1,beforeStart:null,afterEnd:null},o||{});return this.each(function(){var b=false,animCss=o.vertical?"top":"left",sizeCss=o.vertical?"height":"width";var c=$(this),ul=$("ul",c),tLi=$("li",ul),tl=tLi.size(),v=o.visible;if(o.circular){ul.prepend(tLi.slice(tl-v-1+1).clone()).append(tLi.slice(0,v).clone());o.start+=v}var f=$("li",ul),itemLength=f.size(),curr=o.start;c.css("visibility","visible");f.css({overflow:"hidden",float:o.vertical?"none":"left"});ul.css({margin:"0",padding:"0",position:"relative","list-style-type":"none","z-index":"1"});c.css({overflow:"hidden",position:"relative","z-index":"2",left:"0px"});var g=o.vertical?height(f):width(f);var h=g*itemLength;var j=g*v;f.css({width:f.width(),height:f.height()});ul.css(sizeCss,h+"px").css(animCss,-(curr*g));c.css(sizeCss,j+"px");if(o.btnPrev)$(o.btnPrev).click(function(){return go(curr-o.scroll)});if(o.btnNext)$(o.btnNext).click(function(){return go(curr+o.scroll)});if(o.btnGo)$.each(o.btnGo,function(i,a){$(a).click(function(){return go(o.circular?o.visible+i:i)})});if(o.mouseWheel&&c.mousewheel)c.mousewheel(function(e,d){return d>0?go(curr-o.scroll):go(curr+o.scroll)});if(o.auto)setInterval(function(){go(curr+o.scroll)},o.auto+o.speed);function vis(){return f.slice(curr).slice(0,v)};function go(a){if(!b){if(o.beforeStart)o.beforeStart.call(this,vis());if(o.circular){if(a<=o.start-v-1){ul.css(animCss,-((itemLength-(v*2))*g)+"px");curr=a==o.start-v-1?itemLength-(v*2)-1:itemLength-(v*2)-o.scroll}else if(a>=itemLength-v+1){ul.css(animCss,-((v)*g)+"px");curr=a==itemLength-v+1?v+1:v+o.scroll}else curr=a}else{if(a<0||a>itemLength-v)return;else curr=a}b=true;ul.animate(animCss=="left"?{left:-(curr*g)}:{top:-(curr*g)},o.speed,o.easing,function(){if(o.afterEnd)o.afterEnd.call(this,vis());b=false});if(!o.circular){$(o.btnPrev+","+o.btnNext).removeClass("disabled");$((curr-o.scroll<0&&o.btnPrev)||(curr+o.scroll>itemLength-v&&o.btnNext)||[]).addClass("disabled")}}return false}})};function css(a,b){return parseInt($.css(a[0],b))||0};function width(a){return a[0].offsetWidth+css(a,'marginLeft')+css(a,'marginRight')};function height(a){return a[0].offsetHeight+css(a,'marginTop')+css(a,'marginBottom')}})(jQuery);	

/* max_slider */
var slider = function(){function getElementsByClass(object, tag, className) {var o = object.getElementsByTagName(tag);for ( var i = 0, n = o.length, ret = []; i < n; i++) {if (o[i].className == className) ret.push(o[i]);}if (ret.length == 1) ret = ret[0];return ret;}function setOpacity (obj,o) {
if (obj.filters) obj.filters.alpha.opacity = Math.round(o);else obj.style.opacity = o / 100;}function Slider(oCont, speed, iW, iH, oP){this.slides=[];this.over=false;this.S=this.S0 = speed;
this.iW=iW;this.iH=iH;this.oP= oP;this.oc=document.getElementById(oCont);this.frm=getElementsByClass(this.oc, 'div', 'slide');this.NF=this.frm.length;this.resize();for (var i = 0; i < this.NF; i++){this.slides[i] = new Slide(this, i);}
this.oc.parent = this;this.view= this.slides[0];this.Z= this.mx;this.oc.onmouseout = function () {this.parent.mouseout();return false;}}Slider.prototype = {run : function () {this.Z += this.over ? (this.mn - this.Z) * .5 : (this.mx - this.Z) * .5;this.view.calc();var i = this.NF;
while (i--) this.slides[i].move();},resize : function (){this.wh = this.oc.clientWidth;this.ht = this.oc.clientHeight;this.wr = this.wh * this.iW;this.r  = this.ht / this.wr;this.mx = this.wh / this.NF;this.mn = (this.wh * (1 - this.iW)) / (this.NF - 1);},mouseout : function () {this.over= false;setOpacity(this.view.img, this.oP);}}
Slide = function (parent, N) {this.parent = parent;this.N = N;this.x0 = this.x1 = N * parent.mx;this.v = 0;this.loaded = false;this.cpt= 0;this.start= new Date();this.obj= parent.frm[N];this.txt    = getElementsByClass(this.obj, 'div', 'text');this.img    = getElementsByClass(this.obj, 'img', 'diapo');this.bkg    = document.createElement('div');this.bkg.className = 'backgroundText';this.obj.insertBefore(this.bkg, this.txt);if (N == 0) this.obj.style.borderLeft = 'none';this.obj.style.left = Math.floor(this.x0) + 'px';setOpacity(this.img, parent.oP);this.obj.parent = this;this.obj.onmouseover = function() {this.parent.over();return false;}}
Slide.prototype = {calc : function() {var that = this.parent;for (var i = 0; i <= this.N; i++) {that.slides[i].x1 = i * that.Z;}for (var i = this.N + 1; i < that.NF; i++) {that.slides[i].x1 = that.wh - (that.NF - i) * that.Z;}},move : function() {var that = this.parent;var s = (this.x1 - this.x0) / that.S;if (this.N && Math.abs(s) > .5) {this.obj.style.left = Math.floor(this.x0 += s) + 'px';}var v = (this.N < that.NF - 1) ? that.slides[this.N + 1].x0 - this.x0 : that.wh - this.x0;if (Math.abs(v - this.v) > .5) {this.bkg.style.top = this.txt.style.top = Math.floor(2 + that.ht - (v - that.Z) * that.iH * that.r) + 'px';this.v = v;this.cpt++;} else {if (!this.pro) {this.pro = true;var tps = new Date() - this.start;if(this.cpt > 1) {that.S = Math.max(2, (28 / (tps / this.cpt)) * that.S0);}}}if (!this.loaded) {if (this.img.complete) {this.img.style.visibility = 'visible';this.loaded = true;}}},over : function () {this.parent.resize();this.parent.over = true;setOpacity(this.parent.view.img, this.parent.oP);this.parent.view = this;this.start = new Date();this.cpt = 0;this.pro = false;this.calc();setOpacity(this.img, 100);}} 
return {init : function() {this.s1 = new Slider("slider", 12, 1.84/3, 1/3.2, 70);setInterval("slider.s1.run();", 16);}}}();

$(function(){setTimeout(function(){$(".ssliderBody_l1").jCarouselLite({mouseWheel: true,visible: 1,scroll:1,speed: 750,auto:10000});},500);setTimeout(function(){$(".ssliderBody_l2").jCarouselLite({mouseWheel: true,visible: 1,scroll:1,speed: 750,auto:10000});},500);setTimeout(function(){$(".ssliderBody_r1").jCarouselLite({mouseWheel: true,visible: 1,scroll:1,speed: 750,auto:10000});},500);setTimeout(function(){$(".ssliderBody_r2").jCarouselLite({mouseWheel: true,visible: 1,scroll:1,speed: 750,auto:10000});},500);});
