//fadeInImages();
$(document).ready(function(){

$("#fade_in1").css('opacity', 0).animate({'opacity': 1}, 2500); 
$("#fade_in2").css('opacity', 0).animate({'opacity': 1}, 5500); 
$("#fade_in3").css('opacity', 0).animate({'opacity': 1}, 6500); 

    if($("#featured-info").length) {

        $("#featured-info .colA .fade").innerfade({
			speed: "5000",
			timeout: "5000"
		});
		colB = setTimeout(function() {
			$("#featured-info .colB .fade").innerfade({
				speed: "5000",
				timeout: "5000"
			});
		}, 2000);
		colC = setTimeout(function() {
			$("#featured-info .colC .fade").innerfade({
				speed: "5000",
				timeout: "5000"
			});
		}, 4000);
	}
	
	$("#clientLogin").click(function(){
		if($("#loginLayer").is(":visible")){
			$("#loginLayer").fadeOut("slow");
		} else {
			$("#loginLayer").fadeIn("slow");
		}
	});
	
	$("#go").click(function(){
		if($("#username").val() == "") {
			alert("Please enter a username");
		} else {
			$("#go").attr("disabled", "disabled");
			var hash = { userName: $("#username").val() };
			$.post("/ajax/checkUsername.php", hash, function(data){
				if (data.error !== undefined) {
					$("#go").removeAttr("disabled");
					alert(data.error);
				} else {
					/* This will need to be vetted so that we're not going to redirect anywhere we shouldn't. */
					$("#go").removeAttr("disabled");
					var directory = data.directory;
					location.href = directory;
				}
			}
			, "json");
		}
	});

});
