function FLB_validateFormTellFriend() { //v4.0
	var i,p,q,nm,nmT,test,num,min,max,errors='',args=FLB_validateForm.arguments;
	testForm = false;

	val = MM_findObj('the_name');
	val = val.value;
	if (val == "") {
		errors+='- You must enter your name.\n';
	}

	val = MM_findObj('the_email_add');
	p=val.value.indexOf('@');
	if (p<1 || p==(val.length-1)) {
		errors+='- You must enter a valid e-mail address.\n';
	}

	val = MM_findObj('friends_email_add');
	val = val.value;
	if (val == "") {
		errors+='- You must enter a valid friend s e-mail address.\n';
	}

	if (errors) {
		alert('The following error(s) occurred:\n'+errors);
	} else {
		if ( (BoutonSubmit=MM_findObj('Submit')) != null) {
			BoutonSubmit.disabled = true;
			BoutonSubmit.value = "Wait...";
		}
	}
	document.MM_returnValue = (errors == '');

}




function FLB_validateFormBeta() { //v4.0
	var i,p,q,nm,nmT,test,num,min,max,errors='',args=FLB_validateForm.arguments;
	testForm = false;

		val = MM_findObj('pb_email_add');
		p=val.value.indexOf('@');
		if (p<1 || p==(val.length-1)) {
			errors+='- You must enter a valid e-mail address.\n';
		}

	if (errors) {
		alert('The following error(s) occurred:\n'+errors);
	} else {
		if ( (BoutonSubmit=MM_findObj('Submit')) != null) {
			BoutonSubmit.disabled = true;
			BoutonSubmit.value = "Wait...";
		}
	}
	document.MM_returnValue = (errors == '');

}




function FLB_validateFormDemoTrynWin() { //v4.0
	var i,p,q,nm,nmT,test,num,min,max,errors='',args=FLB_validateForm.arguments;
	testForm = false;
	n = document.forms.downloaddemo.DxO_Correction_Module.length;
	for (i=0;i<n;i++)
		{ if (document.forms.downloaddemo.DxO_Correction_Module[i].checked) { testForm = true; } }
	if (!testForm) {
		errors+='- Please choose your DxO Correction Module and your OS.\n';
	}

	if (document.forms.downloaddemo.TypeDownload[0].checked) {
	/*
		val = MM_findObj('question_1');
		if (val.options[val.selectedIndex].value == "#") {
			errors += '- Question 1 is mandatory.\n';
		}
	
		val = MM_findObj('question_2');
		if (val.options[val.selectedIndex].value == "#") {
			errors += '- Question 2 is mandatory.\n';
		}
	
		val = MM_findObj('question_3');
		if (val.options[val.selectedIndex].value == "#") {
			errors += '- Question 3 is mandatory.\n';
		}
	
		val = MM_findObj('question_4');
		val = val.value;
		if (val == "") {
			errors += '- Supplementary question is mandatory.\n';
		}
	
		val = MM_findObj('rules');
		if (!val.checked) {
			errors += '- You must accept the rules of the contest to participate.\n';
		}
	*/
	
	
		
		
		val = MM_findObj('first_name');
		val = val.value;
		if (val == "") {
			errors += '- First name is mandatory.\n';
		}
	
		val = MM_findObj('last_name');
		val = val.value;
		if (val == "") {
			errors += '- Name is mandatory.\n';
		}
	
		val = MM_findObj('city');
		val = val.value;
		if (val == "") {
			errors += '- City is mandatory.\n';
		}
	
		val = MM_findObj('country');
		val = val.value;
		if (val == "") {
			errors += '- Country is mandatory.\n';
		}
	
		
		val = MM_findObj('origin');
		if (val.options[val.selectedIndex].value == "#") {
			errors += '- How did you hear about the contest? is mandatory\n';
		}
	
	
		val = MM_findObj('email_address');
		val = val.value;
		if (val == "") {
			errors += '- You must enter a valid e-mail address.\n';
		} else {
			p=val.indexOf('@');
			if (p<1 || p==(val.length-1)) {
				errors+='- You must enter a valid e-mail address.\n';
			}
		}

	} else if (document.forms.downloaddemo.TypeDownload[1].checked) {
		
		val = MM_findObj('pb_email_add');
		p=val.value.indexOf('@');
		if (p<1 || p==(val.length-1)) {
			errors+='- You must enter a valid e-mail address.\n';
		}
	}


	if (errors) {
		alert('The following error(s) occurred:\n'+errors);
	} else {
		if ( (BoutonSubmit=MM_findObj('Submit1')) != null) {
			BoutonSubmit.disabled = true;
			BoutonSubmit.value = "Wait...";
		}
		if ( (BoutonSubmit=MM_findObj('Submit2')) != null) {
			BoutonSubmit.disabled = true;
			BoutonSubmit.value = "Wait...";
		}
	}
	document.MM_returnValue = (errors == '');
}





