$(document).ready(function(){	
	/* SUBMIT BUTTON */
	$('#button_name').focus(function() {this.value = "";});
	$('#button_email').focus(function() {this.value = "";});
	var upload = new Ajax_upload('#uploadbutton', {
	  // Location of the server-side upload script
	  action: '../index.php/home/submit_button',
	  // File upload name
	  name: 'button',
	  // Additional data to send
	  data: {
	    name : $('#button_name').val(),
	    email : $('#button_email').val()
	  },
	  // Submit file after selection
	  autoSubmit: false,
	  onSubmit: function(file, ext) {
		if (! (ext && /^(jpg|png|jpeg|gif)$/.test(ext))){
			// extension is not allowed
			alert('Error: Allowed jpg, jpeg, png, and gif only');
			// cancel upload
			return false;
		} else {
			$('.allowed_types').html("<img src='../images/loader.gif' />");
		}		
	  },
	  onComplete: function(file, response) {
		$('#submit_button_container').slideUp('slow', function() {
			//alert(response);
			$(this).html("<p>Thanks for your submission! We will review your button, then add it to the collection if you did a good job on it.</p>");
		}).slideDown('slow');
	  }
	});
	$('#submit_button').click(function() {
		upload.submit();
	})
});