$(document).ready(function()
{
	$(".authlabel").click(function()
	{
		$(this).hide();
		fi = document.getElementById($(this).attr("forfield")+"Input");
		fi.focus();
	});

	$("INPUT.txt").focus(function()
	{
		$(this).toggleClass("focused");
		if (!$(this).val())
			$("#"+$(this).attr("name")+"Label").hide();

	});

	$("INPUT.txt").blur(function()
	{
		$(this).toggleClass("focused");
		if (!$(this).val())
			$("#"+$(this).attr("name")+"Label").show();
	});

	$("#keep_signedLabel").click(function()
	{
		$("#"+$(this).attr("forfield")+"Input").click();
	});
	
	$("#loginForm").submit(function(event)
	{
		event.preventDefault();
		
		var submit = true;
		var fields =  ["loginInput","passwordInput"];
		for (var f in fields)
			if (!$("#"+fields[f]).val())
			{
				document.getElementById(fields[f]).focus();
				submit = false;
				break;
			}
		
		if (submit)
		{
			$("IMG.spinner").show();
			$("INPUT").addClass("disabled");
			
			$(this).unbind("submit");
			$(this).submit();
		}
	});
	
	checkInput();
});

function checkInput()
{
	$("INPUT.txt").each(function()
	{
		if ($(this).val())
			$("#"+$(this).attr("name")+"Label").hide();
	});
}