// Test les caracteres speciaux
function checkSpecCarac(event){
	return true;
	if( (event.keyCode>=33 && event.keyCode<=47 && event.keyCode!=45) || (event.keyCode>=58 && event.keyCode<=64) || (event.keyCode>=91 && event.keyCode<=96) || (event.keyCode>=123 && event.keyCode<=126) ){
		alert(event.keyCode);
		return false;
	}
	if( (event.which>=33 && event.which<=47 && event.which!=45) || (event.which>=58 && event.which<=64) || (event.which>=91 && event.which<=96) || (event.which>=123 && event.which<=126) ){
		alert(event.which);
		return false;
	}
	return true;
}


// Alertes
$(function(){
	$('#messages, #warnings, #erreurs').show('slow');
});

function alertNotLogged() {
	var div = $('body #not_logged_div');
	if(!div.length){
		var h = 170;
		if($.browser.msie){
			h = 180;
		}
		$('body').prepend('<div id="not_logged_div"><a href="index.php?csaction=site/identification_afficher&width=310&height='+h+'" class="not_logged_thickbox"></a></div>');
		$('body #not_logged_div').hide();
		tb_init('a.not_logged_thickbox');
		div.find('.swicth_content').each(swicth);
	}
	$('body #not_logged_div a').click();
	setTimeout('initSwitch()', 500);
}

function alertOwnArticle() {
	alert('Vous ne pouvez pas buzzer votre propre article  !');
}

function searchMots(){
	var val = $('#bto_recherche input[name=recherche_mots]').val();
	$('#recherche_motsHidden').val(val);
	$('#recherche_motsHidden').parent().submit();
	return false;
	/* $('form#rechercheMot input[name=recherche_mots]').val(val);
	$('form#rechercheMot').submit(); */
}

// Fonction requetage AJAX
function getUrlDecode(url){ // Décodage url
	url = url.replace(/%2F/gi, '/');
	url = url.replace(/&amp;/gi, '&');
	return url;
}
 function formatItem(row) { // Formattage du resultat d'un Autocomplete
	return row[0] + " (<strong>id: " + row[1] + "</strong>)";
}
function formatResult(row) { 
	//console.debug(row);
	//console.debug(row[0].replace(/(<.+?>)/gi, ''));
	return row[0].replace(/(<.+?>)/gi, '');
}

swicth = function(){
	this.oldVal = null;
	this.onfocus = function(){
		if(!this.oldVal){
			this.oldVal = this.value;
		}
		if(this.value==this.oldVal){
			this.value = '';
		}
	}
	this.onblur = function(){
		if(this.value==''){
			this.value = this.oldVal;
		}
	}
}

initSwitch = function(){
	$('.swicth_content').each(swicth);
}

$(initSwitch);