function outputcountryshort(countryshorttable, cntrid, sortid, uarray){
	if ( !countryshorttable || !uarray || (uarray.length==0) ) return;
       	var captionRow = countryshorttable.insertRow(-1);

       	var captionCell = captionRow.insertCell(-1);
	captionCell.className = 'size15_bkgray_nopad_firsthi';
	captionCell.align = 'center';
	captionCell.innerHTML = '<a href="" class="alinkblack">Исходные данные сезона</a>';
	captionCell.colSpan = 3;

       	var captionCell = captionRow.insertCell(-1);
	captionCell.className = 'size15_bkgray_nopad_hi';
	captionCell.align = 'center';
	captionCell.innerHTML = '<a href="" class="alinkblack">Результаты сезона</a>';
	captionCell.colSpan = 4;

       	var captionRow = countryshorttable.insertRow(-1);

       	var captionCell = captionRow.insertCell(-1);

	captionCell.className = 'size15_bkgray_nopad_first';
	captionCell.align = 'center';
	captionCell.innerHTML = '<a href="" class="alinkblack" onClick="rebuildcountryshort('+cntrid+', 1); return false;">Сезон</a>';
	captionCell.rowSpan = 2;
	captionCell.style.width = '100px';

       	var captionCell = captionRow.insertCell(-1);
	captionCell.className = 'size15_bkgray_nopad';
	captionCell.align = 'center';
	captionCell.innerHTML = '<a href="" class="alinkblack" onClick="rebuildcountryshort('+cntrid+', 2); return false;">Место в заявочной ТК</a>';
	captionCell.rowSpan = 2;
	captionCell.style.width = '180px';

       	var captionCell = captionRow.insertCell(-1);
	captionCell.className = 'size15_bkgray_nopad';
	captionCell.align = 'center';
	captionCell.innerHTML = 'Заявлено клубов';
	captionCell.rowSpan = 2;
	captionCell.style.width = '140px';

       	var captionCell = captionRow.insertCell(-1);
	captionCell.className = 'size15_bkgray_nopad';
	captionCell.align = 'center';
	captionCell.innerHTML = '<a href="" class="alinkblack" onClick="rebuildcountryshort('+cntrid+', 4); return false;">Набрано очков</a>';
	captionCell.rowSpan = 2;
	captionCell.style.width = '120px';

       	var captionCell = captionRow.insertCell(-1);
	captionCell.className = 'size15_bkgray_nopad';
	captionCell.align = 'center';
	captionCell.innerHTML = '<a href="" class="alinkblack" onClick="rebuildcountryshort('+cntrid+', 5); return false;">Коэффициент</a>';
	captionCell.rowSpan = 2;
	captionCell.style.width = '100px';

       	var captionCell = captionRow.insertCell(-1);
	captionCell.className = 'size15_bkgray_nopad';
	captionCell.align = 'center';
	captionCell.innerHTML = 'Место в формирующейся ТК';
	captionCell.colSpan = 2;
	captionCell.style.width = '300px';

       	var captionRow = countryshorttable.insertRow(-1);

       	var captionCell = captionRow.insertCell(-1);
	captionCell.className = 'size15_bkgray_nopad';
	captionCell.align = 'center';
	captionCell.innerHTML = '<a href="" class="alinkblack" onClick="rebuildcountryshort('+cntrid+', 6); return false;">Перед сезоном</a>';
	captionCell.style.width = '140px';

       	var captionCell = captionRow.insertCell(-1);
	captionCell.className = 'size15_bkgray_nopad';
	captionCell.align = 'center';
	captionCell.innerHTML = '<a href="" class="alinkblack" onClick="rebuildcountryshort('+cntrid+', 7); return false;">По итогам сезона</a>';
	captionCell.style.width = '160px';


	for (var i = 0; i < uarray.length; i++) {
		var captionRow = countryshorttable.insertRow(-1);

		for (var j = 0; j < uarray[i].length; j++) {
			var captionCell = captionRow.insertCell(-1);
			captionCell.align = 'center';		
			var s = 'size12';
			if (i%2!=0) s += '_bklgray';
			s += '_nopad';
			if (j==0) s += '_first';
			captionCell.className = s;
			captionCell.innerHTML = uarray[i][j]	
		}
	}

}






