/*
obviously requires jquery
emulates html 5 attribute "placeholder", but by using an attribute named "placeholderValue"
*/

$(document).ready(function()
{ 
	var a=$('input[type=text]');
	var placeholderColor="#ddd";
	for(var i=0;i<a.length;i++)
	{
		if(a[i]!=null)
		{
			var b="";
			try
			{
				if(a[i].hasAttribute("placeholderValue"))
					b=a[i].getAttribute("placeholderValue");
			}
			catch(e)
			{
				if(a[i].placeholderValue!=undefined)
					b=a[i].placeholderValue;
			}
			if(b!="")
			{
				a[i].value=b;
				a[i].style.color=placeholderColor;
			}
			else
			{
				if(a[i].defaultValue!="")
				{
					a[i].value=a[i].defaultValue;
				}
			}
			a[i].onfocus=function(){ 
				if(this.value == this.getAttribute("placeholderValue"))
				{
					this.value="";
					this.style.color="";
				}
			};
			
			a[i].onblur=function(){
				if(this.value == "")
				{
					var b="";
					try
					{
						if(this.hasAttribute("placeholderValue"))
							b=this.getAttribute("placeholderValue");
					}
					catch(e)
					{
						if(this.placeholderValue!=undefined)
							b=this.placeholderValue;
					}
					if(b!="")
					{
						this.value=b;
						this.style.color=placeholderColor;
					}
				}
			};
		}
	}
	
});
