function validate_cb(cbname,cid,maxcid)
{
   if(cid==maxcid)
   {
	var checkme = document.getElementById(cbname+'['+maxcid+']');
	var uncheckall = document.getElementsByName(cbname+'[]');
	
	for(i=0;i<(uncheckall.length - 1);i++)
	{
	    var elem = uncheckall[i];
	    elem.checked='';
	}

	return true;	
   }
   else
   {
	var uncheckme = document.getElementById(cbname+'['+maxcid+']');
	uncheckme.checked='';
	return true;
   }
}

function validateOther(otherid,maindpid,mainqid,maintype)
{
   if(maintype!='checkbox' && maintype!='radio')
   {
	return false;
   }
   
   if(maintype=='checkbox')
   {
	var mainid='answer_'+maindpid+'['+mainqid+']';
	var uncheckall = document.getElementsByName('answer_'+maindpid+'[]');
	var main = document.getElementById(mainid);
	var other = document.getElementById(otherid);

	if(other.value != "")
	{
	    for(i=0;i<uncheckall.length;i++)
	    {
	    	var elem = uncheckall[i];
		elem.checked='';
	    }

	    main.checked='checked';
	    return true;	
	}
   }

   if(maintype=='radio')
   {
	var other = document.getElementById(otherid);
	var mainid='answer_'+maindpid+'['+mainqid+']';
	var main = document.getElementById(mainid);

	if(other.value != "")
	{
	    if(main.checked!='true')
	    {
		main.checked='true';
		return true;
            }
	}
   }
}

function validateOtherCheck(mainid,cid,maxcid,otherdpid)
{
   var other = document.getElementById('answer_'+otherdpid);
   
   if(cid != maxcid)
   {
	var maxq = mainid+'['+maxcid+']';
	var uncheck = document.getElementById(maxq);

	uncheck.checked='';
	other.value="";
   }
}

function validateOtherSelect(mainid,maxcid,otherdpid)
{
   var other = document.getElementById('answer_'+otherdpid);
   var main = document.getElementById(mainid);

   if(main.value != maxcid)
   {
	other.value="";	
   }
}

function rolloverImage(idext,action)
{
   var main = document.getElementById(idext+'_icon');

   if(action == 'over')
   {
	main.src='images/'+idext+'_ro.png';
	return true;
   }
  
   if(action == 'out')
   {
	main.src='images/'+idext+'.png';
	return true;
   }
}  

function rolloverImageAndText(idext,action,image)
{
   var main = document.getElementById(idext+'_icon');
   var text = document.getElementById(idext+'_text');

   if(action == 'over')
   {
	main.src='images/'+image+'_ro.png';
	text.style.display="";

	return true;
   }
  
   if(action == 'out')
   {
	main.src='images/'+image+'.png';
	text.style.display="none";

	return true;
   }
}  

function emailChange()
{
   var email = document.getElementById('email');
   var span = document.getElementById('login');

   span.value = email.value;
}
