jQuery.noConflict();

jQuery(function($){
	
	$warning = $('#signatureRequired');
	$confirm = $('#sigReqConfirm');
	$continue = $('#ccp0--coform--SUBMIT');
	$shipOpt = $('input.khxc_formfieldradcb', '#ccp0--coform');
	
	if($('input.khxc_formfieldradcb:checked', '#ccp0--coform').hasClass('sig_req')){
		$warning.fadeIn(500);
		$continue.attr('disabled', true).val('Please agree to shipping terms');
	} else {
		$warning.fadeOut(500, function(){
			$warning.css({'background':'#ffbc08'})
		});
		$confirm.removeAttr('checked');
		$continue.removeAttr('disabled').val('Continue');
	}
	
	$shipOpt.click(function(){
		$opt = $(this);
		if($opt.hasClass('sig_req')){
			$warning.fadeIn(500);
			if(!$confirm.is(':checked')) $continue.attr('disabled', true).val('Please agree to shipping terms');
		} else {
			$warning.fadeOut(500, function(){
				$warning.css({'background':'#ffbc08'})
			});
			$confirm.removeAttr('checked');
			$continue.removeAttr('disabled').val('Continue');
		}
	});

	$confirm.click(function(){
		if($confirm.is(':checked') || $confirm.checked){
			$warning.css({'background':'#aaff7f'});
			$continue.removeAttr('disabled').val('Continue');
		} else {
			$warning.css({'background':'#ffbc08'});
			$continue.attr('disabled', true).val('Please agree to shipping terms');
		}
	});
});