// identification member
function verifLogin()
{
  erreur = ""
  if (document.formLogin.login.value == "")
  {
   erreur += "Please indicate the login.\n"
  }
    if (document.formLogin.passwd.value == "")
  {
   erreur += "Please indicate the password.\n"
  }
  if (erreur == "")
  {
    document.formLogin.submit()
  }
  else
  {
    alert(erreur)
  }
}

// Validate user in the questionnaire
function validateUser()
{
  erreur = ""
  if ((document.forms.formQuestionnaireNewUser1.contactMail.value == "") ||
  	  (document.forms.formQuestionnaireNewUser1.organization.value == "") ||
  	  (document.forms.formQuestionnaireNewUser1.country.value == ""))
  {
   erreur += "Please indicate mandatory fields.\n";
  }
  if (erreur == "")
  {
    document.forms.formQuestionnaireNewUser1.submit();
  }
  else
  {
    alert(erreur);
  }
}

// Validate project in the questionnaire
function validateAddProjects()
{
  	erreur = "";
    ok = "false";
  	for (i=0; i<2; i++) {
  		if (document.forms.formQuestionnaireInfrastructure.infrastructure[i].checked)
  			ok = "true";
  	}
  	if (ok == "false")
  	{
   		erreur += "Please indicate check \"Yes\" or \"No\".\n";
  	}
  	if (erreur == "")
  	{
    	document.forms.formQuestionnaireInfrastructure.submit();
  	}
  	else
  	{
   	 	alert(erreur);
  	}
}

// Validate repository in the questionnaire
function validateAddRepository()
{
	erreur = "";
    ok = "false";
  	for (i=0; i<2; i++) {
  		if (document.forms.formQuestionnaireArchive.archive[i].checked)
  			ok = "true";
  	}
  	if (ok == "false")
  	{
   		erreur += "Please indicate check \"Yes\" or \"No\".\n";
  	}
  	if (erreur == "")
  	{
    	document.forms.formQuestionnaireArchive.submit();
  	}
  	else
  	{
   	 	alert(erreur);
  	}
}

// Validate description of repository in the questionnaire
function validateRepositoryDescription()
{
	erreur = ""
  	if (document.forms.formQuestionnaireNewRepositoryDescription.identifier.value == "")
  	{
   	erreur += "Please indicate mandatory fields.\n";
  	}
  	if (erreur == "")
  	{
    	document.forms.formQuestionnaireNewRepositoryDescription.submit();
  	}
  	else
  	{
   	 	alert(erreur);
  	}
}

// Validate contents of repository in the questionnaire
function validateRepositoryContents()
{
	erreur = ""
	ok = "false";
  	for (i=0; i<9; i++) {
  		if (document.forms.formQuestionnaireNewRepositoryContents.repositorySubject[i].checked)
  			ok = "true";
  	}
  	if (ok == "false")
  	{
   		erreur += "Please indicate subject field.\n";
  	}
  	else
  	{
  		if ((document.forms.formQuestionnaireNewRepositoryContents.repositorySubject[8].checked) &&
  			(document.forms.formQuestionnaireNewRepositoryContents.repositorySubjectOther.value == ""))
  			erreur += "Please specify other subject field.\n";
  	}
  	
  	ok = "false";
  	for (i=0; i<4; i++) {
  		if (document.forms.formQuestionnaireNewRepositoryContents.repositoryCoveredArea[i].checked)
  			ok = "true";
  	}
  	if (ok == "false")
  	{
   		erreur += "Please indicate covered area field.\n";
  	}
  	
  	if (document.forms.formQuestionnaireNewRepositoryContents.repositoryCoveredTime.value == "")
  		erreur += "Please indicate covered time field.\n";
  		
  	if (document.forms.formQuestionnaireNewRepositoryContents.repositoryActualAmountData.value == "")
  		erreur += "Please indicate covered time field.\n";
  	
  	if (erreur == "")
  	{
    	document.forms.formQuestionnaireNewRepositoryContents.submit();
  	}
  	else
  	{
   	 	alert(erreur);
  	}
	
}

