$(document).ready(function() {

	/* New window (add class "blank") */
	$(function(){
	    $('a.blank').click(function(){
	        window.open(this.href);
	        return false;
	    });
	});

		// Prepare page for JavaScript
		$('body').addClass("js");
		$('input.text').attr('value', '');
		$('textarea').text("");
		
		// Hide background
	   	$('input.text, textarea').focus(function(){
			$(this).addClass("focus");
		});
		
		// Show background, unless the field is empty
		$('input.text, textarea').blur(function(){
			if (this.value=="") {
				$(this).removeClass("focus");
			};
		});


		// DO CAROUSEL THING
		
		posit = 0;
		theWidth = 1;
		
		function test(){
			posit = parseInt($("#carousel ul").css("left"), 10);
			x = ulWidth-170
			theWidth = "-"+x;
			// $("#debug").html("position: " + posit + "<br />theWidth: " + theWidth);

		}

		// Work out the width of all the List Items
		countItems = $("#carousel li").size();
		ulWidth = countItems * 170;
		$("#carousel ul").width(ulWidth);
	
			$("#forward").click(function(){
				if (posit != theWidth)  {
					$("#carousel ul").animate({"left": "-=170px"}, "fast", function(){
						test();
					});
				}
			});
				
			$("#back").click(function(){
				if (posit < "0")  {
					$("#carousel ul").animate({"left": "+=170px"}, "fast", function(){
						test();
					});
				}
			})
		
	
});
