$(document).ready(function(){
	
	//drop-down menu code
	$("li.flevel").bind("mouseenter",function(){
		$(this).find("ul").slideDown(150);
		$(this).addClass("nav-current");
	}).bind("mouseleave",function(){
		$(this).find("ul").slideUp(150);
		$(this).removeClass("nav-current");
	});
	
	
	//automatically clear that search form
	$(".autodel").focus(function() {
		if($(this).val() == "enter keywords here") { $(this).val("");}
	});
	
	$(".autodel").blur(function() {
		if($(this).val() == "") { $(this).val("enter keywords here");}
	});
	
	$("#header").click(function(){
		window.location = headerURL;
	});
	
	$("#author").focus(function() {		if($(this).val() == "Name") { $(this).val("");}							});
	$("#email").focus(function() {		if($(this).val() == "Email (hidden)") { $(this).val("");}		});
	$("#url").focus(function() {			if($(this).val() == "Website URL") { $(this).val("");}			});
	$("#comment").focus(function() {	if($(this).val() == "Write a comment?") { $(this).val("");}	});
	
	$("#author").blur(function() {	if($(this).val() == "") { $(this).val("Name");}							});
	$("#email").blur(function() {		if($(this).val() == "") { $(this).val("Email (hidden)");}		});
	$("#url").blur(function() {			if($(this).val() == "") { $(this).val("Website URL");}			});
	$("#comment").blur(function() {	if($(this).val() == "") { $(this).val("Write a comment?");}	});
	
	//form validation baby!
	$("#commentform").submit(function() {
		//check if fields are blank or default value
		if($("#author").val() == "" || $("#author").val() == "Name") {
			$("#author").addClass("error");
		} else {
			$("#author").removeClass("error");
		}
		
		if($("#email").val() == "" || $("#email").val() == "Email (hidden)") {
			$("#email").addClass("error");
		} else {
			$("#email").removeClass("error");
		}
		
		if($("#comment").val() == "" || $("#comment").val() == "Write a comment?") {
			$("#comment").addClass("error");
		} else {
			$("#comment").removeClass("error");
		}
			
		if($("#author").val() == "" || $("#author").val() == "Name" ||
			$("#email").val() == "" || $("#email").val() == "Email (hidden)" ||
			$("#comment").val() == "" || $("#comment").val() == "Write a comment?"
		) {
			$(".comment-msg").slideDown();
			return false;
		} else {
			$(".comment-msg").hide();
			if($("#url").val() == "" || $("#url").val() == "Website URL") { $("#url").val("");}
			$(this).submit();
			return false;
		}
	});
	
	if($(".content-wrap").height() < $(".side-wrap").height()) {
		$(".content-wrap").height($(".side-wrap").height());
	} else {
		$(".side-wrap").height($(".content-wrap").height());
	}
	
	if(screen.height > $(document).height()) {
		//alert($(".content-wide").height());
		$(".content-wide").height($(".content-wide").height() + screen.height - $(document).height() - 20);
		//alert($(".content-wide").height());
	}
});