function FLB_validateFormDemo() { //v4.0
	var i,p,q,nm,nmT,test,num,min,max,errors='',args=FLB_validateForm.arguments;
	testForm = false;
	n = document.forms.downloaddemo.DxO_Correction_Module.length;
	for (i=0;i<n;i++)
		{ if (document.forms.downloaddemo.DxO_Correction_Module[i].checked) { testForm = true; } }
	if (!testForm) {
		errors+='- Please choose your DxO Correction Module and your OS.\n';
	}


/*
if (document.forms.downloaddemo.TypeDownload[0].checked) {

		val = MM_findObj('question_1');
		if (val.options[val.selectedIndex].value == "#") {
			errors += '- Question 1 is mandatory.\n';
		}

		val = MM_findObj('question_2');
		if (val.options[val.selectedIndex].value == "#") {
			errors += '- Question 2 is mandatory.\n';
		}

		val = MM_findObj('question_3');
		if (val.options[val.selectedIndex].value == "#") {
			errors += '- Question 3 is mandatory.\n';
		}

		val = MM_findObj('question_4');
		val = val.value;
		if (val == "") {
			errors += '- Supplementary question is mandatory.\n';
		}

		val = MM_findObj('rules');
		if (!val.checked) {
			errors += '- You must accept the rules of the contest to participate.\n';
		}



		
		
		val = MM_findObj('first_name');
		val = val.value;
		if (val == "") {
			errors += '- First name is mandatory.\n';
		}

		val = MM_findObj('last_name');
		val = val.value;
		if (val == "") {
			errors += '- Name is mandatory.\n';
		}

		val = MM_findObj('city');
		val = val.value;
		if (val == "") {
			errors += '- City is mandatory.\n';
		}

		val = MM_findObj('country');
		val = val.value;
		if (val == "") {
			errors += '- Country is mandatory.\n';
		}

		
		val = MM_findObj('origin');
		if (val.options[val.selectedIndex].value == "#") {
			errors += '- How did you hear about the contest? is mandatory.\n';
		}


		val = MM_findObj('email_address');
		val = val.value;
		if (val == "") {
			errors += '- You must enter a valid e-mail address.\n';
		} else {
			p=val.indexOf('@');
			if (p<1 || p==(val.length-1)) {
				errors+='- You must enter a valid e-mail address.\n';
			}
		}
	}
	else if (document.forms.downloaddemo.TypeDownload[1].checked) {
		*/
		val = MM_findObj('pb_email_add');
		p=val.value.indexOf('@');
		if (p<1 || p==(val.length-1)) {
			errors+='- You must enter a valid e-mail address.\n';
		}
/*	}*/


	val = MM_findObj('pb_country');
	if (val.options[val.selectedIndex].value == "0") {
		errors += '- Please choose your country.\n';
	}




	if (errors) {
		alert('The following error(s) occurred:\n'+errors);
	} else {
		if ( (BoutonSubmit=MM_findObj('Submit1')) != null) {
			BoutonSubmit.disabled = true;
			BoutonSubmit.value = "Wait...";
		}
		if ( (BoutonSubmit=MM_findObj('Submit2')) != null) {
			BoutonSubmit.disabled = true;
			BoutonSubmit.value = "Wait...";
		}
	}
	document.MM_returnValue = (errors == '');
}







