var tips;
var thetop = 0;
var old = thetop;
var tips1;
var thetop1 = 0;
var old1 = thetop1;
var tips2;
var thetop2 = 0;
var old2 = thetop2;
var tips4;
var thetop4 = 0;
var old4 = thetop4;
var tips6;
var thetop6 = 0;
var old6 = thetop6;
window.onload = function () {
function $(param) {
if (arguments[1] == true) {
return document.queryselectorall(param);
}
else {
return document.queryselector(param);
}
}
var $box = $(".box");
var $box1 = $(".box-1 ul li", true);
var $box2 = $(".box-2 ul");
var $box3 = $(".box-3");
var $length = $box1.length;
var str = "";
for (var i = 0; i < $length; i++) {
if (i == 0) {
str += "
" + (i + 1) + "";
}
else {
str += "" + (i + 1) + "";
}
}
$box2.innerhtml = str;
var current = 0;
var timer;
timer = setinterval(go, 6000);
function go() {
for (var j = 0; j < $length; j++) {
$box1[j].style.display = "none";
$box2.children[j].classname = "";
}
if ($length == current) {
current = 0;
}
$box1[current].style.display = "block";
$box2.children[current].classname = "on";
current++;
}
for (var k = 0; k < $length; k++) {
$box1[k].onmouseover = function () {
clearinterval(timer);
}
$box1[k].onmouseout = function () {
timer = setinterval(go, 6000);
}
}
for (var p = 0; p < $box3.children.length; p++) {
$box3.children[p].onmouseover = function () {
clearinterval(timer);
}
;
$box3.children[p].onmouseout = function () {
timer = setinterval(go, 1000);
}
}
for (var u = 0; u < $length; u++) {
$box2.children[u].index = u;
$box2.children[u].onmouseover = function () {
clearinterval(timer);
for (var j = 0; j < $length; j++) {
$box1[j].style.display = "none";
$box2.children[j].classname = "";
}
this.classname = "on";
$box1[this.index].style.display = "block";
current = this.index + 1;
}
$box2.children[u].onmouseout = function () {
timer = setinterval(go, 1000);
}
}
$box3.children[0].onclick = function () {
back();
}
$box3.children[1].onclick = function () {
go();
}
function back() {
for (var j = 0; j < $length; j++) {
$box1[j].style.display = "none";
$box2.children[j].classname = "";
}
if (current == 0) {
current = $length;
}
$box1[current - 1].style.display = "block";
$box2.children[current - 1].classname = "on";
current--;
}
function getdate(){
var d=new date();
var years=d.getfullyear();//获取年份
var months=d.getmonth()+1;//获取月份
var days=d.getdate();
var hours=d.gethours();
var minutes=d.getminutes();
var seconds=d.getseconds();
var xqarr=["星期日","星期一","星期二","星期三","星期四","星期五","星期六"];//创建星期几数组
var week=xqarr[d.getday()];//获取星期几
if(months<10){
months="0"+months;//月份如果小于10,就加0,格式好看些。
}
if(days<10){
days="0"+days;//日数如果小于10,就加0,格式好看些。
}
return years+"年"+months+"月"+days+"日"+"   "+week ;
}
console.log(getdate());//在控制台查看时间,检查元素。
var ospan=document.getelementbyid("time");
ospan.innerhtml=getdate();
// initfloattips();
// initfloattips1();
//initfloattips2();
};
function initfloattips() {
tips = document.getelementbyid('ad2');
movetips();
};
function movetips() {
var tt = 50;
if (window.innerheight) {
pos = window.pageyoffset
} else if (document.documentelement && document.documentelement.scrolltop) {
pos = document.documentelement.scrolltop
} else if (document.body) {
pos = document.body.scrolltop;
}
pos = pos - tips.offsettop + thetop;
pos = tips.offsettop + pos / 10;
if (pos < thetop) pos = thetop;
if (pos != old) {
tips.style.top = pos + "px";
tt = 10;
}
old = pos;
settimeout(movetips, tt);
};
function initfloattips1() {
tips1 = document.getelementbyid('ad1');
movetips1();
};
function movetips1() {
var tt1 = 50;
if (window.innerheight) {// 文档显示区高度
pos1 = window.pageyoffset
} else if (document.documentelement && document.documentelement.scrolltop) {// 获取滚动条位置
pos1 = document.documentelement.scrolltop
} else if (document.body) {
pos1 = document.body.scrolltop;
}
pos1 = pos1 - tips1.offsettop + thetop1;
pos1 = tips1.offsettop + pos1 / 10;
if (pos1 < thetop1) pos1 = thetop1;
if (pos1 != old1) {
tips1.style.top = pos1 + "px";
tt1 = 10;
}
old1 = pos1;
settimeout(movetips1, tt1);
};
function initfloattips2() {
tips2 = document.getelementbyid('ad3');
movetips2();
};
function movetips2() {
var tt2 = 50;
if (window.innerheight) {
pos2 = window.pageyoffset
} else if (document.documentelement && document.documentelement.scrolltop) {
pos2 = document.documentelement.scrolltop
} else if (document.body) {
pos2 = document.body.scrolltop;
}
pos2 = pos2 - tips2.offsettop + thetop2;//指 tips2 距离上方或上层控件的位置
pos2 = tips2.offsettop + pos2 / 10;
if (pos2 < thetop2) pos2 = thetop2;
if (pos2 != old2) {
tips2.style.top = pos2 + "px";
tt2 = 10;
}
old2 = pos2;
settimeout(movetips2, tt2);
};
function initfloattips4() {
tips2 = document.getelementbyid('ad4');
movetips4();
};
function movetips4() {
var tt4 = 50;
if (window.innerheight) {
pos4 = window.pageyoffset
} else if (document.documentelement && document.documentelement.scrolltop) {
pos4 = document.documentelement.scrolltop
} else if (document.body) {
pos4 = document.body.scrolltop;
}
pos4 = pos4 - tips4.offsettop + thetop4;//指 tips4 距离上方或上层控件的位置
pos4 = tips4.offsettop + pos4 / 10;
if (pos4 < thetop4) pos4 = thetop4;
if (pos4 != old4) {
tips4.style.top = pos4 + "px";
tt4 = 10;
}
old4 = pos4;
settimeout(movetips4, tt4);
};
function initfloattips6() {
tips2 = document.getelementbyid('ad6');
movetips6();
};
function movetips6() {
var tt6 = 80;
if (window.innerheight) {
pos6 = window.pageyoffset
} else if (document.documentelement && document.documentelement.scrolltop) {
pos6 = document.documentelement.scrolltop
} else if (document.body) {
pos6 = document.body.scrolltop;
}
pos6 = pos6 - tips6.offsettop + thetop6;//指 tips6 距离上方或上层控件的位置
pos6 = tips6.offsettop + pos6 / 10;
if (pos6 < thetop6) pos6 = thetop6;
if (pos6 != old6) {
tips6.style.top = pos6 + "px";
tt6 = 10;
}
old6 = pos6;
settimeout(movetips6, tt6);
};