function disable_zoom() {
	(function($) {
  $.fn.nodoubletapzoom = function() {
      $(this).bind('touchstart', function preventZoom(e) {
        var t2 = e.timeStamp
          , t1 = $(this).data('lastTouch') || t2
          , dt = t2 - t1
          , fingers = e.originalEvent.touches.length;
        $(this).data('lastTouch', t2);
        if (!dt || dt > 500 || fingers > 1) return; // not double-tap

        e.preventDefault(); // double tap - prevent the zoom
        // also synthesize click events we just swallowed up
        $(this).trigger('click').trigger('click');
      });
  };
})(jQuery);
}

document.addEventListener('gesturestart', function (e) {
    e.preventDefault();
});

document.documentElement.addEventListener('touchstart', function (event) {
    if (event.touches.length > 1) {
        event.preventDefault();
    }
}, false);

// array
array_Sw = [];
array_Sh = [];
array_Sx = [];
array_Sy = [];
console.log("array_Sw", array_Sw);
console.log("array_Sh", array_Sh);
console.log("array_Sx", array_Sx);
console.log("array_Sy", array_Sy);

// var
// dimension du navigateur
var Fw = $(window).outerWidth(true);
var Fh = $(window).outerHeight(true);
// console.log("Fw",Fw);
// console.log("Fh",Fh);

// dimension des div
var $section = $("section > div")
console.log("$section", $section);

for (var i = 0; i < $section.length; i++) {
	var Sw = $section[i].offsetWidth
	var Sh = $section[i].offsetHeight
	// console.log("Sw",Sw);
	// console.log("Sh",Sh);
	array_Sw.push(Sw);
	array_Sh.push(Sh);

	// position des div
	var Sx = $section[i].offsetLeft
	var Sy = $section[i].offsetTop
	// console.log("Sx",Sx);
	// console.log("Sy",Sy);
	array_Sx.push(Sx);
	array_Sy.push(Sy);
}

function grab() {
	$("body").mouseup(function(){
		$("body").css( "cursor","grab");
	}).mousedown(function(){
		$("body").css( "cursor","grabbing");
	});
}

function initStart() {
	var Start = $('#start').offset()
	$(window).animate({ scrollTop: Start.top - ((Fh/2) - (663.333 / 2))}, 0);
	$(window).animate({ scrollLeft: Start.left - ((Fw/2) - (659.633 / 2)) }, 0);
}