function FLB_validateForm() { //v4.0
	var i,p,q,nm,nmT,test,num,min,max,errors='',args=FLB_validateForm.arguments;
	if ( MM_findObj('TheForm').value == 'pb_img_quality' ) {
		var m=0; 
		var tabalgo = new Array('a', 'b', 'c', 'd', 'e');
		for (i=0;i<5;i++) {
			if (eval("document.forms.support.pb_algorithms_used_"+tabalgo[i]+".checked == true")){
				m=m+1;
				}
			}
		if ( !(m>=1) ) {
			errors+='- At least one algorithm must be selected.\n';
		}
	} else if ( MM_findObj('TheForm').value == 'downloaddemo' ) {
		testForm = false;
		n = document.forms.downloaddemo.DxO_Correction_Module.length;
		for (i=0;i<n;i++)
			{ if (document.forms.downloaddemo.DxO_Correction_Module[i].checked) { testForm = true; } }
		if (!testForm) {
			errors+='- Please choose your DxO Correction Module and your OS.\n';
		}
	} else if ( MM_findObj('TheForm').value == 'availability' ) {
		testBody = false;
		for (i=1; i<document.forms.support.elements['body1'].options.length ;i++) { if (document.forms.support.elements['body1'].options[i].selected == true) { testBody = true; } }
		if (!testBody) {
			errors+='- At least one Correction Module (Camera body & lens) must be selected.\n';
		}
	} else if ( MM_findObj('TheForm').value == 'reseller_register' ) {
		testBody = false;
		val = MM_findObj('country');
		if (val.options[val.selectedIndex].value == "0") {
			errors += '- Please choose your country.\n';
		}
	}
	
	for (i=0; i<(args.length-2); i+=3) {
		test=args[i+2];
		val=MM_findObj(args[i]);
		if (val) {
			nm=val.name;
			nmT='';
			switch (nm){
				// ---Form Reseller Register
				case 'company_name':
					nmT='Company name';
					break;
				case 'town':
					nmT='Town';
					break;
				case 'zip_code':
					nmT='Zip code';
					break;
				case 'phone_number':
					nmT='Phone number';
					break;
				case 'email_address':
					nmT='email address';
					break;
				case 'country':
					nmT='Country';
					break;
				// ---Form Support
				case 'pb_name':
					nmT='Name';
					break;
				case 'pb_order_num':
					nmT='Order number';
					break;
				case 'pb_email_add':
					nmT='E-Mail address';
					break;
				case 'pb_telephone':
					nmT='Telephone number';
					break;
				case 'pb_op_system':
					nmT='Operating system';
					break;
				case 'pb_type_of_order':
					nmT='Type of order';
					break;
				case 'pb_type_pb':
					nmT='Type of problem';
					break;
				case 'pb_desc_pb':
					nmT='Description of the problem';
					break;
				case 'pb_cpu':
					nmT='CPU';
					break;
				case 'pb_ram':
					nmT='RAM';
					break;
				case 'pb_module_used':
					nmT='DxO Correction Module used';
					break;
				case 'pb_camera_used':
					nmT='Camera used';
					break;
				case 'pb_lens_used':
					nmT='Lens used';
					break;
				case 'pb_comments_questions':
					nmT='Comments / Questions';
					break;
			}
			if ((val=val.value)!="") {
				if (test.indexOf('isEmail')!=-1) {
					p=val.indexOf('@');
					if (p<1 || p==(val.length-1)) {
						errors+='- '+nmT+' must contain an e-mail address.\n';
					}
				} else if (test!='R') {
					num = parseFloat(val);
					if (isNaN(val)) {
						errors+='- '+nmT+' must contain a number.\n';
					}
					if (test.indexOf('inRange') != -1) {
						p=test.indexOf(':');
						min=test.substring(8,p);
						max=test.substring(p+1);
						if (num<min || max<num) {
							errors+='- '+nmT+' must contain a number between '+min+' and '+max+'.\n';
						}
					}
				}
			} else if (test.charAt(0) == 'R') {
				errors += '- '+nmT+' is required.\n';
			}
		}
	}
	if (errors) {
		alert('The following error(s) occurred:\n'+errors);
	} else {
		if ( (BoutonSubmit=MM_findObj('Submit')) != null) {
			BoutonSubmit.disabled = true;
			BoutonSubmit.value = "Wait...";
		}
	}
	document.MM_returnValue = (errors == '');
}

