PageSourceSearch

https://www.clarendonagricare.com/wp-content/themes/mural/js/screen.js?ver=1.0

js clarendonagricare.com collected 2026-10-08 18:33:34 UTC 42,532 bytes, 1,152 lines download raw bytes

1/* Replace "no-js" class with "js" in the HTML element */
2var htmlElement = document.getElementsByTagName('html')[0];
3htmlElement.className = htmlElement.className.replace("no-js","js");
4
5/* Cufon fonts */
6if( unisphere_globals.cufonFonts != '') {
7	var cufonFonts = eval( "(" + unisphere_globals.cufonFonts + ")" );
8	jQuery.each(cufonFonts.fonts, function(k, v) {
9		Cufon.replace( v.selector, { fontFamily: v.fontFamily, hover: true });
10	});
11	window.setInterval( function() {Cufon.refresh();}, 100 );
12}
13
14jQuery(document).ready(function() {
15
16	// Adds a browser specific CSS class to the body tag
17	jQuery('body').addClass( jQuery.uaMatch(navigator.userAgent).browser ).addClass( jQuery.uaMatch(navigator.userAgent).browser + '-' + parseInt(jQuery.browser.version, 10));
18
19	// Remove some cufon replaces that occurred on certain Woocommerce places
20	removeCufon('.product a h3, .related.products h2, .woocommerce_tabs h2');
21
22	mobileNav();
23	
24	/* Dropdown menu using superfish */
25	jQuery('.nav').supersubs({
26		minWidth: 12,
27		maxWidth: 25,
28		extraWidth: 1
29	}).superfish({
30		delay: 250,
31		animation: { opacity: 'show', height: 'show' },
32		speed: 'fast',
33		autoArrows: false 
34	});
35
36	/* Quicksand animation and filtering of the Portfolio */
37	var data = jQuery(".portfolio-sortable").clone();
38
39	if(window.location.hash != '') {
40	    var filterClass = window.location.hash.substring(1);
41
42	    jQuery(".portfolio-filters li a").removeClass("active");
43
44	    var filteredData = data.find('.portfolio-item[data-type*=' + filterClass + ']');
45
46	    jQuery('.portfolio-sortable').quicksand(filteredData, {
47	        duration: 500,
48	        easing: 'easeInOutExpo',
49	        adjustHeight: 'dynamic'
50	    }, function(){
51	        // end callback
52	        SetPortfolioItemHover();
53			SetLightbox();
54
55		    // Check for the existence of the SublimeVideo object
56			if (typeof sublimevideo !== 'undefined' && typeof sublimevideo !== false) {			
57				jQuery('video.zoom').each(function() {						
58					sublimevideo.prepare(jQuery(this).attr('id'));
59				});
60			} 
61	    });
62
63	    jQuery(".portfolio-filters li." + filterClass).children('a').addClass("active");
64	}
65
66	jQuery('.portfolio-filters li').click(function(e) {
67
68		jQuery(".portfolio-filters li a").removeClass("active");
69
70		var filterClass = jQuery(this).attr('class');
71
72		if (filterClass == 'all') {
73			var filteredData = data.find('.portfolio-item');
74		} else {
75			var filteredData = data.find('.portfolio-item[data-type*=' + filterClass + ']');
76		}
77
78		jQuery('.portfolio-sortable').quicksand(filteredData, {
79			duration: 500,
80			easing: 'easeInOutExpo',
81			adjustHeight: 'dynamic'
82		}, function(){
83			// end callback
84			SetPortfolioItemHover();
85			SetLightbox();
86
87		    // Check for the existence of the SublimeVideo object
88			if (typeof sublimevideo !== 'undefined' && typeof sublimevideo !== false) {			
89				jQuery('video.zoom').each(function() {						
90					sublimevideo.prepare(jQuery(this).attr('id'));
91				});
92			} 
93		});
94
95		jQuery(this).children('a').addClass("active");
96
97		return false;
98	});
99
100	// Masonry blog template
101	var masonry_container = jQuery('.blog-masonry');
102	if( masonry_container ) {
103		masonry_container.imagesLoaded(function(){
104			var _gutterWidth = Math.round(jQuery('.blog-masonry div:first-child').width() * 0.1);
105			masonry_container.masonry({
106		    	itemSelector: '.post, .page, .portfolio_cpt',
107		    	gutterWidth: _gutterWidth
108		  	});
109		});
110	}
111
112	/* Ajax Contact form validation and submit */
113	jQuery('form#contactForm').submit(function() {
114		jQuery(this).find('.error').remove();
115		var hasError = false;
116		jQuery(this).find('.requiredField').each(function() {
117			if(jQuery.trim(jQuery(this).val()) == '') {
118				jQuery(this).addClass('input-error');
119				hasError = true;
120			} else if(jQuery(this).hasClass('email')) {
121				var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
122				if(!emailReg.test(jQuery.trim(jQuery(this).val()))) {
123					jQuery(this).addClass('input-error');
124					hasError = true;
125				}
126			}
127		});
128		if(!hasError) {
129			jQuery(this).find('#unisphere-submit').fadeOut('normal', function() {
130				jQuery(this).parent().parent().find('.sending-message').show('normal');
131			});
132			var formInput = jQuery(this).serialize();
133			var contactForm = jQuery(this);
134			jQuery.ajax({
135				type: "POST",
136				url: jQuery(this).attr('action'),
137				data: formInput,
138				success: function(data){
139					contactForm.parent().fadeOut("normal", function() {
140						jQuery(this).prev().prev().show('normal'); // Show success message
141					});
142				},
143				error: function(data){
144					contactForm.parent().fadeOut("normal", function() {
145						jQuery(this).prev().show('normal');  // Show error message
146					});
147				}
148			});
149		}
150		
151		return false;
152		
153	});
154	
155	jQuery('.requiredField').blur(function() {
156		if(jQuery.trim(jQuery(this).val()) != '' && !jQuery(this).hasClass('email')) {
157			jQuery(this).removeClass('input-error');
158		} else {
159			jQuery(this).addClass('input-error');
160		}
161	});
162	
163	jQuery('.email').blur(function() {
164		var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
165		if(emailReg.test(jQuery.trim(jQuery(this).val())) && jQuery(this).val() != '') {
166			jQuery(this).removeClass('input-error');
167		} else {
168			jQuery(this).addClass('input-error');
169		} 
170	});	
171	
172	/* Search Watermark */
173	var watermark = unisphere_globals.searchLocalized;
174	jQuery(".search").each(function() {
175		if (jQuery(this).val() == '') {
176			jQuery(this).val(watermark);
177		}	
178	});	
179	
180	jQuery(".search")
181		.focus(	function() {
182			if (this.value == watermark) {
183				this.value = "";
184			}
185		})
186		.blur(function() {
187			if (this.value == "") {
188				this.value = watermark;
189			}
190		});
191
192	/* Remove empty .portfolio-detail-media div */
193	if(jQuery.trim(jQuery(".portfolio-detail-media").html()) == "") {
194		jQuery(".portfolio-detail-media").remove();
195	}
196
197	/* Remove empty #comments div */
198	if(jQuery.trim(jQuery("#comments").text()) == "") {
199		jQuery("#comments").remove();
200	}
201
202	/* Remove empty .price paragraphs */
203	if(jQuery.trim(jQuery("p.price").html()) == "") {
204		jQuery("p.price").remove();
205		jQuery("div.product_meta").css('marginTop', '4px');
206	}
207	
208	/* Tabs */
209	jQuery(".tab-content").hide(); //Hide all content
210	jQuery(".tab-container > br").remove();
211
212	// Select the first tabs by default
213	jQuery("ul.tabs").each( function() {
214		jQuery(this).find("li:first").addClass("active"); //Activate first tab
215	});
216	
217	jQuery(".tab-container").each( function() {
218		jQuery(this).find(".tab-content:first").show(); //Show first tab content
219	});
220
221	// Check if we have a hash in the querystring in order to show a particular tab on page load
222	if( window.location.hash != '') {
223		var tab_id = window.location.hash.substring(1, window.location.hash.indexOf('-'));
224		var tab_to_show = window.location.hash.substring(window.location.hash.indexOf('-tab') + 4);
225
226		jQuery('ul.tabs[data-tab-id=' + tab_id + '] li').each( function() {
227			jQuery(this).removeClass("active"); //Deactivate first tab
228
229			if( jQuery(this).find('a').attr('href') == '#tab' + tab_to_show )
230				jQuery(this).addClass("active"); // Activate selected tab
231		});
232		
233		jQuery('ul.tabs[data-tab-id=' + tab_id + ']').next().find(".tab-content").hide(); //Hide all tab content
234		jQuery('ul.tabs[data-tab-id=' + tab_id + ']').next().find("div.tab-content:nth-child(" + tab_to_show + ")").show();
235	}
236
237	jQuery("ul.tabs li").click(function() {
238		jQuery(this).parent().find('li.active').removeClass("active");
239		jQuery(this).addClass("active"); //Add "active" class to selected tab
240		jQuery(this).parent().next().find(".tab-content").hide(); //Hide all tab content
241
242		var activeTabIndex = (jQuery(this).find("a").attr("href")).substring((jQuery(this).find("a").attr("href")).indexOf('#tab') + 4); //Find the href attribute value to identify the active tab + content
243		
244		var activeTabContent = jQuery(this).parent().next().find("div.tab-content:nth-child(" + activeTabIndex + ")");
245		activeTabContent.fadeIn(); //Fade in the active ID content
246		
247		return false;
248	});
249	
250	/* Toggle */
251	jQuery(".toggle-container .toggle-content").hide(); //Hide (Collapse) the toggle containers on load
252	jQuery(".toggle-container .toggle-sign").text('+'); //Add the + sign on load
253
254	jQuery(".toggle-container-open .toggle-content").show(); //Show the default opened toggle containers on load	
255	jQuery(".toggle-container-open .toggle-sign").text('-'); //Add the - sign on load
256
257	jQuery(".toggle-container .toggle-content").each( function() {
258		jQuery(this).css('width', jQuery(this).parent().width() - 30 );
259	});
260		
261	jQuery(".toggle-container .toggle").click(function(e) {
262		e.preventDefault();
263		if(jQuery(this).find('.toggle-sign').text() == '-') {
264			jQuery(this).find('.toggle-sign').text('+');
265		} else {
266			jQuery(this).find('.toggle-sign').text('-');
267		}
268		jQuery(this).next(".toggle-content").slideToggle();
269	});
270	
271	/* Required to style post page links similar to the wp-pagenavi ones */
272	jQuery('.post_linkpages a span').each( function() {                                  
273        jQuery(this).parent().html(jQuery(this).html());
274    });
275    jQuery('.post_linkpages span').addClass('current');
276	
277	/* Pricing Table */
278	jQuery(".price-table > br").remove();
279	jQuery(".price-table .price-column:nth-child(even)").addClass('price-column-even');
280	jQuery(".price-column li:nth-child(even)").addClass('even');
281	
282	jQuery(".price-table").each( function() { 
283        jQuery(this).find('.price-column:first').addClass('price-column-first');
284    });
285	
286	jQuery(".price-table").each( function() { 
287        jQuery(this).find('.price-column:last').addClass('price-column-last');
288    });
289    
290    /* Buttons */
291    // Add target="_blank" to buttons that have the data-newwindow="true" attribute
292	jQuery('.custom-button[data-newwindow=true]').each( function() {                                  
293		jQuery(this).attr('target', '_blank').removeAttr('data-newwindow');
294	});
295	
296	// Add custom hover background color to buttons that have the data-bgcolorhover attribute
297	jQuery('.custom-button').each( function() {
298		if( jQuery(this).attr('data-bgcolor') != '' ) { jQuery(this).css('backgroundColor', jQuery(this).attr('data-bgcolor')); }
299		if( jQuery(this).attr('data-txtcolor') != '' ) { jQuery(this).css('color', jQuery(this).attr('data-txtcolor')); }
300		jQuery(this).hover(
301			function () { // on hover
302				jQuery(this).css('backgroundColor', '');
303				jQuery(this).css('color', '');
304				if( jQuery(this).attr('data-bgcolorhover') != '' ) { jQuery(this).css('backgroundColor', jQuery(this).attr('data-bgcolorhover')); }
305				if( jQuery(this).attr('data-txtcolorhover') != '' ) { jQuery(this).css('color', jQuery(this).attr('data-txtcolorhover')); }
306			}, 
307			function () { // off hover
308				jQuery(this).css('backgroundColor', '');
309				jQuery(this).css('color', '');
310				if( jQuery(this).attr('data-bgcolor') != '' ) { jQuery(this).css('backgroundColor', jQuery(this).attr('data-bgcolor')); }
311				if( jQuery(this).attr('data-txtcolor') != '' ) { jQuery(this).css('color', jQuery(this).attr('data-txtcolor')); }
312			}
313		);
314	});
315
316	// Add custom color to a price column
317	jQuery('.price-column').each( function() {		
318		if( jQuery(this).attr('data-color') != '' ) { 
319			var columnColor = jQuery(this).attr('data-color');
320			jQuery(this).find('.price-tag').css('color', jQuery(this).attr('data-color')); 
321			var customButton = jQuery(this).find('li .custom-button');
322			customButton.css('backgroundColor', jQuery(this).attr('data-color')); 
323
324			customButton.hover(
325				function () { // on hover
326				}, 
327				function () { // off hover
328					customButton.css('backgroundColor', columnColor); 
329				}
330			);
331		}
332	});
333
334    /* Hide the footer widgets area if there's no widgets present */
335	if( jQuery('.footer-column .widget').size() == 0 ) {
336    	jQuery('#footer-widgets-container').css('display', 'none');
337	};
338
339	/* Hide woocommerce upsells if there are no products to display */
340	if( jQuery('div.upsells ul.products li.info').size() == 1 ) {
341    	jQuery('div.upsells').css('display', 'none');
342	};
343
344	/* Hide woocommerce cross-sells if there are no products to display */
345	if( jQuery('div.cross-sells ul.products li.info').size() == 1 ) {
346    	jQuery('div.cross-sells').css('display', 'none');
347	};
348
349	jQuery('input.submitbutton').each( function() {		
350		jQuery(this).attr('class', 'custom-button');
351	});
352
353	SetPortfolioItemHover();
354	SetLightbox();
355	SetVideoPlayer();	
356	jQuery("#content-container, #footer-widgets-container").fitVids();
357});
358
359/* Portfolio images hover effect */
360function SetPortfolioItemHover() {	
361	// reset top position to a very high number
362	// also set the height of .portfolio-info to the height of the image
363	jQuery(".portfolio-hover-effect .portfolio-item .portfolio-info").each(function() {
364		jQuery(this).css("top", "1000px").css("height", (jQuery(this).prev().height() - 40) + "px");
365	});
366
367	// bind the hover effect
368	jQuery(".portfolio-hover-effect .portfolio-item").unbind('hover');
369	jQuery(".portfolio-hover-effect .portfolio-item").hover(function() {
370		jQuery(this).find('.portfolio-info').css("top", jQuery(this).find('img').height() + 'px');
371		jQuery(this).find('.portfolio-info').stop().animate({ top: '-=' + (jQuery(this).find('img').height()) }, 250, 'easeInOutExpo');
372	},function(){
373		jQuery(this).find('.portfolio-info').stop().animate({ top: '+=' + (jQuery(this).find('img').height()) }, 250, 'easeInOutExpo', function() {
374			jQuery(this).css("top", jQuery(this).parent().find('img').height() + 'px');
375		});	
376	});
377}
378
379function SetLightbox() {
380
381	/* This fixes inline content lightboxes in some WP installations */
382	jQuery('a.lightbox').each(function(){
383		if(jQuery(this).attr('href').indexOf('#') != -1) {
384			jQuery(this).attr('href', jQuery(this).attr('href').substr(jQuery(this).attr('href').indexOf('#')));
385		}
386	});
387	
388	/* PrettyPhoto */
389	jQuery("a[data-rel^='lightbox'], a.zoom[rel='thumbnails'], a[rel^='prettyPhoto']").prettyPhoto();
390	
391	/* Reduce opacity when mouse hover lightbox images */
392	jQuery("a img").not("#slider img, .slider img, .portfolio-hover-effect img, #logo img").hover(function() {
393		jQuery(this).stop().fadeTo("fast", 0.7); // This sets the opacity to 60% on hover
394	},function(){
395		jQuery(this).stop().fadeTo("fast", 1.0); // This sets the opacity back to 100% on mouseout
396	});
397}
398
399function SetVideoPlayer() {
400	/* Sub-header Slider or Shortcode Slider init */
401    if( jQuery('#slider-container').length > 0 || jQuery('.slider-container').length > 0 || jQuery('.embedded-video-flv').length > 0 || jQuery('.embedded-video-html5').length > 0 ) {
402	    // Check for the existence of the SublimeVideo object
403		if (typeof sublimevideo !== 'undefined' && typeof sublimevideo !== false) {			
404			sublimevideo.ready(function(){
405				// Start sub-header slider
406				if( jQuery('#slider').length > 0 ) {
407					DisplaySubHeaderSlider( jQuery('#slider') );
408					SetSubHeaderSliderNavigation();
409				}
410				// Start slider shortcodes
411				jQuery('.slider').each(function() {					
412					DisplayShortcodeSlider(jQuery(this));
413				});
414
415				// Display embedded FLV videos
416				jQuery('.embedded-video-flv').each( function() {
417					DisplayShortcodeFlvVideo(jQuery(this));
418				});
419
420				// Display embedded FLV videos
421				jQuery('.embedded-video-html5').each( function() {
422					DisplayShortcodeHtml5Video(jQuery(this));
423				});
424			});
425
426			// Initialize sublimevideo API if not already initialized
427			if( !jQuery.isFunction( sublimevideo.getState ) ) {
428				sublimevideo.load();
429			}
430		} else {
431			if( jQuery('#slider').length > 0 ) {
432				DisplaySubHeaderSlider( jQuery('#slider') );
433				SetSubHeaderSliderNavigation();
434			}
435			jQuery('.slider').each(function() {
436				DisplayShortcodeSlider(jQuery(this));
437			});
438		}
439	}
440}
441
442function DisplaySubHeaderSlider(element) {	
443	jQuery(element)
444	.after('<span id="slider-prev"/>') 
445	.after('<span id="slider-next"/>') 
446	.cycle({ 
447		fx: 'fade', 
448		easing: 'easeInOutExpo', 
449		cleartype: 1,
450		speed: element.attr('data-speed'),
451		timeout: element.attr('data-timeout'),
452		prev: '#slider-prev',
453		next: '#slider-next',
454		before: onCycleBefore,
455		after: onCycleAfter
456	});
457
458	var aspectRatio = element.attr('data-aspect-ratio');	
459	var newheight = parseInt(element.width()/aspectRatio);
460	if( element.parent().hasClass('fullwidth') )
461		newheight = parseInt(element.parent().width()/aspectRatio);
462   	element.css('height', newheight + 'px');
463   	element.parent().css('height', newheight + 'px');
464   	element.children('li').children('.slider-video').each(function(){
465		jQuery(this).css('height', newheight + 'px');
466	});
467
468	jQuery(element).touchwipe({
469		wipeLeft: function() {
470			jQuery(element).cycle("next");
471		},
472		wipeRight: function() {
473			jQuery(element).cycle("prev");
474		},
475		preventDefaultEvents: false
476	});
477}
478
479function DisplayShortcodeSlider(element) {	
480	jQuery(element)
481	.after('<span id="slider-prev-' + element.attr('id') + '" class="slider-prev"/>') 
482	.after('<span id="slider-next-' + element.attr('id') + '" class="slider-next"/>') 
483	.cycle({ 
484		fx: 'fade', 
485		easing: 'easeInOutExpo', 
486		cleartype: 1,
487		speed: element.attr('data-speed'),
488		timeout: element.attr('data-timeout'),
489		prev: '#slider-prev-' + element.attr('id'),
490		next: '#slider-next-' + element.attr('id'),
491		before: onCycleBefore,
492		after: onCycleAfter
493	});
494
495	var aspectRatio = element.attr('data-aspect-ratio');	
496	var newheight = parseInt(element.width()/aspectRatio);
497   	element.css('height', newheight + 'px');
498   	element.parent().css('height', newheight + 'px');
499   	element.children('li').children('.slider-video').each(function(){
500		jQuery(this).css('height', newheight + 'px');
501	});
502
503	jQuery(element).touchwipe({
504		wipeLeft: function() {
505			jQuery(element).cycle("next");
506		},
507		wipeRight: function() {
508			jQuery(element).cycle("prev");
509		},
510		preventDefaultEvents: false
511	});
512}
513
514function DisplayShortcodeFlvVideo(element) {
515	var player_id = element.find('div').attr('id');
516	var autoplay = element.attr('data-autoplay');
517	var video_thumbnail = element.attr('data-video-thumbnail');
518	var videourl_flv = element.attr('data-videourl-flv');
519
520	var videourl_flv_hd;
521	if (typeof element.attr('data-videourl-flv_hd') !== 'undefined' && element.attr('data-videourl-flv_hd') !== false)
522		videourl_flv_hd = element.attr('data-videourl-flv_hd');
523
524	// Create a <video> DOM element 
525	var video = jQuery('<video/>').attr('id', player_id).attr('class', 'sublimevideo').attr('preload', 'none').attr('poster', video_thumbnail);
526
527	// Create the <source> DOM elements
528	video.append( jQuery('<source/>').attr('src', videourl_flv) );
529	if (videourl_flv_hd) { video.append( jQuery('<source/>').attr('src', videourl_flv_hd).attr('data-quality', 'hd') ); }
530
531	element.empty().append(video);
532
533	if(autoplay == 'true') {
534		sublimevideo.prepareAndPlay(player_id); // start the video
535	} else { 
536		sublimevideo.prepare(player_id);
537	}
538
539	sublimevideo.onStart(function(sv){
540		jQuery('.sublimevideo').each(function(){
541			sublimevideo.unprepare(jQuery(this));
542		});
543	});
544
545	var aspectRatio = element.width() / element.height();
546	element.attr('data-aspect-ratio', aspectRatio);	
547	element.css('width', '100%');
548 		
549	var newWidth = element.width();
550  	sublimevideo.resize(player_id, newWidth, newWidth/aspectRatio);
551  	element.css('height', parseInt(newWidth/aspectRatio) + 'px');
552}
553
554function DisplayShortcodeHtml5Video(element) {
555	var player_id = element.find('div').attr('id');
556	var autoplay = element.attr('data-autoplay');
557	var video_thumbnail = element.attr('data-video-thumbnail');
558	var videourl_mp4 = element.attr('data-videourl-mp4');
559
560	var videourl_mp4_hd;
561	if (typeof element.attr('data-videourl-mp4-hd') !== 'undefined' && element.attr('data-videourl-mp4-hd') !== false)
562		videourl_mp4_hd = element.attr('data-videourl-mp4-hd');
563
564	var videourl_webm;
565	if (typeof element.attr('data-videourl-webm') !== 'undefined' && element.attr('data-videourl-webm') !== false)
566		videourl_webm = element.attr('data-videourl-webm');
567
568	var videourl_webm_hd;
569	if (typeof element.attr('data-videourl-webm-hd') !== 'undefined' && element.attr('data-videourl-webm-hd') !== false)
570		videourl_webm_hd = element.attr('data-videourl-webm-hd');
571
572	// Create a <video> DOM element 
573	var video = jQuery('<video/>').attr('id', player_id).attr('class', 'sublimevideo').attr('preload', 'none').attr('poster', video_thumbnail);
574
575	// Create the <source> DOM elements
576	video.append( jQuery('<source/>').attr('src', videourl_mp4) );
577	if (videourl_mp4_hd) { video.append( jQuery('<source/>').attr('src', videourl_mp4_hd).attr('data-quality', 'hd') ); }
578	if (videourl_webm) { video.append( jQuery('<source/>').attr('src', videourl_webm) ); }
579	if (videourl_webm_hd) { video.append( jQuery('<source/>').attr('src', videourl_webm_hd).attr('data-quality', 'hd') ); }
580
581	element.empty().append(video);
582
583	if(autoplay == 'true' && !isIOS()) {
584		sublimevideo.prepareAndPlay(player_id); // start the video
585	} else {
586		sublimevideo.prepare(player_id);
587	}
588
589	sublimevideo.onStart(function(sv){
590		jQuery('.sublimevideo').each(function(){
591			sublimevideo.unprepare(jQuery(this));
592		});
593	});
594
595	var aspectRatio = element.width() / element.height();
596	element.attr('data-aspect-ratio', aspectRatio);	
597	element.css('width', '100%');
598 		
599	var newWidth = element.width();
600  	sublimevideo.resize(player_id, newWidth, newWidth/aspectRatio);
601  	element.css('height', parseInt(newWidth/aspectRatio) + 'px');
602}
603
604function SetSubHeaderSliderNavigation() {
605	// Sub-header Slider navigation hover effect
606	jQuery('#slider-container #slider-prev').hover(
607		function () { // on hover
608			jQuery(this).stop().animate({ marginLeft: '-563' }, 250, 'easeInOutExpo');
609		},
610		function () { // off hover
611			jQuery(this).stop().animate({ marginLeft: '-558' }, 250, 'easeInOutExpo');
612		}
613	);
614
615	jQuery('#slider-container #slider-next').hover(
616		function () { // on hover
617			jQuery(this).stop().animate({ marginLeft: '525' }, 250, 'easeInOutExpo');
618		},
619		function () { // off hover
620			jQuery(this).stop().animate({ marginLeft: '520' }, 250, 'easeInOutExpo');
621		}
622	);
623}
624
625function onCycleAfter() {
626	jQuery(this).find('.slider-title').delay(100).animate({'bottom':'30px','opacity':'1','marginTop':'0'}, 200);
627	jQuery(this).find('.description').delay(300).animate({'bottom':'30px','opacity':'1','marginTop':'0'}, 200);
628}
629
630/* Event triggered before every slider transition */
631function onCycleBefore() {
632	jQuery(this).find('.slider-title').css({'bottom':'0','opacity':'0','marginTop':'15px'});
633	jQuery(this).find('.description').css({'bottom':'0','opacity':'0','marginTop':'35px'});
634
635	var sliderContainer = jQuery(this).parent().parent();
636	var slider = jQuery(this).parent();
637
638	// By default resume the slider, if a video exists the slider will pause when autoplay is on
639	slider.cycle('resume');
639 // go to next slider item
640
641	// Unprepare any sublime videos in the slider
642	slider.find('.slider-video').each(function() {
643		if( jQuery(this).attr('data-videotype') == 'html5_flv' ) {
644			sublimevideo.unprepare('object' + jQuery(this).attr('id'));
645		}
646	});
647
648	// Search for an embeded video and remove it
649	var element = slider.find('object, iframe, .sublimevideo');
650	element.wrap(function() {
651		return '<div id="object' + element.parent().attr('id') + '" />';
652	}).remove();
653
654	// CSS class to display the slider navigation on different slider item styles.
655	// Adds a "with-description" or "no-description" class to the slider container
656	sliderContainer.removeClass('with-description no-description video image').addClass(jQuery(this).attr('class'));
657
658	// Now create a video if it's present on this slider item
659	var video_element = jQuery(this).find('.slider-video');	
660	if(video_element.length) {
661		sliderContainer.addClass('video');
662		createVideo(video_element);
663	} else {
664		sliderContainer.addClass('image');
665	}
666}
667
668/* Function to embed a video in the slider */
669var yt_player;
670function createVideo(element) {
671	if(element.length) { // if element exists
672		var slider = element.parent().parent();
673		var parent_li = element.parent();
674		slider.cycle('pause'); // pause the slider until video finishes
675
676		var video_id;
677		if (typeof element.attr('data-videourl') !== 'undefined' && element.attr('data-videourl') !== false)
678			video_id = GetVideoId(element.attr('data-videourl'));
679		var player_id = element.find('div').attr('id');					
680		var video_type = element.attr('data-videotype');
681		var unisphere_js = unisphere_globals.jsFolderUrl;
682		var autoplay = element.attr('data-autoplay');		
683
684		if(video_type == 'youtube') {
685			if(isIE()) {
686				var params = { allowScriptAccess: "always", allowfullscreen: "true", wmode: 'transparent' };
687				var atts = { id: player_id, unisphere_autoplay: autoplay };
688				swfobject.embedSWF("http://www.youtube.com/v/" + video_id + "?enablejsapi=1&fs=1&wmode=transparent&autohide=1&showinfo=0&playerapiid=" + player_id, player_id, "100%", "100%", "8", unisphere_js + "/expressinstall.swf", null, params, atts);
689			} else {
690				yt_player = new YT.Player(player_id, { 
691					height: '100%',
692					width: '100%',
693					videoId: video_id,
694					playerVars: {
695						wmode: 'transparent',
696						autohide: 1,
697						showinfo: 0,
698						autoplay: (autoplay == 'true' && !isIOS() ? 1 : 0)
699					},
700					events: {
701						'onReady': onYouTubePlayerReady,
702						'onStateChange': onYouTubePlayerStateChange
703	          		}
704	        	});
705
706	        	if( autoplay != "true" )
707	        		slider.cycle('resume');
708	        }
709		} else if(video_type == 'vimeo') {
710			if(isIE()) {
711				var flashvars = {
712					clip_id: video_id,
713					fullscreen: 1,
714					show_portrait: 0,
715					show_byline: 0,
716					show_title: 0,
717					js_api: 1, // required in order to use the Javascript API
718					js_onLoad: 'onVimeoPlayerReady', // moogaloop will call this JS function when it's done loading (optional)
719					js_swf_id: player_id // this will be passed into all event methods so you can keep track of multiple moogaloops (optional)
720				};
721				var params = { allowscriptaccess: 'always', allowfullscreen: 'true', wmode: 'transparent' };
722				var attributes = { unisphere_autoplay: autoplay };
723				
724				// For more SWFObject documentation visit: http://code.google.com/p/swfobject/wiki/documentation
725				swfobject.embedSWF("http://vimeo.com/moogaloop.swf", player_id, "100%", "100%", "9.0.0", unisphere_js + "/expressinstall.swf", flashvars, params, attributes);
726			} else {
727				jQuery('#' + player_id).append('<iframe id="' + player_id + '" type="text/html" width="100%" height="100%" src="http://player.vimeo.com/video/' + video_id + '?api=1&amp;show_portrait=0&amp;show_byline=0&amp;show_title=0&amp;player_id=' + player_id + '" frameborder="0" unisphere_autoplay="' + autoplay + '"></iframe>');
728				jQuery('#' + player_id).find('iframe').unwrap();
729				var vimeoPlayer = document.getElementById(player_id);
730	            Froogaloop(vimeoPlayer).addEvent('ready', onVimeoPlayerReady);
731            }
732		} else { // All other video types: FLV, MP4, WEBM
733			var videourl_mp4 = false;
734			if (typeof element.attr('data-videourl-mp4') !== 'undefined' && element.attr('data-videourl-mp4') !== false)
735				videourl_mp4 = element.attr('data-videourl-mp4');
736
737			var videourl_mp4_hd = false;
738			if (typeof element.attr('data-videourl-mp4-hd') !== 'undefined' && element.attr('data-videourl-mp4-hd') !== false)
739				videourl_mp4_hd = element.attr('data-videourl-mp4-hd');
740
741			// If is iOS and no MP4 video format is provided stop right here
742			if( isIOS() && !videourl_mp4 && !videourl_mp4_hd ) {
743				return;
744			}
745
746			var videourl_webm;
747			if (typeof element.attr('data-videourl-webm') !== 'undefined' && element.attr('data-videourl-webm') !== false)
748				videourl_webm = element.attr('data-videourl-webm');
749
750			var videourl_webm_hd;
751			if (typeof element.attr('data-videourl-webm-hd') !== 'undefined' && element.attr('data-videourl-webm-hd') !== false)
752				videourl_webm_hd = element.attr('data-videourl-webm-hd');
753
754			var videourl_flv;
755			if (typeof element.attr('data-videourl-flv') !== 'undefined' && element.attr('data-videourl-flv') !== false)
756				videourl_flv = element.attr('data-videourl-flv');
757
758			var videourl_flv_hd;
759			if (typeof element.attr('data-videourl-flv_hd') !== 'undefined' && element.attr('data-videourl-flv_hd') !== false)
760				videourl_flv_hd = element.attr('data-videourl-flv_hd');
761			
762			var video_thumbnail = element.attr('data-video-thumbnail');
763
764			// Create a <video> DOM element 
765			var video = jQuery('<video/>').attr('id', player_id).attr('class', 'sublimevideo').attr('preload', 'none').attr('poster', video_thumbnail);
766
767			// Create the <source> DOM elements
768			if (videourl_mp4) { video.append( jQuery('<source/>').attr('src', videourl_mp4) ); }
769			if (videourl_mp4_hd) { video.append( jQuery('<source/>').attr('src', videourl_mp4_hd).attr('data-quality', 'hd') ); }
770			if (videourl_webm) { video.append( jQuery('<source/>').attr('src', videourl_webm) ); }
771			if (videourl_webm_hd) { video.append( jQuery('<source/>').attr('src', videourl_webm_hd).attr('data-quality', 'hd') ); }
772			if (videourl_flv) { video.append( jQuery('<source/>').attr('src', videourl_flv) ); }
773			if (videourl_flv_hd) { video.append( jQuery('<source/>').attr('src', videourl_flv_hd).attr('data-quality', 'hd') ); }
774
775			element.empty().append(video);
776
777			if(autoplay == 'true') {
778				sublimevideo.prepareAndPlay(player_id); // start the video
779			} else { // else resume the slider
780				sublimevideo.prepare(player_id);
781				slider.cycle('resume');
782			}
783
784			if( slider.parent().hasClass('fullwidth') )	{
785				sublimevideo.resize(player_id, slider.parent().width(), slider.parent().height());
786			} else {
787				if( parent_li.hasClass('with-description') ) {
788					var slider_description = parent_li.find('.slider-description');
789					if(jQuery('body').hasClass('single')) { slider_description.css('width', '0'); } 
790					slider_description.removeClass('width-100');
791					slider_description.addClass('width-0');					
792					sublimevideo.resize(player_id, parent_li.width() - slider_description.outerWidth(), element.height());
793					slider_description.removeClass('width-0');
794					slider_description.addClass('width-100');
795					if(jQuery('body').hasClass('single')) { slider_description.css('width', '100%'); } 
796				} else {
797					sublimevideo.resize(player_id, parent_li.width(), element.height());
798				}
799			}
800
801			sublimevideo.onEnd(function(sv){
802				if( jQuery('#' + sv.element.id).parents('#slider').size() != 0 ) {
803					jQuery('#' + sv.element.id).parents('#slider').cycle('next'); // go to next slider item
804				} else {
805					jQuery('#' + sv.element.id).parents('.slider').cycle('next'); // go to next slider item
806				}
807			});
808
809			sublimevideo.onStart(function(sv){
810				jQuery('.sublimevideo').each(function(){
811					if( jQuery(this).parents('#slider').size() != 0 ) {
812						jQuery(this).parents('#slider').cycle('resume'); // resume the slider until video finishes
813					} else if( jQuery(this).parents('#slider').size() == 0 ) {
814						jQuery(this).parents('.slider').cycle('resume'); // resume the slider until video finishes
815					}
816					sublimevideo.unprepare(jQuery(this));
817				});
818				if( jQuery('#' + sv.element.id).parents('#slider').size() != 0 ) {
819					jQuery('#' + sv.element.id).parents('#slider').cycle('pause'); // pause the slider until video finishes
820				} else {
821					jQuery('#' + sv.element.id).parents('.slider').cycle('pause'); // pause the slider until video finishes
822				}
823			});
824
825		}
826	}
827}
828
829var youTubePlayerLoggers = {}; 
830function onYouTubePlayerReady(event) {
831	var playerId;	
832	if(isIE()) {
833		playerId = event;
834		ytplayer = document.getElementById(playerId); // Get the reference to the video			
835		youTubePlayerLoggers[playerId] = function (state) {
836	        var slider = jQuery('#'+(playerId)).parent().parent().parent();
837			if(state > 0) { // Video as started
838				slider.cycle('pause'); // pause the slider until video finishes
839			} else if(state == 0) { // Video has ended
840				slider.cycle('next'); // go to next slider item
841			}
842	    }; 
843	    ytplayer.addEventListener("onStateChange", "youTubePlayerLoggers."+playerId); 
844
845	    // If autoplay is set, then start the video
846		if(jQuery('#'+playerId).attr('unisphere_autoplay') == 'true') {
847			ytplayer.playVideo(); // start the video
848		} else { // else resume the slider
849			var slider = jQuery('#'+playerId).parent().parent().parent();
850			slider.cycle('resume');
851		}
852	} else {
853		playerId = jQuery(event.target.getVideoEmbedCode()).attr('id');	
854	}
855}
856
857function onYouTubePlayerStateChange(event) {
858	state = event.data;	
859	var slider = jQuery('#'+jQuery(event.target.getVideoEmbedCode()).attr('id')).parent().parent().parent();
860
861	if(state > 0) { // Video as started
862		slider.cycle('pause'); // pause the slider until video finishes
863	} else if(state == 0) { // Video has ended
864		slider.cycle('next'); // go to next slider item
865	}
866}
867
868function onVimeoPlayerReady(playerId) {
869	if(isIE()) {
870		vmplayer = document.getElementById(playerId); // Get the reference to the video			
871		vmplayer.api_addEventListener('onPlay', 'onVimeoPlay'); // add onPlay event listener
872		vmplayer.api_addEventListener('onFinish', 'onVimeoFinish'); // add onFinish event listener	
873	} else {
874		// Keep a reference to Froogaloop for this player
875		var container = document.getElementById(playerId).parentNode.parentNode,
876			froogaloop = Froogaloop(playerId);
877		froogaloop.addEvent('play', onVimeoPlay );
878		froogaloop.addEvent('finish', onVimeoFinish );
879	}
880
881	// If autoplay is set, then start the video and pause the slider
882	if(jQuery('#'+playerId).attr('unisphere_autoplay') == 'true' && !isIOS()) {		
883		if(isIE()) {
884			vmplayer.api_play(); // start the video
885		} else {
886			froogaloop.api('play'); // start the video
887		}
888	} else { // else resume the slider
889		var slider = jQuery('#'+playerId).parent().parent().parent();
890		slider.cycle('resume');
891	}
892}
893
894function onVimeoPlay(playerId) {
895	var slider = jQuery('#'+playerId).parent().parent().parent();
896	slider.cycle('pause'); // pause the slider until video finishes
897}
898
899function onVimeoFinish(playerId) {
900	var slider = jQuery('#'+playerId).parent().parent().parent();
901	slider.cycle('next'); // go to next slider item
902}
903
904/* Extract video id */
905function GetVideoId(url) {
906	var videoId;
907	if(url.match(/(youtube)/)) {
908		videoId = url.replace(/^[^v]+v.(.{11}).*/,"$1"); // Youtube Video
909	} else if(url.match(/(vimeo)/)) {
910		var re = new RegExp('/[0-9]+', "g");
911		var match = re.exec(url);
912		videoId = match[0].substring(1);
913	} else {
914		videoId = false;
915	}
916	return videoId;
917}
918
919function isIE() {
920	if (jQuery.browser.msie) {
921		return true;
922	}
923
924	return false;
925}
926
927function isIOS() {
928	var deviceAgent = navigator.userAgent.toLowerCase();
929	return deviceAgent.match(/(iphone|ipod|ipad)/);
930}
931
932function removeCufon(selector) {
933	jQuery(selector).each(function() {
934		var g = '';
935	 	jQuery(this).find('cufon cufontext').each(function() {
936	 	    g = g + jQuery(this).html();
937	 	}); 
938	 	if( g != '') {
939	 		jQuery(this).html( jQuery.trim(g) );
940	 	}
941	});
942}
943
944function mobileNav() {
945  /* Clone our navigation */
946  var mainNavigation = jQuery('#header .menu').clone();
947
948  /* Add a "select" element to be populated with options, and create a variable to select our new empty option menu */
949  jQuery('#header #menu-bg .mobile-menu').remove();
950  jQuery('#header #menu-bg').append('<select class="mobile-menu"></select>');
951  var selectMenu = jQuery('select.mobile-menu');
952
953  /* Navigate our nav clone for information needed to populate options */
954  jQuery(mainNavigation).children('ul').children('li').each(function() {
955
956     /* Get top-level link and text */
957     var href = jQuery(this).children('a').attr('href');
958     var text = jQuery(this).children('a').text();
959     var isCurrent = ( jQuery(this).hasClass('current_page_item') || jQuery(this).hasClass('current-menu-item') );
960
961     /* Append this option to our "select" */
962     jQuery(selectMenu).append('<option value="'+href+'"'+(isCurrent?'selected="selected"':'')+'>'+text+'</option>');
963
964     /* Check for "children" and navigate for more options if they exist */
965     if (jQuery(this).children('ul').length > 0) {
966        jQuery(this).children('ul').children('li').each(function() {
967
968           /* Get child-level link and text */
969           var href2 = jQuery(this).children('a').attr('href');
970           var text2 = jQuery(this).children('a').text();
971           var isCurrent2 = ( jQuery(this).hasClass('current_page_item') || jQuery(this).hasClass('current-menu-item') );
972
973           /* Append this option to our "select" */
974           jQuery(selectMenu).append('<option value="'+href2+'"'+(isCurrent2?'selected="selected"':'')+'>- '+text2+'</option>');
975
976           	/* Check for "children" and navigate for more options if they exist */
977	        if (jQuery(this).children('ul').length > 0) {
978	            jQuery(this).children('ul').children('li').each(function() {
979
980	               /* Get child-level link and text */
981	               var href3 = jQuery(this).children('a').attr('href');
982	               var text3 = jQuery(this).children('a').text();
983	               var isCurrent3 = ( jQuery(this).hasClass('current_page_item') || jQuery(this).hasClass('current-menu-item') );
984
985	               /* Append this option to our "select" */
986	               jQuery(selectMenu).append('<option value="'+href3+'"'+(isCurrent3?'selected="selected"':'')+'>-- '+text3+'</option>');
987
988	               	/* Check for "children" and navigate for more options if they exist */
989			        if (jQuery(this).children('ul').length > 0) {
990			            jQuery(this).children('ul').children('li').each(function() {
991
992			               /* Get child-level link and text */
993			               var href4 = jQuery(this).children('a').attr('href');
994			               var text4 = jQuery(this).children('a').text();
995			               var isCurrent4 = ( jQuery(this).hasClass('current_page_item') || jQuery(this).hasClass('current-menu-item') );
996
997			               /* Append this option to our "select" */
998			               jQuery(selectMenu).append('<option value="'+href4+'"'+(isCurrent4?'selected="selected"':'')+'>--- '+text4+'</option>');
999			            });
1000			        }
1001	            });
1002	        }
1003        });
1004     }
1005  });
1006
1007   /* When our select menu is changed, change the window location to match the value of the selected option. */
1008   jQuery(selectMenu).change(function() {
1009      location = this.options[this.selectedIndex].value;
1010   });
1011}
1012
1013// Gets called when video needs resizing
1014function resizeSlidersAndVideo() {
1015	// Resize shortcode videos
1016  	jQuery('.sublimevideo').each(function() {
1017  		var slider = jQuery(this).parent().parent().parent();
1018  		var aspectRatio = slider.attr('data-aspect-ratio');
1019  		var newWidth = slider.width();
1020  		sublimevideo.resize(jQuery(this).attr('id'), newWidth, newWidth/aspectRatio);
1021  		slider.css('height', parseInt(newWidth/aspectRatio) + 'px');
1022	});
1023
1024	// Resize slider videos and the slider itself
1025	jQuery('.slider, #slider').each(function() {
1026		var slider = jQuery(this);
1027		var aspectRatio = slider.attr('data-aspect-ratio');			
1028		var newWidth = slider.width();
1029		if( slider.parent().hasClass('fullwidth') ) { newWidth = slider.parent().width(); }
1030		var newheight = parseInt(newWidth/aspectRatio);
1031
1032	   	slider.css('height', newheight + 'px');
1033	   	slider.parent().css('height', newheight + 'px');
1034
1035	   	slider.children('li').each(function(){
1036			jQuery(this).css('width', newWidth + 'px');
1037		});
1038
1039	   	slider.children('li').children('.slider-video').each(function(){
1040			jQuery(this).css('height', newheight + 'px');
1041			if( jQuery(this).attr('data-videotype') == 'html5_flv' ) {
1042	  			var parent_li = jQuery(this).parent();
1043				if( parent_li.hasClass('with-description') && !slider.parent().hasClass('fullwidth') ) {
1044					var slider_description = parent_li.find('.slider-description');
1045					slider_description.removeClass('width-100');
1046					slider_description.addClass('width-0');
1047					sublimevideo.resize('object' + jQuery(this).attr('id'), newWidth - slider_description.outerWidth(), newWidth/aspectRatio);
1048					slider_description.removeClass('width-0');
1049					slider_description.addClass('width-100');
1050				} else {
1051					sublimevideo.resize('object' + jQuery(this).attr('id'), newWidth, newWidth/aspectRatio);
1052				}
1053	  		}
1054		});
1055	});
1056};
1057
1058jQuery(window).load(function() {    
1059
1060	var deviceAgent = navigator.userAgent.toLowerCase();
1061	if( deviceAgent.match(/(iphone|ipod|ipad)/) ) {		
1062		if( jQuery("#full-bg").length == 0 && jQuery('body').css('background-image') != '' && jQuery('body').css('background-repeat') == 'no-repeat' && jQuery('body').css('background-attachment') == 'fixed' ) {
1063			var bgImage = jQuery('body').css('background-image').replace(/"/g,"").replace(/url\(|\)$/ig, "");
1064			jQuery('body').css('background-image', '');
1065
1066			jQuery('<div />', {
1067				id    : 'full-bg-wrapper'
1068			}).append(jQuery('<img />', {
1069					src   : bgImage,
1070					id    : 'full-bg',
1071					alt   : ''
1072			})).prependTo('body');
1073		}
1074	}
1075
1076	var theWindow        = jQuery(window),
1077	    $bg              = jQuery("#full-bg"),
1078	    aspectRatio      = $bg.width() / $bg.height();
1079
1080	function resizeBg() {
1081		if ( (theWindow.width() / theWindow.height()) < aspectRatio ) {
1082		    $bg.removeClass().addClass('full-bg-height');
1083		} else {
1084		    $bg.removeClass().addClass('full-bg-width');
1085		}
1086	}
1087
1088	resizeBg();
1089	
1090	theWindow.resize(function() {
1091		resizeBg();
1092	});
1093});
1094
1095var rtime = new Date(1, 1, 2000, 12,00,00);
1096var timeout = false;
1097var delta = 200;
1098jQuery(window).resize(function() {
1099	// Bind the onresizeend event
1100	rtime = new Date();
1101    if (timeout === false) {
1102        timeout = true;
1103        setTimeout(resizeend, delta);
1104    }
1105
1106    var deviceAgent = navigator.userAgent.toLowerCase();
1107	if( !deviceAgent.match(/(iphone|ipod|ipad)/) ) {
1108		resizeSlidersAndVideo();
1109		SetPortfolioItemHover();		
1110
1111		// Update the Masonry blog script
1112		var _gutterWidth = Math.round(jQuery('.blog-masonry div:first-child').width() * 0.1);
1113		jQuery('.blog-masonry').masonry({
1114	    	itemSelector: '.post, .page, .portfolio_cpt',
1115	    	gutterWidth: _gutterWidth
1116	  	});
1117	}
1118});
1119
1120jQuery(window).bind('orientationchange', function(event){
1121	SetPortfolioItemHover();
1122	resizeSlidersAndVideo();
1123
1124	// Update the Masonry blog script
1125	var _gutterWidth = Math.round(jQuery('.blog-masonry div:first-child').width() * 0.1);
1126	jQuery('.blog-masonry').masonry({
1127    	itemSelector: '.post, .page, .portfolio_cpt',
1128    	gutterWidth: _gutterWidth
1129  	});
1130});
1131
1132function resizeend() {
1133    if (new Date() - rtime < delta) {
1134        setTimeout(resizeend, delta);
1135    } else {
1136        timeout = false;
1137        var deviceAgent = navigator.userAgent.toLowerCase();
1138		if( !deviceAgent.match(/(iphone|ipod|ipad)/) ) {
1139			/* Dropdown menu using superfish */
1140			jQuery('.nav').supersubs({
1141				minWidth: 12,
1142				maxWidth: 25,
1143				extraWidth: 1
1144			}).superfish({
1145				delay: 250,
1146				animation: { opacity: 'show', height: 'show' },
1147				speed: 'fast',
1148				autoArrows: false 
1149			});
1150		}
1151    }               
1152}

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.