//holds all clicked documents
var folder = new Array()

function showSub(docID) {
	//if folder array is set it means that row was clicked
	if (folder[docID]=="set") { 
		$('sub'+docID).innerHTML=""
		$('sub'+docID).hide(); //to remove inner HTML is not enough we have to hide it - in IE would stay break
		delete folder[docID] // Removes the element from array so we now that next click should display content
		return
	} else {
  
		new Ajax.Request('docaction.php', { //url with server file
			method: 'GET',
			parameters: 'q='+docID, //passing paramenters
			onCreate: function() {
			$('sub'+docID).previous(0).setStyle({'cursor':'wait'});
			},
			onComplete: function() {
			$('sub'+docID).previous(0).setStyle({'cursor': 'pointer'});
			},
			onSuccess: function(xhrResponse) {
				$('sub'+docID).show();
				$('sub'+docID).innerHTML = xhrResponse.responseText; //insert response from server to the element with correct id
			},
			onFailure: function(xhrResponse) { //this is on failure
				alert('There was a problem retrieving the data: \n' +
					xhrResponse.statusText
				);
			}
		});
	folder[docID]="set"; //inserts array so we now that it's been called
	}
}

function showInfo(subdocID) {
 
	new Ajax.Request('subdocaction.php', { //url with server file
		method: 'GET',
		parameters: 'q='+subdocID, //passing paramenters
		onCreate: function() {
		$('subdoc'+subdocID).setStyle({'cursor':'wait'});
		},
		onComplete: function() {
		$('subdoc'+subdocID).setStyle({'cursor': 'pointer'});
		},
		onSuccess: function(xhrResponse) {
			$('info').innerHTML = xhrResponse.responseText; //insert response from server to the element with id="bio"
		},
		onFailure: function(xhrResponse) { //this is on failure
			alert('There was a problem retrieving the data: \n' +
				xhrResponse.statusText
			);
		}
	});
}

function clearInfo() {
document.getElementById("info").innerHTML=""
}
