// JavaScript Document
var max=1000;	
var timerID=null;
var running=false;

function countChars()                                                                                          
{                                                                                                              
if(document.getElementById('anunt').value.length>max)                                                                
{                                                                                                              
document.getElementById('anunt').blur();                                                                             
document.getElementById('ramase').value =0;                                                                            
alert("Numarul maxim de caractere admise pentru anunt este de "+ max +"!");                                                         
}                                                                                                              
else document.getElementById('ramase').value =                                                                         
max-document.getElementById('anunt').value.length;                                                                   
if (document.getElementById('ramase').value==0)                                                                        
        {                                                                                                      
        var text=document.getElementById('anunt').value                                                              
        document.getElementById('anunt').value=text.substr(0,max);                                                   
        }                                                                                                      
} 
		
function timerTick()
	{	
	if(running) 
		{
		stopTimer();
		if(navigator.appName=="Netscape")
			{
			document.getElementById('anunt').blur();
			}
		document.getElementById('anunt').focus();
		startTimer();
		countChars();
		}
	}

function stopTimer()
	{
	clearTimeout(timerID);
	running=false;
	}
		
function startTimer()
	{
	if(!running) 
		{
		running=true;
		timerID=setTimeout("timerTick()",200);
		}
	}