function scrollto() {

	array_Y = [];
	array_N = [];
	array_Nxt = [];
	array_Nxt2 = [];

	var $y = $("section > div #y")
	var $n = $("section > div #n")
	var $nxt = $("section > div #next")
	var $nxt2 = $("section > div #next2")

	for (var i = 0; i < $y.length; i++) {
		var Sy = $y[i]
		array_Y.push(Sy);
	}

	for (var i = 0; i < $n.length; i++) {
		var Sn = $n[i]
		array_N.push(Sn);
	}

	for (var i = 0; i < $nxt.length; i++) {
		var Snxt = $nxt[i]
		array_Nxt.push(Snxt);
	}

	for (var i = 0; i < $nxt2.length; i++) {
		var Snxt2 = $nxt2[i]
		array_Nxt2.push(Snxt2);
	}


	console.log("array_Y", array_Y);
	console.log("array_N", array_N);
	console.log("array_Nxt", array_Nxt);
	console.log("array_Nxt2", array_Nxt2);

	// Click yes
	$(array_Y[0]).click(function(){
		var x = array_Sx[1] - ((Fw/2) - (array_Sw[1]/2));
		var y = array_Sy[1] - ((Fh/2) - (array_Sh[1]/2));
		$(window).scrollTo({top:y, left:x	},800);
	});

	$(array_Y[1]).click(function(){
		var x1 = array_Sx[2] - ((Fw/2) - (array_Sw[2]/2));
		var y1 = array_Sy[2] - ((Fh/2) - (array_Sh[2]/2));
		$(window).scrollTo({top:y1, left:x1}, 800);
	});

	$(array_Y[2]).click(function(){
		var x1 = array_Sx[6] - ((Fw/2) - (array_Sw[6]/2));
		var y1 = array_Sy[6] - ((Fh/2) - (array_Sh[6]/2));
		$(window).scrollTo({top:y1, left:x1}, 800);
	});

	$(array_Y[3]).click(function(){
		var x1 = array_Sx[7] - ((Fw/2) - (array_Sw[7]/2));
		var y1 = array_Sy[7] - ((Fh/2) - (array_Sh[7]/2));
		$(window).scrollTo({top:y1, left:x1}, 800);
	});

	$(array_Y[4]).click(function(){
		var x1 = array_Sx[10] - ((Fw/2) - (array_Sw[10]/2));
		var y1 = array_Sy[10] - ((Fh/2) - (array_Sh[10]/2));
		$(window).scrollTo({top:y1, left:x1}, 800);
	});

	$(array_Y[5]).click(function(){
		var x1 = array_Sx[11] - ((Fw/2) - (array_Sw[11]/2));
		var y1 = array_Sy[11] - ((Fh/2) - (array_Sh[11]/2));
		$(window).scrollTo({top:y1, left:x1}, 800);
	});

	$(array_Y[6]).click(function(){
		var x1 = array_Sx[16] - ((Fw/2) - (array_Sw[16]/2));
		var y1 = array_Sy[16] - ((Fh/2) - (array_Sh[16]/2));
		$(window).scrollTo({top:y1, left:x1}, 800);
	});

	$(array_Y[7]).click(function(){
		var x1 = array_Sx[15] - ((Fw/2) - (array_Sw[15]/2));
		var y1 = array_Sy[15] - ((Fh/2) - (array_Sh[15]/2));
		$(window).scrollTo({top:y1, left:x1}, 800);
	});

	$(array_Y[8]).click(function(){
		var x1 = array_Sx[16] - ((Fw/2) - (array_Sw[16]/2));
		var y1 = array_Sy[16] - ((Fh/2) - (array_Sh[16]/2));
		$(window).scrollTo({top:y1, left:x1}, 800);
	});

	// click Non
	$(array_N[0]).click(function(){
		var x = array_Sx[16] - ((Fw/2) - (array_Sw[16]/2));
		var y = array_Sy[16] - ((Fh/2) - (array_Sh[16]/2));
		$(window).scrollTo({top:y, left:x}, 800);
	});

	$(array_N[1]).click(function(){
		var x1 = array_Sx[3] - ((Fw/2) - (array_Sw[3]/2));
		var y1 = array_Sy[3] - ((Fh/2) - (array_Sh[3]/2));
		$(window).scrollTo({top:y1, left:x1}, 800);
	});

	$(array_N[2]).click(function(){
		var x1 = array_Sx[5] - ((Fw/2) - (array_Sw[5]/2));
		var y1 = array_Sy[5] - ((Fh/2) - (array_Sh[5]/2));
		$(window).scrollTo({top:y1, left:x1}, 800);
	});

	$(array_N[3]).click(function(){
		var x1 = array_Sx[8] - ((Fw/2) - (array_Sw[8]/2));
		var y1 = array_Sy[8] - ((Fh/2) - (array_Sh[8]/2));
		$(window).scrollTo({top:y1, left:x1}, 800);
	});

	$(array_N[4]).click(function(){
		var x1 = array_Sx[9] - ((Fw/2) - (array_Sw[9]/2));
		var y1 = array_Sy[9] - ((Fh/2) - (array_Sh[9]/2));
		$(window).scrollTo({top:y1, left:x1}, 800);
	});

	$(array_N[5]).click(function(){
		var x1 = array_Sx[12] - ((Fw/2) - (array_Sw[12]/2));
		var y1 = array_Sy[12] - ((Fh/2) - (array_Sh[12]/2));
		$(window).scrollTo({top:y1, left:x1}, 800);
	});

	$(array_N[6]).click(function(){
		var x1 = array_Sx[14] - ((Fw/2) - (array_Sw[14]/2));
		var y1 = array_Sy[14] - ((Fh/2) - (array_Sh[14]/2));
		$(window).scrollTo({top:y1, left:x1}, 800);
	});

	$(array_N[7]).click(function(){
		var x1 = array_Sx[13] - ((Fw/2) - (array_Sw[13]/2));
		var y1 = array_Sy[13] - ((Fh/2) - (array_Sh[13]/2));
		$(window).scrollTo({top:y1, left:x1}, 800);
	});

	$(array_N[8]).click(function(){
		var x1 = array_Sx[14] - ((Fw/2) - (array_Sw[14]/2));
		var y1 = array_Sy[14] - ((Fh/2) - (array_Sh[14]/2));
		$(window).scrollTo({top:y1, left:x1}, 800);
	});


		// click next
		$(array_Nxt[0]).click(function(){
			var x = array_Sx[4] - ((Fw/2) - (array_Sw[4]/2));
			var y = array_Sy[4] - ((Fh/2) - (array_Sh[4]/2));
			$(window).scrollTo({top:y, left:x	},800);
		});

		$(array_Nxt[1]).click(function(){
			var x = array_Sx[4] - ((Fw/2) - (array_Sw[4]/2));
			var y = array_Sy[4] - ((Fh/2) - (array_Sh[4]/2));
			$(window).scrollTo({top:y, left:x	},800);
		});

		$(array_Nxt[2]).click(function(){
			var x = array_Sx[4] - ((Fw/2) - (array_Sw[4]/2));
			var y = array_Sy[4] - ((Fh/2) - (array_Sh[4]/2));
			$(window).scrollTo({top:y, left:x	},800);
		});

		$(array_Nxt[3]).click(function(){
			var x = array_Sx[16] - ((Fw/2) - (array_Sw[16]/2));
			var y = array_Sy[16] - ((Fh/2) - (array_Sh[16]/2));
			$(window).scrollTo({top:y, left:x	},800);
		});

		$(array_Nxt[4]).click(function(){
			var x = array_Sx[10] - ((Fw/2) - (array_Sw[10]/2));
			var y = array_Sy[10] - ((Fh/2) - (array_Sh[10]/2));
			$(window).scrollTo({top:y, left:x	},800);
		});

		$(array_Nxt[5]).click(function(){
			var x = array_Sx[12] - ((Fw/2) - (array_Sw[12]/2));
			var y = array_Sy[12] - ((Fh/2) - (array_Sh[12]/2));
			$(window).scrollTo({top:y, left:x	},800);
		});

		$(array_Nxt[6]).click(function(){
			var x = array_Sx[15] - ((Fw/2) - (array_Sw[15]/2));
			var y = array_Sy[15] - ((Fh/2) - (array_Sh[15]/2));
			$(window).scrollTo({top:y, left:x	},800);
		});

		// click next2
		$(array_Nxt2[0]).click(function(){
			var x = array_Sx[11] - ((Fw/2) - (array_Sw[11]/2));
			var y = array_Sy[11] - ((Fh/2) - (array_Sh[11]/2));
			$(window).scrollTo({top:y, left:x	},800);
		});

}

jQuery(document).ready(function($) {
	disable_zoom();
	grab();
	initStart();
	scrollto();
});
