function switchClass(o,c) {
	o.className = c;
}
function isValidEmail(email) {
	ok = true;
	len = email.length;

	if (email.indexOf('@') == -1 || email.indexOf('@') == 0)
		ok = false;
	if (email.indexOf('@') == len)
		ok = false;

	if (email.indexOf('.') == -1 || email.indexOf('.') == 0)
		ok = false;
	if (email.indexOf('.') == len)
		ok = false;
	
	return ok;
}
function makeRequest(url_href) {
	url_href += "&rnd=" + Math.random();
	if (window.XMLHttpRequest) {
		http_request = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		http_request = new ActiveXObject("Microsoft.XMLHTTP");
	}
	http_request.onreadystatechange = getResult;
	http_request.open('GET', url_href, true);
	http_request.send(null);
}
function getResult() {
	if (http_request.readyState == 4) {
		if (http_request.status == 200) {
			res = http_request.responseText.split(":");
			parseResults(res);
		} else {
			//alert("Impossible to connect to the server. Please check your internet connection."); 
		}
	}
}
function getElementsByClass(searchClass,node,tag) {
	var classElements = new Array();
	if ( node == null )
		node = document;
	if ( tag == null )
		tag = '*';
	var els = node.getElementsByTagName(tag);
	var elsLen = els.length;
	var pattern = new RegExp("(^|\\\\s)"+searchClass+"(\\\\s|$)");
	for (i = 0, j = 0; i < elsLen; i++) {
		if ( pattern.test(els[i].className) ) {
			classElements[j] = els[i];
			j++;
		}
	}
	return classElements;
}
function trim(sString) {
	while (sString.substring(0,1) == ' ') {
		sString = sString.substring(1, sString.length);
	}
	while (sString.substring(sString.length-1, sString.length) == ' ') {
		sString = sString.substring(0,sString.length-1);
	}
	return sString;
}
function goTo(url) {
	window.location = url;
}
function showUp(url,width,height) {
	if (width == 'undefined' && height == 'undefined') {
		width = screen.width;
		height = screen.height;
	}
	eval("page_open = window.open('" + url + "','','scrollbars=1,width=" + width + ",height=" + height + "');");
}
function isOk(msg) {
	goOn = confirm(msg);
	return goOn;
}
function editTopic(tid) {
	$("#criar-topico").hide('fast');
	$("#editar-topico").show('slow');
	$("#editar-topico input[name='tid']").attr('value',tid);
	t_title = $("#tid-" + tid).text();
	$("#editar-topico input[name='title']").attr('value',t_title);
}
function cancelEditTopic() {
	$("#editar-topico").hide('fast');
	$("#criar-topico").show('slow');
	$("#editar-topico input[name='tid']").attr('value',0);
	$("#editar-topico input[name='title']").attr('value','');
}
function editPost(pid) {
	$("#criar-resposta").hide('fast');
	$("#editar-resposta").show('slow');
	$("#editar-resposta input[name='pid']").attr('value',pid);
	p_text = $("#pid-" + pid).text();
	$("#editar-resposta textarea[name='text']").attr('value',p_text);
}
function cancelEditPost(pid) {
	$("#editar-resposta").hide('fast');
	$("#criar-resposta").show('slow');
	$("#editar-resposta input[name='pid']").attr('value',0);
	$("#editar-resposta textarea[name='text']").attr('value','');
}