function tw(id,src){ this.src=src; this.id=id; this.div=document.createElement("div"); this.div.style.position="absolute"; this.div.style.width="952"; this.div.style.height="372"; this.div.style.left=0; this.div.style.top=0; this.div.style.overflow="hidden"; this.div.innerHTML=''; this.show=function(obj){ obj.insertAdjacentElement("beforeEnd",this.div); } this.out=function(obj){ try{ obj.removeChild(this.div); }catch(e){} } } function display(obj1,obj2){ obj1.div.style.zIndex=200; obj2.div.style.zIndex=100; var mode=parseInt(Math.random()*6); switch(mode){ case 0: move(obj1,960,0); break; case 1: move(obj1,-960,0); break; case 2: move(obj1,0,380); break; case 3: move(obj1,960,380); break; case 4: var tempobj=new tw(obj1.id,obj1.src); tempobj.div.style.zIndex=500; tempobj.div.style.left=parseInt(tempobj.div.style.width)/2; tempobj.div.innerHTML=tempobj.div.innerHTML.replace("LEFT: 0","LEFT: -476"); tempobj.div.style.width=parseInt(tempobj.div.style.width)/2; tempobj.show(document.getElementById("tvmain")); obj1.div.style.width=parseInt(obj1.div.style.width)/2; move(tempobj,960,0); move(obj1,-960,0); break; default: move(obj1,0,-380); } obj2.show(document.getElementById("tvmain")); } function move(obj,x,y){ var speedx=10; var speedy=4; x1=parseInt(obj.div.style.left); y1=parseInt(obj.div.style.top); if(x>x1){ if((x-x1)<=speedx){ x1=x; }else{ x1+=speedx; } } if(xy1){ if((y-y1)<=speedy){ y1=y; }else{ y1+=speedy; } } if(y=id_max) var id_next=0; else var id_next=id_now+1; display(tws[id_now],tws[id_next]); id_now=id_next; setpos(); window.setTimeout("main()",8000); } start(); // //设置滚动条位置 function setpos(){ var obj=document.getElementById("jindutiao"); obj.style.left=512*(id_now/id_max); } //滚动条对象 function gundong(){ var x=0; var y=0; var moused=false; var obj=document.getElementById("jindutiao"); this.mousedown=function(e){ this.x=e.x; this.y=e.y; this.moused=true; } this.mouseup=function(e){ this.moused=false; } this.mousemove=function(e){ if(this.moused){ var newx=parseInt(obj.style.left)+(e.x-this.x); if(newx>=0&&newx<=512){ obj.style.left=newx; if(parseInt(newx/(512/(id_max+1)))!=id_now&&parseInt(newx/(512/(id_max+1)))<=id_max){ id_now=parseInt(newx/(512/(id_max+1))); obj1=document.getElementById("tvmain"); for(i in obj1.children){ obj1.removeChild(obj1.children[0]); } tws[id_now].show(document.getElementById("tvmain")); } } this.x=e.x; } } } var gd=new gundong(); ///////////////