﻿var _timer = null; var _ssInProgress = false; var _moInfo; var _moCacheImg = new Image(); var _inPrefetch = true; var _nextMORequested = false; var _prevMORequested = false; var _showCurrentMO = false; var _fadeInMoAnimation; var _mediaObjectsToDispose = new Array(); var _widthBorderBuffer = 34; var _galleryId; var _pageLoadHasFired = false; function tbMediaObjectActions_onItemCheckChange(b, a) { var c = a.get_item(); switch (c.get_id()) { case "tbiInfo": toggleInfo(c); break; case "tbiViewHiRes": toggleHiRes(c); break; case "tbiPermalink": togglePermalink(c); break } } function tbMediaObjectActions_onItemSelect(b, a) { var c = a.get_item(); switch (c.get_id()) { case "tbiSlideshow": toggleSlideshow(c); break; case "tbiDelete": deleteObject(c); break } } function toggleInfo(a) { if (dgMediaObjectInfo.get_isShowing()) { dgMediaObjectInfo.Close() } else { setMediaObjectInfoDialogSize(); refreshMetadata($get("moid").value); dgMediaObjectInfo.Show(); updateProfile(a.get_checked()) } } function startSlideShow() { if (_tbIsVisible) { var a = tbMediaObjectActions.get_items().getItemById("tbiSlideshow"); if (a) { if (a.get_imageUrl() == "play.png") { toggleSlideshow(a) } } else { startSlideShowTimer() } } else { startSlideShowTimer() } } function toggleSlideshow(a) { if (a.get_imageUrl() == "play.png") { a.set_imageUrl("pause.png"); startSlideShowTimer() } else { if (_timer) { _timer.stop(); _ssInProgress = false } a.set_imageUrl("play.png") } } function startSlideShowTimer() { _timer = new Gsp.Timer(showNextMediaObject); _timer.set_interval(_ssDelay); _ssInProgress = true; _timer.start() } function updateProfile(a) { Gsp.Gallery.SetMetaDataVisibility(a, _galleryId) } function setMediaObjectInfoDialogSize() { if (_inPrefetch) { window.setTimeout("setMediaObjectInfoDialogSize()", 100); return } var b = 200; var h = 400; var d = 600; var e = 400; var c = document.body.clientHeight ? document.body.clientHeight : 600; var f = 52; var a = document.body.clientWidth - _moInfo.Width - f; var g = _moInfo.Height; if ($get("hr").value.toLowerCase() == "true") { a = h } else { if (a < b) { a = b } else { if (a > d) { a = d } } } if (g < e) { g = e } else { if (g > c) { g = c } } dgMediaObjectInfo.set_width(a); dgMediaObjectInfo.set_height(g) } function getDisplayType() { if (_viewHiRes) { return 3 } else { return 2 } } function showMediaObject(a) { if (typeof (dgEditCaption) !== "undefined") { if (dgEditCaption.get_isShowing()) { dgEditCaption.close() } } _showCurrentMO = true; _inPrefetch = true; Gsp.Gallery.GetMediaObjectHtml(a, getDisplayType(), getMediaObjectHtmlCompleted, getMediaObjectHtmlFailure) } function getMediaObjectHtmlCompleted(c, b, a) { _moInfo = c; if (c.NextSSUrl && c.NextSSUrl.length > 0) { _moCacheImg.src = c.NextSSUrl } _inPrefetch = false; if (_nextMORequested) { _nextMORequested = false; if (_ssInProgress && !_timer.isRunning) { _timer.start() } showNextMediaObject() } if (_prevMORequested) { _prevMORequested = false; showPrevMediaObject() } if (_showCurrentMO) { _showCurrentMO = false; showCurrentMediaObject() } } function disposeAjaxObject(a) { var b = $find(a); if (b) { b.dispose() } } function showCurrentMediaObject() { Array.forEach(_mediaObjectsToDispose, disposeAjaxObject); Array.clear(_mediaObjectsToDispose); $get(_mo).innerHTML = _moInfo.HtmlOutput; if (_moInfo.ScriptOutput.length > 0) { runScript(_moInfo.ScriptOutput, _moInfo.Id) } var b = $get(_moTitle); if (b) { b.innerHTML = _moInfo.Title } b = $get("lblMoPosition"); if (b) { b.innerHTML = _moInfo.Index + 1 } b = $get("lblMoCount"); if (b) { b.innerHTML = _moInfo.NumObjectsInAlbum } if (_tbIsVisible) { var c = tbMediaObjectActions.get_items().getItemById("tbiPermalink"); if (c) { c.set_checked(false) } Sys.UI.DomElement.removeCssClass($get("divPermalink"), "gsp_visible"); Sys.UI.DomElement.addCssClass($get("divPermalink"), "gsp_invisible"); var e = tbMediaObjectActions.get_items().getItemById("tbiViewHiRes"); if (e) { e.set_visible(_moInfo.HiResAvailable); var d = _moInfo.Width + _widthBorderBuffer; var f = parseInt($get("toolbarContainer").style.width); $get("divMoView").style.width = (d > f ? d + "px" : f + "px") } var a = tbMediaObjectActions.get_items().getItemById("tbiDownload"); if (a) { a.set_visible(_moInfo.IsDownloadable) } } document.body.style.cursor = "default" } function showNextMediaObject() { if (_inPrefetch) { document.body.style.cursor = "wait"; _nextMORequested = true; if (_ssInProgress) { _timer.stop() } return } Array.forEach(_mediaObjectsToDispose, disposeAjaxObject); Array.clear(_mediaObjectsToDispose); if ((_moInfo.NextId == 0) || (_ssInProgress && (_moInfo.NextSSId == 0))) { redirectToHomePage(); return } document.body.style.cursor = "wait"; if (typeof (dgEditCaption) !== "undefined") { if (dgEditCaption.get_isShowing()) { dgEditCaption.close() } } $get("moid").value = (_ssInProgress ? _moInfo.NextSSId : _moInfo.NextId); $get(_mo).innerHTML = (_ssInProgress ? _moInfo.NextSSHtmlOutput : _moInfo.NextHtmlOutput); if ((_ssInProgress) && (_moInfo.NextSSScriptOutput.length > 0)) { runScript(_moInfo.NextSSScriptOutput, _moInfo.NextSSId) } else { if ((!_ssInProgress) && (_moInfo.NextScriptOutput.length > 0)) { runScript(_moInfo.NextScriptOutput, _moInfo.NextId) } } var a = $get("mo_img"); if (a) { a.src = _moCacheImg.src; if (_fadeInMoAnimation) { _fadeInMoAnimation.set_target(a); _fadeInMoAnimation.play() } } var h = $get(_moTitle); if (h) { h.innerHTML = (_ssInProgress ? _moInfo.NextSSTitle : _moInfo.NextTitle) } ctl = $get("lblMoPosition"); if (ctl) { ctl.innerHTML = (_ssInProgress ? _moInfo.NextSSIndex + 1 : _moInfo.Index + 2) } ctl = $get("lblMoCount"); if (ctl) { ctl.innerHTML = _moInfo.NumObjectsInAlbum } if (_tbIsVisible) { var d = tbMediaObjectActions.get_items().getItemById("tbiPermalink"); if (d) { d.set_checked(false) } Sys.UI.DomElement.removeCssClass($get("divPermalink"), "gsp_visible"); Sys.UI.DomElement.addCssClass($get("divPermalink"), "gsp_invisible"); var g = tbMediaObjectActions.get_items().getItemById("tbiViewHiRes"); if (g) { if (_ssInProgress) { g.set_visible(_moInfo.NextSSHiResAvailable) } else { g.set_visible(_moInfo.NextHiResAvailable) } var b = (_ssInProgress ? _moInfo.NextSSWidth : _moInfo.NextWidth); var e = b + _widthBorderBuffer; var i = parseInt($get("toolbarContainer").style.width); $get("divMoView").style.width = (e > i ? e + "px" : i + "px") } var c = tbMediaObjectActions.get_items().getItemById("tbiDownload"); if (c) { if (_ssInProgress) { c.set_visible(_moInfo.NextSSIsDownloadable) } else { c.set_visible(_moInfo.NextIsDownloadable) } } } if ((typeof (dgMediaObjectInfo) != "undefined") && dgMediaObjectInfo.get_isShowing()) { if (_ssInProgress) { refreshMetadata(_moInfo.NextSSId) } else { refreshMetadata(_moInfo.NextId) } } document.body.style.cursor = "default"; _inPrefetch = true; var f = (_ssInProgress ? _moInfo.NextSSId : _moInfo.NextId); Gsp.Gallery.GetMediaObjectHtml(f, getDisplayType(), getMediaObjectHtmlCompleted, getMediaObjectHtmlFailureOnNavigate) } function getMediaObjectHtmlFailureOnNavigate(b, c, a) { if (b.get_exceptionType() == "GalleryServerPro.ErrorHandler.CustomExceptions.InvalidMediaObjectException") { Gsp.Gallery.GetMediaObjectHtml(_moInfo.Id, getDisplayType(), getMediaObjectHtmlCompleted, getMediaObjectHtmlFailure) } else { _inPrefetch = false } } function getMediaObjectHtmlFailure(b, c, a) { if (b.get_exceptionType() == "GalleryServerPro.ErrorHandler.CustomExceptions.InvalidMediaObjectException") { alert(b.get_message()) } else { alert(b.get_exceptionType() + ": " + b.get_message()) } _inPrefetch = false } function showPrevMediaObject() { if (_inPrefetch) { document.body.style.cursor = "wait"; _prevMORequested = true; return } Array.forEach(_mediaObjectsToDispose, disposeAjaxObject); Array.clear(_mediaObjectsToDispose); if (_moInfo.PrevId == 0) { redirectToHomePage(); return } document.body.style.cursor = "wait"; if (typeof (dgEditCaption) !== "undefined") { if (dgEditCaption.get_isShowing()) { dgEditCaption.close() } } $get("moid").value = _moInfo.PrevId; $get(_mo).innerHTML = _moInfo.PrevHtmlOutput; if (_moInfo.PrevScriptOutput.length > 0) { runScript(_moInfo.PrevScriptOutput, _moInfo.PrevId) } var a = $get("mo_img"); if (a && _fadeInMoAnimation) { _fadeInMoAnimation.set_target(a); _fadeInMoAnimation.play() } var d = $get(_moTitle); if (d) { d.innerHTML = _moInfo.PrevTitle } ctl = $get("lblMoPosition"); if (ctl) { ctl.innerHTML = _moInfo.Index } ctl = $get("lblMoCount"); if (ctl) { ctl.innerHTML = _moInfo.NumObjectsInAlbum } if (_tbIsVisible) { var c = tbMediaObjectActions.get_items().getItemById("tbiPermalink"); if (c) { c.set_checked(false) } Sys.UI.DomElement.removeCssClass($get("divPermalink"), "gsp_visible"); Sys.UI.DomElement.addCssClass($get("divPermalink"), "gsp_invisible"); var f = tbMediaObjectActions.get_items().getItemById("tbiViewHiRes"); if (f) { f.set_visible(_moInfo.PrevHiResAvailable); var e = _moInfo.PrevWidth + _widthBorderBuffer; var g = parseInt($get("toolbarContainer").style.width); $get("divMoView").style.width = (e > g ? e + "px" : g + "px") } var b = tbMediaObjectActions.get_items().getItemById("tbiDownload"); if (b) { b.set_visible(_moInfo.PrevIsDownloadable) } } if ((typeof (dgMediaObjectInfo) != "undefined") && dgMediaObjectInfo.get_isShowing()) { refreshMetadata(_moInfo.PrevId) } document.body.style.cursor = "default"; _inPrefetch = true; Gsp.Gallery.GetMediaObjectHtml(_moInfo.PrevId, getDisplayType(), getMediaObjectHtmlCompleted, getMediaObjectHtmlFailureOnNavigate) } function dgMediaObjectInfo_OnClose(b, a) { if (_tbIsVisible) { var c = tbMediaObjectActions.get_items().getItemById("tbiInfo"); if (c) { c.set_checked(false) } } updateProfile(false) } function refreshMetadata(a) { Gsp.Gallery.GetMetadataItems(a, refreshMetadataCompleted) } function refreshMetadataCompleted(a) { gdmeta.load(a); gdmeta.render() } function gdmeta_onLoad(b, a) { if (_tbIsVisible) { var c = tbMediaObjectActions.get_items().getItemById("tbiInfo"); if ((c) && c.get_checked()) { setMediaObjectInfoDialogSize(); gdmeta.render(); dgMediaObjectInfo.Show() } } } function setDialogSize(b, d, a) { var c = document.getElementById(b.get_id()); b.beginUpdate(); b.Width = d; b.Height = a; if (Sys.Browser.agent != Sys.Browser.InternetExplorer) { c.style.width = d + "px"; c.style.height = a + "px" } b.endUpdate() } function runScript(script, moid) { try { eval(script) } catch (e) { window.location = getPermalink(moid) } } function getEmbedCode(a) { return "<iframe allowtransparency='true' frameborder='0' sandbox='allow-same-origin allow-forms allow-scripts' scrolling='auto' src='" + _galleryResourcesUrl + "/embed.aspx?moid=" + a + "' style='width:100%;height:100%'></iframe>" } function getPermalink(c) { var a = removeQSParm(document.location.href, "msg"); a = replaceQSParm(a, "moid", c); if (_tbIsVisible) { var b = tbMediaObjectActions.get_items().getItemById("tbiViewHiRes"); if (b && b.get_checked()) { return replaceQSParm(a, "hr", 1) } else { return removeQSParm(a, "hr") } } } function replaceQSParm(a, d, c) { var b = new RegExp("([?|&])" + d + "=.*?(&|$)", "i"); if (a.match(b)) { return a.replace(b, "$1" + d + "=" + c + "$2") } else { if (a.indexOf("?") == -1) { return a + "?" + d + "=" + c } else { return a + "&" + d + "=" + c } } } function removeQSParm(a, c) { var b = new RegExp("(&)" + c + "=.*?(&|$)", "i"); if (a.match(b)) { return a.replace(b, "$2") } else { return a } } Type.registerNamespace("Gsp"); Gsp.Timer = function (a) { this._interval = 10000; this._raiseTickDelegate = Function.createDelegate(this, this._tick); this._userCallback = a; this._timer = null }; function Gsp$Timer$get_interval() { return this._interval } function Gsp$Timer$set_interval(a) { this._interval = a } function Gsp$Timer$stop() { this._stopTimer() } function Gsp$Timer$start() { this._startTimer() } function Gsp$Timer$_tick() { if (this._userCallback !== null) { this._userCallback() } this._startTimer() } function Gsp$Timer$_startTimer() { this._timer = window.setTimeout(this._raiseTickDelegate, this.get_interval()) } function Gsp$Timer$_stopTimer() { if (this._timer !== null) { window.clearTimeout(this._timer); this._timer = null } } function Gsp$Timer$_isRunning() { return (this._timer !== null) } Gsp.Timer.prototype = { get_interval: Gsp$Timer$get_interval, set_interval: Gsp$Timer$set_interval, stop: Gsp$Timer$stop, start: Gsp$Timer$start, _tick: Gsp$Timer$_tick, _startTimer: Gsp$Timer$_startTimer, _stopTimer: Gsp$Timer$_stopTimer, _isRunning: Gsp$Timer$_isRunning }; Gsp.Timer.registerClass("Gsp.Timer"); Sys.Application.notifyScriptLoaded();
