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

	/* example 1 */
	var button = $('#button1');
	var button2 = $('#button2'), interval;
	
	new Ajax_upload(button,{	
		action: 'upload.php', // I disabled uploads in this example for security reasons		
		name: 'userfile',		
		onSubmit : function(file, ext){
		if (! (ext && /^(mp3|Mp3|mP3|Wav|wav|WAV|M4a|M4A|m4A|m4a)$/.test(ext))){
                        // extension is not allowed
                        alert('Error: invalid file extension');
                        // cancel upload
                        return false;
                } 
	
		/*
		if (ext!="mp3"){
                        // extension is not allowed
                        alert('Error: invalid file extension');
                        // cancel upload
                        return false;
                }*/
			
			// 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 = button2.text();
				if (text.length < 13){
					button2.text(text + '.');					
				} else {
					button2.text('Uploading');				
				}
			}, 200);
		},
		onComplete: function(file, response){
			button2.text('');
			//button2.display = 'none';
			document.forms[0].uploadfileName.value = file;
			window.clearInterval(interval);
			// enable upload button
			this.disable();			
			// add file to the list
			//$('<div></div>').appendTo('#example1 .files').text(file);
					
			$('<li id="tt"></li>').appendTo('#example1 .print').text(file);
			document.getElementById("closeImg").style.display = "block";
			document.getElementById("preview").style.display = "block";

			
		}
	});
	
});/*]]>*/
