var intrvl;
function selectcountry(countryid){
	gde(countryid);
	if(lastcountry!=0){
		document.getElementById('selimg'+lastcountry).innerHTML='&nbsp;';
		document.getElementById('flagtd'+lastcountry).setAttribute("bgcolor","");
		document.getElementById('linktd'+lastcountry).setAttribute("bgcolor","");
	}
	lastcountry=countryid;
	document.getElementById('selimg'+countryid).innerHTML='<img src="i/s3.gif" width="11" height="22" />';
	document.getElementById('flagtd'+countryid).setAttribute("bgcolor","#07CDFF");
	document.getElementById('linktd'+countryid).setAttribute("bgcolor","#07CDFF");
}

function gde(id){
		parametrer=new Array();
		parametrer['countryid']=id;
		document.getElementById('gdeloading').style.visibility='visible';
		op_ajax_knop();
}

var console=null;

/*
Создание XMLHttpRequest-объекта
Возвращает созданный объект или null, если XMLHttpRequest не поддерживается
*/
function createRequestObject() {
    var request = null;
    try {
        request=new ActiveXObject('Msxml2.XMLHTTP');
    } catch (e){}
    if(!request) try {
        request=new ActiveXObject('Microsoft.XMLHTTP');
    } catch (e){}
    if(!request) try {
        request=new XMLHttpRequest();
    } catch (e){}
    return request;
}

/*
Кодирование данных (простого ассоциативного массива вида { name : value, ...} в
URL-escaped строку (кодировка UTF-8)
*/
function urlEncodeData(data) {
    var query = [];
    if (data instanceof Object) {
        for (var k in data) {
            query.push(encodeURIComponent(k) + "=" + encodeURIComponent(data[k]));
        }
        return query.join('&');
    } else {
        return encodeURIComponent(data);
    }
}

/*
Выполнение POST-запроса 
url  - адрес запроса
data - параметры в виде простого ассоциативного массива { name : value, ...} 
callback - (не обяз.) callback-функция, которая будет вызвана после выполнения запроса и получения ответа от сервера
*/

function serverRequest(url, data, callback) {
    var request = createRequestObject();
    if(!request) return false;
    request.onreadystatechange  = function() { 
            if(request.readyState == 4 && callback) callback(request);
        };
    request.open('POST', url, true);
    
        request.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
    request.send(urlEncodeData(data));
    return true;
}

function op_callback(request) {
		resp=request.responseText;
		var str01,br;
		str01=new String(resp);
		
		document.getElementById('gdediv').innerHTML=str01+'<div style="position:absolute;top:50%; left:50%; visibility:hidden" id="gdeloading"><img src="./images/loading.gif" border="0" alt="" width="32" height="32" /></div>';
		
}
function op_ajax_knop(){
//console=document.getElementById('console');
serverRequest("./gde.php",parametrer,op_callback);
}
