
{

	var number,temp;	//variables to use later
	var set=6;	//limit of numbers picked
	var limit=49;	//upper range of available numbers
	var list=new Array(set);	//array to hold generated numbers
	var match=false;

	var	lines =1;
		
	var count; 
	
	for(count=0;count<6;count++)
	{
	{	
    		for(index=0;index<set;index++)		//simple loop to generate 6 random numbers
    		{
    			//create a loop that checks for duplicate numbers picked and rejects them
    			do{
    				match=false;
    				number=(Math.floor(Math.random()*limit+1));// number between 1 and 49 created
    
    				for(check=0;check<=index && match==false;check++)// need to check if new number is unique to picked set
    				{
    					if(list[check]==number)
    						match=true;
    				}
    
    			}while(match==true);// if duplicate found repeat loop until unique number found
    			list[index]=number;//add unique number to array
    		}
    
    		// sorting loop needs to ensure that if lowest number in last position it has enough turns to be placed into
    		//     the first position before the loop stops-->
    		
    		for(sort=0;sort<=set;sort++)//start loop count
    		{
    			for(index=0;index<=set;index++)//loop through positions in array and compare the contents with the position above
    			{
    				if(list[index]>list[index+1])
    				{
    					temp=list[index];//make copy of higher number
    					list[index]=list[index+1];//move lower copy down one position
    					list[index+1]=temp;//replace higher position with higher number
    				}
    			}
    		}
    
    
    	document.write('<table border="1" width="250px"	summary="displays numbers in nice format"	cellspacing="3" cellpadding="2">')
    	document.write('<tr>')
    	for(index=0;index<set;index++)//display contents of array to user
    	{
    		document.write('<td width="15px" align="center">  ',list[index],' </td>  ');//make the table cells equal spacing and data centred
    	}
    	document.write('</tr>');
    	document.write('</table>');
	}
	}
}
