function change(str)
{
	return (str.replace(",","&"));
}

function loadPg(lien,cible,sid)
{ // Gere l'ouverture des pages dans MainFr

	//alert(top.mainFr.frames.length+" -> "+lien);

	if (top.mainFr.frames.length < 2)
	{// Ouverture frameset avec la frame correspondant au clic
		top.mainFr.location = "main.php?"+sid+"&"+cible+"="+lien;
	}
	else
	{// Modif de la frame correspondant au clic
		// lien de la forme 'lien.php(par1=val1,par2=val2,...)'
		a = lien.replace("(","?");
		lien = a.replace(")","");

		while (lien.indexOf(",") > 0)
		{
			lien = change(lien);
		}// -> lien de la forme 'lien.php?par1=val1&par2=val2&...'*/
		top.mainFr.frames[cible+"_mainFr"].location = lien;		
	}
}

function OpenWindow(page, name, w, h, scroll, resz)
{ // Ouvre une pop-up centree
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	prop = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable='+resz+'';
	win = window.open(page, name, prop);
}

function PopImg(img, titre)
{ // Ouvre une fenetre pop adaptee a la taille de l'image
	var extra_width = 20;
	var extra_height = 50;
	if (checkIt('msie')) {
		extra_width = 25;
		extra_height = 70;	
	}
	else if (checkIt('firefox')) {
		extra_width = 40;
		extra_height = 65;
	}
	else if (checkIt('opera')) {
		extra_width = 20;
		extra_height = 60;
	}
	
	win = open("",'image','width=50,height=50,toolbar=no,scrollbars=no,resizable=yes');	
	win.document.writeln("<html><head><title>"+titre+"</title></head>");
	win.document.writeln("<script language=javascript>function checksize()  { if (document.images[0].complete) {  window.resizeTo(document.images[0].width+" + extra_width + ",document.images[0].height+" + extra_height + ");window.focus();} else { setTimeout('check()',250) } }</script>");
	win.document.writeln("<body onload='checksize();this.focus()' bgcolor='#ffffff' onContextMenu='return true' leftmargin='5' topmargin='5' marginwidth='5' marginheight='5'><center><a href=\"javascript:close()\"><img src='"+img+"' border=0\"></a></center>");
	win.document.writeln("");
	win.document.writeln("</body></html>");
	win.document.close();
}

function reconnecter(sid)
{
	top.haut.location = top.haut.location;
	top.menuFr.popup = false;
	top.menuFr.location = 'menu.php?' + sid;
	top.mainFr.ht_mainFr.location = 'ac_connectes.php?' + sid;
	top.mainFr.bs_mainFr.location = 'accueil.php?' + sid;
}

function reloadMenu(sid)
{
	if(!top.menuFr.loaded)
	{
		top.menuFr.popup = false;
		top.menuFr.location = "menu.php?"+sid;
	}
}

function checkIt(string)
{
	var detect = navigator.userAgent.toLowerCase();
	var place,thestring;

	place = detect.indexOf(string) + 1;
	thestring = string;	
	
	return place;
}