function check_idiom(chislo_poley){    
function isEmpty(str) {         
  for (var i = 0; i < str.length; i++){
     if (" " != str.charAt(i)){
         return false;
     }    
  }    
  return true;
}
//-------------------------------
function isNumber(str){         
//----//
	function trim(s){
     return rtrim(ltrim(s));
    }

	function ltrim(s){
	 return s.replace(/^\s+/, '');   
	}

	function rtrim(s){
  	 return s.replace(/\s+$/, ''); 
	}
//----//
	
	var reg = /^[0-9]+$/;      
	str = trim(str);
	var result = reg.test(str);

		if (result) {  
			    return false;
		} 
		else { 
			   return true;
		} 
} 

//-----------------------------------------------------------------------------
function is_interval(str){     
	var	this_number = parseInt(str);  
		if ((this_number>=1) && (this_number<=chislo_poley)) {    
			return false;
		} 
		else { 
			return true;
		} 
}
//-----------------------------------------------------------------------------

input_id= new Array(chislo_poley);  
for (k=0;k<=chislo_poley-1;k++){
 input_id[k]='id'+k; 
}

 count_full=0;                         
for (i=0;i<=chislo_poley-1;i++){
	if (isEmpty(document.getElementById(input_id[i]).value)){            
	 window.alert("Please give all the answers");
	  return false;
	  break;
	} 
	else {
	  count_full+=1;	
	}

}

if (count_full==chislo_poley){
count_isnumber=0;      
for (i=0;i<=chislo_poley-1;i++){
	if (isNumber(document.getElementById(input_id[i]).value)){            
	 			window.alert("Please use numbers only");
				  return false;
				  break;
			} 

	    	else{ 	
	     		count_isnumber+=1;
			}
}
}

if (count_isnumber==chislo_poley){  
count_is_interval=0;   
for (i=0;i<=chislo_poley-1;i++){
	if (is_interval(document.getElementById(input_id[i]).value)){       
	 			window.alert("Please type in only numbers from 1 to "+chislo_poley);
				  return false;
				  break;
	} 
	else{	    	
 	count_is_interval+=1;	
	}
}
}

if (count_is_interval==chislo_poley){
count_isnt_reply=0;              

array_numbers= new Array(chislo_poley);  
array_reply= new Array(chislo_poley);   
for (i=0;i<=chislo_poley-1;i++){
  array_numbers[i]=i+1;
  array_reply[i]=0;
}
 		for (i=0;i<=chislo_poley-1;i++){
           this_field = parseInt(document.getElementById(input_id[i]).value);
		   for (j=0;j<=chislo_poley-1;j++){
		      if (this_field==j+1){         
			    array_reply[j]+=1;
			  }
		   }
 		}

for (k=0;k<=chislo_poley-1;k++){
	if(array_reply[k]>=2){      
	window.alert("Please use each number only once");
	  return false;
	   break;
	}
	else {
	 count_isnt_reply+=1;
	}
}
} 

if (count_isnt_reply==chislo_poley){
   return true;
}
	
}   