function outputcountrysvodka(countrysvodkatable, cntrid, bseas, eseas, sortid, uarray){
	if ( !countrysvodkatable || !uarray || (uarray.length==0) ) return;
       	var captionRow = countrysvodkatable.insertRow(-1);

       	var captionCell = captionRow.insertCell(-1);
	captionCell.className = 'size15_bkgray_nopad_firsthi';
	captionCell.align = 'center';
	captionCell.innerHTML = '<a href="" class="alinkblack" onClick="rebuildcountrysvodka(' + cntrid + ', '+ bseas +', '+ eseas +', 1); return false;">Клуб</a>';

       	var captionCell = captionRow.insertCell(-1);
	captionCell.className = 'size15_bkgray_nopad_hi';
	captionCell.align = 'center';
	captionCell.innerHTML = '<a href="" class="alinkblack" onClick="rebuildcountrysvodka(' + cntrid + ', '+ bseas +', '+ eseas +', 2); return false;">Среднее</a>';

       	var captionCell = captionRow.insertCell(-1);
	captionCell.className = 'size15_bkgray_nopad_hi';
	captionCell.align = 'center';
	captionCell.innerHTML = '<a href="" class="alinkblack" onClick="rebuildcountrysvodka(' + cntrid + ', '+ bseas +', '+ eseas +', 3); return false;">Очки</a>';

       	var captionCell = captionRow.insertCell(-1);
	captionCell.className = 'size15_bkgray_nopad_hi';
	captionCell.align = 'center';
	captionCell.innerHTML = '<a href="" class="alinkblack" onClick="rebuildcountrysvodka(' + cntrid + ', '+ bseas +', '+ eseas +', 4); return false;">Участия</a>';

       	var captionCell = captionRow.insertCell(-1);
	captionCell.className = 'size15_bkgray_nopad_hi';
	captionCell.align = 'center';
	captionCell.innerHTML = '<a href="" class="alinkblack" onClick="rebuildcountrysvodka(' + cntrid + ', '+ bseas +', '+ eseas +', 5); return false;">Участия в ЛЧ</a>';
	captionCell.noWrap = true;

       	var captionCell = captionRow.insertCell(-1);
	captionCell.className = 'size15_bkgray_nopad_hi';
	captionCell.align = 'center';
	captionCell.innerHTML = '<a href="" class="alinkblack" onClick="rebuildcountrysvodka(' + cntrid + ', '+ bseas +', '+ eseas +', 6); return false;">Игры</a>';

       	var captionCell = captionRow.insertCell(-1);
	captionCell.className = 'size15_bkgray_nopad_hi';
	captionCell.align = 'center';
	captionCell.innerHTML = '<a href="" class="alinkblack" onClick="rebuildcountrysvodka(' + cntrid + ', '+ bseas +', '+ eseas +', 7); return false;">Победы</a>';

       	var captionCell = captionRow.insertCell(-1);
	captionCell.className = 'size15_bkgray_nopad_hi';
	captionCell.align = 'center';
	captionCell.innerHTML = '<a href="" class="alinkblack" onClick="rebuildcountrysvodka(' + cntrid + ', '+ bseas +', '+ eseas +', 8); return false;">Ничьи</a>';

       	var captionCell = captionRow.insertCell(-1);
	captionCell.className = 'size15_bkgray_nopad_hi';
	captionCell.align = 'center';
	captionCell.innerHTML = '<a href="" class="alinkblack" onClick="rebuildcountrysvodka(' + cntrid + ', '+ bseas +', '+ eseas +', 9); return false;">Поражения</a>';


	for (var i = 0; i < uarray.length; i++) {
		var captionRow = countrysvodkatable.insertRow(-1);

		for (var j = 0; j < uarray[i].length; j++) {
			var captionCell = captionRow.insertCell(-1);
			if (j==0) {
			    s = 'size15_bkgray_first';
			    captionCell.noWrap = true;
			}else{
			    captionCell.align = 'center';
			    s = 'size15';
			    if (i%2!=0) s += '_bklgray';
			}
			captionCell.className = s;
			captionCell.innerHTML = uarray[i][j]	
		}
	}

}





