function validate()
{
  
  var submitcenter=mainform.sub_gcabbr.value;
  var registrationdata=mainform.bulk.value;
 
  if(submitcenter=='')
  {
	alert('Please enter Submitting Center');
	return false;
  }

  else if(registrationdata=='')
  {
     alert('Please enter the Clone Registration Data');
     return false;
  }
  else
  {
	
	var rd = registrationdata;
	var lines = new Array();
	lines = rd.split('\n');
	
	
	for(var i=0; i<lines.length;++i)
	{
		var linenum=i+1;
		var fields = new Array();
		fields = (lines[i]).split(';');
		//alert(fields.length);
		if(fields.length != 5)
		{
			alert("Error on line "+ linenum +": One clone per line. Each line consists of 5 elements delimited by semi-colons. So there is only maximum four semi-coluns in a line.");
			return false;
		}
		var tok = trimstring( (fields[1]).toLowerCase() );
		
		var acctok = trimstring( (fields[3]).toLowerCase() );
		//alert(acctok);
		
		
		if( (tok != "reserve")  && (tok!="commit") && (tok!="redundant") && (tok!="abandon") && (tok!="accession") && (tok!="free") )
		{
			alert("Error in Registration data on line " + linenum +". Invalid value: \"" + tok + "\". The second field must be one of the transaction codes described in the submission page.");
			return false;
		}
		if((tok=="accession") && (acctok==""))
		{
			alert("Please enter accession number in 4th field");
			return false;
		}
	}

	return true;
	
  }
  

  return false;
  
}

//removes leading and trailing whitespaces
function trimstring(str)
{
	return str.replace(/^\s+/g, '').replace(/\s+$/g, '');

}