function fractionToFloat(str) {
   if(str.length) {
      num = str.split("/");
      return num[0]/num[1];
   } else
      return 0;
}

function checkCustomValue(c, t) {
   if(t == 1) {
      cwVal = 0;
      cwiVal = 0;
      w = document.getElementById('sWidth'+c);
      cw = document.getElementById('cWidth'+c);
      cwi = document.getElementById('cWidthInch'+c);
      cwVal = (cw.value.length > 0) ? parseInt(cw.value) : 0;
      cwiVal = (cwi[cwi.selectedIndex].value.length > 0) ? eval(cwi[cwi.selectedIndex].value) : 0;
      if(((cwVal + cwiVal) - w[w.selectedIndex].value) > 1) {
         alert('Please go to next size!');
         cw.value = 0;
         cwi.selectedIndex = 0;
      }
   } else {
      chVal = 0;
      chiVal = 0;
      h = document.getElementById('sHeight'+c);
      ch = document.getElementById('cHeight'+c);
      chi = document.getElementById('cHeightInch'+c);
      chVal = (ch.value.length > 0) ? parseInt(ch.value) : 0;
      chiVal = (chi[chi.selectedIndex].value.length > 0) ? fractionToFloat(chi[chi.selectedIndex].value) : 0;
      if(((chVal + chiVal) - h.value) > 1) {
         alert('Please go to next size!');
         ch.value = 0;
         chi.selectedIndex = 0;
      }
   }
}


function checkCustomValueHV(c, t) {
   if(t == 1) {
      cwVal = 0;
      cwiVal = 0;
      w = document.getElementById('wdths'+c);
      cw = document.getElementById('cWidth'+c);
      cwi = document.getElementById('cWidthInch'+c);
      cwVal = (cw.value.length > 0) ? parseInt(cw.value) : 0;
      cwiVal = (cwi[cwi.selectedIndex].value.length > 0) ? eval(cwi[cwi.selectedIndex].value) : 0;
      if(((cwVal + cwiVal) - w.value) > 1) {
         alert('Please go to next size!');
         cw.value = 0;
         cwi.selectedIndex = 0;
      }
   } else {
      chVal = 0;
      chiVal = 0;
      h = document.getElementById('hghts'+c);
      ch = document.getElementById('cHeight'+c);
      chi = document.getElementById('cHeightInch'+c);
      chVal = (ch.value.length > 0) ? parseInt(ch.value) : 0;
      chiVal = (chi[chi.selectedIndex].value.length > 0) ? eval(chi[chi.selectedIndex].value) : 0;
      if(((chVal + chiVal) - h[h.selectedIndex].value) > 1) {
         alert('Please go to next size!');
         ch.value = 0;
         chi.selectedIndex = 0;
      }
   }
}