// GIFNET Validatiom routines by (Angelo Kello -DEC 2003)
// Last modified 28/12/2003

   function togglerows()
   {
      // obj=(document.all) ? document.all[target] : document.getElementById(target);
      x=document.membership.occupation.value ;
      if (x=="Scientist") {
        obj0=document.all["row0"] ; obj1=document.all["row1"] ; 
        obj2=document.all["row2"] ; obj3=document.all["row3"] ;
        obj0.style.display='inline' ; obj1.style.display='inline' ;
        obj2.style.display='inline' ; obj3.style.display='inline' ;


        }
      else {
        obj0=document.all["row0"] ; obj0.style.display='none' ;    
        obj1=document.all["row1"] ; obj1.style.display='none' ;
        obj2=document.all["row2"] ; obj2.style.display='none' ;
        obj3=document.all["row3"] ; obj3.style.display='none' ;
      }   
   }
 function isEmailAddr(email)
{
  var result = false
  var theStr = new String(email)
  var index = theStr.indexOf("@");
  if (index > 0)
  {
    var pindex = theStr.indexOf(".",index);
    if ((pindex > index+1) && (theStr.length > pindex+1))
	result = true;
  }
  return result;
}
  
 function validateForm()
{
	// check name
	if (document.forms[0].elements[0].value == "")
	{
		alert (" Please enter a name!");
		document.membership.name1.focus() ;
		return false;
	}

	// check Surname
	if ((document.membership.name2) && (document.membership.name2.value == ""))
	{
		alert (" Please enter a Surname! ");
		document.membership.name2.focus() ;
		return false;
	}
	// check Email
	if ((document.membership.email) && (document.membership.email.value.length < 7))
	{
		alert (" Please enter a valid Email! ");
		document.membership.email.focus() ;
		return false;
	}
	
   if ((document.membership.email) && (!isEmailAddr(document.membership.email.value)))
   {
    alert("Please enter a complete email address in the form: yourname@yourdomain.com");
    document.membership.email.focus();
    return (false);
   }

   // check country	
    	if ((document.membership.country) && (document.membership.country.value == "none"))
    	{
		 alert ("Please select a country!");
		 document.membership.country.focus() ;
		 return false;
	   }
  // check occupation	
       if ((document.membership.occupation) && (document.membership.occupation.value == "none"))
	   {
		 alert ("Please select an occupation!");
		 document.membership.occupation.focus() ;
		 return false;
	   }

  // check phone
       if ((document.membership.phone) && (document.membership.phone.value == ""))
	   {
		 alert ("Please enter a phone number!");
		 document.membership.phone.focus() ;
		 return false;
	   }

  // check contact person
       if ((document.membership.conperson) && (document.membership.conperson.value == ""))
	   {
		 alert ("Please enter the contact person!");
		 document.membership.conperson.focus() ;
		 return false;
	   }
  // check extra fields here	   
	  if ((document.membership.occupation) && (document.membership.occupation.value == "Scientist"))
	   {
	    if (document.membership.s_field.value.length < 3)
	    {
   		 alert ("Please specify the field of science \n in which you are active!");
		 document.membership.s_field.focus() ;
		 return false;   
	    }
	    if (document.membership.s_affl.value.length < 3)
	    {
   		 alert ("Please specify the scientific institution you are affiliated with!");
		 document.membership.s_affl.focus() ;
		 return false;   
	    }
	    if (document.membership.s_spec.value.length < 3)
	    {
   		 alert ("Please specify your field of specialty!");
		 document.membership.s_spec.focus() ;
		 return false;   
	    }

	   }

} //end function validateForm()   
   
   

