function uploadfile() {

var button = $('button1'), file_li = $$('#up .files')[0], interval;
new Ajax_upload(button,{
	action: 'upload.php', 
	name: 'userfile',
	onSubmit : function(file, ext){

		// change button text, when user selects file			
		button.update('Uploading');

		// If you want to allow uploading only 1 file at time,
		// you can disable upload button
		this.disable();

		// Animating upload button
		// Uploding -> Uploading. -> Uploading...
		interval = window.setInterval(function(){
			var text = button.innerHTML;
			if (text.length < 13){
				button.update(text + '.');					
			} else {
				button.update('Uploading');				
			}
		}, 200);			
	},
	onComplete: function(file, response){
	//	console.log(response);
		button.update('Upload');
		window.clearInterval(interval);

		// enable upload button
		this.enable();

		// add file to the list			
		file_li.insert(new Element('li').update(file));						
	}
});

}

document.observe("dom:loaded", function() {

	uploadfile();

});	