﻿
function InputPlaceholder (input, value, bgImgPath,border, default_text)
{
	var thisCopy = this
	
	this.Input = input
	this.Value = value
	this.SaveOriginal = (input.value == value)
	this.bgImgPath = bgImgPath
	this.border=border
	this.default_text=default_text
	
    this.Input.style.border=border
    this.Input.style.background=this.bgImgPath

	this.setupEvent (this.Input, 'focus', function() {return thisCopy.onFocus()})
	this.setupEvent (this.Input, 'blur',  function() {return thisCopy.onBlur()})
	this.setupEvent (this.Input, 'keydown', function() {return thisCopy.onKeyDown()})

	if (input.value == '') this.onBlur();

	return this
}

InputPlaceholder.prototype.setupEvent = function (elem, eventType, handler)
{
	if (elem.attachEvent)
	{
		elem.attachEvent ('on' + eventType, handler)
	}

	if (elem.addEventListener)
	{
		elem.addEventListener (eventType, handler, false)
	}
}

InputPlaceholder.prototype.onFocus = function()
{
	if (!this.SaveOriginal &&  this.Input.value == this.Value)
	{
		this.Input.value = ''
	    this.Input.style.background=''
	    this.Input.style.border=this.border
	}
	else
	{
	    this.Input.style.background=''
		
	}
}

InputPlaceholder.prototype.onKeyDown = function()
{
	
	this.Input.style.background=''
	this.Input.style.border=this.border
	
}

InputPlaceholder.prototype.onBlur = function()
{
    

	if (this.Input.value == '' || this.Input.value == this.Value)
	{
		this.Input.value = this.Value
		if (this.Input.value == '')
		    this.Input.style.background=this.bgImgPath
		    
		else
		    this.Input.style.background=''

	}
	else
	{
	    this.Input.style.background=''
		
	}
}




function InputPlaceholder2 (input, default_text)
{
	var thisCopy = this
	
	this.Input = input
	this.SaveOriginal = (input.value == default_text)
	this.default_text=default_text
	
	this.setupEvent (this.Input, 'focus', function() {return thisCopy.onFocus()})
	this.setupEvent (this.Input, 'blur',  function() {return thisCopy.onBlur()})
	this.setupEvent (this.Input, 'keydown', function() {return thisCopy.onKeyDown()})

	if (input.value == '') this.onBlur();

	return this
}

InputPlaceholder2.prototype.setupEvent = function (elem, eventType, handler)
{
	if (elem.attachEvent)
	{
		elem.attachEvent ('on' + eventType, handler)
	}

	if (elem.addEventListener)
	{
		elem.addEventListener (eventType, handler, false)
	}
}

InputPlaceholder2.prototype.onFocus = function()
{
	if (!this.SaveOriginal &&  this.Input.value == this.default_text)
	{
		this.Input.value = ''
	}
	else
	{
	    /*this.Input.value = ''*/
		
	}
}

InputPlaceholder2.prototype.onKeyDown = function()
{
	
	

}

InputPlaceholder2.prototype.onBlur = function()
{
    

	if (this.Input.value == '' || this.Input.value == this.default_text)
	{
		this.Input.value = this.default_text
        
	}
	else
	{   
	    /*this.Input.value = ''*/
		
	}
}




function InputPlaceholder3 (input, default_text, default_color, color)
{
	var thisCopy = this
	
	this.Input = input
	this.SaveOriginal = (input.value == default_text)
	this.default_text=default_text
	this.default_color=default_color
	this.color=color
	this.default_type=this.Input.type
	
	this.setupEvent (this.Input, 'focus', function() {return thisCopy.onFocus()})
	this.setupEvent (this.Input, 'blur',  function() {return thisCopy.onBlur()})
	this.setupEvent (this.Input, 'keydown', function() {return thisCopy.onKeyDown()})

	if (input.value == '') this.onBlur();

	return this
}

InputPlaceholder3.prototype.setupEvent = function (elem, eventType, handler)
{
	if (elem.attachEvent)
	{
		elem.attachEvent ('on' + eventType, handler)
	}

	if (elem.addEventListener)
	{
		elem.addEventListener (eventType, handler, false)
	}
}

InputPlaceholder3.prototype.onFocus = function()
{
	if (!this.SaveOriginal &&  this.Input.value == this.default_text)
	{
	    this.Input.type=this.default_type
		this.Input.value = ''
		this.Input.style.color=this.color;
		
	}
	else
	{
	    /*this.Input.value = ''*/
		
	}
}

InputPlaceholder3.prototype.onKeyDown = function()
{
	
	

}

InputPlaceholder3.prototype.onBlur = function()
{
    

	if (this.Input.value == '' || this.Input.value == this.default_text)
	{
	    this.Input.type="text"
		this.Input.value = this.default_text
		this.Input.style.color=this.default_color;
		        
	}
	else
	{   
	    /*this.Input.value = ''*/
		
	}
}

