Просмотр файла engine/classes/highslide/highslide.js

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