function setDisableCheckbox(checkboxID, setID) {
	$("#" + checkboxID).change(function() {
		if (this.checked) {
			$("#" + setID + " input[id!=" + checkboxID + "]").attr("disabled", "disabled").removeAttr("checked");
			$("#" + setID + " input[type=text]").attr("value", "");
		} else {
			$("#" + setID + " :disabled").removeAttr("disabled");
		}
	});
}


/* Sign up */

function checkUsername(p) {
	var ill = /[^a-zA-Z0-9]/g;
	if (ill.test(p.value)) p.value = p.value.replace(ill, '');
	var reg = /^[a-z0-9]{5,15}$/i;
	if (reg.test(p.value)) {
		p.style.border = '#afa 1px solid';
		p.style.background = '#dfd';
	} else {
		p.style.border = '#faa 1px solid';
		p.style.background = '#fdd';
	}
}

function checkPw(p) {
	var reg = /^[a-z0-9.,;:_\-!?$%#+=\/]{5,15}$/i;
	if (reg.test(p.value)) {
		p.style.border = '#afa 1px solid';
		p.style.background = '#dfd';
	} else {
		p.style.border = '#faa 1px solid';
		p.style.background = '#fdd';
	}
	checkPwConf();
}

function checkPwConf() {
	var pw = $('#pw');
	var ec = $('#pw_conf');
	if (pw != '') {
		if (ec.attr('value') == pw.attr('value')) {
			if (ec.attr('value') == '') return;
			ec.css('border', '#afa 1px solid');
			ec.css('background', '#dfd');
		} else {
			ec.css('border', '#faa 1px solid');
			ec.css('background', '#fdd');
		}
	}
}

/**
 * Limit Textarea
 */
function areaLength(textareaID, charsID, maxlength) {
	var strlength = $('#' + textareaID).val().length;
	if (strlength > maxlength) {
		var text = $('#' + textareaID).val();
		$('#' + textareaID).val(text.substring(0, maxlength));
		strlength = maxlength;
	}
	var left = maxlength - strlength;
	$('#' + charsID).text(left);
}
