function checkVal(obj, status)
{
   	var st = (status==true) ? "" : "disabled" ;
	if(obj.type!="select-one" && obj.length>1)
	{
	   for(var i=0; i<obj.length; i++)
		   obj[i].disabled=st;
	}
	else
	{  
    	 	obj.disabled=st;
	}
	return false;
}
/*
*
**/
function getCode()
{
   	var win = window.open(wwwRoot+"admin/code_f.php", "code", "width=500,height=300");
   	return win;
}
/*
*
**/
function getAna()
{
   	var win = window.open(wwwRoot+"ana_f.php", "ana", "width=500,height=300");
   	return win;
}
/*
*
**/
function getCompta(p)
{
   	var win = window.open(wwwRoot+"admin/compta_f.php?tg="+p, "code", "width=500,height=300");
   	return win;
}
/*
*
**/
function getDealer()
{
   var win = window.open(wwwRoot+"admin/dealer_f.php", "dealer", "width=520,height=300,scrollbars=yes,resizable=yes");
   	return win;
}
/*
*
**/
function getNAF()
{
   var win = window.open(wwwRoot+"admin/naf_f.php", "NAF", "width=520,height=300");
   	return win;
}
/*
*
**/
function setCode(o)
{
	if(o.selectedIndex<0)
		return;
	top.opener.document.forms["zeform"].elements.code.value = o[o.selectedIndex].text;
	top.opener.document.forms["zeform"].elements.codeh.value = o[o.selectedIndex].value;
   	top.close();
   	return;
}
/*
*
**/
function setNAF(o)
{
	if(o.selectedIndex<0)
		return;
	top.opener.document.forms["zeform"].elements.naf.value = o[o.selectedIndex].text;
	top.opener.document.forms["zeform"].elements.nafh.value = o[o.selectedIndex].value;
   	top.close();
   	return;
}
/*
*
**/
function setCompta(o, tg)
{
	if(o.selectedIndex<0)
		return;
	top.opener.document.forms["zeform"].elements[tg].value = o[o.selectedIndex].text;
	top.opener.document.forms["zeform"].elements[tg+"h"].value = o[o.selectedIndex].value;
   	top.close();
   	return;
}
/*
*
**/
function setDealer(o)
{
	if(o.selectedIndex<0)
		return;
	top.opener.document.forms["zeform"].elements.dealer.value = o[o.selectedIndex].text;
	top.opener.document.forms["zeform"].elements.dealerh.value = o[o.selectedIndex].value;
   	top.close();
   	return;
}
/*
*
**/
function checkForm(obj, needed)
{
   	var errorStr = new String("");
	var ok = new Boolean(true);
	for(var i=0; i<needed.length; i++)
	{
	   	if(obj.elements[needed[i][0]] && obj.elements[needed[i][0]].value=="")
		{
		    ok=false;
			errorStr += "le champs '"+needed[i][1]+"' est obligatoire\n";
		}
	   if(obj.elements[needed[i][0]].type=="select-one")
	   {
           if(obj.elements[needed[i][0]][obj.elements[needed[i][0]].selectedIndex].value==-1)
	       {       
		      ok=false;
			 errorStr += "le champs '"+needed[i][1]+"' est obligatoire\n";
            }
	   }		
	}
	if(ok==false)
	{
	      	errorStr = "Le formulaire est incomplet :\n"+errorStr;
	      	alert(errorStr);
		return false;
	}
	return true;
}
/******************************************************/
/*
* Class PopInfo : popup descriptive des ateliers/confˇrences
**/
function PopInfo()
{
    var visible = false;
    var popClip = null;    
    // public methods   
    this.init=function(obj)
    {
        document.onmousemove = getPos;
        this.popClip = document.getElementById(obj);
    }
    this.show=function()
    {
        this._setVisible(true);
    }
    this.hide=function()
    {
        this._setVisible(false);    
    }
    this.setData=function(str)
    {
        this.popClip.innerHTML = unescape(str);
        if(str.length>0)
            this.show();
        else
            this.hide();
    }
    // private methods
    this._setVisible=function(st)
    {
        var vis = (st==true) ? "block" : "none";
        this.popClip.style.display = vis; 
        this.visible = st;
    }
    this._move=function(x,y)
    {
        if(this.visible==true)
        {
            this.popClip.style.top = y+"px";
            this.popClip.style.left = x+"px";
        }
        return false;
    }    
    return this;
/******************************************************/    
} // end class
/******************************************************/
var pInfo = new PopInfo();
/******************************************************/
function getPos(evt)
{
    var x=-250;
    var y=-250;
    if(document.all)
    {
        var scrollObj = (document.documentElement) ? document.documentElement : document.body;
        x = self.event.x+scrollObj.scrollLeft;
        y = self.event.y+scrollObj.scrollTop;
    }
    else
    {
        x = evt.pageX;
        y = evt.pageY;
    }
    if(pInfo && pInfo._move)
        pInfo._move(x,y+15);
    return false;
}
/******************************************************/
function checkInt(n)
{
    if(n.toString().length==1)
        return "0"+n;
    return n;
}/******************************************************/
function infoBulle(str)
{
    if(pInfo)
    {
        pInfo.setData(str);    
    }
}
/******************************************************/
function resetForm(f)
{
    for(var i=0; i<f.elements.length; i++)
    {
        if(f.elements[i].checked)
            f.elements[i].checked=false;
    }
}

function checkAll(obj, state)
{
    var chk = state==1 ? true : false;
    for(var i=0; i<obj.length; i++)
        obj[i].checked = chk;
}

function getDateLength(d, l)
{
    var tmpd = d.split(" ");
    var tmpdd = tmpd[0].split("-");
    var tmpdh = tmpd[1].split(":");
    var plus = l.split(":");
    var dt = new Date();
    dt.setYear(tmpdd[0]);   
    dt.setMonth(tmpdd[1]);
    dt.setDate(tmpdd[2]);
    dt.setHours(parseInt(tmpdh[0], 10)+parseInt(plus[0], 10));    
    dt.setMinutes(parseInt(tmpdh[1], 10)+parseInt(plus[1], 10));
    document.write(checkInt(dt.getHours())+"h"+checkInt(dt.getMinutes()));
}