function border_rouge(nom){
		window.document.getElementById(nom).style.border = "thin solid #FF0000";
	}

function border_normale(nom){
window.document.getElementById(nom).style.borderWidth = '';
window.document.getElementById(nom).style.borderStyle = '';
window.document.getElementById(nom).style.borderColor = '';
	}

function verify_form(arr){
for(i=0;i<arr.length;i++){border_normale(arr[i].id);};
var	ok=1;
var msg='.';
for(i=0;i<arr.length;i++){
	if(arr[i].value==""){border_rouge(arr[i].id);ok=0;};					// on test si le champs est rempli
	if((arr[i].id.indexOf("mail")>-1) || (arr[i].id.indexOf("Mail")>-1)){	//Si c'est un mail on teste la validité du mail
		adresse_email = arr[i].value;arobase = adresse_email.indexOf("@");point = adresse_email.indexOf(".",arobase);mauvais_endroit_point = arobase+1;
		double_point = adresse_email.indexOf("..",arobase);nbr_carac = adresse_email.length - point;double_arobase = adresse_email.indexOf("@",arobase+1);
		if((arobase < 1) || (point <= mauvais_endroit_point) || (adresse_email.length < 5) || (double_point >= 0) || (nbr_carac < 3) || (double_arobase >= 0))
		{msg="El email no es valido,\ngracias por verificar su email.";ok=0; border_rouge(arr[i].id);}
	}
};//for
	if(ok==0){alert(""+msg);arr[0].focus();return false}
	if(ok==1)return true
}

//fonction pour récupérer l'objet en fonction du navigateur
function getObj(item){
  if(document.getElementById) return document.getElementById(item);
  else if(document.all) return document.all[item];
  else if(document.layers){ var obj = document.layers[item]; obj.style = document.layers[item]; return obj; }
	else return null;
}

// prend largeur,hauteur de base, retourne largeur,hauteur
function getPosAbsolute(objet,l,h){
	l += objet.offsetLeft;
	h += objet.offsetTop;
	if(objet.offsetParent == null) return new Array(l,h);
	else return getPosAbsolute(objet.offsetParent,l,h);
}


function popaide(o,sujet,on)
{
	return aideaff(o,sujet,"aide",on);
}

function popimage(o,sujet,on)
{
	return aideaff(o,sujet,"img_",on);
}


function aideaff(o,sujet,div,on)
{
	var a,pos,marge,w;
	a = getObj(div+sujet);
	if( a == null ) return false; 
	if( a.style.visibility == "visible" )
	{	 
		if( on )
		{
			return true; 
		}
		a.style.visibility = "hidden"; 
		return true; 
	} 
	if( !on ) 
	{
		return true; 
	}
	pos = getPosAbsolute(o,0,0); 
	marge = 5; 
	w = Math.min(250,a.offsetWidth); 
	a.style.width = w; 
	if( window.innerWidth != null && (w + pos[0] + o.offsetWidth + marge >= window.innerWidth))
	{
		a.style.left = pos[0] - w - marge;
	} 
	else if( document.body.clientWidth != null && (w + pos[0] + o.offsetWidth + marge >= document.body.clientWidth) )
	{
		a.style.left = pos[0] - w - marge;
	} 
	else
	{
		a.style.left = pos[0] + o.offsetWidth + marge;
	} 
	a.style.top = pos[1] + (o.offsetHeight / 2); 
	a.style.visibility = "visible"; 
	return true; 
}




function addCar(car,champ){
	compt++;
	if(compt<=6)
	{
		document.getElementById(champ).value  += car;
	}
}

function resetCar(champ) {
	if(document.getElementById(champ)){
		document.getElementById(champ).value="";
		compt = 0;
	}
	
}

function openAndWrite(letexte){
	if(letexte != "" ){
		mafenetre = window.open("", "", "width=200,height=50,location=no,menubar=no,scrollbars=no,directories=no,resizable=no,status=no,toolbar=no,screenX=500,screenY=500");
		//On affiche les images
		while(letexte.indexOf('[') != -1){
			var letexte = letexte.replace('[',"<img src='images/");
			var letexte = letexte.replace(']',".gif' />");
		}
		mafenetre.document.write('<html><body><p align="center">');
		mafenetre.document.write(letexte);
		mafenetre.document.write('<br><br><a href="javascript:this.close()">Close</a></p></body></html>');
		mafenetre.document.close();	
		mafenetre.focus();	
 	}
}

function popupWindow(url) {
  window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width=500,height=500,screenX=150,screenY=150,top=150,left=150')
}

function popupSizeWindow(url,width,height) {
  window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width='+width+',height='+height+',screenX=150,screenY=150,top=150,left=150')
}
