1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219
|
<!--
/* Copyright 2001 : Atout Développement */
/* Auteur : Yvan Vanwynsberghe */
var ns4 = (document.layers)? true:false; //NS 4
var ie4 = (document.all)? true:false; //IE 4
var dom = (document.getElementById)? true:false; //DOM
function Init()
{
MyBox = new Box('MyBox', 'conteneur', 1, 100, 4000, 30);
MyBox.start();
}
function GetNS4Object(MyID,MyDocument)
{
var MyObject= eval('MyDocument.'+MyID);
if (!(MyObject))
for(var i=0;i<MyDocument.layers.length;i++)
{
MyObject = GetNS4Object(MyID,MyDocument.layers[i].document);
if (MyObject) break;
}
return MyObject;
}
function GetObject(MyID)
{
if (dom) return document.getElementById(MyID);
if (ie4) return document.all[MyID];
if (ns4) return GetNS4Object(MyID,window.document);
return 0;
}
function GetCSS(MyObject)
{
if (dom || ie4) return MyObject.style;
else if (ns4) return MyObject;
else return 0;
}
function GetHeight(MyObject)
{
if (dom || ie4) return MyObject.offsetHeight;
else if (ns4) return MyObject.clip.height;
else return 0;
}
function GetWidth(MyObject)
{
if (dom || ie4) return MyObject.offsetWidth;
else if (ns4) return MyObject.clip.width;
else return 0;
}
function GetTop(MyObject)
{
if (dom || ie4)
return (MyObject.offsetTop);
if (ns4) return MyObject.y;
return 0;
}
function GetLeft(MyObject)
{
if (dom || ie4) return MyObject.offsetLeft;
if (ns4) return MyObject.x;
return 0;
}
function MoveObject(myX,myY)
{
this.X = myX;
this.Y = myY;
this.CSS.left=this.X;
this.CSS.top=this.Y;
}
function MoveObjectUp(mystep)
{
this.Y -= mystep;
this.CSS.top=this.Y;
}
function MoveObjectDown(mystep)
{
this.Y += mystep;
this.CSS.top=this.Y;
}
function CreateObject(DivId,MyObject)
{
if (MyObject)
this.Object = MyObject;
else
this.Object = GetObject(DivId);
if (this.Object)
{
this.CSS = GetCSS(this.Object);
this.Height = GetHeight(this.Object);
this.Width = GetWidth(this.Object);
this.X = GetTop(this.Object);
this.Y = GetLeft(this.Object);
this.Move = MoveObject;
this.Up = MoveObjectUp;
this.Down = MoveObjectDown;
}
return this;
}
function DelTextNode(MyObject)
{
var node = MyObject.firstChild;
var next;
while (node)
{
next = node.nextSibling;
if (node.nodeType == 3)
MyObject.removeChild(node);
node = next;
}
}
function CreateChildren(MyObject,HoriSpacer,VertSpacer)
{
var i=0;
var MyChildren = new Array();
if (dom)
{
DelTextNode(MyObject);
for (i=0;i<MyObject.childNodes.length;i++)
{
MyChildren[i] = new CreateObject(0,MyObject.childNodes[i]);
MyChildren[i].Move(i*HoriSpacer,i*VertSpacer);
}
return MyChildren;
}
if (ie4)
{
for (i=0;i<MyObject.children.length;i++)
{
MyChildren[i] = new CreateObject(0,MyObject.children(i));
MyChildren[i].Move(i*HoriSpacer,i*VertSpacer);
}
return MyChildren;
}
if (ns4)
{
for (i=0;i<MyObject.document.layers.length;i++)
{
MyChildren[i] = new CreateObject(0,MyObject.layers[i]);
MyChildren[i].Move(i*HoriSpacer,i*VertSpacer);
}
return MyChildren;
}
}
function ScrollUp()
{
var MyInterval = this.Interval1;
this.stop();
if (this.Children[this.FirstChildren].Y<-this.threshold)
{
MyInterval = this.Interval2;
this.Children[this.FirstChildren].Down(this.TotalHeight);
if (this.FirstChildren<this.Children.length-1)
{
this.FirstChildren++;
this.threshold += this.Children[this.FirstChildren].Height;
}
else
{
this.FirstChildren = 0;
this.threshold = this.Children[this.FirstChildren].Height+this.Spacer;
}
}
for (var i=0;i<this.Children.length;i++)
{
this.Children[i].Up(this.Step);
}
this.ProcessId = setTimeout(this.name + '.start()', MyInterval);
}
function ScrollStop()
{
if (this.ProcessId)
clearTimeout(this.ProcessId);
this.ProcessId = null;
}
function Box(BoxName, DivId, myStep, myTempo1, myTempo2, mySpacer)
{
this.name = BoxName;
this.Step = myStep ? myStep : 1;
this.Interval1 = myTempo1 ? myTempo1 : 100;
this.Interval2 = myTempo2 ? myTempo2 : 100;
this.Spacer = mySpacer ? mySpacer : 0;
this.ProcessId = null;
this.Container = new CreateObject(DivId);
this.Children = new CreateChildren(this.Container.Object,0,mySpacer);
this.FirstChildren = 0;
this.LastChildren = this.Children.length-1;
this.threshold = this.Children[0].Height+this.Spacer;
var myHeight = 0;
for (var i=0;i<this.Children.length;i++)
{
myHeight += (this.Children[i].Height + this.Spacer);
}
this.TotalHeight = myHeight;
this.Container.visibility = 'visible';
}
Box.prototype.start = ScrollUp;
Box.prototype.stop = ScrollStop;
//--> |
Partager