PageSourceSearch

https://tshirtplus.com.au/ssc/bundlev3/c-1/1390becb2a663355d6e4729fb5b66c82/j~application~lightwindow.js

js tshirtplus.com.au collected 2026-10-03 21:23:08 UTC 93,579 bytes, 2,909 lines download raw bytes

1// Place your application-specific JavaScript functions and classes here
2function log(msg, trace) {
3  try {
4    console.debug(msg);
5    if(trace) {
6      console.trace();
7    }
8  } catch(e) {}
9}
10
11var useAlphaHack = false;
12if((BrowserDetect.browser == "Explorer")&&(BrowserDetect.version < 7.0)&&(BrowserDetect.version >= 5.5)) {
13  useAlphaHack = true;
14}
15
16function f_clientWidth() {
17  return f_filterResults (
18    window.innerWidth ? window.innerWidth : 0,
19    document.documentElement ? document.documentElement.clientWidth : 0,
20    document.body ? document.body.clientWidth : 0
21  );
22}
23function f_clientHeight() {
24  return f_filterResults (
25    window.innerHeight ? window.innerHeight : 0,
26    document.documentElement ? document.documentElement.clientHeight : 0,
27    document.body ? document.body.clientHeight : 0
28  );
29}
30function f_scrollLeft() {
31  return f_filterResults (
32    window.pageXOffset ? window.pageXOffset : 0,
33    document.documentElement ? document.documentElement.scrollLeft : 0,
34    document.body ? document.body.scrollLeft : 0
35  );
36}
37function f_scrollTop() {
38  return f_filterResults (
39    window.pageYOffset ? window.pageYOffset : 0,
40    document.documentElement ? document.documentElement.scrollTop : 0,
41    document.body ? document.body.scrollTop : 0
42  );
43}
44function f_filterResults(n_win, n_docel, n_body) {
45  var n_result = n_win ? n_win : 0;
46  if (n_docel && (!n_result || (n_result > n_docel)))
47    n_result = n_docel;
48  return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
49}
50
51function windowSize() {
52  var myWidth = 0, myHeight = 0;
53  if( typeof( window.innerWidth ) == 'number' ) {
54    //Non-IE
55    myWidth = window.innerWidth;
56    myHeight = window.innerHeight;
57  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
58    //IE 6+ in 'standards compliant mode'
59    myWidth = document.documentElement.clientWidth;
60    myHeight = document.documentElement.clientHeight;
61  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
62    //IE 4 compatible
63    myWidth = document.body.clientWidth;
64    myHeight = document.body.clientHeight;
65  }
66  return {w: myWidth + f_scrollLeft(), h:myHeight + f_scrollTop()};
67}
68
69var hiddenSelects = [];
70
71var currentPopupId = null;
72var popupStack = [];
73var currentPopupCallback = null;
74
75var iframeMode = false;
76  
77//dnPopup function may already have been defined on v3/common/utils.js
78window.dnPopup = (typeof dnPopup == 'function') ? dnPopup : function(divId, mode, callback) {
79  log("dnPopup(" + divId + ")");
80  var div = $(divId);
81  if(div==null) {
82    alert("unable to get element:" + divId);
83    return;
84  }
85  
86  var bgdiv = $('popupbackground');
87  if(bgdiv==null) {
88    alert("unable to get element:popupbackground");
89    return;
90  }
91  
92  var height = f_clientHeight();
93  var width = f_clientWidth();
94  
95  if(width < document.body.clientWidth) {
96    width = document.body.clientWidth;
97  }
98  
99  /*if (document.body.scrollHeight>document.body.offsetHeight){ 
100    bgdiv.style.height=document.body.scrollHeight+"px"; 
101  }else{
102    bgdiv.style.height=document.body.offsetHeight+"px";
103  }*/
104  
105  bgdiv.show();
106  
107  div.style.zIndex = 3001;
108  
109  if(mode==1) {
110    
111  } else {
112    div.style.position="absolute";
113    div.style.display="block";
114    div.style.visibility="hidden";
115    log("scrolltop =" +  f_scrollTop() + ", f_clientHeight()=" + f_clientHeight());
116    if( ((((f_clientHeight() / 2) - (div.clientHeight/2))) + f_scrollTop()) <10 ) {
117      div.style.top = "10px";
118    } else {
119      div.style.top = parseInt(((f_clientHeight() / 2) - (div.clientHeight/2)),10) + f_scrollTop() + "px";
120      log("div.style.top=" + div.style.top);
121    }
122    
123    div.style.left = parseInt(((f_clientWidth()  / 2) - (div.clientWidth/2)),10) + f_scrollLeft() + "px";
124    div.style.visibility="visible";
125  }
126  
127  if (iframeMode) {
128    div.className = 'ipopup';
129    div.style.top = '0';
130    div.style.left = '0';
131    window.scrollTo(0,0);
132    parent.orderManager.notifyPopupSizeChange(div.clientWidth, div.clientHeight);
133  }
134  
135  if(currentPopupId != null) {
136    restoreHiddenSelects();
137    if(currentPopupCallback != null) {
138      currentPopupCallback("hide");  
139    }
140    popupStack.push([currentPopupId, currentPopupCallback]);
141    $(currentPopupId).style.display="none";
142  }
143  
144  currentPopupId = divId;
145  currentPopupCallback = callback;
146  storeBackgroundSelects(div);
147  
148  return {t: div.style.top, l: div.style.left};
149};
150
151if(window.popup == null) {
152  window.popup = window.dnPopup;
153}
154
155function storeBackgroundSelects(div) {
156  var sels = document.getElementsByTagName("SELECT");
157  for(var i=0;i < sels.length;i++) {
158    if(!$(sels[i]).descendantOf(div)) {
159      hiddenSelects.push(sels[i]);
160      sels[i].style.visibility="hidden";
161    }
162  }
163}
164
165function restoreHiddenSelects() {
166  while(hiddenSelects.size() > 0) {
167    var el = hiddenSelects.pop();
168    el.style.visibility = "visible";
169  }
170}
171
172function swapPopup(oldDivId, newDivId, reposition) {
173  var oldDiv = $(oldDivId);
174  var newDiv = $(newDivId);
175  
176  newDiv.style.zIndex = oldDiv.style.zIndex;
177  
178  if (iframeMode) {
179    newDiv.className = 'ipopup';
180  }
181  
182  if(reposition == true) {
183    newDiv.style.visibility="hidden";
184    newDiv.style.display="";
185    repositionPopup(newDivId);
186  } else {
187    newDiv.style.top = oldDiv.style.top;
188    newDiv.style.left = oldDiv.style.left;
189    newDiv.style.width = oldDiv.style.width;
190    newDiv.style.height = oldDiv.style.height;
191  }
192  newDiv.style.display="";
193  newDiv.style.visibility="visible";
194  oldDiv.style.display="none";
195  
196  restoreHiddenSelects();
197  storeBackgroundSelects(newDiv);
198  
199  currentPopupId = newDivId;
200  if(currentPopupCallback != null) {
201    currentPopupCallback("swap");
202  }
203}
204
205//closePopup function may already have been defined on v3/common/utils.js
206window.closePopup = (typeof closePopup == 'function') ? closePopup : function(divId, mode, ignoreIframe) {
207  if(divId == null) {
208    divId = currentPopupId;
209  }
210  log("closePopup(" + divId + ")");
211  var div = $(divId);
212  if(div==null) {
213    alert("unable to get popup element");
214    return;
215  }
216  //check if its a dnm-popup...
217  if(div.className == 'dnm-popup-container') {
218    return dnmClosePopup(divId);
219  }
220  
221  var bgdiv = $('popupbackground');
222  if(bgdiv==null) {
223    alert("unable to get background element");
224    return;
225  }
226  
227  if(mode != 1) {
228    log(div);
229    div.style.visibility="hidden";
230    div.style.display="none";
231    log(div);
232  }
233  
234  if (iframeMode && !ignoreIframe) {
235    parent.orderManager.notifyPopupClose();
236  }
237  
238  restoreHiddenSelects();
239  
240  if(popupStack.length > 0) {
241    var psData = popupStack.pop();
242    currentPopupId = psData[0];
243    currentPopupCallback = psData[1];
244    div = $(currentPopupId)
245    div.style.display="";
246    storeBackgroundSelects(div) ;
247    if(currentPopupCallback != null) {
248      currentPopupCallback("restore");
249    }
250    if (iframeMode) {
251      parent.orderManager.notifyPopupSizeChange(div.clientWidth, div.clientHeight);
252    }
253  } else {
254    log(bgdiv);
255    //bgdiv.className="popupclose";
256    bgdiv.hide();
257    log(bgdiv);
258    currentPopupId = null;
259    currentPopupCallback = null;
260  }
261  
262};
263
264function repositionPopup(divId) {
265  var div = $(divId);
266  if(div==null) {
267    alert("unable to get popup element");
268    return;
269  }
270  
271  if (iframeMode) {
272    div.style.top = '0';
273    div.style.left = '0';
274    parent.orderManager.notifyPopupSizeChange(div.clientWidth, div.clientHeight);
275  } else {
276    if( ((((f_clientHeight() / 2) - (div.clientHeight/2))) + f_scrollTop()) <10 ) {
277      div.style.top = "10px";
278    } else {
279      div.style.top = (((f_clientHeight() / 2) - (div.clientHeight/2))) + f_scrollTop() + "px";
280    }
281    
282    div.style.left = (((f_clientWidth()  / 2) - (div.clientWidth/2))) + f_scrollLeft() + "px";
283  }
284  
285  if(currentPopupCallback != null) {
286    currentPopupCallback("reposition");
287  }
288}
289
290
291function dynamicPopup(url) {
292  var div = $('dynpopup_content');
293  if(div == null) {
294    alert("Unable to get dynamic popup");
295  }
296  div.update("Loading....");
297  dnPopup('dynpopup');
298  var aKey = null;
299  var t2 = new Ajax.Updater({success:"dynpopup_content"}, url, {asynchronous:true, evalScripts:true,
300    onComplete: function D_onComplete() { 
301      asyncFinish(aKey);
302      repositionPopup("dynpopup");
303    },
304    onFailure: function D_onFailure() {
305      closePopup("dynpopup");
306      alert("An error occured processing request");
307    }
308  });
309  aKey = asyncStart($("dynpopup"));
310}
311
312function dynamicPopupContent(title, message) {
313  var html = '<div class="popup_box">\n<div class="popup_int">';
314  if(title != null) {
315    html += '<h3>' + title + '</h3>';
316  }
317  if(message != null) {
318    html += '<div class="popup_content">' + message + '</div>';
319  }
320  html += '</div></div>';
321  return html;
322}
323
324
325var msgBoxCallback = null;
326var msgboxId = null;
327
328function msgBox(title, message, icon, yes, no, cancel, callback) {
329  msgBoxCallback = callback;
330  msgboxId = getNextId();
331  var html="";
332  if(icon != null) { html += '<img src="' + icon + '" align="left"/>'; }
333  html+="";
334  html+='<h3>' + title + '</h3>';
335  html+='<div class="popup-content-deep msgbox-content">';
336  html += '<div class="msgbox-text">' + message + '</div></div><div class="submit msgbox_buttons">';
337  
338  
339  if(cancel != null) {
340    html += '<input type="button" value="' + cancel + '" onclick="msgBoxFinish(2);" class="btn btn-cancel btn-large"/>';
341  }
342  if(no != null) {
343    html += '<b class="action"><input type="button" value="' + no + '" onclick="msgBoxFinish(1);" class="btn btn-large" /></b>';
344  }
345  if(yes != null) {
346    html += '<input type="button" value="' + yes + '" onclick="msgBoxFinish(0);" class="btn btn-primary btn-large" id="d_msgbox_def_' + msgboxId + '"/>';
347  }
348  html += "</div>";
349  html += "</div>";
350  var div = document.createElement("DIV");
351  div.className = "popup msgbox";
352  div.style.display="none";
353  div.id = "msgbox_" + msgboxId;
354  div.innerHTML = html;
355  
356  document.body.appendChild(div);
357  dnPopup("msgbox_" + msgboxId);
358  try {
359    $('d_msgbox_def_' + msgboxId).focus();
360  } catch(e) {}
361}
362
363function msgBoxFinish(result) {
364  closePopup("msgbox_" + msgboxId);
365  var div = document.getElementById("msgbox_" + msgboxId);
366  document.body.removeChild(div);
367  if(msgBoxCallback != null) {
368    msgBoxCallback(result);
369  }
370}
371
372
373var promptCallback = null;
374var promptId = null;
375
376function promptNew(title, message, icon, ok, cancel, defaultValue, callback) {
377  promptCallback = callback;
378  promptId = getNextId();
379  var html="";
380  if(icon != null) {
381    html += '<img src="' + icon + '" align="left"/>'; 
382  }
383  
384  html += '<h3>' + title + '</h3>';
385  html+='<div class="popup-content-deep msgbox-content">';
386  html += '<span class="msgbox_text"><label>' + message + '</label><input id="propt_val_' + promptId + '" value="' + defaultValue + '"/></span></div><div class="submit msgbox_buttons">';
387  if(cancel != null) {
388    html += '<input type="button" value="' + cancel + '" onclick="promptFinish(1);" class="btn btn-cancel"/> ';
389  }
390  if(ok != null) {
391    html += '<input type="button" value="' + ok + '" onclick="promptFinish(0);" class="btn btn-primary" />';
392  }
393  
394  html += "</div>";
395  html += "</div>";
396  var div = document.createElement("DIV");
397  div.className = "popup xxxmsgbox";
398  div.style.display="none";
399  div.id = "prompt_" + promptId;
400  div.innerHTML = html;
401  
402  document.body.appendChild(div);
403  dnPopup("prompt_" + promptId);
404  $('propt_val_' + promptId).focus();
405  var el = document.getElementById("propt_val_" + promptId);
406  el.focus();
407}
408
409function promptFinish(result) {
410  var val = null;
411  closePopup("prompt_" + promptId);
412  if(result == 0) {
413    var el = document.getElementById("propt_val_" + promptId);
414    if (el) {
415      val = el.value;
416    }  
417  }
418  var div = document.getElementById("prompt_" + promptId);
419  if (div) {
420    document.body.removeChild(div);
421  }  
422  if (val != null) {
423    promptCallback(result, val);
424  }  
425}
426
427function showProgressPopup(title, message) {
428  var popupId = "progress_popup_" + getNextId();
429  var html ="";
430  if(title != null) {
431    html += '<h3>' + title + '</h3>';
432  }
433  html += '<div>';
434  html +=   '<div class="progress-popup-text">' + message + '</div>';
435  html += "</div>";
436  var div = document.createElement("DIV");
437  div.className = "popup progress-popup";
438  div.style.display="none";
439  div.id = popupId;
440  div.innerHTML = html;
441  
442  document.body.appendChild(div);
443  dnPopup(popupId);
444  
445  return popupId;
446}
447
448var nextId = 0;
449function getNextId() {
450  nextId --;
451  return nextId;
452}
453
454function getElId(el) {
455  if(el.id != null && el.id != "") {
456    return el.id;
457  }
458  el.id = "tmp_id_" + getNextId();
459  return el.id;
460}
461
462var asyncActions = new Hash();
463
464function asyncStart(container) {
465  var containerEl = $(container);
466  var containerId = getElId(containerEl);
467  
468  log("asyncStart:" + containerId);
469  
470  //there can only be one async action per container...
471  if(asyncActions[containerId] != null) {
472    log("Stopping existing async action " + containerId);
473    asyncFinish({id:containerId, v: asyncActions[containerId].v});
474  }
475  
476  var divB = document.createElement("DIV");
477  divB.style.display = "none";
478  divB.className = "async_action_background";
479  
480  var div = document.createElement("DIV");
481  div.style.display = "none";
482  div.className = "async_action";
483  
484  div.innerHTML="<img src='/images/loading-oval.svg' alt='[]' />";
485  var oldPositioning = null;
486  
487
488  var dims = Element.getDimensions(container);
489  var offset = Position.cumulativeOffset(containerEl);
490  
491  log(offset);
492
493  
494  
495  divB.style.position = "absolute";
496  divB.style.top = offset[1] + "px";
497  divB.style.left = offset[0] + "px";
498  divB.style.height = dims.height + "px";
499  divB.style.width = dims.width + "px";
500  //divB.style.display="none";
501  divB.style.opacity = 0.50;
502  divB.style.backgroundColor="#FFFFFF";
503
504  divB.style.zIndex = 9999;
505  document.body.appendChild(divB);
506  divB.id = "aa_" + containerId + "_bg";
507  
508  div.style.position = "absolute";
509  div.style.top = offset[1] + "px";
510  div.style.left = offset[0] + "px";
511  div.style.height = dims.height + "px";
512  div.style.width = dims.width + "px";
513  div.backgroundColor="#000000";
514  //div.style.display="none";
515  div.style.zIndex = 10000;
516  document.body.appendChild(div);
517  //Effect.Appear(div, { duration: 0.2 });
518  
519  div.id = "aa_" + containerId;
520  
521  //only show if offsets are valid
522  if (offset[0] !== 0 && offset[1] !== 0) {
523    $(divB).show();
524    $(div).show();
525  }
526  var v = getNextId();
527  asyncActions[containerId] = {d:div, db:divB, c:container, p:oldPositioning, v:v};
528  return {id: containerId, v:v};
529}
530
531function asyncFinish(key) {
532  if(key == null) {
533    return;
534  }
535  var containerId = key.id;
536  
537  var aa = asyncActions[containerId];
538  if(aa == null) {
539    log("asyncFinish ignored (" + containerId + " not in asyncActions)");
540  } else {
541    if(aa.v != key.v) {
542      log("asyncFinish ignored (" + aa.v + " != " + key.v + ")");
543    } else {
544      delete asyncActions[containerId];
545      try {
546        // Check to make sure the object exists before removing it (because this is run twice and may not still exist)
547        if($(aa.d.id)){
548         // Effect.Fade(aa.d, { 
549          //  duration: 0.2, 
550          //  afterFinish: function asyncFinishAfterFinish(){document.body.removeChild(aa.d);}
551         // });
552         document.body.removeChild(aa.d);
553        }
554        if($(aa.db.id)){
555          document.body.removeChild(aa.db);
556        }
557      } catch(e) {}
558    }
559  }
560}
561
562function setImageUrl(container, img, url, callback) {
563  var cbimg = null;
564  if(img!= null) {
565    cbimg = img; 
566  } else {
567    var cbimg = document.createElement("IMG");
568    cbimg.style.display = "none";
569    document.body.appendChild(cbimg);
570    log("appended async img");
571  }
572  var callbackDone = false;
573  var asyncKey = null;
574  cbimg.onload = function() {
575      log("async img loaded: " + callbackDone);
576      if(callbackDone) {
577        return;
578      }
579      callbackDone = true;
580      /*
581      if(img!=null) {
582        log("si");
583        img.src = cbimg.src;
584        log("sd");
585      }
586      */
587      if(callback!=null) {
588        callback(cbimg.src);
589      }
590      asyncFinish(asyncKey);
591      if(img==null) {
592        document.body.removeChild(cbimg);
593      }
594    };
595    
596  cbimg.src = url;
597  if(BrowserDetect.browser == "Explorer" || BrowserDetect.browser == "Safari") {
598    if(cbimg.complete) {
599      log("async img complete: " + callbackDone);
600      /*
601      if(img!=null) {
602        img.src = cbimg.src;
603      }
604      */
605      if(callbackDone) {
606        return;
607      }
608      callbackDone = true;
609      if(callback!=null) {
610        callback(cbimg.src);
611      }
612      if(img==null) {
613        document.body.removeChild(cbimg);
614      }
615    } else {
616      asyncKey = asyncStart(container);
617      
618    }
619  } else {
620    //other browsers call onload properly...
621    asyncKey = asyncStart(container);
622  }
623}
624
625function setBackgroundImage(container, div, url) {
626  setImageUrl(container, null, url, function(nUrl) {
627    log("setting background image to " + nUrl);
628    div.style.backgroundImage = "url(" + nUrl + ")";
629  });
630}
631
632
633function setTransImage(el, src, w, h) {
634  if(useAlphaHack) {
635    el.src = "/images/trans.gif";
636    el.style.fontSize = "1px";
637    el.style.width = w + "px";
638    el.style.height = h + "px";
639    el.style.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src="' + src + '", sizingMethod="scale")';
640  } else {
641    el.src = src;
642    el.style.width = w + "px";
643    el.style.height = h + "px";
644    //el.width = w;
645    //el.height = h;
646  }
647}
648
649function updateStatesFromEl(countryEl, stateControlId) {
650  //alert("getting updateStatesFromEl..");
651  updateStates(countryEl.value, stateControlId);
652}
653
654function updateStates(countryId, stateControlId, stateContainerId, filterStates) {
655  //alert("getting states..");
656  //alert(stateControlId);
657  var sb = document.getElementById(stateControlId);
658  //alert("got el");
659  //alert(sb);
660  if(sb==null) {
661    alert("unable to get states element (" + stateControlId + ") to populate it");
662    return;
663  }
664  var selectedValue = encodeURIComponent(sb.value);
665  //alert("1");
666  sb.options.length = 0;
667  //alert("2");
668  sb.options[0] = new Option("Updating...","");
669  
670  //alert("asyncStart..");
671  var aKey = asyncStart(stateControlId);
672  
673  var extraParams = '&sel_value=' + selectedValue;
674  if(stateContainerId != null) {
675    extraParams = '&cnt=' + stateContainerId;
676    if(filterStates) {
677      extraParams += '&fs=1';
678    }
679  }
680  //alert("calling..");
681  var t2 = new Ajax.Request("/shared/lookups/update_states_dropdown?id=" + countryId + "&ctl=" + stateControlId + extraParams , {asynchronous:true, evalScripts:true, onComplete: function() { asyncFinish(aKey);},
682      onException: function(t,e) {
683        alert(e.name);
684        alert(e.message);
685  }});
686}
687
688function updatePostcode(countryId, postcodeControlId) {
689  var pc = $(postcodeControlId);
690  
691  if (pc == null) {
692    alert("Unable to get postcode control (" + postcodeControlId + ") to update");
693    return;
694  }
695  
696  var aKey = asyncStart(postcodeControlId);
697  
698  var t2 = new Ajax.Request("/shared/lookups/check_postcode_usage?id=" + countryId + "&ctl=" + postcodeControlId, {asynchronous:true, evalScripts:true, onComplete: function() { asyncFinish(aKey);},
699      onException: function(t,e) {
700        alert(e.name);
701        alert(e.message);
702  }});
703}
704
705function toggle_faq(fid) {
706  var el = $("a_" + fid);
707  if(el.style.display=="none") {
708    el.style.display="";
709  } else {
710    el.style.display="none";
711  }
712}
713
714function showCv2Info() {
715  myLightWindow.activateWindow({
716      href: "/product_info/pop/_cv2",
717      title: 'CV2 Numbers',
718      width: 400,
719      height: 400
720    });
721  
722}
723
724
725var ttCurrentPopup = null;
726var ttTimer = null;
727
728function ttMouseOver(el, popEl) {
729  if(ttCurrentPopup==popEl) {
730    ttClearTimeout();
731    return;
732  }
733  if(ttCurrentPopup!=null) {
734    ttCurrentPopup.style.display="none";
735  }
736  //position the new popup
737  
738  pos = Position.cumulativeOffset(el);
739  popEl.style.left = (pos[0] + 10) + "px";
740  popEl.style.top = (pos[1] + 10) + "px";
741  popEl.style.display="block";
742  
743  ttClearTimeout();
744  ttCurrentPopup = popEl;
745  
746}
747
748function ttMouseLeave(el, popEl) {
749  if(ttCurrentPopup==popEl) {
750    ttSetCloseTimeout(ttCurrentPopup);
751    return;
752  }
753}
754
755function ttSetCloseTimeout(popEl) {
756  ttClearTimeout();
757  //log("ttSetCloseTimeout()");
758  ttTimer = window.setTimeout( function () { 
759      popEl.style.display="none";
760      ttCurrentPopup = null;
761  }, 1000);
762}
763
764function ttClearTimeout() {
765  if(ttTimer != null) {
766    window.clearTimeout(ttTimer);
767    ttTimer = null;
768  }
769}
770
771//quick version of $ that does not extend
772function $q(element) {
773  if (typeof element == 'string')
774    element = document.getElementById(element);
775  return element;
776}
777
778//quick version that does not extend
779function firstChildElement(element) {
780  var el = element.firstChild;
781  while((el != null)&&(el.nodeType != 1)) {
782    el = el.nextSibling;
783  }
784  return el;
785}
786
787//quick version that does not extend
788function nextSiblingElement(element) {
789  var el = element.nextSibling;
790  while((el != null)&&(el.nodeType != 1)) {
791    el = el.nextSibling;
792  }
793  return el;
794}
795
796//quick version that does not extend
797function prevSiblingElement(element) {
798  var el = element.previousSibling;
799  while((el != null)&&(el.nodeType != 1)) {
800    el = el.previousSibling;
801  }
802  return el;
803}
804
805
806
807
808var debug = null;
809
810function logError(msg, data) {
811  try {
812    console.error(msg);
813    if(data != null) console.error(data);
814    console.trace();
815  } catch(e) {}
816
817  if((debug!=null)&&(debug.style.display != 'none')) {
818    debug.value = msg + "\n" + debug.value;
819  }
820}
821
822function imageRollover(){
823  var a=document.getElementsByTagName('li');
824  for(x=0; x<a.length; x++){
825    if(a[x].className=="display"){
826      var b=a[x].getElementsByTagName('a');
827      b[0].onmouseover=function(){ 
828        var c=this.getElementsByTagName('img');
829        if(c.length==2){
830          c[0].style.display="none";
831          c[1].style.display="inline";
832        }
833      }
834      b[0].onmouseout=function(){
835        var c=this.getElementsByTagName('img');
836        if(c.length==2){
837          c[1].style.display="none";
838          c[0].style.display="inline";
839        }
840      }
841    }
842  }
843}
844
845
846// monitors whether changes made to the current page
847var page_dirty = false;
848
849function setPageDirty() {
850  page_dirty = true;
851}
852
853function isPageDirty() {
854  return page_dirty;
855}
856
857function pageDirtyCheck() {
858  if (isPageDirty()) {
859    return confirm("Changes are not saved. Do you still want to leave this page?");
860  }
861}
862
863
864
865// prevent double click submit button
866function stopDoubleClick(timeout) {
867  var f;
868  var d = document.createElement('DIV');
869  d.style.height = document.body.offsetHeight + 'px';
870  d.style.width = document.body.offsetWidth + 'px';
871  d.style.top = d.style.left = 0;
872  d.className = "screen_guard";
873  d.id = "screen_guard";
874  d.style.display = "none";
875  document.body.appendChild(d);
876  
877  for (var i=0; i<document.forms.length; i++) {
878    document.forms[i].onkeypress = "return false;";
879  }
880  $(d).show();
881  setTimeout("disableSubmit();", 10);
882  if (timeout != 0) setTimeout("enableForms();", timeout);
883  
884  return true;
885}
886
887function disableSubmit() {
888  for (var i=0; i<document.forms.length; i++) {
889    for (var j=0; j<document.forms[i].elements.length; j++) {
890      if (document.forms[i].elements[j].type == "submit") {
891        document.forms[i].elements[j].disabled = "disabled";
892      }
893    }
894  }
895}
896
897function enableForms() {
898  var sg = $("screen_guard")
899  if (sg != null) sg.remove();
900  
901  for (var i=0; i<document.forms.length; i++) {
902    document.forms[i].onkeypress = "";
903    for (var j=0; j<document.forms[i].elements.length; j++) {
904      if (document.forms[i].elements[j].type == "submit") {
905        document.forms[i].elements[j].disabled = "";
906      }
907    }
908  }
909}
910
911
912
913
914var MarketBannerClass=Class.create({
915  initialize: function(container){
916    
917    
918    this.cell=container.getElementsBySelector("#m_wrapper .m_cell");
919    this.button=container.getElementsBySelector("#m_controls a");
920    this.curr=0;
921    
922    for(x=0; x<this.cell.length; x++){
923      this.show_option=this.show.bindAsEventListener(this, x);
924      Event.observe(this.button[x], "click", this.show_option);
925    }
926    
927    this.starttime();
928  }, 
929  show: function(e, num){
930    this.cleartime();
931    this.clear();
932    this.curr=num;
933    this.cell[this.curr].setStyle({
934        //"opacity" : 0,
935        "display" : "block"
936    });
937    //new Effect.Appear(this.cell[this.curr], { from: 0, to: 1 });
938    this.cell[this.curr].addClassName('alt');
939    this.button[this.curr].addClassName('alt');
940    this.starttime();
941  },
942  clear: function(){
943    //new Effect.Fade(this.cell[this.curr]);
944    this.cell[this.curr].removeClassName('alt');
945    this.button[this.curr].removeClassName('alt');
946  }, 
947  job: function(){
948    int_curr=this.curr+1;
949    if(int_curr>=this.cell.length){
950      int_curr=0;
951    }
952    this.show(1, int_curr);
953    //this.starttime();
954  },
955  starttime: function(){
956    if(this.cell.length>0){
957      this.timeout = window.setTimeout(this.job.bind(this), 5000);
958    }
959  },
960  cleartime: function(){
961    clearTimeout(this.timeout);
962  }
963});
964
965
966
967
968// lightwindow.js v2.0
969//
970// Copyright (c) 2007 stickmanlabs
971// Author: Kevin P Miller | http://www.stickmanlabs.com
972// 
973// LightWindow is freely distributable under the terms of an MIT
973-style license.
974//
975// I don't care what you think about the file size...
976//   Be a pro: 
977//      http://www.thinkvitamin.com/features/webapps/serving-javascript-fast
978//      http://rakaz.nl/item/make_your_pages_load_faster_by_combining_and_compressing_javascript_and_css_files
979//
980
981/*-----------------------------------------------------------------------------------------------*/
982
983if(typeof Effect == 'undefined')
984  throw("lightwindow.js requires including script.aculo.us' effects.js library!");
985
986// This will stop image flickering in IE6 when elements with images are moved
987try {
988  document.execCommand("BackgroundImageCache", false, true);
989} catch(e) {}
990
991var lightwindow = Class.create();  
992lightwindow.prototype = {
993  //
994  //  Setup Variables
995  //
996  element : null,
997  contentToFetch : null,
998  windowActive : false,
999  dataEffects : [],
1000  dimensions : {
1001    cruft : null,
1002    container : null,
1003    viewport : {
1004      height : null,
1005      width : null,
1006      offsetTop : null,
1007      offsetLeft : null
1008    }
1009  },
1010  pagePosition : {
1011    x : 0,
1012    y : 0
1013  },
1014  pageDimensions : {
1015    width : null,
1016    height : null
1017  },
1018  preloadImage : [],
1019  preloadedImage : [],
1020  galleries : [],
1021  resizeTo : {
1022    height : null,
1023    heightPercent : null,
1024    width : null,
1025    widthPercent : null,
1026    fixedTop : null,
1027    fixedLeft : null
1028  },
1029  scrollbarOffset : 18,
1030  navigationObservers : {
1031    previous : null,
1032    next : null
1033  },
1034  containerChange : {
1035    height : 0,
1036    width : 0
1037  },
1038  activeGallery : false,
1039  galleryLocation : {
1040    current : 0,
1041    total : 0
1042  },
1043  //
1044  //  Initialize the lightwindow.
1045  //
1046  initialize : function(options) {
1047    this.options = Object.extend({
1048      resizeSpeed : 8,
1049      contentOffset : {
1050        height : 20,
1051        width : 20
1052      },
1053      dimensions : {
1054        image : {height : 250, width : 250},
1055        page : {height : 250, width : 250},
1056        inline : {height : 250, width : 250},
1057        media : {height : 250, width : 250},
1058        external : {height : 250, width : 250},
1059        titleHeight : 25
1060      },
1061      classNames : {  
1062        standard : 'lightwindow',
1063        action : 'lightwindow_action'
1064      },
1065      fileTypes : {
1066        page : ['asp', 'aspx', 'cgi', 'cfm', 'htm', 'html', 'pl', 'php4', 'php3', 'php', 'php5', 'phtml', 'rhtml', 'shtml', 'txt', 'vbs', 'rb'],
1067        media : ['aif', 'aiff', 'asf', 'avi', 'divx', 'm1v', 'm2a', 'm2v', 'm3u', 'mid', 'midi', 'mov', 'moov', 'movie', 'mp2', 'mp3', 'mpa', 'mpa', 'mpe', 'mpeg', 'mpg', 'mpg', 'mpga', 'pps', 'qt', 'rm', 'ram', 'swf', 'viv', 'vivo', 'wav'],
1068        image : ['bmp', 'gif', 'jpg', 'png', 'tiff']
1069      },
1070      mimeTypes : {
1071        avi : 'video/avi',
1072        aif : 'audio/aiff',
1073        aiff : 'audio/aiff',
1074        gif : 'image/gif',
1075        bmp : 'image/bmp',
1076        jpeg : 'image/jpeg',
1077        m1v : 'video/mpeg',
1078        m2a : 'audio/mpeg',
1079        m2v : 'video/mpeg',
1080        m3u : 'audio/x-mpequrl',
1081        mid : 'audio/x-midi',
1082        midi : 'audio/x-midi',
1083        mjpg : 'video/x-motion-jpeg',
1084        moov : 'video/quicktime',
1085        mov : 'video/quicktime',
1086        movie : 'video/x-sgi-movie',
1087        mp2 : 'audio/mpeg',
1088        mp3 : 'audio/mpeg3',
1089        mpa : 'audio/mpeg',
1090        mpa : 'video/mpeg',
1091        mpe : 'video/mpeg',
1092        mpeg : 'video/mpeg',
1093        mpg : 'audio/mpeg',
1094        mpg : 'video/mpeg',
1095        mpga : 'audio/mpeg',
1096        pdf : 'application/pdf',
1097        png : 'image/png',
1098        pps : 'application/mspowerpoint',
1099        qt : 'video/quicktime',
1100        ram : 'audio/x-pn-realaudio-plugin',
1101        rm : 'application/vnd.rn-realmedia',
1102        swf  : 'application/x-shockwave-flash',
1103        tiff : 'image/tiff',
1104        viv : 'video/vivo',
1105        vivo : 'video/vivo',
1106        wav : 'audio/wav',
1107        wmv : 'application/x-mplayer2'      
1108      },  
1109      classids : {
1110        mov : 'clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B',
1111        swf : 'clsid:D27CDB6E-AE6D-11cf-96B8-444553540000',
1112        wmv : 'clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6'
1113      },
1114      codebases : {
1115        mov : 'http://www.apple.com/qtactivex/qtplugin.cab#version=6,0,2,0',
1116        swf : 'http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0',
1117        wmv : 'http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,5,715'
1118      },  
1119      viewportPadding : 10,
1120      EOLASFix : 'swf,wmv,fla,flv',
1121      overlay : {
1122        opacity : 0.7,
1123        image : '/images/black.png',
1124        presetImage : '/images/black-70.png'
1125      },
1126      skin :   {
1127        main :   '<div id="lightwindow_container" >'+
1128              '<div id="lightwindow_title_bar" >'+
1129                '<div id="lightwindow_title_bar_inner" >'+
1130                  '<span id="lightwindow_title_bar_title"></span>'+
1131                  '<a id="lightwindow_title_bar_close_link" >close</a>'+
1132                '</div>'+
1133              '</div>'+
1134              '<div id="lightwindow_stage" >'+
1135                '<div id="lightwindow_contents" >'+
1136                '</div>'+
1137                '<div id="lightwindow_navigation" >'+
1138                  '<a href="#" id="lightwindow_previous" >'+
1139                    '<span id="lightwindow_previous_title"></span>'+
1140                  '</a>'+
1141                  '<a href="#" id="lightwindow_next" >'+
1142                    '<span id="lightwindow_next_title"></span>'+
1143                  '</a>'+
1144                  '<iframe name="lightwindow_navigation_shim" id="lightwindow_navigation_shim" src="javascript:false;" frameBorder="0" scrolling="no"></iframe>'+
1145                '</div>'+                
1146                '<div id="lightwindow_galleries">'+
1147                  '<div id="lightwindow_galleries_tab_container" >'+
1148                    '<a href="#" id="lightwindow_galleries_tab" >'+
1149                      '<span id="lightwindow_galleries_tab_span" class="up" >Galleries</span>'+
1150                    '</a>'+
1151                  '</div>'+
1152                  '<div id="lightwindow_galleries_list" >'+
1153                  '</div>'+
1154                '</div>'+
1155              '</div>'+
1156              '<div id="lightwindow_data_slide" >'+
1157                '<div id="lightwindow_data_slide_inner" >'+
1158                  '<div id="lightwindow_data_details" >'+
1159                    '<div id="lightwindow_data_gallery_container" >'+
1160                      '<span id="lightwindow_data_gallery_current"></span>'+
1161                      ' of '+
1162                      '<span id="lightwindow_data_gallery_total"></span>'+
1163                    '</div>'+
1164                    '<div id="lightwindow_data_author_container" >'+
1165                      'by <span id="lightwindow_data_author"></span>'+
1166                    '</div>'+
1167                  '</div>'+
1168                  '<div id="lightwindow_data_caption" >'+
1169                  '</div>'+
1170                '</div>'+
1171              '</div>'+
1172            '</div>',  
1173        loading :   '<div id="lightwindow_loading" >'+
1174                '<img src="/images/ajax-loading.gif" alt="" />'+
1175                '<span>Loading or <a href="javascript: myLightWindow.deactivate();">Cancel</a></span>'+
1176                '<iframe name="lightwindow_loading_shim" id="lightwindow_loading_shim" src="javascript:false;" frameBorder="0" scrolling="no"></iframe>'+
1177              '</div>',
1178        iframe :   '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'+
1179              '<html xmlns="http://www.w3.org/1999/xhtml">'+
1180              '<body>'+
1181                  '{body_replace}'+
1182                '</body>'+
1183              '</html>',
1184        gallery : {
1185          top :    '<div class="lightwindow_galleries_list">'+
1186                  '<h1>{gallery_title_replace}</h1>'+
1187                  '<ul>',
1188          middle :       '<li>'+
1189                      '{gallery_link_replace}'+
1190                    '</li>',
1191          bottom :     '</ul>'+
1192                '</div>'
1193        }
1194      },
1195      formMethod : 'get',
1196      hideFlash : false,
1197      hideGalleryTab : false,
1198      showTitleBar : true,
1199      animationHandler : false,
1200      navigationHandler : false,
1201      transitionHandler : false,
1202      finalAnimationHandler : false,
1203      formHandler : false,
1204      galleryAnimationHandler : false,
1205      showGalleryCount : true
1206    }, options || {});
1207    this.duration = ((11-this.options.resizeSpeed)*0.15);
1208    this._setupLinks();
1209    this._getScroll();
1210    this._getPageDimensions();
1211    this._browserDimensions();
1212    this._addLightWindowMarkup(false);
1213    this._setupDimensions(); 
1214    this.buildGalleryList();
1215  },
1216  //
1217  //  Activate the lightwindow.
1218  //
1219  activate : function(e, link){    
1220    // Clear out the window Contents
1221    this._clearWindowContents(true);
1222      
1223    // Add back in out loading panel
1224    this._addLoadingWindowMarkup();
1225
1226    // Setup the element properties
1227    this._setupWindowElements(link);
1228    
1229    // Setup everything
1230    this._getScroll();
1231    this._browserDimensions();
1232    this._setupDimensions();
1233    this._toggleTroubleElements('hidden', false);
1234    this._displayLightWindow('block', 'hidden');
1235    this._setStatus(true);
1236    this._monitorKeyboard(true);
1237    this._prepareIE(true);
1238    this._loadWindow();
1239  },
1240  //
1241  //  Turn off the window
1242  //
1243  deactivate : function(event){
1244    // The window is not active
1245    this.windowActive = false;
1246    
1247    // There is no longer a gallery active
1248    this.activeGallery = false;
1249    if (!this.options.hideGalleryTab) {
1250      this._handleGalleryAnimation(false);
1251    }
1252    
1253    // Kill the animation
1254    this.animating = false;
1255    
1256    // Clear our element
1257    this.element = null;
1258    
1259    // hide the window.
1260    this._displayLightWindow('none', 'visible');
1261    
1262    // Clear out the window Contents
1263    this._clearWindowContents(false);
1264    
1265    // Stop all animation
1266    var queue = Effect.Queues.get('lightwindowAnimation').each(function(e){e.cancel();});
1267    
1268    // Undo the setup
1269    this._prepareIE(false);
1270    this._setupDimensions();
1271    this._toggleTroubleElements('visible', false);  
1272    this._monitorKeyboard(false);  
1273  },
1274  //
1275  //  Initialize specific window
1276  //
1277  createWindow : function(element, attributes) {
1278    this._processLink($(element));
1279  },
1280  //
1281  //  Open a Window from a hash of attributes
1282  //
1283  activateWindow : function(options) {
1284    this.element = Object.extend({
1285      href : null,
1286      title : null,
1287      author : null,
1288      caption : null,
1289      rel : null,
1290      top : null,
1291      left : null,
1292      type : null,
1293      showImages : null,
1294      height : null,
1295      width : null,
1296      loadingAnimation : null,
1297      iframeEmbed : null,
1298      form : null
1299    }, options || {});
1300    
1301    // Set the window type
1302    this.contentToFetch = this.element.href;
1303    this.windowType = this.element.type ? this.element.type : this._fileType(this.element.href);  
1304    
1305    // Clear out the window Contents
1306    this._clearWindowContents(true);
1307      
1308    // Add back in out loading panel
1309    this._addLoadingWindowMarkup();
1310    
1311    // Setup everything
1312    this._getScroll();
1313    this._browserDimensions();
1314    this._setupDimensions();
1315    this._toggleTroubleElements('hidden', false);
1316    this._displayLightWindow('block', 'hidden');
1317    this._setStatus(true);
1318    this._monitorKeyboard(true);
1319    this._prepareIE(true);
1320    this._loadWindow();
1321  },
1322  //
1323  //  Fire off our Form handler
1324  //
1325  submitForm : function(e) {
1326    if (this.options.formHandler) {
1327      this.options.formHandler(e);
1328    } else {
1329      this._defaultFormHandler(e);
1330    }
1331  },
1332  //
1333  //  Reload the window with another location
1334  //
1335  openWindow : function(element) {
1336    var element = $(element);
1337
1338    // The window is active
1339    this.windowActive = true;
1340    
1341    // Clear out the window Contents
1342    this._clearWindowContents(true);
1343    
1344    // Add back in out loading panel
1345    this._addLoadingWindowMarkup();
1346    
1347    // Setup the element properties
1348    this._setupWindowElements(element);
1349
1350    this._setStatus(true);
1351    this._handleTransition();
1352  },
1353  //
1354  //  Navigate the window
1355  //
1356  navigateWindow : function(direction) {
1357    this._handleNavigation(false);
1358    if (direction == 'previous') {
1359      this.openWindow(this.navigationObservers.previous);
1360    } else if (direction == 'next'){ 
1361      this.openWindow(this.navigationObservers.next);
1362    }
1363  },
1364  //
1365  //  Build the Gallery List and Load it
1366  //
1367  buildGalleryList : function() {
1368    var output = '';
1369    var galleryLink;
1370    for (var i in this.galleries) {
1371      if (typeof this.galleries[i] == 'object') {
1372        output += (this.options.skin.gallery.top).replace('{gallery_title_replace}', unescape(i));
1373        for (j in this.galleries[i]) {
1374          if (typeof this.galleries[i][j] == 'object') {            
1375            galleryLink = '<a href="#" id="lightwindow_gallery_'+i+'_'+j+'" >'+unescape(j)+'</a>';
1376            output += (this.options.skin.gallery.middle).replace('{gallery_link_replace}', galleryLink);
1377          }
1378        }
1379        output += this.options.skin.gallery.bottom;
1380      }
1381    }
1382    new Insertion.Top('lightwindow_galleries_list', output);
1383    
1384    // Attach Events
1385    for (var i in this.galleries) {
1386      if (typeof this.galleries[i] == 'object') {
1387        for (j in this.galleries[i]) {
1388          if (typeof this.galleries[i][j] == 'object') {
1389            Event.observe($('lightwindow_gallery_'+i+'_'+j), 'click', this.openWindow.bind(this, this.galleries[i][j][0]), false);
1390            $('lightwindow_gallery_'+i+'_'+j).onclick = function() {return false;};  
1391          }
1392        }
1393      }
1394    }
1395  },
1396  // 
1397  //  Set Links Up
1398  //
1399  _setupLinks : function() {
1400    var links = $$('.'+this.options.classNames.standard);
1401    links.each(function(link) {
1402      this._processLink(link);
1403    }.bind(this));  
1404  },
1405  //
1406  //  Process a Link
1407  //
1408  _processLink : function(link) {
1409    if ((this._fileType(link.getAttribute('href')) == 'image' || this._fileType(link.getAttribute('href')) == 'media')) {
1410      if (gallery = this._getGalleryInfo(link.rel)) {
1411        if (!this.galleries[gallery[0]]) {
1412          this.galleries[gallery[0]] = new Array();
1413        }
1414        if (!this.galleries[gallery[0]][gallery[1]]) {
1415          this.galleries[gallery[0]][gallery[1]] = new Array();
1416        }
1417        this.galleries[gallery[0]][gallery[1]].push(link);
1418      }
1419    }
1420    
1421    // Take care of our inline content
1422    var url = link.getAttribute('href');
1423    if (url.indexOf('?') > -1) {
1424      url = url.substring(0, url.indexOf('?'));
1425    }
1426    
1427    var container = url.substring(url.indexOf('#')+1);
1428    if($(container)) {
1429      $(container).setStyle({
1430        display : 'none'
1431      });
1432    }
1433    
1434    Event.observe(link, 'click', this.activate.bindAsEventListener(this, link), false);
1435    link.onclick = function() {return false;};    
1436  },
1437  //
1438  //  Setup our actions
1439  //
1440  _setupActions : function() {
1441    var links = $$('#lightwindow_container .'+this.options.classNames.action);
1442    links.each(function(link) {
1443      Event.observe(link, 'click', this[link.getAttribute('rel')].bindAsEventListener(this, link), false);
1444      link.onclick = function() {return false;};
1445    }.bind(this));
1446  },
1447  //
1448  //  Add the markup to the page.
1449  //
1450  _addLightWindowMarkup : function(rebuild) {
1451    var overlay = Element.extend(document.createElement('div'));
1452    overlay.setAttribute('id', 'lightwindow_overlay');    
1453    // FF Mac has a problem with putting Flash above a layer without a 100% opacity background, so we need to use a pre-made
1454    if (Prototype.Browser.Gecko) {
1455      overlay.setStyle({
1456        backgroundImage: 'url('+this.options.overlay.presetImage+')',
1457        backgroundRepeat: 'repeat',
1458        height: this.pageDimensions.height+'px'
1459      });      
1460    } else {
1461      overlay.setStyle({
1462        opacity: this.options.overlay.opacity,
1463        backgroundImage: 'url('+this.options.overlay.image+')',
1464        backgroundRepeat: 'repeat',
1465        height: this.pageDimensions.height+'px'
1466      });
1467    }
1468    
1469    var lw = document.createElement('div');
1470    lw.setAttribute('id', 'lightwindow');
1471    lw.innerHTML = this.options.skin.main;
1472    
1473    var body = document.getElementsByTagName('body')[0];
1474    body.appendChild(overlay);
1475    body.appendChild(lw);  
1476        
1477    if ($('lightwindow_title_bar_close_link')) {
1478      Event.observe($('lightwindow_title_bar_close_link'), 'click', this.deactivate.bindAsEventListener(this));
1479      $('lightwindow_title_bar_close_link').onclick = function() {return false;};
1480    }
1481      
1482    Event.observe($('lightwindow_previous'), 'click', this.navigateWindow.bind(this, 'previous'), false);
1483    $('lightwindow_previous').onclick = function() {return false;};    
1484    Event.observe($('lightwindow_next'), 'click', this.navigateWindow.bind(this, 'next'), false);
1485    $('lightwindow_next').onclick = function() {return false;};
1486
1487    if (!this.options.hideGalleryTab) {
1488      Event.observe($('lightwindow_galleries_tab'), 'click', this._handleGalleryAnimation.bind(this, true), false);
1489      $('lightwindow_galleries_tab').onclick = function() {return false;};
1490    }
1491    
1492    // Because we use position absolute, kill the scroll Wheel on animations
1493    if (Prototype.Browser.IE) {
1494      Event.observe(document, 'mousewheel', this._stopScrolling.bindAsEventListener(this), false);
1495    } else {
1496      Event.observe(window, 'DOMMouseScroll', this._stopScrolling.bindAsEventListener(this), false);
1497    }
1498        
1499    Event.observe(overlay, 'click', this.deactivate.bindAsEventListener(this), false);
1500    overlay.onclick = function() {return false;};
1501  },
1502  //
1503  //  Add loading window markup
1504  //
1505  _addLoadingWindowMarkup : function() {
1506    $('lightwindow_contents').innerHTML += this.options.skin.loading;
1507  },
1508  //
1509  //  Setup the window elements
1510  //
1511  _setupWindowElements : function(link) {
1512    this.element = link;
1513    this.element.title = null ? '' : link.getAttribute('title');
1514    this.element.author = null ? '' : link.getAttribute('author');
1515    this.element.caption = null ? '' : link.getAttribute('caption');
1516    this.element.rel = null ? '' : link.getAttribute('rel');
1517    this.element.params = null ? '' : link.getAttribute('params');
1518
1519    // Set the window type
1520    this.contentToFetch = this.element.href;
1521    this.windowType = this._getParameter('lightwindow_type') ? this._getParameter('lightwindow_type') : this._fileType(this.contentToFetch);  
1522  },
1523  //
1524  //  Clear the window contents out
1525  //
1526  _clearWindowContents : function(contents) {
1527    // If there is an iframe, its got to go
1528    if ($('lightwindow_iframe')) {
1529      Element.remove($('lightwindow_iframe'));
1530    }
1531
1532    // Stop playing an object if its still around
1533    if ($('lightwindow_media_primary')) {
1534      try {
1535        $('lightwindow_media_primary').Stop();
1536      } catch(e) {}
1537      Element.remove($('lightwindow_media_primary'));
1538    }
1539
1540    // Stop playing an object if its still around    
1541    if ($('lightwindow_media_secondary')) {
1542      try {
1543        $('lightwindow_media_secondary').Stop();
1544      } catch(e) {}
1545      Element.remove($('lightwindow_media_secondary'));
1546    }
1547    
1548    this.activeGallery = false;
1549    this._handleNavigation(this.activeGallery);
1550    
1551    if (contents) {
1552      // Empty the contents
1553      $('lightwindow_contents').innerHTML = '';
1554      
1555      // Reset the scroll bars
1556      $('lightwindow_contents').setStyle({
1557        overflow: 'hidden'
1558      });    
1559      
1560      if (!this.windowActive) {
1561        $('lightwindow_data_slide_inner').setStyle({
1562          display: 'none'
1563        });
1564
1565        $('lightwindow_title_bar_title').innerHTML = '';
1566      }
1567
1568      // Because of browser differences and to maintain flexible captions we need to reset this height at close
1569      $('lightwindow_data_slide').setStyle({
1570        height: 'auto'
1571      });
1572    }
1573    
1574    this.resizeTo.height = null;
1575    this.resizeTo.width = null;
1576  },
1577  //
1578  //  Set the status of our animation to keep things from getting clunky
1579  //
1580  _setStatus : function(status) {
1581    this.animating = status;
1582    if (status) {
1583      Element.show('lightwindow_loading');
1584    }
1585    if (!(/MSIE 6./i.test(navigator.userAgent))) {
1586      this._fixedWindow(status);
1587    }
1588  },
1589  //
1590  //  Make this window Fixed
1591  //
1592  _fixedWindow : function(status) {
1593    if (status) {
1594      if (this.windowActive) {
1595        this._getScroll();
1596        $('lightwindow').setStyle({
1597          position: 'absolute',
1598          top: parseFloat($('lightwindow').getStyle('top'))+this.pagePosition.y+'px',
1599          left: parseFloat($('lightwindow').getStyle('left'))+this.pagePosition.x+'px'
1600        });    
1601      } else {
1602        $('lightwindow').setStyle({
1603          position: 'absolute'
1604        });            
1605      }
1606    } else {
1607      if (this.windowActive) {
1608        this._getScroll();
1609        $('lightwindow').setStyle({
1610          position: 'fixed',
1611          top: parseFloat($('lightwindow').getStyle('top'))-this.pagePosition.y+'px',
1612          left: parseFloat($('lightwindow').getStyle('left'))-this.pagePosition.x+'px'
1613        });    
1614      } else {
1615        if ($('lightwindow_iframe')) {
1616          // Ideally here we would set a 50% value for top and left, but Safari rears it ugly head again and we need to do it by pixels
1617          this._browserDimensions();
1618        }
1619        $('lightwindow').setStyle({
1620          position: 'fixed',
1621          top: (parseFloat(this._getParameter('lightwindow_top')) ? parseFloat(this._getParameter('lightwindow_top'))+'px' : this.dimensions.viewport.height/2+'px'),
1622          left: (parseFloat(this._getParameter('lightwindow_left')) ? parseFloat(this._getParameter('lightwindow_left'))+'px' : this.dimensions.viewport.width/2+'px')
1623        });
1624      }
1625    }
1626  },
1627  //
1628  //  Prepare the window for IE.
1629  //
1630  _prepareIE : function(setup) {
1631    if (Prototype.Browser.IE) {
1632      var height, overflowX, overflowY;
1633      if (setup) { 
1634        var height = '100%';
1635      } else {
1636        var height = 'auto';
1637      }
1638      var body = document.getElementsByTagName('body')[0];
1639      var html = document.getElementsByTagName('html')[0];
1640      html.style.height = body.style.height = height;
1641    }
1642  },
1643  _stopScrolling : function(e) {
1644    if (this.animating) {
1645      if (e.preventDefault) {
1646        e.preventDefault();
1647      }
1648      e.returnValue = false;    
1649    }
1650  },
1651  //
1652  //  Get the scroll for the page.
1653  //
1654  _getScroll : function(){
1655        if(typeof(window.pageYOffset) == 'number') {
1656          this.pagePosition.x = window.pageXOffset;
1657          this.pagePosition.y = window.pageYOffset;
1658        } else if(document.body && (document.body.scrollLeft || document.body.scrollTop)) {
1659           this.pagePosition.x = document.body.scrollLeft;
1660          this.pagePosition.y = document.body.scrollTop;
1661    } else if(document.documentElement) {
1662          this.pagePosition.x = document.documentElement.scrollLeft;
1663          this.pagePosition.y = document.documentElement.scrollTop;
1664        }
1665  },
1666  //
1667  //  Reset the scroll.
1668  //
1669  _setScroll : function(x, y) {
1670    document.documentElement.scrollLeft = x; 
1671    document.documentElement.scrollTop = y; 
1672  },
1673  //
1674  //  Hide Selects from the page because of IE.
1675  //     We could use iframe shims instead here but why add all the extra markup for one browser when this is much easier and cleaner
1676  //
1677  _toggleTroubleElements : function(visibility, content){
1678    
1679    if (content) {
1680      var selects = $('lightwindow_contents').getElementsByTagName('select');
1681    } else {
1682      var selects = document.getElementsByTagName('select');
1683    }
1684    
1685    for(var i = 0; i < selects.length; i++) {
1686      selects[i].style.visibility = visibility;
1687    }
1688    
1689    if (!content) {
1690      if (this.options.hideFlash){
1691        var objects = document.getElementsByTagName('object');
1692        for (i = 0; i != objects.length; i++) {
1693          objects[i].style.visibility = visibility;
1694        }
1695        var embeds = document.getElementsByTagName('embed');
1696        for (i = 0; i != embeds.length; i++) {
1697          embeds[i].style.visibility = visibility;
1698        }
1699      }
1700      var iframes = document.getElementsByTagName('iframe');
1701      for (i = 0; i != iframes.length; i++) {
1702        iframes[i].style.visibility = visibility;
1703      }
1704    }
1705  },
1706  // 
1707  //  Get the actual page size
1708  //
1709  _getPageDimensions : function() {
1710    var xScroll, yScroll;
1711    if (window.innerHeight && window.scrollMaxY) {  
1712      xScroll = document.body.scrollWidth;
1713      yScroll = window.innerHeight + window.scrollMaxY;
1714    } else if (document.body.scrollHeight > document.body.offsetHeight){ 
1715      xScroll = document.body.scrollWidth;
1716      yScroll = document.body.scrollHeight;
1717    } else { 
1718      xScroll = document.body.offsetWidth;
1719      yScroll = document.body.offsetHeight;
1720    }
1721
1722    var windowWidth, windowHeight;
1723    if (self.innerHeight) {  
1724      windowWidth = self.innerWidth;
1725      windowHeight = self.innerHeight;
1726    } else if (document.documentElement && document.documentElement.clientHeight) { 
1727      windowWidth = document.documentElement.clientWidth;
1728      windowHeight = document.documentElement.clientHeight;
1729    } else if (document.body) { 
1730      windowWidth = document.body.clientWidth;
1731      windowHeight = document.body.clientHeight;
1732    }  
1733
1734    if(yScroll < windowHeight){
1735      this.pageDimensions.height = windowHeight;
1736    } else { 
1737      this.pageDimensions.height = yScroll;
1738    }
1739
1740    if(xScroll < windowWidth){  
1741      this.pageDimensions.width = windowWidth;
1742    } else {
1743      this.pageDimensions.width = xScroll;
1744    }
1745  },
1746  //
1747  //  Display the lightWindow.
1748  //
1749  _displayLightWindow : function(display, visibility) {
1750    $('lightwindow_overlay').style.display = $('lightwindow').style.display = $('lightwindow_container').style.display = display;  
1751    $('lightwindow_overlay').style.visibility = $('lightwindow').style.visibility = $('lightwindow_container').style.visibility = visibility;
1752  },
1753  //
1754  //  Setup Dimensions of lightwindow.
1755
1756  //
1757  _setupDimensions : function() {
1758
1759    var originalHeight, originalWidth;
1760    switch (this.windowType) {
1761      case 'page' :
1762        originalHeight = this.options.dimensions.page.height;
1763        originalWidth = this.options.dimensions.page.width;
1764        break;
1765
1766      case 'image' :
1767        originalHeight = this.options.dimensions.image.height;
1768        originalWidth = this.options.dimensions.image.width;
1769        break;
1770        
1771      case 'media' :
1772        originalHeight = this.options.dimensions.media.height;
1773        originalWidth = this.options.dimensions.media.width;
1774        break;
1775      
1776      case 'external' : 
1777        originalHeight = this.options.dimensions.external.height;
1778        originalWidth = this.options.dimensions.external.width;
1779        break;
1780        
1781      case 'inline' :
1782        originalHeight = this.options.dimensions.inline.height;
1783        originalWidth = this.options.dimensions.inline.width;
1784        break;
1785        
1786      default :
1787        originalHeight = this.options.dimensions.page.height;
1788        originalWidth = this.options.dimensions.page.width;
1789        break;
1790        
1791    }
1792
1793    var offsetHeight = this._getParameter('lightwindow_top') ? parseFloat(this._getParameter('lightwindow_top'))+this.pagePosition.y : this.dimensions.viewport.height/2+this.pagePosition.y;
1794    var offsetWidth = this._getParameter('lightwindow_left') ? parseFloat(this._getParameter('lightwindow_left'))+this.pagePosition.x : this.dimensions.viewport.width/2+this.pagePosition.x;
1795    
1796    // So if a theme has say shadowed edges, they should be consistant and take care of in the contentOffset
1797    $('lightwindow').setStyle({
1798      top: offsetHeight+'px',
1799      left: offsetWidth+'px'
1800    });
1801    
1802    $('lightwindow_container').setStyle({
1803      height: originalHeight+'px',
1804      width: originalWidth+'px',
1805      left: -(originalWidth/2)+'px',
1806      top: -(originalHeight/2)+'px'
1807    });
1808
1809    $('lightwindow_contents').setStyle({
1810      height: originalHeight+'px',
1811      width: originalWidth+'px'
1812    });
1813  },
1814  //
1815  //  Get the type of file.
1816  //
1817  _fileType : function(url) {
1818    var image = new RegExp("[^\.]\.("+this.options.fileTypes.image.join('|')+")\s*$", "i");
1819    if (image.test(url)) return 'image';
1820    if (url.indexOf('#') > -1 && (document.domain == this._getDomain(url))) return 'inline';    
1821    if (url.indexOf('?') > -1) url = url.substring(0, url.indexOf('?'));
1822    var type = 'unknown';
1823    var page = new RegExp("[^\.]\.("+this.options.fileTypes.page.join('|')+")\s*$", "i");
1824    var media = new RegExp("[^\.]\.("+this.options.fileTypes.media.join('|')+")\s*$", "i");
1825    if (document.domain != this._getDomain(url)) type = 'external';
1826      if (media.test(url)) type = 'media';
1827    if (type == 'external' || type == 'media') return type;
1828      if (page.test(url) || url.substr((url.length-1), url.length) == '/') type = 'page';
1829    return type;
1830  },
1831  //
1832  //  Get file Extension
1833  //
1834  _fileExtension : function(url) {
1835    if (url.indexOf('?') > -1) {
1836      url = url.substring(0, url.indexOf('?'));
1837    }
1838    var extenstion = '';
1839    for (var x = (url.length-1); x > -1; x--) {
1840      if (url.charAt(x) == '.') {
1841        return extenstion;
1842      }
1843      extenstion = url.charAt(x)+extenstion;
1844    }
1845  },
1846  //
1847  //  Monitor the keyboard while this lightwindow is up
1848  //
1849  _monitorKeyboard : function(status) {
1850    if (status) document.onkeydown = this._eventKeypress.bind(this); 
1851    else document.onkeydown = '';
1852  },
1853  //
1854  //  Perform keyboard actions
1855  //
1856  _eventKeypress : function(e) {
1857    if (e == null) {
1858      var keycode = event.keyCode;
1859    } else {
1860      var keycode = e.which;
1861    }
1862    
1863    switch (keycode) { 
1864      case 27: 
1865        this.deactivate(); 
1866        break;
1867      
1868      case 13:
1869        return;
1870        
1871      default:
1872        break;
1873    }
1874  
1875    // Gotta stop those quick fingers
1876    if (this.animating) {
1877      return false;
1878    }
1879    
1880    switch (String.fromCharCode(keycode).toLowerCase()) {
1881      case 'p':
1882        if (this.navigationObservers.previous) {
1883          this.navigateWindow('previous');
1884        }
1885        break;
1886        
1887      case 'n':
1888        if (this.navigationObservers.next) {
1889          this.navigateWindow('next');
1890        }
1891        break;
1892        
1893      default:
1894        break;
1895    }
1896  },
1897  //
1898  //  Get Gallery Information
1899  //
1900  _getGalleryInfo : function(rel) {
1901    if (!rel) return false;
1902    if (rel.indexOf('[') > -1) {
1903      return new Array(escape(rel.substring(0, rel.indexOf('['))), escape(rel.substring(rel.indexOf('[')+1, rel.indexOf(']'))));
1904    } else {
1905      return false;
1906    }
1907  },
1908  //
1909  //  Get the domain from a string.
1910  //
1911  _getDomain : function(url) {    
1912        var leadSlashes = url.indexOf('//');
1913        var domainStart = leadSlashes+2;
1914        var withoutResource = url.substring(domainStart, url.length);
1915        var nextSlash = withoutResource.indexOf('/');
1916        var domain = withoutResource.substring(0, nextSlash);
1917    if (domain.indexOf(':') > -1){
1918      var portColon = domain.indexOf(':');
1919      domain = domain.substring(0, portColon);
1920         }
1921    return domain;
1922    },
1923  //
1924  //  Get the value from the params attribute string.
1925  //
1926  _getParameter : function(parameter, parameters) {
1927    if (!this.element) return false;
1928    if (parameter == 'lightwindow_top' && this.element.top) {
1929      return unescape(this.element.top);
1930    } else if (parameter == 'lightwindow_left' && this.element.left) {
1931      return unescape(this.element.left);
1932    } else if (parameter == 'lightwindow_type' && this.element.type) {
1933      return unescape(this.element.type);
1934    } else if (parameter == 'lightwindow_show_images' && this.element.showImages) {
1935      return unescape(this.element.showImages);
1936    } else if (parameter == 'lightwindow_height' && this.element.height) {
1937      return unescape(this.element.height);
1938    } else if (parameter == 'lightwindow_width' && this.element.width) {
1939      return unescape(this.element.width);
1940    } else if (parameter == 'lightwindow_loading_animation' && this.element.loadingAnimation) {
1941      return unescape(this.element.loadingAnimation);
1942    } else if (parameter == 'lightwindow_iframe_embed' && this.element.iframeEmbed) {
1943      return unescape(this.element.iframeEmbed);
1944    } else if (parameter == 'lightwindow_form' && this.element.form) {
1945      return unescape(this.element.form);
1946    } else {
1947      if (!parameters) {
1948        if (this.element.params) parameters = this.element.params;
1949        else return;
1950      }
1951      var value;
1952      var parameterArray = parameters.split(',');
1953      var compareString = parameter+'=';
1954      var compareLength = compareString.length;
1955      for (var i = 0; i < parameterArray.length; i++) {
1956        if (parameterArray[i].substr(0, compareLength) == compareString) {
1957          var currentParameter = parameterArray[i].split('=');
1958          value = currentParameter[1];
1959          break;
1960        }
1961      }
1962      if (!value) return false;
1963      else return unescape(value);
1964    }
1965  },
1966  //
1967  //  Get the Browser Viewport Dimensions
1968  //
1969  _browserDimensions : function() {
1970    if (Prototype.Browser.IE) {
1971            this.dimensions.viewport.height = document.documentElement.clientHeight;
1972            this.dimensions.viewport.width = document.documentElement.clientWidth;   
1973        } else {
1974            this.dimensions.viewport.height = window.innerHeight;
1975            this.dimensions.viewport.width = document.width || document.body.offsetWidth;
1976        }
1977  },
1978  //
1979  //  Get the scrollbar offset, I don't like this method but there is really no other way I can find.
1980  //
1981  _getScrollerWidth : function() {
1982      var scrollDiv = Element.extend(document.createElement('div'));
1983    scrollDiv.setAttribute('id', 'lightwindow_scroll_div');
1984    scrollDiv.setStyle({
1985      position: 'absolute',
1986      top: '-10000px',
1987      left: '-10000px',
1988      width: '100px',
1989      height: '100px',
1990      overflow: 'hidden'
1991    });
1992
1993
1994
1995      var contentDiv = Element.extend(document.createElement('div'));
1996    contentDiv.setAttribute('id', 'lightwindow_content_scroll_div');
1997    contentDiv.setStyle({
1998      width: '100%',
1999      height: '200px'
2000    });
2001
2002      scrollDiv.appendChild(contentDiv);
2003
2004    var body = document.getElementsByTagName('body')[0];
2005    body.appendChild(scrollDiv);
2006
2007      var noScroll = $('lightwindow_content_scroll_div').offsetWidth;
2008      scrollDiv.style.overflow = 'auto';
2009      var withScroll = $('lightwindow_content_scroll_div').offsetWidth;
2010
2011       Element.remove($('lightwindow_scroll_div'));
2012
2013      this.scrollbarOffset = noScroll-withScroll;
2014  },
2015  
2016
2017  //
2018  //  Add a param to an object dynamically created
2019  //
2020  _addParamToObject : function(name, value, object, id) {
2021    var param = document.createElement('param');
2022    param.setAttribute('value', value);
2023    param.setAttribute('name', name);
2024    if (id) {
2025      param.setAttribute('id', id);
2026    }
2027    object.appendChild(param);
2028    return object;
2029  },
2030  //
2031  //  Get the outer HTML of an object CROSS BROWSER
2032  //
2033  _outerHTML : function(object) {
2034     if (Prototype.Browser.IE) {
2035      return object.outerHTML;
2036    } else {
2037      var clone = object.cloneNode(true);
2038      var cloneDiv = document.createElement('div');
2039      cloneDiv.appendChild(clone);
2040      return cloneDiv.innerHTML;
2041    }
2042  },
2043  //
2044  //  Convert an object to markup
2045  //
2046  _convertToMarkup : function(object, closeTag) {
2047    var markup = this._outerHTML(object).replace('</'+closeTag+'>', '');
2048    if (Prototype.Browser.IE) {
2049      for (var i = 0; i < object.childNodes.length; i++){
2050        markup += this._outerHTML(object.childNodes[i]);
2051      }
2052      markup += '</'+closeTag+'>';
2053    }
2054    return markup;
2055  },
2056  //
2057  //  Depending what type of browser it is we have to append the object differently... DAMN YOU IE!!
2058  //
2059  _appendObject : function(object, closeTag, appendTo) {
2060    if (Prototype.Browser.IE) {
2061      appendTo.innerHTML += this._convertToMarkup(object, closeTag);
2062      
2063      // Fix the Eolas activate thing but only for specified media, for example doing this to a quicktime film breaks it.
2064      if (this.options.EOLASFix.indexOf(this._fileType(this.element.href)) > -1) {
2065        var objectElements = document.getElementsByTagName('object');
2066        for (var i = 0; i < objectElements.length; i++) {
2067          if (objectElements[i].getAttribute("data")) objectElements[i].removeAttribute('data');
2068          objectElements[i].outerHTML = objectElements[i].outerHTML;
2069          objectElements[i].style.visibility = "visible";
2070        }
2071      }
2072    } else {
2073      appendTo.appendChild(object);  
2074    }  
2075  },
2076  //
2077  //  Add in iframe
2078  //
2079  _appendIframe : function(scroll) {
2080    var iframe = document.createElement('iframe');
2081    iframe.setAttribute('id', 'lightwindow_iframe');
2082    iframe.setAttribute('name', 'lightwindow_iframe');
2083    iframe.setAttribute('src', 'about:blank');
2084    iframe.setAttribute('height', '100%');
2085    iframe.setAttribute('width', '100%');
2086    iframe.setAttribute('frameborder', '0');
2087    iframe.setAttribute('marginwidth', '0');
2088    iframe.setAttribute('marginheight', '0');
2089    iframe.setAttribute('scrolling', scroll);  
2090    
2091    this._appendObject(iframe, 'iframe', $('lightwindow_contents'));
2092  },
2093  //
2094  //  Write Content to the iframe using the skin
2095  //
2096  _writeToIframe : function(content) {
2097    var template = this.options.skin.iframe;
2098    template = template.replace('{body_replace}', content); 
2099    if ($('lightwindow_iframe').contentWindow){
2100      $('lightwindow_iframe').contentWindow.document.open();
2101      $('lightwindow_iframe').contentWindow.document.write(template);
2102      $('lightwindow_iframe').contentWindow.document.close();
2103    } else {
2104      $('lightwindow_iframe').contentDocument.open();
2105      $('lightwindow_iframe').contentDocument.write(template);
2106      $('lightwindow_iframe').contentDocument.close();
2107    }
2108  },
2109  _checkImage : function(img) {
2110    // During the onload event, IE correctly identifies any images
2111      // that weren't downloaded as not complete. Others should too.
2112      // Gecko-based browsers act like NS4 in that they report this
2113      // incorrectly: they always return true.
2114      // if (!img.complete) {
2115      //     return false;
2116      // }
2117
2118      // However, they do have two very useful properties: naturalWidth
2119      // and naturalHeight. These give the true size of the image. If
2120      // it failed to load, either of these should be zero.
2121      if (typeof img.naturalWidth != "undefined" && img.naturalWidth == 0) {
2122          return false;
2123      }
2124      log(img);
2125      // No other way of checking: assume it's ok.
2126      return true;
2127    
2128  },
2129  //
2130  //  Load the window Information
2131  //  
2132  _loadWindow : function() {
2133    switch (this.windowType) {
2134      case 'image' :
2135
2136        var current = 0;
2137        var images = [];
2138        this.checkImage = [];
2139        this.resizeTo.height = this.resizeTo.width = 0;
2140        this.imageCount = this._getParameter('lightwindow_show_images') ? parseInt(this._getParameter('lightwindow_show_images')) : 1;
2141
2142        // If there is a gallery get it
2143        if (gallery = this._getGalleryInfo(this.element.rel)) {  
2144          for (current = 0; current < this.galleries[gallery[0]][gallery[1]].length; current++) {
2145            if (this.contentToFetch.indexOf(this.galleries[gallery[0]][gallery[1]][current].href) > -1) {
2146              break;
2147            }
2148          }
2149          if (this.galleries[gallery[0]][gallery[1]][current-this.imageCount]) {
2150            this.navigationObservers.previous = this.galleries[gallery[0]][gallery[1]][current-this.imageCount];
2151          } else {
2152            this.navigationObservers.previous = false;
2153          }
2154          if (this.galleries[gallery[0]][gallery[1]][current+this.imageCount]) {
2155            this.navigationObservers.next = this.galleries[gallery[0]][gallery[1]][current+this.imageCount];
2156          } else {
2157            this.navigationObservers.next = false;
2158          }
2159          
2160          this.activeGallery = true;
2161        } else {
2162          this.navigationObservers.previous = false;
2163          this.navigationObservers.next = false;          
2164
2165          this.activeGallery = false;
2166        }
2167        
2168        for (var i = current; i < (current+this.imageCount); i++) {
2169    
2170          if (gallery && this.galleries[gallery[0]][gallery[1]][i]) {
2171            this.contentToFetch = this.galleries[gallery[0]][gallery[1]][i].href;
2172            
2173            this.galleryLocation = {current: (i+1)/this.imageCount, total: (this.galleries[gallery[0]][gallery[1]].length)/this.imageCount};
2174                      
2175            if (!this.galleries[gallery[0]][gallery[1]][i+this.imageCount]) {
2176              $('lightwindow_next').setStyle({
2177                display: 'none'
2178              });
2179            } else {
2180              $('lightwindow_next').setStyle({
2181                display: 'block'
2182              });
2183              $('lightwindow_next_title').innerHTML = this.galleries[gallery[0]][gallery[1]][i+this.imageCount].title;
2184            }
2185            
2186            if (!this.galleries[gallery[0]][gallery[1]][i-this.imageCount]) {
2187              $('lightwindow_previous').setStyle({
2188                display: 'none'
2189              });
2190            } else {
2191              $('lightwindow_previous').setStyle({
2192                display: 'block'
2193              });
2194              $('lightwindow_previous_title').innerHTML = this.galleries[gallery[0]][gallery[1]][i-this.imageCount].title;
2195            }
2196          }
2197
2198          images[i] = document.createElement('img');
2199          images[i].setAttribute('id', 'lightwindow_image_'+i);
2200          images[i].setAttribute('border', '0');
2201          images[i].setAttribute('src', this.contentToFetch);
2202          $('lightwindow_contents').appendChild(images[i]);
2203
2204          // We have to do this instead of .onload 
2205          this.checkImage[i] = new PeriodicalExecuter(function(i) {
2206            if (!(typeof $('lightwindow_image_'+i).naturalWidth != "undefined" && $('lightwindow_image_'+i).naturalWidth == 0)) {
2207  
2208              this.checkImage[i].stop();
2209  
2210              var imageHeight = $('lightwindow_image_'+i).getHeight();
2211              if (imageHeight > this.resizeTo.height) {
2212                this.resizeTo.height = imageHeight;
2213              }
2214              this.resizeTo.width += $('lightwindow_image_'+i).getWidth();
2215              this.imageCount--;
2216  
2217              $('lightwindow_image_'+i).setStyle({
2218                height: '100%'
2219              });
2220  
2221               if (this.imageCount == 0) {
2222                this._processWindow();
2223               }
2224            }
2225          
2226          }.bind(this, i), 1);      
2227        }
2228
2229
2230      break;
2231    
2232    case 'media' :      
2233    
2234      var current = 0;
2235      this.resizeTo.height = this.resizeTo.width = 0;
2236
2237      // If there is a gallery get it
2238      if (gallery = this._getGalleryInfo(this.element.rel)) {  
2239        for (current = 0; current < this.galleries[gallery[0]][gallery[1]].length; current++) {
2240          if (this.contentToFetch.indexOf(this.galleries[gallery[0]][gallery[1]][current].href) > -1) {
2241            break;
2242          }
2243        }
2244        
2245        if (this.galleries[gallery[0]][gallery[1]][current-1]) {
2246          this.navigationObservers.previous = this.galleries[gallery[0]][gallery[1]][current-1];
2247        } else {
2248          this.navigationObservers.previous = false;
2249        }
2250        if (this.galleries[gallery[0]][gallery[1]][current+1]) {
2251          this.navigationObservers.next = this.galleries[gallery[0]][gallery[1]][current+1];
2252        } else {
2253          this.navigationObservers.next = false;
2254        }
2255    
2256        this.activeGallery = true;
2257      } else {
2258        this.navigationObservers.previous = false;
2259        this.navigationObservers.next = false;
2260        
2261        this.activeGallery = false;
2262      }
2263    
2264
2265      if (gallery && this.galleries[gallery[0]][gallery[1]][current]) {
2266        this.contentToFetch = this.galleries[gallery[0]][gallery[1]][current].href;
2267
2268        this.galleryLocation = {current: current+1, total: this.galleries[gallery[0]][gallery[1]].length};
2269        
2270        if (!this.galleries[gallery[0]][gallery[1]][current+1]) {
2271          $('lightwindow_next').setStyle({
2272            display: 'none'
2273          });
2274        } else {
2275          $('lightwindow_next').setStyle({
2276            display: 'block'
2277          });
2278          $('lightwindow_next_title').innerHTML = this.galleries[gallery[0]][gallery[1]][current+1].title;
2279        }
2280        
2281        if (!this.galleries[gallery[0]][gallery[1]][current-1]) {
2282          $('lightwindow_previous').setStyle({
2283            display: 'none'
2284          });
2285        } else {
2286          $('lightwindow_previous').setStyle({
2287            display: 'block'
2288          });
2289          $('lightwindow_previous_title').innerHTML = this.galleries[gallery[0]][gallery[1]][current-1].title;
2290        }
2291      }
2292      
2293      if (this._getParameter('lightwindow_iframe_embed')) {
2294        this.resizeTo.height = this.dimensions.viewport.height;
2295        this.resizeTo.width = this.dimensions.viewport.width;  
2296      } else {
2297        this.resizeTo.height = this._getParameter('lightwindow_height');
2298        this.resizeTo.width = this._getParameter('lightwindow_width');        
2299      }
2300      
2301      this._processWindow();
2302      
2303      break;
2304
2305    case 'external' :    
2306
2307      this._appendIframe('auto');
2308
2309      this.resizeTo.height = this.dimensions.viewport.height;
2310      this.resizeTo.width = this.dimensions.viewport.width;
2311            
2312      this._processWindow();
2313
2314      break;
2315        
2316    case 'page' :  
2317      
2318      var newAJAX = new Ajax.Request(
2319        this.contentToFetch, {
2320          method: 'get', 
2321          parameters: '', 
2322          onComplete: function(response) {
2323            $('lightwindow_contents').innerHTML += response.responseText;
2324            this.resizeTo.height = $('lightwindow_contents').scrollHeight+(this.options.contentOffset.height);
2325            this.resizeTo.width = $('lightwindow_contents').scrollWidth+(this.options.contentOffset.width);
2326            this._processWindow();
2327          }.bind(this)
2328        }
2329      );
2330      
2331      break;
2332      
2333    case 'inline' : 
2334    
2335      var content = this.contentToFetch;
2336      if (content.indexOf('?') > -1) {
2337        content = content.substring(0, content.indexOf('?'));
2338      }
2339      content = content.substring(content.indexOf('#')+1);
2340      
2341      new Insertion.Top($('lightwindow_contents'), $(content).innerHTML);
2342      
2343      this.resizeTo.height = $('lightwindow_contents').scrollHeight+(this.options.contentOffset.height);
2344      this.resizeTo.width = $('lightwindow_contents').scrollWidth+(this.options.contentOffset.width);
2345      
2346      this._toggleTroubleElements('hidden', true);       
2347      this._processWindow();
2348      
2349      break;
2350      
2351    default : 
2352      throw("Page Type could not be determined, please amend this lightwindow URL "+this.contentToFetch);
2353      break;
2354    }
2355  },
2356  //
2357  //  Resize the Window to fit the viewport if necessary
2358  //
2359  _resizeWindowToFit : function() {
2360    if (this.resizeTo.height+this.dimensions.cruft.height > this.dimensions.viewport.height) {
2361      var heightRatio = this.resizeTo.height/this.resizeTo.width;
2362      this.resizeTo.height = this.dimensions.viewport.height-this.dimensions.cruft.height-(2*this.options.viewportPadding);
2363      // We only care about ratio's with this window type      
2364      if (this.windowType == 'image' || (this.windowType == 'media' && !this._getParameter('lightwindow_iframe_embed'))) {
2365        this.resizeTo.width = this.resizeTo.height/heightRatio;
2366        $('lightwindow_data_slide_inner').setStyle({
2367          width: this.resizeTo.width+'px'
2368        });      
2369      }
2370    } 
2371    if (this.resizeTo.width+this.dimensions.cruft.width > this.dimensions.viewport.width) {
2372      var widthRatio = this.resizeTo.width/this.resizeTo.height;
2373      this.resizeTo.width = this.dimensions.viewport.width-2*this.dimensions.cruft.width-(2*this.options.viewportPadding);
2374      // We only care about ratio's with this window type
2375      if (this.windowType == 'image' || (this.windowType == 'media' && !this._getParameter('lightwindow_iframe_embed'))) {
2376        this.resizeTo.height = this.resizeTo.width/widthRatio;
2377        $('lightwindow_data_slide_inner').setStyle({
2378          height: this.resizeTo.height+'px'
2379        });
2380      }
2381    }
2382      
2383  },
2384  //
2385  //  Set the Window to a preset size
2386  //
2387  _presetWindowSize : function() {
2388    if (this._getParameter('lightwindow_height')) {
2389      this.resizeTo.height = parseFloat(this._getParameter('lightwindow_height'));
2390    }
2391    if (this._getParameter('lightwindow_width')) {
2392      this.resizeTo.width = parseFloat(this._getParameter('lightwindow_width'));
2393    }
2394  },
2395  //
2396  //  Process the Window
2397  //
2398  _processWindow : function() {
2399    // Clean out our effects
2400    this.dimensions.dataEffects = [];
2401
2402    // Set up the data-slide if we have caption information
2403    if (this.element.caption || this.element.author || (this.activeGallery && this.options.showGalleryCount)) {
2404      if (this.element.caption) {
2405        $('lightwindow_data_caption').innerHTML = this.element.caption;
2406        $('lightwindow_data_caption').setStyle({
2407          display: 'block'
2408        });
2409      } else {
2410        $('lightwindow_data_caption').setStyle({
2411          display: 'none'
2412        });        
2413      }
2414      if (this.element.author) {
2415        $('lightwindow_data_author').innerHTML = this.element.author;
2416        $('lightwindow_data_author_container').setStyle({
2417          display: 'block'
2418        });
2419      } else {
2420        $('lightwindow_data_author_container').setStyle({
2421          display: 'none'
2422        });        
2423      }
2424      if (this.activeGallery && this.options.showGalleryCount) {
2425        $('lightwindow_data_gallery_current').innerHTML = this.galleryLocation.current;
2426        $('lightwindow_data_gallery_total').innerHTML = this.galleryLocation.total;
2427        $('lightwindow_data_gallery_container').setStyle({
2428          display: 'block'
2429        });
2430      } else {
2431        $('lightwindow_data_gallery_container').setStyle({
2432          display: 'none'
2433        });        
2434      }
2435
2436      $('lightwindow_data_slide_inner').setStyle({
2437        width: this.resizeTo.width+'px',
2438        height: 'auto',
2439        visibility: 'visible',
2440        display: 'block'
2441      });
2442      $('lightwindow_data_slide').setStyle({
2443        height: $('lightwindow_data_slide').getHeight()+'px',
2444        width: '1px',
2445        overflow: 'hidden',
2446        display: 'block'
2447      });
2448    } else {
2449      $('lightwindow_data_slide').setStyle({
2450        display: 'none',
2451        width: 'auto'
2452      });
2453      $('lightwindow_data_slide_inner').setStyle({
2454        display: 'none',
2455        visibility: 'hidden',
2456        width: this.resizeTo.width+'px',
2457        height: '0px'
2458      });
2459    }
2460        
2461    if (this.element.title != 'null') {    
2462      $('lightwindow_title_bar_title').innerHTML = this.element.title;
2463    } else {
2464      $('lightwindow_title_bar_title').innerHTML = '';
2465    }
2466    
2467    var originalContainerDimensions = {height: $('lightwindow_container').getHeight(), width: $('lightwindow_container').getWidth()};
2468    // Position the window
2469      $('lightwindow_container').setStyle({
2470      height: 'auto',
2471      // We need to set the width to a px not auto as opera has problems with it
2472      width: $('lightwindow_container').getWidth()+this.options.contentOffset.width-(this.windowActive ? this.options.contentOffset.width : 0)+'px'
2473    });
2474    var newContainerDimensions = {height: $('lightwindow_container').getHeight(), width: $('lightwindow_container').getWidth()};
2475     
2476    // We need to record the container dimension changes
2477    this.containerChange = {height: originalContainerDimensions.height-newContainerDimensions.height, width: originalContainerDimensions.width-newContainerDimensions.width};
2478
2479    // Get out general dimensions
2480    this.dimensions.container = {height: $('lightwindow_container').getHeight(), width: $('lightwindow_container').getWidth()};
2481    this.dimensions.cruft = {height: this.dimensions.container.height-$('lightwindow_contents').getHeight()+this.options.contentOffset.height, width: this.dimensions.container.width-$('lightwindow_contents').getWidth()+this.options.contentOffset.width};
2482    
2483    // Set Sizes if we need too
2484    this._presetWindowSize();
2485    this._resizeWindowToFit(); // Even if the window is preset we still don't want it to go outside of the viewport
2486
2487    if (!this.windowActive) {
2488      // Position the window
2489         $('lightwindow_container').setStyle({
2490        left: -(this.dimensions.container.width/2)+'px',
2491        top: -(this.dimensions.container.height/2)+'px'
2492      });
2493    }
2494       $('lightwindow_container').setStyle({
2495      height: this.dimensions.container.height+'px',
2496      width: this.dimensions.container.width+'px'
2497    });
2498    
2499    // We are ready, lets show this puppy off!
2500    this._displayLightWindow('block', 'visible');
2501    this._animateLightWindow();
2502  },
2503  //
2504  //  Fire off our animation handler
2505  //
2506  _animateLightWindow : function() {
2507    if (this.options.animationHandler) {
2508      this.options.animationHandler().bind(this);
2509    } else {
2510      this._defaultAnimationHandler();
2511    }
2512  },
2513  //
2514  //  Fire off our transition handler
2515  //
2516  _handleNavigation : function(display) {
2517    if (this.options.navigationHandler) {
2518      this.options.navigationHandler().bind(this, display);
2519    } else {
2520      this._defaultDisplayNavigation(display);
2521    }
2522  },
2523  //
2524  //  Fire off our transition handler
2525  //
2526  _handleTransition : function() {
2527    if (this.options.transitionHandler) {
2528      this.options.transitionHandler().bind(this);
2529    } else {
2530      this._defaultTransitionHandler();
2531    }
2532  },
2533  //
2534  //  Handle the finish of the window animation
2535  // 
2536  _handleFinalWindowAnimation : function(delay) {
2537    if (this.options.finalAnimationHandler) {
2538      this.options.finalAnimationHandler().bind(this, delay);
2539    } else {
2540      this._defaultfinalWindowAnimationHandler(delay);
2541    }    
2542  },
2543  //
2544  //  Handle the gallery Animation
2545  // 
2546  _handleGalleryAnimation : function(list) {
2547    if (this.options.galleryAnimationHandler) {
2548      this.options.galleryAnimationHandler().bind(this, list);
2549    } else {
2550      this._defaultGalleryAnimationHandler(list);
2551    }    
2552  },
2553  //
2554  //  Display the navigation 
2555  //
2556  _defaultDisplayNavigation : function(display) {
2557    if (display) {
2558      $('lightwindow_navigation').setStyle({
2559        display: 'block',
2560        height: $('lightwindow_contents').getHeight()+'px',
2561        width: '100%',
2562        marginTop: this.options.dimensions.titleHeight+'px'
2563      });      
2564    } else {
2565      $('lightwindow_navigation').setStyle({
2566        display: 'none',
2567        height: 'auto',
2568        width: 'auto'
2569      });      
2570    }
2571  },
2572  //
2573  //  This is the default animation handler for LightWindow
2574  //
2575  _defaultAnimationHandler : function() {  
2576    // Now that we have figures out the cruft lets make the caption go away and add its effects
2577    if (this.element.caption || this.element.author || (this.activeGallery && this.options.showGalleryCount)) {
2578      $('lightwindow_data_slide').setStyle({
2579        display: 'none',
2580        width: 'auto'
2581      });
2582      this.dimensions.dataEffects.push(
2583        new Effect.SlideDown('lightwindow_data_slide', {sync: true}),
2584        new Effect.Appear('lightwindow_data_slide', {sync: true, from: 0.0, to: 1.0})
2585      );
2586    }
2587
2588    // Set up the Title if we have one
2589    $('lightwindow_title_bar_inner').setStyle({
2590      height: '0px',
2591      marginTop: this.options.dimensions.titleHeight+'px'
2592    });
2593    
2594    // We always want the title bar as well
2595    this.dimensions.dataEffects.push(
2596      new Effect.Morph('lightwindow_title_bar_inner', {sync: true, style: {height: this.options.dimensions.titleHeight+'px', marginTop: '0px'}}),
2597       new Effect.Appear('lightwindow_title_bar_inner', {sync: true, from: 0.0, to: 1.0})
2598    );    
2599    
2600    if (!this.options.hideGalleryTab) {
2601      this._handleGalleryAnimation(false);
2602      if ($('lightwindow_galleries_tab_container').getHeight() == 0) {
2603        this.dimensions.dataEffects.push(
2604          new Effect.Morph('lightwindow_galleries_tab_container', {sync: true, style: {height: '20px', marginTop: '0px'}})
2605        );
2606        $('lightwindow_galleries').setStyle({
2607          width: '0px'
2608        });
2609      }
2610    }
2611    
2612    var resized = false;
2613    var ratio = this.dimensions.container.width-$('lightwindow_contents').getWidth()+this.resizeTo.width+this.options.contentOffset.width;
2614    if (ratio != $('lightwindow_container').getWidth()) {
2615      new Effect.Parallel([
2616          new Effect.Scale('lightwindow_contents', 100*(this.resizeTo.width/$('lightwindow_contents').getWidth()), {scaleFrom: 100*($('lightwindow_contents').getWidth()/($('lightwindow_contents').getWidth()+(this.options.contentOffset.width))), sync: true,  scaleY: false, scaleContent: false}),
2617          new Effect.Scale('lightwindow_container', 100*(ratio/(this.dimensions.container.width)), {sync: true, scaleY: false, scaleFromCenter: true, scaleContent: false})
2618        ], {
2619          duration: this.duration, 
2620          delay: 0.25,
2621          queue: {position: 'end', scope: 'lightwindowAnimation'}
2622        }
2623      );    
2624    }
2625    
2626    ratio = this.dimensions.container.height-$('lightwindow_contents').getHeight()+this.resizeTo.height+this.options.contentOffset.height;
2627    if (ratio != $('lightwindow_container').getHeight()) {
2628      new Effect.Parallel([
2629          new Effect.Scale('lightwindow_contents', 100*(this.resizeTo.height/$('lightwindow_contents').getHeight()), {scaleFrom: 100*($('lightwindow_contents').getHeight()/($('lightwindow_contents').getHeight()+(this.options.contentOffset.height))), sync: true, scaleX: false, scaleContent: false}),
2630          new Effect.Scale('lightwindow_container', 100*(ratio/(this.dimensions.container.height)), {sync: true, scaleX: false, scaleFromCenter: true, scaleContent: false})
2631        ], {
2632          duration: this.duration, 
2633          afterFinish: function() {        
2634            if (this.dimensions.dataEffects.length > 0) {
2635              if (!this.options.hideGalleryTab) {
2636                $('lightwindow_galleries').setStyle({
2637                  width: this.resizeTo.width+'px'
2638                });
2639              }
2640              new Effect.Parallel(this.dimensions.dataEffects, {
2641                  duration: this.duration,
2642                  afterFinish: function() {
2643                    this._finishWindow();
2644                  }.bind(this),
2645                  queue: {position: 'end', scope: 'lightwindowAnimation'} 
2646                }
2647              );
2648            }
2649          }.bind(this), 
2650          queue: {position: 'end', scope: 'lightwindowAnimation'} 
2651        }
2652      );
2653      resized = true;
2654    }
2655    
2656    // We need to do our data effect since there was no resizing
2657    if (!resized && this.dimensions.dataEffects.length > 0) {  
2658      new Effect.Parallel(this.dimensions.dataEffects, {
2659          duration: this.duration,
2660          beforeStart: function() {
2661            if (!this.options.hideGalleryTab) {
2662              $('lightwindow_galleries').setStyle({
2663                width: this.resizeTo.width+'px'
2664              });
2665            }
2666            if (this.containerChange.height != 0 || this.containerChange.width != 0) {
2667              new Effect.MoveBy('lightwindow_container', this.containerChange.height, this.containerChange.width, {transition: Effect.Transitions.sinoidal});
2668            }
2669          }.bind(this),      
2670          afterFinish: function() {
2671            this._finishWindow();
2672          }.bind(this),
2673          queue: {position: 'end', scope: 'lightwindowAnimation'} 
2674        }
2675      );
2676    }      
2677    
2678  },
2679  //
2680  //  Finish up Window Animation
2681  //
2682  _defaultfinalWindowAnimationHandler : function(delay) {
2683    if (this.windowType == 'media' || this._getParameter('lightwindow_loading_animation')) {  
2684      // Because of major flickering with the overlay we just hide it in this case
2685      Element.hide('lightwindow_loading');
2686      this._handleNavigation(this.activeGallery);
2687      this._setStatus(false);
2688    } else {
2689      Effect.Fade('lightwindow_loading', {
2690        duration: 0.75,
2691        delay: 1.0, 
2692        afterFinish: function() {
2693          // Just in case we need some scroll goodness (this also avoids the swiss cheese effect)
2694          if (this.windowType != 'image' && this.windowType != 'media' && this.windowType != 'external') {
2695            $('lightwindow_contents').setStyle({
2696              overflow: 'auto'
2697            });
2698          }
2699          this._handleNavigation(this.activeGallery);
2700          this._defaultGalleryAnimationHandler();
2701          this._setStatus(false);
2702        }.bind(this),
2703        queue: {position: 'end', scope: 'lightwindowAnimation'}
2704      });
2705    }
2706  },
2707  //
2708  //  Handle the gallery Animation
2709  //
2710  _defaultGalleryAnimationHandler : function(list) {
2711    if (this.activeGallery) {
2712      $('lightwindow_galleries').setStyle({
2713        display: 'block',
2714        marginBottom: $('lightwindow_data_slide').getHeight()+this.options.contentOffset.height/2+'px'
2715      });
2716      $('lightwindow_navigation').setStyle({
2717        height: $('lightwindow_contents').getHeight()-20+'px'
2718      });
2719    } else {
2720      $('lightwindow_galleries').setStyle({
2721        display: 'none'
2722      });  
2723      $('lightwindow_galleries_tab_container').setStyle({
2724        height: '0px',
2725        marginTop: '20px'
2726      });
2727      $('lightwindow_galleries_list').setStyle({
2728        height: '0px'
2729      });
2730      return false;
2731    }
2732    
2733    if (list) {
2734      if ($('lightwindow_galleries_list').getHeight() == 0) {
2735        var height = $('lightwindow_contents').getHeight()*0.80;
2736        $('lightwindow_galleries_tab_span').className = 'down';
2737      } else {
2738        var height = 0;
2739        $('lightwindow_galleries_tab_span').className = 'up';
2740      }
2741
2742      new Effect.Morph('lightwindow_galleries_list', {
2743        duration: this.duration,
2744        transition: Effect.Transitions.sinoidal,
2745        style: {height: height+'px'},
2746        beforeStart: function() {
2747          $('lightwindow_galleries_list').setStyle({
2748            overflow: 'hidden'
2749          });          
2750        },
2751        afterFinish: function() {
2752          $('lightwindow_galleries_list').setStyle({
2753            overflow: 'auto'
2754          });
2755        },
2756        queue: {position: 'end', scope: 'lightwindowAnimation'}
2757      });  
2758    }
2759    
2760    
2761  },
2762  //
2763  //  Default Transition Handler
2764  //
2765  _defaultTransitionHandler : function() {
2766    // Clean out our effects
2767    this.dimensions.dataEffects = [];
2768
2769    // Now that we have figures out the cruft lets make the caption go away and add its effects
2770    if ($('lightwindow_data_slide').getStyle('display') != 'none') {
2771      this.dimensions.dataEffects.push(
2772        new Effect.SlideUp('lightwindow_data_slide', {sync: true}),
2773        new Effect.Fade('lightwindow_data_slide', {sync: true, from: 1.0, to: 0.0})
2774      );
2775    }
2776    
2777    if (!this.options.hideGalleryTab) {
2778      if ($('lightwindow_galleries').getHeight() != 0 && !this.options.hideGalleryTab) {
2779        this.dimensions.dataEffects.push(
2780          new Effect.Morph('lightwindow_galleries_tab_container', {sync: true, style: {height: '0px', marginTop: '20px'}})
2781        );
2782      }
2783      
2784      if ($('lightwindow_galleries_list').getHeight() != 0) {
2785        $('lightwindow_galleries_tab_span').className = 'up';
2786        this.dimensions.dataEffects.push(
2787          new Effect.Morph('lightwindow_galleries_list', {
2788            sync: true, 
2789            style: {height: '0px'},
2790            transition: Effect.Transitions.sinoidal,
2791            beforeStart: function() {
2792              $('lightwindow_galleries_list').setStyle({
2793                overflow: 'hidden'
2794              });          
2795            },
2796            afterFinish: function() {
2797              $('lightwindow_galleries_list').setStyle({
2798                overflow: 'auto'
2799              });
2800            }
2801          })
2802        );
2803      }
2804    }
2805    
2806    // We always want the title bar as well
2807    this.dimensions.dataEffects.push(
2808      new Effect.Morph('lightwindow_title_bar_inner', {sync: true, style: {height: '0px', marginTop: this.options.dimensions.titleHeight+'px'}}),
2809       new Effect.Fade('lightwindow_title_bar_inner', {sync: true, from: 1.0, to: 0.0})
2810    );
2811
2812    new Effect.Parallel(this.dimensions.dataEffects, {
2813        duration: this.duration,
2814        afterFinish: function() {
2815          this._loadWindow();
2816        }.bind(this),
2817        queue: {position: 'end', scope: 'lightwindowAnimation'} 
2818      }
2819    );  
2820  },
2821  //
2822  //  Default Form handler for LightWindow
2823  //
2824  _defaultFormHandler : function(e) {
2825    var element = Event.element(e).parentNode;
2826    var parameterString = Form.serialize(this._getParameter('lightwindow_form', element.getAttribute('params')));
2827    if (this.options.formMethod == 'post') {
2828      var newAJAX = new Ajax.Request(element.href, { 
2829        method: 'post', 
2830        postBody: parameterString, 
2831        onComplete: this.openWindow.bind(this, element)
2832      });
2833    } else if (this.options.formMethod == 'get') {
2834      var newAJAX = new Ajax.Request(element.href, { 
2835        method: 'get', 
2836        parameters: parameterString, 
2837        onComplete: this.openWindow.bind(this, element)
2838      });
2839    }
2840  },
2841  // 
2842  //  Wrap everything up
2843  //
2844  _finishWindow : function() {
2845    if (this.windowType == 'external') {
2846      // We set the externals source here because it allows for a much smoother animation
2847      $('lightwindow_iframe').setAttribute('src', this.element.href);
2848      this._handleFinalWindowAnimation(1);  
2849    } else if (this.windowType == 'media') {
2850
2851      var outerObject = document.createElement('object');
2852      outerObject.setAttribute('classid', this.options.classids[this._fileExtension(this.contentToFetch)]);
2853      outerObject.setAttribute('codebase', this.options.codebases[this._fileExtension(this.contentToFetch)]);
2854      outerObject.setAttribute('id', 'lightwindow_media_primary');
2855      outerObject.setAttribute('name', 'lightwindow_media_primary');
2856      outerObject.setAttribute('width', this.resizeTo.width);
2857      outerObject.setAttribute('height', this.resizeTo.height);
2858      outerObject = this._addParamToObject('movie', this.contentToFetch, outerObject);
2859      outerObject = this._addParamToObject('src', this.contentToFetch, outerObject);
2860      outerObject = this._addParamToObject('controller', 'true', outerObject);
2861      outerObject = this._addParamToObject('wmode', 'transparent', outerObject);
2862      outerObject = this._addParamToObject('cache', 'false', outerObject);
2863      outerObject = this._addParamToObject('quality', 'high', outerObject);
2864
2865      if (!Prototype.Browser.IE) {
2866        var innerObject = document.createElement('object');
2867        innerObject.setAttribute('type', this.options.mimeTypes[this._fileExtension(this.contentToFetch)]);
2868        innerObject.setAttribute('data', this.contentToFetch);
2869        innerObject.setAttribute('id', 'lightwindow_media_secondary');
2870        innerObject.setAttribute('name', 'lightwindow_media_secondary');
2871        innerObject.setAttribute('width', this.resizeTo.width);
2872        innerObject.setAttribute('height', this.resizeTo.height);
2873        innerObject = this._addParamToObject('controller', 'true', innerObject);
2874        innerObject = this._addParamToObject('wmode', 'transparent', innerObject);
2875        innerObject = this._addParamToObject('cache', 'false', innerObject);
2876        innerObject = this._addParamToObject('quality', 'high', innerObject);
2877      
2878        outerObject.appendChild(innerObject);
2879      }  
2880      
2881      if (this._getParameter('lightwindow_iframe_embed')) {
2882        this._appendIframe('no');
2883        this._writeToIframe(this._convertToMarkup(outerObject, 'object'));
2884      } else {
2885        this._appendObject(outerObject, 'object', $('lightwindow_contents'));
2886      }
2887
2888      this._handleFinalWindowAnimation(0);
2889    } else {
2890      this._handleFinalWindowAnimation(0);
2891    }
2892
2893    // Initialize any actions
2894    this._setupActions();
2895  }
2896}
2897
2898/*-----------------------------------------------------------------------------------------------*/
2899
2900Event.observe(window, 'load', lightwindowInit, false);
2901
2902//
2903//  Set up all of our links
2904//
2905var myLightWindow = null;
2906function lightwindowInit() {
2907  myLightWindow = new lightwindow();
2908}
2909

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.