function math_round(Num, Places) {
   if (Places > 0) {
      if ((Num.toString().length - Num.toString().lastIndexOf('.')) > (Places + 1)) {
         var Rounder = Math.pow(10, Places);
         return Math.round(Num * Rounder) / Rounder;
      }
      else return Num;
   }
   else return Math.round(Num);
}
function lkcsearch(){
if (document.frm1.bodys.value==""){
alert("Body of text is a required filed.");
document.frm1.bodys.focus();
return (false);
}                                            
if ((document.frm1.k1.value=="")&&(document.frm1.k2.value=="")&&(document.frm1.k3.value=="")){
alert("At least one keyword field must be filed before search.");
document.frm1.k1.focus();
return (false);
}

index=1;
pindex=0;
endwhile=0
bodyt=document.frm1.bodys.value;
bodyl=bodyt.toLowerCase()
finalfs=bodyl.indexOf(".",bodyl.length-1);
if(finalfs>=0)
bodyl=bodyl.substring(0,bodyl.length-1);
while(index>=0){
index = bodyl.indexOf("<",0);
if (index >= 0)
{
pindex = bodyl.indexOf(">",index);
bodyank=bodyl.substring(index,pindex+1);
bodyl=bodyl.replace(bodyank," ");
}
}
//then, these, they, this, was, were, with.
bodyl=bodyl.replace("and"," ");
bodyl=bodyl.replace("but"," ");
bodyl=bodyl.replace("for"," ");
bodyl=bodyl.replace("from"," ");
bodyl=bodyl.replace("here"," ");
bodyl=bodyl.replace("her"," ");
bodyl=bodyl.replace("his"," ");
bodyl=bodyl.replace("how"," ");
bodyl=bodyl.replace("not"," ");
bodyl=bodyl.replace("than"," ");
bodyl=bodyl.replace("that"," ");
bodyl=bodyl.replace("the"," ");
bodyl=bodyl.replace("them"," ");
bodyl=bodyl.replace("then"," ");
bodyl=bodyl.replace("these"," ");
bodyl=bodyl.replace("they"," ");
bodyl=bodyl.replace("this"," ");
bodyl=bodyl.replace("was"," ");
bodyl=bodyl.replace("were"," ");
bodyl=bodyl.replace("with"," ");
bodyl=bodyl.replace(". "," ");
bodyl=bodyl.replace("@ "," ");
rm_ext_char="";
real_chr="";
for(i=0; i<bodyl.length; i++){
one_chr=bodyl.charCodeAt(i);

if ((one_chr>=65 && one_chr<=90) || (one_chr>=97 && one_chr<=122) || (one_chr>=48 && one_chr<=57)){
real_chr=bodyl.charAt(i);
}else{
real_chr=" ";
}
rm_ext_char=rm_ext_char+real_chr
}

bodyl=rm_ext_char.split(" ");
rm_s_d="";
full_text="";
count=0
for(i=0; i<bodyl.length; i++){
rm_s_d=bodyl[i];
if (rm_s_d.length>2){
count=count+1;
full_text=full_text+" "+rm_s_d;
}
}

//document.frm1.bodys.value=full_text;
if (document.frm1.k1.value!=""){
kf=document.frm1.k1.value;
rm_ext_char="";
real_chr="";
for(i=0; i<kf.length; i++){
one_chr=kf.charCodeAt(i);
if ((one_chr>=65 && one_chr<=90) || (one_chr>=97 && one_chr<=122) || (one_chr>=48 && one_chr<=57)){
real_chr=kf.charAt(i);
}else{
real_chr=" ";
}
rm_ext_char=rm_ext_char+real_chr
}
kf=rm_ext_char;
kslen=kf.split(" ");
if(kslen.length>1){
kf=kf.toLowerCase()
countkf=0.1;
kftotal=0;
while(countkf>=0){
if (countkf>=0.1 && countkf<0.2)
{
countkf = full_text.indexOf(kf,0);
}
else
{
end=countkf+kf.length;
countkf = full_text.indexOf(kf,end);
}

if (countkf >= 0)
{
kftotal=kftotal+1;
}
}
if (kslen.length>count)
document.frm1.r1.value=0;
else
document.frm1.r1.value=math_round(kftotal/(count+1-kslen.length)*100,1);
}else{

if (document.frm1.k1.value!=""){
k1=document.frm1.k1.value;
kl=k1.toLowerCase()
ks=k1+"s";
countk1=0;
for(i=0; i<bodyl.length; i++){
rm_s_d=bodyl[i];
if (rm_s_d.length>1){
if (rm_s_d==kl || rm_s_d==ks){
		countk1=countk1+1;
	}
  }
}

document.frm1.r1.value=math_round(countk1/count*100,1);

}




}
}




if (document.frm1.k2.value!=""){
kf=document.frm1.k2.value;
rm_ext_char="";
real_chr="";
for(i=0; i<kf.length; i++){
one_chr=kf.charCodeAt(i);
if ((one_chr>=65 && one_chr<=90) || (one_chr>=97 && one_chr<=122) || (one_chr>=48 && one_chr<=57)){
real_chr=kf.charAt(i);
}else{
real_chr=" ";
}
rm_ext_char=rm_ext_char+real_chr
}
kf=rm_ext_char;

kslen=kf.split(" ");
if(kslen.length>1){
kf=kf.toLowerCase()
countkf=0.1;
kftotal=0;
while(countkf>=0){
if (countkf>=0.1 && countkf<0.2)
{
countkf = full_text.indexOf(kf,0);
}
else
{
end=countkf+kf.length;
countkf = full_text.indexOf(kf,end);
}

if (countkf >= 0)
{
kftotal=kftotal+1;
}
}
if (kslen.length>count)
document.frm1.r2.value=0;
else
document.frm1.r2.value=math_round(kftotal/(count+1-kslen.length)*100,1);
}else{
if (document.frm1.k2.value!=""){
k2=document.frm1.k2.value;
kl2=k2.toLowerCase()
k2s=kl2+"s";
countk2=0;
for(i=0; i<bodyl.length; i++){
rm_s_d=bodyl[i];
if (rm_s_d.length>1){
if (rm_s_d==kl2 || rm_s_d==k2s){
		countk2=countk2+1;
	}
  }
}

document.frm1.r2.value=math_round(countk2/count*100,1);

}



}
}

if (document.frm1.k3.value!=""){
kf=document.frm1.k3.value;
rm_ext_char="";
real_chr="";
for(i=0; i<kf.length; i++){
one_chr=kf.charCodeAt(i);
if ((one_chr>=65 && one_chr<=90) || (one_chr>=97 && one_chr<=122) || (one_chr>=48 && one_chr<=57)){
real_chr=kf.charAt(i);
}else{
real_chr=" ";
}
rm_ext_char=rm_ext_char+real_chr
}
kf=rm_ext_char;

kslen=kf.split(" ");
if(kslen.length>1){
kf=kf.toLowerCase()
countkf=0.1;
kftotal=0;
while(countkf>=0){
if (countkf>=0.1 && countkf<0.2){
countkf = full_text.indexOf(kf,0);
}
else
{
end=countkf+kf.length;
countkf = full_text.indexOf(kf,end);
}

if (countkf >= 0)
{
kftotal=kftotal+1;
}
}
if (kslen.length>count)
document.frm1.r3.value=0;
else
document.frm1.r3.value=math_round(kftotal/(count+1-kslen.length)*100,1);
}else{

if (document.frm1.k3.value!=""){
k3=document.frm1.k3.value;
kl3=k3.toLowerCase()
k3s=kl3+"s";
countk3=0;
for(i=0; i<bodyl.length; i++){
rm_s_d=bodyl[i];
if (rm_s_d.length>1){
if (rm_s_d==kl3 || rm_s_d==k3s){
		countk3=countk3+1;
	}
  }
}

document.frm1.r3.value=math_round(countk3/count*100,1);

}


}
}







return (false);
}
