source: extensions/Slim/js/lytebox.js @ 18811

Last change on this file since 18811 was 18811, checked in by Miklfe, 11 years ago
File size: 95.2 KB
Line 
1//**************************************************************************************************/
2//      Lytebox v5.5
3//
4//       Author: Markus F. Hay
5//  Website: http://lytebox.com  (http://dolem.com/lytebox)
6//         Date: January 26, 2012
7//      License: Creative Commons Attribution 3.0 License (http://creativecommons.org/licenses/by/3.0/)
8//**************************************************************************************************/
9function Lytebox(bInitialize, aHttp) {
10        /*** Language Configuration ***/
11       
12                // English - configure for your language or customize as needed.
13                // Note that these values will be seen by users when mousing over buttons.
14                this.label = new Object();
15                this.label['close']             = 'Close (Esc)';
16                this.label['prev']              = 'Precédent';  // Previous (left arrow)
17                this.label['next']              = 'Suivant';            // Next (right arrow)
18                this.label['play']              = 'Play (spacebar)';
19                this.label['pause']     = 'Pause (spacebar)';
20                this.label['print']     = 'Print';
21                this.label['image']     = 'Image %1 of %2';             // %1 = active image, %2 = total images
22                this.label['page']              = 'Page %1 of %2';              // %1 = active page, %2 = total pages
23               
24       
25        /*** Configure Lytebox ***/
26       
27                this.theme                      = (typeof lyteboxTheme !== 'undefined') && /^(black|grey|red|green|blue|gold|orange)$/i.test(lyteboxTheme) ? lyteboxTheme : 'grey'; // themes: black (default), grey, red, green, blue, gold, orange
28                this.roundedBorder              = false;                // controls whether or not the viewer uses rounded corners (false = square corners)
29                this.innerBorder                = true;                 // controls whether to show the inner border around image/html content
30                this.outerBorder                = false;                        // controls whether to show the outer grey (or theme) border
31                this.resizeSpeed                = 5;                    // controls the speed of the image resizing (1=slowest and 10=fastest)
32                this.maxOpacity                 = 90;                   // higher opacity = darker overlay, lower opacity = lighter overlay
33                this.borderSize                 = 0;                    // if you adjust the padding in the CSS, you will need to update this variable -- otherwise, leave this alone...
34
35                this.appendQS                   = false;                // if true, will append request_from=lytebox to the QS. Use this with caution as it may cause pages to not render
36                this.fixedPosition              = this.isMobile() ? false : true;       // if true, viewer will remain in a fixed position, otherwise page scrolling will be allowed
37                this.inherit                    = true;                 // controls whether or not data-lyte-options are inherited from the first link in a grouped set
38               
39                this.__hideObjects              = true;                 // controls whether or not objects (such as Flash, Java, etc.) should be hidden when the viewer opens
40                this.__autoResize               = true;                 // controls whether or not images should be resized if larger than the browser window dimensions
41                this.__doAnimations             = true;                 // controls ALL animation effects (i.e. overlay fade in/out, image resize transition, etc.)
42                this.__animateOverlay   = false;                // controls ONLY the overlay (background darkening) effects, and whether or not to fade in/out
43                this.__forceCloseClick  = false;                // if true, users are forced to click on the "Close" button when viewing content
44                this.__refreshPage              = false;                // force page refresh after closing Lytebox
45                this.__showPrint                = false;                // true to show print button, false to hide
46                this.__navType                  = 3;                    // 1 = "Prev/Next" buttons on top left and left
47                                                                                                // 2 = "Prev/Next" buttons in navigation bar
48                                                                                                // 3 = navType_1 + navType_2 (show both)
49                                                                                                       
50                // These two options control the position of the title/counter and navigation buttons. Note that for mobile devices,
51                // the title is displayed on top and the navigation on the bottom. This is due to the view area being limited.
52                // You can customize this for non-mobile devices by changing the 2nd condition (: false) to true (: true)
53                this.__navTop                   = this.isMobile() ? false : false; // true to show the buttons on the top right, false to show them on bottom right (default)
54                this.__titleTop                 = this.isMobile() ? true : false;  // true to show the title on the top left, false to show it on the bottom left (default)
55       
56       
57        /*** Configure HTML Content / Media Viewer Options ***/
58       
59                this.__width                    = '100%';               // default width of content viewer
60                this.__height                   = '100%';               // default height of content viewer
61                this.__scrolling                = 'auto';               // controls whether or not scrolling is allowed in the content viewer -- options are auto|yes|no
62                this.__loopPlayback             = false;                // controls whether or not embedded media is looped (swf, avi, mov, etc.)
63                this.__autoPlay                 = true;                 // controls whether or not to autoplay embedded media
64                this.__autoEmbed                = true;                 // controls whether or not to automatically embed media in an object tag
65       
66       
67        /*** Configure Slideshow Options ***/
68       
69                this.__slideInterval    = 4000;                 // change value (milliseconds) to increase/decrease the time between "slides"
70                this.__showNavigation   = false;                // true to display Next/Prev buttons/text during slideshow, false to hide
71                this.__showClose                = true;                 // true to display the Close button, false to hide
72                this.__showDetails              = true;                 // true to display image details (caption, count), false to hide
73                this.__showPlayPause    = true;                 // true to display pause/play buttons next to close button, false to hide
74                this.__autoEnd                  = true;                 // true to automatically close Lytebox after the last image is reached, false to keep open
75                this.__pauseOnNextClick = false;                // true to pause the slideshow when the "Next" button is clicked
76                this.__pauseOnPrevClick = true;                 // true to pause the slideshow when the "Prev" button is clicked
77                this.__loopSlideshow    = false;                // true to continuously loop through slides, false otherwise
78       
79       
80        /*** Configure Event Callbacks ***/
81       
82                this.__beforeStart              = '';                   // function to call before the viewer starts
83                this.__afterStart               = '';                   // function to call after the viewer starts
84                this.__beforeEnd                = '';                   // function to call before the viewer ends (after close click)
85                this.__afterEnd                 = '';                   // function to call after the viewer ends
86       
87               
88        /*** Configure Lytetip (tooltips) Options ***/
89                this.__changeTipCursor  = true;                 // true to change the cursor to 'help', false to leave default (inhereted)
90                this.__tipDecoration    = 'dotted';             // controls the text-decoration (underline) of the tip link (dotted|solid|none)
91                this.__tipStyle                 = 'classic';    // sets the default tip style if none is specified via data-lyte-options. Possible values are classic, info, help, warning, error
92                this.__tipRelative              = true;                 // if true, tips will be positioned relative to the element. if false, tips will be absolutely positioned on the page.
93                                                                                                // if you are having issues with tooltips not being properly positioned, then set this to false
94
95
96        this.navTypeHash = new Object();
97        this.navTypeHash['Hover_by_type_1']     = true;
98        this.navTypeHash['Display_by_type_1']   = false;
99        this.navTypeHash['Hover_by_type_2']     = false;
100        this.navTypeHash['Display_by_type_2']   = true;
101        this.navTypeHash['Hover_by_type_3']     = true;
102        this.navTypeHash['Display_by_type_3']   = true;
103        this.resizeWTimerArray          = new Array();
104        this.resizeWTimerCount          = 0;
105        this.resizeHTimerArray          = new Array();
106        this.resizeHTimerCount          = 0;
107        this.changeContentTimerArray= new Array();
108        this.changeContentTimerCount= 0;
109        this.overlayTimerArray          = new Array();
110        this.overlayTimerCount          = 0;
111        this.imageTimerArray            = new Array();
112        this.imageTimerCount            = 0;
113        this.timerIDArray                       = new Array();
114        this.timerIDCount                       = 0;
115        this.slideshowIDArray           = new Array();
116        this.slideshowIDCount           = 0;
117        this.imageArray  = new Array();
118        this.slideArray  = new Array();
119        this.frameArray  = new Array();
120        this.contentNum = null;
121        this.aPageSize = new Array();
122        this.overlayLoaded = false;
123        this.checkFrame();
124        this.isSlideshow        = false;
125        this.isLyteframe        = false;
126        this.tipSet                     = false;
127        this.ieVersion = this.ffVersion = this.chromeVersion = this.operaVersion = this.safariVersion = -1;
128        this.ie = this.ff = this.chrome = this.opera = this.safari = false;
129        this.setBrowserInfo();
130        this.classAttribute = (((this.ie && this.doc.compatMode == 'BackCompat') || (this.ie && this.ieVersion <= 7)) ? 'className' : 'class');
131        this.classAttribute = (this.ie && (document.documentMode == 8 || document.documentMode == 9)) ? 'class' : this.classAttribute;
132        this.isReady = false;
133        if (bInitialize) {
134                this.http = aHttp;
135                this.bodyOnscroll = document.body.onscroll;
136                if(this.resizeSpeed > 10) { this.resizeSpeed = 10; }
137                if(this.resizeSpeed < 1) { this.resizeSpeed = 1; }
138                var ie8Duration = 2;
139                        var isWinXP = (navigator.userAgent.match(/windows nt 5.1/i) || navigator.userAgent.match(/windows nt 5.2/i) ? true : false);
140                this.resizeDuration = (11 - this.resizeSpeed) * (this.ie ? (this.ieVersion >= 9 ? 6 : (this.ieVersion == 8 ? (this.doc.compatMode == 'BackCompat' ? ie8Duration : ie8Duration - 1) : 3)) : 7);
141                        this.resizeDuration = this.ff ? (11 - this.resizeSpeed) * (this.ffVersion < 6 ? 3 : (isWinXP ? 6 : 12)) : this.resizeDuration;
142                this.resizeDuration = this.chrome ? (11 - this.resizeSpeed) * 5 : this.resizeDuration;
143                this.resizeDuration = this.safari ? (11 - this.resizeSpeed) * 20 : this.resizeDuration;
144                        this.resizeDuration = this.isMobile() ? (11 - this.resizeSpeed) * 2 : this.resizeDuration;
145                if (window.name != 'lbIframe') {
146                        this.initialize();
147                }
148        } else {
149                this.http = new Array();
150                if (typeof $ == 'undefined') {
151                        $ = function (id) {
152                                        if ($.cache[id] === undefined) {
153                                                $.cache[id] = document.getElementById(id) || false;
154                                        }
155                                        return $.cache[id];
156                                };
157                        $.cache = {};
158                }
159        }
160}
161Lytebox.prototype.setBrowserInfo = function() {
162        var ua = navigator.userAgent.toLowerCase();
163        this.chrome = ua.indexOf('chrome') > -1;
164        this.ff = ua.indexOf('firefox') > -1;
165        this.safari = !this.chrome && ua.indexOf('safari') > -1;
166        this.opera = ua.indexOf('opera') > -1;
167        this.ie = /*@cc_on!@*/false;
168        if (this.chrome) {
169                var re = new RegExp("chrome/([0-9]{1,}[\.0-9]{0,})");
170                if (re.exec(ua) != null) {
171                        this.chromeVersion = parseInt( RegExp.$1 );
172                }
173        }
174        if (this.ff) {
175                var re = new RegExp("firefox/([0-9]{1,}[\.0-9]{0,})");
176                if (re.exec(ua) != null) {
177                        this.ffVersion = parseInt( RegExp.$1 );
178                }
179        }
180        if (this.ie) {
181                var re = new RegExp("msie ([0-9]{1,}[\.0-9]{0,})");
182                if (re.exec(ua) != null) {
183                        this.ieVersion = parseInt( RegExp.$1 );
184                }
185        }
186        if (this.opera) {
187                var re = new RegExp("opera/([0-9]{1,}[\.0-9]{0,})");
188                if (re.exec(ua) != null) {
189                        this.operaVersion = parseInt( RegExp.$1 );
190                }
191        }
192        if (this.safari) {
193                var re = new RegExp("version/([0-9]{1,}[\.0-9]{0,})");
194                if (re.exec(ua) != null) {
195                        this.safariVersion = parseInt( RegExp.$1 );
196                }
197        }
198};
199Lytebox.prototype.initialize = function() {
200        this.updateLyteboxItems();
201        var oBody = this.doc.getElementsByTagName('body').item(0);
202        if (this.doc.$('lbOverlay')) { oBody.removeChild(this.doc.$('lbOverlay')); }
203        if (this.doc.$('lbMain')) {     oBody.removeChild(this.doc.$('lbMain')); }
204        if (this.doc.$('lbLauncher')) { oBody.removeChild(this.doc.$('lbLauncher')); }
205        var oLauncher = this.doc.createElement('a');
206                oLauncher.setAttribute('id','lbLauncher');
207                oLauncher.setAttribute(this.classAttribute, 'lytebox');
208                oLauncher.style.display = 'none';
209                oBody.appendChild(oLauncher);
210        var oOverlay = this.doc.createElement('div');
211                oOverlay.setAttribute('id','lbOverlay');
212                oOverlay.setAttribute(this.classAttribute, this.theme);
213                if (this.ie && (this.ieVersion <= 6 || (this.ieVersion <= 9 && this.doc.compatMode == 'BackCompat'))) {
214                        oOverlay.style.position = 'absolute';
215                }
216                oOverlay.style.display = 'none';
217                oBody.appendChild(oOverlay);
218        var oLytebox = this.doc.createElement('div');
219                oLytebox.setAttribute('id','lbMain');
220                oLytebox.style.display = 'none';
221                oBody.appendChild(oLytebox);
222        var oOuterContainer = this.doc.createElement('div');
223                oOuterContainer.setAttribute('id','lbOuterContainer');
224                oOuterContainer.setAttribute(this.classAttribute, this.theme);
225                if (this.roundedBorder) {
226                        oOuterContainer.style.MozBorderRadius = '8px';
227                        oOuterContainer.style.borderRadius = '8px';
228                }
229                oLytebox.appendChild(oOuterContainer);
230        var oTopContainer = this.doc.createElement('div');
231                oTopContainer.setAttribute('id','lbTopContainer');
232                oTopContainer.setAttribute(this.classAttribute, this.theme);
233                if (this.roundedBorder) {
234                        oTopContainer.style.MozBorderRadius = '8px';
235                        oTopContainer.style.borderRadius = '8px';
236                }
237                oOuterContainer.appendChild(oTopContainer);
238        var oTopData = this.doc.createElement('div');
239                oTopData.setAttribute('id','lbTopData');
240                oTopData.setAttribute(this.classAttribute, this.theme);
241                oTopContainer.appendChild(oTopData);
242        var oTitleTop = this.doc.createElement('span');
243                oTitleTop.setAttribute('id','lbTitleTop');
244                oTopData.appendChild(oTitleTop);
245        var oNumTop = this.doc.createElement('span');
246                oNumTop.setAttribute('id','lbNumTop');
247                oTopData.appendChild(oNumTop);
248        var oTopNav = this.doc.createElement('div');
249                oTopNav.setAttribute('id','lbTopNav');
250                oTopContainer.appendChild(oTopNav);
251        var oCloseTop = this.doc.createElement('a');
252                oCloseTop.setAttribute('id','lbCloseTop');
253                oCloseTop.setAttribute('title', this.label['close']);
254                oCloseTop.setAttribute(this.classAttribute, this.theme);
255                oCloseTop.setAttribute('href','javascript:void(0)');
256                oTopNav.appendChild(oCloseTop);
257        var oPrintTop = this.doc.createElement('a');
258                oPrintTop.setAttribute('id','lbPrintTop')
259                oPrintTop.setAttribute('title', this.label['print']);
260                oPrintTop.setAttribute(this.classAttribute, this.theme);
261                oPrintTop.setAttribute('href','javascript:void(0)');
262                oTopNav.appendChild(oPrintTop);
263        var oNextTop = this.doc.createElement('a');
264                oNextTop.setAttribute('id','lbNextTop');
265                oNextTop.setAttribute('title', this.label['next']);
266                oNextTop.setAttribute(this.classAttribute, this.theme);
267                oNextTop.setAttribute('href','javascript:void(0)');
268                oTopNav.appendChild(oNextTop);
269        var oPauseTop = this.doc.createElement('a');
270                oPauseTop.setAttribute('id','lbPauseTop');
271                oPauseTop.setAttribute('title', this.label['pause']);
272                oPauseTop.setAttribute(this.classAttribute, this.theme);
273                oPauseTop.setAttribute('href','javascript:void(0)');
274                oPauseTop.style.display = 'none';
275                oTopNav.appendChild(oPauseTop);
276        var oPlayTop = this.doc.createElement('a');
277                oPlayTop.setAttribute('id','lbPlayTop');
278                oPlayTop.setAttribute('title', this.label['play']);
279                oPlayTop.setAttribute(this.classAttribute, this.theme);
280                oPlayTop.setAttribute('href','javascript:void(0)');
281                oPlayTop.style.display = 'none';
282                oTopNav.appendChild(oPlayTop);
283        var oPrevTop = this.doc.createElement('a');
284                oPrevTop.setAttribute('id','lbPrevTop');
285                oPrevTop.setAttribute('title', this.label['prev']);
286                oPrevTop.setAttribute(this.classAttribute, this.theme);
287                oPrevTop.setAttribute('href','javascript:void(0)');
288                oTopNav.appendChild(oPrevTop);
289        var oIframeContainer = this.doc.createElement('div');
290                oIframeContainer.setAttribute('id','lbIframeContainer');
291                oIframeContainer.style.display = 'none';
292                oOuterContainer.appendChild(oIframeContainer);
293        var oIframe = this.doc.createElement('iframe');
294                oIframe.setAttribute('id','lbIframe');
295                oIframe.setAttribute('name','lbIframe')
296                oIframe.setAttribute('frameBorder','0');
297                if (this.innerBorder) {
298                        oIframe.setAttribute(this.classAttribute, this.theme);
299                }
300                oIframe.style.display = 'none';
301                oIframeContainer.appendChild(oIframe);
302        var oImageContainer = this.doc.createElement('div');
303                oImageContainer.setAttribute('id','lbImageContainer');
304                oOuterContainer.appendChild(oImageContainer);
305        var oLyteboxImage = this.doc.createElement('img');
306                oLyteboxImage.setAttribute('id','lbImage');
307                if (this.innerBorder) {
308                        oLyteboxImage.setAttribute(this.classAttribute, this.theme);
309                }
310                oImageContainer.appendChild(oLyteboxImage);
311        var oLoading = this.doc.createElement('div');
312                oLoading.setAttribute('id','lbLoading');
313                oLoading.setAttribute(this.classAttribute, this.theme);
314                oOuterContainer.appendChild(oLoading);
315        var oBottomContainer = this.doc.createElement('div');
316                oBottomContainer.setAttribute('id','lbBottomContainer');
317                oBottomContainer.setAttribute(this.classAttribute, this.theme);
318                if (this.roundedBorder) {
319                        oBottomContainer.style.MozBorderRadius = '8px';
320                        oBottomContainer.style.borderRadius = '8px';
321                }
322                oOuterContainer.appendChild(oBottomContainer);
323        var oDetailsBottom = this.doc.createElement('div');
324                oDetailsBottom.setAttribute('id','lbBottomData');
325                oDetailsBottom.setAttribute(this.classAttribute, this.theme);
326                oBottomContainer.appendChild(oDetailsBottom);
327        var oTitleBottom = this.doc.createElement('span');
328                oTitleBottom.setAttribute('id','lbTitleBottom');
329                oDetailsBottom.appendChild(oTitleBottom);
330        var oNumBottom = this.doc.createElement('span');
331                oNumBottom.setAttribute('id','lbNumBottom');
332                oDetailsBottom.appendChild(oNumBottom);
333        var oDescBottom = this.doc.createElement('span');
334                oDescBottom.setAttribute('id','lbDescBottom');
335                oDetailsBottom.appendChild(oDescBottom);
336        var oHoverNav = this.doc.createElement('div');
337                oHoverNav.setAttribute('id','lbHoverNav');
338                oImageContainer.appendChild(oHoverNav);
339        var oBottomNav = this.doc.createElement('div');
340                oBottomNav.setAttribute('id','lbBottomNav');
341                oBottomContainer.appendChild(oBottomNav);
342        var oPrevHov = this.doc.createElement('a');
343                oPrevHov.setAttribute('id','lbPrevHov');
344                oPrevHov.setAttribute('title', this.label['prev']);
345                oPrevHov.setAttribute(this.classAttribute, this.theme);
346                oPrevHov.setAttribute('href','javascript:void(0)');
347                oHoverNav.appendChild(oPrevHov);
348        var oNextHov = this.doc.createElement('a');
349                oNextHov.setAttribute('id','lbNextHov');
350                oNextHov.setAttribute('title', this.label['next']);
351                oNextHov.setAttribute(this.classAttribute, this.theme);
352                oNextHov.setAttribute('href','javascript:void(0)');
353                oHoverNav.appendChild(oNextHov);
354        var oClose = this.doc.createElement('a');
355                oClose.setAttribute('id','lbClose');
356                oClose.setAttribute('title', this.label['close']);
357                oClose.setAttribute(this.classAttribute, this.theme);
358                oClose.setAttribute('href','javascript:void(0)');
359                oBottomNav.appendChild(oClose);
360        var oPrint = this.doc.createElement('a');
361                oPrint.setAttribute('id','lbPrint');
362                oPrint.setAttribute('title', this.label['print']);
363                oPrint.setAttribute(this.classAttribute, this.theme);
364                oPrint.setAttribute('href','javascript:void(0)');
365                oPrint.style.display = 'none';
366                oBottomNav.appendChild(oPrint);
367        var oNext = this.doc.createElement('a');
368                oNext.setAttribute('id','lbNext');
369                oNext.setAttribute('title', this.label['next']);
370                oNext.setAttribute(this.classAttribute, this.theme);
371                oNext.setAttribute('href','javascript:void(0)');
372                oBottomNav.appendChild(oNext);
373        var oPause = this.doc.createElement('a');
374                oPause.setAttribute('id','lbPause');
375                oPause.setAttribute('title', this.label['pause']);
376                oPause.setAttribute(this.classAttribute, this.theme);
377                oPause.setAttribute('href','javascript:void(0)');
378                oPause.style.display = 'none';
379                oBottomNav.appendChild(oPause);
380        var oPlay = this.doc.createElement('a');
381                oPlay.setAttribute('id','lbPlay');
382                oPlay.setAttribute('title', this.label['play']);
383                oPlay.setAttribute(this.classAttribute, this.theme);
384                oPlay.setAttribute('href','javascript:void(0)');
385                oPlay.style.display = 'none';
386                oBottomNav.appendChild(oPlay);
387        var oPrev = this.doc.createElement('a');
388                oPrev.setAttribute('id','lbPrev');
389                oPrev.setAttribute('title', this.label['prev']);
390                oPrev.setAttribute(this.classAttribute, this.theme);
391                oPrev.setAttribute('href','javascript:void(0)');
392                oBottomNav.appendChild(oPrev);
393        var iframes = (this.isFrame && window.parent.frames[window.name].document) ? window.parent.frames[window.name].document.getElementsByTagName('iframe') : document.getElementsByTagName('iframe');
394        for (var i = 0; i < iframes.length; i++) {
395                if (/youtube/i.test(iframes[i].src)) {
396                        iframes[i].src += ((/\?/.test(iframes[i].src)) ? '&' : '?') + 'wmode=transparent';
397                }
398        }
399        this.isReady = true;
400};
401Lytebox.prototype.updateLyteboxItems = function() {
402        var anchors = (this.isFrame && window.parent.frames[window.name].document) ? window.parent.frames[window.name].document.getElementsByTagName('a') : document.getElementsByTagName('a');
403                anchors = (this.isFrame) ? anchors : document.getElementsByTagName('a');
404        var areas = (this.isFrame && window.parent.frames[window.name].document) ? window.parent.frames[window.name].document.getElementsByTagName('area') : document.getElementsByTagName('area');
405        var lyteLinks = this.combine(anchors, areas);
406        var myLink = relAttribute = revAttribute = classAttribute = dataOptions = dataTip = tipDecoration = tipStyle = tipImage = tipHtml = aSetting = sName = sValue = sExt = aUrl = null;
407        var bImage = bRelative = false;
408        for (var i = 0; i < lyteLinks.length; i++) {
409                myLink = lyteLinks[i];
410                relAttribute = String(myLink.getAttribute('rel'));
411                classAttribute = String(myLink.getAttribute(this.classAttribute));
412                if (myLink.getAttribute('href')) {
413                        sType = classAttribute.match(/lytebox|lyteshow|lyteframe/i);
414                        sType = this.isEmpty(sType) ? relAttribute.match(/lytebox|lyteshow|lyteframe/i) : sType;
415                        dataOptions = String(myLink.getAttribute('data-lyte-options'));
416                        dataOptions = this.isEmpty(dataOptions) ? String(myLink.getAttribute('rev')) : dataOptions;
417                        aUrl = myLink.getAttribute('href').split('?');
418                        sExt = aUrl[0].split('.').pop().toLowerCase();
419                        bImage = (sExt == 'png' || sExt == 'jpg' || sExt == 'jpeg' || sExt == 'gif' || sExt == 'bmp');
420                        if (sType && sType.length >= 1) {
421                                if (this.isMobile() && /youtube/i.test(myLink.getAttribute('href'))) {
422                                        myLink.target = '_blank';
423                                } else if (bImage && (dataOptions.match(/slide:true/i) || sType[0].toLowerCase() == 'lyteshow')) {
424                                        myLink.onclick = function () { $lb.start(this, true, false); return false; }
425                                } else if (bImage) {
426                                        myLink.onclick = function () { $lb.start(this, false, false); return false; }
427                                } else {
428                                        myLink.onclick = function () { $lb.start(this, false, true); return false; }
429                                }
430                        }
431                        dataTip = String(myLink.getAttribute('data-tip'));
432                        dataTip = this.isEmpty(dataTip) ? myLink.getAttribute('title') : dataTip;
433                        if (classAttribute.toLowerCase().match('lytetip') && !this.isEmpty(dataTip) && !this.tipsSet) {
434                                if (this.__changeTipCursor) { myLink.style.cursor = 'help'; }
435                                tipDecoration = this.__tipDecoration;
436                                tipStyle = this.__tipStyle;
437                                bRelative = this.__tipRelative;
438                                if (!this.isEmpty(dataOptions)) {
439                                        aOptions = dataOptions.split(' ');
440                                        for (var j = 0; j < aOptions.length; j++) {
441                                                aSetting = aOptions[j].split(':');
442                                                sName = (aSetting.length > 1 ? this.trim(aSetting[0]).toLowerCase() : '');
443                                                sValue = (aSetting.length > 1 ? this.trim(aSetting[1]) : '');
444                                                switch(sName) {
445                                                        case 'tipstyle':
446                                                                tipStyle = (/classic|info|help|warning|error/.test(sValue) ? sValue : tipStyle); break;
447                                                        case 'changetipcursor':
448                                                                myLink.style.cursor = (/true|false/.test(sValue) ? (sValue == 'true' ? 'help' : '') : myLink.style.cursor); break;
449                                                        case 'tiprelative':
450                                                                bRelative = (/true|false/.test(sValue) ? (sValue == 'true') : bRelative); break;
451                                                        case 'tipdecoration':
452                                                                tipDecoration = (/dotted|solid|none/.test(sValue) ? sValue : tipDecoration); break;
453                                                }
454                                        }
455                                }
456                                if (tipDecoration != 'dotted') {
457                                        myLink.style.borderBottom = (tipDecoration == 'solid' ? '1px solid' : 'none');
458                                }
459                                switch(tipStyle) {
460                                        case 'info': tipStyle = 'lbCustom lbInfo'; tipImage = 'lbTipImg lbInfoImg'; break;
461                                        case 'help': tipStyle = 'lbCustom lbHelp'; tipImage = 'lbTipImg lbHelpImg'; break;
462                                        case 'warning': tipStyle = 'lbCustom lbWarning'; tipImage = 'lbTipImg lbWarningImg'; break;
463                                        case 'error': tipStyle = 'lbCustom lbError'; tipImage = 'lbTipImg lbErrorImg'; break;
464                                        case 'classic': tipStyle = 'lbClassic'; tipImage = ''; break;
465                                        default: tipStyle = 'lbClassic'; tipImage = '';
466                                }
467                                if ((this.ie && this.ieVersion <= 7) || (this.ieVersion == 8 && this.doc.compatMode == 'BackCompat')) {
468                                        tipImage = '';
469                                        if (tipStyle != 'lbClassic' && !this.isEmpty(tipStyle)) {
470                                                tipStyle += ' lbIEFix';
471                                        }
472                                }
473                                var aLinkPos = this.findPos(myLink);
474                                if ((this.ie && (this.ieVersion <= 6 || this.doc.compatMode == 'BackCompat')) || bRelative) {
475                                        myLink.style.position = 'relative';
476                                }
477                                tipHtml = myLink.innerHTML;
478                                myLink.innerHTML = '';
479                                if ((this.ie && this.ieVersion <= 6 && this.doc.compatMode != 'BackCompat') || bRelative) {
480                                        myLink.innerHTML = tipHtml + '<span class="' + tipStyle + '">' + (tipImage ? '<div class="' + tipImage + '"></div>' : '') + dataTip + '</span>';
481                                } else {
482                                        myLink.innerHTML = tipHtml + '<span class="' + tipStyle + '" style="left:'+aLinkPos[0]+'px;top:'+(aLinkPos[1]+aLinkPos[2])+'px;">' + (tipImage ? '<div class="' + tipImage + '"></div>' : '') + dataTip + '</span>';
483                                }
484                                if (classAttribute.match(/lytebox|lyteshow|lyteframe/i) == null) {
485                                        myLink.setAttribute('title','');
486                                }
487                        }
488                }
489        }
490        this.tipsSet = true;
491};
492Lytebox.prototype.launch = function(args) {
493        var sUrl = this.isEmpty(args.url) ? '' : String(args.url);
494        var sOptions = this.isEmpty(args.options) ? '' : String(args.options);
495        var sTitle = this.isEmpty(args.title) ? '' : args.title;
496        var sDesc = this.isEmpty(args.description) ? '' : args.description;
497        var bSlideshow = /slide:true/i.test(sOptions);
498        if (this.isEmpty(sUrl)) {
499                return false;
500        }
501        if (!this.isReady) {
502                this.timerIDArray[this.timerIDCount++] = setTimeout("$lb.launch({ url: '" + sUrl + "', options: '" + sOptions + "', title: '" + sTitle + "', description: '" + sDesc + "' })", 100);
503                return;
504        } else {
505                for (var i = 0; i < this.timerIDCount; i++) { window.clearTimeout(this.timerIDArray[i]); }
506        }
507        var aUrl = sUrl.split('?');
508        var sExt = aUrl[0].split('.').pop().toLowerCase();
509        var bImage = (sExt == 'png' || sExt == 'jpg' || sExt == 'jpeg' || sExt == 'gif' || sExt == 'bmp');
510        var oLauncher = this.doc.$('lbLauncher');
511                oLauncher.setAttribute('href', sUrl);
512                oLauncher.setAttribute('data-lyte-options', sOptions);
513                oLauncher.setAttribute('data-title', sTitle);
514                oLauncher.setAttribute('data-description', sDesc);
515        this.updateLyteboxItems();
516        this.start(oLauncher, bSlideshow, (bImage ? false : true));
517};
518Lytebox.prototype.start = function(oLink, bSlideshow, bFrame) {
519        var dataOptions = String(oLink.getAttribute('data-lyte-options'));
520                dataOptions = this.isEmpty(dataOptions) ? String(oLink.getAttribute('rev')) : dataOptions;
521        this.setOptions(dataOptions);
522        this.isSlideshow = (bSlideshow ? true : false);
523        this.isLyteframe = (bFrame ? true : false);
524        this.isPaused=true;
525        if (!this.isEmpty(this.beforeStart)) {
526                var callback = window[this.beforeStart];
527                if (typeof callback === 'function') {
528                        if (!callback(this.args)) { return; }
529                }
530        }
531        if (this.ie && this.ieVersion <= 6) { this.toggleSelects('hide'); }
532        if (this.hideObjects) { this.toggleObjects('hide'); }
533        if (this.isFrame && window.parent.frames[window.name].document) {
534                window.parent.$lb.printId = (this.isLyteframe ? 'lbIframe' : 'lbImage');
535        } else {
536                this.printId = (this.isLyteframe ? 'lbIframe' : 'lbImage');
537        }
538        this.aPageSize  = this.getPageSize();
539        var objOverlay  = this.doc.$('lbOverlay');
540        var objBody             = this.doc.getElementsByTagName("body").item(0);
541        objOverlay.style.height = this.aPageSize[1] + "px";
542        objOverlay.style.display = '';
543        this.fadeIn({ id: 'lbOverlay', opacity: (this.doAnimations && this.animateOverlay && (!this.ie || this.ieVersion >= 9) ? 0 : this.maxOpacity) });
544        var anchors = (this.isFrame && window.parent.frames[window.name].document) ? window.parent.frames[window.name].document.getElementsByTagName('a') : document.getElementsByTagName('a');
545                anchors = (this.isFrame) ? anchors : document.getElementsByTagName('a');
546        var areas = (this.isFrame && window.parent.frames[window.name].document) ? window.parent.frames[window.name].document.getElementsByTagName('area') : document.getElementsByTagName('area');
547        var lyteLinks = this.combine(anchors, areas);
548        var sType = sExt = aUrl = null;
549        this.frameArray = [];
550        this.frameNum = 0;
551        this.imageArray = [];
552        this.imageNum = 0;
553        this.slideArray = [];
554        this.slideNum = 0;
555        if (this.isEmpty(this.group)) {
556                dataOptions = String(oLink.getAttribute('data-lyte-options'));
557                dataOptions = this.isEmpty(dataOptions) ? String(oLink.getAttribute('rev')) : dataOptions;
558                if (this.isLyteframe) {                 
559                        this.frameArray.push(new Array(oLink.getAttribute('href'), (!this.isEmpty(oLink.getAttribute('data-title')) ? oLink.getAttribute('data-title') : oLink.getAttribute('title')), oLink.getAttribute('data-description'), dataOptions));
560                } else {
561                        this.imageArray.push(new Array(oLink.getAttribute('href'), (!this.isEmpty(oLink.getAttribute('data-title')) ? oLink.getAttribute('data-title') : oLink.getAttribute('title')), oLink.getAttribute('data-description'), dataOptions));
562                }
563        } else {
564                for (var i = 0; i < lyteLinks.length; i++) {
565                        var myLink = lyteLinks[i];
566                        dataOptions = String(myLink.getAttribute('data-lyte-options'));
567                        dataOptions = this.isEmpty(dataOptions) ? String(myLink.getAttribute('rev')) : dataOptions;
568                        if (myLink.getAttribute('href') && dataOptions.toLowerCase().match('group:' + this.group)) {
569                                sType = String(myLink.getAttribute(this.classAttribute)).match(/lytebox|lyteshow|lyteframe/i);
570                                sType = this.isEmpty(sType) ? myLink.getAttribute('rel').match(/lytebox|lyteshow|lyteframe/i) : sType;
571                                aUrl = myLink.getAttribute('href').split('?');
572                                sExt = aUrl[0].split('.').pop().toLowerCase();
573                                bImage = (sExt == 'png' || sExt == 'jpg' || sExt == 'jpeg' || sExt == 'gif' || sExt == 'bmp');
574                                if (sType && sType.length >= 1) {
575                                        if (bImage && (dataOptions.match(/slide:true/i) || sType[0].toLowerCase() == 'lyteshow')) {
576                                                this.slideArray.push(new Array(myLink.getAttribute('href'), (!this.isEmpty(myLink.getAttribute('data-title')) ? myLink.getAttribute('data-title') : myLink.getAttribute('title')), myLink.getAttribute('data-description'), dataOptions));
577                                        } else if (bImage) {
578                                                this.imageArray.push(new Array(myLink.getAttribute('href'), (!this.isEmpty(myLink.getAttribute('data-title')) ? myLink.getAttribute('data-title') : myLink.getAttribute('title')), myLink.getAttribute('data-description'), dataOptions));
579                                        } else {
580                                                this.frameArray.push(new Array(myLink.getAttribute('href'), (!this.isEmpty(myLink.getAttribute('data-title')) ? myLink.getAttribute('data-title') : myLink.getAttribute('title')), myLink.getAttribute('data-description'), dataOptions));
581                                        }
582                                }
583                        }
584                }
585                if (this.isLyteframe) {
586                        this.frameArray = this.removeDuplicates(this.frameArray);
587                        while(this.frameArray[this.frameNum][0] != oLink.getAttribute('href')) { this.frameNum++; }
588                } else if (bSlideshow) {
589                        this.slideArray = this.removeDuplicates(this.slideArray);
590                        try {
591                                while(this.slideArray[this.slideNum][0] != oLink.getAttribute('href')) { this.slideNum++; }
592                        } catch(e) {
593                        }
594                } else {
595                        this.imageArray = this.removeDuplicates(this.imageArray);
596                        while(this.imageArray[this.imageNum][0] != oLink.getAttribute('href')) { this.imageNum++; }
597                }
598        }
599        this.changeContent(this.isLyteframe ? this.frameNum : (this.isSlideshow ? this.slideNum : this.imageNum));
600};
601Lytebox.prototype.changeContent = function(iContentNum) {
602        this.contentNum = iContentNum;
603        if (!this.overlayLoaded) {
604                this.changeContentTimerArray[this.changeContentTimerCount++] = setTimeout("$lb.changeContent(" + this.contentNum + ")", 250);
605                return;
606        } else {
607                for (var i = 0; i < this.changeContentTimerCount; i++) { window.clearTimeout(this.changeContentTimerArray[i]); }
608        }
609        var sDataLyteOptions = (this.isLyteframe) ? this.frameArray[this.contentNum][3] : (this.isSlideshow ? this.slideArray[this.contentNum][3] : this.imageArray[this.contentNum][3]);
610        if (!this.inherit || /inherit:false/i.test(sDataLyteOptions)) {
611                this.setOptions(String(sDataLyteOptions));
612        } else {
613                var sDataLyteOptions1 = String((this.isLyteframe) ? this.frameArray[0][3] : (this.isSlideshow ? this.slideArray[0][3] : this.imageArray[0][3]));
614                if (this.isLyteframe) {
615                        var sWidth = sHeight = null;
616                        try { sWidth = sDataLyteOptions.match(/width:\d+(%|px|)/i)[0]; } catch(e) { }
617                        try { sHeight = sDataLyteOptions.match(/height:\d+(%|px|)/i)[0]; } catch(e) { }
618                        if (!this.isEmpty(sWidth)) {
619                                sDataLyteOptions1 = sDataLyteOptions1.replace(/width:\d+(%|px|)/i, sWidth);
620                        }
621                        if (!this.isEmpty(sHeight)) {
622                                sDataLyteOptions1 = sDataLyteOptions1.replace(/height:\d+(%|px|)/i, sHeight);
623                        }
624                }
625                this.setOptions(sDataLyteOptions1);
626        }
627        var object = this.doc.$('lbMain');
628                object.style.display = '';
629        var iDivisor = 200;
630        if (this.autoResize && this.fixedPosition) {
631                if (this.ie && (this.ieVersion <= 7 || this.doc.compatMode == 'BackCompat')) {
632                        object.style.top = (this.getPageScroll() + (this.aPageSize[3] / iDivisor)) + "px";
633                        var ps = (this.aPageSize[3] / iDivisor);
634                        this.scrollHandler = function(){
635                                $lb.doc.$('lbMain').style.top = ($lb.getPageScroll() + ps) + 'px';
636                        }
637                        this.bodyOnscroll = document.body.onscroll;
638                        if (window.addEventListener) {
639                                window.addEventListener('scroll', this.scrollHandler);
640                        } else if (window.attachEvent) {
641                                window.attachEvent('onscroll', this.scrollHandler);
642                        }
643                        object.style.position = "absolute";
644                } else {
645                        object.style.top = ((this.aPageSize[3] / iDivisor)) + "px";
646                        object.style.position = "fixed";
647                }
648        } else {
649                object.style.position = "absolute";
650                object.style.top = (this.getPageScroll() + (this.aPageSize[3] / iDivisor)) + "px";
651        }
652        this.doc.$('lbOuterContainer').style.paddingBottom = '0';
653        if (!this.outerBorder) {
654                this.doc.$('lbOuterContainer').style.border = 'none';
655        } else {
656                this.doc.$('lbOuterContainer').setAttribute(this.classAttribute, this.theme);
657        }
658        if (this.forceCloseClick) {
659                this.doc.$('lbOverlay').onclick = '';
660        } else {
661                this.doc.$('lbOverlay').onclick = function() { $lb.end(); return false; }
662        }
663        this.doc.$('lbMain').onclick = function(e) {
664                var e = e;
665                if (!e) {
666                        if (window.parent.frames[window.name] && (parent.document.getElementsByTagName('frameset').length <= 0)) {
667                                e = window.parent.window.event;
668                        } else {
669                                e = window.event;
670                        }
671                }
672                var id = (e.target ? e.target.id : e.srcElement.id);
673                if ((id == 'lbMain') && (!$lb.forceCloseClick)) { $lb.end(); return false; }
674        }
675        this.doc.$('lbPrintTop').onclick = this.doc.$('lbPrint').onclick = function() { $lb.printWindow(); return false; }
676        this.doc.$('lbCloseTop').onclick = this.doc.$('lbClose').onclick = function() { $lb.end(); return false; }
677        this.doc.$('lbPauseTop').onclick = function() { $lb.togglePlayPause("lbPauseTop", "lbPlayTop"); return false; }
678        this.doc.$('lbPause').onclick = function() { $lb.togglePlayPause("lbPause", "lbPlay"); return false; }
679        this.doc.$('lbPlayTop').onclick = function() { $lb.togglePlayPause("lbPlayTop", "lbPauseTop"); return false; }
680        this.doc.$('lbPlay').onclick = function() { $lb.togglePlayPause("lbPlay", "lbPause"); return false; }
681        if (this.isSlideshow && this.showPlayPause && this.isPaused) {
682                this.doc.$('lbPlay').style.display = '';
683                this.doc.$('lbPause').style.display = 'none';
684        }
685        if (this.isSlideshow) {
686                for (var i = 0; i < this.slideshowIDCount; i++) { window.clearTimeout(this.slideshowIDArray[i]); }
687        }
688        if (!this.outerBorder) {
689                this.doc.$('lbOuterContainer').style.border = 'none';
690        } else {
691                this.doc.$('lbOuterContainer').setAttribute(this.classAttribute, this.theme);
692        }
693        var iDecreaseMargin = 10;
694        if (this.titleTop || this.navTop) {
695                this.doc.$('lbTopContainer').style.visibility = 'hidden';
696                iDecreaseMargin += this.doc.$('lbTopContainer').offsetHeight;
697        } else {
698                this.doc.$('lbTopContainer').style.display = 'none';
699        }
700        this.doc.$('lbBottomContainer').style.display = 'none';
701        this.doc.$('lbImage').style.display = 'none';
702        this.doc.$('lbIframe').style.display = 'none';
703        this.doc.$('lbPrevHov').style.display = 'none';
704        this.doc.$('lbNextHov').style.display =  'none';
705        this.doc.$('lbIframeContainer').style.display = 'none';
706        this.doc.$('lbLoading').style.marginTop = '-' + iDecreaseMargin + 'px';
707        this.doc.$('lbLoading').style.display = '';
708        if (this.isLyteframe) {
709                var iframe = $lb.doc.$('lbIframe');
710                        iframe.src = 'about:blank';
711                var w = this.trim(this.width);
712                var h = this.trim(this.height);
713                if (/\%/.test(w)) {
714                        var percent = parseInt(w);
715                        w = parseInt((this.aPageSize[2]-50)*percent/100);
716                        w = w+'px';
717                }
718                if (/\%/.test(h)) {
719                        var percent = parseInt(h);
720                        h = parseInt((this.aPageSize[3]-150)*percent/100);
721                        h = h+'px';
722                }
723                if (this.autoResize) {
724                        var x = this.aPageSize[2] - 50;
725                        var y = this.aPageSize[3] - 150;
726                        w = (parseInt(w) > x ? x : w) + 'px';
727                        h = (parseInt(h) > y ? y : h) + 'px';
728                }
729                iframe.height = this.height = h;
730                iframe.width = this.width = w;
731                iframe.scrolling = this.scrolling;
732                var oDoc = iframe.contentWindow || iframe.contentDocument;
733                try {
734                        if (oDoc.document) {
735                                oDoc = oDoc.document;
736                        }
737                        oDoc.body.style.margin = 0;
738                        oDoc.body.style.padding = 0;
739                        if (this.ie && this.ieVersion <= 8) {
740                                oDoc.body.scroll = this.scrolling;
741                                oDoc.body.overflow = this.scrolling = 'no' ? 'hidden' : 'auto';
742                        }
743                } catch(e) { }
744                this.resizeContainer(parseInt(this.width), parseInt(this.height));
745        } else {
746                this.imgPreloader = new Image();
747                this.imgPreloader.onload = function() {
748                        var imageWidth = $lb.imgPreloader.width;
749                        var imageHeight = $lb.imgPreloader.height;
750                        if ($lb.autoResize) {
751                                var x = $lb.aPageSize[2] - 10;
752                                var y = $lb.aPageSize[3] - 60;
753                                if (imageWidth > x) {
754                                        imageHeight = Math.round(imageHeight * (x / imageWidth));
755                                        imageWidth = x; 
756                                        if (imageHeight > y) { 
757                                                imageWidth = Math.round(imageWidth * (y / imageHeight));
758                                                imageHeight = y; 
759                                        }
760                                } else if (imageHeight > y) { 
761                                        imageWidth = Math.round(imageWidth * (y / imageHeight));
762                                        imageHeight = y; 
763                                        if (imageWidth > x) {
764                                                imageHeight = Math.round(imageHeight * (x / imageWidth));
765                                                imageWidth = x;
766                                        }
767                                }
768                        }
769                        var lbImage = $lb.doc.$('lbImage');
770                        lbImage.src = $lb.imgPreloader.src;
771                        lbImage.width = imageWidth;
772                        lbImage.height = imageHeight;
773                        $lb.resizeContainer(imageWidth, imageHeight);
774                        $lb.imgPreloader.onload = function() {};
775                }
776                this.imgPreloader.src = (this.isSlideshow ? this.slideArray[this.contentNum][0] : this.imageArray[this.contentNum][0]);
777        }
778};
779Lytebox.prototype.resizeContainer = function(iWidth, iHeight) {
780        this.resizeWidth = iWidth;
781        this.resizeHeight = iHeight;
782        this.wCur = this.doc.$('lbOuterContainer').offsetWidth;
783        this.hCur = this.doc.$('lbOuterContainer').offsetHeight;
784        this.xScale = ((this.resizeWidth  + (this.borderSize * 2)) / this.wCur) * 100;
785        this.yScale = ((this.resizeHeight  + (this.borderSize * 2)) / this.hCur) * 100;
786        var wDiff = (this.wCur - this.borderSize * 2) - this.resizeWidth;
787        var hDiff = (this.hCur - this.borderSize * 2) - this.resizeHeight;
788        this.wDone = (wDiff == 0);
789        if (!(hDiff == 0)) {
790                this.hDone = false;
791                this.resizeH('lbOuterContainer', this.hCur, this.resizeHeight + this.borderSize * 2, this.getPixelRate(this.hCur, this.resizeHeight));
792        } else {
793                this.hDone = true;
794                if (!this.wDone) {
795                        this.resizeW('lbOuterContainer', this.wCur, this.resizeWidth + this.borderSize * 2, this.getPixelRate(this.wCur, this.resizeWidth));
796                }
797        }
798        if ((hDiff == 0) && (wDiff == 0)) {
799                if (this.ie){ this.pause(250); } else { this.pause(100); } 
800        }
801        this.doc.$('lbPrevHov').style.height = this.resizeHeight + "px";
802        this.doc.$('lbNextHov').style.height = this.resizeHeight + "px";
803        if (this.hDone && this.wDone) {
804                if (this.isLyteframe) {
805                        this.loadContent();
806                } else {
807                        this.showContent();
808                }
809        }
810};
811Lytebox.prototype.loadContent = function() {
812        try {
813                var iframe = this.doc.$('lbIframe');
814                var uri = this.frameArray[this.contentNum][0];
815                if (!this.inline && this.appendQS) {
816                        uri += ((/\?/.test(uri)) ? '&' : '?') + 'request_from=lytebox';
817                }
818                if (this.autoPlay && /youtube/i.test(uri)) {
819                        uri += ((/\?/.test(uri)) ? '&' : '?') + 'autoplay=1';
820                }
821                        if (!this.autoEmbed || (this.ff && (uri.match(/.pdf|.mov|.wmv/i)))) {
822                        this.frameSource = uri;
823                        this.showContent();
824                        return;
825                }
826                if (this.ie) {
827                        iframe.onreadystatechange = function() {
828                                if ($lb.doc.$('lbIframe').readyState == "complete") {
829                                        $lb.showContent();
830                                        $lb.doc.$('lbIframe').onreadystatechange = null;
831                                }
832                        };
833                } else {
834                        iframe.onload = function() {
835                                $lb.showContent();
836                                $lb.doc.$('lbIframe').onload = null;
837                        };
838                }
839                if (this.inline || (uri.match(/.mov|.avi|.wmv|.mpg|.mpeg|.swf/i))) {
840                        iframe.src = 'about:blank';
841                        this.frameSource = '';
842                        var sHtml = (this.inline) ? this.doc.$(uri.substr(uri.indexOf('#') + 1, uri.length)).innerHTML : this.buildObject(parseInt(this.width), parseInt(this.height), uri);
843                        var oDoc = iframe.contentWindow || iframe.contentDocument;
844                        if (oDoc.document) {
845                                oDoc = oDoc.document;
846                        }
847                        oDoc.open();
848                        oDoc.write(sHtml);
849                        oDoc.close();
850                        oDoc.body.style.margin = 0;
851                        oDoc.body.style.padding = 0;
852                        if (!this.inline) {
853                                oDoc.body.style.backgroundColor = '#fff';
854                                oDoc.body.style.fontFamily = 'Verdana, Helvetica, sans-serif';
855                                oDoc.body.style.fontSize = '0.9em';
856                        }
857                        this.frameSource = '';
858                } else {
859                        this.frameSource = uri;
860                        iframe.src = uri;
861                }
862        } catch(e) { }
863};
864Lytebox.prototype.showContent = function() {
865        if (this.isSlideshow) {
866                if(this.contentNum == (this.slideArray.length - 1)) {
867                        if (this.loopSlideshow) {
868                                this.slideshowIDArray[this.slideshowIDCount++] = setTimeout("$lb.changeContent(0)", this.slideInterval);
869                        } else if (this.autoEnd) {
870                                this.slideshowIDArray[this.slideshowIDCount++] = setTimeout("$lb.end('slideshow')", this.slideInterval);
871                        }
872                } else {
873                        if (!this.isPaused) {
874                                this.slideshowIDArray[this.slideshowIDCount++] = setTimeout("$lb.changeContent("+(this.contentNum+1)+")", this.slideInterval);
875                        }
876                }
877                this.doc.$('lbHoverNav').style.display = (this.ieVersion != 6 && this.showNavigation && this.navTypeHash['Hover_by_type_' + this.navType] ? '' : 'none');
878                this.doc.$('lbCloseTop').style.display = (this.showClose && this.navTop ? '' : 'none');
879                this.doc.$('lbClose').style.display = (this.showClose && !this.navTop ? '' : 'none');
880                this.doc.$('lbBottomData').style.display = (this.showDetails ? '' : 'none');
881                this.doc.$('lbPauseTop').style.display = (this.showPlayPause && this.navTop ? (!this.isPaused ? '' : 'none') : 'none');
882                this.doc.$('lbPause').style.display = (this.showPlayPause && !this.navTop ? (!this.isPaused ? '' : 'none') : 'none');
883                this.doc.$('lbPlayTop').style.display = (this.showPlayPause && this.navTop ? (!this.isPaused ? 'none' : '') : 'none');
884                this.doc.$('lbPlay').style.display = (this.showPlayPause && !this.navTop ? (!this.isPaused ? 'none' : '') : 'none');
885                this.doc.$('lbPrevTop').style.display = (this.navTop && this.showNavigation && this.navTypeHash['Display_by_type_' + this.navType] ? '' : 'none');
886                this.doc.$('lbPrev').style.display = (!this.navTop && this.showNavigation && this.navTypeHash['Display_by_type_' + this.navType] ? '' : 'none');
887                this.doc.$('lbNextTop').style.display = (this.navTop && this.showNavigation && this.navTypeHash['Display_by_type_' + this.navType] ? '' : 'none');
888                this.doc.$('lbNext').style.display = (!this.navTop && this.showNavigation && this.navTypeHash['Display_by_type_' + this.navType] ? '' : 'none');
889        } else {
890                this.doc.$('lbHoverNav').style.display = (this.ieVersion != 6 && this.navTypeHash['Hover_by_type_' + this.navType] && !this.isLyteframe ? '' : 'none');
891                if ((this.navTypeHash['Display_by_type_' + this.navType] && !this.isLyteframe && this.imageArray.length > 1) || (this.frameArray.length > 1 && this.isLyteframe)) {
892                        this.doc.$('lbPrevTop').style.display = (this.navTop ? '' : 'none');
893                        this.doc.$('lbPrev').style.display = (!this.navTop ? '' : 'none');
894                        this.doc.$('lbNextTop').style.display = (this.navTop ? '' : 'none');
895                        this.doc.$('lbNext').style.display = (!this.navTop ? '' : 'none');
896                } else {
897                        this.doc.$('lbPrevTop').style.display = 'none';
898                        this.doc.$('lbPrev').style.display = 'none';
899                        this.doc.$('lbNextTop').style.display = 'none';
900                        this.doc.$('lbNext').style.display = 'none';
901                }
902                this.doc.$('lbCloseTop').style.display = (this.navTop ? '' : 'none');
903                this.doc.$('lbClose').style.display = (!this.navTop ? '' : 'none');                             
904                this.doc.$('lbBottomData').style.display = '';
905                this.doc.$('lbPauseTop').style.display = 'none';
906                this.doc.$('lbPause').style.display = 'none';
907                this.doc.$('lbPlayTop').style.display = 'none';
908                this.doc.$('lbPlay').style.display = 'none';
909        }
910        this.doc.$('lbPrintTop').style.display = (this.showPrint && this.navTop ? '' : 'none');
911        this.doc.$('lbPrint').style.display = (this.showPrint && !this.navTop ? '' : 'none');
912        this.updateDetails();
913        this.doc.$('lbLoading').style.display = 'none';
914        this.doc.$('lbImageContainer').style.display = (this.isLyteframe ? 'none' : '');
915        this.doc.$('lbIframeContainer').style.display = (this.isLyteframe ? '' : 'none');
916        if (this.isLyteframe) {
917                if (!this.isEmpty(this.frameSource)) {
918                        this.doc.$('lbIframe').src = this.frameSource;
919                }
920                this.doc.$('lbIframe').style.display = '';
921                this.fadeIn({ id: 'lbIframe', opacity: (this.doAnimations && (!this.ie || this.ieVersion >= 9) ? 0 : 100) });
922        } else {
923                this.doc.$('lbImage').style.display = '';
924                this.fadeIn({ id: 'lbImage', opacity: (this.doAnimations && (!this.ie || this.ieVersion >= 9) ? 0 : 100) });
925                this.preloadNeighborImages();
926        }
927        if (!this.isEmpty(this.afterStart)) {
928                var callback = window[this.afterStart];
929                if (typeof callback === 'function') {
930                        callback(this.args);
931                }
932        }
933};
934Lytebox.prototype.updateDetails = function() {
935        var sTitle = (this.isSlideshow ? this.slideArray[this.contentNum][1] : (this.isLyteframe ? this.frameArray[this.contentNum][1] : this.imageArray[this.contentNum][1]));
936        var sDesc  = (this.isSlideshow ? this.slideArray[this.contentNum][2] : (this.isLyteframe ? this.frameArray[this.contentNum][2] : this.imageArray[this.contentNum][2]));
937        if (this.ie && this.ieVersion <= 7 || (this.ieVersion >= 8 && this.doc.compatMode == 'BackCompat')) {
938                this.doc.$(this.titleTop ? 'lbTitleBottom' : 'lbTitleTop').style.display = 'none';
939                this.doc.$(this.titleTop ? 'lbTitleTop' : 'lbTitleBottom').style.display = (this.isEmpty(sTitle) ? 'none' : 'block');
940        }
941        this.doc.$('lbDescBottom').style.display = (this.isEmpty(sDesc) ? 'none' : '');
942        this.doc.$(this.titleTop ? 'lbTitleTop' : 'lbTitleBottom').innerHTML = (this.isEmpty(sTitle) ? '' : sTitle);
943        this.doc.$(this.titleTop ? 'lbTitleBottom' : 'lbTitleTop').innerHTML = '';
944        this.doc.$(this.titleTop ? 'lbNumBottom' : 'lbNumTop').innerHTML = '';
945        this.updateNav();
946        if (this.titleTop || this.navTop) {
947                this.doc.$('lbTopContainer').style.display = 'block';
948                this.doc.$('lbTopContainer').style.visibility = 'visible';
949        } else {
950                this.doc.$('lbTopContainer').style.display = 'none';
951        }
952        var object = (this.titleTop ? this.doc.$('lbNumTop') : this.doc.$('lbNumBottom'));
953        if (this.isSlideshow && this.slideArray.length > 1) {
954                object.innerHTML = this.label['image'].replace('%1', this.contentNum + 1).replace('%2', this.slideArray.length);
955        } else if (this.imageArray.length > 1 && !this.isLyteframe) {
956                object.innerHTML = this.label['image'].replace('%1', this.contentNum + 1).replace('%2', this.imageArray.length);
957        } else if (this.frameArray.length > 1 && this.isLyteframe) {
958                object.innerHTML = this.label['page'].replace('%1', this.contentNum + 1).replace('%2', this.frameArray.length);
959        } else {
960                object.innerHTML = '';
961        }
962        var bAddSpacer = !(this.titleTop || (this.isEmpty(sTitle) && this.isEmpty(object.innerHTML)));
963        this.doc.$('lbDescBottom').innerHTML = (this.isEmpty(sDesc) ? '' : (bAddSpacer ? '<br style="line-height:0.6em;" />' : '') + sDesc);
964        var iNavWidth = 0;
965        if (this.ie && this.ieVersion <= 7 || (this.ieVersion >= 8 && this.doc.compatMode == 'BackCompat')) {
966                iNavWidth = 39 + (this.showPrint ? 39 : 0) + (this.isSlideshow && this.showPlayPause ? 39 : 0);
967                if ((this.isSlideshow && this.slideArray.length > 1 && this.showNavigation && this.navType != 1) ||
968                        (this.frameArray.length > 1 && this.isLyteframe) ||
969                        (this.imageArray.length > 1 && !this.isLyteframe && this.navType != 1)) {
970                                iNavWidth += 39*2;
971                }
972        }
973        this.doc.$('lbBottomContainer').style.display = (!(this.titleTop && this.navTop) || !this.isEmpty(sDesc) ? 'block' : 'none');
974        if (this.titleTop && this.navTop) {
975                if (iNavWidth > 0) {
976                        this.doc.$('lbTopNav').style.width = iNavWidth + 'px';
977                }
978                this.doc.$('lbTopData').style.width = (this.doc.$('lbTopContainer').offsetWidth - this.doc.$('lbTopNav').offsetWidth - 15) + 'px';
979                if (!this.isEmpty(sDesc)) {
980                        this.doc.$('lbDescBottom').style.width = (this.doc.$('lbBottomContainer').offsetWidth - 15) + 'px';
981                }
982        } else if ((!this.titleTop || !this.isEmpty(sDesc)) && !this.navTop) {
983                if (iNavWidth > 0) {
984                        this.doc.$('lbBottomNav').style.width = iNavWidth + 'px';
985                }
986                this.doc.$('lbBottomData').style.width = (this.doc.$('lbBottomContainer').offsetWidth - this.doc.$('lbBottomNav').offsetWidth - 15) + 'px';
987                this.doc.$('lbDescBottom').style.width = this.doc.$('lbBottomData').style.width;
988        }
989        this.fixBottomPadding();
990        this.aPageSize = this.getPageSize();
991        var iMainTop = parseInt(this.doc.$('lbMain').style.top);
992        if ((this.ie && this.ieVersion <= 7) || (this.ieVersion >= 8 && this.doc.compatMode == 'BackCompat')) {
993                iMainTop = (this.ie ? parseInt(this.doc.$('lbMain').style.top) - this.getPageScroll() : parseInt(this.doc.$('lbMain').style.top));
994        }
995        var iOverlap = (this.doc.$('lbOuterContainer').offsetHeight + iMainTop) - this.aPageSize[3];
996        var iDivisor = 40;
997        if (iOverlap > 0 && this.autoResize && this.fixedPosition) {
998                if (this.ie && (this.ieVersion <= 7 || this.doc.compatMode == 'BackCompat')) {
999                        document.body.onscroll = this.bodyOnscroll;
1000                        if (window.removeEventListener) {
1001                                window.removeEventListener('scroll', this.scrollHandler);
1002                        } else if (window.detachEvent) {
1003                                window.detachEvent('onscroll', this.scrollHandler);
1004                        }
1005                }
1006                this.doc.$('lbMain').style.position = "absolute";
1007                this.doc.$('lbMain').style.top = (this.getPageScroll() + (this.aPageSize[3] / iDivisor)) + "px";
1008        }
1009};
1010Lytebox.prototype.updateNav = function() {
1011        if (this.isSlideshow) {
1012                if (this.contentNum != 0) {
1013                        if (this.navTypeHash['Display_by_type_' + this.navType] && this.showNavigation) {
1014                                this.doc.$(this.navTop ? 'lbPrevTop' : 'lbPrev').setAttribute(this.classAttribute, this.theme);
1015                                this.doc.$(this.navTop ? 'lbPrevTop' : 'lbPrev').style.display = '';
1016                                this.doc.$(this.navTop ? 'lbPrevTop' : 'lbPrev').onclick = function() {
1017                                        if ($lb.pauseOnPrevClick) { $lb.togglePlayPause($lb.navTop ? 'lbPauseTop' : 'lbPause', $lb.navTop ? 'lbPlayTop' : 'lbPlay'); }
1018                                        $lb.changeContent($lb.contentNum - 1); return false;
1019                                }
1020                        }
1021                        if (this.navTypeHash['Hover_by_type_' + this.navType]) {
1022                                var object = this.doc.$('lbPrevHov');
1023                                object.style.display = '';
1024                                object.onclick = function() {
1025                                        if ($lb.pauseOnPrevClick) { $lb.togglePlayPause($lb.navTop ? 'lbPauseTop' : 'lbPause', $lb.navTop ? 'lbPlayTop' : 'lbPlay'); }
1026                                        $lb.changeContent($lb.contentNum - 1); return false;
1027                                }
1028                        }
1029                } else {
1030                        if (this.navTypeHash['Display_by_type_' + this.navType]) {
1031                                this.doc.$(this.navTop ? 'lbPrevTop' : 'lbPrev').setAttribute(this.classAttribute, this.theme + 'Off');
1032                                this.doc.$(this.navTop ? 'lbPrevTop' : 'lbPrev').onclick = function() { return false; }
1033                        }
1034                }
1035                if (this.contentNum != (this.slideArray.length - 1) && this.showNavigation) {
1036                        if (this.navTypeHash['Display_by_type_' + this.navType]) {
1037                                this.doc.$(this.navTop ? 'lbNextTop' : 'lbNext').setAttribute(this.classAttribute, this.theme);
1038                                this.doc.$(this.navTop ? 'lbNextTop' : 'lbNext').style.display = '';
1039                                this.doc.$(this.navTop ? 'lbNextTop' : 'lbNext').onclick = function() {
1040                                        if ($lb.pauseOnNextClick) { $lb.togglePlayPause($lb.navTop ? 'lbPauseTop' : 'lbPause', $lb.navTop ? 'lbPlayTop' : 'lbPlay'); }
1041                                        $lb.changeContent($lb.contentNum + 1); return false;
1042                                }
1043                        }
1044                        if (this.navTypeHash['Hover_by_type_' + this.navType]) {
1045                                var object = this.doc.$('lbNextHov');
1046                                object.style.display = '';
1047                                object.onclick = function() {
1048                                        if ($lb.pauseOnNextClick) { $lb.togglePlayPause($lb.navTop ? 'lbPauseTop' : 'lbPause', $lb.navTop ? 'lbPlayTop' : 'lbPlay'); }
1049                                        $lb.changeContent($lb.contentNum + 1); return false;
1050                                }
1051                        }
1052                } else {
1053                        if (this.navTypeHash['Display_by_type_' + this.navType]) { 
1054                                this.doc.$(this.navTop ? 'lbNextTop' : 'lbNext').setAttribute(this.classAttribute, this.theme + 'Off');
1055                                this.doc.$(this.navTop ? 'lbNextTop' : 'lbNext').onclick = function() { return false; }
1056                        }
1057                }
1058        } else if (this.isLyteframe) {
1059                if(this.contentNum != 0) {
1060                        this.doc.$(this.navTop ? 'lbPrevTop' : 'lbPrev').setAttribute(this.classAttribute, this.theme);
1061                        this.doc.$(this.navTop ? 'lbPrevTop' : 'lbPrev').style.display = '';
1062                        this.doc.$(this.navTop ? 'lbPrevTop' : 'lbPrev').onclick = function() {
1063                                $lb.changeContent($lb.contentNum - 1); return false;
1064                        }
1065                } else {
1066                        this.doc.$(this.navTop ? 'lbPrevTop' : 'lbPrev').setAttribute(this.classAttribute, this.theme + 'Off');
1067                        this.doc.$(this.navTop ? 'lbPrevTop' : 'lbPrev').onclick = function() { return false; }
1068                }
1069                if(this.contentNum != (this.frameArray.length - 1)) {
1070                        this.doc.$(this.navTop ? 'lbNextTop' : 'lbNext').setAttribute(this.classAttribute, this.theme);
1071                        this.doc.$(this.navTop ? 'lbNextTop' : 'lbNext').style.display = '';
1072                        this.doc.$(this.navTop ? 'lbNextTop' : 'lbNext').onclick = function() {
1073                                $lb.changeContent($lb.contentNum + 1); return false;
1074                        }
1075                } else {
1076                        this.doc.$(this.navTop ? 'lbNextTop' : 'lbNext').setAttribute(this.classAttribute, this.theme + 'Off');
1077                        this.doc.$(this.navTop ? 'lbNextTop' : 'lbNext').onclick = function() { return false; }
1078                }
1079        } else {
1080                if(this.contentNum != 0) {
1081                        if (this.navTypeHash['Display_by_type_' + this.navType]) {
1082                                this.doc.$(this.navTop ? 'lbPrevTop' : 'lbPrev').setAttribute(this.classAttribute, this.theme);
1083                                this.doc.$(this.navTop ? 'lbPrevTop' : 'lbPrev').style.display = '';
1084                                this.doc.$(this.navTop ? 'lbPrevTop' : 'lbPrev').onclick = function() {
1085                                        $lb.changeContent($lb.contentNum - 1); return false;
1086                                }
1087                        }
1088                        if (this.navTypeHash['Hover_by_type_' + this.navType]) {
1089                                var object2 = this.doc.$('lbPrevHov');
1090                                object2.style.display = '';
1091                                object2.onclick = function() {
1092                                        $lb.changeContent($lb.contentNum - 1); return false;
1093                                }
1094                        }
1095                } else {
1096                        if (this.navTypeHash['Display_by_type_' + this.navType]) {
1097                                this.doc.$(this.navTop ? 'lbPrevTop' : 'lbPrev').setAttribute(this.classAttribute, this.theme + 'Off');
1098                                this.doc.$(this.navTop ? 'lbPrevTop' : 'lbPrev').onclick = function() { return false; }
1099                        }
1100                }
1101                if(this.contentNum != (this.imageArray.length - 1)) {
1102                        if (this.navTypeHash['Display_by_type_' + this.navType]) {
1103                                this.doc.$(this.navTop ? 'lbNextTop' : 'lbNext').setAttribute(this.classAttribute, this.theme);
1104                                this.doc.$(this.navTop ? 'lbNextTop' : 'lbNext').style.display = '';
1105                                this.doc.$(this.navTop ? 'lbNextTop' : 'lbNext').onclick = function() {
1106                                        $lb.changeContent($lb.contentNum + 1); return false;
1107                                }
1108                        }
1109                        if (this.navTypeHash['Hover_by_type_' + this.navType]) {
1110                                var object2 = this.doc.$('lbNextHov');
1111                                object2.style.display = '';
1112                                object2.onclick = function() {
1113                                        $lb.changeContent($lb.contentNum + 1); return false;
1114                                }
1115                        }
1116                } else {
1117                        if (this.navTypeHash['Display_by_type_' + this.navType]) { 
1118                                this.doc.$(this.navTop ? 'lbNextTop' : 'lbNext').setAttribute(this.classAttribute, this.theme + 'Off');
1119                                this.doc.$(this.navTop ? 'lbNextTop' : 'lbNext').onclick = function() { return false; }
1120                        }
1121                }
1122        }
1123        this.enableKeyboardNav();
1124};
1125Lytebox.prototype.fixBottomPadding = function() {
1126        if (!((this.ieVersion == 7 || this.ieVersion == 8 || this.ieVersion == 9) && this.doc.compatMode == 'BackCompat') && this.ieVersion != 6) {
1127                var titleHeight = this.doc.$('lbTopContainer').offsetHeight + 5;
1128                var offsetHeight = (titleHeight == 5 ? 0 : titleHeight) + this.doc.$('lbBottomContainer').offsetHeight;
1129                this.doc.$('lbOuterContainer').style.paddingBottom = (offsetHeight + 5) + 'px';
1130        }
1131};
1132Lytebox.prototype.enableKeyboardNav = function() { document.onkeydown = this.keyboardAction; };
1133Lytebox.prototype.disableKeyboardNav = function() { document.onkeydown = ''; };
1134Lytebox.prototype.keyboardAction = function(e) {
1135        var keycode = key = escape = null;
1136        keycode = (e == null) ? event.keyCode : e.which;
1137        key             = String.fromCharCode(keycode).toLowerCase();
1138        escape  = (e == null) ? 27 : e.DOM_VK_ESCAPE;
1139        if ((key == 'x') || (key == 'c') || (keycode == escape || keycode == 27)) {
1140                parent.$lb.end();
1141        } else if (keycode == 32 && $lb.isSlideshow && $lb.showPlayPause) {
1142                if ($lb.isPaused) {
1143                        $lb.togglePlayPause($lb.navTop ? 'lbPlayTop' : 'lbPlay', $lb.navTop ? 'lbPauseTop' : 'lbPause');
1144                } else {
1145                        $lb.togglePlayPause($lb.navTop ? 'lbPauseTop' : 'lbPause', $lb.navTop ? 'lbPlayTop' : 'lbPlay');
1146                }
1147                return false;
1148        } else if (key == 'p' || keycode == 37) {
1149                if ($lb.isSlideshow) {
1150                        if($lb.contentNum != 0) {
1151                                $lb.disableKeyboardNav();
1152                                $lb.changeContent($lb.contentNum - 1);
1153                        }
1154                } else if ($lb.isLyteframe) {
1155                        if($lb.contentNum != 0) {
1156                                $lb.disableKeyboardNav();
1157                                $lb.changeContent($lb.contentNum - 1);
1158                        }
1159                } else {
1160                        if($lb.contentNum != 0) {
1161                                $lb.disableKeyboardNav();
1162                                $lb.changeContent($lb.contentNum - 1);
1163                        }
1164                }
1165        } else if (key == 'n' || keycode == 39) {
1166                if ($lb.isSlideshow) {
1167                        if($lb.contentNum != ($lb.slideArray.length - 1)) {
1168                                $lb.disableKeyboardNav();
1169                                $lb.changeContent($lb.contentNum + 1);
1170                        }
1171                } else if ($lb.isLyteframe) {
1172                        if($lb.contentNum != ($lb.frameArray.length - 1)) {
1173                                $lb.disableKeyboardNav();
1174                                $lb.changeContent($lb.contentNum + 1);
1175                        }
1176                } else {
1177                        if($lb.contentNum != ($lb.imageArray.length - 1)) {
1178                                $lb.disableKeyboardNav();
1179                                $lb.changeContent($lb.contentNum + 1);
1180                        }
1181                }
1182        }
1183};
1184Lytebox.prototype.preloadNeighborImages = function() {
1185        if (this.isSlideshow) {
1186                if ((this.slideArray.length - 1) > this.contentNum) {
1187                        var preloadNextImage = new Image();
1188                                preloadNextImage.src = this.slideArray[this.contentNum + 1][0];
1189                }
1190                if (this.contentNum > 0) {
1191                        var preloadPrevImage = new Image();
1192                                preloadPrevImage.src = this.slideArray[this.contentNum - 1][0];
1193                }
1194        } else {
1195                if ((this.imageArray.length - 1) > this.contentNum) {
1196                        var preloadNextImage = new Image();
1197                                preloadNextImage.src = this.imageArray[this.contentNum + 1][0];
1198                }
1199                if (this.contentNum > 0) {
1200                        var preloadPrevImage = new Image();
1201                                preloadPrevImage.src = this.imageArray[this.contentNum - 1][0];
1202                }
1203        }
1204};
1205Lytebox.prototype.togglePlayPause = function(sHideId, sShowId) {
1206        if (this.isSlideshow && (sHideId == 'lbPauseTop' || sHideId == 'lbPause')) {
1207                for (var i = 0; i < this.slideshowIDCount; i++) { window.clearTimeout(this.slideshowIDArray[i]); }
1208        }
1209        this.doc.$(sHideId).style.display = 'none';
1210        this.doc.$(sShowId).style.display = '';
1211        if (sHideId == 'lbPlayTop' || sHideId == 'lbPlay') {
1212                this.isPaused = false;
1213                if (this.contentNum == (this.slideArray.length - 1)) {
1214                        if (this.loopSlideshow) {
1215                                this.changeContent(0);
1216                        } else if (this.autoEnd) {
1217                                this.end();
1218                        }
1219                } else {
1220                        this.changeContent(this.contentNum + 1);
1221                }
1222        } else {
1223                this.isPaused = true;
1224        }
1225};
1226Lytebox.prototype.end = function(sCaller) {
1227        var closeClick = (sCaller == 'slideshow' ? false : true);
1228        if (this.isSlideshow && this.isPaused && !closeClick) { return; }
1229        if (!this.isEmpty(this.beforeEnd)) {
1230                var callback = window[this.beforeEnd];
1231                if (typeof callback === 'function') {
1232                        if (!callback(this.args)) { return; }
1233                }
1234        }
1235        this.disableKeyboardNav();
1236        document.body.onscroll = this.bodyOnscroll;
1237        if (this.refreshPage) {
1238                var uri_href = top.location.href;
1239                var reg=/\#.*$/g;
1240                uri_href=uri_href.replace(reg, "");
1241                top.location.href = uri_href;
1242                return;
1243        }
1244        this.doc.$('lbMain').style.display = 'none';
1245        this.fadeOut({ id: 'lbOverlay', opacity: (this.doAnimations && this.animateOverlay && (!this.ie || this.ieVersion >= 9) ? this.maxOpacity : 0), speed: 5, display: 'none' });
1246        this.toggleSelects('visible');
1247        if (this.hideObjects) { this.toggleObjects('visible'); }
1248        this.doc.$('lbOuterContainer').style.width = '200px';
1249        this.doc.$('lbOuterContainer').style.height = '200px';
1250        if (this.inline && this.safari) {
1251                var iframe = this.doc.$('lbIframe');
1252                var oDoc = iframe.contentWindow || iframe.contentDocument;
1253                if (oDoc.document) {
1254                        oDoc = oDoc.document;
1255                }
1256                oDoc.open();
1257                oDoc.write('<html><head></head><body></body></html>');
1258                oDoc.close();
1259        }
1260        if (this.isSlideshow) {
1261                for (var i = 0; i < this.slideshowIDCount; i++) { window.clearTimeout(this.slideshowIDArray[i]); }
1262                this.isPaused = false;
1263        }
1264        if (!this.isEmpty(this.afterEnd)) {
1265                var callback = window[this.afterEnd];
1266                if (typeof callback === 'function') {
1267                        callback(this.args);
1268                }
1269        }
1270};
1271Lytebox.prototype.checkFrame = function() {
1272        if (window.parent.frames[window.name] && (parent.document.getElementsByTagName('frameset').length <= 0) && window.name != 'lbIframe') {
1273                this.isFrame = true;
1274                this.doc = parent.document;
1275        } else {
1276                this.isFrame = false;
1277                this.doc = document;
1278        }
1279        this.doc.$ = this.doc.getElementById;
1280};
1281Lytebox.prototype.getPixelRate = function(iCurrent, iDim) {
1282        var diff = (iDim > iCurrent) ? iDim - iCurrent : iCurrent - iDim;
1283        if (diff >= 0 && diff <= 100) { return (100 / this.resizeDuration); }
1284        if (diff > 100 && diff <= 200) { return (150 / this.resizeDuration); }
1285        if (diff > 200 && diff <= 300) { return (200 / this.resizeDuration); }
1286        if (diff > 300 && diff <= 400) { return (250 / this.resizeDuration); }
1287        if (diff > 400 && diff <= 500) { return (300 / this.resizeDuration); }
1288        if (diff > 500 && diff <= 600) { return (350 / this.resizeDuration); }
1289        if (diff > 600 && diff <= 700) { return (400 / this.resizeDuration); }
1290        if (diff > 700) { return (450 / this.resizeDuration); }
1291};
1292Lytebox.prototype.fadeIn = function(args) {
1293        var sId = this.isEmpty(args.id) ? '' : args.id;
1294        var iSpeed = (this.isEmpty(args.speed) ? 5 : (parseInt(args.speed) > 5 ? 5 : parseInt(args.speed)));
1295                iSpeed = isNaN(iSpeed) ? 5 : iSpeed;
1296        var iOpacity = this.isEmpty(args.opacity) ? 0 : parseInt(args.opacity);
1297                iOpacity = isNaN(iOpacity) ? 0 : iOpacity;
1298        var sDisplay = this.isEmpty(args.display) ? '' : args.display;
1299        var sVisibility = this.isEmpty(args.visibility) ? '' : args.visibility;
1300        var oElement = this.doc.$(sId);
1301        var iIncrement = iSpeed;
1302        if (/lbImage|lbIframe|lbOverlay|lbBottomContainer|lbTopContainer/.test(sId)) {
1303                iIncrement = this.ff ? (this.ffVersion >= 6 ? 2 : 5) : (this.safari ? 3 : (this.ieVersion <= 8 ? 10 : 5));
1304                iIncrement = this.isMobile() ? 20 : iIncrement;
1305                iIncrement = (sId == 'lbOverlay' ? iIncrement * 2 : iIncrement);
1306                iIncrement = (sId == 'lbIframe' ? 100 : iIncrement);
1307        } else if (this.ieVersion == 7 || this.ieVersion == 8) {
1308                iIncrement = 10;
1309        }
1310        oElement.style.opacity = (iOpacity / 100);
1311        oElement.style.filter = "alpha(opacity=" + (iOpacity) + ")";
1312        if (iOpacity >= 100 && (sId == 'lbImage' || sId == 'lbIframe')) {
1313                try { oElement.style.removeAttribute("filter"); } catch(e) {}
1314                this.fixBottomPadding();
1315        } else if (iOpacity >= this.maxOpacity && sId == 'lbOverlay') {
1316                for (var i = 0; i < this.overlayTimerCount; i++) { window.clearTimeout(this.overlayTimerArray[i]); }
1317                this.overlayLoaded = true;
1318                return;
1319        } else if (iOpacity >= 100 && (sId == 'lbBottomContainer' || sId == 'lbTopContainer')) {
1320                try { oElement.style.removeAttribute("filter"); } catch(e) {}
1321                for (var i = 0; i < this.imageTimerCount; i++) { window.clearTimeout(this.imageTimerArray[i]); }
1322                this.doc.$('lbOverlay').style.height = this.aPageSize[1] + "px";
1323        } else if (iOpacity >= 100) {
1324                for (var i = 0; i < this.imageTimerCount; i++) { window.clearTimeout(this.imageTimerArray[i]); }
1325        } else {
1326                if (sId == 'lbOverlay') {
1327                        this.overlayTimerArray[this.overlayTimerCount++] = setTimeout("$lb.fadeIn({ id: '" + sId + "', opacity: " + (iOpacity + iIncrement) + ", speed: " + iSpeed + " })", 1);
1328                } else {
1329                        this.imageTimerArray[this.imageTimerCount++] = setTimeout("$lb.fadeIn({ id: '" + sId + "', opacity: " + (iOpacity + iIncrement) + ", speed: " + iSpeed + " })", 1);
1330                }
1331        }
1332};
1333Lytebox.prototype.fadeOut = function(args) {
1334        var sId = this.isEmpty(args.id) ? '' : args.id;
1335        var iSpeed = (this.isEmpty(args.speed) ? 5 : (parseInt(args.speed) > 5 ? 5 : parseInt(args.speed)));
1336                iSpeed = isNaN(iSpeed) ? 5 : iSpeed;
1337        var iOpacity = this.isEmpty(args.opacity) ? 100 : parseInt(args.opacity);
1338                iOpacity = isNaN(iOpacity) ? 100 : iOpacity;
1339        var sDisplay = this.isEmpty(args.display) ? '' : args.display;
1340        var sVisibility = this.isEmpty(args.visibility) ? '' : args.visibility;
1341        var oElement = this.doc.$(sId);
1342        if (this.ieVersion == 7 || this.ieVersion == 8) {
1343                iSpeed *= 2;
1344        }
1345        oElement.style.opacity = (iOpacity / 100);
1346        oElement.style.filter = "alpha(opacity=" + iOpacity + ")";
1347        if (iOpacity <= 0) {
1348                try {
1349                        if (!this.isEmpty(sDisplay)) {
1350                                oElement.style.display = sDisplay;
1351                        }
1352                        if (!this.isEmpty(sVisibility)) {
1353                                oElement.style.visibility = sVisibility;
1354                        }
1355                } catch(err) { }
1356                if (sId == 'lbOverlay') {
1357                        this.overlayLoaded = false;
1358                        if (this.isLyteframe) {
1359                                this.doc.$('lbIframe').src = 'about:blank';
1360                                this.initialize();
1361                        }
1362                } else {
1363                        for (var i = 0; i < this.timerIDCount; i++) { window.clearTimeout(this.timerIDArray[i]); }
1364                }
1365        } else if (sId == 'lbOverlay') {
1366                this.overlayTimerArray[this.overlayTimerCount++] = setTimeout("$lb.fadeOut({ id: '" + sId + "', opacity: " + (iOpacity - (iSpeed * 2)) + ", speed: " + iSpeed + ", display: '" + sDisplay + "', visibility: '" + sVisibility + "' })", 1);
1367        } else {
1368                this.timerIDArray[this.timerIDCount++] = setTimeout("$lb.fadeOut({ id: '" + sId + "', opacity: " + (iOpacity - iSpeed) + ", speed: " + iSpeed + ", display: '" + sDisplay + "', visibility: '" + sVisibility + "' })", 1);
1369        }
1370};
1371Lytebox.prototype.resizeW = function(sId, iCurrentW, iMaxW, iPixelRate, iSpeed) {
1372        var object = this.doc.$(sId);
1373        var newW = (this.doAnimations ? iCurrentW : iMaxW);
1374        object.style.width = (newW) + "px";
1375        if (newW < iMaxW) {
1376                newW += (newW + iPixelRate >= iMaxW) ? (iMaxW - newW) : iPixelRate;
1377        } else if (newW > iMaxW) {
1378                newW -= (newW - iPixelRate <= iMaxW) ? (newW - iMaxW) : iPixelRate;
1379        }
1380        this.resizeWTimerArray[this.resizeWTimerCount++] = setTimeout("$lb.resizeW('" + sId + "', " + newW + ", " + iMaxW + ", " + iPixelRate + ", " + (iSpeed) + ")", iSpeed);
1381        if (parseInt(object.style.width) == iMaxW) {
1382                this.wDone = true;
1383                for (var i = 0; i < this.resizeWTimerCount; i++) { window.clearTimeout(this.resizeWTimerArray[i]); }
1384                if (this.isLyteframe) {
1385                        this.loadContent();
1386                } else {
1387                        this.showContent();
1388                }
1389        }
1390};
1391Lytebox.prototype.resizeH = function(sId, iCurrentH, iMaxH, iPixelRate, iSpeed) {
1392        var object = this.doc.$(sId);
1393        var newH = (this.doAnimations ? iCurrentH : iMaxH);
1394        object.style.height = (newH) + "px";
1395        if (newH < iMaxH) {
1396                newH += (newH + iPixelRate >= iMaxH) ? (iMaxH - newH) : iPixelRate;
1397        } else if (newH > iMaxH) {
1398                newH -= (newH - iPixelRate <= iMaxH) ? (newH - iMaxH) : iPixelRate;
1399        }
1400        this.resizeHTimerArray[this.resizeHTimerCount++] = setTimeout("$lb.resizeH('" + sId + "', " + newH + ", " + iMaxH + ", " + iPixelRate + ", " + (iSpeed+.02) + ")", iSpeed+.02);
1401        if (parseInt(object.style.height) == iMaxH) {
1402                this.hDone = true;
1403                for (var i = 0; i < this.resizeHTimerCount; i++) { window.clearTimeout(this.resizeHTimerArray[i]); }
1404                this.resizeW('lbOuterContainer', this.wCur, this.resizeWidth + this.borderSize * 2, this.getPixelRate(this.wCur, this.resizeWidth));
1405        }
1406};
1407Lytebox.prototype.getPageScroll = function() {
1408        if (self.pageYOffset) {
1409                return this.isFrame ? parent.pageYOffset : self.pageYOffset;
1410        } else if (this.doc.documentElement && this.doc.documentElement.scrollTop){
1411                return this.doc.documentElement.scrollTop;
1412        } else if (document.body) {
1413                return this.doc.body.scrollTop;
1414        }
1415};
1416Lytebox.prototype.getPageSize = function() {
1417        var xScroll, yScroll, windowWidth, windowHeight;
1418        if (window.innerHeight && window.scrollMaxY) {
1419                xScroll = this.doc.scrollWidth;
1420                yScroll = (this.isFrame ? parent.innerHeight : self.innerHeight) + (this.isFrame ? parent.scrollMaxY : self.scrollMaxY);
1421        } else if (this.doc.body.scrollHeight > this.doc.body.offsetHeight){
1422                xScroll = this.doc.body.scrollWidth;
1423                yScroll = this.doc.body.scrollHeight;
1424        } else {
1425                xScroll = this.doc.getElementsByTagName("html").item(0).offsetWidth;
1426                yScroll = this.doc.getElementsByTagName("html").item(0).offsetHeight;
1427                xScroll = (xScroll < this.doc.body.offsetWidth) ? this.doc.body.offsetWidth : xScroll;
1428                yScroll = (yScroll < this.doc.body.offsetHeight) ? this.doc.body.offsetHeight : yScroll;
1429        }
1430        if (self.innerHeight) {
1431                windowWidth = (this.isFrame) ? parent.innerWidth : self.innerWidth;
1432                windowHeight = (this.isFrame) ? parent.innerHeight : self.innerHeight;
1433        } else if (document.documentElement && document.documentElement.clientHeight) {
1434                windowWidth = this.doc.documentElement.clientWidth;
1435                windowHeight = this.doc.documentElement.clientHeight;
1436                windowWidth = (windowWidth == 0) ? this.doc.body.clientWidth : windowWidth;
1437                windowHeight = (windowHeight == 0) ? this.doc.body.clientHeight : windowHeight;
1438        } else if (document.body) {
1439                windowWidth = this.doc.getElementsByTagName("html").item(0).clientWidth;
1440                windowHeight = this.doc.getElementsByTagName("html").item(0).clientHeight;
1441                windowWidth = (windowWidth == 0) ? this.doc.body.clientWidth : windowWidth;
1442                windowHeight = (windowHeight == 0) ? this.doc.body.clientHeight : windowHeight;
1443        }
1444        var pageHeight = (yScroll < windowHeight) ? windowHeight : yScroll;
1445        var pageWidth = (xScroll < windowWidth) ? windowWidth : xScroll;
1446        return new Array(pageWidth, pageHeight, windowWidth, windowHeight);
1447};
1448Lytebox.prototype.toggleObjects = function(sState) {
1449        var objects = this.doc.getElementsByTagName("object");
1450        for (var i = 0; i < objects.length; i++) {
1451                objects[i].style.visibility = (sState == "hide") ? 'hidden' : 'visible';
1452        }
1453        var embeds = this.doc.getElementsByTagName("embed");
1454        for (var i = 0; i < embeds.length; i++) {
1455                embeds[i].style.visibility = (sState == "hide") ? 'hidden' : 'visible';
1456        }
1457        if (this.isFrame) {
1458                for (var i = 0; i < parent.frames.length; i++) {
1459                        try {
1460                                objects = parent.frames[i].window.document.getElementsByTagName("object");
1461                                for (var j = 0; j < objects.length; j++) {
1462                                        objects[j].style.visibility = (sState == "hide") ? 'hidden' : 'visible';
1463                                }
1464                        } catch(e) {}
1465                       
1466                        try {
1467                                embeds = parent.frames[i].window.document.getElementsByTagName("embed");
1468                                for (var j = 0; j < embeds.length; j++) {
1469                                        embeds[j].style.visibility = (sState == "hide") ? 'hidden' : 'visible';
1470                                }
1471                        } catch(e) {}
1472                }
1473        }
1474};
1475Lytebox.prototype.toggleSelects = function(sState) {
1476        var selects = this.doc.getElementsByTagName("select");
1477        for (var i = 0; i < selects.length; i++ ) {
1478                selects[i].style.visibility = (sState == "hide") ? 'hidden' : 'visible';
1479        }
1480        if (this.isFrame) {
1481                for (var i = 0; i < parent.frames.length; i++) {
1482                        try {
1483                                selects = parent.frames[i].window.document.getElementsByTagName("select");
1484                                for (var j = 0; j < selects.length; j++) {
1485                                        selects[j].style.visibility = (sState == "hide") ? 'hidden' : 'visible';
1486                                }
1487                        } catch(e) {}
1488                }
1489        }
1490};
1491Lytebox.prototype.pause = function(iMillis) {
1492        var now = new Date();
1493        var exitTime = now.getTime() + iMillis;
1494        while (true) {
1495                now = new Date();
1496                if (now.getTime() > exitTime) { return; }
1497        }
1498};
1499Lytebox.prototype.combine = function(aAnchors, aAreas) {
1500        var lyteLinks = [];
1501        for (var i = 0; i < aAnchors.length; i++) {
1502                lyteLinks.push(aAnchors[i]);
1503        }
1504        for (var i = 0; i < aAreas.length; i++) {
1505                lyteLinks.push(aAreas[i]);
1506        }
1507        return lyteLinks;
1508};
1509Lytebox.prototype.removeDuplicates = function (aArray) {
1510        var aNew = new Array();
1511        o:for(var i = 0, n = aArray.length; i < n; i++) {
1512                for(var x = 0, y = aNew.length; x < y; x++) {
1513                        if (aNew[x][0].toLowerCase() == aArray[i][0].toLowerCase()) { continue o; }
1514                }
1515                aNew[aNew.length] = aArray[i];
1516        }
1517        return aNew;
1518};
1519Lytebox.prototype.printWindow = function () {
1520        var w = this.isLyteframe ? 800 : this.imgPreloader.width + 20;
1521        var h = this.isLyteframe ? 600 : this.imgPreloader.height + 20;
1522        var left = parseInt((screen.availWidth/2) - (w/2));
1523        var top = parseInt((screen.availHeight/2) - (h/2));
1524        var wOpts = "width=" + w + ",height=" + h + ",left=" + left + ",top=" + top + "screenX=" + left + ",screenY=" + top + "directories=0,location=0,menubar=0,resizable=0,scrollbars=0,status=0,titlebar=0,toolbar=0";
1525        var d = new Date();
1526        var wName = 'Print' + d.getTime();
1527        var wUrl = document.getElementById(this.printId).src;
1528        this.wContent = window.open(wUrl, wName, wOpts);
1529        this.wContent.focus();
1530        var t = setTimeout("$lb.printContent()",1000);
1531};
1532Lytebox.prototype.printContent = function() {
1533        try {
1534                if (this.wContent.document.readyState == 'complete') {
1535                        this.wContent.print();
1536                        this.wContent.close();
1537                        this.wContent = null;
1538                } else {
1539                        var t = setTimeout("$lb.printContent()",1000);
1540                }
1541        } catch(e) { }
1542};
1543Lytebox.prototype.setOptions = function(sOptions) {
1544        this.args = '';
1545        this.group = '';
1546        this.inline = false;
1547        this.hideObjects = this.__hideObjects;
1548        this.autoResize = this.__autoResize;
1549        this.doAnimations = this.__doAnimations;
1550        this.animateOverlay = this.__animateOverlay;
1551        this.forceCloseClick = this.__forceCloseClick;
1552        this.refreshPage = this.__refreshPage;
1553        this.showPrint = this.__showPrint;
1554        this.navType = this.__navType;
1555        this.titleTop = this.__titleTop;
1556        this.navTop = this.__navTop;
1557        this.beforeStart = this.__beforeStart;
1558        this.afterStart = this.__afterStart
1559        this.beforeEnd = this.__beforeEnd;
1560        this.afterEnd = this.__afterEnd;
1561        this.scrolling = this.__scrolling;
1562        this.width = this.__width;
1563        this.height = this.__height;
1564        this.loopPlayback = this.__loopPlayback;
1565        this.autoPlay = this.__autoPlay;
1566        this.autoEmbed = this.__autoEmbed;
1567        this.slideInterval = this.__slideInterval;
1568        this.showNavigation = this.__showNavigation;
1569        this.showClose = this.__showClose;
1570        this.showDetails = this.__showDetails;
1571        this.showPlayPause = this.__showPlayPause;
1572        this.autoEnd = this.__autoEnd;
1573        this.pauseOnNextClick = this.__pauseOnNextClick;
1574        this.pauseOnPrevClick = this.__pauseOnPrevClick;
1575        this.loopSlideshow = this.__loopSlideshow;
1576       
1577        var sName = sValue = '';
1578        var aSetting = null;
1579        var aOptions = sOptions.split(' ');
1580        for (var i = 0; i < aOptions.length; i++) {
1581                aSetting = aOptions[i].split(':');
1582                sName = (aSetting.length > 1 ? this.trim(aSetting[0]).toLowerCase() : '');
1583                sValue = (aSetting.length > 1 ? this.trim(aSetting[1]): '');
1584                switch(sName) {
1585                        case 'group':                   this.group = (sName == 'group' ? (!this.isEmpty(sValue) ? sValue.toLowerCase() : '') : ''); break;
1586                        case 'hideobjects':             this.hideObjects = (/true|false/.test(sValue) ? (sValue == 'true') : this.__hideObjects); break;
1587                        case 'autoresize':              this.autoResize = (/true|false/.test(sValue) ? (sValue == 'true') : this.__autoResize); break;
1588                        case 'doanimations':    this.doAnimations = (/true|false/.test(sValue) ? (sValue == 'true') : this.__doAnimations); break;
1589                        case 'animateoverlay':  this.animateOverlay = (/true|false/.test(sValue) ? (sValue == 'true') : this.__animateOverlay); break;
1590                        case 'forcecloseclick': this.forceCloseClick = (/true|false/.test(sValue) ? (sValue == 'true') : this.__forceCloseClick); break;
1591                        case 'refreshpage':             this.refreshPage = (/true|false/.test(sValue) ? (sValue == 'true') : this.__refreshPage); break;
1592                        case 'showprint':               this.showPrint = (/true|false/.test(sValue) ? (sValue == 'true') : this.__showPrint); break;
1593                        case 'navtype':                 this.navType = (/[1-3]{1}/.test(sValue) ? parseInt(sValue) : this.__navType); break;
1594                        case 'titletop':                this.titleTop = (/true|false/.test(sValue) ? (sValue == 'true') : this.__titleTop); break;
1595                        case 'navtop':                  this.navTop = (/true|false/.test(sValue) ? (sValue == 'true') : this.__navTop); break;
1596                        case 'beforestart':             this.beforeStart = (!this.isEmpty(sValue) ? sValue : this.__beforeStart); break;
1597                        case 'afterstart':              this.afterStart = (!this.isEmpty(sValue) ? sValue : this.__afterStart); break;
1598                        case 'beforeend':               this.beforeEnd = (!this.isEmpty(sValue) ? sValue : this.__beforeEnd); break;
1599                        case 'afterend':                this.afterEnd = (!this.isEmpty(sValue) ? sValue : this.__afterEnd); break;
1600                        case 'args':                    this.args = (!this.isEmpty(sValue) ? sValue : ''); break;
1601                        case 'scrollbars':              this.scrolling = (/auto|yes|no/.test(sValue) ? sValue : this.__scrolling); break;
1602                        case 'scrolling':               this.scrolling = (/auto|yes|no/.test(sValue) ? sValue : this.__scrolling); break;
1603                        case 'width':                   this.width = (/\d(%|px|)/.test(sValue) ? sValue : this.__width); break;
1604                        case 'height':                  this.height = (/\d(%|px|)/.test(sValue) ? sValue : this.__height); break;
1605                        case 'loopplayback':    this.loopPlayback = (/true|false/.test(sValue) ? (sValue == 'true') : this.__loopPlayback); break;
1606                        case 'autoplay':                this.autoPlay = (/true|false/.test(sValue) ? (sValue == 'true') : this.__autoPlay); break;
1607                        case 'autoembed':               this.autoEmbed = (/true|false/.test(sValue) ? (sValue == 'true') : this.__autoEmbed); break;
1608                        case 'inline':                  this.inline = (/true|false/.test(sValue) ? (sValue == 'true') : false);
1609                        case 'slideinterval':   this.slideInterval = (/\d/.test(sValue) ? parseInt(sValue) : this.__slideInterval); break;
1610                        case 'shownavigation':  this.showNavigation = (/true|false/.test(sValue) ? (sValue == 'true') : this.__showNavigation); break;
1611                        case 'showclose':               this.showClose = (/true|false/.test(sValue) ? (sValue == 'true') : this.__showClose); break;
1612                        case 'showdetails':             this.showDetails = (/true|false/.test(sValue) ? (sValue == 'true') : this.__showDetails); break;
1613                        case 'showplaypause':   this.showPlayPause = (/true|false/.test(sValue) ? (sValue == 'true') : this.__showPlayPause); break;
1614                        case 'autoend':                 this.autoEnd = (/true|false/.test(sValue) ? (sValue == 'true') : this.__autoEnd); break;
1615                        case 'pauseonnextclick': this.pauseOnNextClick = (/true|false/.test(sValue) ? (sValue == 'true') : this.__pauseOnNextClick); break;
1616                        case 'pauseonprevclick': this.pauseOnPrevClick = (/true|false/.test(sValue) ? (sValue == 'true') : this.__pauseOnPrevClick); break;
1617                        case 'loopslideshow':   this.loopSlideshow = (/true|false/.test(sValue) ? (sValue == 'true') : this.__loopSlideshow); break;
1618                }
1619        }
1620};
1621        Lytebox.prototype.buildObject = function(w, h, url) {
1622        var object = '';
1623        var classId = '';
1624        var codebase = '';
1625        var pluginsPage = '';
1626        var auto = this.autoPlay ? 'true' : 'false';
1627        var loop = this.loopPlayback ? 'true' : 'false';
1628        var type = url.match(/.mov|.avi|.wmv|.mpg|.mpeg|.swf/i);
1629        switch(type[0]) {
1630        case '.mov':
1631                        codebase = 'http://www.apple.com/qtactivex/qtplugin.cab';
1632                        pluginsPage = 'http://www.apple.com/quicktime/';
1633                        classId = 'clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B';
1634                        object  = '<object classid="' + classId + '" width="' + w + '" height="' + h + '" codebase="' + codebase + '">'
1635                                        + '<param name="src" value="' + url + '">'
1636                                        + '<param name="autoplay" value="' + auto + '">'
1637                                        + '<param name="loop" value="' + loop + '">'
1638                                        + '<param name="controller" value="true">'
1639                                        + '<embed src="' + url + '" width="' + w + '" height="' + h + '" autoplay="' + auto + '" loop="' + loop + '" controller="true" pluginspage="' + pluginsPage + '"></embed>'
1640                                        + '</object>';
1641                        if (this.getQuicktimeVersion() <= 0) {
1642                                object  = '<div style="padding:1em;">'
1643                                                + '<h2>QUICKTIME PLAYER</h2>'
1644                                                + '<p>Content on this page requires a newer version of QuickTime. Please click the image link below to download and install the latest version.</p>'
1645                                                + '<p><a href="http://www.apple.com/quicktime/" target="_blank"><img src="http://images.apple.com/about/webbadges/images/qt7badge_getQTfreeDownload.gif" alt="Get QuickTime" border="0" /></a></p>'
1646                                                + '</div>';
1647                        }
1648                        break;
1649                case '.avi':
1650                case '.mpg':
1651                case '.mpeg':
1652                case '.wmv':
1653                        classId = 'clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B';                 
1654                        object  = '<object classid="' + classId + '" width="' + w + '" height="' + h + '" codebase="' + codebase + '">'
1655                                        + '<param name="src" value="' + url + '">'
1656                                        + '<param name="autoplay" value="' + auto + '">'
1657                                        + '<param name="loop" value="' + loop + '">'
1658                                        + '<param name="controller" value="true">'
1659                                        + '<object type="video/quicktime" data="' + url + '" width="' + w + '" height="' + h + '">'
1660                                        + '<param name="controller" value="false">'
1661                                        + '<param name="autoplay" value="' + auto + '">'
1662                                        + '<param name="loop" value="' + loop + '">'
1663                                        + '</object>' 
1664                                        + '</object>';
1665                        break;
1666                case '.swf':
1667                        classId = 'clsid:D27CDB6E-AE6D-11cf-96B8-444553540000';
1668                        object  = '<object classid="' + classId + '" width="' + w + '" height="' + h + '" codebase="' + codebase + '">'
1669                                        + '<param name="movie" value="' + url + '">'
1670                                        + '<param name="quality" value="high">'
1671                                        + '<param name="wmode" value="opaque">'
1672                                        + '<!--[if !IE]>-->'
1673                                        + '<object type="application/x-shockwave-flash" data="' + url + '" width="' + w + '" height="' + h + '">'
1674                                        + '<!--<![endif]-->'
1675                                        + '<param name="quality" value="high">'
1676                                        + '<param name="wmode" value="opaque">'
1677                                        + '<div style="padding:1em;">'
1678                                        + '<h2>FLASH PLAYER</h2>'
1679                                        + '<p>Content on this page requires a newer version of Adobe Flash Player. Please click the image link below to download and install the latest version.</p>'
1680                                        + '<p><a href="http://www.adobe.com/go/getflashplayer" target="_blank"><img src="http://www.adobe.com/macromedia/style_guide/images/160x41_Get_Flash_Player.jpg" alt="Get Adobe Flash player" border="0" /></a></p>'
1681                                        + '</div>'
1682                                        + '<!--[if !IE]>-->'
1683                                        + '</object>'
1684                                        + '<!--<![endif]-->'
1685                                        + '</object>';
1686                        break;
1687        }
1688        return object;
1689};
1690Lytebox.prototype.getQuicktimeVersion = function() {
1691        var agent = navigator.userAgent.toLowerCase(); 
1692        var version = -1;
1693        if (navigator.plugins != null && navigator.plugins.length > 0) {
1694                for (i=0; i < navigator.plugins.length; i++ ) {
1695                        var plugin = navigator.plugins[i];
1696                        if (plugin.name.indexOf('QuickTime') > -1) {
1697                                version = parseFloat(plugin.name.substring(18));
1698                        }
1699                }
1700        } else if (this.autoEmbed && agent.indexOf('msie') != -1 && parseInt(navigator.appVersion) >= 4 && agent.indexOf('win') != -1 && agent.indexOf('16bit') == -1) {
1701                var control = null;
1702                try {
1703                        control = new ActiveXObject('QuickTime.QuickTime');
1704                } catch (e) { }
1705                if (control) {
1706                        isInstalled = true;
1707                }                       
1708                try {
1709                        control = new ActiveXObject('QuickTimeCheckObject.QuickTimeCheck');
1710                } catch (e) { return; }
1711                if (control) {
1712                        isInstalled = true;
1713                        version = control.QuickTimeVersion.toString(16);
1714                        version = version.substring(0, 1) + '.' + version.substring(1, 3);
1715                        version = parseInt(version);
1716                }
1717        }
1718        return version;
1719};
1720Lytebox.prototype.findPos = function(el) {
1721        if (this.ie && this.doc.compatMode == 'BackCompat') {
1722                return [0, 16, 12];
1723        }
1724        var left = 0;
1725        var top = 0;
1726        var height = 0;
1727        height = el.offsetHeight + 6;
1728        if (el.offsetParent) {
1729                do {
1730                        left += el.offsetLeft;
1731                        top += el.offsetTop;
1732                } while (el = el.offsetParent);
1733        }
1734        return [left, top, height];
1735};
1736Lytebox.prototype.isMobile = function() {
1737        var ua = navigator.userAgent;
1738        return (ua.match(/ipad/i) != null)
1739                || (ua.match(/ipod/i) != null)
1740                || (ua.match(/iphone/i) != null)
1741                || (ua.match(/android/i) != null)
1742                || (ua.match(/opera mini/i) != null)
1743                || (ua.match(/blackberry/i) != null)
1744                || (ua.match(/(pre\/|palm os|palm|hiptop|avantgo|plucker|xiino|blazer|elaine)/i) != null)
1745                || (ua.match(/(iris|3g_t|windows ce|opera mobi|windows ce; smartphone;|windows ce; iemobile)/i) != null)
1746                || (ua.match(/(mini 9.5|vx1000|lge |m800|e860|u940|ux840|compal|wireless| mobi|ahong|lg380|lgku|lgu900|lg210|lg47|lg920|lg840|lg370|sam-r|mg50|s55|g83|t66|vx400|mk99|d615|d763|el370|sl900|mp500|samu3|samu4|vx10|xda_|samu5|samu6|samu7|samu9|a615|b832|m881|s920|n210|s700|c-810|_h797|mob-x|sk16d|848b|mowser|s580|r800|471x|v120|rim8|c500foma:|160x|x160|480x|x640|t503|w839|i250|sprint|w398samr810|m5252|c7100|mt126|x225|s5330|s820|htil-g1|fly v71|s302|-x113|novarra|k610i|-three|8325rc|8352rc|sanyo|vx54|c888|nx250|n120|mtk |c5588|s710|t880|c5005|i;458x|p404i|s210|c5100|teleca|s940|c500|s590|foma|samsu|vx8|vx9|a1000|_mms|myx|a700|gu1100|bc831|e300|ems100|me701|me702m-three|sd588|s800|8325rc|ac831|mw200|brew |d88|htc\/|htc_touch|355x|m50|km100|d736|p-9521|telco|sl74|ktouch|m4u\/|me702|8325rc|kddi|phone|lg |sonyericsson|samsung|240x|x320|vx10|nokia|sony cmd|motorola|up.browser|up.link|mmp|symbian|smartphone|midp|wap|vodafone|o2|pocket|kindle|mobile|psp|treo)/i) != null);
1747};
1748Lytebox.prototype.validate = function(args) {
1749        var reTest = sName = '';
1750        var bValid = false;
1751        var oElement = this.isEmpty(args.id) ? (this.isEmpty(args.element) ? null : args.element) : document.getElementById(args.id);
1752        var sInput = this.isEmpty(args.value) ? '' : String(args.value);
1753        var sType = this.isEmpty(args.type) ? '' : String(args.type).toLowerCase();
1754        var sRegex = this.isEmpty(args.regex) ? '' : args.regex;
1755        var sCCType = (/visa|mc|amex|diners|discover|jcb/.test(args.ccType) ? args.ccType : '');
1756        var sImageType = this.isEmpty(args.imageType) ? '' : String(args.imageType.toLowerCase());
1757        var iMin = (/^\d+$/.test(args.min) ? parseInt(args.min) : 0);
1758        var iMax = (/^\d+$/.test(args.max) ? parseInt(args.max) : 0);
1759        var bInclusive = args.inclusive ? true : (/true|false/.test(args.inclusive) ? (args.inclusive == 'true') : true);
1760        var bAllowComma = args.allowComma ? true : (/true|false/.test(args.allowComma) ? (args.allowComma == 'true') : true);
1761        var bAllowWhitespace = args.allowWhiteSpace ? true : (/true|false/.test(args.allowWhiteSpace) ? (args.allowWhiteSpace == 'true') : true);
1762        if ((this.isEmpty(sInput) && this.isEmpty(oElement)) || (this.isEmpty(sType) && this.isEmpty(sRegex))) {
1763                return false;
1764        }
1765        var sInput = this.isEmpty(sInput) ? oElement.value : sInput;
1766        if (!this.isEmpty(sRegex)) {
1767                bValid = sRegex.test(sInput);
1768        } else {
1769                switch(sType) {
1770                        case 'alnum':
1771                                bValid = (bAllowWhitespace ? /^[a-z0-9\s]+$/i.test(sInput) : /^[a-z0-9]+$/i.test(sInput)); break;
1772                        case 'alpha':
1773                                bValid = (bAllowWhitespace ? /^[a-z\s]+$/i.test(sInput) : /^[a-z]+$/i.test(sInput)); break;
1774                        case 'between':
1775                                var iInput = bAllowComma ? parseInt(sInput.replace(/\,/g,'')) : parseInt(sInput);
1776                                bValid = (bInclusive ? (iInput >= iMin && iInput <= iMax) : (iInput > iMin && iInput < iMax)); break;
1777                        case 'ccnum':
1778                                if (this.isEmpty(sCCType)) {
1779                                        bValid = /^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|6(?:011|5[0-9][0-9])[0-9]{12}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|(?:2131|1800|35\d{3})\d{11})$/.test(sInput); break;
1780                                } else {
1781                                        switch(sCCType) {
1782                                                case 'visa':
1783                                                        bValid = /^4[0-9]{12}(?:[0-9]{3})?$/.test(sInput); break;
1784                                                case 'mc':
1785                                                        bValid = /^5[1-5][0-9]{14}$/.test(sInput); break;
1786                                                case 'amex':
1787                                                        bValid = /^3[47][0-9]{13}$/.test(sInput); break;
1788                                                case 'diners':
1789                                                        bValid = /^3(?:0[0-5]|[68][0-9])[0-9]{11}$/.test(sInput); break;
1790                                                case 'discover':
1791                                                        bValid = /^6(?:011|5[0-9]{2})[0-9]{12}$/.test(sInput); break;
1792                                                case 'jcb':
1793                                                        bValid = /^(?:2131|1800|35\d{3})\d{11}$/.test(sInput); break;
1794                                                default:
1795                                                        bValid = false;
1796                                        }
1797                                }
1798                        case 'date':
1799                                var date = new Date(sInput);
1800                                bValid = !(date.toString() == 'NaN' || date.toString() == 'Invalid Date'); break;
1801                        case 'digits':
1802                                bValid = /^\d+$/.test(sInput); break;
1803                        case 'email':
1804                                bValid = /^([a-z0-9_\.\-])+\@(([a-z0-9\-])+\.)+([a-z0-9]{2,4})+$/i.test(sInput); break;
1805                        case 'float':
1806                                bValid = /^[-+]?[0-9]*\.?[0-9]+$/.test(bAllowComma ? sInput.replace(/\,/g,'') : sInput); break;
1807                        case 'image':
1808                                if (this.isEmpty(sImageType)) {
1809                                        bValid = /^(png|jpg|jpeg|gif)$/i.test(sInput.split('.').pop()); break;
1810                                } else {
1811                                        bValid = (sInput.split('.').pop().toLowerCase().match(sImageType) ? true : false); break;
1812                                }
1813                        case 'int':
1814                        case 'integer':
1815                                bValid = /^[-+]?\d+$/.test(sInput.replace(/\,/g,'')); break;
1816                        case 'len':
1817                        case 'length':
1818                                bValid = (iMin == iMax) ? (sInput.length == iMin) : (sInput.length >= iMin && sInput.length <= iMax); break;
1819                        case 'phone':
1820                                bValid = /^\(?(\d{3})\)?[- ]?(\d{3})[- ]?(\d{4})$/.test(sInput); break;
1821                        case 'notempty':
1822                                bValid = !this.isEmpty(sInput); break;
1823                        case 'ssn':
1824                                bValid = /^[0-9]{3}\-?[0-9]{2}\-?[0-9]{4}$/.test(sInput); break;
1825                        case 'url':
1826                                bValid = /\b((?:[a-z][\w-]+:(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»""'']))/i.test(sInput); break;
1827                        case 'zip':
1828                                bValid = /^\d{5}$|^\d{5}-\d{4}$/.test(sInput); break;
1829                }
1830        }
1831        return bValid;
1832};
1833Lytebox.prototype.ajax = function(args) {
1834        var iIndex = this.http.length;
1835        var oRequest = this.getRequestObject();
1836        this.http[iIndex] = oRequest;
1837        var oHttpArgs = args;
1838        oHttpArgs.index = iIndex;
1839        oHttpArgs.method = !(/get|post/i.test(oHttpArgs.method)) ? 'get' : oHttpArgs.method;
1840        oHttpArgs.cache = !(/true|false/.test(oHttpArgs.cache)) ? true : (oHttpArgs.cache == 'true' || oHttpArgs.cache);
1841        if (!this.isEmpty(oHttpArgs.timeout) && (/^\d+$/.test(oHttpArgs.timeout))) {
1842                oHttpArgs.timerId = setTimeout("$lb.http["+iIndex+"].abort()", oHttpArgs.timeout);
1843        }
1844        oRequest.onreadystatechange = function() {
1845                return function() {
1846                        if (oRequest.readyState == 4 && oRequest.status == 200) {
1847                                if (document.getElementById(oHttpArgs.updateId)) {
1848                                        try {
1849                                                document.getElementById(oHttpArgs.updateId).innerHTML = oRequest.responseText;
1850                                        } catch(e) { alert(e.description ); };
1851                                }
1852                                if (typeof oHttpArgs.success === 'function') {
1853                                        oHttpArgs.success(oRequest);
1854                                }
1855                                window.clearTimeout(oHttpArgs.timerId);
1856                                $lb.http[oHttpArgs.index] = null;
1857                        } else if (oRequest.readyState == 4 && oRequest.status != 200) {
1858                                if (typeof oHttpArgs.fail === 'function') {
1859                                        oHttpArgs.fail(oRequest);
1860                                }
1861                                window.clearTimeout(oHttpArgs.timerId);
1862                                $lb.http[oHttpArgs.index] = null;
1863                        }
1864                } (oRequest, oHttpArgs);
1865        }
1866        if (oHttpArgs.method.toLowerCase() == 'post') {
1867                var oForm = document.getElementById(oHttpArgs.form);
1868                var bStripTags = !(/true|false/.test(args.stripTags)) ? false : (args.stripTags == 'true' || args.stripTags);
1869                var sParams = (oForm == null ? this.serialize({ name: oHttpArgs.form, stripTags: bStripTags }) : this.serialize({ element: oForm, stripTags: bStripTags }));
1870                var sTimestamp = (!oHttpArgs.cache ? ((/\&/.test(sParams)) ? '&' : '') + new Date().getTime() : '');
1871                oRequest.open('post', oHttpArgs.url, true);
1872                oRequest.setRequestHeader('Content-type','application/x-www-form-urlencoded');
1873                oRequest.send(sParams + sTimestamp);
1874        } else {
1875                var sTimestamp = (!oHttpArgs.cache ? ((/\?/.test(oHttpArgs.url)) ? '&' : '?') + new Date().getTime() : '');
1876                oRequest.open('get', oHttpArgs.url  + sTimestamp, true);
1877                oRequest.send();
1878        }
1879};
1880Lytebox.prototype.serialize = function(args) {
1881        var sParams = sValue = '';
1882        var bStripTags = !(/true|false/.test(args.stripTags)) ? false : (args.stripTags == 'true' || args.stripTags);
1883        var oElements = this.isEmpty(args.id) ? (this.isEmpty(args.element) ? null : args.element) : document.getElementById(args.id);
1884        if (oElements == null) {
1885                for (var i = 0; i < document.forms.length; i++) {
1886                        if (document.forms[i].name == args.name) {
1887                                oElements = document.forms[i].elements;
1888                        }
1889                }
1890        }
1891        for (var i = 0; i < oElements.length; i++) {
1892                if ((oElements[i].type == 'checkbox' && !oElements[i].checked) ||
1893                        (oElements[i].type == 'radio' && !oElements[i].checked) ||
1894                        (oElements[i].disabled) || (oElements[i].name == '') || (oElements[i].type == 'reset')) {
1895                        continue;
1896                }
1897                if (oElements[i].type == 'select-multiple') {
1898                        for (var j = 0; j < oElements[i].options.length; j++) {
1899                                if (oElements[i].options[j].selected == true) {
1900                                        sParams += (sParams == '' ? '' : '&') + oElements[i].name + '=' + encodeURIComponent(oElements[i].options[j].value);
1901                                }
1902                        }
1903                } else {
1904                        sValue = bStripTags ? this.stripTags({ value: oElements[i].value }) : oElements[i].value;
1905                        sParams += (sParams == '' ? '' : '&') + oElements[i].name + '=' + encodeURIComponent(sValue);
1906                }
1907        }
1908        return sParams;
1909};
1910Lytebox.prototype.getRequestObject = function () {
1911        var oReq = null;
1912        if (window.XMLHttpRequest) {
1913                try { oReq = new XMLHttpRequest(); } catch (e) { }
1914        } else if (typeof ActiveXObject != 'undefined') {
1915                try {
1916                        oReq = new ActiveXObject("Msxml2.XMLHTTP");
1917                } catch (e) {
1918                        try { oReq = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { }
1919                }
1920        }
1921        return oReq;
1922};
1923Lytebox.prototype.isEmpty = function(args) {
1924        var sValue = '';
1925        try {
1926                sValue = this.isEmpty(args.value) ? args : args.value;
1927        } catch(e) {
1928                sValue = args;
1929        }
1930        return (this.trim(sValue) == '' || sValue == 'null' || sValue == null || typeof(sValue) == 'undefined');
1931};
1932Lytebox.prototype.stripTags = function(args) {
1933        var oElement = this.isEmpty(args.id) ? (this.isEmpty(args.element) ? null : args.element) : document.getElementById(args.id);
1934        if (!this.isEmpty(oElement)) {
1935                oElement.value = String(oElement.value).replace(/(<([^>]+)>)/ig, '');
1936        } else {
1937                var sValue = '';
1938                try {
1939                        sValue = this.isEmpty(args.value) ? args : args.value;
1940                } catch(e) {
1941                        sValue = args;
1942                }
1943                return (this.trim(sValue) == '[object Object]') ? '' : String(sValue).replace(/(<([^>]+)>)/ig, '');
1944        }
1945};
1946Lytebox.prototype.trim = function(args) {
1947        var sValue = '';
1948        try {
1949                sValue = this.isEmpty(args.value) ? args : args.value;
1950        } catch(e) {
1951                sValue = args;
1952        }
1953        return String(sValue).replace(/^\s+|\s+$/g, '');
1954};
1955Lytebox.prototype.capitalize = function (args) {
1956        return String(args.value ? args.value : args).replace( /(^|\s)([a-z])/g , function(m,p1,p2){return p1+p2.toUpperCase();});
1957};
1958Lytebox.prototype.hasClass = function (args) {
1959        var sClass = this.isEmpty(args.name) ? '' : args.name;
1960        var oElement = this.isEmpty(args.id) ? (this.isEmpty(args.element) ? null : args.element) : document.getElementById(args.id);
1961        return new RegExp('(\\s|^)' + sClass + '(\\s|$)').test(oElement.className);
1962};
1963Lytebox.prototype.addClass = function (args) {
1964        var sClass = this.isEmpty(args.name) ? '' : args.name;
1965        var oElement = this.isEmpty(args.id) ? (this.isEmpty(args.element) ? null : args.element) : document.getElementById(args.id);
1966        var aClasses = sClass.split(' ');
1967        for (var i = 0; i < aClasses.length; i++) {
1968                if (!this.hasClass({ element: oElement, name: aClasses[i] })) {
1969                        oElement.className += ' ' + aClasses[i];
1970                }
1971        }
1972};
1973Lytebox.prototype.removeClass = function (args) {
1974        var sClass = this.isEmpty(args.name) ? '' : args.name;
1975        var oElement = this.isEmpty(args.id) ? (this.isEmpty(args.element) ? null : args.element) : document.getElementById(args.id);
1976        var aClasses = sClass.split(' ');
1977        for (var i = 0; i < aClasses.length; i++) {
1978                if (this.hasClass({ element: oElement, name: aClasses[i] })) {
1979                        oElement.className = oElement.className.replace(new RegExp('(\\s|^)' + aClasses[i] + '(\\s|$)'), ' ').replace(/\s+/g, ' ').replace(/^\s|\s$/, '');
1980                }
1981        }
1982};
1983if (window.addEventListener) {
1984        window.addEventListener("load", initLytebox, false);
1985} else if (window.attachEvent) {
1986        window.attachEvent("onload", initLytebox);
1987} else {
1988        window.onload = function() {initLytebox();}
1989}
1990function initLytebox() { myLytebox = $lb = new Lytebox(true, $lb.http); }
1991myLytebox = $lb = new Lytebox(false);
Note: See TracBrowser for help on using the repository browser.