function initFocus()
{
    var inputs = document.getElementsByTagName("input");
    var labels = document.getElementsByTagName("label");
    for (var i=0; i<inputs.length; i++)
    {
        if (inputs[i].type == "radio" || inputs[i].type == "checkbox")
        {
            inputs[i].onclick = function ()
            {
                for (var j=0; j<labels.length; j++)
                {
                    if(labels[j].htmlFor != "")
                    {
                        var label = document.getElementById(labels[j].htmlFor);
                        if(this.id == labels[j].htmlFor)
                        {
                            if(labels[j].className.indexOf("focus") == -1)
                                labels[j].className += " focus";
                            else if(this.type != "radio")
                                labels[j].className = labels[j].className.replace("focus", "");
                        }
                        else if(this.type == "radio" && label && this.name == label.name)
                            labels[j].className = labels[j].className.replace("focus", "");
                    }
                }
            }
            if(inputs[i].checked == true)
            {
                for (var j=0; j<labels.length; j++)
                {
                    if(labels[j].htmlFor != "")
                    {
                        if(inputs[i].id == labels[j].htmlFor)
                            labels[j].className += " focus";
                    }
                }
            }
        }
    }
	var arr = new Array("input", "textarea")
    for (var j=0; j<arr.length; j++)
    {
        var inputs = document.getElementsByTagName(arr[j]);
        for (var i=0; i<inputs.length; i++)
        {
            inputs[i].onfocus = function ()
            {
                this.parentNode.className += " focus";
                removeText(this);
            }
            inputs[i].onblur = function ()
            {
                this.parentNode.className = this.parentNode.className.replace("focus", "");
                addText(this);
            }
        }
    }
}
if (window.addEventListener)
    window.addEventListener("load", initFocus, false);
else if (window.attachEvent)
    window.attachEvent("onload", initFocus);

