function realcount(obj)
			{
				niek	= 0;
				for (counter = 0; counter < obj.length; counter++)
    				if (!obj.options[counter])
    				{
    					niek++;	
    				}
    				
    			return counter-niek;
			}

function add_multistuff(obj1,obj2)
	{
  		for (i = 0; i < obj1.length; i++)
    		if (obj1.options[i].selected)
    		{
		      var opt = document.createElement("OPTION");
		      opt.text=obj1.options[i].text;
		      opt.value=obj1.options[i].value;
		      obj2.options[realcount(obj2)] = opt;
		      obj1.options[i] = null;
		      i = i - 1;
    		}
	}

function del_multistuff(obj1,obj2)
{
  for (i = 0; i < obj2.length; i++)
    if (obj2.options[i].selected)
    {
      var opt = document.createElement("OPTION");
      opt.text=obj2.options[i].text;
      opt.value=obj2.options[i].value; 
      obj1.options[obj1.length] = opt;
      obj2.options[i] = null;
      i = i - 1;
    }
}

function yrch_userpopup_summon(baseurl,label,id)
{
	window.open("user_seek.php","yrchpopup","status=0,width=100,height=100,resizable=1,scrollbars=1");
	document.userpopup_idfield	= id;
	document.userpopup_labelfield = label;
	document.machin	= "bubu";
}

function yrch_reviewpopup_summon(baseurl,id,blurdestroy)
{
	window.open(baseurl+"review.php?nolayout=1&id="+id+"&blurdestroy="+blurdestroy,"yrchpopup","status=0,width=400,height=300,resizable=1,scrollbars=1");
}

function yrch_editopopup_summon(baseurl,ref,blurdestroy)
{
	window.open(baseurl+"edito.php?nolayout=1&ref="+ref+"&blurdestroy="+blurdestroy,"yrchpopup","status=0,width=400,height=300,resizable=1,scrollbars=1");
}

function yrch_popup(url)
{
	window.open(url,"yrch_popup","status=0,width=800,height=600,resizable=1,scrollbars=1");
}
	
function yrch_userpopup_answer(userid,username)
{
	if(window.opener)
	{
		if(window.opener.document.userpopup_idfield)
		{
			window.opener.document.userpopup_idfield.value		= userid;
			window.opener.document.userpopup_labelfield.value	= username;
			
			window.close();
		}
	}
}

function realcount(obj)
{
	niek	= 0;
	for (counter = 0; counter < obj.length; counter++)
		if (!obj.options[counter])
		{
			niek++;	
		}
		
	return counter-niek;
}
			
function addcat(dest,obj)
{
	//object	= document.parents.elements[0];
  	//dest	= document.parents.elements[3];
  
  	for (i = 0; i < obj.length; i++)
	{
		if (obj.options[i].selected)
	    {
	      var opt = document.createElement("OPTION");
	      opt.text= obj.options[i].text;
	      opt.value=obj.options[i].value;
	      dest.options[realcount(dest)] = opt;
	      obj.options[i] = null;
	      i = i - 1;
	    }
	}
}
//document.parents.catmaster.value
function delcat(dest,obj,mastervalue)
{
  //object	= document.parents.elements[3];
  //dest		= document.parents.elements[0];
  
  for (i = 0; i < obj.length; i++)
    if (obj.options[i].selected)
    {
      if(mastervalue == obj.options[i].value) 
      {
      	alert("impossible de supprimer la catégorie maitresse");
      }
      else
      {
	      var opt = document.createElement("OPTION");
	      opt.text=obj.options[i].text;
	      opt.value=obj.options[i].value; 
	      dest.options[dest.length] = opt;
	      obj.options[i] = null;
	      i = i - 1;
	   }
    }
}
