var bwLimit = 70; // kb/s
var bgImg = basePath + "media/img/bg.jpg";
var fallbackImg = basePath + "media/img/fallback.jpg";

/*
 * check user bandwidth
 */

$(document).ready(function() {    
    getUserBandwidth( function(time, bandwidth) {
    	// low bandwidth?
    	if(bandwidth < bwLimit) {
    		// set background image
    		$("#canvas360").css("background", "url('" + bgImg + "')");
    		// fade fallback image in
    		$("<div/>", {"class":"image360"}).css({
    			"background": "url('" + fallbackImg + "')"
    		}).hide().appendTo("#canvas360").fadeIn(800);
    	}
    	else {
    		// set background image and load 360° animation
    		$("#canvas360").css("background", "url('" + bgImg + "')");
    		$.getScript(basePath + "js/anim360.js", function() {
    			$("#canvas360").canvas360(basePath + xmlFile);
    		});
    	}
    });
});

/*
 * prevent moving the body on mobile devices
 */

if( navigator.userAgent.match(/(iPhone|iPod|iPad|Android|BlackBerry)/) )
{
	window.addEventListener("load", function() {
	    document.getElementById("canvas360").ontouchmove = function(e) {
	        e.preventDefault();
	    };
	}, false);
}

