

$(document).ready(function(){
						   
	  // Set up the hand for rotation starting at 0 degrees
	var $elie = $('#hand'), degree = 0, timer;
	  // Set up downward rotation function for hand
	function rotate() {
		  // For webkit browsers: e.g. Chrome
		$elie.css({ WebkitTransform: 'rotate(' + degree + 'deg)'});
		  // For Mozilla browser: e.g. Firefox
		$elie.css({ '-moz-transform': 'rotate(' + degree + 'deg)'});

		  // Animate rotation with a recursive call
		timer = setTimeout(function() {
			if ( degree == 0 || degree > -15 ) {
				--degree; rotate();
			}
		},5);
	}
	// Set up upward rotation function for hand
	function rotateback() {
		  // For webkit browsers: e.g. Chrome
		$elie.css({ WebkitTransform: 'rotate(' + degree + 'deg)'});
		  // For Mozilla browser: e.g. Firefox
		$elie.css({ '-moz-transform': 'rotate(' + degree + 'deg)'});

		  // Animate rotation with a recursive call
		timer = setTimeout(function() {
			if ( degree == -15 || degree != 0 ) {
				++degree; rotateback();
			}
		},5);
	}	
	  // On hover rotate hand down, on mouseout rotate back to normal
	$('#hand').hover(
		function(){
			rotate();
		},
		function(){
			rotateback();
		}
	);
	
	
	
	  // Set up Coin Bumps for rotation
	var $bumps = $('#coin-bumps'), coindegree = 0, timercoins;
	function rotateCoin() {

		  // For webkit browsers: e.g. Chrome
		$bumps.css({ WebkitTransform: 'rotate(' + coindegree + 'deg)'});
		  // For Mozilla browser: e.g. Firefox
		$bumps.css({ '-moz-transform': 'rotate(' + coindegree + 'deg)'});

		  // Animate rotation with a recursive call
		timercoins = setTimeout(function() {
			if ( coindegree < 360 ) {
				++coindegree; rotateCoin();
			} else {
				coindegree = 0
			}
		},5);
	}
	
	  // Rotate coin bumps when user clicks either blue arrow
	$('#looksy, #price').click(function() {
		rotateCoin();
	});



	  // Preload image hover states for artists
	jQuery.preLoadImages("images/names-jerszy.png", "images/names-ken.png", "images/names-ian.png", "images/names-natalie.png");
	  // Set hover states for artists
	
	$('#ken').hover(
		function() {
			$('#including').attr('src','images/names-ken.png');
		},
		function() {
			$('#including').attr('src','images/names.png');
		}
	);
	$('#jerszy').hover(
		function() {
			$('#including').attr('src','images/names-jerszy.png');
		},
		function() {
			$('#including').attr('src','images/names.png');
		}
	);
	$('#ian').hover(
		function() {
			$('#including').attr('src','images/names-ian.png');
		},
		function() {
			$('#rethincludingink').attr('src','images/names.png');
		}
	);
	$('#natalie').hover(
		function() {
			$('#including').attr('src','images/names-natalie.png');
		},
		function() {
			$('#including').attr('src','images/names.png');
		}
	);


	  // Slide out about info when banner is clicked
	$('#about-img').toggle(function() {
		$('#about-pennysmash').show(1, function() {
			$('#about').animate({
				left: '+16'
			}, 500 );
		});
	}, function() {
		$('#about').animate({
			left: '-325'
		}, 500, function() {
			$('#about-pennysmash').hide(1);
		});
	});


	  // Set up transitions to show artist bios
	$('#ken').click(function() {
		$('.bio').not('#ken-bio').animate({
			top: '763'
		}, 'fast' );
		$('#ken-bio').animate({
			top: '60'
		}, 'slow' );
	});
	$('#jerszy').click(function() {
		$('.bio').not('#jerszy-bio').animate({
			top: '763'
		}, 'fast' );
		$('#jerszy-bio').animate({
			top: '62'
		}, 'slow' );
	});
	$('#ian').click(function() {
		$('.bio').not('#ian-bio').animate({
			top: '763'
		}, 'fast' );
		$('#ian-bio').animate({
			top: '105'
		}, 'slow' );
	});
	$('#natalie').click(function() {
		$('.bio').not('#natalie-bio').animate({
			top: '763'
		}, 'fast' );
		$('#natalie-bio').animate({
			top: '45'
		}, 'slow' );
	});
	$('.close').click(function(){
		$('.bio').animate({
			top: '763'
		}, 'fast' );
	});
	
	
});
