	function countnew(thisterm,maxlimit,minlimit,density,form)
	{	
		//alert(density);
		thisterm=thisterm.toLowerCase();

		if(thisterm!="")
		{
			var obj=document.getElementById("def");

			var content=form.define.value+ " ";

			content=content.toLowerCase();
			
			b=thisterm.replace("  "," ");
		
			b= b.split(' ');
			
		
//			a=content.replace('\n',' ');

			e=content.split('\n');
			g ='';

			for(i=0; i < (e.length - 1) ; i++)
			{
				g += e[i].substring(0,e[i].length-1) + ' ';
			
			}	
			a = g + e[i];

			var omit = new Array("-",",",".",":",";","!","?","<",">","(",")","{","}","[","]","/","\\","'",'"');
	
			a=a.split(' ');
			
			for(i=0; i < a.length; i++)
			{
				if(a[i]!=thisterm)
				{
					for(k=0;k<omit.length;k++)
					{				
						a[i]=a[i].replace(omit[k]+" " , " ");
						a[i]=a[i].replace(" "+omit[k]+" " , " ");
						a[i]=a[i].replace(" "+omit[k] , " ");	
						
						if((thisterm.indexOf(omit[k]))== -1 && a[i]!=b[0])
						{								
							a[i]=a[i].replace(omit[k]," "); //(/omit[k]/gi,"");
							a[i]=a[i].replace(omit[k]," ");
							a[i]=a[i].replace(omit[k]," ");
							
						}
					}
				}
			}

			
			var new_c = ""; var j = 0; wcnt=0;



			

			for(i=0;i<a.length;i++)
			{
				j++; 
							
						
				if(a[i].length!=0)
				{	
					new_c+=a[i]; 
					wcnt++;
				}
				if(a[i].length!=0 && j!=a.length)
					new_c+=" ";
			}

		
			a = new_c.split(' ');


		
			if(wcnt>maxlimit || wcnt<minlimit)
				document.all.def.style.backgroundColor="red";
			else
				document.all.def.style.backgroundColor="lime";



		
			if(content!="")
				obj.innerHTML=wcnt;  
			else
				obj.innerHTML=0;

		
		
			

			mcnt = 0;
	
			var flag="";
			for(i=0;i<a.length;i++)
			{	

				ll=a[i].length-1;
				var first=a[i].substring(0,1);
				var last=a[i].substring(ll);

				flag=""; 

				if(b[0]==a[i])
				{	
					
					if(b.length > 1)
					{
						for(j=1; j< b.length; j++)
						{
							if( a[i + j] == b[j] && a[i+j].length!=0)
							{
								flag = "success";
							}
							
							else if((j+1)==b.length && a[i + j] != b[j])
							{	
								for(k=0;k<omit.length;k++)
								{	
									if(b[j]!=a[i + j])
									{
										a[i + j]=a[i + j].replace(omit[k],"");
										a[i + j]=a[i + j].replace(omit[k],"");
										a[i + j]=a[i + j].replace(omit[k],"");
									}
									
								}	
									
								if(a[i + j]==b[j])
									flag="success";
							}

							else
							{
								flag = "failed";
								break;
							}

						}
					}
					else
						flag="success";
					
				}
			
				else
				{
					
					for(k=0;k<omit.length;k++)
					{	
															
						if((thisterm.indexOf(omit[k]))== -1 && a[i]!=b[0]) //if((b[0].indexOf(omit[k]))== -1 && a[i]!=b[0])
						{								
							a[i]=a[i].replace(omit[k],""); //(/omit[k]/gi,"");
							a[i]=a[i].replace(omit[k],"");
							a[i]=a[i].replace(omit[k],"");
							
							flag="success";
															
						}
										
					}	
					
					if(a[i]==b[0])
						flag="success";
					
				}
			
			

				if(flag!="success")
				{
					for(k=0;k<omit.length;k++)
					{
						if(first==omit[k])
						{	a[i]=a[i].substring(1,a[i].length);	//a[i]=a[i].replace(omit[k]," ");
						
						}				

						if(last==omit[k])
						{	a[i]=a[i].substring(0,a[i].length-1);	//a[i]=a[i].replace(omit[k]," ");
						
						}
					
					}
							
				}
			}

		
			
			for(i=0 ; i<= a.length ; i++)
			{
					
				if(a[i] == b[0] && a[i].length!=0)
				{	
					if(b.length > 1)
					{
						for(j=1; j< b.length; j++)
						{
							
							if( a[i + j] == b[j] && a[i+j].length!=0)
							{	
								
								match = "success";
							}
							else
							{
								match = "failed";
								break;
							}
						}
					}
					else
					{
						match = "success";
					}
					if(match=="success")
					{
						mcnt++;
					}
				}
			}

		
			var obj=document.getElementById("den");

		
			//var h= mcnt * 100 / (wcnt - (mcnt *  b.length) + mcnt);

			var h= mcnt * 100 / wcnt ;		

			var h=Math.round(h*100)/100 ;



			if(h>=density)
				document.all.den.style.backgroundColor="lime";				
			else
				document.all.den.style.backgroundColor="red";

			
			
			if(content!="" && !isNaN(h))
				obj.innerHTML=h+"%";
			else
				obj.innerHTML=0;
			
		}

	}

function countlines(area)  
{  
 // trim trailing return char if exists  
 var text = area.value.replace(/\s+$/g,"")  
 var split = text.split("\n")  
 return split.length  
}  