function uploadStarted() {
	postEvent("UPLOAD_STARTED", "I'm not sure how to put the filename here.");
	var uploadButtonE = document.getElementById("uploadButton");
	uploadButtonE.value='Uploading...';
	return true;
}

function uploadComplete(xmlresponse) {
	var uploadButtonE = document.getElementById("uploadButton");
	uploadButtonE.value='Upload Image';

	//alert(xmlresponse);
	//var xmlobject = (new DOMParser()).parseFromString(xmlresponse, "text/xml");
	var results = xmlresponse.getElementsByTagName('results')[0];

	if (results != null) {
		var images = results.getElementsByTagName('image');
		if (images.length > 0) {
			clearImageTable(true);
			imageLoader = new ImagePreloader(onPreload, numImageCells);
			imageLoader.preload(images);
			showImageTool();
		}
		else {
			var error = results.getElementsByTagName('error')[0];
			if (error) {
				alert(error.getAttribute('message'));
			}
		}		
	}
	else {
		// alert("Unable to upload file.");
	}
}

/** 
* 
*  AJAX IFRAME METHOD (AIM) 
*  http://www.webtoolkit.info/ 
* 
**/  
AIM = {  
     frame : function(c) {  
   
         var n = 'f' + Math.floor(Math.random() * 99999);  
         var d = document.createElement('DIV');  
         d.innerHTML = '<iframe style="display:none" src="about:blank" id="'+n+'" name="'+n+'" onload="AIM.loaded(\''+n+'\')"></iframe>';  
         document.body.appendChild(d);  
   
         var i = document.getElementById(n);  
         if (c && typeof(c.onComplete) == 'function') {  
             i.onComplete = c.onComplete;  
         }  
   
       return n;  
     },  
   
     form : function(f, name) {  
         f.setAttribute('target', name);  
     },  
   
     submit : function(f, c) {  
         AIM.form(f, AIM.frame(c));  
         if (c && typeof(c.onStart) == 'function') {  
             return c.onStart();  
         } else {  
             return true;  
         }  
     },  
   
     loaded : function(id) {  
         var i = document.getElementById(id);  
         if (i.contentDocument) {  
             var d = i.contentDocument;  
         } else if (i.contentWindow) {  
             var d = i.contentWindow.document;  
         } else {  
             var d = window.frames[id].document;  
         }  
         if (d.location.href == "about:blank") {  
             return;  
         }  
   
         if (typeof(i.onComplete) == 'function') {
         	if (d.XMLDocument) {
         		i.onComplete(d.XMLDocument);
         	}
            i.onComplete(d);
         }
     }  
}  