1// ----------------------------------------------------------------------------------- 2// 3// Lightbox v2.03 4// by Lokesh Dhakar - http://www.huddletogether.com 5// 4/9/06 6// 7// For more information on this script, visit: 8// http://huddletogether.com/projects/lightbox2/ 9// 10// Licensed under the Creative Commons Attribution 2.5 License - http://creativecommons.org/licenses/by/2.5/ 11// 12// Credit also due to those who have helped, inspired, and made their code available to the public. 13// Including: Scott Upton(uptonic.com), Peter-Paul Koch(quirksmode.org), Thomas Fuchs(mir.aculo.us), and others. 14// 15// Lightbox v2.03a 16// by Dynamicdrive.com- http://www.dynamicdrive.com 17// Nov 29th, 2007 18// Added ability for the caption ("title" attr of link) to be optionally hyperlinked, by throwing in a "rev" attr containing the desired link 19// ----------------------------------------------------------------------------------- 20/* 21 22 Table of Contents 23 ----------------- 24 Configuration 25 Global Variables 26 27 Extending Built-in Objects 28 - Object.extend(Element) 29 - Array.prototype.removeDuplicates() 30 - Array.prototype.empty() 31 32 Lightbox Class Declaration 33 - initialize() 34 - start() 35 - changeImage() 36 - resizeImageContainer() 37 - showImage() 38 - updateDetails() 39 - updateNav() 40 - enableKeyboardNav() 41 - disableKeyboardNav() 42 - keyboardAction() 43 - preloadNeighborImages() 44 - end() 45 46 Miscellaneous Functions 47 - getPageScroll() 48 - getPageSize() 49 - getKey() 50 - listenKey() 51 - showSelectBoxes() 52 - hideSelectBoxes() 53 - showFlash() 54 - hideFlash() 55 - pause() 56 - initLightbox() 57 58 Function Calls 59 - addLoadEvent(initLightbox) 60 61*/ 62// ----------------------------------------------------------------------------------- 63 64// 65// Configuration 66// 67 68var fileLoadingImage = "./img/loading.gif"; 69var fileBottomNavCloseImage = "./img/closelabel.gif"; 70 71try 72{ 73 if (OnAdmin) 74 { 75 fileLoadingImage = "../../img/loading.gif"; 76 fileBottomNavCloseImage = "../../img/closelabel.gif"; 77 } 78} 79catch (graycellexp) 80{ 81 fileLoadingImage = "./img/loading.gif"; 82 fileBottomNavCloseImage = "./img/closelabel.gif"; 83} 84 85var animate = true; // toggles resizing animations 86var resizeSpeed = 7; // controls the speed of the image resizing animations (1=slowest and 10=fastest) 87 88var borderSize = 10; //if you adjust the padding in the CSS, you will need to update this variable 89 90// ----------------------------------------------------------------------------------- 91 92// 93// Global Variables 94// 95var imageArray = new Array; 96var activeImage; 97 98if(animate == true){ 99 overlayDuration = 0.2; // shadow fade in/out duration 100 if(resizeSpeed > 10){ resizeSpeed = 10;} 101 if(resizeSpeed < 1){ resizeSpeed = 1;} 102 resizeDuration = (11 - resizeSpeed) * 0.15; 103} else { 104 overlayDuration = 0; 105 resizeDuration = 0; 106} 107 108// ----------------------------------------------------------------------------------- 109 110// 111// Additional methods for Element added by SU, Couloir 112// - further additions by Lokesh Dhakar (huddletogether.com) 113// 114Object.extend(Element, { 115 getWidth: function(element) { 116 element = $(element); 117 return element.offsetWidth; 118 }, 119 setWidth: function(element,w) { 120 element = $(element); 121 element.style.width = w +"px"; 122 }, 123 setHeight: function(element,h) { 124 element = $(element); 125 element.style.height = h +"px"; 126 }, 127 setTop: function(element,t) { 128 element = $(element); 129 element.style.top = t +"px"; 130 }, 131 setSrc: function(element,src) { 132 element = $(element); 133 element.src = src; 134 }, 135 setHref: function(element,href) { 136 element = $(element); 137 element.href = href; 138 }, 139 setInnerHTML: function(element,content) { 140 element = $(element); 141 element.innerHTML = content; 142 } 143}); 144 145// ----------------------------------------------------------------------------------- 146 147// 148// Extending built-in Array object 149// - array.removeDuplicates() 150// - array.empty() 151// 152Array.prototype.removeDuplicates = function () { 153 for(i = 0; i < this.length; i++){ 154 for(j = this.length-1; j>i; j--){ 155 if(this[i][0] == this[j][0]){ 156 this.splice(j,1); 157 } 158 } 159 } 160} 161 162// ----------------------------------------------------------------------------------- 163 164Array.prototype.empty = function () { 165 for(i = 0; i <= this.length; i++){ 166 this.shift(); 167 } 168} 169 170// ----------------------------------------------------------------------------------- 171 172// 173// Lightbox Class Declaration 174// - initialize() 175// - start() 176// - changeImage() 177// - resizeImageContainer() 178// - showImage() 179// - updateDetails() 180// - updateNav() 181// - enableKeyboardNav() 182// - disableKeyboardNav() 183// - keyboardNavAction() 184// - preloadNeighborImages() 185// - end() 186// 187// Structuring of code inspired by Scott Upton (http://www.uptonic.com/) 188// 189var Lightbox = Class.create(); 190 191Lightbox.prototype = { 192 193 // initialize() 194 // Constructor runs on completion of the DOM loading. Loops through anchor tags looking for 195 // 'lightbox' references and applies onclick events to appropriate links. The 2nd section of 196 // the function inserts html at the bottom of the page which is used to display the shadow 197 // overlay and the image container. 198 // 199 initialize: function() { 200 if (!document.getElementsByTagName) { return; } 201 var anchors = document.getElementsByTagName('a'); 202 var areas = document.getElementsByTagName('area'); 203 204 // loop through all anchor tags 205 for (var i = 0; i < anchors.length; i++) { 206 var anchor = anchors[i]; 207 208 var relAttribute = String(anchor.getAttribute('rel')); 209 210 // use the string.match() method to catch 'lightbox' references in the rel attribute 211 if (anchor.getAttribute('href') && (relAttribute.toLowerCase().match('lightbox'))) { 212 anchor.onclick = function() { myLightbox.start(this); return false; } 213 } 214 } 215 216 // loop through all area tags
217 // todo: combine anchor & area tag loops 218 for (var i = 0; i < areas.length; i++) { 219 var area = areas[i]; 220 221 var relAttribute = String(area.getAttribute('rel')); 222 223 // use the string.match() method to catch 'lightbox' references in the rel attribute 224 if (area.getAttribute('href') && (relAttribute.toLowerCase().match('lightbox'))) { 225 area.onclick = function() { myLightbox.start(this); return false; } 226 } 227 } 228 229 // The rest of this code inserts html at the bottom of the page that looks similar to this: 230 // 231 // <div id="overlay"></div> 232 // <div id="lightbox"> 233 // <div id="outerImageContainer"> 234 // <div id="imageContainer"> 235 // <img id="lightboxImage"> 236 // <div style="" id="hoverNav"> 237 // <a href="#" id="prevLink"></a> 238 // <a href="#" id="nextLink"></a> 239 // </div> 240 // <div id="loading"> 241 // <a href="#" id="loadingLink"> 242 // <img src="images/loading.gif"> 243 // </a> 244 // </div> 245 // </div> 246 // </div> 247 // <div id="imageDataContainer"> 248 // <div id="imageData"> 249 // <div id="imageDetails"> 250 // <span id="caption"></span> 251 // <span id="numberDisplay"></span> 252 // </div> 253 // <div id="bottomNav"> 254 // <a href="#" id="bottomNavClose"> 255 // <img src="images/close.gif"> 256 // </a> 257 // </div> 258 // </div> 259 // </div> 260 // </div> 261 262 263 var objBody = document.getElementsByTagName("body").item(0); 264 265 var objOverlay = document.createElement("div"); 266 objOverlay.setAttribute('id', 'overlay'); 267 objOverlay.style.display = 'none'; 268 objOverlay.onclick = function() { myLightbox.end(); } 269 objBody.appendChild(objOverlay); 270 271 var objLightbox = document.createElement("div"); 272 objLightbox.setAttribute('id', 'lightbox'); 273 objLightbox.style.display = 'none'; 274 objLightbox.onclick = function(e) { // close Lightbox is user clicks shadow overlay 275 if (!e) var e = window.event; 276 var clickObj = Event.element(e).id; 277 if (clickObj == 'lightbox') { 278 myLightbox.end(); 279 } 280 }; 281 objBody.appendChild(objLightbox); 282 283 var objOuterImageContainer = document.createElement("div"); 284 objOuterImageContainer.setAttribute('id', 'outerImageContainer'); 285 objLightbox.appendChild(objOuterImageContainer); 286 287 // When Lightbox starts it will resize itself from 250 by 250 to the current image dimension. 288 // If animations are turned off, it will be hidden as to prevent a flicker of a 289 // white 250 by 250 box. 290 if (animate) { 291 Element.setWidth('outerImageContainer', 250); 292 Element.setHeight('outerImageContainer', 250); 293 } else { 294 Element.setWidth('outerImageContainer', 1); 295 Element.setHeight('outerImageContainer', 1); 296 } 297 298 var objImageContainer = document.createElement("div"); 299 objImageContainer.setAttribute('id', 'imageContainer'); 300 objOuterImageContainer.appendChild(objImageContainer); 301 302 var objLightboxImage = document.createElement("img"); 303 objLightboxImage.setAttribute('id', 'lightboxImage'); 304 objImageContainer.appendChild(objLightboxImage); 305 306 var objHoverNav = document.createElement("div"); 307 objHoverNav.setAttribute('id', 'hoverNav'); 308 objImageContainer.appendChild(objHoverNav); 309 310 var objPrevLink = document.createElement("a"); 311 objPrevLink.setAttribute('id', 'prevLink'); 312 objPrevLink.setAttribute('href', '#'); 313 objHoverNav.appendChild(objPrevLink); 314 315 var objNextLink = document.createElement("a"); 316 objNextLink.setAttribute('id', 'nextLink'); 317 objNextLink.setAttribute('href', '#'); 318 objHoverNav.appendChild(objNextLink); 319 320 var objLoading = document.createElement("div"); 321 objLoading.setAttribute('id', 'loading'); 322 objImageContainer.appendChild(objLoading); 323 324 var objLoadingLink = document.createElement("a"); 325 objLoadingLink.setAttribute('id', 'loadingLink'); 326 objLoadingLink.setAttribute('href', '#'); 327 objLoadingLink.onclick = function() { myLightbox.end(); return false; } 328 objLoading.appendChild(objLoadingLink); 329 330 var objLoadingImage = document.createElement("img"); 331 objLoadingImage.setAttribute('src', fileLoadingImage); 332 objLoadingLink.appendChild(objLoadingImage); 333 334 var objImageDataContainer = document.createElement("div"); 335 objImageDataContainer.setAttribute('id', 'imageDataContainer'); 336 objImageDataContainer.className = 'clearfix'; 337 objLightbox.appendChild(objImageDataContainer); 338 339 var objImageData = document.createElement("div"); 340 objImageData.setAttribute('id', 'imageData'); 341 objImageDataContainer.appendChild(objImageData); 342 343 var objImageDetails = document.createElement("div"); 344 objImageDetails.setAttribute('id', 'imageDetails'); 345 objImageData.appendChild(objImageDetails); 346 347 var objCaption = document.createElement("span"); 348 objCaption.setAttribute('id', 'caption'); 349 objImageDetails.appendChild(objCaption); 350
351 var objNumberDisplay = document.createElement("span"); 352 objNumberDisplay.setAttribute('id', 'numberDisplay'); 353 objImageDetails.appendChild(objNumberDisplay); 354 355 var objBottomNav = document.createElement("div"); 356 objBottomNav.setAttribute('id', 'bottomNav'); 357 objImageData.appendChild(objBottomNav); 358 359 var objBottomNavCloseLink = document.createElement("a"); 360 objBottomNavCloseLink.setAttribute('id', 'bottomNavClose'); 361 objBottomNavCloseLink.setAttribute('href', '#'); 362 objBottomNavCloseLink.onclick = function() { myLightbox.end(); return false; } 363 objBottomNav.appendChild(objBottomNavCloseLink); 364 365 var objBottomNavCloseImage = document.createElement("img"); 366 objBottomNavCloseImage.setAttribute('src', fileBottomNavCloseImage); 367 objBottomNavCloseLink.appendChild(objBottomNavCloseImage); 368 }, 369 370 // 371 // start() 372 // Display overlay and lightbox. If image is part of a set, add siblings to imageArray. 373 // 374 start: function(imageLink) { 375 376 function getImageTitle(anchor) { //DynamicDrive.com added function that allows the caption("title") to be linked ("rev"). 377 var ddimageTitle = anchor.getAttribute('title') 378 var ddimageTitleURL = (ddimageTitle != null && ddimageTitle != "") ? anchor.getAttribute('rev') : null 379 return ddimageTitleFinal = (ddimageTitleURL != null && ddimageTitleURL != "") ? '<a href="' + ddimageTitleURL + '" class="ddcaptionurl">' + ddimageTitle + '</a>' : ddimageTitle 380 }; 381 382 hideSelectBoxes(); 383 hideFlash(); 384 385 // stretch overlay to fill page and fade in 386 var arrayPageSize = getPageSize(); 387 Element.setHeight('overlay', arrayPageSize[1]); 388 389 new Effect.Appear('overlay', { duration: overlayDuration, from: 0.0, to: 0.8 }); 390 391 imageArray = []; 392 imageNum = 0; 393 394 if (!document.getElementsByTagName) { return; } 395 var anchors = document.getElementsByTagName('a'); 396 397 // if image is NOT part of a set.. 398 if ((imageLink.getAttribute('rel') == 'lightbox')) { 399 // add single image to imageArray 400 imageArray.push(new Array(imageLink.getAttribute('imgid'), getImageTitle(imageLink))); 401 } else { 402 // if image is part of a set.. 403 404 // loop through anchors, find other images in set, and add them to imageArray 405 for (var i = 0; i < anchors.length; i++) { 406 var anchor = anchors[i]; 407 if (anchor.getAttribute('href') && (anchor.getAttribute('rel') == imageLink.getAttribute('rel'))) { 408 imageArray.push(new Array(anchor.getAttribute('imgid'), getImageTitle(anchor))); 409 } 410 } 411 imageArray.removeDuplicates(); 412 while (imageArray[imageNum][0] != imageLink.getAttribute('imgid')) { imageNum++; } 413 } 414 415 // calculate top offset for the lightbox and display 416 var arrayPageScroll = getPageScroll(); 417 var lightboxTop = arrayPageScroll[1] + (arrayPageSize[3] / 10); 418 419 Element.setTop('lightbox', lightboxTop); 420 Element.show('lightbox'); 421 422 this.changeImage(imageNum); 423 }, 424 425 // 426 // changeImage() 427 // Hide most elements and preload image in preparation for resizing image container. 428 // 429 changeImage: function(imageNum) { 430 431 activeImage = imageNum; // update global var 432 433 // hide elements during transition 434 if (animate) { Element.show('loading'); } 435 Element.hide('lightboxImage');
436 Element.hide('hoverNav'); 437 Element.hide('prevLink'); 438 Element.hide('nextLink'); 439 Element.hide('imageDataContainer'); 440 Element.hide('numberDisplay'); 441 442 imgPreloader = new Image(); 443 444 // once image is preloaded, resize image container 445 imgPreloader.onload = function() { 446 447 var heightNewNew = imgPreloader.height; 448 var widthNewNew = imgPreloader.width; 449 450 if (imgPreloader.height > 550) heightNewNew = 550; 451 452 var ScaleFactorHeight = imgPreloader.height / heightNewNew; 453 454 imgPreloader.height = heightNewNew; 455 456 457 if (ScaleFactorHeight != 1.0) 458 imgPreloader.width = imgPreloader.width / ScaleFactorHeight; 459 460 461 /*if (imgPreloader.width > 600) 462 widthNewNew = 600; 463 464 var ScaleFactorWidth = imgPreloader.width / widthNewNew; 465 466 imgPreloader.width = widthNewNew;*/ 467 468 469 /*if (ScaleFactorWidth != 1.0) 470 imgPreloader.height = imgPreloader.height / ScaleFactorWidth;*/ 471 472 473 474 475 Element.setWidth('lightboxImage', imgPreloader.width); 476 Url = 'PhotoHandler.ashx?i=' + imageArray[activeImage][0] + '&h=' + imgPreloader.height; 477 Element.setSrc('lightboxImage', Url); 478 479 myLightbox.resizeImageContainer(imgPreloader.width, imgPreloader.height); 480 481 } 482 483 imgPreloader.src = 'PhotoHandler.ashx?i=' + imageArray[activeImage][0]; 484 }, 485 486 // 487 // resizeImageContainer() 488 // 489 resizeImageContainer: function(imgWidth, imgHeight) { 490 491 // get curren width and height 492 this.widthCurrent = Element.getWidth('outerImageContainer'); 493 this.heightCurrent = Element.getHeight('outerImageContainer'); 494 495 // get new width and height 496 var widthNew = (imgWidth + (borderSize * 2)); 497 var heightNew = (imgHeight + (borderSize * 2)); 498 499 if (heightNew < 60) heightNew = 60; 500 if (widthNew < 300) widthNew = 300; 501 502 // scalars based on change from old to new 503 this.xScale = (widthNew / this.widthCurrent) * 100; 504 this.yScale = (heightNew / this.heightCurrent) * 100; 505 506 // calculate size difference between new and old image, and resize if necessary 507 wDiff = this.widthCurrent - widthNew; 508 hDiff = this.heightCurrent - heightNew; 509 510 if (!(hDiff == 0)) { new Effect.Scale('outerImageContainer', this.yScale, { scaleX: false, duration: resizeDuration, queue: 'front' }); } 511 if (!(wDiff == 0)) { new Effect.Scale('outerImageContainer', this.xScale, { scaleY: false, delay: resizeDuration, duration: resizeDuration }); } 512 513 // if new and old image are same size and no scaling transition is necessary, 514 // do a quick pause to prevent image flicker. 515 if ((hDiff == 0) && (wDiff == 0)) { 516 if (navigator.appVersion.indexOf("MSIE") != -1) { pause(250); } else { pause(100); } 517 } 518 ; 519 Element.setHeight('prevLink', imgHeight); 520 Element.setHeight('nextLink', imgHeight); 521 522 Element.setWidth('imageDataContainer', widthNew); 523 524 this.widthCurrent = 10; 525 526 527 this.showImage(); 528 }, 529 530 // 531 // showImage() 532 // Display image and begin preloading neighbors. 533 // 534 showImage: function() { 535 Element.hide('loading'); 536 537 new Effect.Appear('lightboxImage', 538 { 539 duration: resizeDuration, queue: 'end', afterFinish: function() { myLightbox.updateDetails(); } 540 }); 541 this.preloadNeighborImages(); 542 }, 543 544 // 545 // updateDetails() 546 // Display caption, image number, and bottom nav. 547 // 548 updateDetails: function() { 549 Element.show('caption'); 550 var captiontxt = imageArray[activeImage][1]; 551 if (captiontxt == null || captiontxt == 'null' || captiontxt == 'null') 552 captiontxt = ''; 553 554 Element.setInnerHTML('caption', captiontxt); 555 556 // if image is part of set display 'Image x of x' 557 if (imageArray.length > 1) {
558 Element.show('numberDisplay'); 559 Element.setInnerHTML('numberDisplay', "Image " + eval(activeImage + 1) + " of " + imageArray.length); 560 } 561 562 new Effect.Parallel( 563 [new Effect.SlideDown('imageDataContainer', { sync: true, duration: resizeDuration, from: 0.0, to: 1.0 }), 564 new Effect.Appear('imageDataContainer', { sync: true, duration: resizeDuration })], 565 { duration: resizeDuration, afterFinish: function() { 566 // update overlay size and update nav 567 var arrayPageSize = getPageSize(); 568 Element.setHeight('overlay', arrayPageSize[1]); 569 myLightbox.updateNav(); 570 } 571 } 572 ); 573 }, 574 575 // 576 // updateNav() 577 // Display appropriate previous and next hover navigation. 578 // 579 updateNav: function() { 580 581 Element.show('hoverNav'); 582 583 // if not first image in set, display prev image button 584 if (activeImage != 0) { 585 Element.show('prevLink'); 586 document.getElementById('prevLink').onclick = function() { 587 myLightbox.changeImage(activeImage - 1); return false; 588 } 589 } 590 591 // if not last image in set, display next image button 592 if (activeImage != (imageArray.length - 1)) { 593 Element.show('nextLink'); 594 document.getElementById('nextLink').onclick = function() { 595 myLightbox.changeImage(activeImage + 1); return false; 596 } 597 } 598 599 this.enableKeyboardNav(); 600 }, 601 602 // 603 // enableKeyboardNav() 604 // 605 enableKeyboardNav: function() { 606 document.onkeydown = this.keyboardAction; 607 }, 608 609 // 610 // disableKeyboardNav() 611 // 612 disableKeyboardNav: function() { 613 document.onkeydown = ''; 614 }, 615 616 // 617 // keyboardAction() 618 // 619 keyboardAction: function(e) { 620 if (e == null) { // ie 621 keycode = event.keyCode; 622 escapeKey = 27; 623 } else { // mozilla 624 keycode = e.keyCode; 625 escapeKey = e.DOM_VK_ESCAPE; 626 } 627 628 key = String.fromCharCode(keycode).toLowerCase(); 629 630 if ((key == 'x') || (key == 'o') || (key == 'c') || (keycode == escapeKey)) { // close lightbox 631 myLightbox.end(); 632 } else if ((key == 'p') || (keycode == 37)) { // display previous image 633 if (activeImage != 0) { 634 myLightbox.disableKeyboardNav(); 635 myLightbox.changeImage(activeImage - 1); 636 } 637 } else if ((key == 'n') || (keycode == 39)) { // display next image 638 if (activeImage != (imageArray.length - 1)) { 639 myLightbox.disableKeyboardNav(); 640 myLightbox.changeImage(activeImage + 1); 641 } 642 } 643 644 }, 645 646 // 647 // preloadNeighborImages() 648 // Preload previous and next images. 649 // 650 preloadNeighborImages: function() { 651 652 if ((imageArray.length - 1) > activeImage) { 653 preloadNextImage = new Image(); 654 preloadNextImage.src = imageArray[activeImage + 1][0]; 655 } 656 if (activeImage > 0) { 657 preloadPrevImage = new Image(); 658 preloadPrevImage.src = imageArray[activeImage - 1][0]; 659 } 660 661 }, 662 663 // 664 // end() 665 // 666 end: function() { 667 this.disableKeyboardNav(); 668 Element.hide('lightbox'); 669 new Effect.Fade('overlay', { duration: overlayDuration }); 670 showSelectBoxes(); 671 showFlash(); 672 } 673} 674 675// ----------------------------------------------------------------------------------- 676 677// 678// getPageScroll() 679// Returns array with x,y page scroll values. 680// Core code from - quirksmode.org 681// 682function getPageScroll(){ 683 684 var yScroll; 685 686 if (self.pageYOffset) { 687 yScroll = self.pageYOffset; 688 } else if (document.documentElement && document.documentElement.scrollTop){ // Explorer 6 Strict 689 yScroll = document.documentElement.scrollTop; 690 } else if (document.body) {// all other Explorers 691 yScroll = document.body.scrollTop; 692 } 693 694 arrayPageScroll = new Array('',yScroll) 695 return arrayPageScroll; 696} 697 698// ----------------------------------------------------------------------------------- 699 700// 701// getPageSize() 702// Returns array with page width, height and window width, height 703// Core code from - quirksmode.org 704// Edit for Firefox by pHaez 705// 706function getPageSize(){ 707 708 var xScroll, yScroll; 709 710 if (window.innerHeight && window.scrollMaxY) { 711 xScroll = document.body.scrollWidth; 712 yScroll = window.innerHeight + window.scrollMaxY; 713 } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac 714 xScroll = document.body.scrollWidth; 715 yScroll = document.body.scrollHeight; 716 } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari 717 xScroll = document.body.offsetWidth; 718 yScroll = document.body.offsetHeight; 719 } 720 721 var windowWidth, windowHeight;
722 if (self.innerHeight) { // all except Explorer 723 windowWidth = self.innerWidth; 724 windowHeight = self.innerHeight; 725 } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode 726 windowWidth = document.documentElement.clientWidth; 727 windowHeight = document.documentElement.clientHeight; 728 } else if (document.body) { // other Explorers 729 windowWidth = document.body.clientWidth; 730 windowHeight = document.body.clientHeight; 731 } 732 733 // for small pages with total height less then height of the viewport 734 if(yScroll < windowHeight){ 735 pageHeight = windowHeight; 736 } else { 737 pageHeight = yScroll; 738 } 739 740 // for small pages with total width less then width of the viewport 741 if(xScroll < windowWidth){ 742 pageWidth = windowWidth; 743 } else { 744 pageWidth = xScroll; 745 } 746 747 arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 748 return arrayPageSize; 749} 750 751// ----------------------------------------------------------------------------------- 752 753// 754// getKey(key) 755// Gets keycode. If 'x' is pressed then it hides the lightbox. 756// 757function getKey(e){ 758 if (e == null) { // ie 759 keycode = event.keyCode; 760 } else { // mozilla 761 keycode = e.which; 762 } 763 key = String.fromCharCode(keycode).toLowerCase(); 764 765 if(key == 'x'){ 766 } 767} 768 769// ----------------------------------------------------------------------------------- 770 771// 772// listenKey() 773// 774function listenKey () { document.onkeypress = getKey; } 775 776// --------------------------------------------------- 777 778function showSelectBoxes(){ 779 var selects = document.getElementsByTagName("select"); 780 for (i = 0; i != selects.length; i++) { 781 selects[i].style.visibility = "visible"; 782 } 783} 784 785// --------------------------------------------------- 786 787function hideSelectBoxes(){ 788 var selects = document.getElementsByTagName("select"); 789 for (i = 0; i != selects.length; i++) { 790 selects[i].style.visibility = "hidden"; 791 } 792} 793 794// --------------------------------------------------- 795 796function showFlash(){ 797 var flashObjects = document.getElementsByTagName("object"); 798 for (i = 0; i != flashObjects.length; i++) { 799 flashObjects[i].style.visibility = "visible"; 800 } 801 802 var flashEmbeds = document.getElementsByTagName("embeds"); 803 for (i = 0; i != flashEmbeds.length; i++) { 804 flashEmbeds[i].style.visibility = "visible"; 805 } 806} 807 808// --------------------------------------------------- 809 810function hideFlash(){ 811 var flashObjects = document.getElementsByTagName("object"); 812 for (i = 0; i != flashObjects.length; i++) { 813 flashObjects[i].style.visibility = "hidden"; 814 } 815 816 var flashEmbeds = document.getElementsByTagName("embeds"); 817 for (i = 0; i != flashEmbeds.length; i++) { 818 flashEmbeds[i].style.visibility = "hidden"; 819 } 820 821} 822 823 824// --------------------------------------------------- 825 826// 827// pause(numberMillis) 828// Pauses code execution for specified time. Uses busy code, not good. 829// Help from Ran Bar-On [[email protected]] 830// 831 832function pause(ms){ 833 var date = new Date(); 834 curDate = null; 835 do{var curDate = new Date();} 836 while( curDate - date < ms); 837} 838/* 839function pause(numberMillis) { 840 var curently = new Date().getTime() + sender; 841 while (new Date().getTime(); 842} 843*/ 844// --------------------------------------------------- 845 846 847 848function initLightbox() { myLightbox = new Lightbox(); } 849Event.observe(window, 'load', initLightbox, false);
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.