window.addEvent('domready',function() {
	// Slideshow module. If a slideshow exists on the page, then we'll load up the needed Javascript and process them.
	sliderArr = $$("div.sliderContainer");
	if(sliderArr.length) {
		fileArr = ["/shared/js/Loop.js","/shared/js/Slick.Parser.js",
				   "/shared/js/SlideShow.js","/shared/js/SlideShow.CSS.js",
				   "/shared/js/slideshow_generator.js","/shared/css/slideshow.css"];
		new LoadFiles(fileArr, { "onComplete": renderSlideshows });
	}
	// End of slideshow module.
	 
	if(is_mobile() || is_phablet() || is_portrait_tablet()) {
		if($('navMenu') && $('menu-btn')) {
		    $('navMenu').fade('hide');
		    $('navMenu').setStyle('display','block');
		    $('menu-btn').addEvent('click', function() {
		        this.toggleClass('is-active');
		        $('navMenu').fade('toggle');
		    });
		}
	}
	
});

function renderSlideshows() {
	$$(".sliderContainer").each(function(ele) {
		new SlideGenerator(ele);
	})
}

function is_mobile() {
	if(window.matchMedia) {
		var mq = window.matchMedia( "(max-device-width: 480px) and (orientation:portrait)" ).matches || 
					window.matchMedia( "(max-device-height: 480px) and (orientation:landscape)" ).matches;
		return mq;
	} else
		return false;
}

function is_phablet() {
	if(window.matchMedia) {
		var mq = window.matchMedia( "(min-device-width: 481px) and (max-device-width: 719px) and (orientation: portrait)" ).matches;
		return mq;
	} else
		return false;
}

function is_portrait_tablet() {
	if(window.matchMedia) {
		var mq = window.matchMedia( "(max-device-width: 980px) and (min-device-width: 720px) and (orientation: portrait)" ).matches;
		return mq;
	} else
		return false;
}

function is_tablet() {
	if(window.matchMedia) {
		var mq = window.matchMedia( "(max-device-width: 980px) and (min-device-width: 720px) and (orientation: portrait)" ).matches ||
					window.matchMedia( "(max-device-width: 1024px) and (min-device-width: 720px) and (orientation: landscape)" ).matches;
		return mq;
	} else
		return false;
}