function limit(obj)
{
	if(obj.value.length>512) obj.value = obj.value.substr(0,512);
}
function trim(str)
{
	return str.replace(/(^\s*)|(\s*$)/g,'');
}
function empty(obj, changeType)
{
	if(obj.value==obj.defaultValue){
		obj.value='';
		if(changeType!=undefined && changeType){
			obj.type="password";
			obj.focus();
		}
	}
}
function fill(obj, changeType)
{
	if(trim(obj.value)==""){
		obj.value=obj.defaultValue;
		if(changeType!=undefined && changeType){
			obj.type="text";
		}
	}
}
function verif(obj, full)
{
	if(full)
	{
		empty(obj.shout_pseudo);
		empty(obj.shout_psw);
		empty(obj.shout_text);
		obj.shout_pseudo.value = trim(obj.shout_pseudo.value);
		obj.shout_psw.value = trim(obj.shout_psw.value);
		obj.shout_text.value = trim(obj.shout_text.value);
		if(obj.shout_pseudo.value=="" || obj.shout_text.value=="" || obj.shout_psw.value=="")
		{
			alert('Vous devez un pseudo, un mot de passe et un message avant de poster');
			if(obj.shout_pseudo.value=="") obj.shout_pseudo.reset();
			if(obj.shout_psw.value=="") obj.shout_pseudo.reset();
			if(obj.shout_text.value=="") obj.shout_pseudo.reset();
			return false;
		}
	}
	else
	{
		empty(obj.shout_text);
		obj.shout_text.value = trim(obj.shout_text.value);
		if(obj.shout_text.value=="")
		{
			alert('Vous devez un message avant de poster');
			obj.shout_text.reset();;
			return false;
		}
	}
	return true;
}
function openSmiliesWindow()
{
	window.open("smilies.html","shout_smilies","width=250,height=500,location=no,menubar=no,resizable=no,scrollbars=yes,status=yes,toolbar=no,dependant=yes");
}
function openArchivesWindow()
{
	window.open();
}
function addsmilie(text)
{
	var txtarea = document.shout_form.shout_text;
	empty(txtarea);
	text = ' ' + text + ' ';
	if (txtarea.createTextRange && txtarea.caretPos) {
		var caretPos = txtarea.caretPos;
		caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? caretPos.text + text + ' ' : caretPos.text + text;
		txtarea.focus();
	} else {
		txtarea.value  += text;
		txtarea.focus();
	}
}
