function cache_popup(nom_popup)
{
	popup = document.getElementById(nom_popup);
	popup.style.display = "none";
}

function affiche_popup(nom_popup)
{
	popup = document.getElementById(nom_popup);
	popup.style.display = "block";
}

function deroule_popup(nom_popup)
{
	popup = document.getElementById(nom_popup);
	popup.style.right="-350";
	scroll_popup("-100",nom_popup);
}

function scroll_popup(Y,nom_popup)
{	
	window.scrollTo(0,0);
	if ( Y!=2 )
	{
		Ypos=Y;
		popup = document.getElementById(nom_popup);
		popup.style.right=Ypos;
		Ypos=parseInt(Ypos)+2;
		tim=window.setTimeout(function() { scroll_popup(Ypos,nom_popup); }, 5);
	}
	else
	{
		window.clearTimeout(tim);
	}
}

function recupValeurURL(chaine)
{
	var adres=self.parent.location;

	URL=adres.toString();
	resURL=URL.split('?');
	
	var vTEST=eval("/"+chaine+"=/");
	resTEST=vTEST.test(resURL);

	if ( resTEST )
	{
		resURLbis=resURL[1].split("&");
		for ( i=0 ; i<resURLbis.length ; i++ )
		{
			var vTEST=eval("/"+chaine+"=/");
			resTEST=vTEST.test( resURLbis[i] );

			if ( resTEST)
			{
				var res=resURLbis[i].split("=");
			}
		}
		return res[1];
	}
}


function affecter_param(url,parm)
{
	var valeur=recupValeurURL(parm);
	var toto=url+"?"+parm+"="+valeur;
	self.parent.location=toto;
}

function display_html(txt,var_div)
{
	document.getElementById(var_div).innerHTML=txt;
	affiche_popup(var_div);
}

function display_xml()
{
}

function display_alert(txt,var_div)
{
	cache_popup(var_div)
	alert(txt);
}

function open_popup(nom_popup)
{
	popup = document.getElementById(nom_popup);
	popup.style.display = "block";
}

function close_popup(nom_popup)
{
	popup = document.getElementById(nom_popup);
	popup.style.display = "none";
}

function getElemRefs(id)
{
	var el = (document.getElementById)? document.getElementById(id): (document.all)? document.all[id]: (document.layers)? document.layers[id]: null;
	if (el) el.css = (el.style)? el.style: el;
	return el;
}

function showLayer(id)
{
	var lyr = getElemRefs(id);
	if (lyr && lyr.css)
		lyr.css.display = "block";
}

function hideLayer(id)
{
	var lyr = getElemRefs(id);
	if (lyr && lyr.css) 
		lyr.css.display = "none";
}

function displayLayer(id)
{
	var lyr = getElemRefs(id);
	if (lyr && lyr.css) 
		lyr.css.display = "block";
}

function dontDisplayLayer(id) 
{
	var lyr = getElemRefs(id);
	if (lyr && lyr.css) 
		lyr.css.display = "none";
}

function toggleDisplayLayer(id)
{
	var lyr = getElemRefs(id);
	if (lyr.css.display == "none")
	{
		displayLayer(id);
	}
	else 
	{
		dontDisplayLayer(id);
	}
}

function displayOnglet(id)
{
	var lyr = getElemRefs(id);
	if (lyr && lyr.css) 
		lyr.css.display = "block";
}

function dontDisplayOnglet(id)
{
	var lyr = getElemRefs(id);
	if (lyr && lyr.css) 
		lyr.css.display = "none";
}

function toggleDisplayOnglet(id)
{
	var lyr = getElemRefs(id);
	if (lyr.css.display == "none")
	{
		displayOnglet(id);
	}
	else 
	{
		dontDisplayOnglet(id);
	}
}

function showDiv(id)
{
	var lyr = getElemRefs(id);
	if (lyr && lyr.css) 
		lyr.css.display = "block";
}

function hideDiv(id)
{
	var lyr = getElemRefs(id);
	if (lyr && lyr.css) 
		lyr.css.display = "none";
}

function goblink_id(freq,nom_id,text_1,text_2)
{
	blink_tab = document.getElementById(nom_id);
	go_visibility = blink_tab.innerHTML;
	if(blink_tab.innerHTML != text_1)
	{
		blink_tab.innerHTML = text_1;
	}
	else
	{
		blink_tab.innerHTML = text_2;
	}
	setTimeout(function(){goblink_id(freq,nom_id,text_2,text_1)}, freq);
}

function removeSpaces(string)
{
	return string.split(' ').join('');
}

function checkEmail(a_mail)
{
	mymail			= a_mail;
	var mail_err	= 0
	var r_mail		= /^([a-z0-9]+([a-z0-9-_]+)*\.)*[a-z0-9]+([-_]?[a-z0-9]+)*@([a-z0-9]+([-_]?[a-z0-9]+)*\.)+[a-z]{2,4}$/
	ok_mail			= r_mail.exec(mymail);
	
	if (!ok_mail)
	{
		return false;
	}
	else
	{
		return true;
	}
}

