function ajax_request() {

var ip = $("input#ip-address").val().replace(/^\s*|\s*$/g,'');
var port = $("input#port-number").val().replace(/^\s*|\s*$/g,'');

if (ip && port) {
	$.ajax({
	    type: 'GET', url: '/ajax/proxy.php', data: 'send='+ip+':'+port, dataType: 'html', timeout: 5000,
	    beforeSend: function() {
	        $('#ajax-response').html('<p align="center"><img src="/ajax/ajax-loader.gif" width="32" height="32" /></p>');
	    },
	    error: function() {
	        $('#ajax-response').html('<p align="center"><b>Serwer nie odpowiada</b></p>');
	    },
	    success:  function(html) { 
		var proxy = html.split("|");
		$("#ajax-response").html('<p>Adres: <b>'+proxy[0]+'</b><br/>Typ: <b>'+proxy[1]+'</b><br/>Kraj: <b>'+proxy[2]+'</b></p>'); 
	    }
	});
}
}

function chckListElem(id) {
        var ip = $("td#ip")[id].textContent;
	var port = $("td#port")[id].textContent;

	$.ajax({
	    type: 'GET', url: '/ajax/proxy.php', data: 'send='+ip+':'+port, dataType: 'html', timeout: 5000,
	    beforeSend: function() {
	        $("td#response")[id].innerHTML = '<img src="/ajax/progress-bar.gif" width="16" height="16" style="border:0px" />';
	    },
	    error: function() {
	        $("td#response")[id].innerHTML = '<font color="#C03939"><b>Nie działa</b></font>';
	    },
	    success:  function(html) { 
		$("td#response")[id].innerHTML = '<font color="#008E00"><b>Działa</b></font>'; 
	    }
	});
}

function checkList() {

var iplist = $("textarea#lista").val();

if (iplist) { 
        $.ajax({
            type: 'POST', url: '/results.php', data: 'lista='+iplist, dataType: 'html',
            beforeSend: function() {
                $('#proxy-form').html('<p align="center"><img src="/ajax/ajax-loader.gif" width="32" height="32" style="border:0" /></p>');
            },
            error: function() {
                $('#proxy-form').html('<p align="center"><b>Serwer nie odpowiada</b></p>');
            },
            success:  function(html) {
                $("#proxy-form").html('<center><table border="0"><tr><td>'+html+'</td></tr></table></center>');
            }
        });

}
}