// Validate access of repository in the questionnaire
function validateRepositoryAccess()
{
	erreur = ""
	ok = "false";
  	for (i=0; i<2; i++) {
  		if (document.forms.formQuestionnaireNewRepositoryAccess.repositoryGatewayAccess[i].checked)
  			ok = "true";
  	}
  	if (ok == "false")
  	{
   		erreur += "Please indicate gateway field.\n";
  	}
  	
  	ok = "false";
  	for (i=0; i<5; i++) {
  		if (document.forms.formQuestionnaireNewRepositoryAccess.repositoryHighSpeedNetwork[i].checked)
  			ok = "true";
  	}
  	if (ok == "false")
  	{
   		erreur += "Please indicate high-speed network field.\n";
  	}
  	else
  	{
  		if ((document.forms.formQuestionnaireNewRepositoryAccess.repositoryHighSpeedNetwork[4].checked) &&
  			(document.forms.formQuestionnaireNewRepositoryAccess.repositoryHighSpeedNetworkOther.value == ""))
  			erreur += "Please specify other high-speed network field.\n";
  	}
  	
  	if (erreur == "")
  	{
    	document.forms.formQuestionnaireNewRepositoryAccess.submit();
  	}
  	else
  	{
   	 	alert(erreur);
  	}

}

// Validate standards in the questionnaire
function validateStandards()
{
	erreur = "";
	ok = "false";
  	for (i=0; i<3; i++) {
  		if (document.forms.formQuestionnaireStandards.standards_oais_reference_model[i].checked)
  			ok = "true";
  	}
  	if (ok == "false")
  	{
   		erreur += "Please indicate if your archive is compliant with the OAIS reference model.\n";
  	}
  	if (erreur == "")
  	{
    	document.forms.formQuestionnaireStandards.submit();
  	}
  	else
  	{
   	 	alert(erreur);
  	}
}

// Cancel the questionnaire
function cancelQuestionnaire()
{
	document.location = "index.php?menu=identification";
}

// Validate email in the questionnaire
function validateEmail()
{
	if (document.formQuestionnaireLogin.loginEmail.value == "")
		alert('Please indicate email.');
	else
		document.formQuestionnaireLogin.submit();
}

// Validate infrastructure in the questionnaire
function validateInfrastructure()
{
	if ((document.formQuestionnaireNewInfrastructure.projectName.value == "") || 
	    (document.formQuestionnaireNewInfrastructure.userRole.value == ""))
		alert('Please indicate mandatory fields.');
	else
		document.formQuestionnaireNewInfrastructure.submit();
}

// Update infrastructure in the questionnaire
function updateInfrastructure()
{
	if ((document.formQuestionnaireUpdateInfrastructure.projectName.value == "") || 
	    (document.formQuestionnaireUpdateInfrastructure.userRole.value == ""))
		alert('Please indicate mandatory fields.');
	else
		document.formQuestionnaireUpdateInfrastructure.submit();
}

// Cancel infrastructure in the questionnaire
function cancelInfrastructure(iduser)
{
	document.location = "index.php?menu=questionnaire&iduser="+iduser;
}

function saisirChamp(value) 
{ 
	document.forms.formQuestionnaireNewUser1.typeOrganization.value=value;
}

function cancelRepositoryDescription(iduser)
{
	document.location = "index.php?menu=questionnaireArchive&iduser="+iduser;
}

function cancelRepositoryContents(idrepository,iduser)
{
	document.location = "index.php?menu=questionnaireRepository&type=description&repository=update&idrepository="+idrepository+"&iduser="+iduser;
}

function cancelRepositoryAccess(idrepository,iduser)
{
	document.location = "index.php?menu=questionnaireRepository&type=contents&repository=update&idrepository="+idrepository+"&iduser="+iduser;
}

function cancelStandards(iduser)
{
	document.location = "index.php?menu=questionnaireArchive&iduser="+iduser;
}

function cancelCuration(iduser)
{
	document.location = "index.php?menu=questionnaireStandards&iduser="+iduser;
}

function cancelUpgrade(iduser)
{
	document.location = "index.php?menu=questionnaireCuration&iduser="+iduser;
}

function cancelDiscard(iduser)
{
	document.location = "index.php?menu=questionnaireUpgrade&iduser="+iduser;
}

function cancelEffort(iduser)
{
	document.location = "index.php?menu=questionnaireDiscard&iduser="+iduser;
}

function cancelSustainability(iduser)
{
	document.location = "index.php?menu=questionnaireEffort&iduser="+iduser;
}

function disableRepositorySubjectOther()
{
	document.formQuestionnaireNewRepositoryContents.repositorySubjectOther.value="";
	document.formQuestionnaireNewRepositoryContents.repositorySubjectOther.disabled=true;
}

