var PlaceHolder = Class.create({
	initialize: function(inputId , text) {
		this.message  = text;
        this.inputText = $(inputId);
        this.originalInput = null;
        this.newInput = null;
        this.originalType = this.inputText.type; //for the password inputs
        
        if (this.originalType == 'password') {
	        if (Prototype.Browser.IE) {
	        	this.originalInput = this.inputText;
	        	var newInput = new Element('input', {'id': this.inputText.id, 'type': 'text'});
	        	if (this.inputText.name != null) newInput.name = this.inputText.name;
	        	if (this.inputText.className != null) newInput.className = this.inputText.className;
	        	if (this.inputText.size != null) newInput.setAttribute('size', this.inputText.size);
	        	if (this.inputText.maxlength != null) newInput.setAttribute('maxlength', this.inputText.maxlength);
	        	if (this.inputText.onkeypress != null) newInput.observe('keypress', this.inputText.onkeypress);
	
	        	var cssText = this.inputText.getStyle('cssText');
	        	if (cssText != null) newInput.style.cssText = cssText;
	        	
	        	$(this.inputText.parentNode).update(newInput);
	        	this.newInput = newInput;
	        	this.inputText = newInput;
	        } else {
	        	this.inputText.type = 'text';
	        }
	   	}
        this.inputText.value = this.message;
        
   	    var current = this;
   	    var eventBlur = function(event) {
    		if (this.value.blank()) {
    			if (current.originalType == 'password') {
	        		if (Prototype.Browser.IE) {
	        		         //Change the input Password to input Text
	            		$(this.parentNode).update(current.newInput);
	            		current.inputText = current.newInput;
	        		} else {
	        			this.type = "text";
	        		}
	        	}	
      			current.inputText.value = current.message;
     		}
  		};
   	    
   	    
        if (this.originalType == 'password' && Prototype.Browser.IE) { 
        	this.originalInput.observe('blur', eventBlur);
        } else {
			Event.observe(this.inputText, 'blur', eventBlur);
        }
        Event.observe(this.inputText, 'focus', function (event) {
         	if(current.inputText.value == current.message) {
            	current.inputText.value = '';
            	if (current.originalType == 'password' && Prototype.Browser.IE) {
            		//Change the input Text to inputPassword
            		$(this.parentNode).update(current.originalInput);
            		var focusInput = function() {
            			current.originalInput.focus();
            		}
            		setTimeout(focusInput, 1);
     			} else {
     				current.inputText.type = current.originalType;
     			}
          	}
    	});
	}
});