function  LimitTextArea(id,limit)
{
	if(id.lastIndexOf('_')!=id.indexOf('_'))
	{
		var index=id.lastIndexOf('_')+1;
		var sub=id.substr(0,index);
		var i=parseInt(id.substr(index));
		while($(sub+i))
		{
			SetCharacterLimit(sub+i,limit);
			i++;
		}

	}
	else
	{
		SetCharacterLimit(id,limit);
	}
	
}
function SetCharacterLimit(id,limit)
{
	var e=$(id);
	if(e && e.hasAttribute('cols'))
	{
		var div =document.createElement('div');
		div.id=id+'_charsrem';
		div.className='charsrem';
		e.parentNode.appendChild(div);
		div.style.width=(e.clientWidth-5)+'px';
		e.onchange=function() {
			if(this.value.length>limit)
			{
				var sub=this.value;
				sub=sub.substring(0,limit);
				this.value=sub;
			}
			this.up().down('.charsrem').innerHTML='You may enter a further '+(limit-this.value.length)+' characters.';
		}
		e.onkeyup=e.onchange;
		e.onchange();
	}
}

function SetTextAreaBGText(id,text)
{
	var e=$(id);
	if(e)
	{
		var oldbackground=e.style.background;
		var oldcolor=e.style.color;
		var oldfontstyle=e.style.fontStyle;
		var oldcontent=e.value;
		e.style.background='#eee';
		e.style.color='#333';
		e.style.fontStyle='italic';
		e.value=text;
		e.onsubmit=function() {
			if(e.value==text)
			{
				e.value=oldcontent;
				e.style.background=oldbackground;
				e.style.color=oldcolor;
				e.style.fontStyle=oldfontstyle;
			}
		}
		e.onfocus=e.onsubmit;
	}
}

