$(function() {
	$('.uploader').hide();
  $('.error').hide();
$('#submit').attr("disabled", true);

$('#agree').click(function() { 	if ($('#agree').attr('checked')) { $('#submit').attr("disabled", false); } else { $('#submit').attr("disabled", true); }	});  

  $("#submit").click(function() {
		// validate and process form
		// first hide any error messages
    $('.error').hide();
    // $("label#email_error").show();
		var email = $("input#email").val();
		if (email == "") {
      $("label#email_error").show();
      $("input#email").focus();
      return false;
    }  
		var title = $("input#title").val();
		if (title == "") {
      $("label#title_error").show();
      $("input#title").focus();
      return false;
    }

		var otherSchool = $("input#otherSchool").val();
		var school = $("select#school").val();
		//alert($("select#school").val());
		if (school == "Other" && otherSchool == "") {
      $("label#school_error").show();
      $("input#otherSchool").focus();
      return false;
    }
		
		var dataString = 'title='+ title + '&email=' + email + '&school=' + school + '&otherSchool=' + otherSchool;
		//alert (dataString);return false;
		
		$.ajax({
      type: "POST",
      url: "/assets/snippets/form_processor/pics.php",
      data: dataString,
      success: function(msg) {
				//alert(msg);
        //$('#contact_form').html("<div id='message'></div>");
        //$('#message').html("<h2>Contact Form Submitted!</h2>")
        //.append("<p>We will be in touch soon.</p>")
        //.hide()
        //.fadeIn(1500, function() {
         // $('#message').append("<img id='checkmark' src='images/check.png' />");				
        //});
				if (msg != 'error' && msg != "") {
						
						$('.uploader-form').hide();
						$('.uploader').show()
							$('.uploader').flash({
										src: "/assets/flash/upload5.swf?sessionID=" + msg,
										width: 320,
										height: 240
								});
				}
      }
     });
    return false;
	});
});
runOnLoad(function(){
  $("input#email").select().focus();
});
