﻿/* Contains a set of UTILS for mnipulationg UI controls using prototype */
var ContegroUIUtilsClass = Class.create({

    makeTextboxLabelInLine: function(textboxElement, labelElement) {
        
        var textbox = prototypeJs(textboxElement);
        var label = prototypeJs(labelElement);
        var inlineTextbox = textbox.clone();

        inlineTextbox.id = textbox.id + "_inlinelabel";
        inlineTextbox.name = textbox.name + "_inlinelabel";
        inlineTextbox.addClassName("InlineLabel");
        inlineTextbox.value = label.innerHTML;

        if(textbox.type.toLowerCase() == 'password') inlineTextbox.type = 'text';

        label.hide();
        textbox.insert({ after: inlineTextbox });
        if (textbox.value.length == 0)
            textbox.hide();
        else
            inlineTextbox.hide();

        inlineTextbox.observe("focus", function() {
            inlineTextbox.hide();
            textbox.show();
            textbox.focus();
        });

        textbox.observe("blur", function() {
            if (textbox.value.length == 0) {
                inlineTextbox.show();
                textbox.hide();
            }
        });
    }
});


var ContegroUIUtils = new ContegroUIUtilsClass();
