2 Powered by C.S Wowd script
\r
3 for correct work need write to cs_patch full patch to cs wowd site
\r
4 var cs_patch = 'http://localhost/cswowd/';
\r
5 WARNING this script include cs_powered.css style from C.S Wowd
\r
7 var cs_patch = 'http://localhost/cswowd/cswowd/';
\r
8 var config = new Object();
\r
10 config. width = 0 // Tooltip width, 0 for auto
\r
11 config. OffsetX = 40 // Horizontal offset of left-top corner from mousepointer
\r
12 config. OffsetY = -30 // Vertical offset
\r
13 config. Sticky = false // Move or not while shown
\r
14 config. Border = true // Show border
\r
15 config. step = 100 // Opacity step time
\r
16 config. timeUp = 0 // Show opacity time
\r
17 config. timeDown = 1500 // Hide opacity time
\r
18 tt_aV = new Array(); // Caches and enumerates config data for currently active tooltip
\r
21 var tt_musX = 0, tt_musY = 0, tt_scrlX = 0, tt_scrlY = 0;
\r
22 // Broser depend data
\r
23 var tt_db = document.body ||
\r
24 document.documentElement ||
\r
25 (document.getElementsByTagName ? document.getElementsByTagName("body")[0] : null);
\r
27 var tt_u = "undefined";
\r
29 var tt_opaTimer = new Number(0),
\r
30 tt_mainDiv = 0, // Main div
\r
31 tt_subDiv = 0, // Main sub div - for opacity
\r
32 tt_status = 0, // Status & 1 - tip shown/hide
\r
33 tt_element = 0, // onmouseover element for hide tooltip
\r
34 tt_opacity = 0, // Current sub div opacity
\r
35 tt_Cache = new Array(),
\r
36 tt_ajaxObjects = new Array(),
\r
38 tt_loading_text = '<div class=loading> </div>';
\r
40 function sack(file) {
\r
41 this.xmlhttp = null;
\r
43 this.resetData = function() {
\r
44 this.method = "GET";
\r
46 this.execute = false;
\r
47 this.element = null;
\r
48 this.elementObj = null;
\r
49 this.requestFile = file;
\r
50 this.responseStatus = new Array(2);
\r
53 this.resetFunctions = function() {
\r
54 this.onLoading = function() { };
\r
55 this.onLoaded = function() { };
\r
56 this.onInteractive = function() { };
\r
57 this.onCompletion = function() { };
\r
58 this.onError = function() { };
\r
59 this.onFail = function() { };
\r
62 this.reset = function() {
\r
63 this.resetFunctions();
\r
67 this.createAJAX = function() {
\r
69 this.xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
\r
72 this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
\r
74 this.xmlhttp = null;
\r
78 if (! this.xmlhttp) {
\r
79 if (typeof XMLHttpRequest != "undefined") {
\r
80 this.xmlhttp = new XMLHttpRequest();
\r
87 this.runResponse = function() {
\r
88 eval(this.response);
\r
91 this.runAJAX = function(urlstring) {
\r
96 this.elementObj = document.getElementById(this.element);
\r
100 if (this.method == "GET") {
\r
101 this.xmlhttp.open(this.method, this.requestFile, this.mode);
\r
103 this.xmlhttp.open(this.method, this.requestFile, this.mode);
\r
105 this.xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded")
\r
109 this.xmlhttp.onreadystatechange = function() {
\r
110 switch (self.xmlhttp.readyState) {
\r
118 self.onInteractive();
\r
121 self.response = self.xmlhttp.responseText;
\r
122 self.responseXML = self.xmlhttp.responseXML;
\r
123 self.responseStatus[0] = self.xmlhttp.status;
\r
124 self.responseStatus[1] = self.xmlhttp.statusText;
\r
126 if (self.execute) {
\r
127 self.runResponse();
\r
130 if (self.elementObj) {
\r
131 elemNodeName = self.elementObj.nodeName;
\r
132 elemNodeName.toLowerCase();
\r
133 if (elemNodeName == "input"
\r
134 || elemNodeName == "select"
\r
135 || elemNodeName == "option"
\r
136 || elemNodeName == "textarea") {
\r
137 self.elementObj.value = self.response;
\r
139 self.elementObj.innerHTML = self.response;
\r
142 if (self.responseStatus[0] == "200") {
\r
143 self.onCompletion();
\r
148 self.URLString = "";
\r
153 this.xmlhttp.send(this.URLString);
\r
161 function ajax_AddContent(ajaxIndex, url)
\r
163 var result = tt_ajaxObjects[ajaxIndex].response;
\r
164 tt_Cache[url] = result.replace('src=', 'src=' + cs_patch);
\r
165 tt_ajaxObjects[ajaxIndex] = false;
\r
166 if (tt_currentTip != url)
\r
168 if ((tt_status & 1) == 0)
\r
170 tt_UpdateTip(tt_Cache[url]);
\r
171 tt_SetOpa(tt_subDiv.style, tt_opacity);
\r
172 tt_updatePosition();
\r
176 tt_currentTip = arguments[0];
\r
177 if(tt_Cache[tt_currentTip])
\r
179 arguments[0] = tt_Cache[tt_currentTip];
\r
184 arguments[0] = tt_loading_text;
\r
186 var ajaxIndex = tt_ajaxObjects.length;
\r
187 var i = tt_currentTip;
\r
188 tt_ajaxObjects[ajaxIndex] = new sack(cs_patch + 'ajax.php?tip=' + i);
\r
189 tt_ajaxObjects[ajaxIndex].mode = true;
\r
190 tt_ajaxObjects[ajaxIndex].onCompletion = function(){ ajax_AddContent(ajaxIndex, i); };
\r
191 tt_ajaxObjects[ajaxIndex].onError = function(){ tt_UpdateTip('Unable to connect'); };
\r
192 tt_ajaxObjects[ajaxIndex].runAJAX();
\r
195 function tt_hrefTip(e)
\r
197 e = window.event || e;
\r
198 var ref = e.target || e.srcElement;
\r
199 while (ref.tagName!='A')
\r
201 if (ref.parentNode == null)
\r
203 ref = ref.parentNode;
\r
207 function tt_enableHrefTip(element)
\r
209 var r={'item':'i', 'spell':'s', 'enchant':'e'};
\r
210 var c = element.getElementsByTagName("a");
\r
211 for (var i = 0; i < c.length; i++)
\r
214 var reg = a.href.match('(.+\\?)(.+?)=(\\d+)');
\r
215 if (reg && a.id=="" && r[reg[2]])
\r
217 a.id = r[reg[2]] + reg[3];
\r
218 tt_AddEvtFnc(a, "mouseover", tt_hrefTip, true);
\r
224 tt_currentTip = -1;
\r
227 function tt_Tip(arg)
\r
230 tt_UpdateTip(arg[0]);
\r
231 tt_updatePosition();
\r
234 function tt_opaStepUp(step)
\r
236 tt_opacity+=(100*step/tt_aV[TIMEUP]);
\r
237 var time = Math.floor(tt_aV[TIMEUP]/step);
\r
238 if (tt_opacity < 100)
\r
239 tt_opaTimer.Timer("tt_opaStepUp(" + step + ")", time, true);
\r
241 {tt_opaTimer.EndTimer();tt_opacity = 100;}
\r
242 tt_SetOpa(tt_subDiv.style, tt_opacity);
\r
244 function tt_opaStepDown(step)
\r
246 tt_opacity-=(100*step/tt_aV[TIMEDOWN]);
\r
247 var time = Math.floor(tt_aV[TIMEDOWN]/step);
\r
248 if (tt_opacity > 0)
\r
249 tt_opaTimer.Timer("tt_opaStepDown(" + step + ")", time, true);
\r
251 {tt_opaTimer.EndTimer();tt_finishHideTip();}
\r
252 tt_SetOpa(tt_subDiv.style, tt_opacity);
\r
254 function tt_startShowTip()
\r
256 tt_opaTimer.EndTimer();
\r
259 tt_RemEvtFnc(tt_element, "mouseout", tt_Hide);
\r
264 tt_mainDiv.style.visibility = "visible";
\r
268 tt_opaStepUp(tt_aV[STEP]);
\r
273 function tt_startHideTip()
\r
275 tt_opaTimer.EndTimer();
\r
277 if (tt_aV[TIMEDOWN])
\r
278 tt_opaStepDown(tt_aV[STEP]);
\r
280 tt_finishHideTip();
\r
282 function tt_finishHideTip()
\r
284 tt_mainDiv.style.visibility = "hidden";
\r
287 function tt_updatePosition()
\r
289 var win_width = tt_GetClientW();
\r
290 var win_height = tt_GetClientH();
\r
291 var div_width = tt_mainDiv.offsetWidth || tt_mainDiv.style.pixelWidth || 0;
\r
292 var div_height = tt_mainDiv.offsetHeight || tt_mainDiv.style.pixelHeight || 0;
\r
293 var x = tt_musX - tt_scrlX + tt_aV[OFFSETX];
\r
294 var y = tt_musY - tt_scrlY + tt_aV[OFFSETY];
\r
295 if (x + div_width >= win_width ) x = win_width - div_width;
\r
296 if (y + div_height>= win_height) y = win_height - div_height;
\r
298 var inX_ByX = (tt_musX - tt_scrlX > x && tt_musX - tt_scrlX < x + div_width );
\r
299 var inY_ByY = (tt_musY - tt_scrlY > y && tt_musY - tt_scrlY < y + div_height);
\r
300 if (inX_ByX && inY_ByY)
\r
303 x = tt_musX - tt_scrlX - div_width - 10;
\r
305 y = tt_musY - tt_scrlY - div_height - 10;
\r
310 var css = tt_mainDiv.style;
\r
311 css.left = (x + tt_scrlX)+'px';
\r
312 css.top = (y + tt_scrlY)+'px';
\r
314 function tt_UpdateTip(text)
\r
316 var width = tt_aV[WIDTH]==0 ? '' : (' style="width:' + tt_aV[WIDTH] + 'px;"');
\r
318 tt_mainDiv.innerHTML = ''
\r
319 + '<div id=tt_tooltip>'
\r
320 + '<table class=tooltip cellSpacing=0 cellPadding=0><tbody>'
\r
321 + '<tr><td class=tiptopl></td><td class=tiptop></td><td class=tiptopr></td></tr>'
\r
322 + '<tr><td class=tipl> </td><td class=tipbody' + width + '>'
\r
324 + '</td><td class=tipr> </td></tr>'
\r
325 + '<tr><td class=tipbottoml></td><td class=tipbottom></td><td class=tipbottomr></td></tr>'
\r
326 + '</tbody></table></div>';
\r
328 tt_mainDiv.innerHTML = ''
\r
329 + '<div id=tt_tooltip ' + width + '>'
\r
332 tt_subDiv = document.getElementById('tt_tooltip');
\r
334 function tt_GetClientW()
\r
336 return(document.body && (typeof(document.body.clientWidth) != tt_u) ? document.body.clientWidth
\r
337 : (typeof(window.innerWidth) != tt_u) ? window.innerWidth
\r
338 : tt_db ? (tt_db.clientWidth || 0)
\r
341 function tt_GetClientH()
\r
343 return(document.body && (typeof(document.body.clientHeight) != tt_u) ? document.body.clientHeight
\r
344 : (typeof(window.innerHeight) != tt_u) ? window.innerHeight
\r
345 : tt_db ? (tt_db.clientHeight || 0)
\r
348 function tt_Hide(e)
\r
350 e = window.event || e;
\r
353 var target = e.target || e.srcElement;
\r
354 if (tt_element == target)
\r
356 tt_RemEvtFnc(tt_element, "mouseout", tt_Hide);
\r
362 function tt_Scroll(e)
\r
364 e = window.event || e;
\r
367 tt_scrlX = window.pageXOffset || (tt_db ? (tt_db.scrollLeft || 0) : 0);
\r
368 tt_scrlY = window.pageYOffset || (tt_db ? (tt_db.scrollTop || 0) : 0);
\r
370 tt_updatePosition();
\r
373 function tt_Move(e)
\r
375 e = window.event || e;
\r
378 tt_musX = (typeof(e.pageX) != tt_u) ? e.pageX : (e.clientX + tt_scrlX);
\r
379 tt_musY = (typeof(e.pageY) != tt_u) ? e.pageY : (e.clientY + tt_scrlY);
\r
380 if (tt_element == 0 && tt_status & 1)
\r
382 tt_element = e.target || e.srcElement;
\r
383 tt_AddEvtFnc(tt_element, "mouseout", tt_Hide);
\r
385 if (!tt_aV[STICKY] && tt_status&1)
\r
386 tt_updatePosition();
\r
391 // Create the tooltip DIV
\r
392 if(tt_db.insertAdjacentHTML)
\r
393 tt_db.insertAdjacentHTML("afterBegin", tt_MkMainDivHtm());
\r
394 else if(typeof tt_db.innerHTML != tt_u && document.createElement && tt_db.appendChild)
\r
395 tt_db.appendChild(tt_MkMainDivDom());
\r
396 tt_mainDiv = document.getElementById('tt_mytooltip');
\r
397 tt_mainDiv.style.position = "absolute";
\r
398 tt_mainDiv.style.zIndex = 1000;
\r
400 tt_AddEvtFnc(window, "scroll", tt_Scroll);
\r
401 tt_AddEvtFnc(document, "mousemove", tt_Move);
\r
402 tt_AddEvtFnc(window, "unload", tt_finishHideTip);
\r
403 tt_finishHideTip();
\r
404 tt_addLoadEvent(function() {tt_enableHrefTip(document);});
\r
405 document.write('<LINK rel="stylesheet" href="' + cs_patch + 'cs_powered.css" type="text/css" />');
\r
407 function tt_MkMainDivHtm()
\r
409 return('<div id=tt_mytooltip></div>');
\r
411 function tt_MkMainDivDom()
\r
413 var el = document.createElement("div");
\r
415 el.id = "tt_mytooltip";
\r
418 function tt_addLoadEvent(func)
\r
420 var oldonload = window.onload;
\r
421 if (typeof window.onload != 'function')
\r
422 window.onload = func;
\r
424 window.onload = function(){oldonload();func();}
\r
426 function tt_AddEvtFnc(el, sEvt, PFnc)
\r
430 if(el.addEventListener)
\r
431 el.addEventListener(sEvt, PFnc, false);
\r
433 el.attachEvent("on" + sEvt, PFnc);
\r
436 function tt_RemEvtFnc(el, sEvt, PFnc)
\r
440 if(el.removeEventListener)
\r
441 el.removeEventListener(sEvt, PFnc, false);
\r
443 el.detachEvent("on" + sEvt, PFnc);
\r
447 function tt_getOpaSettings()
\r
450 var s = document.body.style;
\r
451 if (typeof s.opacity == 'string') p = 'opacity';
\r
452 else if (typeof s.MozOpacity == 'string') p = 'MozOpacity';
\r
453 else if (typeof s.KhtmlOpacity == 'string') p = 'KhtmlOpacity';
\r
454 else if (document.body.filters && navigator.appVersion.match(/MSIE ([\d.]+);/)[1]>=5.5) p='filter';
\r
457 function tt_SetOpa(oElem, nOpacity)
\r
459 var p = tt_getOpaSettings();
\r
461 tt_SetOpa = new Function('oElem', 'nOpacity', 'if (nOpacity >= 100) {oElem.style.filter = ""; return;} var oAlpha = oElem.filters["DXImageTransform.Microsoft.alpha"] || oElem.filters.alpha; if (oAlpha) oAlpha.opacity = nOpacity;else {oElem.style.zoom = 1;oElem.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity="+nOpacity+")";}');
\r
463 tt_SetOpa = new Function('oElem', 'nOpacity', 'oElem.style.'+p+' = nOpacity/100;');
\r
465 tt_SetOpa = new Function(oElem, nOpacity);
\r
466 return tt_SetOpa(oElem, nOpacity);
\r
468 Number.prototype.Timer = function(s, iT, bUrge)
\r
470 if(!this.value || bUrge)
\r
471 this.value = window.setTimeout(s, iT);
\r
473 Number.prototype.EndTimer = function()
\r
477 window.clearTimeout(this.value);
\r
481 // Creates command names by translating config variable names to upper case
\r
482 function tt_MkCmdEnum()
\r
485 for(var i in config)
\r
486 eval("window." + i.toString().toUpperCase() + " = " + n++);
\r
488 function tt_ReadCmds(a)
\r
491 // First load the global config values, to initialize also values
\r
492 // for which no command has been passed
\r
494 for(var j in config)
\r
495 tt_aV[i++] = config[j];
\r
496 // Then replace each cached config value for which a command has been
\r
497 // passed (ensure the # of command args plus value args be even)
\r
500 for(i = a.length - 1; i > 0; i -= 2)
\r
501 tt_aV[a[i - 1]] = a[i];
\r