function classChange(elementid,newclass) {
	document.getElementById(elementid).className = newclass;
	}


function insertion(repdeb, repfin, formname, txtareaname) {
	var input = document.forms[formname].elements[txtareaname];
	input.focus();
	/* pour l'Explorer Internet */
	if(typeof document.selection != 'undefined') {
		/* Insertion du code de formatage */
		var range = document.selection.createRange();
		var insText = range.text;
		range.text = repdeb + insText + repfin;
		/* Ajustement de la position du curseur */
		range = document.selection.createRange();
		if (insText.length == 0) {
			range.move('character', -repfin.length);
		} 
		else {
			range.moveStart('character', repdeb.length + insText.length + repfin.length);
		}
		range.select();
	}
	/* pour navigateurs plus récents basés sur Gecko*/
	else if(typeof input.selectionStart != 'undefined') {
		/* Insertion du code de formatage */
		var start = input.selectionStart;
		var end = input.selectionEnd;
		var insText = input.value.substring(start, end);
		input.value = input.value.substr(0, start) + repdeb + insText + repfin + input.value.substr(end);
		/* Ajustement de la position du curseur */
		var pos;
		if (insText.length == 0) {
			pos = start + repdeb.length;
		} 
		else {
			pos = start + repdeb.length + insText.length + repfin.length;
		}
		input.selectionStart = pos;
		input.selectionEnd = pos;
	}
}


var timeoutID;
function resizeImage(image,size,pixStep,timeStep)
	{
	clearTimeout(timeoutID);
	timeoutID = setTimeout("increaseSize(" + image.id + ", " + size + ", " + pixStep + ", " + timeStep + ")",timeStep);
	}


function increaseSize(image,size,pixStep,timeStep)
	{
	if (image.width != size)		// Tant que l'image n'a pas la bonne taille...
		{
		if (image.width > size)	// Si l'image est plus grande que voulu, on diminue la taille
			{
			if ((image.width - size) < pixStep) pixStep = (image.width - size);
			image.width = image.width - pixStep;
			}
		else						// Si l'image est plus petite que voulu, on augmente la taille
			{
			if ((size - image.width) < pixStep) pixStep = (size - image.width);
			image.width = image.width + pixStep;
			}
		timeoutID = setTimeout("increaseSize(" + image.id + ", " + size + ", " + pixStep + ", " + timeStep + ")",timeStep);
		}
	}	
	
/*
** Fonction permettant d'afficher/cacher un objet de type block (<p>, <div>, ...)
** @params : objId : l'id de l'objet à afficher/cacher
*/
function changeVisibility(objId) {
		obj = document.getElementById(objId);
		if (obj.style.display == "none") obj.style.display = "block";
		else obj.style.display = "none";
	}

/*
** Fonction permettant d'afficher/cacher une ligne de tableau <tr>
** @params : objId : l'id de la ligne à afficher/cacher
** @params : display : 3 valeurs possibles : show (afficher), change (modifier le statut), hide (cacher)
*/
function changeTableLineVisibility(objId, display) {
	obj = document.getElementById(objId);
	var bidule = "table-row";
	if(navigator.appName == "Microsoft Internet Explorer") { // Boooooouh le vilain hack pour IE... 
		bidule = "inline";
		}
	if(display == "show") obj.style.display = bidule;
	else if(display == "hide") obj.style.display = "none";
	//~ if (obj.style.display == "none") obj.style.display = bidule;
	//~ else obj.style.display = "none";
	return false;
	}


/*
** Fonction de vérification du formulaire de demande d'informations
** @params : formId : l'id du formulaire à vérifier
*/
function checkForm(formId) {
	var form = document.getElementById(formId);
	if(form.nom.value.length < 3 || form.prenom.value.length < 3) {
		alert('Veuillez entrer une valeur pour le champ "Nom" et le champ "Prénom" !');
		return false;
	}
	if(checkMail(form.email.value) == false) {
		alert('Veuillez entrer une adresse e-mail valide !');
		return false;
	}
}

/*
** Fonction de vérification de la validité d'une adresse mail
*/
function checkMail(emailAddress) {
	var x = emailAddress;
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (filter.test(x)) return true;
	else return false;
}


/****************************************************/
String.prototype.trim = function() {
    return this.replace(/(?:^\s+|\s+$)/g, "");
}

