1DEBUG_LEVEL = 3; 2RESIZE_MARGIN = 10; 3 4var openerInfo = new Object(); 5var imp = new Object(); 6 7var globalDivs = new Array(); 8var activeDivs = new Array(); 9var divEvents = new Array(); 10var tooltipDivs = new Array(); 11var currentTooltip; 12var timeouts = new Array(); 13var mousePos = new Array(); 14window.iPopups = new Array(); 15window.iFrames = new Array(); //holds references to the content window of dynamically created iframes 16var idCount = 0; 17//var xmlHttp; 18var xmlHttpRequests = new Array(); 19var xmlHttpHandlers = new Array(); 20window.currentIPopup = 0; 21 22var _appDiv; 23 24 25function makeDraggable(obj, handle){ 26 makeCool(obj); 27 obj.grabbed = false; 28 obj.grab = div_grab; 29 obj.ungrab = div_ungrab; 30 if (!handle) handle = obj; 31 else handle.handleObj = obj; 32 handle.onmousedown = obj.grab; 33} 34 35function makeResizable(obj, handle){ 36 obj = getObj(obj); 37 makeCool(obj); 38 obj.resizeGrabbed = false; 39 obj.resizeGrab = div_resizeGrab; 40 obj.resizeUngrab = div_resizeUngrab; 41 obj.resizeCheck = div_resizeCheck; 42 obj.resizeSetCursor = div_resizeSetCursor; 43 if (!handle) handle = obj; 44 else handle.handleObj = obj;
45 handle.onmousedown = obj.resizeGrab; 46 handle.onmousemove = obj.resizeSetCursor; 47} 48 49 50function followMouse(e){ 51 e = normalizeEvent(e); 52 div = activeDivs.slide; 53 normalizeDiv(div); 54 //getObj('debug').innerHTML += '<br>'+e.target; 55 //getObj('debug').innerHTML += '<br>'+e.pro.x+','+e.pro.y; 56 //if (div.prevX && Math.abs(div.prevX - e.pro.x) > 100) return; 57 div.prevX = e.pro.x; 58 div.moveTo(div.grabStartX + (e.pro.x - div.mouseStartX), div.grabStartY + (e.pro.y - div.mouseStartY)); 59} 60 61function resizeFollowMouse(e){ 62 e = normalizeEvent(e); 63 div = activeDivs.resize; 64 normalizeDiv(div); 65 var width, height; 66 //we have to use screenX/Y for it to work over different frames 67 var dX = e.screenX - div.mouseStartX; 68 var dY = e.screenY - div.mouseStartY; 69 switch (div.resizeGrabbed){ 70 case 'l': 71 div.style.width= div.resizeStartWidth - dX; 72 div.moveTo(div.resizeStartX + dX, div.resizeStartY); 73 break; 74 case 'r': 75 div.style.width = div.resizeStartWidth + dX; 76 break; 77 case 't': 78 div.style.height = div.resizeStartHeight - dY; 79 div.moveTo(div.resizeStartX, div.resizeStartY + dY); 80 break; 81 case 'b': 82 div.style.height = div.resizeStartHeight + dY; 83 break; 84 } 85 if (div.fixResize) div.fixResize(); 86} 87 88function ungrab(e){ 89 activeDivs.slide.ungrab(); 90} 91 92function resizeUngrab(e){ 93 activeDivs.resize.resizeUngrab(); 94} 95 96function buildMenu(divId){ 97 var DHTML = (document.getElementById || document.all || document.layers); 98 var div = getObj(divId); 99} 100 101function normalizeEvent(e){ 102 try{ 103 if (!e) var e = window.event; 104 105 e.pro = new Array(); 106 if (e.pageX || e.pageY){ 107 e.pro.x = e.pageX; 108 e.pro.y = e.pageY; 109 } 110 else if (e.clientX || e.clientY){ 111 e.pro.x = e.clientX + document.body.scrollLeft; 112 e.pro.y = e.clientY + document.body.scrollTop; 113 } 114 if (e.srcElement) e.target = e.srcElement; 115 if (e.relatedTarget) e.relTarg = e.relatedTarget; 116 else if (e.fromElement) e.relTarg = e.fromElement; 117 else if (e.toElement) e.relTarg = e.toElement; 118 } 119 catch(exc){ 120 } 121 return e; 122} 123 124function normalizeDiv(obj){ 125 var originalObj = obj; 126 if (obj.calculateXY || (!obj.x && !obj.y) || (obj.x == 'undefined' || obj.y == 'undefined')){ 127 originalObj.calculateXY = true; 128 if (obj.offsetTop){ //it would be more correct to test for offsetParent, but it 129 var originalObj = obj; //misteriously fails in my IE... 130 var left = 0; 131 var top = 0; 132 while (obj.offsetParent){ 133 left += obj.offsetLeft; 134 top += obj.offsetTop; 135 obj = obj.offsetParent; 136 } 137 originalObj.x = left; 138 originalObj.y = top; 139 } 140 } 141 if (!obj.id) obj.id = ++idCount; 142} 143 144function div_resizeSetCursor(e){ 145 var resize = this.resizeCheck(e); 146 switch (resize){ 147 case 'l': 148 this.style.cursor = 'w-resize'; 149 break; 150 case 'r': 151 this.style.cursor = 'e-resize'; 152 break; 153 case 't': 154 this.style.cursor = 'n-resize'; 155 break; 156 case 'b': 157 this.style.cursor = 's-resize'; 158 break; 159 default: 160 this.style.cursor = 'default'; 161 } 162} 163 164function div_resizeCheck(e){ 165 e = normalizeEvent(e); 166 if (this.resizeHandleObj) div = this.resizeHandleObj; 167 else div = this; 168 normalizeDiv(div); 169 if ( ((e.pro.x - this.x) < RESIZE_MARGIN) && ((e.pro.x - this.x) > 0)){ 170 return 'l'; 171 } 172 else if ( ((e.pro.x - this.x - this.offsetWidth) > -RESIZE_MARGIN) && ((e.pro.x - this.x - this.offsetWidth) < 0)){ 173 return 'r'; 174 } 175 if ( ((e.pro.y - this.y) < RESIZE_MARGIN) && ((e.pro.y - this.y) > 0)){ 176 return 't'; 177 } 178 else if ( ((e.pro.y - this.y - this.offsetHeight) > -RESIZE_MARGIN) && ((e.pro.y - this.y - this.offsetHeight) < 0)){ 179 return 'b'; 180 } 181 else{ 182 return false; 183 } 184} 185 186 187function div_resizeGrab(e){ 188 e = normalizeEvent(e); 189 if (this.resizeHandleObj) div = this.resizeHandleObj; 190 else div = this; 191 normalizeDiv(div); 192 div.resizeGrabbed = div.resizeCheck(e); 193 if (!div.resizeGrabbed) return; 194 activeDivs.resize = div; 195 div.resizeStartX = div.x; 196 div.resizeStartY = div.y; 197 div.resizeStartWidth = div.offsetWidth; 198 div.resizeStartHeight = div.offsetHeight; 199 div.mouseStartX = e.screenX; 200 div.mouseStartY = e.screenY; 201 window.onmousemove = resizeFollowMouse; 202 window.onselectstart=new Function ("return false"); 203 window.onmousedown=new Function ("return false"); 204 addEvent(window, 'mouseup', resizeUngrab); 205 for (var i in window.iFrames){ 206 if (!window.iFrames[i].document) continue; 207 addEvent(window.iFrames[i], 'mousemove', resizeFollowMouse); 208 addEvent(window.iFrames[i], 'mouseup', resizeUngrab); 209 } 210} 211 212function div_grab(e){ 213 e = normalizeEvent(e); 214 if (this.handleObj) div = this.handleObj; 215 else div = this; 216 activeDivs.slide = div; 217 normalizeDiv(div); 218 div.grabStartX = div.x; 219 div.grabStartY = div.y; 220 div.mouseStartX = e.pro.x; 221 div.mouseStartY = e.pro.y; 222 if (document.layers){ 223 div.style.clipTop = ''; 224 div.style.clipRight = ''; 225 div.style.clipBottom = ''; 226 div.style.clipLeft = ''; 227 } 228// else{ 229// div.style.clip = ''; 230// } 231 div.style.overflow = 'visible'; 232 div.absoluteClip = null; 233 div.style.visibility = 'visible' 234 window.onmousemove = followMouse; 235 window.onselectstart=new Function ("return false"); 236 window.onmousedown=new Function ("return false"); 237 addEvent(window, 'mouseup', ungrab); 238 for (var i in window.iFrames){ 239 if (!window.iFrames[i].document) continue; 240 addEvent(window.iFrames[i], 'mousemove', followMouse); 241 addEvent(window.iFrames[i], 'mouseup', ungrab); 242 } 243 div.grabbed = true; 244} 245 246function div_resizeUngrab(e){ 247 if (this.resizeHandleObj) div = this.resizeHandleObj; 248 else div = this; 249 window.onmousemove=''; 250 div.resizeGrabbed = false; 251 window.onmousedown=''; 252 window.onselectstart=''; 253 window.onclick=''; 254 for (var i in window.iFrames){ 255 removeEvent(window.iFrames[i], 'mousemove', resizeFollowMouse); 256 } 257} 258 259function div_ungrab(e){ 260 if (this.handleObj) div = this.handleObj; 261 else div = this; 262 window.onmousemove=''; 263 div.grabbed = false; 264 window.onmousedown=''; 265 window.onselectstart=''; 266 window.onclick=''; 267 div.prevX = 0; 268 for (var i in window.iFrames){ 269 removeEvent(window.iFrames[i], 'mousemove', followMouse); 270 } 271} 272 273 274function makeCool(div){ 275 normalizeDiv(div); 276 if (this.isCool) return; 277 div.globalId = globalDivs.push(div) - 1; 278 div.globalRef = "globalDivs["+div.globalId+"]"; 279 div.moveTo = div_moveTo; 280 div.move = div_move; 281 div.absoluteClip = div_absoluteClip; 282 div.moveNextTo = div_moveNextTo; 283 div.pushOn = div_pushOn;
284 div.insertThisBefore = div_insertThisBefore; 285 div.append = div_appendTo; 286 div.remove = div_remove; 287 div.replace = div_replace; 288 div.addClass = div_addClass; 289 div.hasClass = div_hasClass; 290 div.removeClass = div_removeClass; 291 div.addEvent = div_addEvent; 292 div.removeEvent = div_removeEvent; 293 div.setOpacity = div_setOpacity; 294 if (!div.id) div.id = ++idCount; 295 div.isCool = true; 296} 297 298/** 299* @param text string 300* @param section string optional 301* @param level int optional 302*/ 303function debug(text){ 304 section = arguments[1]; 305 level = arguments[2]; 306 if (level && level > DEBUG_LEVEL) return; 307 if (!section) section = 'js'; 308 if (!imp.debugConsole) return; 309 imp.debugConsole.add(section, text); 310} 311 312function div_moveTo(x, y){ 313 this.style.position = "absolute"; 314 this.style.left = x + "px"; 315 this.style.top = y + "px"; 316 if (this.hasAbsoluteClip){ 317 if (document.layers){ 318 this.style.clipTop = this.absoluteClip['top']-x; 319 this.style.clipRight = this.absoluteClip['right']; 320 this.style.clipBottom = this.absoluteClip['bottom']; 321 this.style.clipLeft = this.absoluteClip['left'] - y; 322 } 323 else{ 324 this.style.clip = "rect("+(this.absoluteClip['top']-y)+" "+ this.absoluteClip['right'] + " " +this.absoluteClip['bottom'] + " "+(this.absoluteClip['left']-x)+")"; 325 } 326 } 327} 328 329function div_move(pxX, pxY){ 330 normalizeDiv(this); 331 this.moveTo(this.x + pxX, this.y + pxY); 332} 333 334function div_absoluteClip(absoluteTop, relativeRight, relativeBottom, absoluteLeft){ 335 this.absoluteClip = new Array(); 336 this.absoluteClip['top'] = absoluteTop; 337 this.absoluteClip['right'] = relativeRight; 338 this.absoluteClip['bottom'] = relativeBottom; 339 this.absoluteClip['left'] = absoluteLeft; 340 this.hasAbsoluteClip = true; 341} 342 343function div_setOpacity(opacity){ 344 this.style.opacity = opacity; 345 this.style['-moz-opacity'] = opacity; 346 this.style.filter = "alpha(opacity="+opacity*100+")"; //ie 347} 348 349function div_fade(){ 350} 351 352function div_slide(){ 353} 354 355function div_moveNextTo(div, pos){ 356 normalizeDiv(div); 357 if (pos == 'right') this.moveTo(div.x+div.offsetWidth, div.y); 358 else if (pos == 'bottom') this.moveTo(div.x, div.y+div.offsetHeight); 359 else if (pos == 'left') this.moveTo(div.x-this.offsetWidth, div.y); 360 else if (pos == 'top') this.moveTo(div.x, div.y-this.offsetHeight); 361} 362 363function div_pushOn(div, slide){ 364 normalizeDiv(div); 365 makeCool(div); 366 this.moveTo(div.x, div.y); 367 div.moveNextTo(this, slide); 368} 369 370function div_insertThisBefore(div){ 371 div.parentNode.insertBefore(this, div); 372} 373 374function div_appendTo(div){ 375 div.appendChild(this); 376} 377 378function div_remove(){ 379 this.parentNode.removeChild(this); 380} 381 382function div_replace(div){ 383 div.parentNode.insertBefore(this, div); 384 div.parentNode.removeChild(div); 385} 386 387//function div_restore(){ 388// if (!removedDivs[div.id]) return; 389// if (removedDivs[div.id]['next']) this.insertThisBefore(removedDivs[div.id]['next']); 390// else this.appendTo(removedDivs[div.id]['parent']); 391//} 392 393function div_addClass(n){ 394 this.removeClass(n); 395 this.className += " "+n; 396} 397 398function div_removeClass(n){ 399 classes = this.className.split(" "); 400 className = ""; 401 for (var i=0; i<classes.length; i++){ 402 if (classes[i] != n) className += classes[i] + " "; 403 } 404 this.className = ""+className; 405} 406 407function div_hasClass(name){ 408 var pos = this.className.indexOf(name); 409 if (pos > 0 && (this.className.length <= pos + name.length || this.className.charAt(pos+1) == ' ')) return true; 410 return false; 411} 412 413function addEvent(obj, name, func){ 414 try{ 415 removeEvent(obj, name, func); 416 } catch(exc){ 417 } 418 if (obj.addEventListener) obj.addEventListener(name, func, false); 419 else if (obj.attachEvent) obj.attachEvent('on'+name, func); 420} 421 422function removeEvent(obj, name, func){ 423 try{ 424 if (obj.removeEventListener) obj.removeEventListener(name, func, false); 425 else if (obj.detachEvent) obj.detachEvent('on'+name, func); 426 } 427 catch(exc){} 428} 429 430function stopPropagation(e){ 431 if (!e) var e = window.event; 432 e.cancelBubble = true; 433 if (e.stopPropagation) e.stopPropagation(); 434} 435 436function div_addEvent(name, func){ 437 addEvent(this, name, func); 438} 439 440function div_removeEvent(name, func){ 441 removeEvent(this, name, func); 442} 443 444 445function getObj(name){ 446 var obj; 447 if (typeof(name) == 'object') obj = name; 448 else if (document.getElementById) obj = document.getElementById(name); 449 else if (document.all) obj = document.all[name]; 450 else if (document.layers) obj = getNN4Obj(document, name); 451 if (obj && !obj.id) obj.id = 'obj'+(idCount++); 452 return obj;
453} 454 455function getEl(name){ 456 var el = document.createElement(name); 457 makeCool(el); 458 return el; 459} 460 461function getNN4Obj(obj, name){ 462 var x = obj.layers; 463 for (var i=0; i<x.length; i++){ 464 if (x[i].id == name) return x[i]; 465 else if (x[i].layers.length){ 466 var tmp = getNN4Obj(x[i], name); 467 if (tmp) return tmp; 468 } 469 } 470} 471 472function appendObj(div){ 473 if (!_appDiv){ 474 _appDiv = document.createElement('div'); 475 document.body.appendChild(_appDiv); 476 } 477 _appDiv.appendChild(div); 478} 479 480/* www.webreference.com ---> */ 481 482function setCookie(name, value, expires, path, domain, secure) { 483 var curCookie = name + "=" + escape(value) + 484 ((expires) ? "; expires=" + expires.toGMTString() : "") + 485 ((path) ? "; path=" + path : "") + 486 ((domain) ? "; domain=" + domain : "") + 487 ((secure) ? "; secure" : ""); 488 document.cookie = curCookie; 489} 490 491function getCookie(name) { 492 var dc = document.cookie; 493 var prefix = name + "="; 494 var begin = dc.indexOf("; " + prefix); 495 if (begin == -1) { 496 begin = dc.indexOf(prefix); 497 if (begin != 0) return null; 498 } else 499 begin += 2; 500 var end = document.cookie.indexOf(";", begin); 501 if (end == -1) 502 end = dc.length; 503 return unescape(dc.substring(begin + prefix.length, end)); 504} 505 506function deleteCookie(name, path, domain) { 507 if (getCookie(name)) { 508 document.cookie = name + "=" + 509 ((path) ? "; path=" + path : "") + 510 ((domain) ? "; domain=" + domain : "") + 511 "; expires=Thu, 01-Jan-70 00:00:01 GMT"; 512 } 513} 514 515// date - any instance of the Date object 516// * hand all instances of the Date object to this function for "repairs" 517 518function fixDate(date) { 519 var base = new Date(0); 520 var skew = base.getTime(); 521 if (skew > 0) 522 date.setTime(date.getTime() - skew); 523} 524/* ---> www.webreference.com */ 525 526 527function getWindowSize(){ 528 if (window.innerWidth){ 529 window.width = window.innerWidth; 530 window.height = window.innerHeight; 531 } 532 else if (document.body.offsetWidth){ 533 window.width = document.body.offsetWidth; 534 window.height = document.body.offsetHeight; 535 } 536 else{ 537 window.width = 630; 538 window.height = 460; 539 } 540} 541 542function stopBubbling(e){ 543 if (e.stopPropagation) e.stopPropagation(); 544 else e.cancelBubble = true; 545 546} 547 548function addTooltip(div, text){ 549 makeCool(div); 550 div.addEvent('mouseover', function(e){tooltip(e, text); }); 551 div.addEvent('mouseout', function(e){ untooltip(e); }); 552} 553 554function removeTooltip(){ 555 if (currentTooltip){ 556 makeCool(currentTooltip); 557 try{ 558 currentTooltip.remove(); 559 } catch (exc){ 560 } 561 } 562} 563 564 565function tooltip(e, text){ 566 for (var i in tooltipDivs){ 567 if (i != 0) untooltipDiv(i); 568 } 569 tooltipDivs = new Array(); 570 normalizeEvent(e); 571 div = e.target; 572 normalizeDiv(div); 573 var tt = document.createElement('div'); 574 tt.className = 'tooltip'; 575 tt.style.position = 'absolute'; 576 tt.id = 'tt_'+div.id; 577 tt.innerHTML = text; 578 //var t = document.createTextNode(text); 579 //tt.appendChild(t); 580 tt.style.display = 'none'; 581 appendObj(tt); 582 makeCool(tt); 583 div.tt = tt; 584 div.addEvent('mousemove', function(e){ moveTooltip(e); }); 585 tooltipDivs.push(div); 586 stopBubbling(e); 587 588} 589 590function moveTooltip(e){ 591 normalizeEvent(e); 592 getWindowSize(); 593 var destX, destY; 594 var ttWidth = e.target.tt.offsetWidth; 595 var ttHeight = e.target.tt.offsetHeight; 596 if (e.pro.x < window.width-ttWidth-30) destX = e.pro.x + 10; 597 else destX = e.pro.x - ttWidth - 10; 598 if (e.pro.y < window.height-ttHeight-30) destY = e.pro.y + 10; 599 else destY = e.pro.y - ttHeight - 10; 600 currentTooltip = e.target.tt; 601 e.target.tt.style.display = ''; 602 e.target.tt.moveTo(destX, destY); 603} 604 605function untooltip(e){ 606 normalizeEvent(e); 607 untooltipDiv(e.target); 608} 609 610function untooltipDiv(div){ 611 makeCool(div); 612 div.removeEvent('mousemove', moveTooltip); 613 tt = getObj('tt_'+div.id); 614 if (tt) tt.remove(); 615} 616 617function closeIPopups(){ 618 for (var i in window.iPopups) if (i.remove) i.remove(); 619 window.iPopups = new Array(); 620} 621 622function closeIPopup(num){
623// if (window.iPopup){ 624 try{ 625 document.body.removeChild(window.iPopups[num]); 626 window.iPopups[num] = null; 627 } 628 catch(exc){ 629 } 630// } 631// else window.close(); 632} 633 634function iPopupClose(){ 635 if (window.parent && window.parent.closeIPopup && window.iPopup) window.parent.closeIPopup(window.iPopup.iPopupNum); 636 else window.close(); 637} 638 639/** 640* Opens an url as a DHTML popup 641* 642* @param src string address of the html document to display 643* @param name string will be the name of the iframe 644* @param title string optional descriptive title to display 645* @return object div a reference to the outer div 646*/ 647function openIPopup(src, name, title){ 648// closeIPopups(); 649 var iframe = createIFrame(name, src); 650 div = makeIPopup(iframe, title); 651 iframe.iPopupNum = div.iPopupNum; 652 iframe.contentWindow.iPopup = div; 653 iframe.contentWindow.iPopupNum = div.iPopupNum; 654 div.iPopupIframe = iframe; 655 return div; 656} 657 658function createIPopup(title){ 659 var div = document.createElement('div'); 660 return makeIPopup(div, title); 661} 662 663/** 664* @param div object 665* @param title string optional 666*/ 667function makeIPopup(div, title){ 668 makeCool(div); 669 div.style.width = '100%'; 670 div.style.height = '100%'; 671 var container = document.createElement('div'); 672 window.iPopups.push(container); 673 var iPopupNum = window.iPopups.length-1; 674 makeCool(container); 675 container.iPopupNum = iPopupNum; 676 container.className = 'iPopup container'; 677 var handle = document.createElement('div'); 678 handle.className = 'iPopup handle'; 679 var aspan = document.createElement('span'); 680 var a = document.createElement('a'); 681 a.className = 'iPopup action close'; 682 a.href = 'javascript: window.parent.closeIPopup('+iPopupNum+')'; 683 a.innerHTML = 'X'; 684 aspan.appendChild(a); 685 handle.appendChild(aspan); 686 if (title){ 687 var caption = document.createElement('span'); 688 caption.className = 'iPopup caption'; 689 caption.innerHTML = " "+title; 690 handle.appendChild(caption); 691 } 692 //div.insertBefore(handle, div.firstChild); 693 //div.appendChild(handle); 694 container.appendChild(handle); 695 div.addClass('iPopup content'); 696 container.appendChild(div); 697 makeDraggable(container, handle); 698 makeResizable(container); 699 container.handle = handle; 700 container.content = div; 701 container.addEvent('click', function(e){window.currentIPopup = this.iPopupNum;}); 702 document.body.appendChild(container); 703 position(container); 704 container.content = div; 705 container.handle = handle; 706 //this is an awful hack, but I have no other ideas... 707 container.fixResize = function (){ this.content.style.height = this.offsetHeight - this.handle.offsetHeight - 6;}; 708 container.fixResize(); 709 return container; 710} 711 712function createIFrame(name, src){ 713 debug("Creating iframe "+name); 714 var iframe = document.createElement('iframe'); 715 iframe.onload = function(){ if (this.contentWindow && parent.iFrames){ parent.iFrames[name]=this.contentWindow;} }; 716 iframe.name = name; 717 iframe.src = src; 718 return iframe; 719} 720 721function position(div, x, y){ 722 makeCool(div); 723 getWindowSize(); 724 if (x==undefined) div.moveTo((window.width-div.offsetWidth)/2, (window.height-div.offsetHeight)/2); 725 else{ 726 if (x+div.offsetWidth > window.width) x -= div.width; 727 if (y+div.offsetHeight > window.height) y -= div.height; 728 div.moveTo(x, y); 729 } 730} 731 732var titlesArray; 733function getTitles(div){ 734 titlesArray = new Array(); 735 recGetTitles(div); 736 return titlesArray.length; 737} 738 739function buildIndex(container){ 740 for (var i in titlesArray){ 741 div = titlesArray[i]; 742 a = document.createElement('a'); 743 a.name = 'index'+i; 744 div.parentNode.insertBefore(a, div); 745 index = document.createElement('a'); 746 index.href='#index'+i; 747 index.innerHTML = div.innerHTML; 748 container.appendChild(index); 749 br = document.createElement('br'); 750 container.appendChild(br); 751 } 752} 753 754function recGetTitles(div){ 755 spans = div.getElementsByTagName('span'); 756 for (var i in spans){ 757 if (spans[i].className == 'sottotitolo'){ 758 titlesArray.push(spans[i]); 759 //recGetTitles(spans[i]); 760 } 761 } 762} 763 764function toggle(divId, indicator, htmlOn, htmlOff){ 765 div = getObj(divId); 766 var divIndicator; 767 if (!div || !div.style) return; 768 if (indicator) divIndicator = getObj(indicator); 769 if (div.style.display == 'none'){ 770 if (divIndicator) divIndicator.innerHTML = htmlOff; 771 div.style.display = ''; 772 } 773 else{ 774 if (divIndicator) divIndicator.innerHTML = htmlOn; 775 div.style.display = 'none'; 776 } 777} 778 779var fixedDivs = new Array(); 780var fixedDivsTimeout; 781 782function makeFixedPos(div){ 783 if (div.style.display == 'none') div.style.display = 'block'; 784 makeCool(div); 785 div.fixedPosX = div.x; 786 div.fixedPosY = div.y; 787 div.moveTo(div.fixedPosX, div.fixedPosY); 788 fixedDivs.push(div); 789 if (!fixedDivsTimeout) fixedDivsTimeout = setTimeout('updateFixedPos()', 100); 790} 791 792function updateFixedPos(){ 793 if (window.innerHeight) pos = window.pageYOffset 794 else if (document.documentElement && document.documentElement.scrollTop) pos = document.documentElement.scrollTop 795 else if (document.body) pos = document.body.scrollTop 796 for (var i in fixedDivs){ 797 var div = fixedDivs[i]; 798 div.moveTo(div.fixedPosX, div.fixedPosY + pos); 799 } 800 fixedDivsTimeout = setTimeout('updateFixedPos()', 500); 801} 802 803 804function startTimeout(func, interval){
805 var r = setTimeout(func, interval); 806 timeouts[r] = new Array(); 807 timeouts[r][0] = func; 808 timeouts[r][1] = interval; 809 return r; 810} 811 812//NOTE: this will reset even if the timeout is already expired. 813function resetTimeout(t){ 814 if (!t) return; 815 var func, interval; 816 if (timeouts[t]){ 817 func = timeouts[t][0]; 818 interval = timeouts[t][1]; 819 } 820 if (t) clearTimeout(t); 821 var nt; 822 if (interval && func){ 823 nt = startTimeout(func, interval); 824 } 825 return nt; 826} 827 828 829 830function trackMouse(e){ 831 normalizeEvent(e); 832 mousePos.x = e.pro.x; 833 mousePos.y = e.pro.y; 834} 835 836function mouseInside(div){ 837 normalizeDiv(div); 838 if (mousePos.x > div.x && mousePos.x < div.x+div.offsetWidth && mousePos.y > div.y && mousePos.y < div.y+div.offsetHeight) return true; 839 return false; 840} 841 842makeCool(document); 843document.addEvent('mousemove', trackMouse); 844 845function getAllChildren(div, array){ 846 if (!array) array = new Array(); 847 848} 849 850function getObjectsByClasses(){ 851} 852 853function makeViewport(div){ 854 var container = document.createElement('div'); 855 container.className = 'viewport container'; 856 var handle = document.createElement('div'); 857 handle.className = 'viewport handle'; 858 container.appendChild(handle); 859 container.appendChild(div); 860 makeCool(div); 861 div.addClass('viewportEl'); 862 makeDraggable(container, handle); 863} 864 865function getXmlHttp(){ 866 var x=false; 867 try { 868 x = new ActiveXObject("Msxml2.XMLHTTP"); 869 } catch (e) { 870 try { 871 x = new ActiveXObject("Microsoft.XMLHTTP"); 872 } catch (E) { 873 x = false; 874 } 875 } 876 if (!x && typeof XMLHttpRequest!='undefined') { 877 x = new XMLHttpRequest(); 878 } 879 return x; 880} 881 882function buildQueryString(form){ 883 var qstr = ""; 884 var tmp = ""; 885 fl = form.elements.length; 886 for(i=0;i<fl;i++) { 887 el = form.elements[i]; 888 if((el.type == 'text' ) || (el.type == 'checkbox' && el.checked == true) || 889 (el.type == 'textarea') || (el.type == 'radio' && el.checked == true) || 890 (el.type == 'hidden' )) { //&& el.value.length > 0 891 tmp = el.name+'='+escape(el.value)+'&'; 892 } 893 if(typeof(el.selectedIndex) != 'undefined' && el.selectedIndex != -1){ 894 for(j=0;j<el.options.length;j++) { if(el.options[j].selected == true) { 895 tmp += el.name+'='+escape(el.options[j].value)+'&'; } 896 } 897 } 898 if(tmp.length > 0) { qstr += tmp; tmp = "";} 899 } 900 qstr = qstr.substring(0,qstr.length - 1); 901 return qstr; 902} 903 904//optional param: method (POST, GET) 905function xmlHttpQuery(url, query, method, name, timeout, failCallback, requestName, xmlHttp){ 906 //var method = arguments[2]; 907 if (!method) method = 'POST'; 908 if (!timeout) timeout = 5000; 909 var xmlHttp; 910 if (name){ 911 //not working 912 xmlHttp = xmlHttpRequests[name]; 913 if (xmlHttp && callInProgress(xmlHttp)){ 914 xmlHttp.aborting = 1; 915 xmlHttp.abort(); 916 } 917 } 918 if (!xmlHttp) xmlHttp = getXmlHttp(); 919 if (name) xmlHttpRequests[name] = xmlHttp; 920 xmlHttp.open(method, url,true); 921 if (method == 'POST'){ 922 xmlHttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded'); 923 } 924 xmlHttp.onreadystatechange=function() { 925 if (xmlHttp.readyState==4) { 926 //alert(xmlHttp.responseText); 927 //getObj('debug').innerHTML = xmlHttp.responseText; 928 if (xmlHttp.aborting){ 929 xmlHttp.aborting = 0; 930 return; 931 } 932 if (xmlHttp.status != 200){ 933 if (failCallback) failCallback; 934 //alert(xmlHttp.status); 935 } 936 try{ 937 var xmlDoc = xmlHttp.responseXML; 938 if ((!xmlDoc || !xmlDoc.documentElement) && xmlHttp.responseText){ 939 xmlDoc = parseXmlHttpResponse(xmlHttp.responseText); 940 } 941 if (!xmlDoc || !xmlDoc.documentElement) throw 'Invalid XML response'; 942 var root = xmlDoc.documentElement; 943 for (var i=0; i<root.childNodes.length; i++){ 944 if (root.childNodes[i].nodeType == 1 && xmlHttpHandlers[root.childNodes[i].nodeName]){ 945 if (typeof(xmlHttpHandlers[root.childNodes[i].nodeName]) == 'object'){ 946 for (var j=0; j<xmlHttpHandlers[root.childNodes[i].nodeName].length; j++){ 947 xmlHttpHandlers[root.childNodes[i].nodeName][j](root.childNodes[i]); 948 } 949 } 950 else xmlHttpHandlers[root.childNodes[i].nodeName](root.childNodes[i]); 951 } 952 } 953 } 954 catch(exp){ 955 if (failCallback) failCallback(); 956 } 957 } 958 } 959 //not working 960 //window.setTimeout(function() { 961 // if ( callInProgress(xmlHttp) ) { 962 // xmlHttp.aborting = 1; 963 // xmlHttp.abort(); 964 // if (failCallback) failCallback(); 965 // } 966 //},timeout); 967 if (query) query += "&"; 968 else query = ""; 969 //query += "o=xml&XDEBUG_PROFILE=1"; 970 query += "o=xml"; 971 //getObj('debug').innerHTML = query; 972 //alert(query); 973 xmlHttp.send(query) 974} 975 976function parseXmlHttpResponse(responseText){ 977 responseText = normalizeXmlHttpResponseText(responseText); 978 var xmlDoc = null; 979 if (window.DOMParser){ 980 xmlDoc = (new DOMParser()).parseFromString(responseText, 'text/xml'); 981 if (xmlDoc && xmlDoc.documentElement && xmlDoc.documentElement.nodeName == 'parsererror'){ 982 return null; 983 } 984 return xmlDoc; 985 } 986 if (window.ActiveXObject){ 987 xmlDoc = new ActiveXObject('Microsoft.XMLDOM'); 988 xmlDoc.async = false; 989 xmlDoc.loadXML(responseText); 990 if (xmlDoc.parseError && xmlDoc.parseError.errorCode != 0){ 991 return null; 992 } 993 return xmlDoc; 994 } 995 return null; 996} 997 998function normalizeXmlHttpResponseText(responseText){ 999 if (!responseText) return responseText; 1000 responseText = responseText.replace(/^\uFEFF/, ''); 1001 responseText = responseText.replace(/^[\s\r\n\t]+(?=<)/, ''); 1002 return responseText; 1003} 1004 1005function addXmlHttpHandler(name, func){ 1006 if (xmlHttpHandlers[name] && typeof(xmlHttpHandlers[name]) != 'object'){ 1007 xmlHttpHandlers[name] = [xmlHttpHandlers[name]]; 1008 } 1009 if (!xmlHttpHandlers[name]) xmlHttpHandlers[name] = new Array(); 1010 xmlHttpHandlers[name][xmlHttpHandlers[name].length] = func; 1011 return xmlHttpHandlers[name].length - 1; 1012} 1013 1014function callInProgress(xmlhttp) { 1015 switch ( xmlhttp.readyState ) { 1016 case 1, 2, 3: 1017 return true; 1018 break; 1019 1020 // Case 4 and 0 1021 default: 1022 return false; 1023 break; 1024 } 1025} 1026 1027 1028//Modified from: 1029// @name The Fade Anything Technique 1030// @namespace http://www.axentric.com/aside/fat/ 1031// @version 1.0-RC1 1032// @author Adam Michela 1033 1034function makeHex(r,g,b){
1035 r = r.toString(16); if (r.length == 1) r = '0' + r; 1036 g = g.toString(16); if (g.length == 1) g = '0' + g; 1037 b = b.toString(16); if (b.length == 1) b = '0' + b; 1038 return "#" + r + g + b; 1039} 1040 1041function fadeAndBack(el, fps, duration1, duration2, target, property){ 1042 var color = getBgcolor(el, property); 1043 var o = getObj(el); 1044 callback = "fadeElement('"+o.id+"', "+fps+", "+duration2+", '"+color+"', '', '"+property+"');"; 1045 fadeElement(el, fps, duration1, target, callback, property); 1046} 1047 1048function fadeElement(el, fps, duration, to, callback, property){ 1049 var o = getObj(el); 1050 var frames = Math.round(fps * (duration / 1000)); 1051 var interval = duration / frames; 1052 var delay = interval; 1053 var frame = 0; 1054 var from = getBgcolor(el, property); 1055 var rf = parseInt(from.substr(1,2),16); 1056 var gf = parseInt(from.substr(3,2),16); 1057 var bf = parseInt(from.substr(5,2),16); 1058 var rt = parseInt(to.substr(1,2),16); 1059 var gt = parseInt(to.substr(3,2),16); 1060 var bt = parseInt(to.substr(5,2),16); 1061 1062 var r,g,b,h; 1063 while (frame < frames){ 1064 r = Math.floor(rf * ((frames-frame)/frames) + rt * (frame/frames)); 1065 g = Math.floor(gf * ((frames-frame)/frames) + gt * (frame/frames)); 1066 b = Math.floor(bf * ((frames-frame)/frames) + bt * (frame/frames)); 1067 h = makeHex(r,g,b); 1068 1069 setTimeout("setBgcolor('"+o.id+"','"+h+"','"+property+"')", delay); 1070 1071 frame++; 1072 delay = interval * frame; 1073 } 1074 setTimeout("setBgcolor('"+o.id+"','"+to+"','"+property+"')", delay); 1075 if (callback) setTimeout(callback, delay+interval+100); 1076 1077} 1078 1079function setBgcolor(el, c, property) 1080 { 1081 if (!property || typeof(property) == 'undefined') property = 'background-color'; 1082 var parts = property.split('-'); 1083 if (parts.length > 1){ 1084 property = parts[0]+parts[1].substring(0,1).toUpperCase()+parts[1].substring(1,parts[1].length); 1085 } 1086 var o = getObj(el); 1087 if (o) eval('o.style.'+property+' = c'); 1088 } 1089function getBgcolor(el, property){ 1090 var o = getObj(el); 1091 if (!property || typeof(property) == 'undefined') property = 'background-color'; 1092 var parts = property.split('-'); 1093 if (parts.length > 1){ 1094 ucWProperty = parts[0]+parts[1].substring(0,1).toUpperCase()+parts[1].substring(1,parts[1].length); 1095 } 1096 while(o) 1097 { 1098 var c; 1099 if (window.getComputedStyle) c = window.getComputedStyle(o,null).getPropertyValue(property); 1100 if (o.currentStyle) eval('c = o.currentStyle.'+ucWProperty); 1101 if ((c != "" && c != "transparent") || o.tagName == "BODY") { break; } 1102 o = o.parentNode; 1103 } 1104 if (c == undefined || c == "" || c == "transparent") c = "#FFFFFF"; 1105 var rgb = c.match(/rgb\s*\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)/); 1106 if (rgb) c = makeHex(parseInt(rgb[1]),parseInt(rgb[2]),parseInt(rgb[3])); 1107 return c; 1108} 1109 1110function noa(){ 1111} 1112 1113function disableSelection(element, exceptionTags, exceptionIds){ 1114 element.style.MozUserSelect = 'none' ; 1115 if (!element.all) return; 1116 element.unselectable = 'on' ; 1117 if (!exceptionTags) exceptionTags = new Array(); 1118 if (!exceptionIds) exceptionIds = new Array(); 1119 1120 var e, i = 0 ; 1121 /* 1122 while ( e = element.all[ i++ ] ){ 1123 if (exceptionTags[e.tagName]) continue; 1124 if (exceptionIds[e.id]) continue; 1125 disableSelection(e); 1126 }*/ 1127 while ( e = element.all[ i++ ] ){ 1128 /* 1129 switch ( e.tagName.toUpperCase() ) 1130 { 1131 case 'IFRAME' : 1132 case 'TEXTAREA' : 1133 case 'INPUT' : 1134 case 'SELECT' : 1135 // Ignore the above tags 1136 break ; 1137 default : 1138 e.unselectable = 'on' ; 1139 } 1140 */ 1141 disableSelection(e); 1142 } 1143} 1144/* 1145var reportStatus = new Array(); 1146function report ( msg ) { 1147 reportStatus.push ( msg ); 1148} 1149function showReport ( err ) { 1150 alert ( reportStatus.join ( "\n" ) ); 1151} 1152window.onerror = function ( err, url, line ) { 1153 report ( err + " [" + url + " - line " + line + "]" ); 1154 showReport(); 1155} 1156 1157*/
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.