$(function() {  

$('input[name="enquiry_type"]').live('click', function(){
	if($(this).val() == 'Work') {
		$('#resume').fadeIn('slow');
	} else {
		$('#resume').fadeOut('slow');		
	}
});

$('#userfile').live('change', function() {
	upload_file();
});

$(".button").live('click', function() {
    var form_data = $("#content_html form").serialize();
    var form_url = $("#content_html form").attr("action");
 
    $.ajax({
      type: "POST",
      url: form_url,
      data: form_data,
      dataType: "json",
      success: function(data) {
        if (data.success) {
          $("#content_html form").hide();
          $("#content_html .success").fadeIn('slow');
        } else {
          $("#content_html .error").text(data.msg);
          $("#content_html .error").fadeIn('slow');
        }
      }
    });

    return false;

  });
  
  $("#content_html form").live('click', function() {
    $("#content_html .error").fadeOut('slow');
  });
});

function upload_file() {
		$('#file_upload').submit();
		$('.button').attr('disabled', true);
		$("#content_html .error").text('Checking the file, please wait...');
		$("#content_html .error").fadeIn('slow');
	}
	
	function upload_file_complete(file,status) {
		if (status=='complete') {
			$('#file').val(file);
			$('.button').attr('disabled', false);
			$("#content_html .error").fadeOut('slow');
			$('#upload_status').html(file + ' is now attached.');
		}
		
		if (status=='error') {
			 $("#content_html .error").text(file);
		}
	}
