var relAttr=/^(light|shadow)box/i,expando="shadowboxCacheKey",cacheKey=1;S.cache={};S.select=function(b){var c=[];if(!b){var a;each(document.getElementsByTagName("a"),function(f,g){a=g.getAttribute("rel");if(a&&relAttr.test(a)){c.push(g)}})}else{var e=b.length;if(e){if(typeof b=="string"){if(S.find){c=S.find(b)}}else{if(e==2&&typeof b[0]=="string"&&b[1].nodeType){if(S.find){c=S.find(b[0],b[1])}}else{for(var d=0;d<e;++d){c[d]=b[d]}}}}else{c.push(b)}}return c};S.setup=function(a,b){each(S.select(a),function(c,d){S.addCache(d,b)})};S.teardown=function(a){each(S.select(a),function(b,c){S.removeCache(c)})};S.addCache=function(c,a){var b=c[expando];if(b==undefined){b=cacheKey++;c[expando]=b;addEvent(c,"click",handleClick)}S.cache[b]=S.makeObject(c,a)};S.removeCache=function(a){removeEvent(a,"click",handleClick);delete S.cache[a[expando]];a[expando]=null};S.getCache=function(b){var a=b[expando];return(a in S.cache&&S.cache[a])};S.clearCache=function(){for(var a in S.cache){S.removeCache(S.cache[a].link)}S.cache={}};function handleClick(a){S.open(this);if(S.gallery.length){preventDefault(a)}};