// javascript document window.onload = function () { var obtnleft = document.getelementbyid("goleft"); var obtnright = document.getelementbyid("goright"); var odiv = document.getelementbyid("indexmaindiv"); var odiv1 = document.getelementbyid("maindiv1"); var oul = odiv.getelementsbytagname("ul")[0]; var ali = oul.getelementsbytagname("li"); var now = -5 * (ali[0].offsetwidth + 14); oul.style.width = ali.length * (ali[0].offsetwidth + 14) + 'px'; obtnright.onclick = function () { var n = math.floor((ali.length * (ali[0].offsetwidth + 14) + oul.offsetleft) / ali[0].offsetwidth); if (n <= 5) { move(oul, 'left', 0); } else { move(oul, 'left', oul.offsetleft + now); } } obtnleft.onclick = function () { var now1 = -math.floor((ali.length / 5)) * 5 * (ali[0].offsetwidth + 14); if (oul.offsetleft >= 0) { move(oul, 'left', now1); } else { move(oul, 'left', oul.offsetleft - now); } } var timer = setinterval(obtnright.onclick, 5000); odiv.onmouseover = function () { clearinterval(timer); } odiv.onmouseout = function () { timer = setinterval(obtnright.onclick, 5000); } }; function getstyle(obj, name) { if (obj.currentstyle) { return obj.currentstyle[name]; } else { return getcomputedstyle(obj, false)[name]; } } function move(obj, attr, itarget) { clearinterval(obj.timer) obj.timer = setinterval(function () { var cur = 0; if (attr == 'opacity') { cur = math.round(parsefloat(getstyle(obj, attr)) * 100); } else { cur = parseint(getstyle(obj, attr)); } var speed = (itarget - cur) / 6; speed = speed > 0 ? math.ceil(speed) : math.floor(speed); if (itarget == cur) { clearinterval(obj.timer); } else if (attr == 'opacity') { obj.style.filter = 'alpha(opacity:' + (cur + speed) + ')'; obj.style.opacity = (cur + speed) / 100; } else { obj.style[attr] = cur + speed + 'px'; } }, 30); }