document.write("") document.write("
") document.write("
") document.write("
")var slide_gid = function (id) { return "string" == typeof id ? document.getelementbyid(id) : id; }; var slideclass = { create: function() { return function() { this.initialize.apply(this, arguments); } } }var slideobjectextend = function(destination, source) { for (var property in source) { destination[property] = source[property]; } return destination; }var transformview = slideclass.create(); transformview.prototype = { //容器对象,滑动对象,切换参数,切换数量 initialize: function(container, slider, parameter, count, options) { if(parameter <= 0 || count <= 0) return; var ocontainer = slide_gid(container), oslider = slide_gid(slider), othis = this; this.index = 0;//当前索引 this._timer = null;//定时器 this._slider = oslider;//滑动对象 this._parameter = parameter;//切换参数 this._count = count || 0;//切换数量 this._target = 0;//目标参数 this.setoptions(options); this.up = !!this.options.up; this.step = math.abs(this.options.step); this.time = math.abs(this.options.time); this.auto = !!this.options.auto; this.pause = math.abs(this.options.pause); this.onstart = this.options.onstart; this.onfinish = this.options.onfinish; ocontainer.style.overflow = "hidden"; ocontainer.style.position = "relative"; oslider.style.position = "absolute"; oslider.style.top = oslider.style.left = 0; }, //设置默认属性 setoptions: function(options) { this.options = {//默认值 up: true,//是否向上(否则向左) step: 5,//滑动变化率 time: 10,//滑动延时 auto: true,//是否自动转换 pause: 2000,//停顿时间(auto为true时有效) onstart: function(){},//开始转换时执行 onfinish: function(){}//完成转换时执行 }; slideobjectextend(this.options, options || {}); }, //开始切换设置 start: function() { if(this.index < 0){ this.index = this._count - 1; } else if (this.index >= this._count){ this.index = 0; } this._target = -1 * this._parameter * this.index; this.onstart(); this.move(); }, //移动 move: function() { cleartimeout(this._timer); var othis = this, style = this.up ? "top" : "left", inow = parseint(this._slider.style[style]) || 0, istep = this.getstep(this._target, inow); if (istep != 0) { this._slider.style[style] = (inow + istep) + "px"; this._timer = settimeout(function(){ othis.move(); }, this.time); } else { this._slider.style[style] = this._target + "px"; this.onfinish(); if (this.auto) { this._timer = settimeout(function(){ othis.index++; othis.start(); }, this.pause); } } }, //获取步长 getstep: function(itarget, inow) { var istep = (itarget - inow) / this.step; if (istep == 0) return 0; if (math.abs(istep) < 1) return (istep > 0 ? 1 : -1); return istep; }, //停止 stop: function(itarget, inow) { cleartimeout(this._timer); this._slider.style[this.up ? "top" : "left"] = this._target + "px"; } };slashfixbug=function(){ function each(list, fun){ for (var i = 0, len = list.length; i < len; i++) { fun(list[i], i); } }; var objs = slide_gid("idnumtheme").getelementsbytagname("li"); var tv = new transformview("idtransformviewtheme", "idslidertheme", 246, objs.length, { onstart : function(){ each(objs, function(o, i){ o.classname = tv.index == i ? "on" : ""; }) }//按钮样式 }); tv.start(); each(objs, function(o, i){ o.onmouseover = function(){ o.classname = "on"; tv.auto = false; tv.index = i; tv.start(); } o.onmouseout = function(){ o.classname = ""; tv.auto = true; tv.start(); } }) } if (window.attachevent) { window.attachevent("onload", slashfixbug); } else if (window.addeventlistener) { window.addeventlistener("load", slashfixbug, false); } document.write("
")