var nowShow = 1; var curboxId = 1; var xxgkBoxDefault = 0, xxgkBoxOpen = -655; var zmhdBoxDefault = 32, zmhdBoxOpen = -627; var xxgkPosition = xxgkBoxDefault, zmhdPosition = zmhdBoxDefault; var xxgkScrolling, zmhdScrolling; var onceMove = 100, intervalTime = 20; function glideControl(boxFlag) { curboxId=boxFlag; if (boxFlag == 1) { stopScrolling(xxgkScrolling); stopScrolling(zmhdScrolling); xxgkScrolling = window.setInterval(function() { driveMove(0, 0); }, intervalTime); zmhdScrolling = window.setInterval(function() { driveMove(1, 0); }, intervalTime); } if (boxFlag == 2) { stopScrolling(xxgkScrolling); stopScrolling(zmhdScrolling); xxgkScrolling = window.setInterval(function() { driveMove(0, 1); }, intervalTime); zmhdScrolling = window.setInterval(function() { driveMove(1, 0); }, intervalTime); } if (boxFlag == 3) { stopScrolling(xxgkScrolling); stopScrolling(zmhdScrolling); xxgkScrolling = window.setInterval(function() { driveMove(0, 1); }, intervalTime); zmhdScrolling = window.setInterval(function() { driveMove(1, 1); }, intervalTime); } SetBoxShowStyle(boxFlag); } function moveBox(boxId, nowPosition) { document.getElementById(boxId).style.right = nowPosition + "px"; } function driveMove(boxFlag, direction) { var boxPosition, boxId; if (boxFlag == 0) { boxId = "xxgkbox"; xxgkPosition = direction == 1 ? xxgkPosition - onceMove : xxgkPosition + onceMove; if (xxgkPosition <= xxgkBoxOpen) { xxgkPosition = xxgkBoxOpen; stopScrolling(xxgkScrolling); } if (xxgkPosition >= xxgkBoxDefault) { xxgkPosition = xxgkBoxDefault; stopScrolling(xxgkScrolling); } boxPosition = xxgkPosition; } if (boxFlag == 1) { boxId = "zmhdbox"; zmhdPosition = direction == 1 ? zmhdPosition - onceMove : zmhdPosition + onceMove; if (zmhdPosition <= zmhdBoxOpen) { zmhdPosition = zmhdBoxOpen; stopScrolling(zmhdScrolling); } if (zmhdPosition >= zmhdBoxDefault) { zmhdPosition = zmhdBoxDefault; stopScrolling(zmhdScrolling); } boxPosition = zmhdPosition; } moveBox(boxId, boxPosition); } function changeBg(curstate,boxFlag) { var boxId; if(boxFlag==1) { boxId="xxgktitle"; if(curboxId==1) document.getElementById(boxId).style.backgroundImage= "url('img/bsfw_1.gif' )"; else if(curstate=="over") document.getElementById(boxId).style.backgroundImage= "url('img/bsfw_2.gif' )"; else document.getElementById(boxId).style.backgroundImage= "url('img/bsfw_2.gif' )"; } else if(boxFlag==2) { boxId="zmhdtitle"; if(curboxId==2) document.getElementById(boxId).style.backgroundImage= "url('img/gzcy_1.gif' )"; else if(curstate=="over") document.getElementById(boxId).style.backgroundImage= "url('img/gzcy_2.gif' )"; else document.getElementById(boxId).style.backgroundImage= "url('img/gzcy_2.gif' )"; } else if(boxFlag==3) { boxId="bsfwtitle"; if(curboxId==3) document.getElementById(boxId).style.backgroundImage= "url('img/tzxf_1.gif' )"; else if(curstate=="over") document.getElementById(boxId).style.backgroundImage= "url('img/tzxf_2.gif' )"; else document.getElementById(boxId).style.backgroundImage= "url('img/tzxf_2.gif' )"; } } function SetBoxShowStyle(boxFlag) { if(boxFlag==1) { document.getElementById("xxgktitle").style.backgroundImage= "url('img/bsfw_1.gif' )"; document.getElementById("zmhdtitle").style.backgroundImage= "url('img/gzcy_2.gif' )"; document.getElementById("bsfwtitle").style.backgroundImage= "url('img/tzxf_2.gif' )"; } else if(boxFlag==2) { document.getElementById("xxgktitle").style.backgroundImage= "url('img/bsfw_2.gif' )"; document.getElementById("zmhdtitle").style.backgroundImage= "url('img/gzcy_1.gif' )"; document.getElementById("bsfwtitle").style.backgroundImage= "url('img/tzxf_2.gif' )"; } else if(boxFlag==3) { document.getElementById("xxgktitle").style.backgroundImage= "url('img/bsfw_2.gif' )"; document.getElementById("zmhdtitle").style.backgroundImage= "url('img/gzcy_2.gif' )"; document.getElementById("bsfwtitle").style.backgroundImage= "url('img/tzxf_1.gif' )"; } } function stopScrolling(scrollingId) { window.clearInterval(scrollingId); }