function file(fichier)
{
	if(window.XMLHttpRequest || window.ActiveXObject)
	{
		// Firefox
		if(window.XMLHttpRequest) xhr_object = new XMLHttpRequest();
		// IE
		else
		{
			try
			{
					xhr_object = new ActiveXObject("Msxml2.XMLHTTP");
			} catch(e) {
					xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
			}
		}
    }
    else 
	{
		alert("Votre navigateur ne supporte pas l'objet XMLHTTPRequest...");
		return;
    }

	xhr_object.open("GET", fichier, false);
	xhr_object.send(null);
	if(xhr_object.readyState == 4) return(xhr_object.responseText);
	else return("Pas tres tres bien passé là");
}

function checkmail(email)
{
   var reg = /^[a-z0-9._-]+@[a-z0-9.-]{2,}[.][a-z]{2,3}$/ 
   return (reg.exec(email)!=null)
}
function Trim(myString) { return myString.replace(/\s/g, "") } 
function WriteBox(box,img) { document.getElementById(''+box+'').innerHTML = '<img src="images/icones/'+img+'.jpg" alt="" class="icones" />'; }
function WriteBox2(box,img) { document.getElementById(''+box+'').innerHTML = '<img src="images/icones/'+img+'.png" alt="" class="icones" />'; }
function verifField(texte, SpanId) { if(Trim(texte) != "") { WriteBox(SpanId,'check'); } else { WriteBox(SpanId,'oblig'); } }
function verifEmail(email, SpanId) { if(Trim(email) != "") { if(checkmail(email)) { WriteBox(SpanId,'check'); } else { WriteBox(SpanId,'error_email'); } } else { WriteBox(SpanId,'oblig'); } }
function compareValue(value1, value2, SpanId) { if((Trim(value1) == Trim(value2)) && (Trim(value2) != "")) { WriteBox(SpanId, 'check'); } else { WriteBox(SpanId,'oblig'); } }
function checkOnBlur(element, TxToDisplay) { if(Trim(element.value) == "") element.value = TxToDisplay; }
function checkOnFocus(element, TxToDisplay) { if(Trim(element.value) == TxToDisplay) element.value = ""; }
function verifLogin(login2, SpanId) {
	login = Trim(login2);
	if(login != "") { 
		if(login.length < 3)
		{
			WriteBox(SpanId,'error_length'); 
		}
		else
		{
			var etat = file("scripts/php/comAjax.php?login=" + login); 
			if (etat == "ok") {
				WriteBox(SpanId,'check'); 
			} else { 
				WriteBox(SpanId,'error_login'); 
			}
		}		
	} else { 
		WriteBox(SpanId,'oblig'); 
	} 
}

function addFavoris(TE_id, US_id,numBox)
{
	var etat = file("scripts/php/comAjax.php?toDo=add&TE_id=" + TE_id + '&US_id=' + US_id); 
	if (etat == "ok") {
		WriteBox2('BoxFavoris'+numBox+'','heart_on'); 
	} else { 
		WriteBox2('BoxFavoris'+numBox+'','heart_off'); 
	}
}

function delFavoris(TE_id, US_id,numBox)
{
	var etat = file("scripts/php/comAjax.php?toDo=del&TE_id=" + TE_id + '&US_id=' + US_id); 
	if (etat == "ok") {
		WriteBox2('BoxFavoris'+numBox+'','heart_off'); 
	} else { 
		WriteBox2('BoxFavoris'+numBox+'','heart_on'); 
	}
}

