function chechLength(obj, errMessageId, maxLength) {
	var errMessage = document.getElementById(errMessageId);
	if (obj.value.length > maxLength - 1) {
		errMessage.style.display = '';
	}
	else {
		errMessage.style.display = 'none';
	}
}

function isUpper(s) {
	return s == s.toUpperCase();
}

function oneCapital(s) {
	if (s.length > 1 && isUpper(s.substr(0, 1)) && isUpper(s.substr(1, 1))) {
		s = s.substr(0, 1) + s.substring(1).toLowerCase();
	}
	return s;
}

function BigOneCapital(s) {
	r = Array();
	t = s.split(" ");
	for (i = 0; i < t.length; i++) {
		r.push(oneCapital(t[i]));
	}

	return r.join(" ");
}

function Undo_up(id, email) {

	$.getJSON('ajax.php',
		{
			id: id,
			email: email,
			action: 'undo_up'
		},
		function(obj) {
			$('#undo_up_msg').html(obj.text);
		}
	);

}

function wopen(url, name, w, h) {
	var cw = (window.screen.width - w) / 2;
	var ch = (window.screen.height - h) / 2;

	popupWin = window.open(url, name, 'width=' + w + ',height=' + h + ',top=' + ch + ',left=' + cw + ',resizable=0');
	popupWin.focus();
	return false;
}
