function submitCheck()
{
	var valchk = true;
	if($("form#donation-form").children("#error_msg"))
	{
		$("form#donation-form").children("#error_msg").remove();
	}
	if($("input:radio[name=amt]:checked").val() == undefined && $("input:text[name=other_amt").val() == undefined)
	{
		valchk = false;
	}
	$("label.required").each(function(index) {
		if($(this).siblings("input:text").val() == "" || $(this).siblings("input:text").val() == undefined)
		{
			valchk = false;
			$(this).siblings("input").css("background","yellow");
		}
	});
	if(valchk == false) { 
		$("form#donation-form").prepend("<div id='error_msg' class='required'>Please make sure all required fields are filled in and an amount is selected.</div>");
		$("div#error_msg").css("background", "#FF0000").css("color","#FFFFFF").css("padding","5px").css("margin","0 0 10px 0");
	}
	
	var otherval = $("input#amt_f").val();
	var amtval = $("input:radio[name=amt]:checked").val();
	
	if(otherval != undefined && otherval != "")
	{
		$("input[name=amt_value]").val(otherval);
	}
	else
	{
		$("input:hidden[name=amt_value]").val(amtval);
	}
	
	return valchk;
}

$(function()
{
	$("a.external").newWin();
	$('.hp_slideshow').cycle('fade');
	$("#btn_donate_submit").click(function(){
		var mess = "<h3>These are the results of an Arc of Orleans donation submission.</h3><table>" + $("#donation-summary").html() + "</table>";
		$("tbody.tribute h3", mess).attr("style","padding-top: 20px;");
		$.ajax({
			url: "/struct/gpx/controller/DonationForm.php",
			data: ({method:"sendmail", msgtoarc: mess}),
			type: "POST",
			success: function(data){
				if(data == "1")
				{
					$("#paypal_donate").submit();
				}
				else
				{
					alert("There was an error processing your request. Please try to resubmit. DATA: " + data);
				}
			},
			error: function(XMLHttpRequest, textStatus, errorThrown){
				alert("An error was encountered while processing your request.\nError code: " + errorThrown + "\nRequest: " + XMLHttpRequest);
			}
		});
		return false;
	})
});

/*
jQuery New Window Plugin
Author: Shane Riley
Author URL: http://shaneriley.com
Version: 1
Description: To keep the doctype strict and pass validation, you need to open
links in a new target using Javascript (no more using the target attribute).
This plugin makes opening links in new targets stupid simple. Default target is
"_blank", but you can feed it a different target like in the example below.
Usage: $("a").newWin({target: "_parent"});
*/
(function($)
{
	$.fn.newWin = function(options)
	{
		var defaults =
		{
			target: "_blank"
		};
		var opts = $.extend(defaults, options);
		return this.each(function()
		{
			$(this).click(openWin);
		});
		function openWin()
		{
			$link = $(this);
			window.open($(this).attr("href"), opts.target);
			return false;
		}
	};
})(jQuery);
