 function makeLangListInHdp()
 {
   var list=document.getElementById('langToGroup');
   var grpLList="";
   if (list.length!=0)
   {
     for(i=0;i<list.length-1;i++) grpLList=grpLList+list.options[i].value+":";
     grpLList=grpLList+list.options[list.length-1].value;
     document.signupform.hdp.value=grpLList;
   }
 }

 function letterSubmit(letter) {

   makeLangListInHdp();
   document.signupform.cmd.value=gcmd;
   document.signupform.sub.value=gsub;
   document.signupform.action='';
   document.signupform.fletter.value=letter;
   document.signupform.langSel.value='1';
   document.signupform.submit();
 }

 function addLang()
 {
   var list=document.getElementById('langToGroup');
   var newOpt = document.createElement('option');
   newOpt.value=document.signupform.lang.options[document.signupform.lang.selectedIndex].value;
   newOpt.text= document.signupform.lang.options[document.signupform.lang.selectedIndex].text;

   for(i=0;i<list.length;i++)
    if (list.options[i].value==newOpt.value)
    {
        alert("This language ("+newOpt.text+") is already in your list!");
        return;
    }

   try {
    list.add(newOpt, null); // standards compliant; doesn't work in IE
   }
   catch(ex) {
    list.add(newOpt); // IE only
   }
 }

 function delLang()
 {
   var list=document.getElementById('langToGroup');
   if (list.length<1) return;
   if (list.selectedIndex==-1)
   {
        alert("Select a language to delete from the group languages list");
        return;
   }
   var o = list.options[list.selectedIndex];
   if (o.style.color=='red')
   {
     alert("You can't remove this language, because there are exercises created with it in the group.");
   }
   else
   {
     list.remove(list.selectedIndex);
   }
 }

 function chkLangs()
 {
   var list=document.getElementById('langToGroup');
   if (list.length<1)
   {
        alert("You have to specify at least one language!");
        return false;
   }
   document.signupform.langSel.value='2';
   makeLangListInHdp();
   return true;
 }

 function chkReqFields()
 {
   if (trim(document.signupform.email.value)=="")
   {
        alert("Please enter your E-mail address.");
        return false;
   }
   if (trim(document.signupform.p1.value)=="")
   {
        alert("Please enter your chuala password.");
        return false;
   }

   if (trim(document.signupform.name.value).length<5)
   {
        alert("The subscription name is too short.");
        return false;
   }
   if (trim(document.signupform.desc.value).length<1)
   {
        alert("Please, enter the description field.");
        return false;
   }
   return true;
 }


