$().ready(function() {	if ($('form[name="newdebtreportform"]')) {		$('form[name="newdebtreportform"]').find('select[name="reported_reason_for_not_paying"]').change(function() {				if ($(this).val() == "other") {					$('#other_not_paying_reason').show();				} else {					$('#other_not_paying_reason').hide();				}			});		$('form[name="newdebtreportform"]').submit(function() {			var formfilled = true;
			$(this).find(':input:visible').each(function() {				if ($(this).attr("type") == "submit" || $(this).attr("type") == "hidden")
					return;				if ($(this).val().length == 0) {					if ($(this).attr("name") == "reported_company_name" ||
						$(this).attr("name") == "reported_address" ||
						$(this).attr("name") == "reported_city" ||
						$(this).attr("name") == "reported_state" ||
						$(this).attr("name") == "reported_zip" ||
						$(this).attr("name") == "reported_phone" ||
						$(this).attr("name") == "reported_total_owed" ||
						$(this).attr("name") == "reporter_company_name" ||
						$(this).attr("name") == "reporter_contact" ||
						$(this).attr("name") == "reporter_email") {						formfilled = false;
						$(this).css("border", "1px solid red");
					}				} else {					$(this).css("border", "1px solid green");				}			});
			if (!formfilled) {				alert('Some required fields are not filled out!');				return false;			}		});	}

	if ($('form[name="massdebtimportform"]')) {		$('#showsetdefaultvaluesbutton').css("visibility", "visible");
		$('#setdefaultvalues').click(function() {			$('.reported_field_order_item').each(function() {				var current_field_index = $(this).attr("name").replace('reported_fields[','').replace(']','') * 1;				$(this).attr("selectedIndex", current_field_index + 1);			});		});
		$('form[name="massdebtimportform"]').submit(function() {
			var formfilled = true;
			$(this).find(':input:visible').each(function() {
				if ($(this).attr("type") == "submit" || $(this).attr("type") == "hidden" || $(this).attr("type") == "button")
					return;
				if ($(this).val().length == 0) {					if ($(this).attr("name") != "reporter_phone") {
						formfilled = false;
						$(this).css("border", "1px solid red");
					}
				} else {
					$(this).css("border", "1px solid green");
				}
			});
			if (!formfilled) {
				alert('You haven\'t filled all the fields out!');
				return false;
			}
		});	}


	if ($('form[name="passwordrequestform"]')) {
		$('form[name="passwordrequestform"]').submit(function() {
			var formfilled = true;
			$(this).find(':input:visible').each(function() {
				if ($(this).attr("type") == "submit" || $(this).attr("type") == "hidden" || $(this).attr("type") == "button")
					return;
				if ($(this).val().length == 0) {
					formfilled = false;
					$(this).css("border", "1px solid red");
				} else {
					$(this).css("border", "1px solid green");
				}
			});
			if (!formfilled) {
				alert('You haven\'t filled all the fields out!');
				return false;
			}
		});
	}});