var ayacount = new Array(0,7,286,200,176,120,165,206,75,129,109,123,111,43,52,99,128,111,110,98,135,112,78,118,64,77,227,93,88,69,60,34,30,73,54,45,83,182,88,75,85,54,53,89,59,37,35,38,29,18,45,60,49,62,55,78,96,29,22,24,13,14,11,11,18,12,12,30,52,52,44,28,28,20,56,40,31,50,40,46,42,29,19,36,25,22,17,19,26,30,20,15,21,11,8,8,19,5,8,8,11,11,8,3,9,5,4,7,3,6,3,5,4,5,6,0);

function clear_list(listid) {
	mylist = document.getElementById('ayalist' + listid);
	
	for (var i = mylist.length ; i >= 0 ; i--)
		mylist.options[i] = null;
}

function fill_list(listid,count) {
	mylist = document.getElementById('ayalist' + listid);
	
	for (var i = 1 ; i <= count ; i++)
		mylist.options[i - 1] = new Option(i, i, false, false);
}

function fill_aya(id) {
	mysura = document.getElementById('suralist' + id);
	
	clear_list(id);
	fill_list(id,ayacount[mysura.selectedIndex + 1]);
}

function shownamlist() {
	if (document.mainfrm.nam[0].checked) {
		source = 's';
		var key = document.getElementById('suralist3').value;
	}
	else {
		source = 'p';
		var key = document.getElementById('pagelist3').value;
	}

	document.getElementById('lo1').style.visibility = "visible";
	
	_namlist(key,source,{"content_type": "json", "target": "namlist", "onFinish": function(){document.getElementById('lo1').style.visibility = "hidden";}});	
}

function shownoklist() {
	var key = document.getElementById('suralist2').value;

	document.getElementById('lo2').style.visibility = "visible";
	
	_noklist(key,{"content_type": "json", "target": "noklist", "onFinish": function(){document.getElementById('lo2').style.visibility = "hidden";}});	
}

function showvajlist() {
	if (document.mainfrm.vaj[0].checked)
		var key = document.getElementById('suralist4').value;
	else
		var key = 'noaddr';
		
	document.getElementById('lo3').style.visibility = "visible";

	_vajlist(key,{"content_type": "json", "target": "vajlist", "onFinish": function(){document.getElementById('lo3').style.visibility = "hidden";}});	
}

function svajlist() {	
	var key = document.getElementById('keyvaj').value;

	document.getElementById('lo3').style.visibility = "visible";

	_svajlist(key,{"content_type": "json", "target": "vajlist", "onFinish": function(){document.getElementById('lo3').style.visibility = "hidden";}});	
}

function showvaj() {
	var vl = document.getElementById('vajlist');
	
	if (vl.selectedIndex >= 0) {
		document.myurl.action = 'vaj.php?id=' + vl.options[vl.selectedIndex].value;
		document.myurl.submit();
	}
}

function shownam() {
	var vl = document.getElementById('namlist');
	
	if (vl.selectedIndex >= 0) {
		document.myurl.action = 'nam.php?id=' + vl.options[vl.selectedIndex].value;
		document.myurl.submit();
	}
}

function shownok() {
	var vl = document.getElementById('noklist');
	
	if (vl.selectedIndex >= 0) {
		document.myurl.action = 'nok.php?id=' + vl.options[vl.selectedIndex].value;
		document.myurl.submit();
	}
}

function showtb() {
	var vl = document.getElementById('tblist');
	
	if (vl.selectedIndex >= 0) {
		document.myurl.action = 'tb.php?id=' + vl.options[vl.selectedIndex].value;
		document.myurl.submit();
	}
}

function showtblist() {
	var sura = document.getElementById('suralist1');
	
	if (sura.selectedIndex > 0) {
		document.getElementById('lo4').style.visibility = "visible";
		
		_tblist(sura.options[sura.selectedIndex].value,{"content_type": "json", "target": "tblist", "onFinish": function(){document.getElementById('lo4').style.visibility = "hidden";}});
	}
}