;(function($, window) {
	/** Settings **/

		// List of background images to use, the default image will be the first one in the list
	var backgrounds = [
	    'images/isolanding.jpg'
	],
	
	// Background options - see documentation
	backgroundOptions = {
		 speedOut: 0,
    sync: false

	};
	
	/** End settings **/
	
	$('html').addClass('js-enabled');
		
	$(document).ready(function() {
		$.fullscreen(
			$.extend(backgroundOptions, {
				backgrounds: window.backgrounds || backgrounds,
				backgroundIndex: window.backgroundIndex
			})
		);

		// Accordion
		$('#accordion').accordion({
			autoHeight: false
		});
		
		// Testimonials
		if ($('#testimonials').length) {
			$('#testimonials').cycle({
				fx: 'fade',
				timeout: 6000,
				cleartype: true, cleartypeNoBg: true
			});
		}
		
		// Bind any links with the class 'scroll-top' to animate the scroll to the top
		var scrollElement = 'html, body';
		$('html, body').each(function () {
			var seDomElement = $(this)[0];
		    var initScrollTop = seDomElement.scrollTop;
		    
		    seDomElement.scrollTop = initScrollTop + 1;
		    if (seDomElement.scrollTop == initScrollTop + 1) {
		        scrollElement = this.nodeName.toLowerCase();
		        seDomElement.scrollTop = initScrollTop;
		        return false;
		    }    
		});
		
		$('a.scroll-top').click(function () {			
			if ($(scrollElement).scrollTop() > 0) {
				$(scrollElement).animate({ scrollTop: 0 }, 1000);
			}			
			return false;
		});
		
		// Open links with class popup-link in new window
		$('a.popup-link').click(function() {
			var href = $(this).attr('href');
			if (href.length > 0) {
				window.open(href);
			}
			return false;
		});
		
	}); // End (document).ready
		
	// Any images to preload
	window.preload([
        'images/nav-a-bg1.png',
 		'images/go-to-top1.png',
 		'images/minimise1.png',
		'images/sub-a-hover.png',
		'images/sub-a-hover-warrow.png',
 		'images/2-col-hover.png',
 		'images/3-col-hover.png',
 		'images/4-col-hover.png',
 		'images/5-col-hover.png',
 		'images/6-col-hover.png',
 		'images/grid-hover.png',
		'images/pop-up-h2-bg.png',
		'images/pop-up-rep.png',
		'images/opacity-60-rep.png',
 		'images/opacity-80-rep.png',
 		'images/horz-content-nav-bg2.png',
 		'images/go-to-top1.png',
 		'images/vert-nav-bg.png',
		'images/sub-a-hover-warrow.png',
		'images/sub-a-hover.png',
 		
	]);
})(jQuery, window);
