$(document).ready(function() {
	if(!$.browser.msie) $('ul.sub').corners("bottom");
	
	$('form#contact, form#donate').livequery(function() {
		$(this).submit(function(e) {
			console.log('submitted!');
			var errors = '';
			$('.error_text').remove();
			$('.error_field').removeClass('error_field');
			$.each($(e.target).find(".required"), function(i, elem) {
				if($(elem).val() == '') {
					errors += $(elem).prev("label").text() + " is required.<br />";
					$(elem).addClass('error_field');
					$(elem).after("<span class='error_text'>This field is required.</span>");
				}
			});
			if(errors != '') {
				errors = "<h4>Please fix the following errors and try submitting the form again:</h4>" + errors;
				$('div.error').html(errors).show();
				return false;
			}
		});
	});
	
	$('input[type=submit]').livequery(function() {
		$(this).addClass('button');
	});
	
	$('#sub_nav ul li').each(function(i, n) {
		if(!$(n).hasClass('page_item')) {
			$(n).mouseover(function() {
				$(this).addClass('sfhover');
			});
			$(n).mouseout(function() {
				$(this).removeClass('sfhover');
			});
		}
	});
});

function loadSwf(path, mname, width, height) {
	var src;
	if(path.length == (path.lastIndexOf("/")+1)) src = path + mname;
	else src = path + "/" + mname;
	if (AC_FL_RunContent == 0) {
		alert("This page requires AC_RunActiveContent.js.");
	} else {
		AC_FL_RunContent(
			'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0',
			'width', width,
			'height', height,
			'src', src,
			'quality', 'high',
			'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
			'align', 'middle',
			'play', 'true',
			'loop', 'true',
			'scale', 'showall',
			'wmode', 'transparent',
			'devicefont', 'false',
			'id', mname,
			'bgcolor', '#ffffff',
			'name', mname,
			'menu', 'true',
			'allowFullScreen', 'false',
			'allowScriptAccess','sameDomain',
			'movie', src,
			'salign', ''
			); //end AC code
	}
}