function rgb2hex(rgb) {
	if ($rgb = rgb.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/)) {
		function hex(x) {
			hexDigits = new Array("0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f");
			return isNaN(x) ? "00" : hexDigits[(x - x % 16) / 16] + hexDigits[x % 16];
		}
		return "#" + hex($rgb[1]) + hex($rgb[2]) + hex($rgb[3]);
	}
	return rgb;
}

function isArray(obj) {
	return (obj.constructor.toString().indexOf('Array') != -1);
}
function isRegExp(obj) {
	return (obj.constructor.toString().indexOf('RegExp') != -1);
}

var $tmrError;
function _error(message, ele) {
	clearTimeout($tmrError);
	$('._error').remove();
	if (
		(typeof $_message == 'undefined')
		|| (!$_message))
		{

		$_message = 'body';
	}
	if (ele) {
		$in = ele;
	}
	else {
		$in = $_message;
	}
	$($in).prepend('<div class="_error" style="display: none;">'+message+'</div>');
	$('._error').slideDown('normal', function() {
		$tmrError = setTimeout("$('._error').slideUp('normal', function() { $(this).remove(); });", 3000);
	});
}

var $tmrNote;
function _note(message, ele) {
	clearTimeout($tmrNote);
	$('._note').remove();
	if (
		(typeof $_message == 'undefined')
		|| (!$_message))
		{

		$_message = 'body';
	}
	if (ele) {
		$in = ele;
	}
	else {
		$in = $_message;
	}
	$($in).prepend('<div class="_note" style="display: none;">'+message+'</div>');
	$('._note').slideDown('normal', function() {
		$tmrNote = setTimeout("$('._note').slideUp('normal', function() { $(this).remove(); });", 3000);
	});
}
