(function() {
			window.addEventListener('resize', function(ev) {
				BLB.Images.vpW = BLB.getViewportWidth();
				var thumbsCount = Math.floor(BLB.Images.vpW/BLB.Images.thumbWidth)-2;
				thumbsCount = (thumbsCount%2?thumbsCount:thumbsCount-1);

				if(thumbsCount != BLB.Images.thumbsCount) {
					for(var tmpThumbsCount=BLB.Images.thumbsCount;tmpThumbsCount<=thumbsCount;tmpThumbsCount+=2) {
						var thumbsHalfway = Math.ceil(tmpThumbsCount/2);

						if(BLB.Images.imgListHalfway-thumbsHalfway-BLB.Images.thumbDistance+1 >= 0)
							BLB.Images.prefetchThumbnail(BLB.Images.imgListHalfway-thumbsHalfway-BLB.Images.thumbDistance+1);

						if(BLB.Images.imgListHalfway+thumbsHalfway+BLB.Images.thumbDistance-1 < BLB.Images.imgList.length)
							BLB.Images.prefetchThumbnail(BLB.Images.imgListHalfway+thumbsHalfway+BLB.Images.thumbDistance-1);
					}

					BLB.Images.windowShift((thumbsCount-BLB.Images.thumbsCount)/2);
					BLB.Images.thumbsCount = thumbsCount;
					BLB.Images.setCarouselWindowWidth();
				}
			});

			BLB.Images = {
				currentThumb: null,
				currentImgId: null,
				thumbsCount: 0,
				thumbDistance: 3,
				thumbWidth: 69,
				imgListHalfway: 0,
				carouselClick: false,
				callBackStack: [],
				galleryName: "Job",
				imgList: [824,825,826,828,831,832,833,834,835,836,837,839,840,841,843,844,845,846,847,848,849,851,852,853,854,1134,1135,1136,1137,1138,1139,1146,1147,1148,1446,1482,1484,1505,1559,1714,1721,1890,1892,1893,1894,1895,1900],
				cropped: {img_824:'j1_a.jpg',img_825:'j2_a.jpg',img_826:'j4_a.jpg',img_828:'hs1_55_a.jpg',img_831:'hs1_56_a.jpg',img_832:'lb2job_2_9_a.jpg',img_833:'j7_a.jpg',img_834:'j8_a.jpg',img_835:'j9_a.jpg',img_836:'j10_a.jpg',img_837:'j11_a.jpg',img_839:'j13_a.jpg',img_840:'j14_a.jpg',img_841:'j15_a.jpg',img_843:'j17_a.jpg',img_844:'j18_a.jpg',img_845:'j19_a.jpg',img_846:'j20_a.jpg',img_847:'j21_a.jpg',img_848:'llh_003_a.jpg',img_849:'llh_079_a.jpg',img_851:'llh_206_1_a.jpg',img_852:'llh_206_2_a.jpg',img_853:'llh_352_a.jpg',img_854:'llh_353_a.jpg',img_1134:'sb32a_a.jpg',img_1135:'sb32b_a.jpg',img_1136:'sb32c_a.jpg',img_1137:'sb32d_a.jpg',img_1138:'sb32e_a.jpg',img_1139:'sb32f_a.jpg',img_1146:'sb32l_a.jpg',img_1147:'sb32m_a.jpg',img_1148:'sb32n_a.jpg',img_1446:'OT_timeline2_a.jpg',img_1482:'wc_00bible_a.jpg',img_1484:'wc_00ot_a.jpg',img_1505:'wc_18job_a.jpg',img_1559:'wc_00ot_3wisdom_a.jpg',img_1714:'c58_a.jpg',img_1721:'c65_a.jpg',img_1890:'snapboard_gen_18_25_a.jpg',img_1892:'snapboard_gen_25_8_a.jpg',img_1893:'snapboard_job_8_2_a.jpg',img_1894:'snapboard_job_38-39_a.jpg',img_1895:'snapboard_job_42_4_a.jpg',img_1900:'snapboard_mar_6_48_a.jpg'},
				thumbs: {img_824:'j1_b',img_825:'j2_b',img_826:'j4_b',img_828:'hs1_55_b',img_831:'hs1_56_b',img_832:'lb2job_2_9_b',img_833:'j7_b',img_834:'j8_b',img_835:'j9_b',img_836:'j10_b',img_837:'j11_b',img_839:'j13_b',img_840:'j14_b',img_841:'j15_b',img_843:'j17_b',img_844:'j18_b',img_845:'j19_b',img_846:'j20_b',img_847:'j21_b',img_848:'llh_003_b',img_849:'llh_079_b',img_851:'llh_206_1_b',img_852:'llh_206_2_b',img_853:'llh_352_b',img_854:'llh_353_b',img_1134:'sb32a_b',img_1135:'sb32b_b',img_1136:'sb32c_b',img_1137:'sb32d_b',img_1138:'sb32e_b',img_1139:'sb32f_b',img_1146:'sb32l_b',img_1147:'sb32m_b',img_1148:'sb32n_b',img_1446:'OT_timeline2_b',img_1482:'wc_00bible_b',img_1484:'wc_00ot_b',img_1505:'wc_18job_b',img_1559:'wc_00ot_3wisdom_b',img_1714:'c58_b',img_1721:'c65_b',img_1890:'snapboard_gen_18_25_b',img_1892:'snapboard_gen_25_8_b',img_1893:'snapboard_job_8_2_b',img_1894:'snapboard_job_38-39_b',img_1895:'snapboard_job_42_4_b',img_1900:'snapboard_mar_6_48_b'},
				imgFull: {img_824:'j1.jpg',img_825:'j2.jpg',img_826:'j4.jpg',img_828:'hs1_55.jpg',img_831:'hs1_56.jpg',img_832:'lb2job_2_9.jpg',img_833:'j7.jpg',img_834:'j8.jpg',img_835:'j9.jpg',img_836:'j10.jpg',img_837:'j11.jpg',img_839:'j13.jpg',img_840:'j14.jpg',img_841:'j15.jpg',img_843:'j17.jpg',img_844:'j18.jpg',img_845:'j19.jpg',img_846:'j20.jpg',img_847:'j21.jpg',img_848:'llh_003.jpg',img_849:'llh_079.jpg',img_851:'llh_206_1.jpg',img_852:'llh_206_2.jpg',img_853:'llh_352.jpg',img_854:'llh_353.jpg',img_1134:'sb32a.jpg',img_1135:'sb32b.jpg',img_1136:'sb32c.jpg',img_1137:'sb32d.jpg',img_1138:'sb32e.jpg',img_1139:'sb32f.jpg',img_1146:'sb32.jpg',img_1147:'sb32.jpg',img_1148:'sb32.jpg',img_1446:'OT_timeline2.jpg',img_1482:'wc_00bible.jpg',img_1484:'wc_00ot.jpg',img_1505:'wc_18job.jpg',img_1559:'wc_00ot_3wisdom.jpg',img_1714:'c58.jpg',img_1721:'c65.jpg',img_1890:'snapboard_gen_18_25.jpg',img_1892:'snapboard_gen_25_8.jpg',img_1893:'snapboard_job_8_2.jpg',img_1894:'snapboard_job_38-39.jpg',img_1895:'snapboard_job_42_4.jpg',img_1900:'snapboard_mar_6_48.jpg'},
				imgPDF: {img_824:'',img_825:'',img_826:'',img_828:'',img_831:'',img_832:'',img_833:'',img_834:'',img_835:'',img_836:'',img_837:'',img_839:'',img_840:'',img_841:'',img_843:'',img_844:'',img_845:'',img_846:'',img_847:'',img_848:'',img_849:'',img_851:'',img_852:'',img_853:'',img_854:'',img_1134:'',img_1135:'',img_1136:'',img_1137:'',img_1138:'',img_1139:'',img_1146:'',img_1147:'',img_1148:'',img_1446:'',img_1482:'wc_00bible.pdf',img_1484:'wc_00ot.pdf',img_1505:'wc_18job.pdf',img_1559:'wc_00ot_3wisdom.pdf',img_1714:'',img_1721:'',img_1890:'',img_1892:'',img_1893:'',img_1894:'',img_1895:'',img_1900:''},
				titles: {img_824:'Job\'s Family',img_825:'The Sons of God before the Lord',img_826:'I Only Am Escaped to Tell Thee',img_828:'Job Receives His Misfortunes from God',img_831:'Job Sitting in Ashes',img_832:'Job Reproves His Wife',img_833:'Shall We Receive Good and Not Evil?',img_834:'Job Curses the Day of His Birth',img_835:'A Spirit Passing before Job',img_836:'Job Mocked',img_837:'Job Dreaming',img_839:'The Lord from a Whirlwind',img_840:'Where Wast Thou?',img_841:'Behemoth before Job',img_843:'Job Repenting',img_844:'Job Praying for His Friends',img_845:'Job Receiving Money',img_846:'Job and His Daughters',img_847:'Job Blessings',img_848:'Job\'s Resignation',img_849:'Job and His Friends',img_851:'Job Informed of His Losses',img_852:'Job in Adversity Visited by His Friends',img_853:'Job and His Friends',img_854:'Job Hearing of His Ruin',img_1134:'Harp 1',img_1135:'Harp 2',img_1136:'Harp 3',img_1137:'Harp 4',img_1138:'Harp 5',img_1139:'Harp 6',img_1146:'Horn 3',img_1147:'Drum 1',img_1148:'Drum 2',img_1446:'Old Testament Time Line (Part 2 of 2)',img_1482:'The Bible - Word Cloud',img_1484:'The Old Testament - Word Cloud',img_1505:'Job - Word Cloud',img_1559:'The Books of Wisdom - Word Cloud',img_1714:'The Spirit World',img_1721:'Satan: "The God of This Age"',img_1890:'Abraham Quotes Elihu from the Job Story?',img_1892:'Abraham\'s Death is Described Almost Exactly Like Job\'s',img_1893:'Lessons in How Not to Counsel',img_1894:'God\'s Dialogue with Job Retells All Six Days of Creation',img_1895:'Humbling Moment in Job',img_1900:'Jesus Walking on Water & Job 9'},
				paths: {img_824:'Job',img_825:'Job',img_826:'Job',img_828:'Job',img_831:'Job',img_832:'Job',img_833:'Job',img_834:'Job',img_835:'Job',img_836:'Job',img_837:'Job',img_839:'Job',img_840:'Job',img_841:'Job',img_843:'Job',img_844:'Job',img_845:'Job',img_846:'Job',img_847:'Job',img_848:'Job',img_849:'Job',img_851:'Job',img_852:'Job',img_853:'Job',img_854:'Job',img_1134:'Instruments',img_1135:'Instruments',img_1136:'Instruments',img_1137:'Instruments',img_1138:'Instruments',img_1139:'Instruments',img_1146:'Instruments',img_1147:'Instruments',img_1148:'Instruments',img_1446:'rosepub',img_1482:'wordclouds',img_1484:'wordclouds',img_1505:'wordclouds',img_1559:'wordclouds',img_1714:'larkin',img_1721:'larkin',img_1890:'snapboards',img_1892:'snapboards',img_1893:'snapboards',img_1894:'snapboards',img_1895:'snapboards',img_1900:'snapboards'},
				imgKeywords: {img_824:'Job',img_825:'Job',img_826:'Job',img_828:'Job',img_831:'Job',img_832:'Job, Wife, Reproves',img_833:'Job',img_834:'Job',img_835:'hair, spirit',img_836:'Job',img_837:'Job',img_839:'Job',img_840:'Job',img_841:'Behemoth',img_843:'Job',img_844:'Job',img_845:'Job',img_846:'Job',img_847:'Job',img_848:'Job;',img_849:'Job;',img_851:'Job;',img_852:'Job;',img_853:'Job;',img_854:'Job; Ruin',img_1134:'harp; harps;',img_1135:'harp; harps;',img_1136:'harp; harps;',img_1137:'harp; harps;',img_1138:'harp; harps;',img_1139:'harp; harps;',img_1146:'horn; horns; trumpet;',img_1147:'timbrel; tabret;',img_1148:'timbrel; tabret;',img_1446:'Amos; Cyrus; David; Eli; Elijah; Elisha; Habakkuk; Haggai; Hezekiah; Hosea; Hoshea; Jeroboam; Jonah; Josiah; Judges; Malachi; Manasseh; Micah; Nahum; Nehemiah; Nineveh; Obadiah; Rebuilding the Temple; Ruth; Samuel; Saul; Solomon; Zechariah; Zephaniah',img_1482:'',img_1484:'',img_1505:'',img_1559:'',img_1714:'Spirit;World;Cherub;Earth;Heavenly;Prince;Power;Air;Age;Grave;Paradise;Hell;Lake;Fire;New;Judgment;White;Throne',img_1721:'Satan;God;Age;Third;Heaven;Prince;Power;Air;Earth;Grave;Day ;Paradise;Prison;Fallen;Angels;Present;Dispensation;Dragon;Trinity;Beast;Prophet;Tribulation;Period;Millennium;Great;White;Throne;Nations;Blessing;Kingdom;Serpent;War;Lake;Fire;Bottomless;Pit',img_1890:'Abraham; Elihu; Job',img_1892:'Abraham; Job',img_1893:'Job; great wind',img_1894:'creation; Job; Genesis',img_1895:'Job; ',img_1900:'Jesus'},
				imgScripture: {img_824:'Job 1:1-2',img_825:'Job 1:6',img_826:'Job 1:13-19',img_828:'Job 1:20-22',img_831:'Job 2:8',img_832:'Job 2:9-10',img_833:'Job 2:10',img_834:'Job 3:1-26',img_835:'Job 4:15',img_836:'Job 12:4; Job 18:1-21; Job 19:21',img_837:'Job 7:14',img_839:'Job 38:1-41',img_840:'Job 38:4-41',img_841:'Job 40:15-24',img_843:'Job 42:1-6',img_844:'Job 42:7-10',img_845:'Job 42:11',img_846:'Job 42:15',img_847:'Job 42:10-17',img_848:'Job 1:21-22',img_849:'Job 2:11-13',img_851:'Job 1:13-22',img_852:'Job 4:1-21',img_853:'Job 32:1-22',img_854:'Job 1:13-22',img_1134:'Gen 4:21; Gen 31:27; 1Sa 10:5; 1Sa 16:23; 2Sa 6:5; Job 21:12; Psa 33:2; Psa 43:4; Psa 147:7; Isa 5:12',img_1135:'Gen 4:21; Gen 31:27; 1Sa 10:5; 1Sa 16:23; 2Sa 6:5; Job 21:12; Psa 33:2; Psa 43:4; Psa 147:7; Isa 5:12',img_1136:'Gen 4:21; Gen 31:27; 1Sa 10:5; 1Sa 16:23; 2Sa 6:5; Job 21:12; Psa 33:2; Psa 43:4; Psa 147:7; Isa 5:12',img_1137:'Gen 4:21; Gen 31:27; 1Sa 10:5; 1Sa 16:23; 2Sa 6:5; Job 21:12; Psa 33:2; Psa 43:4; Psa 147:7; Isa 5:12',img_1138:'Gen 4:21; Gen 31:27; 1Sa 10:5; 1Sa 16:23; 2Sa 6:5; Job 21:12; Psa 33:2; Psa 43:4; Psa 147:7; Isa 5:12',img_1139:'Gen 4:21; Gen 31:27; 1Sa 10:5; 1Sa 16:23; 2Sa 6:5; Job 21:12; Psa 33:2; Psa 43:4; Psa 147:7; Isa 5:12',img_1146:'Exd 19:13-25; Lev 25:9; Num 10:1-10; Jos 6:5; Jdg 3:27; Jdg 6:34; Jdg 7:16; 1Sa 13:3; 2Sa 2:28; 2Sa 6:15; 2Sa 15:10; 2Sa 18:16; 2Sa 20:1; 1Ki 1:34; Neh 4:18; Job 39:24',img_1147:'Gen 31:27; Exd 15:20; 1Sa 10:5; Job 17:6; Job 21:12; Psa 81:2; Psa 149:3; Psa 150:4; Isa 5:12',img_1148:'Gen 31:27; Exd 15:20; 1Sa 10:5; Job 17:6; Job 21:12; Psa 81:2; Psa 149:3; Psa 150:4; Isa 5:12',img_1446:'Jdg 1-21; Rth 4:13; 1Sam 1-15; 2Sam 1-20; 2Ch 1-4; 2Ch 10; 2Ch 33; 1Ki 12; 1Ki 17-19; 1Ki 21; 2Ki 1-8; 2Ki 13; 2Ki 18-23; Ezr 1:1-4; Ezr 3:8-13; Ezr 4-6; Neh 1-13; Hos 1-14; Amo 1-9; Oba 1; Jon 1-4; Mic 1-7; Nah 1-3; Hab 1-3; Zep 1-3; Hag 1-2; Zec 1-14; Mal 1-4;',img_1482:'',img_1484:'',img_1505:'',img_1559:'',img_1714:'Gen 1:1;Job 1:1-2:10;Psa 68:18;Isa 14:13-14;Eze 28:14;Mat 27:51-53;Mar 16:19;Luk 16:19-31;Jhn 6:28-29;Jhn 12:31;Jhn 14:30;Rom 8:34;Rom 14:10;2Co 4:4;2Co 5:10;Eph 2:2;Eph 4:8-10;Eph 6:11-18;1Th 4:13-18;1Th 4:16;1Th 4:17;2Pe 2:4;Jde 6;Rev 1:18;Rev 9:1-2;Rev 12:7-12;Rev 20:5;Rev 20:7-10;Rev 20:11-15;Rev 21:1;Rev 21:1-2',img_1721:'Gen 6:1-4;Gen 6:2;Gen 11:1-9;Gen 11:6;Gen 19:1-38;Exo 4:1-5;Exo 7:10-13;Job 1:1-2:10;Job 1:6-7;Isa 14:12-17;Isa 14:13-14;Eze 28:12-19;Eze 28:14;Dan 12:1;Zec 14:4;Mat 4:1-11;Mat 4:24;Mat 12:24-30;Mat 24:21;Mat 25:31-46;Luk 8:26-36;Jhn 12:31;Jhn 14:30;Act 19:11-17;2Co 4:4;Eph 2:2;Eph 6:11-12;Eph 6:11-18;1Th 4:16-17;2Th 1:7-10;1Ti 4:1-3;2Pe 2:4-10;Jde 6-7;Rev 9:1-11;Rev 12:1-6;Rev 12:7-12;Rev 16:12-14;Rev 19:1-21;Rev 20:1-3;Rev 20:7-8;Rev 20:10;Rev 20:11-15;Rev 20:14-15',img_1890:'Gen 18:25; Job 34:10',img_1892:'Job 42:17; Gen 25:8',img_1893:'Job 8:1-2; Job 1:19',img_1894:'Gen 1:3; Job 38:19; Gen 1:14; Job 38:31-33; Gen 1:6; Job 38:8-11; Gen 1:20; Job 39:26-27; Gen 1:11; Job 38:25-27; Gen 1:24; Job 39:1,5,9; Gen 3:15',img_1895:'Job 38:3; Job 42:4',img_1900:'Job 9; Job 9:8; Job 9:11; Job 9:4,11; Mar 6:45-52; Mar 6:48; Mar 6:52'},
				imgDescription: {img_824:'',img_825:'',img_826:'',img_828:'',img_831:'',img_832:'',img_833:'',img_834:'',img_835:'',img_836:'',img_837:'',img_839:'',img_840:'',img_841:'',img_843:'',img_844:'',img_845:'',img_846:'',img_847:'',img_848:'',img_849:'',img_851:'',img_852:'',img_853:'',img_854:'',img_1134:'',img_1135:'',img_1136:'',img_1137:'',img_1138:'',img_1139:'',img_1146:'',img_1147:'',img_1148:'',img_1446:'',img_1482:'<p>These Bible word clouds feature the top 150 to 300 words used in the indicated section of Scripture.</p>',img_1484:'<p>These Bible word clouds feature the top 150 to 300 words used in the indicated section of Scripture.</p>',img_1505:'<p>These Bible word clouds feature the top 150 to 300 words used in the indicated section of Scripture.</p>',img_1559:'<p>These Bible word clouds feature the top 150 to 300 words used in the indicated section of Scripture.</p>',img_1714:'',img_1721:'',img_1890:'',img_1892:'',img_1893:'',img_1894:'',img_1895:'',img_1900:''},

				init: function() {
					if(BLB.blbIsLoaded) {

						YEvent.delegate("imgCarousel", "click", BLB.Images.onClickHndlr, "div");
						YEvent.delegate("imgParade", "click", BLB.Images.onClickHndlr, "div.imgParBrowse");
						YEvent.delegate("imgBody", "click", BLB.Images.onClickHndlr, "div");
						YEvent.delegate("imgBody", "click", BLB.Images.onClickHndlr, "img");
						YEvent.delegate("imgShareLinks", "click", BLB.Images.onClickHndlr, "img");
						YEvent.delegate("imgLegend", "click", BLB.Images.onClickHndlr, "a[class=imgpop]");
						lftRtArrow = new KeyListener(document, {shift:false, ctrl:false, alt:false, keys:[BLB.keyCodes.leftArrow, BLB.keyCodes.rightArrow]}, function(ev, evA) {
							if(evA[1].target.tagName == 'INPUT') return false;
							if(evA[1].target.tagName == 'TEXTAREA') return false;
							if(BLB.Images.imgList.length > 1) {
								var currentImg = document.querySelector('#' + BLB.Images.currentImgId);
								switch(evA[0]) {
									case BLB.keyCodes.leftArrow:
										var nextState = BLB.Images.thumbs[currentImg.previousSibling.id];
										BLB.Images.historyNavigate(nextState);
										break;
									case BLB.keyCodes.rightArrow:
										var nextState = BLB.Images.thumbs[currentImg.nextSibling.id];
										BLB.Images.historyNavigate(nextState);
										break;
									default:
										break;

								};
							}
						}, 'keydown');
						lftRtArrow.enable();

						window.addEventListener('popstate', BLB.Images.popstateEventHandler);
						var state = BLB.Images.getBookmarkedState();
						if(state.toLowerCase() == 'imagedisplay' && document.location.hash != '') {
							var h = document.location.hash.split(/=/)[1];
							document.location.href = document.location.pathname + h;
						}

						var distance = 0;
						var thumbsCount = 0;
						var imgCount = BLB.Images.imgList.length;
						var imgListHalfway = Math.floor(imgCount/2);

						for(var thumb in BLB.Images.thumbs) {
							if(state == BLB.Images.thumbs[thumb]) {
								BLB.Images.currentThumb = state;
								BLB.Images.currentImgId = thumb;
								break;
							}
							distance++;
						}

						BLB.Images.vpW = BLB.getViewportWidth();
						thumbsCount = Math.floor(BLB.Images.vpW/BLB.Images.thumbWidth)-2;
						BLB.Images.thumbsCount = (thumbsCount%2?thumbsCount:thumbsCount-1);
						BLB.Images.imgListHalfway = (imgCount%2?imgListHalfway:imgListHalfway-1);
						BLB.Images.setCarouselWidth();
						BLB.Images.setCarouselWindowWidth();
						var imgCarousel = document.querySelector('#imgCarousel');
						imgCarousel.style.left = '-12px';

						if(BLB.Images.imgListHalfway > distance)
							for(var i=0;i<BLB.Images.imgListHalfway-distance;i++) BLB.Images.imgList.unshift(BLB.Images.imgList.pop());
						else
							for(var i=0;i<distance-BLB.Images.imgListHalfway;i++) BLB.Images.imgList.push(BLB.Images.imgList.shift());

						for(var i=0;i<BLB.Images.imgList.length;i++) {
							var cDiv = document.createElement('div');
							var imgKey = 'img_'+BLB.Images.imgList[i];

							cDiv.id=imgKey;
							if(state==BLB.Images.thumbs[imgKey]) {
								BLB.Images.windowShift((BLB.Images.thumbsCount+1)/2-(i+1));
								cDiv.classList.add('imgParCenter');
							}
							cDiv.appendChild(document.createElement('img'));
							imgCarousel.appendChild(cDiv);

							BLB.Images.prefetchThumbnail(i);
						}
						BLB.Images.updateImgMainBody();
					} else {
						setTimeout(function() { BLB.Images.init(); }, 100);
					}
				},

				// Event delegate single click events
				onClickHndlr: function(ev, matchedEl, container) {
					var currentImg = document.querySelector('#' + BLB.Images.currentImgId);
					switch(container.id) {
						case 'imgBody':
							if(matchedEl.id == 'imgAlertClose') {
								var myBLB = new mBLB();
								myBLB.imgAlertClose();
								matchedEl.parentNode.parentNode.removeChild(matchedEl.parentNode);
								YEvent.stopPropagation(ev);
							} else if(matchedEl.id == 'imgNavR' && BLB.Images.imgList.length > 1) {
								var nextState = BLB.Images.thumbs[currentImg.nextSibling.id];
								BLB.Images.historyNavigate(nextState);
							} else if(matchedEl.id == 'imgNavL' && BLB.Images.imgList.length > 1) {
								var nextState = BLB.Images.thumbs[currentImg.previousSibling.id];
								BLB.Images.historyNavigate(nextState);
							} else if(matchedEl.id == 'imgExact' || matchedEl.id == 'imgZoom') {
								var fullImg = BLB.Images.imgFull[BLB.Images.currentImgId];
								var path = BLB.Images.paths[BLB.Images.currentImgId];
								location.href = '/assets-v3/images/bibleMedia/' + path + '/' + fullImg;
							}
							break;
						case 'imgCarousel':
							if(BLB.Images.imgList.length > 1)
								if(matchedEl.classList.contains('imgParCenter')) {
									var nextState = BLB.Images.thumbs[currentImg.nextSibling.id];
									BLB.Images.historyNavigate(nextState);
								} else {
									var nextState = BLB.Images.thumbs[matchedEl.id];
									BLB.Images.historyNavigate(nextState);
								}
							break;
						case 'imgParade':
							if(BLB.Images.imgList.length > 1)
								if(matchedEl.id=='imgParBrowseRt') {
									var nextState = BLB.Images.thumbs[currentImg.nextSibling.id];
									BLB.Images.historyNavigate(nextState);
								} else {
									var nextState = BLB.Images.thumbs[currentImg.previousSibling.id];
									BLB.Images.historyNavigate(nextState);
								}
							break;
						case 'imgShareLinks':
							if (matchedEl.dataset !== undefined && matchedEl.dataset.sharer !== undefined) {
								var platform = matchedEl.dataset.sharer;
								if (platform == 'shareLink') {
									document.querySelector('#pageLink').click();
									document.querySelector('#imgShareFeedback').innerHTML = "<br /><hr />Please click on the [COPY] button at the top of this page to copy a link to this image.<hr />";
									setTimeout(function() {
										document.querySelector('#imgShareFeedback').innerHTML = "";
									}, 7000);
								}
								else if (platform == 'shareEmail') {
									var email=('<<Enter Recipient Email Here>>');
									var subject = ('An image from Blue Letter Bible');
									var body = 'I wanted to share this wonderful image with you: '+window.location.href;
									var emailLink = document.createElement('a');
									emailLink.href = 'mailto:' + email+'?subject=' +subject+'&body=' +body;
									emailLink.target = '_blank';
									emailLink.click();
								}
								else {
									BLB.sharePage(platform);
								}
							}
							break;
						case 'imgLegend':
						    var linkName = matchedEl.rel;
                            var param = location.href;
                            var popupDiv = document.querySelector('#popupDiv');
            
                            document.querySelector('#popupDivContents').innerHTML = BLB.popupDivContents;
							popupDiv.classList.remove('hidden');
							popupDiv.style.width = '500px';
                            BLB.setXY(matchedEl, popupDiv);
                            BLB.toolTipPopup(linkName, param);
                            YEvent.stopPropagation(ev);
						    break;
						default:
							break;
					};
				},

				slideCarouselWindow: function(direction, count) {
					var thisThumb = document.querySelector('#' + BLB.Images.currentImgId);
					var nextThumb = (direction=='left' ? thisThumb.nextSibling : thisThumb.previousSibling);
					var thumbsHalfway = Math.ceil(BLB.Images.thumbsCount/2);
					var imgCarousel = document.querySelector('#imgCarousel');
	//				var thumbWidth = parseInt(imgCarousel.style.width, 10);
	//				var thumbMarginLeft = parseInt(imgCarousel.style.marginLeft, 10);
					var windowDistance = 69 * (direction=='left'?-1:1);
					var imgCarouselLeft = parseInt(imgCarousel.style.left, 10);
					var imgCarouselKeyFrames = new KeyframeEffect(imgCarousel,
							[
								{
									left: (imgCarouselLeft + windowDistance) + 'px'
								}
							],
							100
						);
					var imgCarouselKeyAnimation = new Animation(imgCarouselKeyFrames, document.timeline);

					imgCarouselKeyAnimation.addEventListener("finish", () => {
						imgCarouselKeyAnimation.commitStyles();
						if(direction=='left') {
							imgCarousel.appendChild(imgCarousel.firstChild)
							BLB.Images.imgList.push(BLB.Images.imgList.shift());
							if (thumbsHalfway+BLB.Images.thumbDistance <= BLB.Images.imgListHalfway)
								BLB.Images.prefetchThumbnail(BLB.Images.imgListHalfway+thumbsHalfway+BLB.Images.thumbDistance);
						} else {
							imgCarousel.insertBefore(imgCarousel.lastChild, imgCarousel.firstChild)
							BLB.Images.imgList.unshift(BLB.Images.imgList.pop());
							if (thumbsHalfway+BLB.Images.thumbDistance <= BLB.Images.imgListHalfway)
								BLB.Images.prefetchThumbnail(BLB.Images.imgListHalfway-thumbsHalfway-BLB.Images.thumbDistance);
						}
					
						if(count > 1) BLB.Images.slideCarouselWindow(direction, --count);
						else if(BLB.Images.callBackStack.length > 0) BLB.Images.slideCarouselWindowCaller();
						else BLB.Images.updateImgMainBody()
					});

					imgCarouselKeyAnimation.play();

					thisThumb.classList.remove('imgParCenter');
					nextThumb.classList.add('imgParCenter');
					
					BLB.Images.currentImgId = nextThumb.id;
					BLB.Images.currentThumb = BLB.Images.thumbs[BLB.Images.currentImgId];
				},

				slideCarouselWindowCaller: function() {
					var state = BLB.Images.callBackStack.shift();
					var ill = BLB.Images.imgList.length;
					var direction = 'left';
					var count = 0;

					for(var i=0;i<ill;i++) {
						var imgKey = 'img_'+BLB.Images.imgList[i];
						var thumbState = BLB.Images.thumbs[imgKey];
						if(count > 0) {
							if(thumbState == BLB.Images.currentThumb || thumbState == state)
								break;
							count++;
						} else if(thumbState == BLB.Images.currentThumb) {
							direction='left';
							count++;
						} else if (thumbState == state) {
							direction='right';
							count++;
						}
					}
					BLB.Images.slideCarouselWindow(direction, count);
				},

				updateImgMainBody: function() {
					var title = BLB.Images.titles[BLB.Images.currentImgId];
					var cropped = BLB.Images.cropped[BLB.Images.currentImgId];
					var path = BLB.Images.paths[BLB.Images.currentImgId];
					var imgSrc = '/assets-v3/images/bibleMedia/'+path+'/' + cropped;
					var tmpImg = document.createElement('img');
					var imgWidth = 72;
					var imgHeight = 0;
					var metaDescTemplate = "Image from the {galleryName} gallery. Images for {scripture} are provided by the Blue Letter Bible and its partner ministries."

					var imgDataTitle = document.querySelector('#imgDataTitle');
					var imgRespTitle = document.querySelector('#imgTitle_Resp');
					var imgDataCr = document.querySelector('#imgDataCr');
					var imgDataSe = document.querySelector('#imgDataSe');
					var imgDataSrc = document.querySelector('#imgDataSrc');
					var imgDataBtn = document.querySelector('#imgDataBtn');
					var imgDataDesc = document.querySelector('#imgDataDesc');
					var imgDataBtn = document.querySelector('#imgDataBtn');

					var scripturesA = BLB.Images.imgScripture[BLB.Images.currentImgId].replace(/(^\s*|;?\s*$)/g, '').replace(/(\d);([a-zA-Z])/g, '$1; $2');
					var keywordsA = BLB.Images.imgKeywords[BLB.Images.currentImgId].replace(/(^\s*|;?\s*$)/g, '');
					var b = null; pb = null; var c = null; var v = null; var v1 = null; var bid = null;

					keywordsA = (keywordsA==''?[]:keywordsA.split(/;/));
					tmpImg.src = imgSrc;

					imgDataBtn.addEventListener('mouseover', function() {
						var img = this.firstChild;
						img.src = img.src.replace(/_a\.svg/, '_b.svg');
					});
					imgDataBtn.addEventListener('mouseout', function() {
						var img = this.firstChild;
						img.src = img.src.replace(/_b\.svg/, '_a.svg');
					});
					tmpImg.addEventListener('load', function() {
						document.querySelector('#imgTitle').innerHTML = title;
						document.querySelector('#imgTitle_Resp').innerHTML = title;

						// Update title and meta data tags
						var metaDesc = metaDescTemplate;
						metaDesc = metaDesc.replace('{galleryName}', BLB.Images.galleryName).replace('{scripture}', title);
						document.title = title +' - '+ BLB.Images.galleryName;
						document.head.querySelector("meta[name='Description']").content = metaDesc;
                        document.head.querySelector("meta[property='og:title']").content = document.title;
                        document.head.querySelector("meta[property='og:description']").content = metaDesc;
                        document.head.querySelector("meta[property='og:image']").content = 'https://www.blueletterbible.org/assets-v3/images/bibleMedia/' + path + '/' + BLB.Images.thumbs[BLB.Images.currentImgId] + '.jpg';

						document.querySelector('#imgExact').innerHTML = '<img src="'+imgSrc+'" alt="" />';
						document.querySelector('#imgPrint').firstChild.src = imgSrc;
						imgDataDesc.innerHTML = '';
						imgDataCr.innerHTML = '';
						imgDataSe.innerHTML = '';
						imgDataSrc.innerHTML = '';
						imgDataTitle.innerHTML = title;
						imgRespTitle.innerHTML = title;

						var imgLinks = document.querySelector('#imgLinks');

						var imgDesc = BLB.Images.imgDescription[BLB.Images.currentImgId];
						var imgDataDescP = document.querySelector('#imgDataDescP');
						var imgDataDescTop = document.querySelector('#imgDataDescTop');
						var imgDesc = BLB.Images.imgDescription[BLB.Images.currentImgId];
						imgDataDescTop.style.display='none';
						imgDataDescTop.innerHTML='';
						imgDataDescP.style.display='none';
						var showDescOnTop = false;
						if (path == "ESV-Global-Study-Bible") {showDescOnTop = true}
						if (imgDesc.length > 0) {
							if (showDescOnTop == true) {
									imgDataDescTop.style.display="block";
									imgDataDescTop.innerHTML = imgDesc;
							}
							else {
							    imgDataDescP.style.display="block";
							    imgDataDesc.innerHTML = imgDesc;
							}
						}
						var imgDataCrP = document.querySelector('#imgDataCrP');
						if(scripturesA.length == 0) {
						    imgDataCrP.style.display="none";
						} else {
						    imgDataCrP.style.display="block";
						    imgDataCr.innerHTML = scripturesA;
						    BLB.Tagger.walkDomTree(imgDataCr);
						}

					// Resize left/right expand controls to fit image area
						setTimeout(function() {
							let lefty = document.querySelector('#siteExpandLeft');
							let righty = document.querySelector('#siteExpandRight');
							let imgBody = document.querySelector('.bubBody.imgBody');
							if (lefty && righty && imgBody) {
								let height = parseInt(imgBody.getBoundingClientRect().height);
								if (!isNaN(height) && height > 145) {
									lefty.style.maxHeight = height + 37 + 'px';
									righty.style.maxHeight = height + 37 + 'px';
								}
							}
						}, 500)

						var imgDataSeP = document.querySelector('#imgDataSeP');
						if(keywordsA.length == 0) {
						    imgDataSeP.style.display="none";
						} else {
						    imgDataSeP.style.display="block";
						    for(var i=0;i<keywordsA.length;i++) {
                                var keywords = keywordsA[i];
                                var a = document.createElement('a');
                                keywords = keywords.replace(/(^\s*|;?\s*$)/g, '');
                                a.innerHTML = keywords;
                                a.href = '/search/search.cfm?Criteria="'+keywords+'"#s=s_refWorks';
                                imgDataSe.appendChild(a);
                                if(i+1<keywordsA.length)
                                    imgDataSe.appendChild(document.createTextNode('; '));
                            }
                        }

                        // Create Image Download Links
						var fullImg = BLB.Images.imgFull[BLB.Images.currentImgId];
						var fullPDF = BLB.Images.imgPDF[BLB.Images.currentImgId];

						imgDataBtn.href = '/assets-v3/images/bibleMedia/' + path + '/' + fullImg;

                        // Create PDF Download Links
                        document.querySelector('span#imgPDFLabel').innerHTML = '';
                        if(fullPDF != '') document.querySelector('span#imgPDFLabel').innerHTML = '<a href="/assets-v3/images/bibleMedia/' + path + '/' + fullPDF + '" download>Download PDF</a><br />';

					});

					BLB.Images.carouselClick=false;
					if(!BLB.firstLoad) BLB.Menu.evDispatch({event: 'page_view'});	// Tell Google about the page_view change due to AJAX call
					BLB.firstLoad = false;
				},

				windowShift: function(count) {
					var imgCarousel = document.querySelector('#imgCarousel');
					var windowLeft = parseInt(imgCarousel.style.left, 10);
					imgCarousel.style.left = windowLeft + (BLB.Images.thumbWidth*count) + 'px';
				},

				setCarouselWidth: function() {
					var imgCarousel = document.querySelector('#imgCarousel');
					var carouselWidth = BLB.Images.imgList.length*BLB.Images.thumbWidth+15+9+78;
					imgCarousel.style.width = carouselWidth+'px';
				},

				setCarouselWindowWidth: function() {
					var imgCarouselWindow = document.querySelector('#imgCarouselWindow');
					var carouselWindowWidth = BLB.Images.thumbsCount*BLB.Images.thumbWidth+15;
					imgCarouselWindow.style.width = carouselWindowWidth+'px';
				},

				prefetchThumbnail: function(thmbPos) {
					var imgCarousel = document.querySelector('#imgCarousel');
					var thumbDiv = imgCarousel.children[thmbPos];
					if(thumbDiv != undefined) {
						var imgKey = thumbDiv.id;
						var thumber = BLB.Images.thumbs[imgKey];
						var thumbsCount = Math.floor(BLB.Images.vpW/BLB.Images.thumbWidth)-2;
						thumbsCount = (thumbsCount%2?thumbsCount:thumbsCount-1);

						thumber = thumber.replace(/.$/, 'd');
						thumbDiv.firstChild.src = '/assets-v3/images/bibleMedia/' + BLB.Images.paths[imgKey] + '/' + thumber + '.jpg';
					}
				},

				getBookmarkedState: function() {
					var pathname = document.location.pathname.replace(/\/+$/, '');
					var pa = pathname.split(/\//);
					var state = pa[pa.length-1];
					return state;
				},

				getHistoryState: function() {
					var historyState = history.state;
					var state = null;
					if(historyState != undefined)
						state = historyState.state;
					return state;
				},

				historyNavigate: function(state) {
					if(BLB.Images.carouselClick) return false;
					BLB.Images.carouselClick=true;
					var pathname = document.location.pathname.replace(/\/+$/, '');
					var pa = pathname.split(/\//);
					pa.pop(); pa.push(state);
					history.replaceState({state:state}, null, pa.join('/'));
					BLB.Images.sectionStateChangeHandler(state);
				},

				sectionStateChangeHandler: function(state) {
					BLB.Images.callBackStack.push(state);
					BLB.Images.slideCarouselWindowCaller();
				},

				popstateEventHandler: function(ev) {
					var state = ev.state;
					BLB.Images.sectionStateChangeHandler(state.state);
				}
			};

			YEvent.onDOMReady(BLB.Images.init, BLB.Images.init, true);
		})();