jQuery.noConflict();

jQuery(function(){
		var btnUpload=jQuery('#upload');
		var status=jQuery('#status');
		var count=1;
		new AjaxUpload(btnUpload, {
			action: 'processing/profile_image.php',
			name: 'uploaded_img',
			onSubmit: function(file, ext){
				 if (! (ext && /^(JPG|jpg|png|jpeg|gif)$/.test(ext))){ 
                    // extension is not allowed 
					status.text('Only JPG, PNG or GIF files are allowed');
					return false;
				}
				if(count >1)
				{
					status.text('Profile image already Uploaded');
					return false;
				}
				document.getElementById('status').innerHTML ='<img src="public/images/spinner.gif" style="width:43px; height:43px;"/> Uploading...';
			},
			onComplete: function(file, response){
				//On completion clear the status
				status.text('');  
				//Add uploaded file to list
				if(response==="success"){
					document.getElementById('profile_img').innerHTML ='<img src="public/images/members/'+file+'>Profile image has been changed refresh browser to see your recent changes';
					
				} else{
					document.getElementById('profile_img').innerHTML ='ERROR';
				}
				count++;
			}
		});
		
	});
