// Sliding functionality for tonyleodesign.com by Tony! Leo
var i = 0;
$(document).ready(function() {
	// key stroke navigation
	var $marginLefty = $("#content");
		$(document.documentElement).keyup(function (event) {
		// checks if input or textarea have focus and disables key navigation
		if ( $('input.text:focus,textarea:focus').size() > 0) {
		return false; }
		else {
		  if (event.keyCode == 39) {
		  		if (i == $('.slide').size() - 1) {
		  			i = 0;
		  			$marginLefty.animate({ marginLeft: 0 + 'px' }, 700);
		  		} else {
					i++;
					$marginLefty.animate({ marginLeft: -910 * i + 'px' }, 500);
				}
		  } else if (event.keyCode == 37) {
		  		if (i != 0) {
					i = i-1; }
				$marginLefty.animate({ marginLeft: -910 * i + 'px' }, 500);
		  } }
	});

	// next/previous navigation
	$(".next").click(function() {
		if (i == $('.slide').size() - 1) {
			i = 0;
			$marginLefty.animate({ marginLeft: 0 + 'px' }, 700);
		} else {
			i++;
			$marginLefty.animate({ marginLeft: -910 * i + 'px' }, 500);
		}
	});
	$(".previous").click(function() {
		if (i != 0) {
			i = i-1; }
		$marginLefty.animate({ marginLeft: -910 * i + 'px' }, 500);
	});
});
