var our_key_length=""//it is used in the plaintext array
var butt_text="";
function highest(nums)
{
	our_key_length=nums;
	//////////////////////
	my_chararray(nums);///this function create the hgt array by running only one time
	//////////////////
	butt_text="<font color='#cccccc' size='2' face='arial'><p align='justify'>It seems probable that the keyword is "		+nums+" letters long. For the time being let us call the keyword &nbsp;&nbsp";
	for(var i=0;i<nums;i++)
	{
	if(i==0)
		{butt_text=butt_text+"L"+(i+1);}
	else
		{butt_text=butt_text+"-"+"L"+(i+1);}
	}
	butt_text=butt_text+".&nbsp;&nbsp;The letter L1 defines one row of the Vigenère square, and effectively provides a monoalphabetic substitution cipher alphabet for the first letter of the plaintext, and also the 6th, 11th, 16th letters, etc. So if we take the corresponding letters in the ciphertext, we know they have been encrypted using the same row of the Vigenère square, and we can work out which row by using frequency analysis, because one row of the square is equivalent to a monoalphabetic cipher. This polyalphabetic cipher consists of cycling between five monoalphabetic ciphers.</p><p align='justify'>Click on  L1 to perform a frequency analysis of the letters that have been encrypted using that part of the keyword.</p></font>";

	butt_text=butt_text+"<table align='center' border='0'><tr><td>&nbsp;</td><td>&nbsp;</td>";
	
	for(var i=0;i<nums;i++)
		{
		butt_text=butt_text+"<td><input type='button' size='2' name=L"+i+" value=L"+(i+1)+"  onClick='graph_compare("+i+")'></td>";		
		}
	butt_text=butt_text+"</tr></table>";
	document.all['buttonLayer'].innerHTML=butt_text;
	
}//end of functiion highest
////////////////////////////////////////////////////////////////////////////////////////////
var which_butt_clicked="";
function graph_compare(char_pos)
{
////
document.all["vis"].style.visibility='visible';
////
which_butt_clicked=char_pos
mywrk(13);
document.knobImg2.style.pixelLeft=261
}

//////////////////////////////////////////////////////////////////////////////////////////////////
var letter="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
var hgt=new Array();
var charset="";
var acharin=""//only use in for loop
var array_ofcharset=new Array();
function my_chararray(key_length)////dhore nissi je eta ekbar run korbe
{
var my_cipher_text=document.form1.cipher.value

for(var i=0;i<key_length;i++)
	{
	hgt[i]=new Array(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
	for(var j=i;j<my_cipher_text.length;j=j+key_length)
		{
		if(my_cipher_text.charAt(j)!=-1)
		charset=charset+my_cipher_text.charAt(j);
		acharin=my_cipher_text.charAt(j);
		if(acharin!=-1)
			{
			hgt[i][letter.indexOf(acharin)]=hgt[i][letter.indexOf(acharin)]+1;
			}
		
		}
	array_ofcharset[i]=charset;charset="";
	}
	var k=0;
	
//making % of the chars according to total chars that is length of array_ofcharset array
 

for(var k=0;i<key_length;k++)
	{
	for(var j=0;j<26;j++)
		{
		hgt[k][j]=Math.round(hgt[k][j]/array_ofcharset[k].length)*100		
		}
	
	}
	

}//end of fuhnction for hgt[]

/////////////////////////////////////////////////////////////////////////////////////////////////////////////