function enableRepositorySubjectOther()
{
	document.formQuestionnaireNewRepositoryContents.repositorySubjectOther.disabled=false;
}

function disableRepositoryDataSourceOther()
{
	document.formQuestionnaireNewRepositoryContents.repositoryDataSourceOther.value="";
	document.formQuestionnaireNewRepositoryContents.repositoryDataSourceOther.disabled=true;
}

function enableRepositoryDataSourceOther()
{
	document.formQuestionnaireNewRepositoryContents.repositoryDataSourceOther.disabled=false;
}

function disableRepositoryAccessExternalUsersOther()
{
	document.formQuestionnaireNewRepositoryAccess.repositoryAccessExternalUsersOther.value="";
	document.formQuestionnaireNewRepositoryAccess.repositoryAccessExternalUsersOther.disabled=true;
}

function enableRepositoryAccessExternalUsersOther()
{
	document.formQuestionnaireNewRepositoryAccess.repositoryAccessExternalUsersOther.disabled=false;
}

function disableRepositoryHighSpeedNetworkOther()
{
	document.formQuestionnaireNewRepositoryAccess.repositoryHighSpeedNetworkOther.value="";
	document.formQuestionnaireNewRepositoryAccess.repositoryHighSpeedNetworkOther.disabled=true;
}

function enableRepositoryHighSpeedNetworkOther()
{
	document.formQuestionnaireNewRepositoryAccess.repositoryHighSpeedNetworkOther.disabled=false;
}

function disableRepositoryProcessCapacityOther()
{
	document.formQuestionnaireNewRepositoryAccess.repositoryProcessCapacityOther.value="";
	document.formQuestionnaireNewRepositoryAccess.repositoryProcessCapacityOther.disabled=true;
}

function enableRepositoryProcessCapacityOther()
{
	document.formQuestionnaireNewRepositoryAccess.repositoryProcessCapacityOther.disabled=false;
}

function disableRepositoryAppliedAccessPolicyOther()
{
	document.formQuestionnaireNewRepositoryAccess.repositoryAppliedAccessPolicyOther.value="";
	document.formQuestionnaireNewRepositoryAccess.repositoryAppliedAccessPolicyOther.disabled=true;
}

function enableRepositoryAppliedAccessPolicyOther()
{
	document.formQuestionnaireNewRepositoryAccess.repositoryAppliedAccessPolicyOther.disabled=false;
}

function disableStandardsContentRenderingNone()
{
	document.formQuestionnaireStandards.standards_content_rendering_other.value="";
	document.formQuestionnaireStandards.standards_content_rendering_other.disabled=true;
	document.formQuestionnaireStandards.standards_content_rendering.checked=false;
	document.formQuestionnaireStandards.standards_content_rendering_internal.checked=false;
	document.formQuestionnaireStandards.standards_content_rendering_sld.checked=false;
	document.formQuestionnaireStandards.standards_content_rendering_wms.checked=false;
	document.formQuestionnaireStandards.standards_content_rendering_iso.checked=false;
}

function disableStandardsContentRendering()
{
	document.formQuestionnaireStandards.standards_content_rendering_none.checked=false;
}

function enableStandardsContentRendering()
{
	document.formQuestionnaireStandards.standards_content_rendering_other.disabled=false;
	document.formQuestionnaireStandards.standards_content_rendering_none.checked=false;
}

function disableStandardsServiceDiscoveryNone()
{
	document.formQuestionnaireStandards.standards_service_discovery_other.value="";
	document.formQuestionnaireStandards.standards_service_discovery_other.disabled=true;
	document.formQuestionnaireStandards.standards_service_discovery.checked=false;
	document.formQuestionnaireStandards.standards_service_discovery_internal.checked=false;
	document.formQuestionnaireStandards.standards_service_discovery_csw.checked=false;
	document.formQuestionnaireStandards.standards_service_discovery_wms.checked=false;
	document.formQuestionnaireStandards.standards_service_discovery_cat.checked=false;
	document.formQuestionnaireStandards.standards_service_discovery_uddi.checked=false;
	document.formQuestionnaireStandards.standards_service_discovery_rss.checked=false;
	document.formQuestionnaireStandards.standards_service_discovery_wsil.checked=false;
}

function disableStandardsServiceDiscovery()
{
	document.formQuestionnaireStandards.standards_service_discovery_none.checked=false;
}

function enableStandardsServiceDiscovery()
{
	document.formQuestionnaireStandards.standards_service_discovery_other.disabled=false;
	document.formQuestionnaireStandards.standards_service_discovery_none.checked=false;
}

