
function checkLogin() {
	var obj = document.getElementById('login');
	if(obj) {
		obj.value.replace(/\s+/, '');
	}
}

function ban(ip, url) {
	if(ip != '') {
		if(window.confirm("Вы уверены, что хотите забанить доступ с адреса '" + ip + "'?")) {
			setTimeout("window.location=\"" + url + "?mode=ban&ip=" + ip + "\"",100);
		}
	}
}

function showRules() {
	var obj = document.getElementById('rules');
	if(obj) {
		obj.style.display = (obj.style.display == 'block') ? ('none') : ('block');
		
	}
}

function showCommentsForm() {
	var obj = document.getElementById('add_comments');
	if(obj) {
		obj.style.display = (obj.style.display == 'block') ? ('none') : ('block');
	}
}

function redirectTo(url) {
	window.location.href = url;
}

function deleteQuote(id,url) {
	var obj = window.confirm("Удалить цитату #" + id + "?");
	if(obj) {
		redirectTo(url + "?mode=delete&q=" + id);
		//window.location.reload(false);
	}
}

function doPreview() {
	var obj = document.getElementById('preview');
	var obj_source = document.getElementById('quote_message');
	if(obj && obj_source) {
		var txt =  obj_source.value
		txt = txt.replace(/(<)(.*)(>)/gi,"<font style='color:#00d;'>&lt;$2&gt;</font>");
		txt = txt.replace(/\*(.*)/,"<font style='color:green;'>* $1</font>");
		txt = txt.replace(/((.*):\ )/,"<font style='color:#00d;'>$1</font>");
		txt = txt.replace(/[\n]/gi,"<br />");
		obj.innerHTML = txt;
	}
}
