//***********************************************************************************************************************************/ // lytebox v3.22 // // author: markus f. hay // website: http://www.dolem.com/lytebox // date: october 2, 2007 // license: creative commons attribution 3.0 license (http://creativecommons.org/licenses/by/3.0/) // browsers: tested successfully on winxp with the following browsers (using no doctype and strict/transitional/loose doctypes): // * firefox: 2.0.0.7, 1.5.0.12 // * internet explorer: 7.0, 6.0 sp2, 5.5 sp2 // * opera: 9.23 // // releases: for up-to-date and complete release information, visit http://www.dolem.com/forum/showthread.php?tid=62 // * v3.22 (10/02/07) // * v3.21 (09/30/07) // * v3.20 (07/12/07) // * v3.10 (05/28/07) // * v3.00 (05/15/07) // * v2.02 (11/13/06) // // credit: lytebox was originally derived from the lightbox class (v2.02) that was written by lokesh dhakar. for more // information please visit http://huddletogether.com/projects/lightbox2/ //***********************************************************************************************************************************/ array.prototype.removeduplicates = function () { for (var i = 1; i < this.length; i++) { if (this[i][0] == this[i-1][0]) { this.splice(i,1); } } } array.prototype.empty = function () { for (var i = 0; i <= this.length; i++) { this.shift(); } } string.prototype.trim = function () { return this.replace(/^\s+|\s+$/g, ''); } function lytebox() { /*** start global configuration ***/ this.theme = 'grey'; // themes: grey (default), red, green, blue, gold this.hideflash = true; // controls whether or not flash objects should be hidden this.outerborder = true; // controls whether to show the outer grey (or theme) border this.resizespeed = 8; // controls the speed of the image resizing (1=slowest and 10=fastest) this.maxopacity = 60; // higher opacity = darker overlay, lower opacity = lighter overlay this.navtype = 1; // 1 = "prev/next" buttons on top left and left (default), 2 = "<< prev | next >>" links next to image number this.autoresize = true; // controls whether or not images should be resized if larger than the browser window dimensions this.doanimations = true; // controls whether or not "animate" lytebox, i.e. resize transition between images, fade in/out effects, etc. this.bordersize = 12; // if you adjust the padding in the css, you will need to update this variable -- otherwise, leave this alone... /*** end global configuration ***/ /*** configure slideshow options ***/ this.slideinterval = 4000; // change value (milliseconds) to increase/decrease the time between "slides" (10000 = 10 seconds) this.shownavigation = true; // true to display next/prev buttons/text during slideshow, false to hide this.showclose = true; // true to display the close button, false to hide this.showdetails = true; // true to display image details (caption, count), false to hide this.showplaypause = true; // true to display pause/play buttons next to close button, false to hide this.autoend = true; // true to automatically close lytebox after the last image is reached, false to keep open this.pauseonnextclick = false; // true to pause the slideshow when the "next" button is clicked this.pauseonprevclick = true; // true to pause the slideshow when the "prev" button is clicked /*** end slideshow configuration ***/ if(this.resizespeed > 10) { this.resizespeed = 10; } if(this.resizespeed < 1) { resizespeed = 1; } this.resizeduration = (11 - this.resizespeed) * 0.15; this.resizewtimerarray = new array(); this.resizewtimercount = 0; this.resizehtimerarray = new array(); this.resizehtimercount = 0; this.showcontenttimerarray = new array(); this.showcontenttimercount = 0; this.overlaytimerarray = new array(); this.overlaytimercount = 0; this.imagetimerarray = new array(); this.imagetimercount = 0; this.timeridarray = new array(); this.timeridcount = 0; this.slideshowidarray = new array(); this.slideshowidcount = 0; this.imagearray = new array(); this.activeimage = null; this.slidearray = new array(); this.activeslide = null; this.framearray = new array(); this.activeframe = null; this.checkframe(); this.isslideshow = false; this.islyteframe = false; /*@cc_on /*@if (@_jscript) this.ie = (document.all && !window.opera) ? true : false; /*@else @*/ this.ie = false; /*@end @*/ this.ie7 = (this.ie && window.xmlhttprequest); this.initialize(); } lytebox.prototype.initialize = function() { this.updatelyteboxitems(); var objbody = this.doc.getelementsbytagname("body").item(0); if (this.doc.getelementbyid('lboverlay')) { objbody.removechild(this.doc.getelementbyid("lboverlay")); objbody.removechild(this.doc.getelementbyid("lbmain")); } var objoverlay = this.doc.createelement("div"); objoverlay.setattribute('id','lboverlay'); objoverlay.setattribute((this.ie ? 'classname' : 'class'), this.theme); if ((this.ie && !this.ie7) || (this.ie7 && this.doc.compatmode == 'backcompat')) { objoverlay.style.position = 'absolute'; } objoverlay.style.display = 'none'; objbody.appendchild(objoverlay); var objlytebox = this.doc.createelement("div"); objlytebox.setattribute('id','lbmain'); objlytebox.style.display = 'none'; objbody.appendchild(objlytebox); var objoutercontainer = this.doc.createelement("div"); objoutercontainer.setattribute('id','lboutercontainer'); objoutercontainer.setattribute((this.ie ? 'classname' : 'class'), this.theme); objlytebox.appendchild(objoutercontainer); var objiframecontainer = this.doc.createelement("div"); objiframecontainer.setattribute('id','lbiframecontainer'); objiframecontainer.style.display = 'none'; objoutercontainer.appendchild(objiframecontainer); var objiframe = this.doc.createelement("iframe"); objiframe.setattribute('id','lbiframe'); objiframe.setattribute('name','lbiframe'); objiframe.style.display = 'none'; objiframecontainer.appendchild(objiframe); var objimagecontainer = this.doc.createelement("div"); objimagecontainer.setattribute('id','lbimagecontainer'); objoutercontainer.appendchild(objimagecontainer); var objlyteboximage = this.doc.createelement("img"); objlyteboximage.setattribute('id','lbimage'); objimagecontainer.appendchild(objlyteboximage); var objloading = this.doc.createelement("div"); objloading.setattribute('id','lbloading'); objoutercontainer.appendchild(objloading); var objdetailscontainer = this.doc.createelement("div"); objdetailscontainer.setattribute('id','lbdetailscontainer'); objdetailscontainer.setattribute((this.ie ? 'classname' : 'class'), this.theme); objlytebox.appendchild(objdetailscontainer); var objdetailsdata =this.doc.createelement("div"); objdetailsdata.setattribute('id','lbdetailsdata'); objdetailsdata.setattribute((this.ie ? 'classname' : 'class'), this.theme); objdetailscontainer.appendchild(objdetailsdata); var objdetails = this.doc.createelement("div"); objdetails.setattribute('id','lbdetails'); objdetailsdata.appendchild(objdetails); var objcaption = this.doc.createelement("span"); objcaption.setattribute('id','lbcaption'); objdetails.appendchild(objcaption); var objhovernav = this.doc.createelement("div"); objhovernav.setattribute('id','lbhovernav'); objimagecontainer.appendchild(objhovernav); var objbottomnav = this.doc.createelement("div"); objbottomnav.setattribute('id','lbbottomnav'); objdetailsdata.appendchild(objbottomnav); var objprev = this.doc.createelement("a"); objprev.setattribute('id','lbprev'); objprev.setattribute((this.ie ? 'classname' : 'class'), this.theme); objprev.setattribute('href','#'); objhovernav.appendchild(objprev); var objnext = this.doc.createelement("a"); objnext.setattribute('id','lbnext'); objnext.setattribute((this.ie ? 'classname' : 'class'), this.theme); objnext.setattribute('href','#'); objhovernav.appendchild(objnext); var objnumberdisplay = this.doc.createelement("span"); objnumberdisplay.setattribute('id','lbnumberdisplay'); objdetails.appendchild(objnumberdisplay); var objnavdisplay = this.doc.createelement("span"); objnavdisplay.setattribute('id','lbnavdisplay'); objnavdisplay.style.display = 'none'; objdetails.appendchild(objnavdisplay); var objclose = this.doc.createelement("a"); objclose.setattribute('id','lbclose'); objclose.setattribute((this.ie ? 'classname' : 'class'), this.theme); objclose.setattribute('href','#'); objbottomnav.appendchild(objclose); var objpause = this.doc.createelement("a"); objpause.setattribute('id','lbpause'); objpause.setattribute((this.ie ? 'classname' : 'class'), this.theme); objpause.setattribute('href','#'); objpause.style.display = 'none'; objbottomnav.appendchild(objpause); var objplay = this.doc.createelement("a"); objplay.setattribute('id','lbplay'); objplay.setattribute((this.ie ? 'classname' : 'class'), this.theme); objplay.setattribute('href','#'); objplay.style.display = 'none'; objbottomnav.appendchild(objplay); }; lytebox.prototype.updatelyteboxitems = function() { var anchors = (this.isframe) ? window.parent.frames[window.name].document.getelementsbytagname('a') : document.getelementsbytagname('a'); for (var i = 0; i < anchors.length; i++) { var anchor = anchors[i]; var relattribute = string(anchor.getattribute('rel')); if (anchor.getattribute('href')) { if (relattribute.tolowercase().match('lytebox')) { anchor.onclick = function () { mylytebox.start(this, false, false); return false; } } else if (relattribute.tolowercase().match('lyteshow')) { anchor.onclick = function () { mylytebox.start(this, true, false); return false; } } else if (relattribute.tolowercase().match('lyteframe')) { anchor.onclick = function () { mylytebox.start(this, false, true); return false; } } } } }; lytebox.prototype.start = function(imagelink, doslide, doframe) { if (this.ie && !this.ie7) { this.toggleselects('hide'); } if (this.hideflash) { this.toggleflash('hide'); } this.islyteframe = (doframe ? true : false); var pagesize = this.getpagesize(); var objoverlay = this.doc.getelementbyid('lboverlay'); var objbody = this.doc.getelementsbytagname("body").item(0); objoverlay.style.height = pagesize[1] + "px"; objoverlay.style.display = ''; this.appear('lboverlay', (this.doanimations ? 0 : this.maxopacity)); var anchors = (this.isframe) ? window.parent.frames[window.name].document.getelementsbytagname('a') : document.getelementsbytagname('a'); if (this.islyteframe) { this.framearray = []; this.framenum = 0; if ((imagelink.getattribute('rel') == 'lyteframe')) { var rev = imagelink.getattribute('rev'); this.framearray.push(new array(imagelink.getattribute('href'), imagelink.getattribute('title'), (rev == null || rev == '' ? 'width: 400px; height: 400px; scrolling: auto;' : rev))); } else { if (imagelink.getattribute('rel').indexof('lyteframe') != -1) { for (var i = 0; i < anchors.length; i++) { var anchor = anchors[i]; if (anchor.getattribute('href') && (anchor.getattribute('rel') == imagelink.getattribute('rel'))) { var rev = anchor.getattribute('rev'); this.framearray.push(new array(anchor.getattribute('href'), anchor.getattribute('title'), (rev == null || rev == '' ? 'width: 400px; height: 400px; scrolling: auto;' : rev))); } } this.framearray.removeduplicates(); while(this.framearray[this.framenum][0] != imagelink.getattribute('href')) { this.framenum++; } } } } else { this.imagearray = []; this.imagenum = 0; this.slidearray = []; this.slidenum = 0; if ((imagelink.getattribute('rel') == 'lytebox')) { this.imagearray.push(new array(imagelink.getattribute('href'), imagelink.getattribute('title'))); } else { if (imagelink.getattribute('rel').indexof('lytebox') != -1) { for (var i = 0; i < anchors.length; i++) { var anchor = anchors[i]; if (anchor.getattribute('href') && (anchor.getattribute('rel') == imagelink.getattribute('rel'))) { this.imagearray.push(new array(anchor.getattribute('href'), anchor.getattribute('title'))); } } this.imagearray.removeduplicates(); while(this.imagearray[this.imagenum][0] != imagelink.getattribute('href')) { this.imagenum++; } } if (imagelink.getattribute('rel').indexof('lyteshow') != -1) { for (var i = 0; i < anchors.length; i++) { var anchor = anchors[i]; if (anchor.getattribute('href') && (anchor.getattribute('rel') == imagelink.getattribute('rel'))) { this.slidearray.push(new array(anchor.getattribute('href'), anchor.getattribute('title'))); } } this.slidearray.removeduplicates(); while(this.slidearray[this.slidenum][0] != imagelink.getattribute('href')) { this.slidenum++; } } } } var object = this.doc.getelementbyid('lbmain'); object.style.top = (this.getpagescroll() + (pagesize[3] / 15)) + "px"; object.style.display = ''; if (!this.outerborder) { this.doc.getelementbyid('lboutercontainer').style.border = 'none'; this.doc.getelementbyid('lbdetailscontainer').style.border = 'none'; } else { this.doc.getelementbyid('lboutercontainer').style.borderbottom = ''; this.doc.getelementbyid('lboutercontainer').setattribute((this.ie ? 'classname' : 'class'), this.theme); } this.doc.getelementbyid('lboverlay').onclick = function() { mylytebox.end(); return false; } this.doc.getelementbyid('lbmain').onclick = function(e) { var e = e; if (!e) { if (window.parent.frames[window.name] && (parent.document.getelementsbytagname('frameset').length <= 0)) { e = window.parent.window.event; } else { e = window.event; } } var id = (e.target ? e.target.id : e.srcelement.id); if (id == 'lbmain') { mylytebox.end(); return false; } } this.doc.getelementbyid('lbclose').onclick = function() { mylytebox.end(); return false; } this.doc.getelementbyid('lbpause').onclick = function() { mylytebox.toggleplaypause("lbpause", "lbplay"); return false; } this.doc.getelementbyid('lbplay').onclick = function() { mylytebox.toggleplaypause("lbplay", "lbpause"); return false; } this.isslideshow = doslide; this.ispaused = (this.slidenum != 0 ? true : false); if (this.isslideshow && this.showplaypause && this.ispaused) { this.doc.getelementbyid('lbplay').style.display = ''; this.doc.getelementbyid('lbpause').style.display = 'none'; } if (this.islyteframe) { this.changecontent(this.framenum); } else { if (this.isslideshow) { this.changecontent(this.slidenum); } else { this.changecontent(this.imagenum); } } }; lytebox.prototype.changecontent = function(imagenum) { if (this.isslideshow) { for (var i = 0; i < this.slideshowidcount; i++) { window.cleartimeout(this.slideshowidarray[i]); } } this.activeimage = this.activeslide = this.activeframe = imagenum; if (!this.outerborder) { this.doc.getelementbyid('lboutercontainer').style.border = 'none'; this.doc.getelementbyid('lbdetailscontainer').style.border = 'none'; } else { this.doc.getelementbyid('lboutercontainer').style.borderbottom = ''; this.doc.getelementbyid('lboutercontainer').setattribute((this.ie ? 'classname' : 'class'), this.theme); } this.doc.getelementbyid('lbloading').style.display = ''; this.doc.getelementbyid('lbimage').style.display = 'none'; this.doc.getelementbyid('lbiframe').style.display = 'none'; this.doc.getelementbyid('lbprev').style.display = 'none'; this.doc.getelementbyid('lbnext').style.display = 'none'; this.doc.getelementbyid('lbiframecontainer').style.display = 'none'; this.doc.getelementbyid('lbdetailscontainer').style.display = 'none'; this.doc.getelementbyid('lbnumberdisplay').style.display = 'none'; if (this.navtype == 2 || this.islyteframe) { object = this.doc.getelementbyid('lbnavdisplay'); object.innerhtml = '    || '; object.style.display = 'none'; } if (this.islyteframe) { var iframe = mylytebox.doc.getelementbyid('lbiframe'); var styles = this.framearray[this.activeframe][2]; var astyles = styles.split(';'); for (var i = 0; i < astyles.length; i++) { if (astyles[i].indexof('width:') >= 0) { var w = astyles[i].replace('width:', ''); iframe.width = w.trim(); } else if (astyles[i].indexof('height:') >= 0) { var h = astyles[i].replace('height:', ''); iframe.height = h.trim(); } else if (astyles[i].indexof('scrolling:') >= 0) { var s = astyles[i].replace('scrolling:', ''); iframe.scrolling = s.trim(); } else if (astyles[i].indexof('border:') >= 0) { // not implemented yet, as there are cross-platform issues with setting the border (from a gui standpoint) //var b = astyles[i].replace('border:', ''); //iframe.style.border = b.trim(); } } this.resizecontainer(parseint(iframe.width), parseint(iframe.height)); } else { imgpreloader = new image(); imgpreloader.onload = function() { var imagewidth = imgpreloader.width; var imageheight = imgpreloader.height; if (mylytebox.autoresize) { var pagesize = mylytebox.getpagesize(); var x = pagesize[2] - 150; var y = pagesize[3] - 150; if (imagewidth > x) { imageheight = math.round(imageheight * (x / imagewidth)); imagewidth = x; if (imageheight > y) { imagewidth = math.round(imagewidth * (y / imageheight)); imageheight = y; } } else if (imageheight > y) { imagewidth = math.round(imagewidth * (y / imageheight)); imageheight = y; if (imagewidth > x) { imageheight = math.round(imageheight * (x / imagewidth)); imagewidth = x; } } } var lbimage = mylytebox.doc.getelementbyid('lbimage') lbimage.src = (mylytebox.isslideshow ? mylytebox.slidearray[mylytebox.activeslide][0] : mylytebox.imagearray[mylytebox.activeimage][0]); lbimage.width = imagewidth; lbimage.height = imageheight; mylytebox.resizecontainer(imagewidth, imageheight); imgpreloader.onload = function() {}; } imgpreloader.src = (this.isslideshow ? this.slidearray[this.activeslide][0] : this.imagearray[this.activeimage][0]); } }; lytebox.prototype.resizecontainer = function(imgwidth, imgheight) { this.wcur = this.doc.getelementbyid('lboutercontainer').offsetwidth; this.hcur = this.doc.getelementbyid('lboutercontainer').offsetheight; this.xscale = ((imgwidth + (this.bordersize * 2)) / this.wcur) * 100; this.yscale = ((imgheight + (this.bordersize * 2)) / this.hcur) * 100; var wdiff = (this.wcur - this.bordersize * 2) - imgwidth; var hdiff = (this.hcur - this.bordersize * 2) - imgheight; if (!(hdiff == 0)) { this.hdone = false; this.resizeh('lboutercontainer', this.hcur, imgheight + this.bordersize*2, this.getpixelrate(this.hcur, imgheight)); } else { this.hdone = true; } if (!(wdiff == 0)) { this.wdone = false; this.resizew('lboutercontainer', this.wcur, imgwidth + this.bordersize*2, this.getpixelrate(this.wcur, imgwidth)); } else { this.wdone = true; } if ((hdiff == 0) && (wdiff == 0)) { if (this.ie){ this.pause(250); } else { this.pause(100); } } this.doc.getelementbyid('lbprev').style.height = imgheight + "px"; this.doc.getelementbyid('lbnext').style.height = imgheight + "px"; this.doc.getelementbyid('lbdetailscontainer').style.width = (imgwidth + (this.bordersize * 2) + (this.ie && this.doc.compatmode == "backcompat" && this.outerborder ? 2 : 0)) + "px"; this.showcontent(); }; lytebox.prototype.showcontent = function() { if (this.wdone && this.hdone) { for (var i = 0; i < this.showcontenttimercount; i++) { window.cleartimeout(this.showcontenttimerarray[i]); } if (this.outerborder) { this.doc.getelementbyid('lboutercontainer').style.borderbottom = 'none'; } this.doc.getelementbyid('lbloading').style.display = 'none'; if (this.islyteframe) { this.doc.getelementbyid('lbiframe').style.display = ''; this.appear('lbiframe', (this.doanimations ? 0 : 100)); } else { this.doc.getelementbyid('lbimage').style.display = ''; this.appear('lbimage', (this.doanimations ? 0 : 100)); this.preloadneighborimages(); } if (this.isslideshow) { if(this.activeslide == (this.slidearray.length - 1)) { if (this.autoend) { this.slideshowidarray[this.slideshowidcount++] = settimeout("mylytebox.end('slideshow')", this.slideinterval); } } else { if (!this.ispaused) { this.slideshowidarray[this.slideshowidcount++] = settimeout("mylytebox.changecontent("+(this.activeslide+1)+")", this.slideinterval); } } this.doc.getelementbyid('lbhovernav').style.display = (this.shownavigation && this.navtype == 1 ? '' : 'none'); this.doc.getelementbyid('lbclose').style.display = (this.showclose ? '' : 'none'); this.doc.getelementbyid('lbdetails').style.display = (this.showdetails ? '' : 'none'); this.doc.getelementbyid('lbpause').style.display = (this.showplaypause && !this.ispaused ? '' : 'none'); this.doc.getelementbyid('lbplay').style.display = (this.showplaypause && !this.ispaused ? 'none' : ''); this.doc.getelementbyid('lbnavdisplay').style.display = (this.shownavigation && this.navtype == 2 ? '' : 'none'); } else { this.doc.getelementbyid('lbhovernav').style.display = (this.navtype == 1 && !this.islyteframe ? '' : 'none'); if ((this.navtype == 2 && !this.islyteframe && this.imagearray.length > 1) || (this.framearray.length > 1 && this.islyteframe)) { this.doc.getelementbyid('lbnavdisplay').style.display = ''; } else { this.doc.getelementbyid('lbnavdisplay').style.display = 'none'; } this.doc.getelementbyid('lbclose').style.display = ''; this.doc.getelementbyid('lbdetails').style.display = ''; this.doc.getelementbyid('lbpause').style.display = 'none'; this.doc.getelementbyid('lbplay').style.display = 'none'; } this.doc.getelementbyid('lbimagecontainer').style.display = (this.islyteframe ? 'none' : ''); this.doc.getelementbyid('lbiframecontainer').style.display = (this.islyteframe ? '' : 'none'); try { this.doc.getelementbyid('lbiframe').src = this.framearray[this.activeframe][0]; } catch(e) { } } else { this.showcontenttimerarray[this.showcontenttimercount++] = settimeout("mylytebox.showcontent()", 200); } }; lytebox.prototype.updatedetails = function() { var object = this.doc.getelementbyid('lbcaption'); var stitle = (this.isslideshow ? this.slidearray[this.activeslide][1] : (this.islyteframe ? this.framearray[this.activeframe][1] : this.imagearray[this.activeimage][1])); object.style.display = ''; object.innerhtml = (stitle == null ? '' : stitle); this.updatenav(); this.doc.getelementbyid('lbdetailscontainer').style.display = ''; object = this.doc.getelementbyid('lbnumberdisplay'); if (this.isslideshow && this.slidearray.length > 1) { object.style.display = ''; /*object.innerhtml = "image " + eval(this.activeslide + 1) + " of " + this.slidearray.length;*/ this.doc.getelementbyid('lbnavdisplay').style.display = (this.navtype == 2 && this.shownavigation ? '' : 'none'); } else if (this.imagearray.length > 1 && !this.islyteframe) { object.style.display = ''; /* object.innerhtml = "image " + eval(this.activeimage + 1) + " of " + this.imagearray.length;*/ this.doc.getelementbyid('lbnavdisplay').style.display = (this.navtype == 2 ? '' : 'none'); } else if (this.framearray.length > 1 && this.islyteframe) { object.style.display = ''; object.innerhtml = "page " + eval(this.activeframe + 1) + " of " + this.framearray.length; this.doc.getelementbyid('lbnavdisplay').style.display = ''; } else { this.doc.getelementbyid('lbnavdisplay').style.display = 'none'; } this.appear('lbdetailscontainer', (this.doanimations ? 0 : 100)); }; lytebox.prototype.updatenav = function() { if (this.isslideshow) { if (this.activeslide != 0) { var object = (this.navtype == 2 ? this.doc.getelementbyid('lbprev2') : this.doc.getelementbyid('lbprev')); object.style.display = ''; object.onclick = function() { if (mylytebox.pauseonprevclick) { mylytebox.toggleplaypause("lbpause", "lbplay"); } mylytebox.changecontent(mylytebox.activeslide - 1); return false; } } else { if (this.navtype == 2) { this.doc.getelementbyid('lbprev2_off').style.display = ''; } } if (this.activeslide != (this.slidearray.length - 1)) { var object = (this.navtype == 2 ? this.doc.getelementbyid('lbnext2') : this.doc.getelementbyid('lbnext')); object.style.display = ''; object.onclick = function() { if (mylytebox.pauseonnextclick) { mylytebox.toggleplaypause("lbpause", "lbplay"); } mylytebox.changecontent(mylytebox.activeslide + 1); return false; } } else { if (this.navtype == 2) { this.doc.getelementbyid('lbnext2_off').style.display = ''; } } } else if (this.islyteframe) { if(this.activeframe != 0) { var object = this.doc.getelementbyid('lbprev2'); object.style.display = ''; object.onclick = function() { mylytebox.changecontent(mylytebox.activeframe - 1); return false; } } else { this.doc.getelementbyid('lbprev2_off').style.display = ''; } if(this.activeframe != (this.framearray.length - 1)) { var object = this.doc.getelementbyid('lbnext2'); object.style.display = ''; object.onclick = function() { mylytebox.changecontent(mylytebox.activeframe + 1); return false; } } else { this.doc.getelementbyid('lbnext2_off').style.display = ''; } } else { if(this.activeimage != 0) { var object = (this.navtype == 2 ? this.doc.getelementbyid('lbprev2') : this.doc.getelementbyid('lbprev')); object.style.display = ''; object.onclick = function() { mylytebox.changecontent(mylytebox.activeimage - 1); return false; } } else { if (this.navtype == 2) { this.doc.getelementbyid('lbprev2_off').style.display = ''; } } if(this.activeimage != (this.imagearray.length - 1)) { var object = (this.navtype == 2 ? this.doc.getelementbyid('lbnext2') : this.doc.getelementbyid('lbnext')); object.style.display = ''; object.onclick = function() { mylytebox.changecontent(mylytebox.activeimage + 1); return false; } } else { if (this.navtype == 2) { this.doc.getelementbyid('lbnext2_off').style.display = ''; } } } this.enablekeyboardnav(); }; lytebox.prototype.enablekeyboardnav = function() { document.onkeydown = this.keyboardaction; }; lytebox.prototype.disablekeyboardnav = function() { document.onkeydown = ''; }; lytebox.prototype.keyboardaction = function(e) { var keycode = key = escape = null; keycode = (e == null) ? event.keycode : e.which; key = string.fromcharcode(keycode).tolowercase(); escape = (e == null) ? 27 : e.dom_vk_escape; if ((key == 'x') || (key == 'c') || (keycode == escape)) { mylytebox.end(); } else if ((key == 'p') || (keycode == 37)) { if (mylytebox.isslideshow) { if(mylytebox.activeslide != 0) { mylytebox.disablekeyboardnav(); mylytebox.changecontent(mylytebox.activeslide - 1); } } else if (mylytebox.islyteframe) { if(mylytebox.activeframe != 0) { mylytebox.disablekeyboardnav(); mylytebox.changecontent(mylytebox.activeframe - 1); } } else { if(mylytebox.activeimage != 0) { mylytebox.disablekeyboardnav(); mylytebox.changecontent(mylytebox.activeimage - 1); } } } else if ((key == 'n') || (keycode == 39)) { if (mylytebox.isslideshow) { if(mylytebox.activeslide != (mylytebox.slidearray.length - 1)) { mylytebox.disablekeyboardnav(); mylytebox.changecontent(mylytebox.activeslide + 1); } } else if (mylytebox.islyteframe) { if(mylytebox.activeframe != (mylytebox.framearray.length - 1)) { mylytebox.disablekeyboardnav(); mylytebox.changecontent(mylytebox.activeframe + 1); } } else { if(mylytebox.activeimage != (mylytebox.imagearray.length - 1)) { mylytebox.disablekeyboardnav(); mylytebox.changecontent(mylytebox.activeimage + 1); } } } }; lytebox.prototype.preloadneighborimages = function() { if (this.isslideshow) { if ((this.slidearray.length - 1) > this.activeslide) { preloadnextimage = new image(); preloadnextimage.src = this.slidearray[this.activeslide + 1][0]; } if(this.activeslide > 0) { preloadprevimage = new image(); preloadprevimage.src = this.slidearray[this.activeslide - 1][0]; } } else { if ((this.imagearray.length - 1) > this.activeimage) { preloadnextimage = new image(); preloadnextimage.src = this.imagearray[this.activeimage + 1][0]; } if(this.activeimage > 0) { preloadprevimage = new image(); preloadprevimage.src = this.imagearray[this.activeimage - 1][0]; } } }; lytebox.prototype.toggleplaypause = function(hideid, showid) { if (this.isslideshow && hideid == "lbpause") { for (var i = 0; i < this.slideshowidcount; i++) { window.cleartimeout(this.slideshowidarray[i]); } } this.doc.getelementbyid(hideid).style.display = 'none'; this.doc.getelementbyid(showid).style.display = ''; if (hideid == "lbplay") { this.ispaused = false; if (this.activeslide == (this.slidearray.length - 1)) { this.end(); } else { this.changecontent(this.activeslide + 1); } } else { this.ispaused = true; } }; lytebox.prototype.end = function(caller) { var closeclick = (caller == 'slideshow' ? false : true); if (this.isslideshow && this.ispaused && !closeclick) { return; } this.disablekeyboardnav(); this.doc.getelementbyid('lbmain').style.display = 'none'; this.fade('lboverlay', (this.doanimations ? this.maxopacity : 0)); this.toggleselects('visible'); if (this.hideflash) { this.toggleflash('visible'); } if (this.isslideshow) { for (var i = 0; i < this.slideshowidcount; i++) { window.cleartimeout(this.slideshowidarray[i]); } } if (this.islyteframe) { this.initialize(); } }; lytebox.prototype.checkframe = function() { if (window.parent.frames[window.name] && (parent.document.getelementsbytagname('frameset').length <= 0)) { this.isframe = true; this.lytebox = "window.parent." + window.name + ".mylytebox"; this.doc = parent.document; } else { this.isframe = false; this.lytebox = "mylytebox"; this.doc = document; } }; lytebox.prototype.getpixelrate = function(cur, img) { var diff = (img > cur) ? img - cur : cur - img; if (diff >= 0 && diff <= 100) { return 10; } if (diff > 100 && diff <= 200) { return 15; } if (diff > 200 && diff <= 300) { return 20; } if (diff > 300 && diff <= 400) { return 25; } if (diff > 400 && diff <= 500) { return 30; } if (diff > 500 && diff <= 600) { return 35; } if (diff > 600 && diff <= 700) { return 40; } if (diff > 700) { return 45; } }; lytebox.prototype.appear = function(id, opacity) { var object = this.doc.getelementbyid(id).style; object.opacity = (opacity / 100); object.mozopacity = (opacity / 100); object.khtmlopacity = (opacity / 100); object.filter = "alpha(opacity=" + (opacity + 10) + ")"; if (opacity == 100 && (id == 'lbimage' || id == 'lbiframe')) { try { object.removeattribute("filter"); } catch(e) {} /* fix added for ie alpha opacity filter bug. */ this.updatedetails(); } else if (opacity >= this.maxopacity && id == 'lboverlay') { for (var i = 0; i < this.overlaytimercount; i++) { window.cleartimeout(this.overlaytimerarray[i]); } return; } else if (opacity >= 100 && id == 'lbdetailscontainer') { try { object.removeattribute("filter"); } catch(e) {} /* fix added for ie alpha opacity filter bug. */ for (var i = 0; i < this.imagetimercount; i++) { window.cleartimeout(this.imagetimerarray[i]); } this.doc.getelementbyid('lboverlay').style.height = this.getpagesize()[1] + "px"; } else { if (id == 'lboverlay') { this.overlaytimerarray[this.overlaytimercount++] = settimeout("mylytebox.appear('" + id + "', " + (opacity+20) + ")", 1); } else { this.imagetimerarray[this.imagetimercount++] = settimeout("mylytebox.appear('" + id + "', " + (opacity+10) + ")", 1); } } }; lytebox.prototype.fade = function(id, opacity) { var object = this.doc.getelementbyid(id).style; object.opacity = (opacity / 100); object.mozopacity = (opacity / 100); object.khtmlopacity = (opacity / 100); object.filter = "alpha(opacity=" + opacity + ")"; if (opacity <= 0) { try { object.display = 'none'; } catch(err) { } } else if (id == 'lboverlay') { this.overlaytimerarray[this.overlaytimercount++] = settimeout("mylytebox.fade('" + id + "', " + (opacity-20) + ")", 1); } else { this.timeridarray[this.timeridcount++] = settimeout("mylytebox.fade('" + id + "', " + (opacity-10) + ")", 1); } }; lytebox.prototype.resizew = function(id, curw, maxw, pixelrate, speed) { if (!this.hdone) { this.resizewtimerarray[this.resizewtimercount++] = settimeout("mylytebox.resizew('" + id + "', " + curw + ", " + maxw + ", " + pixelrate + ")", 100); return; } var object = this.doc.getelementbyid(id); var timer = speed ? speed : (this.resizeduration/2); var neww = (this.doanimations ? curw : maxw); object.style.width = (neww) + "px"; if (neww < maxw) { neww += (neww + pixelrate >= maxw) ? (maxw - neww) : pixelrate; } else if (neww > maxw) { neww -= (neww - pixelrate <= maxw) ? (neww - maxw) : pixelrate; } this.resizewtimerarray[this.resizewtimercount++] = settimeout("mylytebox.resizew('" + id + "', " + neww + ", " + maxw + ", " + pixelrate + ", " + (timer+0.02) + ")", timer+0.02); if (parseint(object.style.width) == maxw) { this.wdone = true; for (var i = 0; i < this.resizewtimercount; i++) { window.cleartimeout(this.resizewtimerarray[i]); } } }; lytebox.prototype.resizeh = function(id, curh, maxh, pixelrate, speed) { var timer = speed ? speed : (this.resizeduration/2); var object = this.doc.getelementbyid(id); var newh = (this.doanimations ? curh : maxh); object.style.height = (newh) + "px"; if (newh < maxh) { newh += (newh + pixelrate >= maxh) ? (maxh - newh) : pixelrate; } else if (newh > maxh) { newh -= (newh - pixelrate <= maxh) ? (newh - maxh) : pixelrate; } this.resizehtimerarray[this.resizehtimercount++] = settimeout("mylytebox.resizeh('" + id + "', " + newh + ", " + maxh + ", " + pixelrate + ", " + (timer+.02) + ")", timer+.02); if (parseint(object.style.height) == maxh) { this.hdone = true; for (var i = 0; i < this.resizehtimercount; i++) { window.cleartimeout(this.resizehtimerarray[i]); } } }; lytebox.prototype.getpagescroll = function() { if (self.pageyoffset) { return this.isframe ? parent.pageyoffset : self.pageyoffset; } else if (this.doc.documentelement && this.doc.documentelement.scrolltop){ return this.doc.documentelement.scrolltop; } else if (document.body) { return this.doc.body.scrolltop; } }; lytebox.prototype.getpagesize = function() { var xscroll, yscroll, windowwidth, windowheight; if (window.innerheight && window.scrollmaxy) { xscroll = this.doc.scrollwidth; yscroll = (this.isframe ? parent.innerheight : self.innerheight) + (this.isframe ? parent.scrollmaxy : self.scrollmaxy); } else if (this.doc.body.scrollheight > this.doc.body.offsetheight){ xscroll = this.doc.body.scrollwidth; yscroll = this.doc.body.scrollheight; } else { xscroll = this.doc.getelementsbytagname("html").item(0).offsetwidth; yscroll = this.doc.getelementsbytagname("html").item(0).offsetheight; xscroll = (xscroll < this.doc.body.offsetwidth) ? this.doc.body.offsetwidth : xscroll; yscroll = (yscroll < this.doc.body.offsetheight) ? this.doc.body.offsetheight : yscroll; } if (self.innerheight) { windowwidth = (this.isframe) ? parent.innerwidth : self.innerwidth; windowheight = (this.isframe) ? parent.innerheight : self.innerheight; } else if (document.documentelement && document.documentelement.clientheight) { windowwidth = this.doc.documentelement.clientwidth; windowheight = this.doc.documentelement.clientheight; } else if (document.body) { windowwidth = this.doc.getelementsbytagname("html").item(0).clientwidth; windowheight = this.doc.getelementsbytagname("html").item(0).clientheight; windowwidth = (windowwidth == 0) ? this.doc.body.clientwidth : windowwidth; windowheight = (windowheight == 0) ? this.doc.body.clientheight : windowheight; } var pageheight = (yscroll < windowheight) ? windowheight : yscroll; var pagewidth = (xscroll < windowwidth) ? windowwidth : xscroll; return new array(pagewidth, pageheight, windowwidth, windowheight); }; lytebox.prototype.toggleflash = function(state) { var objects = this.doc.getelementsbytagname("object"); for (var i = 0; i < objects.length; i++) { objects[i].style.visibility = (state == "hide") ? 'hidden' : 'visible'; } var embeds = this.doc.getelementsbytagname("embed"); for (var i = 0; i < embeds.length; i++) { embeds[i].style.visibility = (state == "hide") ? 'hidden' : 'visible'; } if (this.isframe) { for (var i = 0; i < parent.frames.length; i++) { try { objects = parent.frames[i].window.document.getelementsbytagname("object"); for (var j = 0; j < objects.length; j++) { objects[j].style.visibility = (state == "hide") ? 'hidden' : 'visible'; } } catch(e) { } try { embeds = parent.frames[i].window.document.getelementsbytagname("embed"); for (var j = 0; j < embeds.length; j++) { embeds[j].style.visibility = (state == "hide") ? 'hidden' : 'visible'; } } catch(e) { } } } }; lytebox.prototype.toggleselects = function(state) { var selects = this.doc.getelementsbytagname("select"); for (var i = 0; i < selects.length; i++ ) { selects[i].style.visibility = (state == "hide") ? 'hidden' : 'visible'; } if (this.isframe) { for (var i = 0; i < parent.frames.length; i++) { try { selects = parent.frames[i].window.document.getelementsbytagname("select"); for (var j = 0; j < selects.length; j++) { selects[j].style.visibility = (state == "hide") ? 'hidden' : 'visible'; } } catch(e) { } } } }; lytebox.prototype.pause = function(numbermillis) { var now = new date(); var exittime = now.gettime() + numbermillis; while (true) { now = new date(); if (now.gettime() > exittime) { return; } } }; if (window.addeventlistener) { window.addeventlistener("load",initlytebox,false); } else if (window.attachevent) { window.attachevent("onload",initlytebox); } else { window.onload = function() {initlytebox();} } function initlytebox() { mylytebox = new lytebox(); }