/* ==================================================== */
/* ==============validatePeptide======================= */
/* ==================================================== */
/* fonction de verification des champs pour le formulaire quick quote : peptide */
function validatePeptide() { 
	var Contact_msg= '';
	var Quantites_msg= '';
	var Modification_msg= '';
	var str = ''; 
	var retVal = true;

	$('#Contact_msg').hide(); 
	$('#Quantites_msg').hide(); 
	$('#Modification_msg').hide(); 
/* --------- Gestion de la partie contact -----------*/
	str = $('input[@name=FName]').fieldValue();
	if (str.length==0) { 
		Contact_msg = addMessage(Contact_msg, 'Please indicate your First & last names');
		retVal = false;
	} 
	str = $('input[@name=Company]').fieldValue();
	if (str.length==0) { 
		Contact_msg = addMessage(Contact_msg, 'Please enter a value for Company/Institute/University');
		retVal = false;
	} 
	str = $('input[@name=Division]').fieldValue();
	if (str.length==0) { 
		Contact_msg = addMessage(Contact_msg, 'Please enter a value for Division/Department');
		retVal = false;
	} 
	str = $('input[@name=City]').fieldValue();
	if (str.length==0) { 
		Contact_msg = addMessage(Contact_msg, 'Please enter a value for City');
		retVal = false;
	} 
	str = $('input[@name=Tel]').fieldValue();
	if (str.length==0) { 
		Contact_msg = addMessage(Contact_msg, 'Please enter a value for Tel');
		retVal = false;
	} 
	str = $('input[@name=Fax]').fieldValue();
	if (str.length==0) { 
		Contact_msg = addMessage(Contact_msg, 'Please enter a value for Fax');
		retVal = false;
	} 
	str = $('input[@name=Email]').fieldValue();
	if (!validateEmail(str)||(str.length==0)) { 
		Contact_msg = addMessage(Contact_msg, 'Please enter a valid value for Email');
		retVal = false;
	} 

	if(Contact_msg){
		$('#Contact_msg').html(Contact_msg);
		$('#Contact_msg').show(); 
	}
/* --------- Gestion de la partie Quantity / Purity -----------*/
	str = $('input[@name=Quantity]').fieldValue();
	if (!str) { 
		Quantites_msg = addMessage(Quantites_msg, 'Please enter a value for Quantity / Purity');
		retVal = false;
	} 
	else {
		if (str == 'other') {
			str = $('input[@name=QuantityText]').fieldValue();
				if (str.length==0) { 
				Quantites_msg = addMessage(Quantites_msg, 'Please enter a value for other / Quantity');
				retVal = false;
			} 
			str = $('input[@name=PurityText]').fieldValue();
				if (str.length==0) { 
				Quantites_msg = addMessage(Quantites_msg, 'Please enter a value for other / Purity');
				retVal = false;
			} 
		}		
	}
	if(Quantites_msg){
		$('#Quantites_msg').html(Quantites_msg);
		$('#Quantites_msg').show(); 
	}
/* --------- Gestion de la partie Modification -----------*/
	str = $('input[@name=ModOther]').fieldValue();
	if (str == 'other') {
		str = $('#fModOtherText').val();
		if (!str) { 
			Modification_msg = addMessage(Modification_msg, 'Please enter a value for other / Modification');
			retVal = false;
		} 
	}
	if(Modification_msg){
		$('#Modification_msg').html(Modification_msg);
		$('#Modification_msg').show(); 
	}
	return (retVal);
}

/* ==================================================== */
/* ==============validateAntibodiesMain================ */
/* ==================================================== */

