大宗商品市场入牛市初期
function foucsImg(contrain, gap) {
var getId = function(ele) {
if (typeof ele == 'string') return document.getElementById(ele);
else return ele;
}
var parObj = getId(contrain);
var ullist = parObj.getElementsByTagName('ul');
var img_ul = ullist[0],
title_ul = ullist[1],
order_ul = ullist[2];
var img_li = ullist[0].getElementsByTagName('li');
var title_li = ullist[1].getElementsByTagName('li');
var order_li = ullist[2].getElementsByTagName('li');
var l = img_li.length,
timer, remark = 0;
var objsBtn = getId("foucs_btn");
var objsBtn_l = getId("foucs_l");
var objsBtn_r = getId("foucs_r");
var now = 0;
for (var i = 0; i < l; i++) {
order_li[i].onclick = (function(i) {
return function() {
clearTimeout(timer);
remark = i;
topic();
}
})(i);
}
timer = setTimeout(topic, gap);
parObj.onmouseover = function() {
//clearTimeout(timer);
//objsBtn.style.display="block";
}
parObj.onmouseout = function() {
//timer = setTimeout(topic,gap);
//objsBtn.style.display="none";
}
function topic() {
//debugger;
clearTimeout(timer);
for (var j = 0; j < l; j++) {
if (remark == j) {
order_li[j].className = 'on';
img_li[j].style.display = '';
title_li[j].style.display = '';
} else {
order_li[j].className = '';
img_li[j].style.display = 'none';
title_li[j].style.display = 'none';
}
} //alert(remark);
remark = remark < l - 1 ? (remark + 1) : 0;
if (remark > 4) {
remark = 0;
}
//alert(remark);
timer = setTimeout(topic, gap);
}
objsBtn_l.onclick = function() {
clearTimeout(timer);
remark = remark <= l - 1 ? (remark - 1) : 2;
if (remark < 0) {
remark = 4
}
//document.title=remark;
for (var j = 0; j < l; j++) {
//alert(remark)
if (remark == j) {
order_li[j].className = 'on';
img_li[j].style.display = '';
title_li[j].style.display = '';
} else {
order_li[j].className = '';
img_li[j].style.display = 'none';
title_li[j].style.display = 'none';
}
}
}
objsBtn_r.onclick = function() {
clearTimeout(timer);
remark = remark <= l - 1 ? (remark + 1) : 0;
if (remark > 4) {
remark = 0
}
//document.title=remark;
for (var j = 0; j < l; j++) {
//alert(remark)
if (remark == j) {
order_li[j].className = 'on';
img_li[j].style.display = '';
title_li[j].style.display = '';
} else {
order_li[j].className = '';
img_li[j].style.display = 'none';
title_li[j].style.display = 'none';
}
}
}
};
foucsImg('foucsCon',3000);