	
	
	// Cerca immagini ----------------------------------------------------------------------------------------
	
	var httpSubmit = createRequestObject();
	
	function searchImages(pageNum)
	{
  		str = getFormValues(document.form1);
  		str += "&pageNum="+pageNum;
		httpSubmit.open('post', 'ajaxScripts/updateImmaginiUtenteTable_advSearch.php');
		httpSubmit.onreadystatechange = handleResponse;
		httpSubmit.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=ISO-8859-1");
		httpSubmit.send(str);
		document.getElementById("responseContent").setAttribute("class","loading");
		showResponseLayer();
	}
	
	function handleResponse()
	{
		if(httpSubmit.readyState == 4)
		{
			showResponseLayer();
			var response = httpSubmit.responseXML;
			
			switch(response.getElementsByTagName("exitCode")[0].firstChild.nodeValue)
       		{           				
				case '0':
					var content = response.getElementsByTagName("content")[0].firstChild.nodeValue;
					document.getElementById("responseContent").setAttribute("class","responses");
					document.getElementById("responseContent").innerHTML = content;
           			break;
						
				case '7':
       			case '-1':
       			default:
					var content = response.getElementsByTagName("content")[0].firstChild.nodeValue;
					document.getElementById("responseContent").setAttribute("class","error");
					document.getElementById("responseContent").innerHTML = content;
           			break;
			}
		}
		else
		{
			document.getElementById("responseContent").innerHTML = "Processing data...";
		}
	}
	
	
	function askBeforeDeletingImages(id, pageNum)
	{
		if(confirm("Sei sicuro di voler eliminare questa immagine?"))
		{
			deleteImage(id);
		}
	}
	// Cerca immagini ----------------------------------------------------------------------------------------
	
	// Deleting images --------------------------------------------------------------------------------------
	
	var httpDelete = createRequestObject();
	
	function deleteImage(id)
	{
		httpDelete.open('get', 'ajaxScripts/deleteImage.php?id='+id);
		httpDelete.onreadystatechange = handleDeleteResponse;
		httpDelete.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=ISO-8859-1");
		httpDelete.send(null);
	}
	
	function handleDeleteResponse()
	{
		if(httpDelete.readyState == 4)
		{
			var response = httpDelete.responseXML;
			
			switch(response.getElementsByTagName("exitCode")[0].firstChild.nodeValue)
       		{           				
				case '0':
					updateImmaginiTable();
           			break;
           			
				case '7':
       			case '-1':
       			default:
					updateImmaginiTable();
           			break;
			}
		}
		else
		{
			//document.getElementById("immaginiTable").innerHTML = "<p class=\"testoSemplice\"><b>Reloading table..</b></p>";
		}
	}
	
	// Deleting images --------------------------------------------------------------------------------------
	
	
	