function FLB_validateFormAvailability() { //v4.0
	var tBod1=false,tBod2=false,tBod3=false,tBod4=false,tBod5,tBod6,tBod7,tBod8;
	var errors='',tLens1,tLens2,tLens3,tLens4,tLens5,tLens6,tLens7,tLens8,tMail,valMail;

	for (i=1; i<document.forms.support.elements['body1'].options.length ;i++) {
		if (document.forms.support.elements['body1'].options[i].selected == true) { tBod1 = true; }
	}
	
	for (i=1; i<document.forms.support.elements['body2'].options.length ;i++) {
		if (document.forms.support.elements['body2'].options[i].selected == true) { tBod2 = true; }
	}

	for (i=1; i<document.forms.support.elements['body3'].options.length ;i++) {
		if (document.forms.support.elements['body3'].options[i].selected == true) { tBod3 = true; }
	}

	for (i=1; i<document.forms.support.elements['body4'].options.length ;i++) {
		if (document.forms.support.elements['body4'].options[i].selected == true) { tBod4 = true; }
	}

	tBod5 = (document.forms.support.elements['body5'].value != '');
	tBod6 = (document.forms.support.elements['body6'].value != '');
	tBod7 = (document.forms.support.elements['body7'].value != '');
	tBod8 = (document.forms.support.elements['body8'].value != '');

	tLen1 = (document.forms.support.elements['lens1'].value != '');
	tLen2 = (document.forms.support.elements['lens2'].value != '');
	tLen3 = (document.forms.support.elements['lens3'].value != '');
	tLen4 = (document.forms.support.elements['lens4'].value != '');
	tLen5 = (document.forms.support.elements['lens5'].value != '');
	tLen6 = (document.forms.support.elements['lens6'].value != '');
	tLen7 = (document.forms.support.elements['lens7'].value != '');
	tLen8 = (document.forms.support.elements['lens8'].value != '');

	if (!tBod1 && !tBod2 && !tBod3 && !tBod4 && !tBod5 && !tBod6 && !tBod7 && !tBod8 && !tLen1 && !tLen2 && !tLen3 && !tLen4 && !tLen5 && !tLen6 && !tLen7 && !tLen8) {
		errors='At least one Correction Module (Camera body & lens) must be selected.';
	} else {
		tBodLen1 = (tBod1 == tLen1);
		tBodLen2 = (tBod2 == tLen2);
		tBodLen3 = (tBod3 == tLen3);
		tBodLen4 = (tBod4 == tLen4);
		tBodLen5 = ( (tBod5 == tLen5) || (tBod5 == true && tLen5 == false) );
		tBodLen6 = ( (tBod6 == tLen6) || (tBod6 == true && tLen6 == false) );
		tBodLen7 = ( (tBod7 == tLen7) || (tBod7 == true && tLen7 == false) );
		tBodLen8 = ( (tBod8 == tLen8) || (tBod8 == true && tLen8 == false) );
/*
alert('tBod1 = ' + tBod1);
alert('tBod2 = ' + tBod2);
alert('tBod3 = ' + tBod3);
alert('tBod4 = ' + tBod4);
alert('tBod5 = ' + tBod5);
alert('tBod6 = ' + tBod6);
alert('tBod7 = ' + tBod7);
alert('tBod8 = ' + tBod8);

alert('tLen1 = ' + tLen1);
alert('tLen2 = ' + tLen2);
alert('tLen3 = ' + tLen3);
alert('tLen4 = ' + tLen4);
alert('tLen5 = ' + tLen5);
alert('tLen6 = ' + tLen6);
alert('tLen7 = ' + tLen7);
alert('tLen8 = ' + tLen8);

alert('tBodLen1 = ' + tBodLen1);
alert('tBodLen2 = ' + tBodLen2);
alert('tBodLen3 = ' + tBodLen3);
alert('tBodLen4 = ' + tBodLen4);
alert('tBodLen5 = ' + tBodLen5);
alert('tBodLen6 = ' + tBodLen6);
alert('tBodLen7 = ' + tBodLen7);
alert('tBodLen8 = ' + tBodLen8);
*/
		if (tBodLen1 && tBodLen2 && tBodLen3 && tBodLen4 && tBodLen5 && tBodLen6 && tBodLen7 && tBodLen8) {
			valMail = document.forms.support.elements['pb_email_add'].value;
			if (valMail!="") {
				p=valMail.indexOf('@');
				if (p<1 || p==(valMail.length-1)) {
					errors='Your e-mail address must contain an e-mail address.';
				}
			} else {
				errors='Your e-mail address is required.';
			}
		} else {
			errors='One or several fields are missing.';
		}
	}

	if (errors) {
		alert(errors);
	} else {
		if ( (BoutonSubmit=MM_findObj('Submit')) != null) {
			BoutonSubmit.disabled = true;
			BoutonSubmit.value = "Wait...";
		}
	}
	document.MM_returnValue = (errors == '');
}

