function clearBox(box) {
	box.value = "";
	box.style.color = "black";
	box.onfocus = null;
}

function showElement(element) {
	$(element).show();
}

function hideElement(element) {
	$(element).hide();
}

function randomString(length) {
	var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
	var string_length = length;
	var randomstring = '';
	for (var i=0; i<string_length; i++) {
		var rnum = Math.floor(Math.random() * chars.length);
		randomstring += chars.substring(rnum,rnum+1);
	}
	return randomstring;
}

var prevText = null;

/* cache le lightwindow apres le login */ 
function popupLoginOK(username) {
	myLightWindow.deactivate();
	$('login_info').innerHTML = username + " | <a class=\"lien_logout\" href=\"/logout.php\">d&eacute;connexion</a>";
			
	if (prevText != null) {
		setTimeout("sendComment(prevTitle, prevText, prevOriginalpost)", 0);
	}
}

function isValidEmailAddress(str) {
	var reponse = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/;
 	return reponse.test(str);
}

/* lightwindow pour le vote */
function votePopup() {
	lightwindowInit();
	myLightWindow.activateWindow( {
			href: '/common/include/login-only.php?id=<?php echo $id; ?>', 
			title: 'Voter',
			height: '280',
			width: '400'});
}