function ClearForm(whichField) {
  document.getElementById(whichField).value = "";
}

function updateStatusTextCharCounter(value, e) {
	len = value.length;
    $('#status-field-char-counter').html('' + (140-len));
	if (len > 140) {
		if ($("#update-submit").attr('disabled') != 'disabled') {
			$('#update-submit').attr('disabled', 'disabled')
			$('#update-submit').addClass('update-button-disabled')
		}
	} else {
		if ($("#update-submit").attr('disabled') == true) {
			$('#update-submit').removeAttr('disabled');
			$('#update-submit').removeClass('update-button-disabled')
		}

		if (len > 130) {
			$('#status-field-char-counter').css('color', '#e2e0c8' );
		} else if (len > 120) {
			$('#status-field-char-counter').css('color', '#e2e0c8' );
		} else {
			$('#status-field-char-counter').css('color', '#e2e0c8' );
		}
	}
}

function resetCodeCheck(){
	$("#check_code_response").css("display","none");
	$("#check_code").css("display","block");
	return false;	
}

$(document).ready(function(){
	$("#check_code").submit(function(){
		$("#check_code").css("display","none");
		$("#checking_code").html("<label><img src=\"images/ajax-loader.gif\" id=\"loader-gif\" /> Checking your code ...</label>").animate({display:"toggle"},{duration:5000});
		$("#check_code_response").css("display","block");
//		$("#check_code_response").html("<label>Sorry! There seems to be a problem with your code. <a href=\"#\" id=\"code_retry\" onclick=\"resetCodeCheck(); return false;\">Click here to re-enter your code</a>.</label>");
		$("#check_code_response").html("<label>That code has already been redeemed. Are you sure you entered your code correctly?. <a href=\"#\" id=\"code_retry\" onclick=\"resetCodeCheck(); return false;\">Click here to re-enter your code</a>.</label>");
		return false;
	}
	);
});