function validateAntibodiesMain(){
	var Contact_msg= '';
	var str = ''; 
	var retVal = true;

	$('#Contact_msg').hide(); 
/* --------- Gestion de la partie contact -----------*/
	str = $('input[@name=FName]').fieldValue();
	if (str.length==0) { 
		Contact_msg = addMessage(Contact_msg, 'Please enter a value for First & last names');
		retVal = false;
	} 
	str = $('input[@name=Company]').fieldValue();
	if (str.length==0) { 
		Contact_msg = addMessage(Contact_msg, 'Please enter a value for Company/Institute/University');
		retVal = false;
	} 
	str = $('input[@name=Division]').fieldValue();
	if (str.length==0) { 
		Contact_msg = addMessage(Contact_msg, 'Please enter a value for Division/Department');
		retVal = false;
	} 
	str = $('input[@name=City]').fieldValue();
	if (str.length==0) { 
		Contact_msg = addMessage(Contact_msg, 'Please enter a value for City');
		retVal = false;
	} 
	str = $('input[@name=Tel]').fieldValue();
	if (str.length==0) { 
		Contact_msg = addMessage(Contact_msg, 'Please enter a value for Tel');
		retVal = false;
	} 
	str = $('input[@name=Fax]').fieldValue();
	if (str.length==0) { 
		Contact_msg = addMessage(Contact_msg, 'Please enter a value for Fax');
		retVal = false;
	} 
	str = $('input[@name=Email]').fieldValue();
	if (!validateEmail(str)||(str.length==0)) { 
		Contact_msg = addMessage(Contact_msg, 'Please enter a valid value for Email');
		retVal = false;
	} 

	if(Contact_msg){
		$('#Contact_msg').html(Contact_msg);
		$('#Contact_msg').show(); 
	}

	return (retVal); 
}

/* ==================================================== */
/* ==============validateAntibodiesAPA================= */
/* ==================================================== */

function validateAntibodiesAPA(){
	var ProjectInformation_msg= '';
	var Carrier_msg= '';
	var Protocol_msg= '';
	var PeptideSpecials_msg= '';
	var Host_msg= '';
	var Purification_msg= '';
	var str = ''; 
	var retVal = true;

	$('#ProjectInformation_msg').hide(); 
	$('#Carrier_msg').hide(); 
	$('#Protocol_msg').hide(); 
	$('#PeptideSpecials_msg').hide(); 
	$('#Host_msg').hide(); 
	$('#Purification_msg').hide(); 
/* --------- Gestion de la partie carrier -----------*/
	str = $('input[@name=Carrier]').fieldValue();
	if (str.length==0) { 
		Carrier_msg = addMessage(Carrier_msg, 'Please enter a value for Carrier conjugate');
		retVal = false;
	} 
	else {
		if (str == 'other') {
			str = $('input[@name=CarrierText]').fieldValue();
				if (str.length==0) { 
				Carrier_msg = addMessage(Carrier_msg, 'Please enter a value for other / Carrier conjugate');
				retVal = false;
			} 
		}
	}

	if(Carrier_msg){
		$('#Carrier_msg').html(Carrier_msg);
		$('#Carrier_msg').show(); 
	}
/* --------- Gestion de la partie Protocol -----------*/
	str = $('input[@name=Protocol]').fieldValue();
	if (str.length==0) { 
		Protocol_msg = addMessage(Protocol_msg, 'Please enter a value for Protocol');
		retVal = false;
	} 
	else {
		if (str == 'Multi-peptide co-immunization') {
			str = $('input[@name=NbPeptidesPerProjectText]').fieldValue();
				if (str.length==0) { 
				Protocol_msg = addMessage(Protocol_msg, 'Please enter a value for Number of peptides per project');
				retVal = false;
			} 
		}
		if (str == 'other') {
			str = $('input[@name=ProtocolText]').fieldValue();
				if (str.length==0) { 
				Protocol_msg = addMessage(Protocol_msg, 'Please enter a value for other / Protocol');
				retVal = false;
			} 
		}
	}

	if(Protocol_msg){
		$('#Protocol_msg').html(Protocol_msg);
		$('#Protocol_msg').show(); 
	}
/* --------- Gestion de la partie Peptide Specials -----------*/
	str = $('input[@name=PeptideSpecials2]').fieldValue();
	if (str == 'Higher guaranteed peptide purity level') {
		str = $('input[@name=PurityRequired]').fieldValue();
		if (str.length==0) { 
			PeptideSpecials_msg = addMessage(PeptideSpecials_msg, 'Please enter a value for Purity required');
			retVal = false;
		} 
	}
	str = $('input[@name=PeptideSpecials3]').fieldValue();
	if (str == 'Higher guaranteed peptide amount') {
		str = $('input[@name=QuantityRequired]').fieldValue();
		if (str.length==0) { 
			PeptideSpecials_msg = addMessage(PeptideSpecials_msg, 'Please enter a value for Quantity required');
			retVal = false;
		} 
	}
	if(PeptideSpecials_msg){
		$('#PeptideSpecials_msg').html(PeptideSpecials_msg);
		$('#PeptideSpecials_msg').show(); 
	}
/* --------- Gestion de la partie Host -----------*/
	str = $('input[@name=HostChoice]').fieldValue();
	if (str == 'Selected Host') {
		str = $('#fSelectedHost1').val();
		if (str.length==0) { 
			Host_msg = addMessage(Host_msg, 'Please select your host');
			retVal = false;
		} 
		str = $('input[@name=nbHost]').fieldValue();
		if (str.length==0) { 
			Host_msg = addMessage(Host_msg, 'Please enter a value for Number of hosts per project');
			retVal = false;
		} 
	}
	else {
		if (str == 'Host Combination') {
			str = $('input[@name=Host2Text]').fieldValue();
			if (str.length==0) { 
				Host_msg = addMessage(Host_msg, 'Please enter a value for Host combination');
				retVal = false;
			} 
		}		
	}
	if(Host_msg){
		$('#Host_msg').html(Host_msg);
		$('#Host_msg').show(); 
	}
/* --------- Gestion de la partie Purification -----------*/
	str = $('input[@name=Purification]').fieldValue();
	if (str.length==0) { 
		Purification_msg = addMessage(Purification_msg, 'Please enter a value for Purification');
		retVal = false;
	} 
	if(Purification_msg){
		$('#Purification_msg').html(Purification_msg);
		$('#Purification_msg').show(); 
	}
	return (retVal); 
}

