| 119 |
ghuddy |
1 |
<!-- // Hide
|
|
|
2 |
|
|
|
3 |
// *** TIPSTER ***
|
|
|
4 |
|
|
|
5 |
var isDOM=document.getElementById?1:0;
|
|
|
6 |
var isIE=document.all?1:0;
|
|
|
7 |
var isNS4=(navigator.appName=='Netscape'&&!isDOM)?1:0;
|
|
|
8 |
var isWin=(navigator.platform.indexOf('Win')!=-1)?1:0;
|
|
|
9 |
var isDyn=(isDOM||isIE||isNS4);
|
|
|
10 |
|
|
|
11 |
function getRef(id, par)
|
|
|
12 |
{
|
|
|
13 |
par = !par ? document : (par.navigator?par.document:par);
|
|
|
14 |
return (isIE ? par.all[id] :
|
|
|
15 |
(isDOM ? (par.getElementById?par:par.ownerDocument).getElementById(id) :
|
|
|
16 |
par.layers[id]));
|
|
|
17 |
}
|
|
|
18 |
|
|
|
19 |
function getSty(id, par)
|
|
|
20 |
{
|
|
|
21 |
return (isNS4 ? getRef(id, par) : getRef(id, par).style)
|
|
|
22 |
}
|
|
|
23 |
|
|
|
24 |
if (!window.LayerObj) var LayerObj = new Function('id', 'par',
|
|
|
25 |
'this.ref=getRef(id, par); this.sty=getSty(id, par); return this');
|
|
|
26 |
function getLyr(id, par) { return new LayerObj(id, par) }
|
|
|
27 |
|
|
|
28 |
function LyrFn(fn, fc)
|
|
|
29 |
{
|
|
|
30 |
LayerObj.prototype[fn] = new Function('var a=arguments,p=a[0]; with (this) { '+fc+' }');
|
|
|
31 |
}
|
|
|
32 |
LyrFn('x','if (!isNaN(a[0])) sty.left=p; else return parseInt(sty.left)');
|
|
|
33 |
LyrFn('y','if (!isNaN(a[0])) sty.top=p; else return parseInt(sty.top)');
|
|
|
34 |
LyrFn('vis','sty.visibility=p');
|
|
|
35 |
LyrFn('write','if (isNS4) with (ref.document) {write(p);close()} else ref.innerHTML=p');
|
|
|
36 |
LyrFn('alpha','var f=ref.filters; if (f) {' +
|
|
|
37 |
'if (sty.filter.indexOf("alpha")==-1) sty.filter+="alpha()"; ' +
|
|
|
38 |
'if (f.length&&f.alpha) f.alpha.opacity=p } else if (isDOM) sty.MozOpacity=(p/100)');
|
|
|
39 |
|
|
|
40 |
|
|
|
41 |
if (!window.page) var page = { win: window, minW: 0, minH: 0, MS: isIE&&!window.opera }
|
|
|
42 |
|
|
|
43 |
page.winW=function()
|
|
|
44 |
{ with (this) return Math.max(minW, MS?win.document.body.clientWidth:win.innerWidth) }
|
|
|
45 |
page.winH=function()
|
|
|
46 |
{ with (this) return Math.max(minH, MS?win.document.body.clientHeight:win.innerHeight) }
|
|
|
47 |
|
|
|
48 |
page.scrollX=function()
|
|
|
49 |
{ with (this) return MS?win.document.body.scrollLeft:win.pageXOffset }
|
|
|
50 |
page.scrollY=function()
|
|
|
51 |
{ with (this) return MS?win.document.body.scrollTop:win.pageYOffset }
|
|
|
52 |
|
|
|
53 |
|
|
|
54 |
|
|
|
55 |
|
|
|
56 |
|
|
|
57 |
// *** TIP FUNCTIONS AND OBJECT ***
|
|
|
58 |
|
|
|
59 |
function tipTrack(evt) { with (this)
|
|
|
60 |
{
|
|
|
61 |
// Figure out where the mouse is and call the position function.
|
|
|
62 |
// Also set sX and sY as the scroll position of the document.
|
|
|
63 |
sX = page.scrollX();
|
|
|
64 |
sY = page.scrollY();
|
|
|
65 |
mX = (isIE ? event.clientX + sX : evt.pageX);
|
|
|
66 |
mY = (isIE ? event.clientY + sY : evt.pageY);
|
|
|
67 |
|
|
|
68 |
// If we've set tip tracking, call the position function.
|
|
|
69 |
if (tipStick == 1) position();
|
|
|
70 |
}}
|
|
|
71 |
|
|
|
72 |
function tipPosition() { with (this)
|
|
|
73 |
{
|
|
|
74 |
if (actTip)
|
|
|
75 |
{
|
|
|
76 |
// Pull the window sizes from the page object.
|
|
|
77 |
// In NS4 we size down the window a little as it includes scrollbars.
|
|
|
78 |
var wW = page.winW()-(isIE?0:15), wH = page.winH()-(isIE?0:15);
|
|
|
79 |
|
|
|
80 |
// Pull the compulsory information out of the tip array.
|
|
|
81 |
var t=tips[actTip], tipX=eval(t[0]), tipY=eval(t[1]), tipW=t[2], tipH=t[3], adjY = 1;
|
|
|
82 |
|
|
|
83 |
// Add mouse position onto relatively positioned tips.
|
|
|
84 |
if (typeof(t[0])=='number') tipX += mX;
|
|
|
85 |
if (typeof(t[1])=='number') tipY += mY;
|
|
|
86 |
|
|
|
87 |
// Check the tip is not within 5px of the screen boundaries.
|
|
|
88 |
if (tipX + tipW + 5 > sX + wW) { tipX = sX + wW - tipW - 5; adjY = 2 }
|
|
|
89 |
if (tipY + tipH + 5 > sY + wH) tipY = sY + wH - (adjY*tipH) - 5;
|
|
|
90 |
if (tipX < sX+ 5) tipX = sX + 5;
|
|
|
91 |
if (tipY < sY + 5) tipY = sY + 5;
|
|
|
92 |
|
|
|
93 |
|
|
|
94 |
// If the tip is currently invisible, show at the calculated position.
|
|
|
95 |
if (!showTip && (doFades ? !alpha : true))
|
|
|
96 |
{
|
|
|
97 |
xPos = tipX;
|
|
|
98 |
yPos = tipY;
|
|
|
99 |
}
|
|
|
100 |
|
|
|
101 |
// Move the actual position towards the calculated by the stickiness factor.
|
|
|
102 |
// Low stickinesses will result in slower catchup times.
|
|
|
103 |
xPos += (tipX - xPos) * tipStick;
|
|
|
104 |
yPos += (tipY - yPos) * tipStick;
|
|
|
105 |
|
|
|
106 |
div.x(xPos);
|
|
|
107 |
div.y(yPos);
|
|
|
108 |
}
|
|
|
109 |
}}
|
|
|
110 |
|
|
|
111 |
function tipShow(tipN) { with (this)
|
|
|
112 |
{
|
|
|
113 |
if (!isDyn) return;
|
|
|
114 |
|
|
|
115 |
// My layer object we use.
|
|
|
116 |
if (!div || !div.ref) div = getLyr(myName + 'Layer');
|
|
|
117 |
if (!div.ref) return;
|
|
|
118 |
|
|
|
119 |
// If we're mousing over a different or new tip...
|
|
|
120 |
if (actTip != tipN)
|
|
|
121 |
{
|
|
|
122 |
// Remember this tip number as active, for the other functions.
|
|
|
123 |
actTip = tipN;
|
|
|
124 |
|
|
|
125 |
// Set tip's onmouseover and onmouseout handlers.
|
|
|
126 |
if (isNS4) div.ref.captureEvents(Event.MOUSEOVER | Event.MOUSEOUT);
|
|
|
127 |
div.ref.onmouseover = new Function(myName + '.show("' + tipN + '")');
|
|
|
128 |
div.ref.onmouseout = new Function(myName + '.hide()');
|
|
|
129 |
|
|
|
130 |
// Stick it somewhere onscreen.
|
|
|
131 |
position();
|
|
|
132 |
|
|
|
133 |
// Go through and replace %0% with the array's 0 index, %1% with tips[tipN][1] etc...
|
|
|
134 |
var str = template;
|
|
|
135 |
for (var i=0; i<tips[tipN].length; i++) str = str.replace('%'+i+'%', tips[tipN][i]);
|
|
|
136 |
// Write the proper content... the last <br> strangely helps IE5/Mac...?
|
|
|
137 |
div.write(str + ((document.all && !isWin) ? '<small><br></small>' : ''));
|
|
|
138 |
}
|
|
|
139 |
|
|
|
140 |
// For non-integer stickiness values, we need to use setInterval to animate the tip,
|
|
|
141 |
// if it's 0 or 1 we can just use onmousemove to position it.
|
|
|
142 |
clearInterval(trackTimer);
|
|
|
143 |
if (tipStick != parseInt(tipStick)) trackTimer = setInterval(myName+'.position()', 50);
|
|
|
144 |
|
|
|
145 |
// Set the showTip flag, as a signal for the fade/position routines.
|
|
|
146 |
showTip = true;
|
|
|
147 |
|
|
|
148 |
// Finally either fade in immediately or after a very short delay.
|
|
|
149 |
// The delay is for NS4 to allow it to execute a 'hide' event after this, from a
|
|
|
150 |
// previous mouseout when two tip triggers overlap, because it's a weird browser.
|
|
|
151 |
// So, this show call can cancel a (slightly later) hide. Look, it works, OK? ;).
|
|
|
152 |
clearTimeout(fadeTimer);
|
|
|
153 |
if (isNS4) setTimeout(myName + '.fade()', 1);
|
|
|
154 |
else fade();
|
|
|
155 |
}}
|
|
|
156 |
|
|
|
157 |
function tipHide() { with (this)
|
|
|
158 |
{
|
|
|
159 |
if (!isDyn) return;
|
|
|
160 |
|
|
|
161 |
// Fade out in 100ms, a larger delay so another mouseover can cancel this fade.
|
|
|
162 |
// This allows the user to mouseover a static tip before its hides.
|
|
|
163 |
clearTimeout(fadeTimer);
|
|
|
164 |
fadeTimer = setTimeout('with (' + myName + ') { showTip=false; fade() }', 200);
|
|
|
165 |
}}
|
|
|
166 |
|
|
|
167 |
function tipFade() { with (this)
|
|
|
168 |
{
|
|
|
169 |
// Clear to stop existing fades.
|
|
|
170 |
clearTimeout(fadeTimer);
|
|
|
171 |
|
|
|
172 |
// Show it and optionally increment alpha from 0 to 100.
|
|
|
173 |
if (showTip)
|
|
|
174 |
{
|
|
|
175 |
div.vis('visible');
|
|
|
176 |
if (doFades)
|
|
|
177 |
{
|
|
|
178 |
alpha += fadeSpeed;
|
|
|
179 |
if (alpha > 100) alpha = 100;
|
|
|
180 |
div.alpha(alpha);
|
|
|
181 |
// Call this function again shortly, fading tip in further.
|
|
|
182 |
if (alpha < 100) fadeTimer = setTimeout(myName + '.fade()', 50);
|
|
|
183 |
return;
|
|
|
184 |
}
|
|
|
185 |
}
|
|
|
186 |
|
|
|
187 |
else
|
|
|
188 |
{
|
|
|
189 |
// Similar to before but counting down and hiding at the end.
|
|
|
190 |
if (doFades && alpha > 0)
|
|
|
191 |
{
|
|
|
192 |
alpha -= fadeSpeed;
|
|
|
193 |
if (alpha < 0) alpha = 0;
|
|
|
194 |
div.alpha(alpha);
|
|
|
195 |
fadeTimer = setTimeout(myName + '.fade()', 50);
|
|
|
196 |
return;
|
|
|
197 |
}
|
|
|
198 |
div.vis('hidden');
|
|
|
199 |
// Clear the active tip flag so it is repositioned next time.
|
|
|
200 |
actTip = '';
|
|
|
201 |
// Stop any sticky-tip tracking if it's invisible.
|
|
|
202 |
clearInterval(trackTimer);
|
|
|
203 |
}
|
|
|
204 |
}}
|
|
|
205 |
|
|
|
206 |
function TipObj(myName)
|
|
|
207 |
{
|
|
|
208 |
// Holds the properties the functions above use.
|
|
|
209 |
this.myName = myName;
|
|
|
210 |
this.tips = new Array();
|
|
|
211 |
this.template = '';
|
|
|
212 |
this.actTip = '';
|
|
|
213 |
this.showTip = false;
|
|
|
214 |
this.tipStick = 1;
|
|
|
215 |
this.xPos = this.yPos = this.sX = this.sY = this.mX = this.mY = 0;
|
|
|
216 |
|
|
|
217 |
this.track = tipTrack;
|
|
|
218 |
this.position = tipPosition;
|
|
|
219 |
this.show = tipShow;
|
|
|
220 |
this.hide = tipHide;
|
|
|
221 |
this.fade = tipFade;
|
|
|
222 |
|
|
|
223 |
this.div = null;
|
|
|
224 |
this.trackTimer = 0;
|
|
|
225 |
this.fadeTimer = 0;
|
|
|
226 |
this.alpha = 0;
|
|
|
227 |
this.doFades = false;
|
|
|
228 |
this.fadeSpeed = 20;
|
|
|
229 |
}
|
|
|
230 |
|
|
|
231 |
|
|
|
232 |
// Capture the onmousemove event so tips can follow the mouse. Add in all your tip objects here
|
|
|
233 |
// and also any functions from other scripts that need this event (e.g. my DHTML Scroller) too.
|
|
|
234 |
if (isNS4) document.captureEvents(Event.MOUSEMOVE);
|
|
|
235 |
document.onmousemove = function(evt)
|
|
|
236 |
{
|
|
|
237 |
formTips.track(evt);
|
|
|
238 |
if (isNS4) return document.routeEvent(evt);
|
|
|
239 |
}
|
|
|
240 |
|
|
|
241 |
|
|
|
242 |
// A small function that refreshes NS4 on horizontal resize.
|
|
|
243 |
var nsWinW = window.innerWidth, nsWinH = window.innerHeight;
|
|
|
244 |
function ns4BugCheck()
|
|
|
245 |
{
|
|
|
246 |
if (isNS4 && (nsWinW!=innerWidth || nsWinH!=innerHeight)) location.reload()
|
|
|
247 |
}
|
|
|
248 |
|
|
|
249 |
window.onresize = function()
|
|
|
250 |
{
|
|
|
251 |
ns4BugCheck();
|
|
|
252 |
}
|
|
|
253 |
|
|
|
254 |
// End Hide -->
|