//
// * This method is used to validate user inputs in the paint calculator
// * @param   webForm - The webForm containing the inputs.
// * @param   languageId - The language used to validate the inputs.
// */

function paintMetricNonRegularPieceValidation(webForm, languageId) {
	
   if ((webForm.height_1.value== '' && webForm.width_1.value!='') || (webForm.height_1.value!= '' && webForm.width_1.value=='')) {	  displayErrorMessage(10, languageId, webForm.height_1);
      return;
   }
   if ((webForm.height_2.value== '' && webForm.width_2.value!='') || (webForm.height_2.value!= '' && webForm.width_2.value=='')) {
      displayErrorMessage(10, languageId, webForm.height_2);
      return;
   }

   if ((webForm.height_3.value== '' && webForm.width_3.value!='') || (webForm.height_3.value!= '' && webForm.width_3.value=='')) {
      displayErrorMessage(10, languageId, webForm.height_3);
      return;
   }

   if ((webForm.height_4.value== '' && webForm.width_4.value!='') || (webForm.height_4.value!= '' && webForm.width_4.value=='')) {
	  displayErrorMessage(10, languageId, webForm.height_4);
      return;
   }

   if ((webForm.doorHeight.value== '' && webForm.doorWidth.value!='') || (webForm.doorHeight.value!='' && webForm.doorWidth.value=='')) {
	  displayErrorMessage(10, languageId, webForm.doorHeight);
      return;
   }

   if ((webForm.windowHeight.value== '' && webForm.windowWidth.value!='') || (webForm.windowHeight.value!='' && webForm.windowWidth.value=='')) {
	  displayErrorMessage(10, languageId, webForm.windowHeight);
      return;
   }
   
   if ((webForm.otherHeight.value== '' && webForm.otherWidth.value!='') || (webForm.otherHeight.value!='' && webForm.otherWidth.value=='')) {
	  displayErrorMessage(10, languageId, webForm.otherHeight);
      return;
   }

   validatePositifNumericFields(webForm, languageId);
}

// /*
// * This method is used to validate user inputs in the paint calculator
// * @param   webForm - The webForm containing the inputs.
// * @param   languageId - The language used to validate the inputs.
// */

function paintImperialNonRegularPieceValidation(webForm, languageId) {

   if (((webForm.height_1.value== '' && webForm.heightInch_1.value== '') && (webForm.width_1.value!= '' || webForm.widthInch_1.value!='')) || 
	   ((webForm.width_1.value== '' && webForm.widthInch_1.value=='') && (webForm.height_1.value!= '' || webForm.heightInch_1.value!=''))) {
	  displayErrorMessage(10, languageId, webForm.height_1);
      return;
   }

   if (((webForm.height_2.value== '' && webForm.heightInch_2.value== '') && (webForm.width_2.value!= '' || webForm.widthInch_2.value!='')) || 
	   ((webForm.width_2.value== '' && webForm.widthInch_2.value=='') && (webForm.height_2.value!= '' || webForm.heightInch_2.value!=''))) {

      displayErrorMessage(10, languageId, webForm.height_2);
      return;
   }

   if (((webForm.height_3.value== '' && webForm.heightInch_3.value== '') && (webForm.width_3.value!= '' || webForm.widthInch_3.value!='')) || 
	   ((webForm.width_3.value== '' && webForm.widthInch_3.value=='') && (webForm.height_3.value!= '' || webForm.heightInch_3.value!=''))) {

      displayErrorMessage(10, languageId, webForm.height_3);
      return;
   }

   if (((webForm.height_4.value== '' && webForm.heightInch_4.value== '') && (webForm.width_4.value!= '' || webForm.widthInch_4.value!='')) || 
	   ((webForm.width_4.value== '' && webForm.widthInch_4.value=='') && (webForm.height_4.value!= '' || webForm.heightInch_4.value!=''))) {
	  displayErrorMessage(10, languageId, webForm.height_4);
      return;
   }

   if ((webForm.doorHeight.value== '' && webForm.doorWidth.value!='') || (webForm.doorHeight.value!='' && webForm.doorWidth.value=='')) {
	  displayErrorMessage(10, languageId, webForm.doorHeight);
      return;
   }

   if ((webForm.windowHeight.value== '' && webForm.windowWidth.value!='') || (webForm.windowHeight.value!='' && webForm.windowWidth.value=='')) {
	  displayErrorMessage(10, languageId, webForm.windowHeight);
      return;
   }
   
   if ((webForm.otherHeight.value== '' && webForm.otherWidth.value!='') || (webForm.otherHeight.value!='' && webForm.otherWidth.value=='')) {
	  displayErrorMessage(10, languageId, webForm.otherHeight);
      return;
   }

   validatePositifNumericFields(webForm, languageId);
}