/* ==================================================== */
/* ==============validateAntibodiesAAP================= */
/* ==================================================== */

function validateAntibodiesAAP(){
	var Host_msg= '';
	var Purification_msg= '';
	var str = ''; 
	var retVal = true;

	$('#Host2_msg').hide(); 
	$('#Purification2_msg').hide(); 

/* --------- Gestion de la partie Host -----------*/
	str = $('input[@name=HostChoice2]').fieldValue();
	if (str == 'Selected Host') {
		str = $('#fSelectedHost2').val();
		if (str.length==0) { 
			Host_msg = addMessage(Host_msg, 'Please select your host');
			retVal = false;
		} 
		str = $('input[@name=nbHost2]').fieldValue();
		if (str.length==0) { 
			Host_msg = addMessage(Host_msg, 'Please enter a value for Number of hosts per project');
			retVal = false;
		} 
	}
	else {
		if (str == 'Host Combination') {
			str = $('input[@name=Host2Text2]').fieldValue();
			if (str.length==0) { 
				Host_msg = addMessage(Host_msg, 'Please enter a value for Host combination');
				retVal = false;
			} 
		}		
	}
	if(Host_msg){
		$('#Host2_msg').html(Host_msg);
		$('#Host2_msg').show(); 
	}
/* --------- Gestion de la partie Purification -----------*/
	str = $('input[@name=Purification2]').fieldValue();
	if (str.length==0) { 
		Purification_msg = addMessage(Purification_msg, 'Please enter a value for Purification');
		retVal = false;
	} 
	if(Purification_msg){
		$('#Purification2_msg').html(Purification_msg);
		$('#Purification2_msg').show(); 
	}
	return (retVal);
}

/* ==================================================== */
/* ==============validateGene========================== */
/* ==================================================== */

