﻿function __validateAmount(source, args) 
{
    var floatRegexp = /^([+]?(((\d+(\.)?)|(\d*\,\d+))([eE][+]?\d+)?))$/;

  if (!floatRegexp.test(args.Value)) {
      alert(document.getElementById(fieldID).value);
      args.IsValid = false;
  } else {
      if (args.Value > 100000) {
          alert(document.getElementById(fieldIDAmount).value);
          args.IsValid = false;
      } else {
          if (args.Value == 0) {
              alert(document.getElementById(fieldID).value);
              args.IsValid = false;
          } else {
              args.IsValid = true;
          }
      }
  }
}

function __tryPictureChange() {
    para1Found = false;
    para2Found = false;
    
    try {
        var para1 = document.getElementById(paraSelect1).value;
        para1Found = true;
    } catch (e) { }
        
    try {
        var para2 = document.getElementById(paraSelect2).value;
        para2Found = true;
    } catch (e) { }

    if (para1Found || para2Found) {
        index = 0;
        itemFound = false;
        itemPartlyFound = false;
        for (var i = 0; i < itemArr.length; i++) {
            if (para1Found && para2Found) {
                if (itemArr[i].Parameter1 == para1 && itemArr[i].Parameter2 == para2) {
                    index = i;
                    itemFound = true;
                    break;
                }

                if (itemArr[i].Parameter1 == para1) {
                    index = i;
                    itemPartlyFound = true;
                }

                if (itemArr[i].Parameter2 == para2 && !itemPartlyFound) {
                    index = i;
                    itemPartlyFound = true;
                }
            }

            if (para1Found && !para2Found) {
                if (itemArr[i].Parameter1 == para1) {
                    index = i;
                    itemFound = true;
                }
            }

            if (para2Found && !para1Found) {
                if (itemArr[i].Parameter2 == para2) {
                    index = i;
                    itemFound = true;
                }
            }
        }

        if (itemFound || itemPartlyFound)
            on_img(document.getElementById('MainPicture'), index);
    }
}
