function addCategories(listCode,n)
{var fl=(document.all?document.all["all"+listCode+"List"]:document.getElementById("all"+listCode+"List"));
 var tl=(document.all?document.all["sel"+listCode+"List"]:document.getElementById("sel"+listCode+"List"));
 if(typeof(n)=="undefined"||!n) n=fl.length+tl.length;
 if(tl.length>=n) return;
 for(i=fl.length-1;i>=0;i--)
   {if(tl.length>=n) return;
    if(fl.options[i].selected)
     {tl.options[tl.length]=new Option(fl.options[i].text,fl.options[i].value);
      fl.options[i]=null;
     }
   }
}

function removeCategories(listCode)
{var fl=(document.all?document.all["sel"+listCode+"List"]:document.getElementById("sel"+listCode+"List"));
 var tl=(document.all?document.all["all"+listCode+"List"]:document.getElementById("all"+listCode+"List"));
 for(i=fl.length-1;i>=0;i--)
   {if(fl.options[i].selected)
     {tl.options[tl.length]=new Option(fl.options[i].text,fl.options[i].value);
      fl.options[i]=null;
     }
   }
}

function swapItems(l,i,j)
{var t=l[i].text;
 var v=l[i].value;
 var s=l[i].selected;
 l[i].text=l[j].text;
 l[i].value=l[j].value;
 l[i].selected=l[j].selected;
 l[j].text=t;
 l[j].value=v;
 l[j].selected=s;
}

function moveCatUp()
{var l=(document.all?document.all["selCatList"]:document.getElementById("selCatList"));
 if(l.length<2) return;
 var s=new Array();
 for(var i=1;i<l.length;i++)
   {if(l[i].selected) s[s.length]=i;
   }
 for(i in s) if(!l[s[i]-1].selected) swapItems(l,s[i],s[i]-1);
}

function moveCatDown()
{var l=(document.all?document.all["selCatList"]:document.getElementById("selCatList"));
 if(l.length<2) return;
 var s=new Array();
 for(var i=l.length-2;i>=0;i--)
   {if(l[i].selected) s[s.length]=i;
   }
 for(i in s) if(!l[s[i]+1].selected) swapItems(l,s[i],s[i]+1);
}

function chinfoForm()
{var msg="";
 var obj;
 var form=document.f_chinfo;
 if(typeof(form.vSubmit)!="undefined") form.vSubmit.disabled=true;
 if(form.vDelImg.checked)
   if(!confirm("Are you sure you want to remove the picture?"))
     {form.vDelImg.focus();
      if(typeof(form.vSubmit)!="undefined") form.vSubmit.disabled=false;
      return false;
     }
 var ls=(document.all?document.all["selCatList"]:document.getElementById("selCatList"));
 var le=(document.all?document.all["selExpList"]:document.getElementById("selExpList"));
 if(ls.length==0)
   {msg="Please choose a specialty!";
    obj=ls;
   }
 else if(le.length==0)
   {msg="Please choose an expertise!";
    obj=le;
   }
 else if(trim(form.vEmail.value)!=""&&!emailCheck(form.vEmail.value))
   {msg="Please enter a valid new public e-mail address or leave it empty!";
    obj=form.vEmail;
   }
 if(msg!="")
   {alert(msg);
    obj.focus();
    if(typeof(form.vSubmit)!="undefined") form.vSubmit.disabled=false;
    return false;
   }
 for(var i=0;i<ls.length;i++) ls[i].selected=true;
 for(var i=0;i<le.length;i++) le[i].selected=true;
 return true;
}