function validateGene(){
	var Contact_msg= '';
	var ProjectInformation_msg = '';
	var SequenceEngineering_msg= '';
	var AdditionalServices_msg= '';
	var str = ''; 
	var retVal = true;

	$('#Contact_msg').hide(); 
	$('#ProjectInformation_msg').hide(); 
	$('#SequenceEngineering_msg').hide(); 
	$('#AdditionalServices_msg').hide(); 
/* --------- Gestion de la partie contact -----------*/
	str = $('input[@name=FName]').fieldValue();
	if (str.length==0) { 
		Contact_msg = addMessage(Contact_msg, 'Please enter a value for First & last names');
		retVal = false;
	} 
	str = $('input[@name=Company]').fieldValue();
	if (str.length==0) { 
		Contact_msg = addMessage(Contact_msg, 'Please enter a value for Company/Institute/University');
		retVal = false;
	} 
	str = $('input[@name=Division]').fieldValue();
	if (str.length==0) { 
		Contact_msg = addMessage(Contact_msg, 'Please enter a value for Division/Department');
		retVal = false;
	} 
	str = $('input[@name=City]').fieldValue();
	if (str.length==0) { 
		Contact_msg = addMessage(Contact_msg, 'Please enter a value for City');
		retVal = false;
	} 
	str = $('input[@name=Tel]').fieldValue();
	if (str.length==0) { 
		Contact_msg = addMessage(Contact_msg, 'Please enter a value for Tel');
		retVal = false;
	} 
	str = $('input[@name=Fax]').fieldValue();
	if (str.length==0) { 
		Contact_msg = addMessage(Contact_msg, 'Please enter a value for Fax');
		retVal = false;
	} 
	str = $('input[@name=Email]').fieldValue();
	if (!validateEmail(str)||(str.length==0)) { 
		Contact_msg = addMessage(Contact_msg, 'Please enter a valid value for Email');
		retVal = false;
	} 

	if(Contact_msg){
		$('#Contact_msg').html(Contact_msg);
		$('#Contact_msg').show(); 
	}
/* --------- Gestion de la partie ProjectInformation -----------*/
	str = $('#FProjectDetailText').val();
	if (!str) { 
		ProjectInformation_msg = addMessage(ProjectInformation_msg, 'Please enter a value for Project Details');
		retVal = false;
	} 
	if(ProjectInformation_msg){
		$('#ProjectInformation_msg').html(ProjectInformation_msg);
		$('#ProjectInformation_msg').show(); 
	}
/* --------- Gestion de la partie SequenceEngineering -----------*/
	str = $('input[@name=CodonOptimization]').fieldValue();
	if (str) { 
		str = $('input[@name=CodonOptimizationText]').fieldValue();
		if (str.length==0) { 
			SequenceEngineering_msg = addMessage(SequenceEngineering_msg, 'Please enter a value for Codon optimization required for expression');
			retVal = false;
		} 	
	} 
	if(SequenceEngineering_msg){
		$('#SequenceEngineering_msg').html(SequenceEngineering_msg);
		$('#SequenceEngineering_msg').show(); 
	}
/* --------- Gestion de la partie SequenceEngineering -----------*/
	str = $('input[@name=CustomCloning]').fieldValue();
	if (str) { 
		str = $('input[@name=CustomCloningText]').fieldValue();
		if (str.length==0) { 
			AdditionalServices_msg = addMessage(AdditionalServices_msg, 'Please enter a value for Custom cloning into my provided vector');
			retVal = false;
		} 	
	} 
	str = $('input[@name=AdditionalPlasmid]').fieldValue();
	if (str) { 
		str = $('input[@name=AdditionalPlasmidText]').fieldValue();
		if (str.length==0) { 
			AdditionalServices_msg = addMessage(AdditionalServices_msg, 'Please enter a value for Additional plasmid preparation');
			retVal = false;
		} 	
	} 
	if(AdditionalServices_msg){
		$('#AdditionalServices_msg').html(AdditionalServices_msg);
		$('#AdditionalServices_msg').show(); 
	}
	return (retVal); 

}

/* ==================================================== */
/* ==============validateGeneral======================= */
/* ==================================================== */

function validateGeneral(){
	var Contact_msg= '';
	var str = ''; 
	var retVal = true;

	$('#Contact_msg').hide(); 
/* --------- Gestion de la partie contact -----------*/
	str = $('input[@name=FName]').fieldValue();
	if (str.length==0) { 
		Contact_msg = addMessage(Contact_msg, 'Please enter a value for First & last names');
		retVal = false;
	} 
	str = $('input[@name=Company]').fieldValue();
	if (str.length==0) { 
		Contact_msg = addMessage(Contact_msg, 'Please enter a value for Company/Institute/University');
		retVal = false;
	} 
	str = $('input[@name=Division]').fieldValue();
	if (str.length==0) { 
		Contact_msg = addMessage(Contact_msg, 'Please enter a value for Division/Department');
		retVal = false;
	} 
	str = $('input[@name=City]').fieldValue();
	if (str.length==0) { 
		Contact_msg = addMessage(Contact_msg, 'Please enter a value for City');
		retVal = false;
	} 
	str = $('input[@name=Tel]').fieldValue();
	if (str.length==0) { 
		Contact_msg = addMessage(Contact_msg, 'Please enter a value for Tel');
		retVal = false;
	} 
	str = $('input[@name=Fax]').fieldValue();
	if (str.length==0) { 
		Contact_msg = addMessage(Contact_msg, 'Please enter a value for Fax');
		retVal = false;
	} 
	str = $('input[@name=Email]').fieldValue();
	if (!validateEmail(str)||(str.length==0)) { 
		Contact_msg = addMessage(Contact_msg, 'Please enter a valid value for Email');
		retVal = false;
	} 

	if(Contact_msg){
		$('#Contact_msg').html(Contact_msg);
		$('#Contact_msg').show(); 
	}
	return (retVal); 

}