function disableStandardsServiceDescriptionNone()
{
	document.formQuestionnaireStandards.standards_service_description_other.value="";
	document.formQuestionnaireStandards.standards_service_description_other.disabled=true;
	document.formQuestionnaireStandards.standards_service_description.checked=false;
	document.formQuestionnaireStandards.standards_service_description_internal.checked=false;
	document.formQuestionnaireStandards.standards_service_description_orm.checked=false;
	document.formQuestionnaireStandards.standards_service_description_ogc.checked=false;
}

function disableStandardsServiceDescription()
{
	document.formQuestionnaireStandards.standards_service_description_none.checked=false;
}

function enableStandardsServiceDescription()
{
	document.formQuestionnaireStandards.standards_service_description_other.disabled=false;
	document.formQuestionnaireStandards.standards_service_description_none.checked=false;
}


function disableStandardsDataExchangeNone()
{
	document.formQuestionnaireStandards.standards_data_exchange_other.value="";
	document.formQuestionnaireStandards.standards_data_exchange_other.disabled=true;
	document.formQuestionnaireStandards.standards_data_exchange.checked=false;
	document.formQuestionnaireStandards.standards_data_exchange_internal.checked=false;
	document.formQuestionnaireStandards.standards_data_exchange_digest.checked=false;
	document.formQuestionnaireStandards.standards_data_exchange_sdts.checked=false;
	document.formQuestionnaireStandards.standards_data_exchange_csw.checked=false;
	document.formQuestionnaireStandards.standards_data_exchange_wfs.checked=false;
	document.formQuestionnaireStandards.standards_data_exchange_wcs.checked=false;
	document.formQuestionnaireStandards.standards_data_exchange_iso.checked=false;
	document.formQuestionnaireStandards.standards_data_exchange_ct.checked=false;
}

function disableStandardsDataExchange()
{
	document.formQuestionnaireStandards.standards_data_exchange_none.checked=false;
}

function enableStandardsDataExchange()
{
	document.formQuestionnaireStandards.standards_data_exchange_other.disabled=false;
	document.formQuestionnaireStandards.standards_data_exchange_none.checked=false;
}

function disableStandardsDataFormatNone()
{
	document.formQuestionnaireStandards.standards_data_format_other.value="";
	document.formQuestionnaireStandards.standards_data_format_other.disabled=true;
	document.formQuestionnaireStandards.standards_data_format.checked=false;
	document.formQuestionnaireStandards.standards_data_format_internal.checked=false;
	document.formQuestionnaireStandards.standards_data_format_gml.checked=false;
	document.formQuestionnaireStandards.standards_data_format_context.checked=false;
	document.formQuestionnaireStandards.standards_data_format_esri.checked=false;
	document.formQuestionnaireStandards.standards_data_format_eo.checked=false;
}

function disableStandardsDataFormat()
{
	document.formQuestionnaireStandards.standards_data_format_none.checked=false;
}

function enableStandardsDataFormat()
{
	document.formQuestionnaireStandards.standards_data_format_other.disabled=false;
	document.formQuestionnaireStandards.standards_data_format_none.checked=false;
}

function disableStandardsMetadataNone()
{
	document.formQuestionnaireStandards.standards_metadata_other.value="";
	document.formQuestionnaireStandards.standards_metadata_other.disabled=true;
	document.formQuestionnaireStandards.standards_metadata.checked=false;
	document.formQuestionnaireStandards.standards_metadata_internal.checked=false;
	document.formQuestionnaireStandards.standards_metadata_iso2003.checked=false;
	document.formQuestionnaireStandards.standards_metadata_iso2.checked=false;
	document.formQuestionnaireStandards.standards_metadata_iso19139.checked=false;
	document.formQuestionnaireStandards.standards_metadata_inspire.checked=false;
}

function disableStandardsMetadata()
{
	document.formQuestionnaireStandards.standards_metadata_none.checked=false;
}

function enableStandardsMetadata()
{
	document.formQuestionnaireStandards.standards_metadata_other.disabled=false;
	document.formQuestionnaireStandards.standards_metadata_none.checked=false;
}

function validateAskQuestion()
{
	if ((document.formAskQuestion.subject.value == "") || (document.formAskQuestion.description.value == ""))
		alert('Please indicate subject and description field.');
	else
		document.formAskQuestion.submit();
}