function AutoPreFill( inputFieldId, preFillText )
{
	this.inputFieldId = inputFieldId;
	this.preFillText = preFillText;
	this.init();
}

AutoPreFill.prototype.init = function()
{
	if( $( this.inputFieldId ).val() == '' || $( this.inputFieldId ).val() == this.preFillText || $( this.inputFieldId ).val() == undefined )
	{
		$( this.inputFieldId ).css( 'color', '#888888' );
		$( this.inputFieldId ).val( this.preFillText );
	}
	else
	{
		$( this.inputFieldId ).css( 'color', '#000000' );
	}
}

// Input element was blurred, so fill in pre-fill input if input field is empty
AutoPreFill.prototype.blurEvent = function()
{
	if( $( this.inputFieldId ).val() == '' || $( this.inputFieldId ).val() == this.preFillText || $( this.inputFieldId ).val() == undefined )
	{
		$( this.inputFieldId ).val( this.preFillText );
		$( this.inputFieldId ).css( 'color', '#888888' );
	}
}

// Input element was focussed, so clear pre-fill input if exists any
AutoPreFill.prototype.focusEvent = function()
{
	if( $( this.inputFieldId ).val() == this.preFillText )
	{
		$( this.inputFieldId ).val( '' );
		$( this.inputFieldId ).css( 'color', '#000000' );
	}
}

// Form was submitted. In case it contains the pre-fill text, it has to be cleared
AutoPreFill.prototype.submitEvent = function()
{
	if( $( this.inputFieldId ).val() == this.preFillText )
		$( this.inputFieldId ).val( '' );
}

// When form is autofocussed and the user starts typic the input field has to clear
AutoPreFill.prototype.keyDownEvent = function(){
	if( $( this.inputFieldId ).val() == this.preFillText ){
		$( this.inputFieldId ).val( '' );
		$( this.inputFieldId ).css( 'color', '#000000' );
	}
}

