//variable pour l'effacement du texte dans le moteur de recherche
var erased_annuaire = false;

//on enleve les erreurs eventuelles
function no_error()
{ return true; }
window.onerror = no_error;

function open_popup(page,hauteur,largeur)
//ouvre une popup
{ window.open(page,"Popup","status=no,scrollbars=yes,resizable=no,height="+hauteur+",width="+largeur+",top=0,left=0"); }

function confirm_delete(page, texte)
//demande une confirmation avant de supprimer un site ou une categorie
{
    confirmation = confirm('Etes vous sur de vouloir supprimer '+texte+' ? ');
    if(confirmation)
        window.location.replace(page);
}

function message_annu_status(message)
//affiche un texte dans la barre de statut du navigateur
{ window.status = message; }

function check_id_cat()
//verifie si on a bien selectionner une categorie dans la liste deroulante
{
    if (document.getElementById('id_cat').value == 0)
    {
        alert('Veuillez sélectionner une catégorie !');
        return false;
    }
    else
    { return true; }
}

/***********************************************
* Form Field Progress Bar- By Ron Jonk- http://www.euronet.nl/~jonkr/
* Modified by Dynamic Drive for minor changes
* Script featured/ available at Dynamic Drive- http://www.dynamicdrive.com
* Please keep this notice intact
***********************************************/

function textcounter(field,counter,maxlimit,linecounter) {
	// text width//
	var fieldWidth =  parseInt(field.offsetWidth);
	var charcnt = field.value.length;        

	// trim the extra text
	if (charcnt > maxlimit) { 
		field.value = field.value.substring(0, maxlimit);
	}

	else { 
	// progress bar percentage
	var percentage = parseInt(100 - (( maxlimit - charcnt) * 100)/maxlimit) ;
	document.getElementById(counter).style.width =  parseInt((fieldWidth*percentage)/100)+"px";
	document.getElementById(counter).innerHTML="Limit: "+percentage+"%"
	// color correction on style from CCFFF -> CC0000
	setcolor(document.getElementById(counter),percentage,"background-color");
	}
}

function setcolor(obj,percentage,prop){
	obj.style[prop] = "rgb(80%,"+(100-percentage)+"%,"+(100-percentage)+"%)";
}
