// JavaScript Document

/*<![CDATA[*/
 
	
$(document).ready(function(){
						   
						   
						   

// You must create it only after the DOM is ready for manipulations
// Use $(document).ready for jquery
// document.observe("dom:loaded" for prototype
var button = $('#button1'), interval;

	
	new AjaxUpload(button,{ 
		action: '/js/upload_sow.php', 
		name: 'myfile',
		onSubmit : function(file, ext){
			// change button text, when user selects file			
			button.text('Uploading'); 
			
			// If you want to allow uploading only 1 file at time,
			// you can disable upload button
			this.disable();
			
			// Uploding -> Uploading. -> Uploading...
			interval = window.setInterval(function(){
				var text = button.text();
				if (text.length < 13){
					button.text(text + '.');					
				} else {
					button.text('Uploading');				
				}
			}, 200);
		},
		onComplete: function(file, response){
			button.text('Simple');
						
			window.clearInterval(interval);
						
			// enable upload button
			this.enable();
			
			if (response != 'error') {
				
				
			 jQuery("#img_div").html('<a href=\"/js/image.php?id='+response+'&custom=sow\" ><img src=\"/images/uploads/'+response+'\" alt=\"Click to Edit Image\" title=\"Click to Edit Image\"></a>'); 
		 
			
			} else {
				
			alert("Invalid file type");
			
			}
			 
			 
		}
		
		
		

		
	}); 

 
	 
});/*]]>*/
	 
  
