var lbMobileSite;							// has mobile site design
var lbMobile;								// is mobile
var lbDevice;								// device type
var lbScreenSizeWidth;						// screen size width
var lbScreenSizeHeight;						// screen size height
var lbOrientation;							// mobile orientation
var lbAssetSize;							// image asset size
var lbVideoSize;							// video asset size

// check if mobile is being used
if ((navigator.userAgent.indexOf("iPhone") != -1) || (navigator.userAgent.indexOf("iPod") != -1) || (navigator.userAgent.indexOf("iPad") != -1) || (navigator.userAgent.indexOf("Android") != -1) || (navigator.userAgent.indexOf("Blackberry") != -1) || (navigator.userAgent.indexOf("Playbook") != -1)) {
	lbMobile = true;
} else {
	lbMobile = false;
}

// set the device and image sizes for mobile if there is a mobile optimized site
if (lbMobileSite == true) {
	if ((navigator.userAgent.indexOf("iPhone") != -1) || (navigator.userAgent.indexOf("iPod") != -1)) {
		lbDevice = 'iPhone';
		lbAssetSize = 'mm_';
		lbVideoSize = 'ios_';
	} else if (navigator.userAgent.indexOf("iPad") != -1) {
		lbDevice = 'iPad';
		lbAssetSize = 'ml_';
		lbVideoSize = 'ios_';
	} else if (navigator.userAgent.indexOf("Android") != -1) {
		lbDevice = 'Android';
		lbAssetSize = 'mm_';
		lbVideoSize = 'ios_';
	} else if (navigator.userAgent.indexOf("BlackBerry") != -1) {
		lbDevice = 'Blackberry';
		lbAssetSize = 'ms_';
		lbVideoSize = 'ios_';
	} else if (navigator.userAgent.indexOf("PlayBook") != -1) {
		lbDevice = 'Playbook';
		lbAssetSize = 'ml_';
		lbVideoSize = 'ios_';
	} else {
		lbDevice = 'desktop';
	}
} else {
	lbDevice = 'desktop';
}

// if mobile detect whether device supports orientationchange event, otherwise fall back to the resize event.
// check for current orientation
if (lbMobile == true) {
	var supportsOrientationChange = "onorientationchange" in window,
	    orientationEvent = supportsOrientationChange ? "orientationchange" : "resize";
	// on load
	$(window).load(orientationEvent, function() {
		lbOrientation = window.orientation;
		lbScreenSizeWidth = screen.width;
		lbScreenSizeHeight = screen.height;
	}, false);
	// on change
	window.addEventListener(orientationEvent, function() {
		lbOrientation = window.orientation;
		lbScreenSizeWidth = screen.width;
		lbScreenSizeHeight = screen.height;
//		resizeSlideshow();
	}, false);
}

// if desktop check for screen width/height to optimize the experience for the user
if (lbDevice == 'desktop') {
	if (screen.width <= 1024) {
		lbAssetSize = 'gm_';
	} else if (screen.width <= 1440) {
		lbAssetSize = 'gm_';
	} else if (screen.width <= 1680) {
		lbAssetSize = 'gl_';
	} else if (screen.width <= 1920) {
		lbAssetSize = 'gxl_';
	} else if (screen.width <= 2560) {
		lbAssetSize = 'gxxl_';
	}
	lbVideoSize = 'video_';
}

$(function() {
	// hide iOS addressbar on page load
	if (lbDevice == 'iPhone' || lbDevice == 'iPod') {
		window.addEventListener('load', function() {
			setTimeout(function() {
				window.scrollTo(0, 1)
			}, 0);
		});
	}
});

/*//////////////////////////////
Resolution and Devices

320×240 - Blackberry Devices: Curve 8530, Pearl Flip, Android Devices: Motorola Charm, Sony Ericsson Xperia X10 Mini, others, Symbian OS Devices: Nokia E63, others
320×480 - Apple OS Devices: iPhone, iPod, Android devices: HTC Dream, HTC Hero, Droid Pro, i7500 Galaxy, Samsung Moment, others…
480×360 - Blackberry Devices: Torch, Storm, Bold
360×640 - Symbian OS Devices: Nokia N8, Nokia C6-01, others
480×800 - Android Devices: Liquid A1, HTC Desire, Nexus One, i9000 Galaxy S, others, Maemo (Linux) Devices: Nokia 900, others, Windows Mobile 6 Devices: Sharp S01SH, Windows 7 Phone Devices Venue Pro, Samsung Omnia 7, HTC 7 Pro, others
768×1024 - iPad
640×960 - iPhone 4
1280×800 - Android Devices: Motorola Xoom, Samsung Galaxy Tab 10.1, Windows OS Devices: Asus Eee Pad EP121, Apple OS Devices: Axiotron Modbook
/////////////////////////////*/
