$(document).ready(function(){
	$("a#prevPic").hover(function () {
		$("#prevNavHint").fadeIn(200);
	}, function() {
		$("#prevNavHint").fadeOut(200);
	});
	$("a#nextPic").hover(function () {
		$("#nextNavHint").fadeIn(200);
	}, function() {
		$("#nextNavHint").fadeOut(200);
	});

	var navhandler = function (e) {
		var nav;
		if (e.which == 39 || e.which == 34 || e.which == 32) {
			nav = $("#nextPic");
		} else if (e.which == 37 || e.which == 33 || e.which == 8) {
			nav = $("#prevPic");
		}
		if (nav && nav.length > 0) {
			window.location.href = nav.get(0).href;
			e.preventDefault();
		}
	}
	
	$(document).bind("keydown", navhandler);

	$("input#username").focus(function (e) {
		$(document).unbind("keydown", navhandler);
	});

	$("input#username").blur(function (e) {
		$(document).bind("keydown", navhandler);
	});

	$("input#password").focus(function (e) {
		$(document).unbind("keydown", navhandler);
	});

	$("input#password").blur(function (e) {
		$(document).bind("keydown", navhandler);
	});


	$("input#commentName").focus(function (e) {
		$(document).unbind("keydown", navhandler);
	});

	$("input#commentName").blur(function (e) {
		$(document).bind("keydown", navhandler);
	});


	$("textarea#commentText").focus(function (e) {
		$(document).unbind("keydown", navhandler);
	});

	$("textarea#commentText").blur(function (e) {
		$(document).bind("keydown", navhandler);
	});

});