/* ==================================================== */
/* ==============validateOnlineOrderGeneric============ */
/* ==================================================== */

function validateOnlineOrderGeneric(){
	var ShippingInformation_msg = '';
	var InvoicingInformation_msg = ''
	var OrderInformation_msg = '';
	var str = ''; 
	var retVal = true;
	
	$('#ShippingInformation_msg').hide();
	$('#InvoicingInformation_msg').hide();
	$('#OrderInformation_msg').hide();
	str = $('#fShippingAddress').val();
	if (str.length==0) { 
		ShippingInformation_msg = addMessage(ShippingInformation_msg, 'Please enter a value for Shipping Address');
		retVal = false;
	} 
	str = $('#fShippingCity').val();
	if (str.length==0) { 
		ShippingInformation_msg = addMessage(ShippingInformation_msg, 'Please enter a value for Shipping City, Postal code');
		retVal = false;
	} 
	str = $('#fShippingCountry').val();
	if (str.length==0) { 
		ShippingInformation_msg = addMessage(ShippingInformation_msg, 'Please enter a value for Shipping Country');
		retVal = false;
	} 
	if(ShippingInformation_msg){
		$('#ShippingInformation_msg').html(ShippingInformation_msg);
		$('#ShippingInformation_msg').show(); 
	}

	str = $('#fInvoicingAddress').fieldValue();
	if (str.length==0) { 
		InvoicingInformation_msg = addMessage(InvoicingInformation_msg, 'Please enter a value for Invoicing Address');
		retVal = false;
	} 
	str = $('#fInvoicingCity').fieldValue();
	if (str.length==0) { 
		InvoicingInformation_msg = addMessage(InvoicingInformation_msg, 'Please enter a value for Invoicing City, Postal code');
		retVal = false;
	} 
	str = $('#fInvoicingCountry').fieldValue();
	if (str.length==0) { 
		InvoicingInformation_msg = addMessage(InvoicingInformation_msg, 'Please enter a value for Invoicing Country');
		retVal = false;
	} 
	if(InvoicingInformation_msg){
		$('#InvoicingInformation_msg').html(InvoicingInformation_msg);
		$('#InvoicingInformation_msg').show(); 
	}
	return (retVal); 

}

/* ==================================================== */
/* ==============validateOnlineOrderPeptide============ */
/* ==================================================== */

function validateOnlineOrderPeptide(){
	var retVal = true;
	var go1 = true;
	var go2 = true;
	go1 = validatePeptide();
	go2 = validateOnlineOrderGeneric();
	
	if (!go1 || !go2)
		retVal = false;

	return(retVal);
}

/* ==================================================== */
/* ==============validateOnlineOrderAntibodiesMain===== */
/* ==================================================== */

function validateOnlineOrderAntibodiesMain(){
	var retVal = true;
	var go1 = true;
	var go2 = true;
	
	go1 = validateAntibodiesMain();
	go2 = validateOnlineOrderGeneric();
	if (!go1 || !go2)
		retVal = false;
		
	return(retVal);
}

function validateOnlineOrderGene(){
	var retVal = true;
	var go1 = true;
	var go2 = true;
	
	go1 = validateGene();
	go2 = validateOnlineOrderGeneric();
	if (!go1 || !go2)
		retVal = false;
		
	return(retVal);
}

function validateOnlineOrderGeneral(){
	var retVal = true;

	var go1 = true;
	var go2 = true;
	
	go1 = validateGeneral();
	go2 = validateOnlineOrderGeneric();
	if (!go1 || !go2)
		retVal = false;
		
	return(retVal);
}
