function OuvrirPopup(url,popupdessus,titre,option)
{
	switch(OuvrirPopup.arguments.length)
	{
		case 0:
			url='';
		case 1:
			popupdessus=true;
		case 2:
			titre='_blank';
		case 3:
			option='toolbar=1,location=1,personnalbar=1,status=1,menubar=1,scrollbars=1,resizable=1,height=420,width=760,left=0,top=0,channelmode=0,directories=0';
		default:
	}
	if(url=='')
		url='about:blank';
	fenetre=window.open(url,titre,option);
	if(popupdessus==true)
		fenetre.focus();
	else
		window.focus();
		
	return true;
}

function FermerPopup(retoursurparent)
{
	switch(FermerPopup.arguments.length)
	{
		case 0:
			retoursurparent=false;
		case 1:
			fermerfenetre=true;
		default:
	}
	if(window.opener!=null && retoursurparent==true)
		if(!window.opener.closed)
			window.opener.focus();
	if(fermerfenetre)
		window.close();
}

function DimensionnerPopupParId(id)
{
	var objet=document.getElementById(id);
	window.innerWidth=objet.offsetWidth;
	window.innerHeight=objet.offsetHeight;
	//window.resizeTo(objet.offsetWidth,objet.offsetHeight);
}


function fenetre_ouvrir(url,nom,option)
{
	if(option=='')
		option='toolbar=1,location=1,personnalbar=1,status=1,menubar=1,scrollbars=1,resizable=1,height=500,width=500,left='+((screen.width-500)/2)+',top='+((screen.height-500)/2)+',channelmode=0,directories=0';
	fenetre=window.open(url,nom,option);
	fenetre.focus();
}

function fenetre_fermer()
{
	if(opener!=null)
		if(!opener.closed)
			opener.focus();
	window.close();
}

function parent_verifier(url,mode)
{
	if((top==self && !mode) || (top!=self && mode))
	{
		if (window.opera)
		{
			var balise = document.createElement('a');
			balise.href=url;
			balise.target='_top';
			balise.click();
		}
		else
			top.location=url;
	}
}

function removeChildNodes(childNodes)
{
	var i;
	for(i=childNodes.length-1;i>=0;i--)
	{
		if(childNodes[i].hasChildNodes())
			removeChildNodes(childNodes[i].childNodes)
		try {
			childNodes[i].parentNode.removeChild(childNodes[i]);
		}
		catch(e) {
			alert(e);
		}
	}
}

function removeChildrenFromNode(node)
{
   if(node !== undefined && node !== null)
   {
      return;
   }

   var len = node.childNodes.length;

	while (node.hasChildNodes())
	{
	  node.removeChild(node.firstChild);
	}
}

function vide_noeud(n){
		removeChildNodes(document.getElementById(n).childNodes);
}

function VerifierPattern(pattern,message)
{
	try
	{
		var subject='';
		var pattern=new RegExp(pattern);
		pattern.test(subject);
		if(message)
			alert('Le pattern est CORRECT');
		return true;
	}
	catch(e)
	{
		if(message)
			alert('Le pattern est ERRONE');
		return false;
	}
}

