highslide.js 50 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891
  1. /**
  2. * Name: Highslide JS
  3. * Version: 4.1.13 (2011-10-06)
  4. * Config: default
  5. * Author: Torstein Hønsi
  6. * Support: www.highslide.com/support
  7. * License: www.highslide.com/#license
  8. */
  9. if (!hs) { var hs = {
  10. // Language strings
  11. lang : {
  12. cssDirection: 'ltr',
  13. loadingText : 'Loading...',
  14. loadingTitle : 'Click to cancel',
  15. focusTitle : 'Click to bring to front',
  16. fullExpandTitle : 'Expand to actual size (f)',
  17. creditsText : '',
  18. creditsTitle : 'Go to the Highslide JS homepage',
  19. restoreTitle : 'Click to close image, click and drag to move. Use arrow keys for next and previous.'
  20. },
  21. // See http://highslide.com/ref for examples of settings
  22. graphicsDir : 'highslide/graphics/',
  23. expandCursor : 'zoomin.cur', // null disables
  24. restoreCursor : 'zoomout.cur', // null disables
  25. expandDuration : 250, // milliseconds
  26. restoreDuration : 250,
  27. marginLeft : 15,
  28. marginRight : 15,
  29. marginTop : 15,
  30. marginBottom : 15,
  31. zIndexCounter : 1001, // adjust to other absolutely positioned elements
  32. loadingOpacity : 0.75,
  33. allowMultipleInstances: true,
  34. numberOfImagesToPreload : 5,
  35. outlineWhileAnimating : 2, // 0 = never, 1 = always, 2 = HTML only
  36. outlineStartOffset : 3, // ends at 10
  37. padToMinWidth : false, // pad the popup width to make room for wide caption
  38. fullExpandPosition : 'bottom right',
  39. fullExpandOpacity : 1,
  40. showCredits : true, // you can set this to false if you want
  41. creditsHref : 'http://highslide.com/',
  42. creditsTarget : '_self',
  43. enableKeyListener : true,
  44. openerTagNames : ['a'], // Add more to allow slideshow indexing
  45. dragByHeading: true,
  46. minWidth: 200,
  47. minHeight: 200,
  48. allowSizeReduction: true, // allow the image to reduce to fit client size. If false, this overrides minWidth and minHeight
  49. outlineType : 'drop-shadow', // set null to disable outlines
  50. // END OF YOUR SETTINGS
  51. // declare internal properties
  52. preloadTheseImages : [],
  53. continuePreloading: true,
  54. expanders : [],
  55. overrides : [
  56. 'allowSizeReduction',
  57. 'useBox',
  58. 'outlineType',
  59. 'outlineWhileAnimating',
  60. 'captionId',
  61. 'captionText',
  62. 'captionEval',
  63. 'captionOverlay',
  64. 'headingId',
  65. 'headingText',
  66. 'headingEval',
  67. 'headingOverlay',
  68. 'creditsPosition',
  69. 'dragByHeading',
  70. 'width',
  71. 'height',
  72. 'wrapperClassName',
  73. 'minWidth',
  74. 'minHeight',
  75. 'maxWidth',
  76. 'maxHeight',
  77. 'pageOrigin',
  78. 'slideshowGroup',
  79. 'easing',
  80. 'easingClose',
  81. 'fadeInOut',
  82. 'src'
  83. ],
  84. overlays : [],
  85. idCounter : 0,
  86. oPos : {
  87. x: ['leftpanel', 'left', 'center', 'right', 'rightpanel'],
  88. y: ['above', 'top', 'middle', 'bottom', 'below']
  89. },
  90. mouse: {},
  91. headingOverlay: {},
  92. captionOverlay: {},
  93. timers : [],
  94. pendingOutlines : {},
  95. clones : {},
  96. onReady: [],
  97. uaVersion: /Trident\/4\.0/.test(navigator.userAgent) ? 8 :
  98. parseFloat((navigator.userAgent.toLowerCase().match( /.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/ ) || [0,'0'])[1]),
  99. ie : (document.all && !window.opera),
  100. //ie : navigator && /MSIE [678]/.test(navigator.userAgent), // ie9 compliant?
  101. safari : /Safari/.test(navigator.userAgent),
  102. geckoMac : /Macintosh.+rv:1\.[0-8].+Gecko/.test(navigator.userAgent),
  103. $ : function (id) {
  104. if (id) return document.getElementById(id);
  105. },
  106. push : function (arr, val) {
  107. arr[arr.length] = val;
  108. },
  109. createElement : function (tag, attribs, styles, parent, nopad) {
  110. var el = document.createElement(tag);
  111. if (attribs) hs.extend(el, attribs);
  112. if (nopad) hs.setStyles(el, {padding: 0, border: 'none', margin: 0});
  113. if (styles) hs.setStyles(el, styles);
  114. if (parent) parent.appendChild(el);
  115. return el;
  116. },
  117. extend : function (el, attribs) {
  118. for (var x in attribs) el[x] = attribs[x];
  119. return el;
  120. },
  121. setStyles : function (el, styles) {
  122. for (var x in styles) {
  123. if (hs.ieLt9 && x == 'opacity') {
  124. if (styles[x] > 0.99) el.style.removeAttribute('filter');
  125. else el.style.filter = 'alpha(opacity='+ (styles[x] * 100) +')';
  126. }
  127. else el.style[x] = styles[x];
  128. }
  129. },
  130. animate: function(el, prop, opt) {
  131. var start,
  132. end,
  133. unit;
  134. if (typeof opt != 'object' || opt === null) {
  135. var args = arguments;
  136. opt = {
  137. duration: args[2],
  138. easing: args[3],
  139. complete: args[4]
  140. };
  141. }
  142. if (typeof opt.duration != 'number') opt.duration = 250;
  143. opt.easing = Math[opt.easing] || Math.easeInQuad;
  144. opt.curAnim = hs.extend({}, prop);
  145. for (var name in prop) {
  146. var e = new hs.fx(el, opt , name );
  147. start = parseFloat(hs.css(el, name)) || 0;
  148. end = parseFloat(prop[name]);
  149. unit = name != 'opacity' ? 'px' : '';
  150. e.custom( start, end, unit );
  151. }
  152. },
  153. css: function(el, prop) {
  154. if (el.style[prop]) {
  155. return el.style[prop];
  156. } else if (document.defaultView) {
  157. return document.defaultView.getComputedStyle(el, null).getPropertyValue(prop);
  158. } else {
  159. if (prop == 'opacity') prop = 'filter';
  160. var val = el.currentStyle[prop.replace(/\-(\w)/g, function (a, b){ return b.toUpperCase(); })];
  161. if (prop == 'filter')
  162. val = val.replace(/alpha\(opacity=([0-9]+)\)/,
  163. function (a, b) { return b / 100 });
  164. return val === '' ? 1 : val;
  165. }
  166. },
  167. getPageSize : function () {
  168. var d = document, w = window, iebody = d.compatMode && d.compatMode != 'BackCompat'
  169. ? d.documentElement : d.body,
  170. ieLt9 = hs.ie && (hs.uaVersion < 9 || typeof pageXOffset == 'undefined');
  171. var width = ieLt9 ? iebody.clientWidth :
  172. (d.documentElement.clientWidth || self.innerWidth),
  173. height = ieLt9 ? iebody.clientHeight : self.innerHeight;
  174. hs.page = {
  175. width: width,
  176. height: height,
  177. scrollLeft: ieLt9 ? iebody.scrollLeft : pageXOffset,
  178. scrollTop: ieLt9 ? iebody.scrollTop : pageYOffset
  179. };
  180. return hs.page;
  181. },
  182. getPosition : function(el) {
  183. var p = { x: el.offsetLeft, y: el.offsetTop };
  184. while (el.offsetParent) {
  185. el = el.offsetParent;
  186. p.x += el.offsetLeft;
  187. p.y += el.offsetTop;
  188. if (el != document.body && el != document.documentElement) {
  189. p.x -= el.scrollLeft;
  190. p.y -= el.scrollTop;
  191. }
  192. }
  193. return p;
  194. },
  195. expand : function(a, params, custom, type) {
  196. if (!a) a = hs.createElement('a', null, { display: 'none' }, hs.container);
  197. if (typeof a.getParams == 'function') return params;
  198. try {
  199. new hs.Expander(a, params, custom);
  200. return false;
  201. } catch (e) { return true; }
  202. },
  203. focusTopmost : function() {
  204. var topZ = 0,
  205. topmostKey = -1,
  206. expanders = hs.expanders,
  207. exp,
  208. zIndex;
  209. for (var i = 0; i < expanders.length; i++) {
  210. exp = expanders[i];
  211. if (exp) {
  212. zIndex = exp.wrapper.style.zIndex;
  213. if (zIndex && zIndex > topZ) {
  214. topZ = zIndex;
  215. topmostKey = i;
  216. }
  217. }
  218. }
  219. if (topmostKey == -1) hs.focusKey = -1;
  220. else expanders[topmostKey].focus();
  221. },
  222. getParam : function (a, param) {
  223. a.getParams = a.onclick;
  224. var p = a.getParams ? a.getParams() : null;
  225. a.getParams = null;
  226. return (p && typeof p[param] != 'undefined') ? p[param] :
  227. (typeof hs[param] != 'undefined' ? hs[param] : null);
  228. },
  229. getSrc : function (a) {
  230. var src = hs.getParam(a, 'src');
  231. if (src) return src;
  232. return a.href;
  233. },
  234. getNode : function (id) {
  235. var node = hs.$(id), clone = hs.clones[id], a = {};
  236. if (!node && !clone) return null;
  237. if (!clone) {
  238. clone = node.cloneNode(true);
  239. clone.id = '';
  240. hs.clones[id] = clone;
  241. return node;
  242. } else {
  243. return clone.cloneNode(true);
  244. }
  245. },
  246. discardElement : function(d) {
  247. if (d) hs.garbageBin.appendChild(d);
  248. hs.garbageBin.innerHTML = '';
  249. },
  250. transit : function (adj, exp) {
  251. var last = exp || hs.getExpander();
  252. exp = last;
  253. if (hs.upcoming) return false;
  254. else hs.last = last;
  255. hs.removeEventListener(document, window.opera ? 'keypress' : 'keydown', hs.keyHandler);
  256. try {
  257. hs.upcoming = adj;
  258. adj.onclick();
  259. } catch (e){
  260. hs.last = hs.upcoming = null;
  261. }
  262. try {
  263. exp.close();
  264. } catch (e) {}
  265. return false;
  266. },
  267. previousOrNext : function (el, op) {
  268. var exp = hs.getExpander(el);
  269. if (exp) return hs.transit(exp.getAdjacentAnchor(op), exp);
  270. else return false;
  271. },
  272. previous : function (el) {
  273. return hs.previousOrNext(el, -1);
  274. },
  275. next : function (el) {
  276. return hs.previousOrNext(el, 1);
  277. },
  278. keyHandler : function(e) {
  279. if (!e) e = window.event;
  280. if (!e.target) e.target = e.srcElement; // ie
  281. if (typeof e.target.form != 'undefined') return true; // form element has focus
  282. var exp = hs.getExpander();
  283. var op = null;
  284. switch (e.keyCode) {
  285. case 70: // f
  286. if (exp) exp.doFullExpand();
  287. return true;
  288. case 32: // Space
  289. case 34: // Page Down
  290. case 39: // Arrow right
  291. case 40: // Arrow down
  292. op = 1;
  293. break;
  294. case 8: // Backspace
  295. case 33: // Page Up
  296. case 37: // Arrow left
  297. case 38: // Arrow up
  298. op = -1;
  299. break;
  300. case 27: // Escape
  301. case 13: // Enter
  302. op = 0;
  303. }
  304. if (op !== null) {hs.removeEventListener(document, window.opera ? 'keypress' : 'keydown', hs.keyHandler);
  305. if (!hs.enableKeyListener) return true;
  306. if (e.preventDefault) e.preventDefault();
  307. else e.returnValue = false;
  308. if (exp) {
  309. if (op == 0) {
  310. exp.close();
  311. } else {
  312. hs.previousOrNext(exp.key, op);
  313. }
  314. return false;
  315. }
  316. }
  317. return true;
  318. },
  319. registerOverlay : function (overlay) {
  320. hs.push(hs.overlays, hs.extend(overlay, { hsId: 'hsId'+ hs.idCounter++ } ));
  321. },
  322. getWrapperKey : function (element, expOnly) {
  323. var el, re = /^highslide-wrapper-([0-9]+)$/;
  324. // 1. look in open expanders
  325. el = element;
  326. while (el.parentNode) {
  327. if (el.id && re.test(el.id)) return el.id.replace(re, "$1");
  328. el = el.parentNode;
  329. }
  330. // 2. look in thumbnail
  331. if (!expOnly) {
  332. el = element;
  333. while (el.parentNode) {
  334. if (el.tagName && hs.isHsAnchor(el)) {
  335. for (var key = 0; key < hs.expanders.length; key++) {
  336. var exp = hs.expanders[key];
  337. if (exp && exp.a == el) return key;
  338. }
  339. }
  340. el = el.parentNode;
  341. }
  342. }
  343. return null;
  344. },
  345. getExpander : function (el, expOnly) {
  346. if (typeof el == 'undefined') return hs.expanders[hs.focusKey] || null;
  347. if (typeof el == 'number') return hs.expanders[el] || null;
  348. if (typeof el == 'string') el = hs.$(el);
  349. return hs.expanders[hs.getWrapperKey(el, expOnly)] || null;
  350. },
  351. isHsAnchor : function (a) {
  352. return (a.onclick && a.onclick.toString().replace(/\s/g, ' ').match(/hs.(htmlE|e)xpand/));
  353. },
  354. reOrder : function () {
  355. for (var i = 0; i < hs.expanders.length; i++)
  356. if (hs.expanders[i] && hs.expanders[i].isExpanded) hs.focusTopmost();
  357. },
  358. mouseClickHandler : function(e)
  359. {
  360. if (!e) e = window.event;
  361. if (e.button > 1) return true;
  362. if (!e.target) e.target = e.srcElement;
  363. var el = e.target;
  364. while (el.parentNode
  365. && !(/highslide-(image|move|html|resize)/.test(el.className)))
  366. {
  367. el = el.parentNode;
  368. }
  369. var exp = hs.getExpander(el);
  370. if (exp && (exp.isClosing || !exp.isExpanded)) return true;
  371. if (exp && e.type == 'mousedown') {
  372. if (e.target.form) return true;
  373. var match = el.className.match(/highslide-(image|move|resize)/);
  374. if (match) {
  375. hs.dragArgs = {
  376. exp: exp ,
  377. type: match[1],
  378. left: exp.x.pos,
  379. width: exp.x.size,
  380. top: exp.y.pos,
  381. height: exp.y.size,
  382. clickX: e.clientX,
  383. clickY: e.clientY
  384. };
  385. hs.addEventListener(document, 'mousemove', hs.dragHandler);
  386. if (e.preventDefault) e.preventDefault(); // FF
  387. if (/highslide-(image|html)-blur/.test(exp.content.className)) {
  388. exp.focus();
  389. hs.hasFocused = true;
  390. }
  391. return false;
  392. }
  393. } else if (e.type == 'mouseup') {
  394. hs.removeEventListener(document, 'mousemove', hs.dragHandler);
  395. if (hs.dragArgs) {
  396. if (hs.styleRestoreCursor && hs.dragArgs.type == 'image')
  397. hs.dragArgs.exp.content.style.cursor = hs.styleRestoreCursor;
  398. var hasDragged = hs.dragArgs.hasDragged;
  399. if (!hasDragged &&!hs.hasFocused && !/(move|resize)/.test(hs.dragArgs.type)) {
  400. exp.close();
  401. }
  402. else if (hasDragged || (!hasDragged && hs.hasHtmlExpanders)) {
  403. hs.dragArgs.exp.doShowHide('hidden');
  404. }
  405. hs.hasFocused = false;
  406. hs.dragArgs = null;
  407. } else if (/highslide-image-blur/.test(el.className)) {
  408. el.style.cursor = hs.styleRestoreCursor;
  409. }
  410. }
  411. return false;
  412. },
  413. dragHandler : function(e)
  414. {
  415. if (!hs.dragArgs) return true;
  416. if (!e) e = window.event;
  417. var a = hs.dragArgs, exp = a.exp;
  418. a.dX = e.clientX - a.clickX;
  419. a.dY = e.clientY - a.clickY;
  420. var distance = Math.sqrt(Math.pow(a.dX, 2) + Math.pow(a.dY, 2));
  421. if (!a.hasDragged) a.hasDragged = (a.type != 'image' && distance > 0)
  422. || (distance > (hs.dragSensitivity || 5));
  423. if (a.hasDragged && e.clientX > 5 && e.clientY > 5) {
  424. if (a.type == 'resize') exp.resize(a);
  425. else {
  426. exp.moveTo(a.left + a.dX, a.top + a.dY);
  427. if (a.type == 'image') exp.content.style.cursor = 'move';
  428. }
  429. }
  430. return false;
  431. },
  432. wrapperMouseHandler : function (e) {
  433. try {
  434. if (!e) e = window.event;
  435. var over = /mouseover/i.test(e.type);
  436. if (!e.target) e.target = e.srcElement; // ie
  437. if (!e.relatedTarget) e.relatedTarget =
  438. over ? e.fromElement : e.toElement; // ie
  439. var exp = hs.getExpander(e.target);
  440. if (!exp.isExpanded) return;
  441. if (!exp || !e.relatedTarget || hs.getExpander(e.relatedTarget, true) == exp
  442. || hs.dragArgs) return;
  443. for (var i = 0; i < exp.overlays.length; i++) (function() {
  444. var o = hs.$('hsId'+ exp.overlays[i]);
  445. if (o && o.hideOnMouseOut) {
  446. if (over) hs.setStyles(o, { visibility: 'visible', display: '' });
  447. hs.animate(o, { opacity: over ? o.opacity : 0 }, o.dur);
  448. }
  449. })();
  450. } catch (e) {}
  451. },
  452. addEventListener : function (el, event, func) {
  453. if (el == document && event == 'ready') {
  454. hs.push(hs.onReady, func);
  455. }
  456. try {
  457. el.addEventListener(event, func, false);
  458. } catch (e) {
  459. try {
  460. el.detachEvent('on'+ event, func);
  461. el.attachEvent('on'+ event, func);
  462. } catch (e) {
  463. el['on'+ event] = func;
  464. }
  465. }
  466. },
  467. removeEventListener : function (el, event, func) {
  468. try {
  469. el.removeEventListener(event, func, false);
  470. } catch (e) {
  471. try {
  472. el.detachEvent('on'+ event, func);
  473. } catch (e) {
  474. el['on'+ event] = null;
  475. }
  476. }
  477. },
  478. preloadFullImage : function (i) {
  479. if (hs.continuePreloading && hs.preloadTheseImages[i] && hs.preloadTheseImages[i] != 'undefined') {
  480. var img = document.createElement('img');
  481. img.onload = function() {
  482. img = null;
  483. hs.preloadFullImage(i + 1);
  484. };
  485. img.src = hs.preloadTheseImages[i];
  486. }
  487. },
  488. preloadImages : function (number) {
  489. if (number && typeof number != 'object') hs.numberOfImagesToPreload = number;
  490. var arr = hs.getAnchors();
  491. for (var i = 0; i < arr.images.length && i < hs.numberOfImagesToPreload; i++) {
  492. hs.push(hs.preloadTheseImages, hs.getSrc(arr.images[i]));
  493. }
  494. // preload outlines
  495. if (hs.outlineType) new hs.Outline(hs.outlineType, function () { hs.preloadFullImage(0)} );
  496. else
  497. hs.preloadFullImage(0);
  498. // preload cursor
  499. if (hs.restoreCursor) var cur = hs.createElement('img', { src: hs.graphicsDir + hs.restoreCursor });
  500. },
  501. init : function () {
  502. if (!hs.container) {
  503. hs.ieLt7 = hs.ie && hs.uaVersion < 7;
  504. hs.ieLt9 = hs.ie && hs.uaVersion < 9;
  505. hs.getPageSize();
  506. for (var x in hs.langDefaults) {
  507. if (typeof hs[x] != 'undefined') hs.lang[x] = hs[x];
  508. else if (typeof hs.lang[x] == 'undefined' && typeof hs.langDefaults[x] != 'undefined')
  509. hs.lang[x] = hs.langDefaults[x];
  510. }
  511. hs.container = hs.createElement('div', {
  512. className: 'highslide-container'
  513. }, {
  514. position: 'absolute',
  515. left: 0,
  516. top: 0,
  517. width: '100%',
  518. zIndex: hs.zIndexCounter,
  519. direction: 'ltr'
  520. },
  521. document.body,
  522. true
  523. );
  524. hs.loading = hs.createElement('a', {
  525. className: 'highslide-loading',
  526. title: hs.lang.loadingTitle,
  527. innerHTML: hs.lang.loadingText,
  528. href: 'javascript:;'
  529. }, {
  530. position: 'absolute',
  531. top: '-9999px',
  532. opacity: hs.loadingOpacity,
  533. zIndex: 1
  534. }, hs.container
  535. );
  536. hs.garbageBin = hs.createElement('div', null, { display: 'none' }, hs.container);
  537. // http://www.robertpenner.com/easing/
  538. Math.linearTween = function (t, b, c, d) {
  539. return c*t/d + b;
  540. };
  541. Math.easeInQuad = function (t, b, c, d) {
  542. return c*(t/=d)*t + b;
  543. };
  544. hs.hideSelects = hs.ieLt7;
  545. hs.hideIframes = ((window.opera && hs.uaVersion < 9) || navigator.vendor == 'KDE'
  546. || (hs.ieLt7 && hs.uaVersion < 5.5));
  547. }
  548. },
  549. ready : function() {
  550. if (hs.isReady) return;
  551. hs.isReady = true;
  552. for (var i = 0; i < hs.onReady.length; i++) hs.onReady[i]();
  553. },
  554. updateAnchors : function() {
  555. var el, els, all = [], images = [],groups = {}, re;
  556. for (var i = 0; i < hs.openerTagNames.length; i++) {
  557. els = document.getElementsByTagName(hs.openerTagNames[i]);
  558. for (var j = 0; j < els.length; j++) {
  559. el = els[j];
  560. re = hs.isHsAnchor(el);
  561. if (re) {
  562. hs.push(all, el);
  563. if (re[0] == 'hs.expand') hs.push(images, el);
  564. var g = hs.getParam(el, 'slideshowGroup') || 'none';
  565. if (!groups[g]) groups[g] = [];
  566. hs.push(groups[g], el);
  567. }
  568. }
  569. }
  570. hs.anchors = { all: all, groups: groups, images: images };
  571. return hs.anchors;
  572. },
  573. getAnchors : function() {
  574. return hs.anchors || hs.updateAnchors();
  575. },
  576. close : function(el) {
  577. var exp = hs.getExpander(el);
  578. if (exp) exp.close();
  579. return false;
  580. }
  581. }; // end hs object
  582. hs.fx = function( elem, options, prop ){
  583. this.options = options;
  584. this.elem = elem;
  585. this.prop = prop;
  586. if (!options.orig) options.orig = {};
  587. };
  588. hs.fx.prototype = {
  589. update: function(){
  590. (hs.fx.step[this.prop] || hs.fx.step._default)(this);
  591. if (this.options.step)
  592. this.options.step.call(this.elem, this.now, this);
  593. },
  594. custom: function(from, to, unit){
  595. this.startTime = (new Date()).getTime();
  596. this.start = from;
  597. this.end = to;
  598. this.unit = unit;// || this.unit || "px";
  599. this.now = this.start;
  600. this.pos = this.state = 0;
  601. var self = this;
  602. function t(gotoEnd){
  603. return self.step(gotoEnd);
  604. }
  605. t.elem = this.elem;
  606. if ( t() && hs.timers.push(t) == 1 ) {
  607. hs.timerId = setInterval(function(){
  608. var timers = hs.timers;
  609. for ( var i = 0; i < timers.length; i++ )
  610. if ( !timers[i]() )
  611. timers.splice(i--, 1);
  612. if ( !timers.length ) {
  613. clearInterval(hs.timerId);
  614. }
  615. }, 13);
  616. }
  617. },
  618. step: function(gotoEnd){
  619. var t = (new Date()).getTime();
  620. if ( gotoEnd || t >= this.options.duration + this.startTime ) {
  621. this.now = this.end;
  622. this.pos = this.state = 1;
  623. this.update();
  624. this.options.curAnim[ this.prop ] = true;
  625. var done = true;
  626. for ( var i in this.options.curAnim )
  627. if ( this.options.curAnim[i] !== true )
  628. done = false;
  629. if ( done ) {
  630. if (this.options.complete) this.options.complete.call(this.elem);
  631. }
  632. return false;
  633. } else {
  634. var n = t - this.startTime;
  635. this.state = n / this.options.duration;
  636. this.pos = this.options.easing(n, 0, 1, this.options.duration);
  637. this.now = this.start + ((this.end - this.start) * this.pos);
  638. this.update();
  639. }
  640. return true;
  641. }
  642. };
  643. hs.extend( hs.fx, {
  644. step: {
  645. opacity: function(fx){
  646. hs.setStyles(fx.elem, { opacity: fx.now });
  647. },
  648. _default: function(fx){
  649. try {
  650. if ( fx.elem.style && fx.elem.style[ fx.prop ] != null )
  651. fx.elem.style[ fx.prop ] = fx.now + fx.unit;
  652. else
  653. fx.elem[ fx.prop ] = fx.now;
  654. } catch (e) {}
  655. }
  656. }
  657. });
  658. hs.Outline = function (outlineType, onLoad) {
  659. this.onLoad = onLoad;
  660. this.outlineType = outlineType;
  661. var v = hs.uaVersion, tr;
  662. this.hasAlphaImageLoader = hs.ie && hs.uaVersion < 7;
  663. if (!outlineType) {
  664. if (onLoad) onLoad();
  665. return;
  666. }
  667. hs.init();
  668. this.table = hs.createElement(
  669. 'table', {
  670. cellSpacing: 0
  671. }, {
  672. visibility: 'hidden',
  673. position: 'absolute',
  674. borderCollapse: 'collapse',
  675. width: 0
  676. },
  677. hs.container,
  678. true
  679. );
  680. var tbody = hs.createElement('tbody', null, null, this.table, 1);
  681. this.td = [];
  682. for (var i = 0; i <= 8; i++) {
  683. if (i % 3 == 0) tr = hs.createElement('tr', null, { height: 'auto' }, tbody, true);
  684. this.td[i] = hs.createElement('td', null, null, tr, true);
  685. var style = i != 4 ? { lineHeight: 0, fontSize: 0} : { position : 'relative' };
  686. hs.setStyles(this.td[i], style);
  687. }
  688. this.td[4].className = outlineType +' highslide-outline';
  689. this.preloadGraphic();
  690. };
  691. hs.Outline.prototype = {
  692. preloadGraphic : function () {
  693. var src = hs.graphicsDir + (hs.outlinesDir || "outlines/")+ this.outlineType +".png";
  694. var appendTo = hs.safari && hs.uaVersion < 525 ? hs.container : null;
  695. this.graphic = hs.createElement('img', null, { position: 'absolute',
  696. top: '-9999px' }, appendTo, true); // for onload trigger
  697. var pThis = this;
  698. this.graphic.onload = function() { pThis.onGraphicLoad(); };
  699. this.graphic.src = src;
  700. },
  701. onGraphicLoad : function () {
  702. var o = this.offset = this.graphic.width / 4,
  703. pos = [[0,0],[0,-4],[-2,0],[0,-8],0,[-2,-8],[0,-2],[0,-6],[-2,-2]],
  704. dim = { height: (2*o) +'px', width: (2*o) +'px' };
  705. for (var i = 0; i <= 8; i++) {
  706. if (pos[i]) {
  707. if (this.hasAlphaImageLoader) {
  708. var w = (i == 1 || i == 7) ? '100%' : this.graphic.width +'px';
  709. var div = hs.createElement('div', null, { width: '100%', height: '100%', position: 'relative', overflow: 'hidden'}, this.td[i], true);
  710. hs.createElement ('div', null, {
  711. filter: "progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale, src='"+ this.graphic.src + "')",
  712. position: 'absolute',
  713. width: w,
  714. height: this.graphic.height +'px',
  715. left: (pos[i][0]*o)+'px',
  716. top: (pos[i][1]*o)+'px'
  717. },
  718. div,
  719. true);
  720. } else {
  721. hs.setStyles(this.td[i], { background: 'url('+ this.graphic.src +') '+ (pos[i][0]*o)+'px '+(pos[i][1]*o)+'px'});
  722. }
  723. if (window.opera && (i == 3 || i ==5))
  724. hs.createElement('div', null, dim, this.td[i], true);
  725. hs.setStyles (this.td[i], dim);
  726. }
  727. }
  728. this.graphic = null;
  729. if (hs.pendingOutlines[this.outlineType]) hs.pendingOutlines[this.outlineType].destroy();
  730. hs.pendingOutlines[this.outlineType] = this;
  731. if (this.onLoad) this.onLoad();
  732. },
  733. setPosition : function (pos, offset, vis, dur, easing) {
  734. var exp = this.exp,
  735. stl = exp.wrapper.style,
  736. offset = offset || 0,
  737. pos = pos || {
  738. x: exp.x.pos + offset,
  739. y: exp.y.pos + offset,
  740. w: exp.x.get('wsize') - 2 * offset,
  741. h: exp.y.get('wsize') - 2 * offset
  742. };
  743. if (vis) this.table.style.visibility = (pos.h >= 4 * this.offset)
  744. ? 'visible' : 'hidden';
  745. hs.setStyles(this.table, {
  746. left: (pos.x - this.offset) +'px',
  747. top: (pos.y - this.offset) +'px',
  748. width: (pos.w + 2 * this.offset) +'px'
  749. });
  750. pos.w -= 2 * this.offset;
  751. pos.h -= 2 * this.offset;
  752. hs.setStyles (this.td[4], {
  753. width: pos.w >= 0 ? pos.w +'px' : 0,
  754. height: pos.h >= 0 ? pos.h +'px' : 0
  755. });
  756. if (this.hasAlphaImageLoader) this.td[3].style.height
  757. = this.td[5].style.height = this.td[4].style.height;
  758. },
  759. destroy : function(hide) {
  760. if (hide) this.table.style.visibility = 'hidden';
  761. else hs.discardElement(this.table);
  762. }
  763. };
  764. hs.Dimension = function(exp, dim) {
  765. this.exp = exp;
  766. this.dim = dim;
  767. this.ucwh = dim == 'x' ? 'Width' : 'Height';
  768. this.wh = this.ucwh.toLowerCase();
  769. this.uclt = dim == 'x' ? 'Left' : 'Top';
  770. this.lt = this.uclt.toLowerCase();
  771. this.ucrb = dim == 'x' ? 'Right' : 'Bottom';
  772. this.rb = this.ucrb.toLowerCase();
  773. this.p1 = this.p2 = 0;
  774. };
  775. hs.Dimension.prototype = {
  776. get : function(key) {
  777. switch (key) {
  778. case 'loadingPos':
  779. return this.tpos + this.tb + (this.t - hs.loading['offset'+ this.ucwh]) / 2;
  780. case 'wsize':
  781. return this.size + 2 * this.cb + this.p1 + this.p2;
  782. case 'fitsize':
  783. return this.clientSize - this.marginMin - this.marginMax;
  784. case 'maxsize':
  785. return this.get('fitsize') - 2 * this.cb - this.p1 - this.p2 ;
  786. case 'opos':
  787. return this.pos - (this.exp.outline ? this.exp.outline.offset : 0);
  788. case 'osize':
  789. return this.get('wsize') + (this.exp.outline ? 2*this.exp.outline.offset : 0);
  790. case 'imgPad':
  791. return this.imgSize ? Math.round((this.size - this.imgSize) / 2) : 0;
  792. }
  793. },
  794. calcBorders: function() {
  795. // correct for borders
  796. this.cb = (this.exp.content['offset'+ this.ucwh] - this.t) / 2;
  797. this.marginMax = hs['margin'+ this.ucrb];
  798. },
  799. calcThumb: function() {
  800. this.t = this.exp.el[this.wh] ? parseInt(this.exp.el[this.wh]) :
  801. this.exp.el['offset'+ this.ucwh];
  802. this.tpos = this.exp.tpos[this.dim];
  803. this.tb = (this.exp.el['offset'+ this.ucwh] - this.t) / 2;
  804. if (this.tpos == 0 || this.tpos == -1) {
  805. this.tpos = (hs.page[this.wh] / 2) + hs.page['scroll'+ this.uclt];
  806. };
  807. },
  808. calcExpanded: function() {
  809. var exp = this.exp;
  810. this.justify = 'auto';
  811. // size and position
  812. this.pos = this.tpos - this.cb + this.tb;
  813. if (this.maxHeight && this.dim == 'x')
  814. exp.maxWidth = Math.min(exp.maxWidth || this.full, exp.maxHeight * this.full / exp.y.full);
  815. this.size = Math.min(this.full, exp['max'+ this.ucwh] || this.full);
  816. this.minSize = exp.allowSizeReduction ?
  817. Math.min(exp['min'+ this.ucwh], this.full) :this.full;
  818. if (exp.isImage && exp.useBox) {
  819. this.size = exp[this.wh];
  820. this.imgSize = this.full;
  821. }
  822. if (this.dim == 'x' && hs.padToMinWidth) this.minSize = exp.minWidth;
  823. this.marginMin = hs['margin'+ this.uclt];
  824. this.scroll = hs.page['scroll'+ this.uclt];
  825. this.clientSize = hs.page[this.wh];
  826. },
  827. setSize: function(i) {
  828. var exp = this.exp;
  829. if (exp.isImage && (exp.useBox || hs.padToMinWidth)) {
  830. this.imgSize = i;
  831. this.size = Math.max(this.size, this.imgSize);
  832. exp.content.style[this.lt] = this.get('imgPad')+'px';
  833. } else
  834. this.size = i;
  835. exp.content.style[this.wh] = i +'px';
  836. exp.wrapper.style[this.wh] = this.get('wsize') +'px';
  837. if (exp.outline) exp.outline.setPosition();
  838. if (this.dim == 'x' && exp.overlayBox) exp.sizeOverlayBox(true);
  839. },
  840. setPos: function(i) {
  841. this.pos = i;
  842. this.exp.wrapper.style[this.lt] = i +'px';
  843. if (this.exp.outline) this.exp.outline.setPosition();
  844. }
  845. };
  846. hs.Expander = function(a, params, custom, contentType) {
  847. if (document.readyState && hs.ie && !hs.isReady) {
  848. hs.addEventListener(document, 'ready', function() {
  849. new hs.Expander(a, params, custom, contentType);
  850. });
  851. return;
  852. }
  853. this.a = a;
  854. this.custom = custom;
  855. this.contentType = contentType || 'image';
  856. this.isImage = !this.isHtml;
  857. hs.continuePreloading = false;
  858. this.overlays = [];
  859. hs.init();
  860. var key = this.key = hs.expanders.length;
  861. // override inline parameters
  862. for (var i = 0; i < hs.overrides.length; i++) {
  863. var name = hs.overrides[i];
  864. this[name] = params && typeof params[name] != 'undefined' ?
  865. params[name] : hs[name];
  866. }
  867. if (!this.src) this.src = a.href;
  868. // get thumb
  869. var el = (params && params.thumbnailId) ? hs.$(params.thumbnailId) : a;
  870. el = this.thumb = el.getElementsByTagName('img')[0] || el;
  871. this.thumbsUserSetId = el.id || a.id;
  872. // check if already open
  873. for (var i = 0; i < hs.expanders.length; i++) {
  874. if (hs.expanders[i] && hs.expanders[i].a == a) {
  875. hs.expanders[i].focus();
  876. return false;
  877. }
  878. }
  879. // cancel other
  880. if (!hs.allowSimultaneousLoading) for (var i = 0; i < hs.expanders.length; i++) {
  881. if (hs.expanders[i] && hs.expanders[i].thumb != el && !hs.expanders[i].onLoadStarted) {
  882. hs.expanders[i].cancelLoading();
  883. }
  884. }
  885. hs.expanders[key] = this;
  886. if (!hs.allowMultipleInstances && !hs.upcoming) {
  887. if (hs.expanders[key-1]) hs.expanders[key-1].close();
  888. if (typeof hs.focusKey != 'undefined' && hs.expanders[hs.focusKey])
  889. hs.expanders[hs.focusKey].close();
  890. }
  891. // initiate metrics
  892. this.el = el;
  893. this.tpos = this.pageOrigin || hs.getPosition(el);
  894. hs.getPageSize();
  895. var x = this.x = new hs.Dimension(this, 'x');
  896. x.calcThumb();
  897. var y = this.y = new hs.Dimension(this, 'y');
  898. y.calcThumb();
  899. this.wrapper = hs.createElement(
  900. 'div', {
  901. id: 'highslide-wrapper-'+ this.key,
  902. className: 'highslide-wrapper '+ this.wrapperClassName
  903. }, {
  904. visibility: 'hidden',
  905. position: 'absolute',
  906. zIndex: hs.zIndexCounter += 2
  907. }, null, true );
  908. this.wrapper.onmouseover = this.wrapper.onmouseout = hs.wrapperMouseHandler;
  909. if (this.contentType == 'image' && this.outlineWhileAnimating == 2)
  910. this.outlineWhileAnimating = 0;
  911. // get the outline
  912. if (!this.outlineType) {
  913. this[this.contentType +'Create']();
  914. } else if (hs.pendingOutlines[this.outlineType]) {
  915. this.connectOutline();
  916. this[this.contentType +'Create']();
  917. } else {
  918. this.showLoading();
  919. var exp = this;
  920. new hs.Outline(this.outlineType,
  921. function () {
  922. exp.connectOutline();
  923. exp[exp.contentType +'Create']();
  924. }
  925. );
  926. }
  927. return true;
  928. };
  929. hs.Expander.prototype = {
  930. error : function(e) {
  931. if (hs.debug) alert ('Line '+ e.lineNumber +': '+ e.message);
  932. else window.location.href = this.src;
  933. },
  934. connectOutline : function() {
  935. var outline = this.outline = hs.pendingOutlines[this.outlineType];
  936. outline.exp = this;
  937. outline.table.style.zIndex = this.wrapper.style.zIndex - 1;
  938. hs.pendingOutlines[this.outlineType] = null;
  939. },
  940. showLoading : function() {
  941. if (this.onLoadStarted || this.loading) return;
  942. this.loading = hs.loading;
  943. var exp = this;
  944. this.loading.onclick = function() {
  945. exp.cancelLoading();
  946. };
  947. var exp = this,
  948. l = this.x.get('loadingPos') +'px',
  949. t = this.y.get('loadingPos') +'px';
  950. setTimeout(function () {
  951. if (exp.loading) hs.setStyles(exp.loading, { left: l, top: t, zIndex: hs.zIndexCounter++ })}
  952. , 100);
  953. },
  954. imageCreate : function() {
  955. var exp = this;
  956. var img = document.createElement('img');
  957. this.content = img;
  958. img.onload = function () {
  959. if (hs.expanders[exp.key]) exp.contentLoaded();
  960. };
  961. if (hs.blockRightClick) img.oncontextmenu = function() { return false; };
  962. img.className = 'highslide-image';
  963. hs.setStyles(img, {
  964. visibility: 'hidden',
  965. display: 'block',
  966. position: 'absolute',
  967. maxWidth: '9999px',
  968. zIndex: 3
  969. });
  970. img.title = hs.lang.restoreTitle;
  971. if (hs.safari && hs.uaVersion < 525) hs.container.appendChild(img);
  972. if (hs.ie && hs.flushImgSize) img.src = null;
  973. img.src = this.src;
  974. this.showLoading();
  975. },
  976. contentLoaded : function() {
  977. try {
  978. if (!this.content) return;
  979. this.content.onload = null;
  980. if (this.onLoadStarted) return;
  981. else this.onLoadStarted = true;
  982. var x = this.x, y = this.y;
  983. if (this.loading) {
  984. hs.setStyles(this.loading, { top: '-9999px' });
  985. this.loading = null;
  986. }
  987. x.full = this.content.width;
  988. y.full = this.content.height;
  989. hs.setStyles(this.content, {
  990. width: x.t +'px',
  991. height: y.t +'px'
  992. });
  993. this.wrapper.appendChild(this.content);
  994. hs.container.appendChild(this.wrapper);
  995. x.calcBorders();
  996. y.calcBorders();
  997. hs.setStyles (this.wrapper, {
  998. left: (x.tpos + x.tb - x.cb) +'px',
  999. top: (y.tpos + x.tb - y.cb) +'px'
  1000. });
  1001. this.getOverlays();
  1002. var ratio = x.full / y.full;
  1003. x.calcExpanded();
  1004. this.justify(x);
  1005. y.calcExpanded();
  1006. this.justify(y);
  1007. if (this.overlayBox) this.sizeOverlayBox(0, 1);
  1008. if (this.allowSizeReduction) {
  1009. this.correctRatio(ratio);
  1010. if (this.isImage && this.x.full > (this.x.imgSize || this.x.size)) {
  1011. this.createFullExpand();
  1012. if (this.overlays.length == 1) this.sizeOverlayBox();
  1013. }
  1014. }
  1015. this.show();
  1016. } catch (e) {
  1017. this.error(e);
  1018. }
  1019. },
  1020. justify : function (p, moveOnly) {
  1021. var tgtArr, tgt = p.target, dim = p == this.x ? 'x' : 'y';
  1022. var hasMovedMin = false;
  1023. var allowReduce = p.exp.allowSizeReduction;
  1024. p.pos = Math.round(p.pos - ((p.get('wsize') - p.t) / 2));
  1025. if (p.pos < p.scroll + p.marginMin) {
  1026. p.pos = p.scroll + p.marginMin;
  1027. hasMovedMin = true;
  1028. }
  1029. if (!moveOnly && p.size < p.minSize) {
  1030. p.size = p.minSize;
  1031. allowReduce = false;
  1032. }
  1033. if (p.pos + p.get('wsize') > p.scroll + p.clientSize - p.marginMax) {
  1034. if (!moveOnly && hasMovedMin && allowReduce) {
  1035. p.size = Math.min(p.size, p.get(dim == 'y' ? 'fitsize' : 'maxsize'));
  1036. } else if (p.get('wsize') < p.get('fitsize')) {
  1037. p.pos = p.scroll + p.clientSize - p.marginMax - p.get('wsize');
  1038. } else { // image larger than viewport
  1039. p.pos = p.scroll + p.marginMin;
  1040. if (!moveOnly && allowReduce) p.size = p.get(dim == 'y' ? 'fitsize' : 'maxsize');
  1041. }
  1042. }
  1043. if (!moveOnly && p.size < p.minSize) {
  1044. p.size = p.minSize;
  1045. allowReduce = false;
  1046. }
  1047. if (p.pos < p.marginMin) {
  1048. var tmpMin = p.pos;
  1049. p.pos = p.marginMin;
  1050. if (allowReduce && !moveOnly) p.size = p.size - (p.pos - tmpMin);
  1051. }
  1052. },
  1053. correctRatio : function(ratio) {
  1054. var x = this.x,
  1055. y = this.y,
  1056. changed = false,
  1057. xSize = Math.min(x.full, x.size),
  1058. ySize = Math.min(y.full, y.size),
  1059. useBox = (this.useBox || hs.padToMinWidth);
  1060. if (xSize / ySize > ratio) { // width greater
  1061. xSize = ySize * ratio;
  1062. if (xSize < x.minSize) { // below minWidth
  1063. xSize = x.minSize;
  1064. ySize = xSize / ratio;
  1065. }
  1066. changed = true;
  1067. } else if (xSize / ySize < ratio) { // height greater
  1068. ySize = xSize / ratio;
  1069. changed = true;
  1070. }
  1071. if (hs.padToMinWidth && x.full < x.minSize) {
  1072. x.imgSize = x.full;
  1073. y.size = y.imgSize = y.full;
  1074. } else if (this.useBox) {
  1075. x.imgSize = xSize;
  1076. y.imgSize = ySize;
  1077. } else {
  1078. x.size = xSize;
  1079. y.size = ySize;
  1080. }
  1081. changed = this.fitOverlayBox(this.useBox ? null : ratio, changed);
  1082. if (useBox && y.size < y.imgSize) {
  1083. y.imgSize = y.size;
  1084. x.imgSize = y.size * ratio;
  1085. }
  1086. if (changed || useBox) {
  1087. x.pos = x.tpos - x.cb + x.tb;
  1088. x.minSize = x.size;
  1089. this.justify(x, true);
  1090. y.pos = y.tpos - y.cb + y.tb;
  1091. y.minSize = y.size;
  1092. this.justify(y, true);
  1093. if (this.overlayBox) this.sizeOverlayBox();
  1094. }
  1095. },
  1096. fitOverlayBox : function(ratio, changed) {
  1097. var x = this.x, y = this.y;
  1098. if (this.overlayBox) {
  1099. while (y.size > this.minHeight && x.size > this.minWidth
  1100. && y.get('wsize') > y.get('fitsize')) {
  1101. y.size -= 10;
  1102. if (ratio) x.size = y.size * ratio;
  1103. this.sizeOverlayBox(0, 1);
  1104. changed = true;
  1105. }
  1106. }
  1107. return changed;
  1108. },
  1109. show : function () {
  1110. var x = this.x, y = this.y;
  1111. this.doShowHide('hidden');
  1112. // Apply size change
  1113. this.changeSize(
  1114. 1, {
  1115. wrapper: {
  1116. width : x.get('wsize'),
  1117. height : y.get('wsize'),
  1118. left: x.pos,
  1119. top: y.pos
  1120. },
  1121. content: {
  1122. left: x.p1 + x.get('imgPad'),
  1123. top: y.p1 + y.get('imgPad'),
  1124. width:x.imgSize ||x.size,
  1125. height:y.imgSize ||y.size
  1126. }
  1127. },
  1128. hs.expandDuration
  1129. );
  1130. },
  1131. changeSize : function(up, to, dur) {
  1132. if (this.outline && !this.outlineWhileAnimating) {
  1133. if (up) this.outline.setPosition();
  1134. else this.outline.destroy();
  1135. }
  1136. if (!up) this.destroyOverlays();
  1137. var exp = this,
  1138. x = exp.x,
  1139. y = exp.y,
  1140. easing = this.easing;
  1141. if (!up) easing = this.easingClose || easing;
  1142. var after = up ?
  1143. function() {
  1144. if (exp.outline) exp.outline.table.style.visibility = "visible";
  1145. setTimeout(function() {
  1146. exp.afterExpand();
  1147. }, 50);
  1148. } :
  1149. function() {
  1150. exp.afterClose();
  1151. };
  1152. if (up) hs.setStyles( this.wrapper, {
  1153. width: x.t +'px',
  1154. height: y.t +'px'
  1155. });
  1156. if (this.fadeInOut) {
  1157. hs.setStyles(this.wrapper, { opacity: up ? 0 : 1 });
  1158. hs.extend(to.wrapper, { opacity: up });
  1159. }
  1160. hs.animate( this.wrapper, to.wrapper, {
  1161. duration: dur,
  1162. easing: easing,
  1163. step: function(val, args) {
  1164. if (exp.outline && exp.outlineWhileAnimating && args.prop == 'top') {
  1165. var fac = up ? args.pos : 1 - args.pos;
  1166. var pos = {
  1167. w: x.t + (x.get('wsize') - x.t) * fac,
  1168. h: y.t + (y.get('wsize') - y.t) * fac,
  1169. x: x.tpos + (x.pos - x.tpos) * fac,
  1170. y: y.tpos + (y.pos - y.tpos) * fac
  1171. };
  1172. exp.outline.setPosition(pos, 0, 1);
  1173. }
  1174. }
  1175. });
  1176. hs.animate( this.content, to.content, dur, easing, after);
  1177. if (up) {
  1178. this.wrapper.style.visibility = 'visible';
  1179. this.content.style.visibility = 'visible';
  1180. this.a.className += ' highslide-active-anchor';
  1181. }
  1182. },
  1183. afterExpand : function() {
  1184. this.isExpanded = true;
  1185. this.focus();
  1186. if (hs.upcoming && hs.upcoming == this.a) hs.upcoming = null;
  1187. this.prepareNextOutline();
  1188. var p = hs.page, mX = hs.mouse.x + p.scrollLeft, mY = hs.mouse.y + p.scrollTop;
  1189. this.mouseIsOver = this.x.pos < mX && mX < this.x.pos + this.x.get('wsize')
  1190. && this.y.pos < mY && mY < this.y.pos + this.y.get('wsize');
  1191. if (this.overlayBox) this.showOverlays();
  1192. },
  1193. prepareNextOutline : function() {
  1194. var key = this.key;
  1195. var outlineType = this.outlineType;
  1196. new hs.Outline(outlineType,
  1197. function () { try { hs.expanders[key].preloadNext(); } catch (e) {} });
  1198. },
  1199. preloadNext : function() {
  1200. var next = this.getAdjacentAnchor(1);
  1201. if (next && next.onclick.toString().match(/hs\.expand/))
  1202. var img = hs.createElement('img', { src: hs.getSrc(next) });
  1203. },
  1204. getAdjacentAnchor : function(op) {
  1205. var current = this.getAnchorIndex(), as = hs.anchors.groups[this.slideshowGroup || 'none'];
  1206. return (as && as[current + op]) || null;
  1207. },
  1208. getAnchorIndex : function() {
  1209. var arr = hs.getAnchors().groups[this.slideshowGroup || 'none'];
  1210. if (arr) for (var i = 0; i < arr.length; i++) {
  1211. if (arr[i] == this.a) return i;
  1212. }
  1213. return null;
  1214. },
  1215. cancelLoading : function() {
  1216. hs.discardElement (this.wrapper);
  1217. hs.expanders[this.key] = null;
  1218. if (this.loading) hs.loading.style.left = '-9999px';
  1219. },
  1220. writeCredits : function () {
  1221. this.credits = hs.createElement('a', {
  1222. href: hs.creditsHref,
  1223. target: hs.creditsTarget,
  1224. className: 'highslide-credits',
  1225. innerHTML: hs.lang.creditsText,
  1226. title: hs.lang.creditsTitle
  1227. });
  1228. this.createOverlay({
  1229. overlayId: this.credits,
  1230. position: this.creditsPosition || 'top left'
  1231. });
  1232. },
  1233. getInline : function(types, addOverlay) {
  1234. for (var i = 0; i < types.length; i++) {
  1235. var type = types[i], s = null;
  1236. if (!this[type +'Id'] && this.thumbsUserSetId)
  1237. this[type +'Id'] = type +'-for-'+ this.thumbsUserSetId;
  1238. if (this[type +'Id']) this[type] = hs.getNode(this[type +'Id']);
  1239. if (!this[type] && !this[type +'Text'] && this[type +'Eval']) try {
  1240. s = eval(this[type +'Eval']);
  1241. } catch (e) {}
  1242. if (!this[type] && this[type +'Text']) {
  1243. s = this[type +'Text'];
  1244. }
  1245. if (!this[type] && !s) {
  1246. this[type] = hs.getNode(this.a['_'+ type + 'Id']);
  1247. if (!this[type]) {
  1248. var next = this.a.nextSibling;
  1249. while (next && !hs.isHsAnchor(next)) {
  1250. if ((new RegExp('highslide-'+ type)).test(next.className || null)) {
  1251. if (!next.id) this.a['_'+ type + 'Id'] = next.id = 'hsId'+ hs.idCounter++;
  1252. this[type] = hs.getNode(next.id);
  1253. break;
  1254. }
  1255. next = next.nextSibling;
  1256. }
  1257. }
  1258. }
  1259. if (!this[type] && s) this[type] = hs.createElement('div',
  1260. { className: 'highslide-'+ type, innerHTML: s } );
  1261. if (addOverlay && this[type]) {
  1262. var o = { position: (type == 'heading') ? 'above' : 'below' };
  1263. for (var x in this[type+'Overlay']) o[x] = this[type+'Overlay'][x];
  1264. o.overlayId = this[type];
  1265. this.createOverlay(o);
  1266. }
  1267. }
  1268. },
  1269. // on end move and resize
  1270. doShowHide : function(visibility) {
  1271. if (hs.hideSelects) this.showHideElements('SELECT', visibility);
  1272. if (hs.hideIframes) this.showHideElements('IFRAME', visibility);
  1273. if (hs.geckoMac) this.showHideElements('*', visibility);
  1274. },
  1275. showHideElements : function (tagName, visibility) {
  1276. var els = document.getElementsByTagName(tagName);
  1277. var prop = tagName == '*' ? 'overflow' : 'visibility';
  1278. for (var i = 0; i < els.length; i++) {
  1279. if (prop == 'visibility' || (document.defaultView.getComputedStyle(
  1280. els[i], "").getPropertyValue('overflow') == 'auto'
  1281. || els[i].getAttribute('hidden-by') != null)) {
  1282. var hiddenBy = els[i].getAttribute('hidden-by');
  1283. if (visibility == 'visible' && hiddenBy) {
  1284. hiddenBy = hiddenBy.replace('['+ this.key +']', '');
  1285. els[i].setAttribute('hidden-by', hiddenBy);
  1286. if (!hiddenBy) els[i].style[prop] = els[i].origProp;
  1287. } else if (visibility == 'hidden') { // hide if behind
  1288. var elPos = hs.getPosition(els[i]);
  1289. elPos.w = els[i].offsetWidth;
  1290. elPos.h = els[i].offsetHeight;
  1291. var clearsX = (elPos.x + elPos.w < this.x.get('opos')
  1292. || elPos.x > this.x.get('opos') + this.x.get('osize'));
  1293. var clearsY = (elPos.y + elPos.h < this.y.get('opos')
  1294. || elPos.y > this.y.get('opos') + this.y.get('osize'));
  1295. var wrapperKey = hs.getWrapperKey(els[i]);
  1296. if (!clearsX && !clearsY && wrapperKey != this.key) { // element falls behind image
  1297. if (!hiddenBy) {
  1298. els[i].setAttribute('hidden-by', '['+ this.key +']');
  1299. els[i].origProp = els[i].style[prop];
  1300. els[i].style[prop] = 'hidden';
  1301. } else if (hiddenBy.indexOf('['+ this.key +']') == -1) {
  1302. els[i].setAttribute('hidden-by', hiddenBy + '['+ this.key +']');
  1303. }
  1304. } else if ((hiddenBy == '['+ this.key +']' || hs.focusKey == wrapperKey)
  1305. && wrapperKey != this.key) { // on move
  1306. els[i].setAttribute('hidden-by', '');
  1307. els[i].style[prop] = els[i].origProp || '';
  1308. } else if (hiddenBy && hiddenBy.indexOf('['+ this.key +']') > -1) {
  1309. els[i].setAttribute('hidden-by', hiddenBy.replace('['+ this.key +']', ''));
  1310. }
  1311. }
  1312. }
  1313. }
  1314. },
  1315. focus : function() {
  1316. this.wrapper.style.zIndex = hs.zIndexCounter += 2;
  1317. // blur others
  1318. for (var i = 0; i < hs.expanders.length; i++) {
  1319. if (hs.expanders[i] && i == hs.focusKey) {
  1320. var blurExp = hs.expanders[i];
  1321. blurExp.content.className += ' highslide-'+ blurExp.contentType +'-blur';
  1322. blurExp.content.style.cursor = hs.ieLt7 ? 'hand' : 'pointer';
  1323. blurExp.content.title = hs.lang.focusTitle;
  1324. }
  1325. }
  1326. // focus this
  1327. if (this.outline) this.outline.table.style.zIndex
  1328. = this.wrapper.style.zIndex - 1;
  1329. this.content.className = 'highslide-'+ this.contentType;
  1330. this.content.title = hs.lang.restoreTitle;
  1331. if (hs.restoreCursor) {
  1332. hs.styleRestoreCursor = window.opera ? 'pointer' : 'url('+ hs.graphicsDir + hs.restoreCursor +'), pointer';
  1333. if (hs.ieLt7 && hs.uaVersion < 6) hs.styleRestoreCursor = 'hand';
  1334. this.content.style.cursor = hs.styleRestoreCursor;
  1335. }
  1336. hs.focusKey = this.key;
  1337. hs.addEventListener(document, window.opera ? 'keypress' : 'keydown', hs.keyHandler);
  1338. },
  1339. moveTo: function(x, y) {
  1340. this.x.setPos(x);
  1341. this.y.setPos(y);
  1342. },
  1343. resize : function (e) {
  1344. var w, h, r = e.width / e.height;
  1345. w = Math.max(e.width + e.dX, Math.min(this.minWidth, this.x.full));
  1346. if (this.isImage && Math.abs(w - this.x.full) < 12) w = this.x.full;
  1347. h = w / r;
  1348. if (h < Math.min(this.minHeight, this.y.full)) {
  1349. h = Math.min(this.minHeight, this.y.full);
  1350. if (this.isImage) w = h * r;
  1351. }
  1352. this.resizeTo(w, h);
  1353. },
  1354. resizeTo: function(w, h) {
  1355. this.y.setSize(h);
  1356. this.x.setSize(w);
  1357. this.wrapper.style.height = this.y.get('wsize') +'px';
  1358. },
  1359. close : function() {
  1360. if (this.isClosing || !this.isExpanded) return;
  1361. this.isClosing = true;
  1362. hs.removeEventListener(document, window.opera ? 'keypress' : 'keydown', hs.keyHandler);
  1363. try {
  1364. this.content.style.cursor = 'default';
  1365. this.changeSize(
  1366. 0, {
  1367. wrapper: {
  1368. width : this.x.t,
  1369. height : this.y.t,
  1370. left: this.x.tpos - this.x.cb + this.x.tb,
  1371. top: this.y.tpos - this.y.cb + this.y.tb
  1372. },
  1373. content: {
  1374. left: 0,
  1375. top: 0,
  1376. width: this.x.t,
  1377. height: this.y.t
  1378. }
  1379. }, hs.restoreDuration
  1380. );
  1381. } catch (e) { this.afterClose(); }
  1382. },
  1383. createOverlay : function (o) {
  1384. var el = o.overlayId;
  1385. if (typeof el == 'string') el = hs.getNode(el);
  1386. if (o.html) el = hs.createElement('div', { innerHTML: o.html });
  1387. if (!el || typeof el == 'string') return;
  1388. el.style.display = 'block';
  1389. this.genOverlayBox();
  1390. var width = o.width && /^[0-9]+(px|%)$/.test(o.width) ? o.width : 'auto';
  1391. if (/^(left|right)panel$/.test(o.position) && !/^[0-9]+px$/.test(o.width)) width = '200px';
  1392. var overlay = hs.createElement(
  1393. 'div', {
  1394. id: 'hsId'+ hs.idCounter++,
  1395. hsId: o.hsId
  1396. }, {
  1397. position: 'absolute',
  1398. visibility: 'hidden',
  1399. width: width,
  1400. direction: hs.lang.cssDirection || '',
  1401. opacity: 0
  1402. },this.overlayBox,
  1403. true
  1404. );
  1405. overlay.appendChild(el);
  1406. hs.extend(overlay, {
  1407. opacity: 1,
  1408. offsetX: 0,
  1409. offsetY: 0,
  1410. dur: (o.fade === 0 || o.fade === false || (o.fade == 2 && hs.ie)) ? 0 : 250
  1411. });
  1412. hs.extend(overlay, o);
  1413. if (this.gotOverlays) {
  1414. this.positionOverlay(overlay);
  1415. if (!overlay.hideOnMouseOut || this.mouseIsOver)
  1416. hs.animate(overlay, { opacity: overlay.opacity }, overlay.dur);
  1417. }
  1418. hs.push(this.overlays, hs.idCounter - 1);
  1419. },
  1420. positionOverlay : function(overlay) {
  1421. var p = overlay.position || 'middle center',
  1422. offX = overlay.offsetX,
  1423. offY = overlay.offsetY;
  1424. if (overlay.parentNode != this.overlayBox) this.overlayBox.appendChild(overlay);
  1425. if (/left$/.test(p)) overlay.style.left = offX +'px';
  1426. if (/center$/.test(p)) hs.setStyles (overlay, {
  1427. left: '50%',
  1428. marginLeft: (offX - Math.round(overlay.offsetWidth / 2)) +'px'
  1429. });
  1430. if (/right$/.test(p)) overlay.style.right = - offX +'px';
  1431. if (/^leftpanel$/.test(p)) {
  1432. hs.setStyles(overlay, {
  1433. right: '100%',
  1434. marginRight: this.x.cb +'px',
  1435. top: - this.y.cb +'px',
  1436. bottom: - this.y.cb +'px',
  1437. overflow: 'auto'
  1438. });
  1439. this.x.p1 = overlay.offsetWidth;
  1440. } else if (/^rightpanel$/.test(p)) {
  1441. hs.setStyles(overlay, {
  1442. left: '100%',
  1443. marginLeft: this.x.cb +'px',
  1444. top: - this.y.cb +'px',
  1445. bottom: - this.y.cb +'px',
  1446. overflow: 'auto'
  1447. });
  1448. this.x.p2 = overlay.offsetWidth;
  1449. }
  1450. if (/^top/.test(p)) overlay.style.top = offY +'px';
  1451. if (/^middle/.test(p)) hs.setStyles (overlay, {
  1452. top: '50%',
  1453. marginTop: (offY - Math.round(overlay.offsetHeight / 2)) +'px'
  1454. });
  1455. if (/^bottom/.test(p)) overlay.style.bottom = - offY +'px';
  1456. if (/^above$/.test(p)) {
  1457. hs.setStyles(overlay, {
  1458. left: (- this.x.p1 - this.x.cb) +'px',
  1459. right: (- this.x.p2 - this.x.cb) +'px',
  1460. bottom: '100%',
  1461. marginBottom: this.y.cb +'px',
  1462. width: 'auto'
  1463. });
  1464. this.y.p1 = overlay.offsetHeight;
  1465. } else if (/^below$/.test(p)) {
  1466. hs.setStyles(overlay, {
  1467. position: 'relative',
  1468. left: (- this.x.p1 - this.x.cb) +'px',
  1469. right: (- this.x.p2 - this.x.cb) +'px',
  1470. top: '100%',
  1471. marginTop: this.y.cb +'px',
  1472. width: 'auto'
  1473. });
  1474. this.y.p2 = overlay.offsetHeight;
  1475. overlay.style.position = 'absolute';
  1476. }
  1477. },
  1478. getOverlays : function() {
  1479. this.getInline(['heading', 'caption'], true);
  1480. if (this.heading && this.dragByHeading) this.heading.className += ' highslide-move';
  1481. if (hs.showCredits) this.writeCredits();
  1482. for (var i = 0; i < hs.overlays.length; i++) {
  1483. var o = hs.overlays[i], tId = o.thumbnailId, sg = o.slideshowGroup;
  1484. if ((!tId && !sg) || (tId && tId == this.thumbsUserSetId)
  1485. || (sg && sg === this.slideshowGroup)) {
  1486. this.createOverlay(o);
  1487. }
  1488. }
  1489. var os = [];
  1490. for (var i = 0; i < this.overlays.length; i++) {
  1491. var o = hs.$('hsId'+ this.overlays[i]);
  1492. if (/panel$/.test(o.position)) this.positionOverlay(o);
  1493. else hs.push(os, o);
  1494. }
  1495. for (var i = 0; i < os.length; i++) this.positionOverlay(os[i]);
  1496. this.gotOverlays = true;
  1497. },
  1498. genOverlayBox : function() {
  1499. if (!this.overlayBox) this.overlayBox = hs.createElement (
  1500. 'div', {
  1501. className: this.wrapperClassName
  1502. }, {
  1503. position : 'absolute',
  1504. width: (this.x.size || (this.useBox ? this.width : null)
  1505. || this.x.full) +'px',
  1506. height: (this.y.size || this.y.full) +'px',
  1507. visibility : 'hidden',
  1508. overflow : 'hidden',
  1509. zIndex : hs.ie ? 4 : 'auto'
  1510. },
  1511. hs.container,
  1512. true
  1513. );
  1514. },
  1515. sizeOverlayBox : function(doWrapper, doPanels) {
  1516. var overlayBox = this.overlayBox,
  1517. x = this.x,
  1518. y = this.y;
  1519. hs.setStyles( overlayBox, {
  1520. width: x.size +'px',
  1521. height: y.size +'px'
  1522. });
  1523. if (doWrapper || doPanels) {
  1524. for (var i = 0; i < this.overlays.length; i++) {
  1525. var o = hs.$('hsId'+ this.overlays[i]);
  1526. var ie6 = (hs.ieLt7 || document.compatMode == 'BackCompat');
  1527. if (o && /^(above|below)$/.test(o.position)) {
  1528. if (ie6) {
  1529. o.style.width = (overlayBox.offsetWidth + 2 * x.cb
  1530. + x.p1 + x.p2) +'px';
  1531. }
  1532. y[o.position == 'above' ? 'p1' : 'p2'] = o.offsetHeight;
  1533. }
  1534. if (o && ie6 && /^(left|right)panel$/.test(o.position)) {
  1535. o.style.height = (overlayBox.offsetHeight + 2* y.cb) +'px';
  1536. }
  1537. }
  1538. }
  1539. if (doWrapper) {
  1540. hs.setStyles(this.content, {
  1541. top: y.p1 +'px'
  1542. });
  1543. hs.setStyles(overlayBox, {
  1544. top: (y.p1 + y.cb) +'px'
  1545. });
  1546. }
  1547. },
  1548. showOverlays : function() {
  1549. var b = this.overlayBox;
  1550. b.className = '';
  1551. hs.setStyles(b, {
  1552. top: (this.y.p1 + this.y.cb) +'px',
  1553. left: (this.x.p1 + this.x.cb) +'px',
  1554. overflow : 'visible'
  1555. });
  1556. if (hs.safari) b.style.visibility = 'visible';
  1557. this.wrapper.appendChild (b);
  1558. for (var i = 0; i < this.overlays.length; i++) {
  1559. var o = hs.$('hsId'+ this.overlays[i]);
  1560. o.style.zIndex = o.zIndex || 4;
  1561. if (!o.hideOnMouseOut || this.mouseIsOver) {
  1562. o.style.visibility = 'visible';
  1563. hs.setStyles(o, { visibility: 'visible', display: '' });
  1564. hs.animate(o, { opacity: o.opacity }, o.dur);
  1565. }
  1566. }
  1567. },
  1568. destroyOverlays : function() {
  1569. if (!this.overlays.length) return;
  1570. hs.discardElement(this.overlayBox);
  1571. },
  1572. createFullExpand : function () {
  1573. this.fullExpandLabel = hs.createElement(
  1574. 'a', {
  1575. href: 'javascript:hs.expanders['+ this.key +'].doFullExpand();',
  1576. title: hs.lang.fullExpandTitle,
  1577. className: 'highslide-full-expand'
  1578. }
  1579. );
  1580. this.createOverlay({
  1581. overlayId: this.fullExpandLabel,
  1582. position: hs.fullExpandPosition,
  1583. hideOnMouseOut: true,
  1584. opacity: hs.fullExpandOpacity
  1585. });
  1586. },
  1587. doFullExpand : function () {
  1588. try {
  1589. if (this.fullExpandLabel) hs.discardElement(this.fullExpandLabel);
  1590. this.focus();
  1591. var xSize = this.x.size,
  1592. ySize = this.y.size;
  1593. this.resizeTo(this.x.full, this.y.full);
  1594. var xpos = this.x.pos - (this.x.size - xSize) / 2;
  1595. if (xpos < hs.marginLeft) xpos = hs.marginLeft;
  1596. var ypos = this.y.pos - (this.y.size - ySize) / 2;
  1597. if (ypos < hs.marginTop) ypos = hs.marginTop;
  1598. this.moveTo(xpos, ypos);
  1599. this.doShowHide('hidden');
  1600. } catch (e) {
  1601. this.error(e);
  1602. }
  1603. },
  1604. afterClose : function () {
  1605. this.a.className = this.a.className.replace('highslide-active-anchor', '');
  1606. this.doShowHide('visible');
  1607. if (this.outline && this.outlineWhileAnimating) this.outline.destroy();
  1608. hs.discardElement(this.wrapper);
  1609. hs.expanders[this.key] = null;
  1610. hs.reOrder();
  1611. }
  1612. };
  1613. hs.langDefaults = hs.lang;
  1614. // history
  1615. var HsExpander = hs.Expander;
  1616. if (hs.ie && window == window.top) {
  1617. (function () {
  1618. try {
  1619. document.documentElement.doScroll('left');
  1620. } catch (e) {
  1621. setTimeout(arguments.callee, 50);
  1622. return;
  1623. }
  1624. hs.ready();
  1625. })();
  1626. }
  1627. hs.addEventListener(document, 'DOMContentLoaded', hs.ready);
  1628. hs.addEventListener(window, 'load', hs.ready);
  1629. // set handlers
  1630. hs.addEventListener(document, 'ready', function() {
  1631. if (hs.expandCursor) {
  1632. var style = hs.createElement('style', { type: 'text/css' }, null,
  1633. document.getElementsByTagName('HEAD')[0]),
  1634. backCompat = document.compatMode == 'BackCompat';
  1635. function addRule(sel, dec) {
  1636. if (hs.ie && (hs.uaVersion < 9 || backCompat)) {
  1637. var last = document.styleSheets[document.styleSheets.length - 1];
  1638. if (typeof(last.addRule) == "object") last.addRule(sel, dec);
  1639. } else {
  1640. style.appendChild(document.createTextNode(sel + " {" + dec + "}"));
  1641. }
  1642. }
  1643. function fix(prop) {
  1644. return 'expression( ( ( ignoreMe = document.documentElement.'+ prop +
  1645. ' ? document.documentElement.'+ prop +' : document.body.'+ prop +' ) ) + \'px\' );';
  1646. }
  1647. if (hs.expandCursor) addRule ('.highslide img',
  1648. 'cursor: url('+ hs.graphicsDir + hs.expandCursor +'), pointer !important;');
  1649. }
  1650. });
  1651. hs.addEventListener(window, 'resize', function() {
  1652. hs.getPageSize();
  1653. });
  1654. hs.addEventListener(document, 'mousemove', function(e) {
  1655. hs.mouse = { x: e.clientX, y: e.clientY };
  1656. });
  1657. hs.addEventListener(document, 'mousedown', hs.mouseClickHandler);
  1658. hs.addEventListener(document, 'mouseup', hs.mouseClickHandler);
  1659. hs.addEventListener(document, 'ready', hs.getAnchors);
  1660. hs.addEventListener(window, 'load', hs.preloadImages);
  1661. }