var scrolltotop={setting:{startline:100,scrollto:0,scrollduration:500,fadeduration:[500,100]},controlHTML:'<a href="#pagetop" title="Scroll Back to Top"></a>',controlattrs:{offsetx:5,offsety:5},anchorkeyword:"#pagetop",state:{isvisible:false,shouldvisible:false},scrollup:function(){this.cssfixedsupport||this.$control.css({opacity:0});var a=isNaN(this.setting.scrollto)?this.setting.scrollto:parseInt(this.setting.scrollto),a=typeof a=="string"&&jQuery("#"+a).length==1?jQuery("#"+a).offset().top:0;this.$body.animate({scrollTop:a},
this.setting.scrollduration)},keepfixed:function(){var a=jQuery(window),b=a.scrollLeft()+a.width()-this.$control.width()-this.controlattrs.offsetx,a=a.scrollTop()+a.height()-this.$control.height()-this.controlattrs.offsety;this.$control.css({left:b+"px",top:a+"px"})},togglecontrol:function(){var a=jQuery(window).scrollTop();this.cssfixedsupport||this.keepfixed();this.state.shouldvisible=a>=this.setting.startline?true:false;if(this.state.shouldvisible&&!this.state.isvisible)this.$control.stop().animate({opacity:1},
this.setting.fadeduration[0]),this.state.isvisible=true;else if(this.state.shouldvisible==false&&this.state.isvisible)this.$control.stop().animate({opacity:0},this.setting.fadeduration[1]),this.state.isvisible=false},init:function(){jQuery(document).ready(function(a){var b=scrolltotop,c=document.all;b.cssfixedsupport=!c||c&&document.compatMode=="CSS1Compat"&&window.XMLHttpRequest;b.$body=window.opera?document.compatMode=="CSS1Compat"?a("html"):a("body"):a("html,body");b.$control=a('<div id="topcontrol">'+
b.controlHTML+"</div>").attr({title:"Scroll Back to Top"}).click(function(){b.scrollup();return false}).appendTo("body");document.all&&!window.XMLHttpRequest&&b.$control.text()!=""&&b.$control.css({width:b.$control.width()});b.togglecontrol();a('a[href="'+b.anchorkeyword+'"]').click(function(){b.scrollup();return false});a(window).bind("scroll resize",function(){b.togglecontrol()})})}};scrolltotop.init();
