function labelTrick()
{
	var labels = document.getElementsByTagName("label");

	if (labels)
	{
		for (var i = 0; i < labels.length; i++)
		{
			if (labels[i].getAttribute("class") == "inside")
			{
				var labelFor = labels[i].getAttribute("for");
				var inputTag = document.getElementById(labelFor);
				var labelText = labels[i].firstChild.nodeValue;
				var labelColor, inputColor;
	      if (document.defaultView.getComputedStyle)
	      {
	      	labelColor = document.defaultView.getComputedStyle(labels[i], null).getPropertyValue("color");
	     		inputColor = document.defaultView.getComputedStyle(inputTag, null).getPropertyValue("color");
	      }
	      else if (labels[i].currentStyle)
	      {
	      	labelColor = labels[i].currentStyle.color;
	      	inputColor = inputTag.currentStyle.color;
	      }
				// Change the "value," or what is display inside
				// the input tag to the label's text
				inputTag.value = labelText;
				// Change the label color
				inputTag.style.color = labelColor;
				
				// Hide the label tag
				labels[i].style.display = "none";
				// Make the event handlers
				inputTag.onfocus = makeFocus(labelText, inputColor);
				inputTag.onblur = makeBlur(labelText, labelColor);
			}
		}

		var currentNode = labels[0].parentNode;

		while (currentNode.tagName != "FORM")
		{
			currentNode = currentNode.parentNode;
		}

		currentNode.onsubmit = function()
		{
			for (var i = 0; i < labels.length; i++)
			{
				var labelFor = labels[i].getAttribute("for");
				var inputTag = document.getElementById(labelFor);

				if (inputTag.value == labels[i].firstChild.nodeValue)
				{
					inputTag.value = "";
				}
			}
		}
	}
}

function makeFocus(labelText, changeColor)
{
	return function()
	{
		if (this.value == labelText)
		{
			this.value = "";
			this.style.color = changeColor;
		}
	}
}

function makeBlur(labelText, changeColor)
{
	return function ()
	{
		if (this.value == "")
		{
			this.value = labelText;
			this.style.color = changeColor;
		}
	}
}