PageSourceSearch

https://www.gallerystock.com/js/90900205/v2/lb-core.js

js gallerystock.com collected 2026-09-24 22:14:03 UTC 57,547 bytes, 1,643 lines download raw bytes

1// define core options/setup
2$.extend(mcConf, {
3    emailRegex : /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,
4	lbMobileSite : undefined,						// has mobile site design
5	lbMobile : undefined,							// is mobile
6	lbDevice : undefined,							// device type
7	lbScreenSizeWidth : undefined,					// screen size width
8	lbScreenSizeHeight : undefined,					// screen size height
9	lbOrientationChange : undefined,				// check for orientation change
10	lbOrientation : undefined,						// mobile orientation
11	lbAssetSize : undefined,						// image asset size
12	lbVideoSize : undefined,						// video asset size
13	lbClipSize : undefined,							// video clip size
14	assetStorageURL : undefined,					// asset storage URL
15	menu : undefined, 								// menu
16	capi : '', 										// main content scrollbar
17	mapi : '', 										// menu scrollbar
18	emapi : '',										// extended menu scrollbar
19	scrollbar : undefined,							// has scrollbar true or false, true by default
20	throttleTimeout : '', 							// timeout var for scrollbars
21	screenSizeWidth : screen.width, 				// screen width (used for mobile)
22	screenSizeHeight : screen.height, 				// screen height (used for mobile)
23	retina : undefined,
24	_h : undefined, 								// height of the browser
25	_w : undefined, 								// width of the browser
26	_imgH : undefined, 								// image height (resize on slideshows and the blog)
27	_imgW : undefined, 								// image width (resize on slideshows and the blog)
28	imagePrefixSizes : undefined,					// will be used to store the maximum height and width for each image prefix
29	alternateSpreadColor : undefined					// setting for alternate spread colour
30});
31
32// check if mobile
33mcConf.mobile = false;
34if ((navigator.userAgent.indexOf("iPhone") != -1)
35    || (navigator.userAgent.indexOf("iPod") != -1)
36    || (navigator.userAgent.indexOf("iPad") != -1)
37    || (navigator.userAgent.indexOf("Android") != -1)
38    || (navigator.userAgent.indexOf("BlackBerry") != -1)){
39	mcConf.mobile = true;
40	document.getElementsByTagName('html')[0].classList.add('device-mobile');
41}
42mcConf.deviceRatio = '(-webkit-min-device-pixel-ratio: 1.5),(min--moz-device-pixel-ratio: 1.5),(-o-min-device-pixel-ratio: 3/2),(min-device-pixel-ratio: 1.5),(min-resolution: 144dpi),(min-resolution: 1.5dppx)';
43if (window.devicePixelRatio > 1 || (window.matchMedia && window.matchMedia(mcConf.deviceRatio).matches)) {
44	mcConf.retina = true;
45	document.getElementsByTagName('html')[0].classList.add('screen-retina');
46}
47
48function setAssetSize() {
49	// set the device and image sizes for mobile if there is a mobile optimized site
50	if (mcConf.lbMobileSite == true) {
51		if ((navigator.userAgent.indexOf("iPhone") != -1) || (navigator.userAgent.indexOf("iPod") != -1)) {
52			mcConf.lbDevice = 'iPhone';
53			mcConf.lbAssetSize = mcConf.lbAssetSize_iphone;  // default ml
54			mcConf.lbVideoSize = 'ios';
55		} else if (navigator.userAgent.indexOf("Android") != -1) {
56			mcConf.lbDevice = 'Android';
57			mcConf.lbAssetSize = mcConf.lbAssetSize_droid;  // default ml
58			mcConf.lbVideoSize = 'ios';
59		} else if (navigator.userAgent.indexOf("BlackBerry") != -1) {
60			mcConf.lbDevice = 'Blackberry';
61			mcConf.lbAssetSize = mcConf.lbAssetSize_blackberry;  // default ms
62			mcConf.lbVideoSize = 'ios';
63		} else if (navigator.userAgent.indexOf("PlayBook") != -1) {
64			mcConf.lbDevice = 'Playbook';
65			mcConf.lbAssetSize = mcConf.lbAssetSize_playbook;  // default ml
66			mcConf.lbVideoSize = 'ios';
67		} else {
68			mcConf.lbDevice = 'desktop';
69		}
70	} else {
71		mcConf.lbDevice = 'desktop';
72	}
73
74	// if desktop check for screen width/height to optimize the experience for the user
75	if (mcConf.lbDevice == 'desktop') {
76		if (screen.width <= 800) { // even smaller screens
77			mcConf.lbAssetSize = mcConf.lbAssetSize_800;  // default ml
78			mcConf.lbClipSize = 'lgclip';
79		} else if (screen.width <= 1024) { // smaller screens
80			mcConf.lbAssetSize = mcConf.lbAssetSize_1024; // default gs
81			mcConf.lbClipSize = 'lgclip';
82		} else if (screen.width <= 1366) { // 11" macbook air
83			mcConf.lbAssetSize = mcConf.lbAssetSize_1366; // default gm
84			mcConf.lbClipSize = 'hdclip';
85		} else if (screen.width <= 1440) { // 15" macbook pro and 13" macbook air
86			mcConf.lbAssetSize = mcConf.lbAssetSize_1440; // default gm
87			mcConf.lbClipSize = 'hdclip';
88		} else if (screen.width <= 1680) { // 17" displays
89			mcConf.lbAssetSize = mcConf.lbAssetSize_1680; // default gl
90			mcConf.lbClipSize = 'fullhdclip';
91		} else if (screen.width <= 1920) { // 19-20" displays
92			mcConf.lbAssetSize = mcConf.lbAssetSize_1920; // default gxl
93			mcConf.lbClipSize = 'fullhdclip';
94		} else if (screen.width <= 2560) { // 27" displays
95			mcConf.lbAssetSize = mcConf.lbAssetSize_2560; // default gxxl
96			mcConf.lbClipSize = '2kclip';
97		} else if (screen.width <= 3840) {
98			mcConf.lbAssetSize = mcConf.lbAssetSize_2560; // default gxxl
99			mcConf.lbClipSize = '4kclip';
100		} else {
101			mcConf.lbAssetSize = mcConf.lbAssetSize_2560; // default gxxl
102			mcConf.lbClipSize = '8kclip';
103		}
104		mcConf.lbVideoSize = 'video_';
105	}
106}
107setAssetSize();
108
109// if mobile detect whether device supports orientationchange event, otherwise fall back to the resize event.
110// check for current orientation
111if (mcConf.lbOrientationChange) {
112	var supportsOrientationChange = "onorientationchange" in window,
113	    orientationEvent = supportsOrientationChange ? "orientationchange" : "resize";
114	// on load
115	$(window).load(orientationEvent, function() {
116		mcConf.lbOrientation = window.orientation;
117		mcConf.lbScreenSizeWidth = screen.width;
118		mcConf.lbScreenSizeHeight = screen.height;
119	}, false);
120	// on change
121	window.addEventListener(orientationEvent, function() {
122		mcConf.lbOrientation = window.orientation;
123		mcConf.lbScreenSizeWidth = screen.width;
124		mcConf.lbScreenSizeHeight = screen.height;
125//		resizeSlideshow();
126	}, false);
127}
128
129
130// setup scrollbar for menu
131$(function() {
132
133	// disable contextual menu (right click)
134	if (mcConf.drag_desktop == false) {
135		$('img').on('contextmenu', function(e){
136			e.preventDefault();
137			return false;
138		});
139		$('img').on('mousedown', function(e){
140			e.preventDefault();
141			return false;
142		});
143	}
144
145	// if mobile, hide address bar on IOS and Android
146	if (mcConf.mobile == true) {
147		window.addEventListener("load",function() {
148		    setTimeout(function() {
149		        document.body.scrollTop || window.scrollTo(0, 1);
150		    }, 0);
151		});
152	}
153
154	// detecting iOS 5 to work around a masonry bug
155	if(navigator.userAgent.match(/OS 5_[0-9_]+ like Mac OS X/i) != null) {
156		$('body').addClass('ios5');
157	}
158
159	// setup menu scrollbar
160	if (mcConf.mobile == false) {
161		if(mcConf.useWebkitScrollbars == false || (mcConf.useWebkitScrollbars == true && !$.browser.webkit)){
162			if (mcConf.scrollbar == undefined || mcConf.scrollbar) {
163				if (mcConf.customMenuScrollbar == true) {
164					$(mcConf.menuContainer).jScrollPane({
165						autoReinitialise: mcConf.autoreinitialiseJscrollPane,
166						showArrows: false,
167						autoReinitialiseDelay: mcConf.jspAutoReinitialiseDelay,
168						verticalDragMinHeight: mcConf.menuVerticalDragMinHeight,
169						verticalDragMaxHeight: mcConf.menuVerticalDragMaxHeight,
170						verticalDragMinWidth: mcConf.menuVerticalDragMinWidth,
171						verticalDragMaxWidth: mcConf.menuVerticalDragMaxWidth,
172						horizontalDragMinHeight: mcConf.menuHorizontalDragMinHeight,
173						horizontalDragMaxHeight: mcConf.menuHorizontalDragMaxHeight,
174						horizontalDragMinWidth: mcConf.menuHorizontalDragMinWidth,
175						horizontalDragMaxWidth: mcConf.menuHorizontalDragMaxWidth,
176						verticalGutter: 0,
177						horizontalGutter: 0
178					});
179				} else {
180					$(mcConf.menuContainer).jScrollPane({
181						autoReinitialise: mcConf.autoreinitialiseJscrollPane,
182						showArrows: false,
183						autoReinitialiseDelay: mcConf.jspAutoReinitialiseDelay,
184						verticalGutter: 0,
185						horizontalGutter: 0
186					});
187				}
188				mcConf.mapi = $(mcConf.menuContainer).data('jsp');
189			}
190
191			$(mcConf.menuContainer + ' .container, #n_backtomenu a').bind('mousedown',function() {
192				// reinitialise jScrollpane when the menu toggles
193				if (!mcConf.throttleTimeoutMenu) {
194					mcConf.throttleTimeoutMenu = setTimeout(function(){
195						// menu scrollbars
196						if (!!mcConf.mapi) {
197							mcConf.mapi.reinitialise();
198						}
199						mcConf.throttleTimeoutMenu = null;
200					}, mcConf.navSlideSpeed + 100);
201				}
202			});
203		}
204	}
205
206	// setup content scrollbar
207	if (mcConf.mobile == false) {
208		if(mcConf.useWebkitScrollbars == false || (mcConf.useWebkitScrollbars == true && !$.browser.webkit)){
209			if (mcConf.scrollbar == undefined || mcConf.scrollbar) {
210				if (mcConf.customContentScrollbar == true) {
211					$(mcConf.contentContainer).jScrollPane({
212						autoReinitialise: mcConf.autoreinitialiseJscrollPane,
213						showArrows: false,
214						animateScroll: true,
215						autoReinitialiseDelay: mcConf.jspAutoReinitialiseDelay,
216						verticalDragMinHeight: mcConf.contentVerticalDragMinHeight,
217						verticalDragMaxHeight: mcConf.contentVerticalDragMaxHeight,
218						verticalDragMinWidth: mcConf.contentVerticalDragMinWidth,
219						verticalDragMaxWidth: mcConf.contentVerticalDragMaxWidth,
220						horizontalDragMinHeight: mcConf.contentHorizontalDragMinHeight,
221						horizontalDragMaxHeight: mcConf.contentHorizontalDragMaxHeight,
222						horizontalDragMinWidth: mcConf.contentHorizontalDragMinWidth,
223						horizontalDragMaxWidth: mcConf.contentHorizontalDragMaxWidth,
224						verticalGutter: 0,
225						horizontalGutter: 0
226					});
227				} else {
228					$(mcConf.contentContainer).jScrollPane({
229						autoReinitialise: mcConf.autoreinitialiseJscrollPane,
230						autoReinitialiseDelay: mcConf.jspAutoReinitialiseDelay,
231						showArrows: false,
232						animateScroll: true,
233						verticalGutter: 0,
234						horizontalGutter: 0
235					});
236				}
237				mcConf.capi = $(mcConf.contentContainer).data('jsp');
238				mcConf.scrollbar = true;
239			}
240		}
241	}
242	$(window).bind('resize load',function() {
243		// reinitialise jScrollpane
244		if (!mcConf.throttleTimeout) {
245			mcConf.throttleTimeout = setTimeout(function(){
246				// menu scrollbars
247				if (!!mcConf.mapi) {
248					mcConf.mapi.reinitialise();
249				}
250				// content scrollbars
251				if (!!mcConf.capi) {
252					mcConf.capi.reinitialise();
253				}
254				// thumbnail scrollbars
255				if (!!mcConf.tapi) {
256					mcConf.tapi.reinitialise();
257				}
258				// gallery scrollbars
259				if (!! mcConf.gapi) {
260					mcConf.gapi.reinitialise();
261				}
262				mcConf.throttleTimeout = null;
263			},50);
264		}
265	});
266
267	// generic close all overlays
268	$('.o_close').bind('click', function(evt) {
269		evt.preventDefault();
270		$('.overlay').hide();
271		$('.overlay').removeClass('show');
272		$('.'+$(this).attr('data-target')).removeClass('sel');
273		resumeAllVideoClips();
274		return false;
275	});
276	// focus effect on the field labels for the overlay forms
277	$('.overlay .contact_form input, .overlay .contact_form textarea').bind('focus', function(evt) {
278		$(this).parent().addClass('sel');
279	});
280	$('.overlay .contact_form input, .overlay .contact_form textarea').bind('blur', function(evt) {
281		$(this).parent().removeClass('sel');
282	});
283	// show cover images for artists
284	$('li[cover_image]').hover(
285		function () {
286			if (!$('body').hasClass('no_cover')) {
287				$('#cover').addClass('visible').html('<img src="'+$(this).attr('cover_image')+'" />');
288			}
289		},
290		function () {
291			if (!$('body').hasClass('no_cover')) {
292				if(typeof mcMenu.updateCoverHoverOut == 'function') {
293					return mcMenu.updateCoverHoverOut();
294				}
295				$('#cover').removeClass('visible').html('');
296			}
297		}
298	);
299	//_setupNavMenu();
300	mcMenu.init();
301
302	// mobile optimized site menu binding
303	if (mcConf.mobile_optimized == true){
304		$('.mobile_menu_icon').bind('click',function(){
305			if ($(this).hasClass('sel')){
306				$(this).removeClass('sel');
307				$('nav').removeClass('visible');
308			} else {
309				$(this).addClass('sel');
310				$('nav').addClass('visible');
311			}
312		});
313	}
314
315	// custom share if enabled
316	if (mcConf.customShare == true){
317		// facebook
318		$('body').on('click touchstart', '.st_facebook_custom', function(){
319			var _href = $(this).attr('st_url');
320			window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(_href), "fbshare", "height=400,width=550,resizable=1,toolbar=0.menubar=0,status=0,location=0");
321			if (typeof gtag === 'function') {
322				gtag('event', 'facebook', {
323					'event_category': 'Share'
324				});
325			}
326		});
327		// twitter
328		$('body').on('click touchstart', '.st_twitter_custom', function(){
329			var _href = $(this).attr('st_url');
330			var _txt = $(this).attr('st_title');
331			if(typeof _txt == 'undefined' || _txt.length < 1) { _txt = window.document.title; }
332			window.open('http://twitter.com/intent/tweet?text='+encodeURIComponent(_txt)+' '+encodeURIComponent(_href), "twshare", "height=380,width=660,resizable=1,toolbar=0.menubar=0,status=0,location=0");
333			if (typeof gtag === 'function') {
334				gtag('event', 'twitter', {
335					'event_category': 'Share'
336				});
337			}
338		});
339		// pinterest
340		$('body').on('click touchstart', '.st_pinterest_custom', function(){
341			var _img = $(this).attr('st_image');
342			var _href = $(this).attr('st_url');
343			var _txt = $(this).attr('st_title');
344			if(typeof _txt == 'undefined' || _txt.length < 1) { _txt = window.document.title; }
345			window.open('http://pinterest.com/pin/create/button/?url='+encodeURIComponent(_href)+'&media='+_img+'&description='+encodeURIComponent(_txt), "pinshare", "height=270,width=630,resizable=1,toolbar=0.menubar=0,status=0,location=0");
346			if (typeof gtag === 'function') {
347				gtag('event', 'pinterest', {
348					'event_category': 'Share'
349				});
350			}
351		});
352		// tumblr
353		$('body').on('click touchstart', '.st_tumblr_custom', function(){
354			var _href = $(this).attr('st_url');
355			var _txt = $(this).attr('st_title');
356			if(typeof _txt == 'undefined' || _txt.length < 1) { _txt = window.document.title; }
357			window.open('http://www.tumblr.com/share?v=3&s=&t='+encodeURIComponent(_txt)+'&u='+encodeURIComponent(_href), "tbshare", "height=270,width=630,resizable=1,toolbar=0.menubar=0,status=0,location=0");
358			if (typeof gtag === 'function') {
359				gtag('event', 'tumblr', {
360					'event_category': 'Share'
361				});
362			}
363		});
364		// google+
365		$('body').on('click touchstart', '.st_googleplus_custom', function(){
366			var _href = $(this).attr('st_url');
367			window.open('https://plus.google.com/share?url='+encodeURIComponent(_href), "he
367ight=600,width=600,resizable=1,toolbar=0.menubar=0,status=0,location=0");
368			if (typeof gtag === 'function') {
369				gtag('event', 'google+', {
370					'event_category': 'Share'
371				});
372			}
373		});
374		// weibo
375		$('body').on('click touchstart', '.st_weibo_custom', function(){
376			var _href = $(this).attr('st_url');
377			window.open('http://service.weibo.com/share/share.php?url='+encodeURIComponent(_href)+'&type=button&language=zh_cn&searchPic=true&style=number');
378			if (typeof gtag === 'function') {
379				gtag('event', 'weibo', {
380					'event_category': 'Share'
381				});
382			}
383		});
384		// linkedin
385		$('body').on('click touchstart', '.st_linkedin_custom', function(){
386			var _href = $(this).attr('st_url');
387			var _txt = $(this).attr('st_title');
388			window.open('https://www.linkedin.com/shareArticle?mini=true&url='+encodeURIComponent(_href)+'&summary='+_txt);
389			if (typeof gtag === 'function') {
390				gtag('event', 'linkedin', {
391					'event_category': 'Share'
392				});
393			}
394		});
395		// email
396		$('body').on('click touchstart', '.st_email_custom', function(){
397			var _href = $(this).attr('st_url');
398			var _txt = $(this).attr('st_title');
399			if(typeof _txt == 'undefined' || _txt.length < 1) { _txt = window.document.title; }
400			// set hidden fields
401			$('#o_share_link_url').val($(this).attr('st_url'));
402			$('#o_share_asset_id').val($(this).parents('li').attr('asset'));
403			$('#o_share_portfolio_id').val($(this).parents('li').attr('content'));
404			$('#o_share_email_subject').val(_txt);
405			$('#o_share .top_label').html('share: '+_txt);
406			// share:
407			// show overlay form
408			$('#share_overlay').show();
409			$('#share_overlay').find('[tabindex="1"]').focus();
410			$(this).trigger('share_via_email_opened');
411			if (typeof gtag === 'function') {
412				gtag('event', 'open email form', {
413					'event_category': 'Share'
414				});
415			}
416		});
417		$('#share_overlay .cancel').bind('click', function(e){
418			e.preventDefault();
419			$('#share_overlay').hide();
420		});
421	}
422});
423
424/**
425 * setup main navigation
426 */
427function _setupNavMenu() {
428	// menu type
429	$('#n_top_list li.n_main').addClass('open').removeClass('closed'); // having them hidden by default helps avoid a flash between render and this code running
430	if(mcConf.is_content && mcConf.menu_show_artist_only){$('.level_1>a.sel').addClass('closed').removeClass('open');}
431	if(mcConf.is_news) {$("li.level_1:not(.n_blog)").addClass('closed').removeClass('open');}
432	if($('#n_top_list a.sel').length > 1 && mcConf.menu_show_artist_only){$('.level_1:not(.n_blog)>a.sel').addClass('closed').removeClass('open');}
433
434	if (mcConf.menuType == 'dropdown') {
435		// close the back to menu link
436		$('#n_backtomenu').addClass('closed');
437
438		// toggle the parent elements
439		$('#n_top_list li.n_main.container > a').click(function (e){
440			e.preventDefault();
441			var sublist = $(this).parent().find(' > ul.contents_list');
442			sublist.toggleClass('open').removeClass('closed');
443			if(sublist.hasClass('open')){
444				sublist.addClass('open').removeClass('closed');
445			} else {
446				sublist.addClass('closed').removeClass('open');
447			}
448		});
449		$(body).bind('click', function(){
450			if (mcConf.menuOpen == true){
451				$('#n_top_list li.n_main').removeClass('open').addClass('closed');
452			}
453		});
454	}
455
456
457	if(mcConf.menuType == 'toggle') { // make the default menu work at all...
458
459		$('#n_backtomenu').addClass('closed'); // hide the back to menu link
460		                       			       // TODO: only output the backtomenu if menuType=collapse
461
462		// on the main studio container links, capture click and toggle submenu
463		$('#n_top_list li.n_main.container > a').click(function (e){
464			var sublist = $(this).parent().find(' > ul.contents_list');
465			if (sublist && $(sublist).find('li').length) {
466				e.preventDefault();
467				sublist.toggleClass('open').removeClass('closed');
468				if(sublist.hasClass('open')){ sublist.addClass('open').removeClass('closed'); } else { sublist.addClass('closed').removeClass('open'); }
469				return false;
470			}
471
472		});
473
474	} else if (mcConf.menuType == 'collapse') {
475
476		mcConf.navSlideSpeed = 200;
477		//mcConf.menu_show_artist_only = true;
478		if($('#n_top_list > li.n_main a.sel').length > 0) { // if we have open entries
479			// then show proper stuff
480			$('#n_top_list li.n_sub').removeClass('open').addClass('closed'); // initially hide all portfolios li's
481			$('#n_top_list li.n_main ul.contents_list.open').removeClass('closed').addClass('open'); // open the ul's that should be open
482
483			$('#n_top_list li.n_main').removeClass('open').addClass('closed').each(function (){ // hide all n_main's too
484				if($('a', this).hasClass('sel')){ $(this).addClass('open').removeClass('closed'); } // but open the selected ones
485			});
486
487			$('#n_top_list ul.contents_list.open').last().find('li').addClass('open').removeClass('closed'); // and show the last open header & list
488
489			$('#n_backtomenu a').html(mcConf.menuBackToMenuText); // also, ensure the back to menu is displayed
490			$('#n_backtomenu').addClass('open').removeClass('closed');
491		} else {
492			// set the back to menu label text and hide by default
493			$('#n_backtomenu a').html(mcConf.menuBackToMenuText);
494			$('#n_backtomenu').addClass('closed').removeClass('open');
495		}
496
497		$('#n_top_list li.n_main.container > a').click(function (e){
498			e.preventDefault();
499			if($(this).attr('data-link')){location.href = $(this).attr('href')+$(this).attr('data-link');return;}
500			if ($(this).hasClass('sel')) {
501				// clicked an open container - is the the last open one? if so leave it because it should already be showing it's stuff
502				if($(this).parent().find('li.n_main > a.sel').length > 0) {
503					// not the last open container - close their children
504					$(this).parent().find('li > a').removeClass('sel'); // clear sub sel classes
505					$(this).parent().find('li.n_main > ul.contents_list').removeClass('open').addClass('closed'); // close open subcontainers
506					$(this).parent().find('li').addClass('open').removeClass('closed'); // show all the list items for this container
507					$(this).parent().addClass('closed').removeClass('open'); // hide then slide the current list
508//					$(this).parent().slideDown(mcConf.navSlideSpeed);
509				}
510			} else {
511				$(this).addClass('sel');
512				if($('#n_top_list a.sel').length > 1 && mcConf.menu_show_artist_only){$('.level_1>a.sel').addClass('closed').removeClass('open');}
513				$(this).parent().parent().find('> li').addClass('closed').removeClass('open');
514				$(this).parent().addClass('open').removeClass('closed').find('> ul').addClass('open').removeClass('closed').find('li').addClass('open').removeClass('closed');
515				$('#n_backtomenu').addClass('open').removeClass('closed');
516
517			}
518		});
519
520		// back to menu click
521		$('#n_backtomenu').bind('click', function() {
522			$('#n_top_list a').removeClass('sel').addClass('open').removeClass('closed');
523			$('#n_top_list .n_main').addClass('closed').removeClass('open');
524			$('#n_top_list > .n_main').addClass('open').removeClass('closed');
525			$('#n_top_list ul.contents_list').addClass('closed').removeClass('open');
526			$('#n_top_list .n_sub').addClass('closed').removeClass('open');
527			$('#nav .menu_hide').addClass('closed');
528			$(this).addClass('closed').removeClass('open');
529			$('body').removeClass('no_cover');
530		});
531	} else if (mcConf.menuType == 'default') {
532		// default will do nothing. Can use this for custom behaviours if needed.
533		$('#n_backtomenu').hide(); // hide the back to menu link
534		// TODO: only output the backtomenu if menuType=collapse
535		// NOTE: the navigation, if built properly, should work like this
536	}
537
538	// TODO: implement dropdown nav option
539	// } else if (mcConf.menuType == 'dropdown') {
540	//	// will need to implement the dropdown logic
541}
542
543// signup submit
544function signupSubmit(resp) {
545	var frm = $('.lb_signup_form');
546	var validated = true;
547	var email = $('input[name="data[Contact][email]"]', frm).val();
548	var emailReg = mcConf.emailRegex;
549	$('input.required', frm).each(function(){
550		if ($(this).val() == ''){validated = false;}
551	});
552	if (!emailReg.test(email) ) {validated = false;}
553	if ( !validated ) {
554		frm.trigger('resetCaptcha');
555		alert('Please complete the form and enter all *required information. Thank you.'); return false;
556	}
557	$("input[name=submit]", frm).val("sending...").attr('disabled', 'disabled');
558	if (typeof gtag === 'function') {
559		gtag('event', 'submit', {
560			'event_category': 'Subscribe'
561		});
562	}
563	$.ajax({
564		url: '/contacts/subscribe',
565		data: frm.serialize(),
566		type: 'POST',
567		dataType: 'json',
568		success: function(json) {
569			alert(json.raw);
570			$('input', frm).val('');
571			$("input[name=submit]", frm).val("Submit").attr('disabled', false);
572			$('.o_close').click();
573			$(document).trigger('subscribe_submitted');
574			frm.trigger('resetCaptcha');
575		}
576	});
577	return false;
578}
579
580// login submit
581function loginSubmit(resp) {
582	var frm = $('#login_form');
583	var msg = '';
584	var validated = true;
585	$('input.required', frm).each(function(){
586		if ($(this).val() == ''){validated = false;}
587	});
588	if(!validated){msg += 'Please enter all *required information\n';}
589	var email = $('input[name="data[Contact][email]"]', frm).val();
590	var emailReg = mcConf.emailRegex;
591	if (!emailReg.test(email) ) {msg = 'Please supply a valid email\n';validated = false;}
592
593	if(frm.attr('action') == '/contacts/register') {
594		if($('input[name="data[Contact][password]"]', frm).val() != $('input[name="data[Contact][confirm]"]', frm).val()) {
595			msg += 'Passwords do not match. Please verify and continue.\n';validated = false;
596		}
597	}
598	if ( !validated ) {
599		frm.trigger('resetCaptcha');
600		alert(msg); return false;
601	}
602
603	var submit_pretxt = $("input[name=submit]", frm).val();
604	$("input[name=submit]", frm).val("sending...").attr('disabled', 'disabled');
605
606	$.ajax({
607		url: frm.attr('action'),
608		data: frm.serialize(),
609		type: 'POST',
610		dataType: 'json',
611		success: function(json) {
612			if(json.redirect){
613				document.location = json.redirect;
614			}
615			$("input[name=submit]", frm).val(submit_pretxt).attr('disabled', false);
616			alert(json.raw);
617			if(json.success && $('#login_form').attr('action') == '/contacts/login' && !json.redirect){
618				$('.o_close').click();
619				$('input[type="text"],input[type="password"]', frm).val('');
620			}
621			frm.trigger('resetCaptcha');
622		}
623	});
624	return false;
625
626}
627
628// contact form submission
629var contact_submitting = false;
630function contactSubmit(resp) {
631	if(contact_submitting === true){ return; }
632
633	var emailReg = mcConf.emailRegex;
634	var validated = true;
635
636	var frm = $('.lb_contact_form');
637	if(!frm){ frm = $('#contact_form'); }
638
639	var dynamic_requires = $('input.required', frm);
640	if(dynamic_requires.length > 0) {
641		// if inputs have require classes - require those ones
642		for(var i = 0; i < dynamic_requires.length; i++) {
643			var input = dynamic_requires[i];
644			if ($(input).val() == ''){validated = false;}
645			if($(input).attr('name') == 'email') { // special case for "email"
646				if (!emailReg.test($(input).val())) {validated = false;}
647			}
648		}
649	} else {
650		// otherwise, fallback to default requirements
651		if($("input[name=name]", frm).val() == ''){validated = false;}
652		if($("input[name=email]", frm).val() == ''){validated = false;}
653		if($("textarea[name=comment]", frm).val() == ''){validated = false;}
654
655		var email = $("input[name=email]", frm).val();
656		if (!emailReg.test(email) ) {validated = false;}
657	}
658
659	if (!validated) {
660		alert('Please complete the form and enter all *required information. Thank you.');
661		frm.trigger('resetCaptcha');
662		return false;
663	}
664
665	var preval = $("input[name=submit]", frm).val();
666	$("input[name=submit]", frm).val("sending...");
667	contact_submitting = true;
668	if (typeof gtag === 'function') {
669		gtag('event', 'submit', {
670			'event_category': 'Contact'
671		});
672	}
673	$.ajax({
674		url: '/syndication/request_contact',
675		data: frm.serialize(),
676		type: 'POST',
677		dataType: 'json',
678		success: function(json) {
679			$("input[name=submit]", frm).val("sent");
680			alert(json.raw);
681			setTimeout(function(){ $("input[name=submit]", frm).removeAttr('disabled').val("submit"); }, 1000);
682			$('html').removeClass('noscroll');
683			if($('#contact_overlay').hasClass('show')) {
684				$('#contact_overlay').removeClass('show');
685			} else {
686				$('#contact_overlay').hide(1000);
687			}
688			contact_submitting = false;
689			$('input[type=text], input[type=email]', frm).val("");
690			$('textarea', frm).val("");
691			$("input[name=submit]", frm).val(preval);
692			frm.trigger('resetCaptcha');
693		},
694		error: function (jqXHR, textStatus, errorThrown) {
695			$("input[name=submit]", frm).val("error");
696			setTimeout(function(){ $("input[name=submit]", frm).removeAttr('disabled').val("submit"); }, 3000);
697			contact_submitting = false;
698			frm.trigger('resetCaptcha');
699		}
700	});
701	return false;
702}
703
704function synRequest(resp) {
705	var emailReg = mcConf.emailRegex;
706	var validated = true;
707	var frm = $('#syn_form');
708
709	var dynamic_requires = $('input.required, select.required, textarea.required', frm);
710	if(dynamic_requires.length > 0) {
711		// if inputs have require classes - require those ones
712		for(var i = 0; i < dynamic_requires.length; i++) {
713			var input = dynamic_requires[i];
714			if ($(input).val() == ''){validated = false; }
715			if($(input).attr('name') == 'email') { // special case for "email"
716				if (!emailReg.test($(input).val())) {validated = false; }
717			}
718		}
719	} else {
720		// otherwise, fallback to default requirements
721		if($("input[name=name]", frm).val() == ''){validated = false;}
722		if($("input[name=email]", frm).val() == ''){validated = false;}
723		if($("input[name=company]", frm).val() == ''){validated = false;}
724		if($("input[name=use]", frm).val() == ''){validated = false;}
725		if($("textarea[name=comment]", frm).val() == ''){validated = false;}
726
727		var email = $("input[name=email]", frm).val();
728		if (!emailReg.test(email) ) {validated = false;}
729	}
730
731	if (!validated) {
732		alert('Please complete the form and enter all *required information. Thank you.');
733		frm.trigger('resetCaptcha');
734		return false;
735	}
736
737	$("input[name=submit]", frm).val("sending...").attr('disabled', 'disabled');
738	if (typeof gtag === 'function') {
739		gtag('event', 'request portfolio', {
740			'event_category': 'Contact'
741		});
742	}
743	$.ajax({
744		url: '/syndication/request_portfolio',
745		data: frm.serialize(),
746		type: 'POST',
747		dataType: 'json',
748		success: function(json) {
749			$("input[name=submit]", frm).val("sent");
750			alert(json.raw);
751			setTimeout(function(){ $("input[name=submit]", frm).val("submit"); }, 1000);
752			$('#syndication_overlay').hide(1000);
753			$('input', frm).val("");
754			$('textarea', frm).val("");
755			$(document).trigger('sent.syn_request');
756			frm.trigger('resetCaptcha');
757		},
758		error: function (jqXHR, textStatus, errorThrown) {
759			$("input[name=submit]", frm).val("error");
760			setTimeout(function(){ $("input[name=submit]", frm).val("submit"); }, 3000);
761			frm.trigger('resetCaptcha');
762		}
763	});
764	return false;
765}
766
767function shareSubmit(resp) {
768	var validated = true;
769	var frm = $('.lb_share_form');
770
771	if($("input[name=name]", frm).val() == ''){validated = false;}
772	if($("input[name=email]", frm).val() == ''){validated = false;}
773	if($("input[name=recipients]", frm).val() == ''){validated = false;}
774
775	var email = $("input[name=email]", frm).val();
776	var emailReg = mcConf.emailRegex;
777	if (!emailReg.test(email) ) {validated = false;}
778
779	if (!validated) {
780		alert('Please complete the form and enter all *required information. Thank you.');
781		frm.trigger('resetCaptcha');
782		return false;
783	}
784	$("input[name=submit]", frm).val("sending...").attr('disabled', 'disabled');
785	$.ajax({
786		type:'POST',
787		url:'/syndication/email_lightbox',
788		data:frm.serialize(),
789		dataType:'json',
790		success:function (json) {
791			$("input[name=submit]", frm).val("sent");
792			if (mcConf.lightboxSuccessAlerts) {
793            	alert(json.raw);
794			}
795			$(document).trigger('lightbox_sent');
796			setTimeout(function(){ $("input[name=submit]", frm).removeAttr('disabled').val("submit"); }, 1000);
797			if($('#share_overlay').hasClass('show')) {
798				$('#share_overlay').removeClass('show');
799			} else {
800				$('#share_overlay').hide(1000);
801			}
802			frm.trigger('resetCaptcha');
803			if (typeof gtag === 'function') {
804				gtag('event', 'send email', {
805					'event_category': 'Share'
806				});
807			}
808		},
809		error: function (jqXHR, textStatus, errorThrown) {
810			$("input[name=submit]", frm).val("error");
811			alert('An unknown network error has occurred. Please try your request later.');
812			setTimeout(function(){ $("input[name=submit]", frm).removeAttr('disabled').val("submit"); }, 3000);
813			frm.trigger('resetCaptcha');
814		}
815	});
816	return false;
817}
818
819function setupSearchForm(search_prefix) {
820	$('#open_search_form').bind('click touchstart', function(e){
821		e.preventDefault();
822		$('#search_overlay').addClass('show');
823		$('#search_form input').first().focus();
824		$('html').addClass('noscroll');
825	});
826
827	// submit a search
828	$('#search_form').submit(function(e){
829		e.preventDefault();
830		var q = $('#search_form input[name="q"]').val();
831		if(q.length < 1) {
832			alert('please enter a query');
833		} else {
834			document.location = search_prefix + q;
835		}
836		return false;
837	});
838}
839
840var preloadImageQueue = new Array();
841function preloadAllElementImages(container, size_override){
842	if(typeof size_override == 'undefined'){ size_override = mcConf.lbAssetSize; }
843	$(container).find('img[filename]').each(function(i) {
844		if ($(this).attr('data-original') == true) {
845			$(this).attr('size_override', 'origgif');
846		} else {
847			$(this).attr('size_override', size_override);
848		}
849		preloadImageQueue.push($(this));
850	});
851	processPreloadImageQueue();
852}
853function processPreloadImageQueue(){
854	var count = 0;
855	while(preloadImageQueue.length > 0) {
856		if(++count > mcConf.preloadImageLimit){ break; }
857		preloadTheImage(preloadImageQueue.shift());
858	}
859}
860function preloadTheImage(image_selector) {
861	var offscreen = new Image();
862	var image_source = image_selector.attr('filename');
863	if(image_source) {
864		var size_override = image_selector.attr('size_override');
865		if(image_selector.hasClass('video') || image_selector.attr('type') == 'video'){ size_override = 'lg'; }
866		if(typeof size_override == 'undefined'){ size_override = mcConf.lbAssetSize; }
867		var fileName = /[^_]+$/.exec(image_source);
868		var storage_url = (image_selector.attr('data-baseurl') ? image_selector.attr('data-baseurl') : mcConf.assetStorageURL);
869		var $imageURL =  storage_url+size_override+'_'+fileName;
870	  	offscreen.onload = function(){
871				image_selector.attr('src',$imageURL).removeAttr('filename').removeAttr('size_override').removeClass("loader");
872				if(preloadImageQueue.length > 0) { preloadTheImage(preloadImageQueue.shift(), size_override); }
873				$(document).trigger('core.imagePreloaded', image_selector);
874				delete offscreen;
875	  	}
876	  	offscreen.onerror = function() {
877				image_selector.attr('data-status', 'failed');
878				if(preloadImageQueue.length > 0) { preloadTheImage(preloadImageQueue.shift(), size_override); }
879				$(document).trigger('core.imagePreloaded', image_selector);
880				delete offscreen;
881	  	}
882	  	offscreen.src = $imageURL;
883	}
884}
885
886// setup video clip with a size
887
888function loadVideoClipPrefix (container, size_override){
889	if(typeof size_override == 'undefined'){ size_override = mcConf.lbClipSize; }
890	$(container).find('.video_clip[data-filename]').each(function(i) {
891		var t = $(this),
892			video_source = t.data('filename'),
893			prefix = size_override,
894			fileName = /[^_]+$/.exec(video_source)[0],
895			storage_url = t.data('baseurl') ? t.data('baseurl') : mcConf.assetStorageURL;
896		// each prefix will only be created if the original video is large enough
897		// this fallback selects the closest prefix if the one we want does not exist
898		if (t.data('width') < mcConf.clipPrefixSizes[prefix].width) {
899			for (var key in mcConf.clipPrefixSizes) {
900				if (mcConf.clipPrefixSizes.hasOwnProperty(key)) {
901					var size = mcConf.clipPrefixSizes[key];
902					if (t.data('width') >= size.width) {
903						prefix = key;
904					} else {
905						break;
906					}
907				}
908			}
909		}
910		var videoURL =  storage_url+prefix+'_'+fileName,
911			posterURL = storage_url+mcConf.clipPrefixSizes[prefix].poster+'_'+replaceFileExtension(fileName, 'jpg'),
912			mp4 = replaceFileExtension(videoURL, 'mp4'),
913			video,
914			autoplay = t.data('autoplay') ? 'autoplay' : '';
915		if (t.hasClass('poster-hidden')) {
916			poster = '';
917		}
918		if (t.find('video').length) {
919			video = t.find('video');
920		} else {
921			video = $('<video loop muted '+autoplay+' />').attr({
922				'poster': posterURL,
923				'autoplay': t.data('autoplay'),
924				'data-width': t.data('width'),
925				'data-height': t.data('height'),
926				'data-ratio': t.data('width')/t.data('height')
927			});
928		}
929		$('<source />').appendTo(video).attr({'type': 'video/mp4','src': mp4});
930		if (!t.find('video').length) {
931			t.append(video);
932		}
933		t.removeAttr('data-filename');
934	});
935}
936
937function replaceFileExtension(filename, newExtension) {
938	if (x = filename.lastIndexOf('.')) {
939		filename = filename.substring(0, x + 1) + newExtension;
940		return filename.toLowerCase();
941	} else {
942		return false;
943	}
944}
945
946// screensaver
947function screensaver() {
948	// timeout on screensaver
949	$.idleTimer(mcConf.idleWaitTime);
950
951	// wait for a while to load the images in
952	setTimeout(function(){
953		preloadAllElementImages("#screensaver");
954	}, (mcConf.idleWaitTime - 500));
955
956	// show screensaver
957	$(document).bind("idle.idleTimer", function(){
958		resizeScreenSaver();
959		$('#screensaver').css('display','block').animate({'opacity':'1.0'}, 500);
960		if (homepage == true) {
961			jwplayer(asset_id).pause();
962		}
963	});
964
965	// hide screensaver
966	$(document).bind("active.idleTimer", function(){
967		$('#screensaver').animate({'opacity':'0'}, 500, function() {
968			$(this).hide();
969		});
970		if (homepage == true) {
971			jwplayer(asset_id).play();
972		}
973	});
974
975	// setup home slideshow
976	$('#screensaver .screens').cycle({
977		fx: 'fade',
978		timeout: 5000,
979		delay: 3000,
980		speed: 1000,
981		containerResize: 0,
982		fit: 0,
983		slideResize: 0,
984		cleartype: true,
985		cleartypeNoBg: true
986	});
987
988	resizeScreenSaver();
989
990	$(window).bind('resize',function() {
991		resizeScreenSaver();
992	});
993}
994// resize home slideshow and scale image appropriately
995// only landscape images should be used
996function resizeScreenSaver() {
997	cropImages('#screensaver');
998}
999
1000// function to resize the overlays
1001function resizeOverlay() {
1002	var oHeight = $('.overlay .o_content').height()/2;
1003	var oWidth = $('.overlay .o_content').width()/2;
1004	$('.o_content').css({'margin-left':-oWidth, 'margin-top':-oHeight});
1005}
1006
1007
1008$('.bgoptions a').bind('click',function(){
1009	if(this.id == "blackSwitcher"){
1010		$('.origselected').css('color','white');
1011		$('.n_portfolio ').css('color','white');
1012	}
1013	else {
1014		$('.origselected').css('color','black');
1015		$('.n_portfolio').css('color','black');
1016	}
1017});
1018
1019mcConf.videoList = [];
1020
1021function setupVideo(container) {
1022
1023	$('.slideshow_video', container).each(function() {
1024
1025		// check for videojs class
1026		if ($('.video-js', this).length) {
1027			if ($('.vjs-poster', this).length) {return; }
1028
1029			// Check for video type (video, 3D, 360) There could be more as we start to build support for these.
1030			// Google just announced 180deg movies, so that could be another to add to the list later on.
1031			var videoID = $(this).attr('id');
1032			if ($('.video-js', this).attr('data-video-type') == '360') {
1033
1034				var vid = 'video_'+videoID;
1035				var player = window.player = videojs(vid, {}, function() {
1036					window.addEventListener("resize", function () {
1037							var canvas = player.getChild('Canvas');
1038						if(canvas) canvas.handleResize();
1039					});
1040				});
1041
1042				var videoElement = $(vid);
1043				var width = videoElement.offsetWidth;
1044				var height = videoElement.offsetHeight;
1045				player.width(width);
1046				player.height(height);
1047
1048				player.panorama({
1049					clickAndDrag: true,
1050					autoMobileOrientation: true,
1051					callback: function () {
1052						$('#'+vid).removeClass('vjs-controls-disabled');
1053					}
1054				});
1055
1056			} else {
1057				if (!$('.vjs-control-bar', this).length) {
1058					var vid = 'video_'+videoID;
1059					var player = videojs(vid, {
1060						controls: true,
1061						crossOrigin: 'anonymous',
1062						nativeControlsForTouch: true,
1063						plugins: {
1064							videoJsResolutionSwitcher: {
1065								ui: true,
1066								default: 1920,
1067								dynamicLabel: false
1068							}
1069						}
1070					});
1071					mcConf.videoList.push(player);
1072				}
1073			}
1074		} else {
1075
1076			var slideshow_video = $(this);
1077			var video_url = slideshow_video.attr('rel');
1078			video_url = video_url.substr(0, video_url.lastIndexOf('.')) || video_url;
1079			var asset_id = slideshow_video.attr('id');
1080			var image_url = $('img', slideshow_video).attr('src');
1081
1082			if (!$('#video_' + asset_id + '_wrapper').length && !$('#video_' + asset_id + '_video__wrapper').length) {
1083				$('#video_'+asset_id).hide();
1084				jwplayer('video_' + asset_id).setup({
1085					autostart: mcConf.videoAutostart,
1086					'levels' : [
1087						{file : video_url+'.mp4'}
1088					],
1089					image: image_url,
1090					stretching: mcConf.videoStretching,
1091					screencolor: mcConf.videoScreenColor,
1092					smoothing: true,
1093					width: mcConf.videoWidth,
1094					height: mcConf.videoHeight,
1095					repeat: mcConf.videoRepeat,
1096					mute: mcConf.videoMuted,
1097					'controlbar': mcConf.videoControlPosition,
1098					'controlbar.idlehide': mcConf.videoControlIdleHide,
1099					'controlbar.position': mcConf.videoControlPosition,
1100					'logo.file': mcConf.videoLogoFile,
1101					'logo.position': mcConf.videoLogoPosition,
1102					'logo.over': mcConf.videoLogoOver,
1103					'logo.out': mcConf.videoLogoOut,
1104					'logo.hide': mcConf.videoLogoHide,
1105					'modes' : [
1106						{type: 'flash', src: '/jwplayer/player.swf',config: {
1107							skin: mcConf.videoPlayerSkin
1108						}},
1109						{type: 'html5'}
1110					],
1111					'events': {
1112						'onPlay':   function(){$(document).trigger('onPlay.mcVideo', asset_id); },
1113						'onBuffer':   function(){$(document).trigger('onBuffer.mcVideo', asset_id); },
1114
1115					}
1116				});
1117				$('#video_'+asset_id).show();
1118			}
1119		}
1120	});
1121}
1122
1123function removeVideo(container) {
1124	if ($('.slideshow_video', container).length) {
1125		$('.slideshow_video', container).each( function() {
1126			var slideshow_video = $(this);
1127			var asset_id = slideshow_video.attr('id');
1128			// jwplayer
1129			if (($('#video_' + asset_id + '_wrapper').length || $('#video_' + asset_id + '_video_wrapper').length) && jwplayer('video_' + asset_id).getState()) {
1130				jwplayer('video_' + asset_id).remove();
1131			}
1132			// video.js
1133			if ($(this).find('.vjs-control-bar').length) {
1134				var player = videojs('#video_'+asset_id);
1135				player.pause();
1136			}
1137		});
1138	}
1139}
1140
1141jQuery.fn.extend({
1142    mshow: function () {
1143        $(this).addClass('open').removeClass('closed');
1144        return this;
1145    },
1146    mhide: function () {
1147	    $(this).addClass('closed').removeClass('open');
1148        return this;
1149    }
1150});
1151var mcMenu = {
1152
1153	 config : {
1154        navSlideSpeed : (mcConf.navSlideSpeed) ? mcConf.navSlideSpeed : 200,
1155        top_levels : '#n_top_list li.n_main'
1156    },
1157
1158	init : function (config) {
1159		if (config && typeof(config) == 'object') {
1160        	$.extend(mcMenu.config, config);
1161        }
1162        //$(mcMenu.config.top_levels).mhide();
1163		//$(mcMenu.config.top_levels).mshow(); // having them hidden by default helps avoid a flash between render and this code running
1164
1165		mcMenu.setup();
1166		if(mcConf.menuType == 'collapse'){mcMenu.collapse();}
1167		else if(mcConf.menuType == 'toggle'){mcMenu.toggle();}
1168		else if(mcConf.menuType == 'dropdown'){mcMenu.dropdown();}
1169		return false;
1170	},
1171
1172	setup : function() {
1173
1174		return false;
1175	},
1176
1177	dropdown : function() {
1178		$('#n_backtomenu').addClass('closed');
1179		if(mcConf.is_content) {$('#n_top_list li.n_main').find(' > ul.contents_list').mhide();}
1180		// toggle the parent elements
1181		$('#n_top_list li.n_main.container > a').click(function (e){
1182			e.stopPropagation(); // prevent bubbling on element
1183			e.preventDefault();
1184			var sublist = $(this).parent().find(' > ul.contents_list');
1185			if(sublist.hasClass('open')){
1186				sublist.mhide();
1187				$('body').unbind('click');
1188			} else {
1189				sublist.mshow();
1190			}
1191		});
1192		// body click
1193		$('html').bind('click',function(){
1194			if ($('#n_top_list ul.contents_list').hasClass('open')){
1195				$('#n_top_list ul.contents_list').mhide();
1196			}
1197		});
1198
1199		return false;
1200	},
1201
1202	toggle : function () {
1203
1204		$('#n_backtomenu').addClass('closed'); // hide the back to menu link
1205		// TODO: only output the backtomenu if menuType=collapse
1206
1207		// on the main studio container links, capture click and toggle submenu
1208		$('#n_top_list li.n_main.container > a').click(function (e){
1209			if($(this).parent().hasClass('external')){return;}
1210			var sublist = $(this).parent().find('>ul.contents_list');
1211			if (sublist && $(sublist).find('li').length) {
1212				e.preventDefault();
1213
1214				if(mcMenu.toggle_custom && typeof mcMenu.toggle_custom == 'function') { if(!mcMenu.toggle_custom(this)) { return; } }
1215
1216				if($(this).attr('data-link')){location.href = $(this).attr('href')+$(this).attr('data-link');return;}
1217
1218				if($(this).hasClass('sel')) {
1219					$(this).removeClass('sel');
1220					$(this).parent().find('>ul.contents_list').mhide();
1221
1222				} else {
1223					if($(this).parent().hasClass('level_1')) {
1224						$(mcMenu.config.top_levels).find('ul.contents_list.open').mhide();
1225						$('#n_top_list li.n_main.container > a').removeClass('sel');
1226					}
1227
1228					$(this).addClass('sel');
1229
1230					if(sublist.hasClass('open')){ sublist.mhide(); } else { sublist.mshow(); }
1231				}
1232			}
1233		});
1234
1235		return false;
1236	},
1237
1238	collapse : function () {
1239
1240		if(mcConf.is_lightbox) {$(mcMenu.config.top_levels).mhide();$('#n_backtomenu').mshow();}
1241		$('#n_top_list li.n_main.container > a').bind('click', mcMenu.navClick);
1242		$('#n_backtomenu').bind('click', mcMenu.backToMenuClick);
1243		$('#n_backtocurrent').bind('click', mcMenu.backToCurrentClick);
1244		$('.sub_page a.sel').parent().mshow().parent().mshow();
1245
1246		if($(mcMenu.config.top_levels).find('a.active').length > 0) { // if we have open entries
1247			mcMenu.backToMenuClick(); // reset menu
1248			if($(mcMenu.config.top_levels).mhide().find('a.active').last().parents('.n_sub').length) {
1249				mcMenu.backToCurrentClick(); // click active sub-leaf
1250			} else {
1251				// click along into containers
1252				$(mcMenu.config.top_levels).mhide().find('a.active').each(function(){$(this).trigger('click');});
1253			}
1254
1255		} else {
1256			// set the back to menu hide by default
1257			if(!mcConf.is_lightbox) {
1258				$('#n_backtomenu').mhide();
1259			}
1260		}
1261		if(mcConf.menu_show_artist_only && ($('.n_main.artist > a.active').length || mcConf.is_content)) {
1262			$('li.level_1:not(.artist)>a.sel').mhide();
1263		}
1264
1265		$(document).trigger('mcMenu.collapse');
1266		return false;
1267	},
1268
1269	navClick : function (e) {
1270
1271		if($(this).parent().hasClass('external')){return;}
1272		e.preventDefault();
1273		if($(this).attr('data-link')){location.href = $(this).attr('href')+$(this).attr('data-link');return;}
1274
1275		$(document).trigger('mcMenu.navClick', [this]);
1276
1277		if ($(this).hasClass('sel')) {
1278			// clicked an open container - is the the last open one? if so leave it because it should already be showing it's stuff
1279			if($(this).parent().find('li.n_main > a.sel').length > 0) {
1280				// not the last open container - close their children
1281				$(this).parent().find('li > a').removeClass('sel'); // clear sub sel classes
1282				$(this).parent().find('li.n_main > ul.contents_list').mhide(); // close open subcontainers
1283				$(this).parent().find('li').mshow(); // show all the list items for this container
1284				$(this).parent().mhide(); // hide then slide the current list
1285			}
1286		} else {
1287			// clicked on something we want to open
1288			mcMenu.closeContainers();
1289			mcMenu.openChildren(this);
1290			//$('#n_top_list').find('ul.contents_list').mhide(); // close open subcontainers
1291			if($('.n_main.artist > a.active').length > 1 && mcConf.menu_show_artist_only){$('.level_1:not(.n_blog)>a.sel').mhide();}
1292			//$(this).parent().parent().find('> li').mhide();
1293			//$(this).parent().mshow().find('> ul').mshow().find('li').mshow().find('a').mshow();
1294			$('#n_backtomenu').mshow();
1295
1296		}
1297		return false;
1298	},
1299
1300	backToMenuClick : function () {
1301		$('#n_top_list a').removeClass('sel').mshow();
1302		$('#n_top_list .n_main').mhide();
1303		$('#n_top_list > .n_main').mshow();
1304		$('#n_top_list ul.contents_list').mhide();
1305		$('#n_top_list .n_sub').mhide();
1306		$('#nav .menu_hide').mhide();
1307		$('#nav_top').mhide();
1308		$(this).mhide();
1309		if(mcConf.is_content) { $('#n_backtocurrent').mshow(); }
1310		$('body').removeClass('no_cover');
1311
1312		$(document).trigger('mcMenu.backToMenuClick');
1313		return false;
1314	},
1315
1316	backToCurrentClick : function () {
1317
1318		mcMenu.backToMenuClick();
1319		$('#n_backtocurrent').mhide(); // hide the return button
1320		$('#n_backtomenu').mshow(); // show the menu button
1321		$('#nav .menu_hide').mshow(); // show the controls
1322		$('#n_top_list ul.contents_list.active').last().find('li').mshow(); // and show the last open header & list
1323
1324		$(mcMenu.config.top_levels).mhide().each(function (){ // hide all n_main's too
1325			if($('a', this).hasClass('active')){ // but open the selected ones
1326				$(this).mshow(); // show the li
1327				$('> a', this).addClass('sel'); // sel the artist name
1328				$('ul.contents_list.active', this).mshow(); // show active contents
1329
1330				$(document).trigger('mcMenu.backToCurrentClick.top_level', [this]);
1331
1332				if(mcConf.is_content && mcConf.menu_show_artist_only) {
1333					$('li.level_1>a.sel').mhide();
1334				}
1335			}
1336		});
1337
1338		return false;
1339	},
1340
1341	resetNav : function () {
1342
1343		mcMenu.setup();
1344		if(mcConf.menuType == 'collapse'){mcMenu.collapse();}
1345
1346		return false;
1347	},
1348
1349	closeContainers : function () {
1350
1351		$('li.n_main').each(function (){ // hide all containers
1352			$(this).mhide(); // hide
1353			$(this).find('a').mhide(); // hide the anchor tags
1354			$(this).find('ul').mhide(); // hide the contents list
1355		});
1356
1357
1358	},
1359
1360	openChildren : function (item) {
1361		$(item).addClass('sel').mshow();
1362		$(item).parents('li,ul,a').mshow();
1363		//$(this).parent()
1364		var container = $(item).parent();
1365		//container.mshow();
1366		var contents = container.find('>ul');
1367		contents.mshow().find('li').mshow().find('a').mshow();
1368	}
1369}
1370
1371var mcForms = {
1372
1373
1374}
1375
1376// cropping images for any image that is being passed in within a container
1377// pass in the item container and the function will do the rest
1378function cropImages(e){
1379	$(e).each(function() {
1380		var item = $(this);
1381		$('img, video', item).each( function() {
1382			var _imgW, _imgH;
1383			var img = $(this);
1384			if (typeof img.attr('filename') == 'undefined') { // if the image has been loaded..
1385				_imgW = img.width();  // get the w/h from
1386				_imgH = img.height(); // the actual element
1387			}
1388			if ($(this).is('video') && img.get(0).readyState < 4) {
1389				_imgW = img.attr('data-width');
1390				_imgH = img.attr('data-height');
1391			}
1392			if(!_imgW || !_imgH) { // failing that, get dim from the actual images..
1393				_imgW = img.attr('imgw'); // get it from the database-
1394				_imgH = img.attr('imgh'); // -supplied attributes
1395			}
1396
1397			var _imgRatio = _imgW/_imgH;
1398			var _itemW = item.width();
1399			var _itemH = item.height();
1400			var _itemRatio = _itemW/_itemH;
1401			if (_imgRatio >= _itemRatio){
1402				img.removeClass('portrait');
1403				img.addClass('landscape');
1404				var new_width = _itemH*_imgRatio;
1405				var margin;
1406				if (!!img.attr('data-focus-x') && img.attr('data-focus-x') >= 0) {
1407					margin = Math.ceil(_itemW/2 - img.attr('data-focus-x')*new_width);
1408					if (margin >= 0 ) {margin = 0; }
1409					if (margin < _itemW - new_width) {margin = _itemW - new_width; }
1410				} else {
1411					margin = Math.ceil((_itemW - new_width)/2);
1412				}
1413				img.css({'margin-left':margin+'px', 'margin-top': 0});
1414			} else {
1415				img.removeClass('landscape');
1416				img.addClass('portrait');
1417				var new_height = _itemW/_imgRatio;
1418				var margin;
1419				if (!!img.attr('data-focus-y') && img.attr('data-focus-y') >= 0) {
1420					margin = Math.ceil(_itemH/2 - img.attr('data-focus-y')*new_height);
1421					if (margin > 0 ) {margin = 0; }
1422					if (margin < _itemH - new_height) {margin = _itemH - new_height; }
1423				} else {
1424					margin = Math.ceil((_itemH - new_height)/2);
1425				}
1426				img.css({'margin-top':margin+'px', 'margin-left': 0});
1427			}
1428		});
1429	});
1430}
1431
1432// fill the slideshow area with the images
1433// they will fit vertically and horizontally to fill the required space
1434function fillImages(e){
1435	$(e).each(function() {
1436		var _el;
1437		if ($('video', this).length) {
1438			_el = 'video';
1439		} else {
1440			_el = 'img';
1441		}
1442		var imageWidth = $(_el, this).attr('width');
1443		var imageHeight = $(_el, this).attr('height');
1444		if(!imageWidth){ return; }
1445
1446		var winWidth = $(this).width();
1447		var winHeight = $(this).height();
1448
1449		var picHeight = imageHeight / imageWidth;
1450		var picWidth = imageWidth / imageHeight;
1451		if ((winHeight / winWidth) < picHeight) {
1452			$(_el, this).attr("width",winWidth);
1453			$(_el, this).attr("height",picHeight*winWidth);
1454		} else {
1455			$(_el, this).attr("height",winHeight);
1456			$(_el, this).attr("width",picWidth*winHeight);
1457		};
1458
1459		$(_el, this).css("margin-left",(winWidth-$('img', this).attr('width'))/2);
1460		$(_el, this).css("margin-top",(winHeight-$('img', this).attr('height'))/2);
1461
1462	});
1463}
1464// fit the images within the area
1465function fitImages(e){
1466	$(e).each(function() {
1467		var _el;
1468		if ($('video', this).length) {
1469			_el = 'video';
1470		} else {
1471			_el = 'img';
1472		}
1473		var imgRatio = $(_el, this).attr('data-ratio');
1474		var itemRatio = $(this).width()/$(this).height();
1475		if (imgRatio > itemRatio) {
1476			$(_el, this).addClass('landscape-fit').removeClass('portrait-fit');
1477		} else {
1478			$(_el, this).addClass('portrait-fit').removeClass('landscape-fit');
1479		}
1480	});
1481}
1482if($.Isotope) {
1483
1484	// Modified Isotope methods for gutters in masonry
1485	$.Isotope.prototype._getMasonryGutterColumns = function() {
1486		var gutter = this.options.masonry && this.options.masonry.gutterWidth || 0;
1487		containerWidth = this.element.width();
1488
1489		this.masonry.columnWidth = this.options.masonry && this.options.masonry.columnWidth ||
1490		// Or use the size of the first item
1491		this.$filteredAtoms.outerWidth(true) ||
1492		// If there's no items, use size of container
1493		containerWidth;
1494
1495		this.masonry.columnWidth += gutter;
1496
1497		this.masonry.cols = Math.floor((containerWidth + gutter) / this.masonry.columnWidth);
1498		this.masonry.cols = Math.max(this.masonry.cols, 1);
1499	};
1500
1501	$.Isotope.prototype._masonryReset = function() {
1502		// Layout-specific props
1503		this.masonry = {};
1504		// FIXME shouldn't have to call this again
1505		this._getMasonryGutterColumns();
1506		var i = this.masonry.cols;
1507		this.masonry.colYs = [];
1508		while (i--) {
1509			this.masonry.colYs.push(0);
1510		}
1511	};
1512
1513	$.Isotope.prototype._masonryResizeChanged = function() {
1514		var prevSegments = this.masonry.cols;
1515		// Update cols/rows
1516		this._getMasonryGutterColumns();
1517		// Return if updated cols/rows is not equal to previous
1518		return (this.masonry.cols !== prevSegments);
1519	};
1520
1521	$.Isotope.prototype._masonryReset = function() {
1522		// Layout-specific props
1523		this.masonry = {};
1524		// FIXME shouldn't have to call this again
1525		this._getMasonryGutterColumns();
1526		var i = this.masonry.cols;
1527		this.masonry.colYs = [];
1528		while (i--) {
1529			this.masonry.colYs.push(0);
1530		}
1531	};
1532
1533}
1534
1535// uses alternative colour for spreads
1536function additionalSpreadColor(container, size_override) {
1537	$(container).each(function(){
1538		if(typeof size_override == 'undefined'){ size_override = mcConf.lbAssetSize; }
1539		$(this).find('img[filename]').each(function(i) {
1540			$(this).attr('size_override', size_override);
1541		});
1542		if ($(this).find('img').hasClass('alt_spread')) {
1543			preloadAllElementImages(this, size_override+'_'+mcConf.alternateSpreadColor);
1544		} else {
1545			preloadAllElementImages(this, size_override);
1546		}
1547	});
1548}
1549
1550// removes url uuid
1551function removeUrlUuid() {
1552	var new_url = document.location.pathname.split('/');
1553	var patt = /[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}/;
1554	var prev_asset = new_url.pop();
1555	if(!patt.test(prev_asset)){
1556		new_url.push(prev_asset); // put it back - its not a uuid
1557	}
1558	new_url = new_url.join('/');
1559	return new_url;
1560}
1561
1562// resets url
1563function resetUrl(new_url) {
1564	if (history.pushState) {
1565		window.history.pushState('', document.title, new_url);
1566	}
1567}
1568
1569// autoplay videoclips in Safari again
1570$(window).on('load', function(){
1571	$('video').each(function(){
1572		if ($(this).attr('autoplay') && ($(this).attr('autoplay') == 'autoplay' || $(this).attr('autoplay') == 'true')) {
1573			var promise = $(this)[0].play();
1574			if (promise !== undefined) {
1575				promise.then(function() {
1576
1577				}).catch(function() {
1578
1579				});
1580			}
1581		}
1582	});
1583});
1584
1585function stripUUIDs(url) {
1586	var pattern = /[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}/;
1587	var parts = url.split("/");
1588	var new_url = [];
1589	for (var i=0; i < parts.length; i++) {
1590		if(!pattern.test(parts[i])) {
1591			new_url.push(parts[i]);
1592		}
1593	}
1594	return new_url.join('/');
1595}
1596
1597// video play / pause in viewport
1598!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(require("jquery")):"function"==typeof define&&define.amd?define(["jquery"],n):n(e.jQuery)}(this,function(e){"use strict";function n(n){var t=this;if(1===arguments.length&&"function"==typeof n&&(n=[n]),!(n instanceof Array))throw new SyntaxError("isInViewport: Argument(s) passed to .do/.run should be a function or an array of functions");return n.forEach(function(n){"function"!=typeof n?(console.warn("isInViewport: Argument(s) passed to .do/.run should be a function or an array of functions"),console.warn("isInViewport: Ignoring non-function values in array and moving on")):[].slice.call(t).forEach(function(t){return n.call(e(t))})}),this}function t(n){var t=e("<div></div>").css({width:"100%"});n.append(t);var o=n.width()-t.width();return t.remove(),o}function o(n,r){var i=n.getBoundingClientRect(),a=i.top,u=i.bottom,c=i.left,f=i.right,s=e.extend({tolerance:0,viewport:window},r),d=!1,l=s.viewport.jquery?s.viewport:e(s.viewport);l.length||(console.warn("isInViewport: The viewport selector you have provided matches no element on page."),console.warn("isInViewport: Defaulting to viewport as window"),l=e(window));var p=l.height(),w=l.width(),h=l[0].toString();if(l[0]!==window&&"[object Window]"!==h&&"[object DOMWindow]"!==h){var v=l[0].getBoundingClientRect();a-=v.top,u-=v.top,c-=v.left,f-=v.left,o.scrollBarWidth=o.scrollBarWidth||t(l),w-=o.scrollBarWidth}return s.tolerance=~~Math.round(parseFloat(s.tolerance)),s.tolerance<0&&(s.tolerance=p+s.tolerance),f<=0||c>=w?d:d=s.tolerance?a<=s.tolerance&&u>=s.tolerance:u>0&&a<=p}function r(n){if(n){var t=n.split(",");return 1===t.length&&isNaN(t[0])&&(t[1]=t[0],t[0]=void 0),{tolerance:t[0]?t[0].trim():void 0,viewport:t[1]?e(t[1].trim()):void 0}}return{}}e=e&&e.hasOwnProperty("default")?e.default:e,
1599/**
1600 * @author  Mudit Ameta
1601 * @license https://github.com/zeusdeux/isInViewport/blob/master/license.md MIT
1602 */
1603e.extend(e.expr.pseudos||e.expr[":"],{"in-viewport":e.expr.createPseudo?e.expr.createPseudo(function(e){return function(n){return o(n,r(e))}}):function(e,n,t){return o(e,r(t[3]))}}),e.fn.isInViewport=function(e){return this.filter(function(n,t){return o(t,e)})},e.fn.run=n});
1604
1605
1606$(window).scroll(function() {
1607	$('video').each(function(){
1608		if ($(this).is('[autoplay]')) {
1609			if ($(this).is(":in-viewport(0)")) {
1610				$(this).removeClass('paused');
1611				$(this)[0].play()
1612			} else {
1613				$(this).addClass('paused');
1614				$(this)[0].pause();
1615			}
1616		}
1617	});
1618});
1619
1620
1621function pauseAllVideoClips() {
1622	$('video').each(function(){
1623		if ($(this).is('[autoplay]')) {
1624			if ($(this).hasClass('paused')) {
1625				$(this)[0].pause();
1626			} else {
1627				$(this).addClass('paused');
1628				$(this)[0].pause();
1629			}
1630		}
1631	});
1632}
1633
1634function resumeAllVideoClips() {
1635	$('video').each(function(){
1636		if ($(this).is('[autoplay]')) {
1637			if ($(this).is(":in-viewport(0)")) {
1638				$(this).removeClass('paused');
1639				$(this)[0].play();
1640			}
1641		}
1642	});
1643}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.