// Declare our request variable.
var request = false;

// Define a function that will make our request for us:
function retrieveSurroundingThumbs(album_id,last_id,action) {
    // Clear the curent request
    request = false;
	var album_id = album_id;
	var last_id = last_id;
	var action = action;
	//alert(album_id);
	//alert(getSelectedCheckbox(checkbox_fields));
    //alert(getSelectedCheckboxValue(checkbox_fields));
	
	// Generate the request object and handle different browsers:
    if (window.XMLHttpRequest) { // Mozilla & other compliant browsers
        request = new XMLHttpRequest();
    } else if (window.ActiveXObject) { // Internet Explorer
        request = new ActiveXObject("Microsoft.XMLHTTP");
    }

    // If we don't have a request object, then error out.
    if (!request) {
        alert('Browser does not support AJAX!');
        return false;
    }

    // Ok, now we are ready.  Make the request, and tell it to run the
    // function 'updateDate' when it gets data back.
    request.onreadystatechange = updateThumbsDiv;

    // Open the connection, sending the current value of the form element:
    request.open('GET',
        'http://www.sibiul.ro/ajax-poze.php?action=' + action + '&album_id=' + album_id + '&last_id=' + last_id)
    request.send(null);
}

// The function that will accept the data, and update the page:
function updateThumbsDiv() {
    // Make sure that the state is '4', which means finished:
    if (request.readyState == 4) {
        // Make sure that the status is 200, or 'ok'
        if (request.status == 200) {
            // And now, update the text on the page:
            var text = document.getElementById('thumbnails_list');
            //text.innerHTML = result.firstChild.data;
			text.innerHTML = request.responseText;
        } else {
            alert('Error performing request!' + request.status);
        }
    }
}

