jquery.getpos = function (e) { var l = 0; var t = 0; var w = jquery.intval(jquery.css(e, 'width')); var h = jquery.intval(jquery.css(e, 'height')); var wb = e.offsetwidth; var hb = e.offsetheight; while (e.offsetparent) { l += e.offsetleft + (e.currentstyle ? jquery.intval(e.currentstyle.borderleftwidth) : 0); t += e.offsettop + (e.currentstyle ? jquery.intval(e.currentstyle.bordertopwidth) : 0); e = e.offsetparent; } l += e.offsetleft + (e.currentstyle ? jquery.intval(e.currentstyle.borderleftwidth) : 0); t += e.offsettop + (e.currentstyle ? jquery.intval(e.currentstyle.bordertopwidth) : 0); return { x: l, y: t, w: w, h: h, wb: wb, hb: hb }; }; jquery.getclient = function (e) { if (e) { w = e.clientwidth; h = e.clientheight; } else { w = (window.innerwidth) ? window.innerwidth : (document.documentelement && document.documentelement.clientwidth) ? document.documentelement.clientwidth : document.body.offsetwidth; h = (window.innerheight) ? window.innerheight : (document.documentelement && document.documentelement.clientheight) ? document.documentelement.clientheight : document.body.offsetheight; } return { w: w, h: h }; }; jquery.getscroll = function (e) { if (e) { t = e.scrolltop; l = e.scrollleft; w = e.scrollwidth; h = e.scrollheight; } else { if (document.documentelement && document.documentelement.scrolltop) { t = document.documentelement.scrolltop; l = document.documentelement.scrollleft; w = document.documentelement.scrollwidth; h = document.documentelement.scrollheight; } else if (document.body) { t = document.body.scrolltop; l = document.body.scrollleft; w = document.body.scrollwidth; h = document.body.scrollheight; } } return { t: t, l: l, w: w, h: h }; }; jquery.intval = function (v) { v = parseint(v); return isnan(v) ? 0 : v; }; jquery.fn.scrollto = function (s) { o = jquery.speed(s); return this.each(function () { new jquery.fx.scrollto(this, o); }); }; jquery.fx.scrollto = function (e, o) { var z = this; z.o = o; z.e = e; z.p = jquery.getpos(e); z.s = jquery.getscroll(); z.clear = function () { clearinterval(z.timer); z.timer = null }; z.t = (new date).gettime(); z.step = function () { var t = (new date).gettime(); var p = (t - z.t) / z.o.duration; if (t >= z.o.duration + z.t) { z.clear(); settimeout(function () { z.scroll(z.p.y, z.p.x) }, 13); } else { st = ((-math.cos(p * math.pi) / 2) + 0.5) * (z.p.y - z.s.t) + z.s.t; sl = ((-math.cos(p * math.pi) / 2) + 0.5) * (z.p.x - z.s.l) + z.s.l; z.scroll(st, sl); } }; z.scroll = function (t, l) { window.scrollto(l, t) }; z.timer = setinterval(function () { z.step(); }, 13); };