function rebuildcountryshort(cntrid, sort){
if (window.XMLHttpRequest) req = new XMLHttpRequest();  
else if (window.ActiveXObject) {    
    try {
        req = new ActiveXObject("Msxml2.XMLHTTP");    
    } catch (e){}
    try {     
        req = new ActiveXObject("Microsoft.XMLHTTP"); 
    } catch (e){} 
}  
if (req) {    
    var url = "/engine/modules/ajax/country.php?type=short&cntr=" + cntrid + "&sort=" + sort;
    var messcont = (document.all) ? document.all.mess_cont : document.getElementById("mess_cont");
    var countryshorttable = (document.all) ? document.all.countryshorttable : document.getElementById("countryshorttable");
    req.open("GET", url, true); 
    req.onreadystatechange = function() {
        if (req.readyState == 4) {
            if (req.status == 200){
    		messcont = (document.all) ? document.all.mess_cont : document.getElementById("mess_cont");       
	    	if (messcont){messcont.parentNode.removeChild(messcont);}
		if (countryshorttable){
                    while (countryshorttable.firstChild) {
                        countryshorttable.removeChild(countryshorttable.firstChild)
		    }
                }
		var s = req.responseText;
		var s = s.replace(/[\r\n]/g, ' ');
                var darray = eval(s);
		outputcountryshort(countryshorttable, cntrid, sort, darray);
            }else{
    		messcont = (document.all) ? document.all.mess_cont : document.getElementById("mess_cont");       
	    	if (messcont){messcont.parentNode.removeChild(messcont);}
                alert("Ошибка: "+req.statusText);
            }
        }else{
     	    if (messcont){messcont.parentNode.removeChild(messcont);}
	    loading_progress();
        }
    }
    req.send(null); //отправка запроса без параметров, т.к. они установлены в url
}
else 
    {alert("Браузер не поддерживает AJAX");}
return false;
}    


function rebuildcountrysvodka(cntrid, bseas, eseas, sort){
if (window.XMLHttpRequest) req = new XMLHttpRequest();  
else if (window.ActiveXObject) {    
    try {
        req = new ActiveXObject("Msxml2.XMLHTTP");    
    } catch (e){}
    try {     
        req = new ActiveXObject("Microsoft.XMLHTTP"); 
    } catch (e){} 
}  
if (req) {    
    var url = "/engine/modules/ajax/country.php?type=svodka&cntr=" + cntrid + "&sort=" + sort + "&bseas=" + bseas + "&eseas=" + eseas;
    var messcont = (document.all) ? document.all.mess_cont : document.getElementById("mess_cont");
    var countrysvodkatable = (document.all) ? document.all.countrysvodkatable : document.getElementById("countrysvodkatable");
    req.open("GET", url, true); 
    req.onreadystatechange = function() {
        if (req.readyState == 4) {
            if (req.status == 200){
    		messcont = (document.all) ? document.all.mess_cont : document.getElementById("mess_cont");       
	    	if (messcont){messcont.parentNode.removeChild(messcont);}
		if (countrysvodkatable){
                    while (countrysvodkatable.firstChild) {
                        countrysvodkatable.removeChild(countrysvodkatable.firstChild)
		    }
                }
		var s = req.responseText;
		var s = s.replace(/[\r\n]/g, ' ');
                var darray = eval(s);
		outputcountrysvodka(countrysvodkatable, cntrid, bseas, eseas, sort, darray);
            }else{
    		messcont = (document.all) ? document.all.mess_cont : document.getElementById("mess_cont");       
	    	if (messcont){messcont.parentNode.removeChild(messcont);}
                alert("Ошибка: "+req.statusText);
            }
        }else{
     	    if (messcont){messcont.parentNode.removeChild(messcont);}
	    loading_progress();
        }
    }
    req.send(null); //отправка запроса без параметров, т.к. они установлены в url
}
else 
    {alert("Браузер не поддерживает AJAX");}
return false;
}    


