$(function () {
	if($('#sdiff').val() == '0') { $('.shipinfo').hide(); } else { $('.checker').css('background-image','url(images/check.png)'); }
	$('.checker').bind('click',function() {
		if($('.checker').css('background-image')=='none') { $('.checker').css('background-image','url(images/check.png)'); } else { $('.checker').css('background-image',''); }
		$('.shipinfo').toggle('slow');
		if($('#sdiff').val() == '0') { $('#sdiff').attr('value','1'); } else { $('#sdiff').attr('value','0'); }
	});
	$('#trial_table').css('box-shadow','grey 0 0 3px');
	$('#trial_table input').css('box-shadow','grey 0 0 3px');
	$('#ctbut').css('box-shadow','red 0 0 3px');
	$('#ctbut').css('font-size','19px');
	$('#capform').submit(function () {
		var nogo;
		var sdiff = $('#sdiff').val();
		$('#capform input').each(function () {
			if ($(this).val() == '') {
				var myname = $(this).attr('name');
				if (sdiff == 0 && myname[0] !== 's' && myname !== 'baddress2') { nogo = 1; $(this).css('background-color','#E4BCBC'); }
				if (sdiff == 1 && myname !== 'baddress2' && myname !== 'saddress2') { nogo = 1; $(this).css('background-color','#E4BCBC'); }
			}
			$(this).blur(function () { if ($(this).val() !== '') { $(this).css('background-color',''); }});
		});
		if (nogo == 1) { alert('Please correct the highlighted fields.'); return false; }
		return true;
	});
});
