
function getElementsByClassName(className, tag, elm)
{
    var testClass = new RegExp("(^|\\s)" + className + "(\\s|$)");
    var tag = tag || "*";
    var elm = elm || document;
    var elements = (tag == "*" && elm.all)? elm.all : elm.getElementsByTagName(tag);
    var returnElements = [];
    var current;
    var length = elements.length;
    for(var i=0; i<length; i++){
        current = elements[i];
        if(testClass.test(current.className)){
            returnElements.push(current);
        }
    }

    return returnElements;
}

function inputHelper()
{
    var aInputs = getElementsByClassName("input_helper", "input");
    
    if (aInputs) {
        for(var i = 0; i < aInputs.length; i++) {
            var input      = aInputs[i];
            var properties = input.getAttribute("title").split(':');

            if (!input.value.length) { 
                input.value = properties[1];
            }
            
            input.setAttribute("title", properties[1]);

            if (properties[0] == "password") {
                var input_value = document.getElementById(input.getAttribute("id") + "_value");
                
                input.onfocus=function(i, v)
                              {
                                  return function(e) {
                                      i.style.display = "none";
                                      v.style.display = "";
                                      v.focus();  
                                  }
                                  
                              }(input, input_value);
           
                input_value.onblur=function(i, v)
                                   {
                                       return function(e) {
                                           if (v.value.length == 0) {
                                               i.style.display = "";
                                               v.style.display = "none";
                                           }   
                                       }
                                       
                                   }(input, input_value);
                                   
            } else if (properties[0] == "text") {
                input.onfocus=function(i, p) 
                              {
                                  return function(e) {
                                      if (i.value == p[1]) {
                                          i.value = "";
                                      }
                                  }
                              }(input, properties);
                  
                input.onblur=function(i, p)
                             {
                                 return function(e) {
                                     if (i.value.length == 0) {
                                         i.value = p[1];
                                     }
                                 }
                             }(input, properties);
            }
        }
    }
}