function openUploader(folderName, inputName, multiFile)
{
window.open("media/w2box/index.php?folderName="+folderName+"&multiFile="+multiFile+"&inputName="+inputName, "Uploader",
        "width=800,height=500,resizable,scrollbars=yes,status=1");
}
function setFileName(file, multiFile, inputName)
{
if(multiFile=="1")
{
	if(document.getElementById(inputName).value != '')
		document.getElementById(inputName).value = document.getElementById(inputName).value+"##"+file;
	else
		document.getElementById(inputName).value = file;
}
else
{
	document.getElementById(inputName).value = file
}
}
function Checkall(form, checked){ 
  for (var i = 1; i < form.elements.length; i++){ 
  	if(form.elements[i].type=='checkbox')
  	{
  		form.elements[i].checked = checked; 
  		
  	}
  } 
} 

function verif()
	{
	if(document.getElementById('ActionMaker').value=='0') {
	alert("Vous devez choisir une action !!");	return false;}
	else return true;
	}
function removeF(link)
	{
		var pos1= link.indexOf("f=");
		var debut=link.substring(0,pos1);
		var pos2=link.indexOf("&");
		var fin=link.substring(pos2);
		var rlink=debut+fin;
		return rlink;
		
	}
		
function deleteRow(id, table, returnLink)
	{
	if(confirm("Etes vous sur de vouloir supprimer ce(tte) "+table))
		{returnLink=removeF(returnLink);
		document.location.href="?1&"+returnLink+"&f="+table+"_del&elementId="+id;
		}
	}
function showSubMenu(id)
	{
		//alert("gotta show "+id);
	//alert(menuLabels);
	//alert(menuLabels.length);
	var menuLabels= document.getElementsByName('menu_top');
	for (j=0; j<(menuLabels.length); j++)
		{
		//alert(menuLabels[j]);
		var elem= menuLabels[j].id;
		var sm=elem+"SM";
		//alert("hiding "+sm);
		document.getElementById(sm).style.visibility= 'hidden';
		document.getElementById(sm).style.display= 'none';
		document.getElementById(elem).className='none';
		}
	var sm=id+"SM";
	//alert("showing "+sm);
	document.getElementById(id).className='active';
	document.getElementById(sm).style.visibility= 'visible';
	document.getElementById(sm).style.display= 'block';
	}
	
	function joinGame(type, login)
	{
		if(type==1)
		{
			//xajax_acceptMe(login);
			xajax_acceptInvitation(login);
		}
	
		if(type==0)
		{
			xajax_refuseMe(login);
		}
	}

	function stopGame(box, type)
	{
		if(getCookie("alerted")==0){
			if(type=='confirm')
				{
					if(confirm('Quitter une table en cours jeu si vous etes en mode championnat,sera considéré comme un abandon'))
					{
						xajax_stopGame();
						setCookie("alerted",1);
						closeBox('flash');
					}
					else setCookie("alerted",0);
				}
		if(type=='alert')
			{
				
				link= document.location.href;
				var pos1= link.indexOf("f=play");
				if(pos1>5){
					setCookie("alerted",1);
				xajax_stopGame();
					//alert('Quitter le jeu si vous etes en mode championnat,sera considéré comme un abandon');
				}
				//closeBox('flash');	
				
			}
		}
	}
	function createGame(vs, compet)
	{
		document.location.href='?f=play&mode=multiplayer&action=create&compet='+compet+"&";
	}
function closeBox(type)
{ 
	document.getElementById('message'+type+'Box').style.visibilty='hidden';
	document.getElementById('message'+type+'Box').style.display='none';
	document.getElementById('blackout').style.visibilty='hidden';
	document.getElementById('blackout').style.display='none';
	
	
}

function showAlert()
	{
	effect_1 = Effect.Appear('d1',{duration:1.0});
	}
function closeAlert()
	{
	effect_1 = Effect.Fade('d1',{duration:1.0}); 
	}
	
function verifPartie()
{
	//xajax_verifPartie(document.referrer);
	link=document.location.href;
	var pos1= link.indexOf("f=play");
	
	if(pos1>5)
	stopGame("flash", "alert");
	return false;
}


function show(obj)
{
	document.getElementById(obj).style.display= 'block';
}
function hide(obj)
{
	//alert(obj);
	document.getElementById(obj).style.display= 'none';
}










/*************************/

function setCookie(nom, valeur)
{
var argv=setCookie.arguments;
var argc=setCookie.arguments.length;
var expires=(argc > 2) ? argv[2] : null;
var path=(argc > 3) ? argv[3] : null;
var domain=(argc > 4) ? argv[4] : null;
var secure=(argc > 5) ? argv[5] : false;
document.cookie=nom+"="+escape(valeur)+
((expires==null) ? "" : ("; expires="+expires.toGMTString()))+
((path==null) ? "" : ("; path="+path))+
((domain==null) ? "" : ("; domain="+domain))+
((secure==true) ? "; secure" : "");
}
//-->
function getCookieVal(offset)
{
var endstr=document.cookie.indexOf (";", offset);
if (endstr==-1) endstr=document.cookie.length;
return unescape(document.cookie.substring(offset, endstr));
}
function getCookie(nom)
{
var arg=nom+"=";
var alen=arg.length;
var clen=document.cookie.length;
var i=0;
while (i<clen)
{
var j=i+alen;
if (document.cookie.substring(i, j)==arg) return getCookieVal(j);
i=document.cookie.indexOf(" ",i)+1;
if (i==0) break;

}
return null;
}
function delCookie(nom)
{
date=new Date;
date.setFullYear(date.getFullYear()-1);
EcrireCookie(nom,null,date);
}
function assign(field, val)
{
	
	document.getElementById(field).value= val;
}
function assignVI(field, val, h)
{
	
	document.getElementById(field).value= val;
	document.getElementById('ville_id').value= h;
}