ArtemGavrilenko,
if(img.length > 16){
for (var i = 1; i <= Math.ceil(img.length/16); i++){
if ( i > 1 )
text = '<a class="swith" style="cursor:pointer;" id="' + i + '">' + i + '</a> ';
else
text = '<a class="swith act" style="cursor:pointer;" id="' + i + '">' + i + '</a> ';
$(".pages p").append(text);
}}