//
// * This method is used to validate user inputs in the paint calculator
// * @param   webForm - The webForm containing the inputs.
// * @param   languageId - The language used to validate the inputs.
// */

function paintMetricRegularPieceValidation(webForm, languageId) {

   if (!((webForm.height_1.value!= '') && (webForm.width_1.value!=''))) {
	  displayErrorMessage(10, languageId, webForm.height_1);
      return;
   }

   if ((webForm.doorHeight.value== '' && webForm.doorWidth.value!='') || (webForm.doorHeight.value!='' && webForm.doorWidth.value=='')) {
	  displayErrorMessage(10, languageId, webForm.doorHeight);
      return;
   }

   if ((webForm.windowHeight.value== '' && webForm.windowWidth.value!='') || (webForm.windowHeight.value!='' && webForm.windowWidth.value=='')) {
	  displayErrorMessage(10, languageId, webForm.windowHeight);
      return;
   }
   
   if ((webForm.otherHeight.value== '' && webForm.otherWidth.value!='') || (webForm.otherHeight.value!='' && webForm.otherWidth.value=='')) {
	  displayErrorMessage(10, languageId, webForm.otherHeight);
      return;
   }

   validatePositifNumericFields(webForm, languageId);
}

// **
// * This method is used to validate user inputs in the paint calculator
// * @param   webForm - The webForm containing the inputs.
// * @param   languageId - The language used to validate the inputs.
// */

function paintImperialRegularPieceValidation(webForm, languageId) {

   if (!((webForm.height_1.value!= '' || webForm.heightInch_1.value!= '') && (webForm.width_1.value!='' || webForm.widthInch_1.value!=''))) {
	  displayErrorMessage(10, languageId, webForm.height_1);
      return;
   }

   if ((webForm.doorHeight.value== '' && webForm.doorWidth.value!='') || (webForm.doorHeight.value!='' && webForm.doorWidth.value=='')) {
	  displayErrorMessage(10, languageId, webForm.doorHeight);
      return;
   }

   if ((webForm.windowHeight.value== '' && webForm.windowWidth.value!='') || (webForm.windowHeight.value!='' && webForm.windowWidth.value=='')) {
	  displayErrorMessage(10, languageId, webForm.windowHeight);
      return;
   }
   
   if ((webForm.otherHeight.value== '' && webForm.otherWidth.value!='') || (webForm.otherHeight.value!='' && webForm.otherWidth.value=='')) {
	  displayErrorMessage(10, languageId, webForm.otherHeight);
      return;
   }

   validatePositifNumericFields(webForm, languageId);
}


// **
// * This method displays the error Message.
// * @param   errorNumber - The number number of the error message.
// * @param	languageId - The language identifier
// * @param	inputToFocus - The field where the error is.
// */

function displayErrorMessage(errorNumber, languageId, inputToFocus) {

   if (errorNumber==10) {

       if (languageId==-2) {
	      errorMessage = 'Vous devez remplir les champs « Hauteur » et « Largeur » pour obtenir un résultat.';
	   } else {
          errorMessage = 'You must fill in the « Height » and « Width » fields to obtain a result.';
       }
   }

   inputToFocus.focus();
   inputToFocus.select();

   alert(errorMessage);
}

function validateWallpaperType(webForm, languageId) {
	var indexPitchChosen = parseInt( webForm.wallpaperFormat.selectedIndex );
	if(indexPitchChosen==0){
		alert((languageId == -1) ? "You must choose a wallpaper format." : "Veuillez choisir le format du papier peint." ); return false;
	}
	return true;
}
