﻿var Watermark = {               

    init : function(o, oWM, wmText, wmColor) {                 
        o.oWM = oWM; 
        oWM.o = o;
        
        o.oWM.value = (wmText) ? wmText : "-";          
        o.oWM.style.color = (wmColor) ? wmColor : "#999999";
        
        if (trim(o.value) == "") {
            o.value = "";
            o.style.display = "none";
            
            o.oWM.style.display = "inline";          
        }
        else {
            o.style.display = "inline";          
  
            o.oWM.style.display = "none";        
        }                                                                           
        
        oWM.onfocus = Watermark.focus;
        o.onblur = Watermark.blur;         
    },
    
    focus : function() {        
        var oWM = this;           
          
        oWM.o.style.display = "inline";  
        oWM.o.focus();  
  
        oWM.style.display = "none"; 
    },
    
    blur : function() {
        var o = this;
                
        if (trim(o.value) == "") {
            o.value = "";
            o.style.display = "none";
            
            o.oWM.style.display = "inline";
        }     
    }
};