	jQuery(document).ready(function(){
		
		jQuery("#dialog-comic").dialog({
			autoOpen: false,
			height: 400,
			width: 450,
			modal: true,
			title: "Report this Webcomic",
			close: function() {  },
			buttons: {
				'Sumbit Report': function() {
					challengeField = jQuery("input#recaptcha_challenge_field").val();
					responseField = jQuery("input#recaptcha_response_field").val();
					reportedID = jQuery("input#reportedID").val();
					userID = jQuery("input#userID").val();
					issueID = jQuery("select#issues").val();
					comment = jQuery("textarea#other-comments").val();
					ip = jQuery("input#ip").val();
					//console.log(challengeField);
					//console.log(responseField);
					//return false;
					var html = jQuery.ajax({
						type: "POST",
						url: "/includes/validate-report.php",
						data: "recaptcha_challenge_field=" + challengeField + "&recaptcha_response_field=" + responseField + "&reportedID=" + reportedID + "&userID=" + userID + "&issueID=" + issueID + "&comment=" + comment + "&ip=" + ip,
						async: false
						}).responseText;
				
					//console.log( html );
					if(html == "success") { 
						jQuery('#dialog-link').replaceWith('<span class="right" style="color: #FFF; margin: -28px 5px 0 0;">REPORTED!</span>'); 
						jQuery('#dialog-comic').dialog('destroy');
						// Uncomment the following line in your application
						return true;
					} else {
						jQuery("#captchaStatus").html("The security code you entered did not match. Please try again.");
						Recaptcha.reload();
						return false;
					}

				},
				Cancel: function() {
					jQuery(this).dialog('close');
				}
			}
		 
		});
		
		jQuery('#dialog-link').click(function() {
			jQuery('#dialog-comic').dialog('open');
		});

		
	});