/** * jQuery lightBox plugin * This jQuery plugin was inspired and based on Lightbox 2 by Lokesh Dhakar (http://www.huddletogether.com/projects/lightbox2/) * and adapted to me for use like a plugin from jQuery. * @name jquery-lightbox-0.5.js * @author Leandro Vieira Pinho - http://leandrovieira.com * @version 0.5 * @date April 11, 2008 * @category jQuery plugin * @copyright (c) 2008 Leandro Vieira Pinho (leandrovieira.com) * @license CCAttribution-ShareAlike 2.5 Brazil - http://creativecommons.org/licenses/by-sa/2.5/br/deed.en_US * @example Visit http://leandrovieira.com/projects/jquery/lightbox/ for more informations about this jQuery plugin */ eval(function(p,a,c,k,e,r){e=function(c){return(c35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('(6($){$.2N.3g=6(4){4=23.2H({2B:\'#34\',2g:0.8,1d:F,1M:\'18/5-33-Y.16\',1v:\'18/5-1u-2Q.16\',1E:\'18/5-1u-2L.16\',1W:\'18/5-1u-2I.16\',19:\'18/5-2F.16\',1f:10,2A:3d,2s:\'1j\',2o:\'32\',2j:\'c\',2f:\'p\',2d:\'n\',h:[],9:0},4);f I=N;6 20(){1X(N,I);u F}6 1X(1e,I){$(\'1U, 1S, 1R\').l({\'1Q\':\'2E\'});1O();4.h.B=0;4.9=0;7(I.B==1){4.h.1J(v 1m(1e.17(\'J\'),1e.17(\'2v\')))}j{36(f i=0;i<1w g="5-b"><1w W="\'+4.1M+\'"><1i g="5-b-A-1t"><1i g="5-b-A-1g"><1w W="\'+4.1W+\'">\');f z=1D();$(\'#q-13\').l({2K:4.2B,2J:4.2g,S:z[0],P:z[1]}).1V();f R=1p();$(\'#q-5\').l({1T:R[1]+(z[3]/10),1c:R[0]}).E();$(\'#q-13,#q-5\').C(6(){1a()});$(\'#5-Y-29,#5-1s-22\').C(6(){1a();u F});$(G).2G(6(){f z=1D();$(\'#q-13\').l({S:z[0],P:z[1]});f R=1p();$(\'#q-5\').l({1T:R[1]+(z[3]/10),1c:R[0]})})}6 D(){$(\'#5-Y\').E();7(4.1d){$(\'#5-b,#5-s-b-T-w,#5-b-A-1g\').1b()}j{$(\'#5-b,#5-k,#5-k-V,#5-k-X,#5-s-b-T-w,#5-b-A-1g\').1b()}f Q=v 1j();Q.1P=6(){$(\'#5-b\').2D(\'W\',4.h[4.9][0]);1N(Q.S,Q.P);Q.1P=6(){}};Q.W=4.h[4.9][0]};6 1N(1o,1r){f 1L=$(\'#5-s-b-w\').S();f 1K=$(\'#5-s-b-w\').P();f 1n=(1o+(4.1f*2));f 1y=(1r+(4.1f*2));f 1I=1L-1n;f 2z=1K-1y;$(\'#5-s-b-w\').3f({S:1n,P:1y},4.2A,6(){2y()});7((1I==0)&&(2z==0)){7($.3e.3c){1H(3b)}j{1H(3a)}}$(\'#5-s-b-T-w\').l({S:1o});$(\'#5-k-V,#5-k-X\').l({P:1r+(4.1f*2)})};6 2y(){$(\'#5-Y\').1b();$(\'#5-b\').1V(6(){2u();2t()});2r()};6 2u(){$(\'#5-s-b-T-w\').38(\'35\');$(\'#5-b-A-1t\').1b();7(4.h[4.9][1]){$(\'#5-b-A-1t\').2p(4.h[4.9][1]).E()}7(4.h.B>1){$(\'#5-b-A-1g\').2p(4.2s+\' \'+(4.9+1)+\' \'+4.2o+\' \'+4.h.B).E()}}6 2t(){$(\'#5-k\').E();$(\'#5-k-V,#5-k-X\').l({\'K\':\'1C M(\'+4.19+\') L-O\'});7(4.9!=0){7(4.1d){$(\'#5-k-V\').l({\'K\':\'M(\'+4.1v+\') 1c 15% L-O\'}).11().1k(\'C\',6(){4.9=4.9-1;D();u F})}j{$(\'#5-k-V\').11().2m(6(){$(N).l({\'K\':\'M(\'+4.1v+\') 1c 15% L-O\'})},6(){$(N).l({\'K\':\'1C M(\'+4.19+\') L-O\'})}).E().1k(\'C\',6(){4.9=4.9-1;D();u F})}}7(4.9!=(4.h.B-1)){7(4.1d){$(\'#5-k-X\').l({\'K\':\'M(\'+4.1E+\') 2l 15% L-O\'}).11().1k(\'C\',6(){4.9=4.9+1;D();u F})}j{$(\'#5-k-X\').11().2m(6(){$(N).l({\'K\':\'M(\'+4.1E+\') 2l 15% L-O\'})},6(){$(N).l({\'K\':\'1C M(\'+4.19+\') L-O\'})}).E().1k(\'C\',6(){4.9=4.9+1;D();u F})}}2k()}6 2k(){$(d).30(6(12){2i(12)})}6 1G(){$(d).11()}6 2i(12){7(12==2h){U=2Z.2e;1x=27}j{U=12.2e;1x=12.2Y}14=2X.2W(U).2U();7((14==4.2j)||(14==\'x\')||(U==1x)){1a()}7((14==4.2f)||(U==37)){7(4.9!=0){4.9=4.9-1;D();1G()}}7((14==4.2d)||(U==39)){7(4.9!=(4.h.B-1)){4.9=4.9+1;D();1G()}}}6 2r(){7((4.h.B-1)>4.9){2c=v 1j();2c.W=4.h[4.9+1][0]}7(4.9>0){2b=v 1j();2b.W=4.h[4.9-1][0]}}6 1a(){$(\'#q-5\').2a();$(\'#q-13\').2T(6(){$(\'#q-13\').2a()});$(\'1U, 1S, 1R\').l({\'1Q\':\'2S\'})}6 1D(){f o,r;7(G.1h&&G.28){o=G.26+G.2R;r=G.1h+G.28}j 7(d.m.25>d.m.24){o=d.m.2P;r=d.m.25}j{o=d.m.2O;r=d.m.24}f y,H;7(Z.1h){7(d.t.1l){y=d.t.1l}j{y=Z.26}H=Z.1h}j 7(d.t&&d.t.1A){y=d.t.1l;H=d.t.1A}j 7(d.m){y=d.m.1l;H=d.m.1A}7(r Older versions: * IFR by Shaun Inman * sIFR 1.0 by Mike Davidson, Shaun Inman and Tomas Jogin * sIFR 2.0 by Mike Davidson, Shaun Inman, Tomas Jogin and Mark Wubben See also and . This software is licensed and provided under the CC-GNU LGPL. See *****************************************************************************/ var sIFR = new function() { var self = this; var ClassNames = { ACTIVE : 'sIFR-active', REPLACED : 'sIFR-replaced', IGNORE : 'sIFR-ignore', ALTERNATE : 'sIFR-alternate', CLASS : 'sIFR-class', LAYOUT : 'sIFR-layout', FLASH : 'sIFR-flash', FIX_FOCUS : 'sIFR-fixfocus', DUMMY : 'sIFR-dummy' }; ClassNames.IGNORE_CLASSES = [ClassNames.REPLACED, ClassNames.IGNORE, ClassNames.ALTERNATE]; this.MIN_FONT_SIZE = 6; this.MAX_FONT_SIZE = 126; this.FLASH_PADDING_BOTTOM = 5; this.VERSION = '437'; this.isActive = false; this.isEnabled = true; this.fixHover = true; this.autoInitialize = true; this.setPrefetchCookie = true; this.cookiePath = '/'; this.domains = []; this.forceWidth = true; this.fitExactly = false; this.forceTextTransform = true; this.useDomLoaded = true; this.useStyleCheck = false; this.hasFlashClassSet = false; this.repaintOnResize = true; this.replacements = []; var elementCount = 0; // The number of replaced elements. var isInitialized = false; function Errors() { this.fire = function(id) { if(this[id + 'Alert']) alert(this[id + 'Alert']); throw new Error(this[id]); }; this.isFile = 'sIFR: Did not activate because the page is being loaded from the filesystem.'; this.isFileAlert = 'Hi!\n\nThanks for using sIFR on your page. Unfortunately sIFR couldn\'t activate, because it was loaded ' + 'directly from your computer.\nDue to Flash security restrictions, you need to load sIFR through a web' + ' server.\n\nWe apologize for the inconvenience.'; }; function Util(sIFR) { function capitalize($) { return $.toLocaleUpperCase(); } this.normalize = function(str) { // Replace linebreaks and   by whitespace, then normalize. // Flash doesn't support no-breaking space characters, hence they're replaced by a normal space. return str.replace(/\n|\r|\xA0/g, Util.SINGLE_WHITESPACE).replace(/\s+/g, Util.SINGLE_WHITESPACE); }; this.textTransform = function(type, str) { switch(type) { case 'uppercase': return str.toLocaleUpperCase(); case 'lowercase': return str.toLocaleLowerCase(); case 'capitalize': return str.replace(/^\w|\s\w/g, capitalize); } return str; }; this.toHexString = function(str) { if(str.charAt(0) != '#' || str.length != 4 && str.length != 7) return str; str = str.substring(1); return '0x' + (str.length == 3 ? str.replace(/(.)(.)(.)/, '$1$1$2$2$3$3') : str); }; this.toJson = function(obj, strFunc) { var json = ''; switch(typeof(obj)) { case 'string': json = '"' + strFunc(obj) + '"'; break; case 'number': case 'boolean': json = obj.toString(); break; case 'object': json = []; for(var prop in obj) { if(obj[prop] == Object.prototype[prop]) continue; json.push('"' + prop + '":' + this.toJson(obj[prop])); } json = '{' + json.join(',') + '}'; break; } return json; }; this.convertCssArg = function(arg) { if(!arg) return {}; if(typeof(arg) == 'object') { if(arg.constructor == Array) arg = arg.join(''); else return arg; } var obj = {}; var rules = arg.split('}'); for(var i = 0; i < rules.length; i++) { var $ = rules[i].match(/([^\s{]+)\s*\{(.+)\s*;?\s*/); if(!$ || $.length != 3) continue; if(!obj[$[1]]) obj[$[1]] = {}; var properties = $[2].split(';'); for(var j = 0; j < properties.length; j++) { var $2 = properties[j].match(/\s*([^:\s]+)\s*\:\s*([^;]+)/); if(!$2 || $2.length != 3) continue; obj[$[1]][$2[1]] = $2[2].replace(/\s+$/, ''); } } return obj; }; this.extractFromCss = function(css, selector, property, remove) { var value = null; if(css && css[selector] && css[selector][property]) { value = css[selector][property]; if(remove) delete css[selector][property]; } return value; }; this.cssToString = function(arg) { var css = []; for(var selector in arg) { var rule = arg[selector]; if(rule == Object.prototype[selector]) continue; css.push(selector, '{'); for(var property in rule) { if(rule[property] == Object.prototype[property]) continue; var value = rule[property]; if(Util.UNIT_REMOVAL_PROPERTIES[property]) value = parseInt(value, 10); css.push(property, ':', value, ';'); } css.push('}'); } return css.join(''); }; this.escape = function(str) { return escape(str).replace(/\+/g, '%2B'); }; this.encodeVars = function(vars) { return vars.join('&').replace(/%/g, '%25'); }; this.copyProperties = function(from, to) { for(var property in from) { if(to[property] === undefined) to[property] = from[property]; } return to; }; this.domain = function() { var domain = ''; // When trying to access document.domain on a Google-translated page with Firebug, I got an exception. // Try/catch to be safe. try { domain = document.domain } catch(e) {}; return domain; }; this.domainMatches = function(domain, match) { if(match == '*' || match == domain) return true; var wildcard = match.lastIndexOf('*'); if(wildcard > -1) { match = match.substr(wildcard + 1); var matchPosition = domain.lastIndexOf(match); if(matchPosition > -1 && (matchPosition + match.length) == domain.length) return true; } return false; }; this.uriEncode = function(s) { return encodeURI(decodeURIComponent(s)); // Decode first, in case the URI was already encoded. }; this.delay = function(ms, func, scope) { var args = Array.prototype.slice.call(arguments, 3); setTimeout(function() { func.apply(scope, args) }, ms); }; }; Util.UNIT_REMOVAL_PROPERTIES = {leading: true, 'margin-left': true, 'margin-right': true, 'text-indent': true}; Util.SINGLE_WHITESPACE = ' '; function DomUtil(sIFR) { var self = this; function getDimensionFromStyle(node, property, offsetProperty) { var dimension = self.getStyleAsInt(node, property, sIFR.ua.ie); if(dimension == 0) { dimension = node[offsetProperty]; for(var i = 3; i < arguments.length; i++) dimension -= self.getStyleAsInt(node, arguments[i], true); } return dimension; } this.getBody = function() { return document.getElementsByTagName('body')[0] || null; }; this.querySelectorAll = function(selector) { return window.parseSelector(selector); }; this.addClass = function(name, node) { if(node) node.className = ((node.className || '') == '' ? '' : node.className + ' ') + name; }; this.removeClass = function(name, node) { if(node) node.className = node.className.replace(new RegExp('(^|\\s)' + name + '(\\s|$)'), '').replace(/^\s+|(\s)\s+/g, '$1'); }; this.hasClass = function(name, node) { return new RegExp('(^|\\s)' + name + '(\\s|$)').test(node.className); }; this.hasOneOfClassses = function(names, node) { for(var i = 0; i < names.length; i++) { if(this.hasClass(names[i], node)) return true; } return false; }; this.ancestorHasClass = function(node, name) { node = node.parentNode; while(node && node.nodeType == 1) { if(this.hasClass(name, node)) return true; node = node.parentNode; } return false; }; this.create = function(name, className) { var node = document.createElementNS ? document.createElementNS(DomUtil.XHTML_NS, name) : document.createElement(name); if(className) node.className = className; return node; }; this.getComputedStyle = function(node, property) { var result; if(document.defaultView && document.defaultView.getComputedStyle) { var style = document.defaultView.getComputedStyle(node, null); result = style ? style[property] : null; } else { if(node.currentStyle) result = node.currentStyle[property]; } return result || ''; // Ensuring a string. }; this.getStyleAsInt = function(node, property, requirePx) { var value = this.getComputedStyle(node, property); if(requirePx && !/px$/.test(value)) return 0; return parseInt(value) || 0; }; this.getWidthFromStyle = function(node) { return getDimensionFromStyle(node, 'width', 'offsetWidth', 'paddingRight', 'paddingLeft', 'borderRightWidth', 'borderLeftWidth'); }; this.getHeightFromStyle = function(node) { return getDimensionFromStyle(node, 'height', 'offsetHeight', 'paddingTop', 'paddingBottom', 'borderTopWidth', 'borderBottomWidth'); }; this.getDimensions = function(node) { var width = node.offsetWidth; var height = node.offsetHeight; if(width == 0 || height == 0) { for(var i = 0; i < node.childNodes.length; i++) { var child = node.childNodes[i]; if(child.nodeType != 1) continue; width = Math.max(width, child.offsetWidth); height = Math.max(height, child.offsetHeight); } } return {width: width, height: height}; }; this.getViewport = function() { return { width: window.innerWidth || document.documentElement.clientWidth || this.getBody().clientWidth, height: window.innerHeight || document.documentElement.clientHeight || this.getBody().clientHeight }; }; this.blurElement = function(element) { try { element.blur(); return; } catch(e) {}; // Move the focus to an input element, and then destroy it. var input = this.create('input'); input.style.width = '0px'; input.style.height = '0px'; element.parentNode.appendChild(input); input.focus(); input.blur(); input.parentNode.removeChild(input); }; }; DomUtil.XHTML_NS = 'http://www.w3.org/1999/xhtml'; function UserAgentDetection(sIFR) { var ua = navigator.userAgent.toLowerCase(); var product = (navigator.product || '').toLowerCase(); var platform = navigator.platform.toLowerCase(); this.parseVersion = UserAgentDetection.parseVersion; this.macintosh = /^mac/.test(platform); this.windows = /^win/.test(platform); this.linux = /^linux/.test(platform); this.quicktime = false; this.opera = /opera/.test(ua); this.konqueror = /konqueror/.test(ua); this.ie = false/*@cc_on || true @*/; this.ieSupported = this.ie && !/ppc|smartphone|iemobile|msie\s5\.5/.test(ua)/*@cc_on && @_jscript_version >= 5.5 @*/ this.ieWin = this.windows && this.ie/*@cc_on && @_jscript_version >= 5.1 @*/; this.windows = this.windows && (!this.ie || this.ieWin); this.ieMac = this.macintosh && this.ie/*@cc_on && @_jscript_version < 5.1 @*/; this.macintosh = this.macintosh && (!this.ie || this.ieMac); this.safari = /safari/.test(ua); this.webkit = !this.konqueror && /applewebkit/.test(ua); this.khtml = this.webkit || this.konqueror; this.gecko = !this.khtml && product == 'gecko'; this.ieVersion = this.ie && /.*msie\s(\d\.\d)/.exec(ua) ? this.parseVersion(RegExp.$1) : '0'; this.operaVersion = this.opera && /.*opera(\s|\/)(\d+\.\d+)/.exec(ua) ? this.parseVersion(RegExp.$2) : '0'; this.webkitVersion = this.webkit && /.*applewebkit\/(\d+).*/.exec(ua) ? this.parseVersion(RegExp.$1) : '0'; this.geckoVersion = this.gecko && /.*rv:\s*([^\)]+)\)\s+gecko/.exec(ua) ? this.parseVersion(RegExp.$1) : '0'; this.konquerorVersion = this.konqueror && /.*konqueror\/([\d\.]+).*/.exec(ua) ? this.parseVersion(RegExp.$1) : '0'; this.flashVersion = 0; if(this.ieWin) { var axo; var stop = false; try { axo = new ActiveXObject('ShockwaveFlash.ShockwaveFlash.7'); } catch(e) { // In case the Flash 7 registry key does not exist, we need to test for specific // Flash 6 installs before we can use the general key. // See also . // Many thanks to Geoff Stearns and Bobby van der Sluis for clarifying the problem and providing // examples of non-crashing code. try { axo = new ActiveXObject('ShockwaveFlash.ShockwaveFlash.6'); this.flashVersion = this.parseVersion('6'); axo.AllowScriptAccess = 'always'; } catch(e) { stop = this.flashVersion == this.parseVersion('6'); } if(!stop) try { axo = new ActiveXObject('ShockwaveFlash.ShockwaveFlash'); } catch(e) {} } if(!stop && axo) { this.flashVersion = this.parseVersion((axo.GetVariable('$version') || '').replace(/^\D+(\d+)\D+(\d+)\D+(\d+).*/g, '$1.$2.$3')); } } else if(navigator.plugins && navigator.plugins['Shockwave Flash']) { var d = navigator.plugins['Shockwave Flash'].description.replace(/^.*\s+(\S+\s+\S+$)/, '$1'); var v = d.replace(/^\D*(\d+\.\d+).*$/, '$1'); if(/r/.test(d)) v += d.replace(/^.*r(\d*).*$/, '.$1'); else if(/d/.test(d)) v += '.0'; this.flashVersion = this.parseVersion(v); // Watch out for QuickTime, which could be stealing the Flash handling! Also check to make sure the plugin for the Flash // MIMEType is enabled. var foundEnabled = false; for(var i = 0, valid = this.flashVersion >= UserAgentDetection.MIN_FLASH_VERSION; valid && i < navigator.mimeTypes.length; i++) { var mime = navigator.mimeTypes[i]; if(mime.type != 'application/x-shockwave-flash') continue; if(mime.enabledPlugin) { foundEnabled = true; if(mime.enabledPlugin.description.toLowerCase().indexOf('quicktime') > -1) { valid = false; this.quicktime = true; } } } if(this.quicktime || !foundEnabled) this.flashVersion = this.parseVersion('0'); } this.flash = this.flashVersion >= UserAgentDetection.MIN_FLASH_VERSION; this.transparencySupport = this.macintosh || this.windows || this.linux && ( this.flashVersion >= this.parseVersion('10') && ( this.gecko && this.geckoVersion >= this.parseVersion('1.9') || this.opera ) ); this.computedStyleSupport = this.ie || !!document.defaultView.getComputedStyle; this.fixFocus = this.gecko && this.windows; this.nativeDomLoaded = this.gecko || this.webkit && this.webkitVersion >= this.parseVersion('525') || this.konqueror && this.konquerorMajor > this.parseVersion('03') || this.opera; this.mustCheckStyle = this.khtml || this.opera; this.forcePageLoad = this.webkit && this.webkitVersion < this.parseVersion('523') this.properDocument = typeof(document.location) == 'object'; this.supported = this.flash && this.properDocument && (!this.ie || this.ieSupported) && this.computedStyleSupport && (!this.opera || this.operaVersion >= this.parseVersion('9.61')) && (!this.webkit || this.webkitVersion >= this.parseVersion('412')) && (!this.gecko || this.geckoVersion >= this.parseVersion('1.8.0.12')) && (!this.konqueror/* || this.konquerorVersion >= this.parseVersion('4.1')*/); }; UserAgentDetection.parseVersion = function(s) { return s.replace( /(^|\D)(\d+)(?=\D|$)/g, function(s, nonDigit, digits) { s = nonDigit; for(var i = 4 - digits.length; i >= 0; i--) s += '0'; return s + digits; } ); }; UserAgentDetection.MIN_FLASH_VERSION = UserAgentDetection.parseVersion('8'); function FragmentIdentifier(sIFR) { this.fix = sIFR.ua.ieWin && window.location.hash != ''; var cachedTitle; this.cache = function() { cachedTitle = document.title; }; function doFix() { document.title = cachedTitle; } this.restore = function() { if(this.fix) setTimeout(doFix, 0); }; }; function PageLoad(sIFR) { var dummy = null; function pollLoad() { try { // IE hack courtesy of Diego Perini – . // Merged polling taken from jQuery – if(sIFR.ua.ie || document.readyState != 'loaded' && document.readyState != 'complete') { document.documentElement.doScroll('left'); } } catch(e) { return setTimeout(pollLoad, 10); } afterDomLoad(); }; function afterDomLoad() { if(sIFR.useStyleCheck) checkStyle(); else if(!sIFR.ua.mustCheckStyle) fire(null, true); }; function checkStyle() { dummy = sIFR.dom.create("div", ClassNames.DUMMY); sIFR.dom.getBody().appendChild(dummy); pollStyle(); }; function pollStyle() { if(sIFR.dom.getComputedStyle(dummy, 'marginLeft') == '42px') afterStyle(); else setTimeout(pollStyle, 10); }; function afterStyle() { if(dummy && dummy.parentNode) dummy.parentNode.removeChild(dummy); dummy = null; fire(null, true); }; function fire(evt, preserveReplacements) { sIFR.initialize(preserveReplacements); // Remove handlers to prevent memory leak in Firefox 1.5, but only after onload. if(evt && evt.type == 'load') { if(document.removeEventListener) document.removeEventListener('DOMContentLoaded', fire, false); if(window.removeEventListener) window.removeEventListener('load', fire, false); } }; // Unload detection based on the research from Moxiecode. function verifyUnload() { sIFR.prepareClearReferences(); if(document.readyState == 'interactive') { document.attachEvent('onstop', unloadByStop); setTimeout(function() { document.detachEvent('onstop', unloadByStop) }, 0); } }; function unloadByStop() { document.detachEvent('onstop', unloadByStop); fireUnload(); }; function fireUnload() { sIFR.clearReferences(); }; this.attach = function() { if(window.addEventListener) window.addEventListener('load', fire, false); else window.attachEvent('onload', fire); if(!sIFR.useDomLoaded || sIFR.ua.forcePageLoad || sIFR.ua.ie && window.top != window) return; if(sIFR.ua.nativeDomLoaded) { document.addEventListener('DOMContentLoaded', afterDomLoad, false); } else if(sIFR.ua.ie || sIFR.ua.khtml) { pollLoad(); } }; this.attachUnload = function() { if(!sIFR.ua.ie) return; window.attachEvent('onbeforeunload', verifyUnload); window.attachEvent('onunload', fireUnload); } }; var PREFETCH_COOKIE = 'sifrFetch'; function Prefetch(sIFR) { var hasPrefetched = false; this.fetchMovies = function(movies) { if(sIFR.setPrefetchCookie && new RegExp(';?' + PREFETCH_COOKIE + '=true;?').test(document.cookie)) return; try { // We don't know which DOM actions the user agent will allow hasPrefetched = true; prefetch(movies); } catch(e) {} if(sIFR.setPrefetchCookie) document.cookie = PREFETCH_COOKIE + '=true;path=' + sIFR.cookiePath; }; this.clear = function() { if(!hasPrefetched) return; try { var nodes = document.getElementsByTagName('script'); for(var i = nodes.length - 1; i >= 0; i--) { var node = nodes[i]; if(node.type == 'sifr/prefetch') node.parentNode.removeChild(node); } } catch(e) {} }; function prefetch(args) { for(var i = 0; i < args.length; i++) { document.write(''); } } }; function BrokenFlashIE(sIFR) { var active = sIFR.ua.ie; var fixFlash = active && sIFR.ua.flashVersion < sIFR.ua.parseVersion('9.0.115'); var resetMovies = {}; var registry = {}; this.fixFlash = fixFlash; this.register = function(flashNode) { if(!active) return; var id = flashNode.getAttribute('id'); // Try cleaning up previous Flash this.cleanup(id, false); registry[id] = flashNode; delete resetMovies[id]; if(fixFlash) window[id] = flashNode; }; this.reset = function() { if(!active) return false; for(var i = 0; i < sIFR.replacements.length; i++) { var flash = sIFR.replacements[i]; var flashNode = registry[flash.id]; if(!resetMovies[flash.id] && (!flashNode.parentNode || flashNode.parentNode.nodeType == 11)) { flash.resetMovie(); resetMovies[flash.id] = true; } } return true; }; this.cleanup = function(id, usePlaceholder) { var node = registry[id]; if(!node) return; for(var expando in node) { if(typeof(node[expando]) == 'function') node[expando] = null; } registry[id] = null; if(fixFlash) window[id] = null; if(node.parentNode) { if(usePlaceholder && node.parentNode.nodeType == 1) { // Replace the Flash node by a placeholde element with the same dimensions. This stops the page from collapsing // when the Flash movies are removed. var placeholder = document.createElement('div'); placeholder.style.width = node.offsetWidth + 'px'; placeholder.style.height = node.offsetHeight + 'px'; node.parentNode.replaceChild(placeholder, node); } else { node.parentNode.removeChild(node); } } }; this.prepareClearReferences = function() { if(!fixFlash) return; // Disable Flash cleanup, see // for more info. __flash_unloadHandler = function(){}; __flash_savedUnloadHandler = function(){}; }; this.clearReferences = function() { // Since we've disabled Flash' own cleanup, add all objects on the page to our registry so they can be cleaned up. if(fixFlash) { var objects = document.getElementsByTagName('object'); for(var i = objects.length - 1; i >= 0; i--) registry[objects[i].getAttribute('id')] = objects[i]; } for(var id in registry) { if(Object.prototype[id] != registry[id]) this.cleanup(id, true); } }; } function FlashInteractor(sIFR, id, vars, forceWidth, events) { this.sIFR = sIFR; this.id = id; this.vars = vars; // Type of value depends on SWF builder. This could use some improvement! this.movie = null; this.__forceWidth = forceWidth; this.__events = events; this.__resizing = 0; } FlashInteractor.prototype = { getFlashElement: function() { return document.getElementById(this.id); }, getAlternate: function() { return document.getElementById(this.id + '_alternate'); }, getAncestor: function() { var ancestor = this.getFlashElement().parentNode; return !this.sIFR.dom.hasClass(ClassNames.FIX_FOCUS, ancestor) ? ancestor : ancestor.parentNode; }, available: function() { var flashNode = this.getFlashElement(); return flashNode && flashNode.parentNode; }, call: function(type) { var flashNode = this.getFlashElement(); if (!flashNode[type]) { return false; } // In Firefox 2, exposed Flash methods aren't proper functions, there's no `apply()` method! This workaround // does work, though. return Function.prototype.apply.call(flashNode[type], flashNode, Array.prototype.slice.call(arguments, 1)); }, attempt: function() { if(!this.available()) return false; try { this.call.apply(this, arguments); } catch(e) { if(this.sIFR.debug) throw e; return false; } return true; }, updateVars: function(name, value) { for(var i = 0; i < this.vars.length; i++) { if (this.vars[i].split('=')[0] == name) { this.vars[i] = name + '=' + value; break; } } var vars = this.sIFR.util.encodeVars(this.vars); this.movie.injectVars(this.getFlashElement(), vars); this.movie.injectVars(this.movie.html, vars); }, storeSize: function(type, value) { this.movie.setSize(type, value); this.updateVars(type, value); }, fireEvent: function(name) { if(this.available() && this.__events[name]) this.sIFR.util.delay(0, this.__events[name], this, this); }, resizeFlashElement: function(height, width, firstResize) { if(!this.available()) return; this.__resizing++; var flashNode = this.getFlashElement(); flashNode.setAttribute('height', height); // Reset element height as declared by `MovieCreator` this.getAncestor().style.minHeight = ''; this.updateVars('renderheight', height); this.storeSize('height', height); if(width !== null) { flashNode.setAttribute('width', width); // Don't store the size, it may cause Flash to wrap the text when the movie is reset. this.movie.setSize('width', width); } if(this.__events.onReplacement) { this.sIFR.util.delay(0, this.__events.onReplacement, this, this); delete this.__events.onReplacement; } if(firstResize) { this.sIFR.util.delay(0, function() { this.attempt('scaleMovie'); this.__resizing--; }, this); } else { this.__resizing--; } }, blurFlashElement: function() { if(this.available()) this.sIFR.dom.blurElement(this.getFlashElement()); }, resetMovie: function() { this.sIFR.util.delay(0, this.movie.reset, this.movie, this.getFlashElement(), this.getAlternate()); }, resizeAfterScale: function() { if(this.available() && this.__resizing == 0) this.sIFR.util.delay(0, this.resize, this); }, resize: function() { if(!this.available()) return; this.__resizing++; var flashNode = this.getFlashElement(); var currentWidth = flashNode.offsetWidth; // The Flash movie has no dimensions, which means it's not visible anyway. No need to recalculate. if(currentWidth == 0) return; var originalWidth = flashNode.getAttribute('width'); var originalHeight = flashNode.getAttribute('height'); var ancestor = this.getAncestor(); var minHeight = this.sIFR.dom.getHeightFromStyle(ancestor); // Remove Flash movie from flow flashNode.style.width = '1px'; flashNode.style.height = '1px'; // Set a minimal height on the flashNode's parent, to stop a reflow ancestor.style.minHeight = minHeight + 'px'; // Restore original content var nodes = this.getAlternate().childNodes; var clones = []; for(var i = 0; i < nodes.length; i++) { var node = nodes[i].cloneNode(true); clones.push(node); ancestor.appendChild(node); } // Calculate width var width = this.sIFR.dom.getWidthFromStyle(ancestor); // Remove original content again for(var i = 0; i < clones.length; i++) ancestor.removeChild(clones[i]); // Reset Flash movie flow flashNode.style.width = flashNode.style.height = ancestor.style.minHeight = ''; flashNode.setAttribute('width', this.__forceWidth ? width : originalWidth); flashNode.setAttribute('height', originalHeight); // IE can get mightily confused about where to draw the Flash . This is a workaround to force IE to repaint // the . if(sIFR.ua.ie) { flashNode.style.display = 'none'; var repaint = flashNode.offsetHeight; flashNode.style.display = ''; } // Resize! if(width != currentWidth) { if(this.__forceWidth) this.storeSize('width', width); this.attempt('resize', width); } this.__resizing--; }, // `content` must not be util.escaped when passed in. // alternate may be an array of nodes to be appended to the alternate content, use this // in XHTML documents. replaceText: function(content, alternate) { var escapedContent = this.sIFR.util.escape(content); if(!this.attempt('replaceText', escapedContent)) return false; this.updateVars('content', escapedContent); var node = this.getAlternate(); if(alternate) { while(node.firstChild) node.removeChild(node.firstChild); for(var i = 0; i < alternate.length; i++) node.appendChild(alternate[i]); } else { try { node.innerHTML = content; } catch(e) {}; } return true; }, changeCSS: function(css) { css = this.sIFR.util.escape(this.sIFR.util.cssToString(this.sIFR.util.convertCssArg(css))); this.updateVars('css', css); return this.attempt('changeCSS', css); }, remove: function() { if(this.movie && this.available()) this.movie.remove(this.getFlashElement(), this.id); } }; var MovieCreator = new function() { this.create = function(sIFR, brokenFlash, node, fixFocus, id, src, width, height, vars, wmode, backgroundColor) { var klass = sIFR.ua.ie ? IEFlashMovie : FlashMovie; return new klass( sIFR, brokenFlash, node, fixFocus, id, src, width, height, ['flashvars', vars, 'wmode', wmode, 'bgcolor', backgroundColor, 'allowScriptAccess', 'always', 'quality', 'best'] ); } function FlashMovie(sIFR, brokenFlash, node, fixFocus, id, src, width, height, params) { var object = sIFR.dom.create('object', ClassNames.FLASH); var attrs = ['type', 'application/x-shockwave-flash', 'id', id, 'name', id, 'data', src, 'width', width, 'height', height]; for(var i = 0; i < attrs.length; i += 2) object.setAttribute(attrs[i], attrs[i + 1]); var insertion = object; if(fixFocus) { insertion = dom.create("div", ClassNames.FIX_FOCUS); insertion.appendChild(object); } for(var i = 0; i < params.length; i+=2) { if(params[i] == 'name') continue; var param = dom.create('param'); param.setAttribute('name', params[i]); param.setAttribute('value', params[i + 1]); object.appendChild(param); } // Before removing the existing content, set its height such that the element // does not collapse. Height is restored in `FlashInteractor#resizeFlashElement`. node.style.minHeight = height + 'px'; while(node.firstChild) node.removeChild(node.firstChild); node.appendChild(insertion); this.html = insertion.cloneNode(true); } FlashMovie.prototype = { reset: function(flashNode, alternate) { flashNode.parentNode.replaceChild(this.html.cloneNode(true), flashNode); }, remove: function(flashNode, id) { flashNode.parentNode.removeChild(flashNode); }, setSize: function(type, value) { this.html.setAttribute(type, value); }, injectVars: function(flash, encodedVars) { var params = flash.getElementsByTagName('param'); for(var i = 0; i < params.length; i++) { if(params[i].getAttribute('name') == 'flashvars') { params[i].setAttribute('value', encodedVars); break; } } } }; function IEFlashMovie(sIFR, brokenFlash, node, fixFocus, id, src, width, height, params) { this.dom = sIFR.dom; this.broken = brokenFlash; this.html = '' + '' ; var paramsHtml = ''; for(var i = 0; i < params.length; i+=2) { paramsHtml += ''; } this.html = this.html.replace(/(<\/object>)/, paramsHtml + '$1'); // Before removing the existing content, set its height such that the element // does not collapse. Height is restored in `FlashInteractor#resizeFlashElement`. node.style.minHeight = height + 'px'; node.innerHTML = this.html; this.broken.register(node.firstChild); } IEFlashMovie.prototype = { reset: function(flashNode, alternate) { alternate = alternate.cloneNode(true); var parent = flashNode.parentNode; parent.innerHTML = this.html; this.broken.register(parent.firstChild); parent.appendChild(alternate); }, remove: function(flashNode, id) { this.broken.cleanup(id); }, setSize: function(type, value) { this.html = this.html.replace(type == 'height' ? /(height)="\d+"/ : /(width)="\d+"/, '$1="' + value + '"'); }, injectVars: function(flash, encodedVars) { if(flash != this.html) return; this.html = this.html.replace(/(flashvars(=|\"\svalue=)\")[^\"]+/, '$1' + encodedVars); } }; } this.errors = new Errors(self); var util = this.util = new Util(self); var dom = this.dom = new DomUtil(self); var ua = this.ua = new UserAgentDetection(self); var hacks = { fragmentIdentifier: new FragmentIdentifier(self), pageLoad: new PageLoad(self), prefetch: new Prefetch(self), brokenFlashIE: new BrokenFlashIE(self) }; this.__resetBrokenMovies = hacks.brokenFlashIE.reset; var replaceKwargsStore = { kwargs: [], replaceAll: function(preserve) { for(var i = 0; i < this.kwargs.length; i++) self.replace(this.kwargs[i]); if(!preserve) this.kwargs = []; } }; this.activate = function(/* … */) { if(!ua.supported || !this.isEnabled || this.isActive || !isValidDomain() || isFile()) return; hacks.prefetch.fetchMovies(arguments); this.isActive = true; this.setFlashClass(); hacks.fragmentIdentifier.cache(); hacks.pageLoad.attachUnload(); if(!this.autoInitialize) return; hacks.pageLoad.attach(); }; this.setFlashClass = function() { if(this.hasFlashClassSet) return; dom.addClass(ClassNames.ACTIVE, dom.getBody() || document.documentElement); this.hasFlashClassSet = true; }; this.removeFlashClass = function() { if(!this.hasFlashClassSet) return; dom.removeClass(ClassNames.ACTIVE, dom.getBody()); dom.removeClass(ClassNames.ACTIVE, document.documentElement); this.hasFlashClassSet = false; }; this.initialize = function(preserveReplacements) { if(!this.isActive || !this.isEnabled) return; if(isInitialized) { if(!preserveReplacements) replaceKwargsStore.replaceAll(false); return; } isInitialized = true; replaceKwargsStore.replaceAll(preserveReplacements); if(self.repaintOnResize) { if(window.addEventListener) window.addEventListener('resize', resize, false); else window.attachEvent('onresize', resize); } hacks.prefetch.clear(); }; this.replace = function(kwargs, mergeKwargs) { if(!ua.supported) return; // This lets you specify two kwarg objects so you don't have to repeat common settings. // The first object will be merged with the second, while properties in the second // object have priority over those in the first. The first object is unmodified // for further use, the resulting second object will be used in the replacement. if(mergeKwargs) kwargs = util.copyProperties(kwargs, mergeKwargs); if(!isInitialized) return replaceKwargsStore.kwargs.push(kwargs); if(this.onReplacementStart) this.onReplacementStart(kwargs); var nodes = kwargs.elements || dom.querySelectorAll(kwargs.selector); if(nodes.length == 0) return; var src = getSource(kwargs.src); var css = util.convertCssArg(kwargs.css); var filters = getFilters(kwargs.filters); var forceSingleLine = kwargs.forceSingleLine === true; var preventWrap = kwargs.preventWrap === true && !forceSingleLine; var fitExactly = forceSingleLine || (kwargs.fitExactly == null ? this.fitExactly : kwargs.fitExactly) === true; var forceWidth = fitExactly || (kwargs.forceWidth == null ? this.forceWidth : kwargs.forceWidth) === true; var ratios = kwargs.ratios || []; var pixelFont = kwargs.pixelFont === true; var tuneHeight = parseInt(kwargs.tuneHeight) || 0; var events = !!kwargs.onRelease || !!kwargs.onRollOver || !!kwargs.onRollOut; // Alignment should be handled by the browser in this case. if(fitExactly) util.extractFromCss(css, '.sIFR-root', 'text-align', true); var fontSize = util.extractFromCss(css, '.sIFR-root', 'font-size', true) || '0'; var backgroundColor = util.extractFromCss(css, '.sIFR-root', 'background-color', true) || '#FFFFFF'; var kerning = util.extractFromCss(css, '.sIFR-root', 'kerning', true) || ''; var opacity = util.extractFromCss(css, '.sIFR-root', 'opacity', true) || '100'; var cursor = util.extractFromCss(css, '.sIFR-root', 'cursor', true) || 'default'; var leading = parseInt(util.extractFromCss(css, '.sIFR-root', 'leading')) || 0; var gridFitType = kwargs.gridFitType || (util.extractFromCss(css, '.sIFR-root', 'text-align') == 'right') ? 'subpixel' : 'pixel'; var textTransform = this.forceTextTransform === false ? 'none' : util.extractFromCss(css, '.sIFR-root', 'text-transform', true) || 'none'; // Only font sizes specified in pixels are supported. fontSize = /^\d+(px)?$/.test(fontSize) ? parseInt(fontSize) : 0; // Make sure to support percentages and decimals opacity = parseFloat(opacity) < 1 ? 100 * parseFloat(opacity) : opacity; var cssText = kwargs.modifyCss ? '' : util.cssToString(css); var wmode = kwargs.wmode || ''; if(!wmode) { if(kwargs.transparent) wmode = 'transparent'; else if(kwargs.opaque) wmode = 'opaque'; } if(wmode == 'transparent') { if(!ua.transparencySupport) wmode = 'opaque'; else backgroundColor = 'transparent'; } else if(backgroundColor == 'transparent') { backgroundColor = '#FFFFFF'; } for(var i = 0; i < nodes.length; i++) { var node = nodes[i]; if(dom.hasOneOfClassses(ClassNames.IGNORE_CLASSES, node) || dom.ancestorHasClass(node, ClassNames.ALTERNATE)) continue; // Opera does not allow communication with hidden Flash movies. Visibility is tackled by sIFR itself, but // `display:none` isn't. Additionally, WebKit does not return computed style information for elements with // `display:none`. We'll prevent elements which have `display:none` or are contained in such an element from // being replaced. It's a bit hard to detect this, but we'll check for the dimensions of the element and its // `display` property. var dimensions = dom.getDimensions(node); var height = dimensions.height; var width = dimensions.width; var display = dom.getComputedStyle(node, 'display'); if(!height || !width || !display || display == 'none') continue; // Get the width (to approximate the final size). width = dom.getWidthFromStyle(node); var size, lines; if(!fontSize) { var calculation = calculate(node); size = Math.min(this.MAX_FONT_SIZE, Math.max(this.MIN_FONT_SIZE, calculation.fontSize)); if(pixelFont) size = Math.max(8, 8 * Math.round(size / 8)); lines = calculation.lines; } else { size = fontSize; lines = 1; } var alternate = dom.create('span', ClassNames.ALTERNATE); // Clone the original content to the alternate element. var contentNode = node.cloneNode(true); // Temporarily append the contentNode to the document, to get around IE problems with resolved hrefs node.parentNode.appendChild(contentNode); for(var j = 0, l = contentNode.childNodes.length; j < l; j++) { var child = contentNode.childNodes[j]; // Let's not keep