function switchShape(a,b,c){showHnA(a?true:false);lbxChngProports(b&&!a?99:a);if(a){document.thisForm.HnA.checked=false;document.thisForm.AGS0.checked=false}else{document.thisForm.HnA.checked=c;document.thisForm.AGS0.checked=b}EnableCut(document.thisForm.AGS0.checked)}
function lbxChngProports(a){if(document.thisForm.dpt)switch(a){case 99:document.thisForm.dpt.value=58.7;document.thisForm.dpt2.value=62.3;document.thisForm.tbl.value=53;document.thisForm.tbl2.value=58;break;case 0:document.thisForm.dpt.value=58;document.thisForm.dpt2.value=63;document.thisForm.tbl.value=53;document.thisForm.tbl2.value=62;break;case 1:case 7:document.thisForm.dpt.value=57;document.thisForm.dpt2.value=74;document.thisForm.tbl.value=56;document.thisForm.tbl2.value=79;break;case 6:document.thisForm.dpt.value=
56;document.thisForm.dpt2.value=76;document.thisForm.tbl.value=57;document.thisForm.tbl2.value=83;break;case 2:case 3:case 4:case 5:document.thisForm.dpt.value=56;document.thisForm.dpt2.value=68.5;document.thisForm.tbl.value=51;document.thisForm.tbl2.value=67;break;default:document.thisForm.dpt.value=50;document.thisForm.dpt2.value=80;document.thisForm.tbl.value=50;document.thisForm.tbl2.value=83}}function shpChng(){switchShape(document.thisForm.shp.selectedIndex,0,0)}
function showHnA(a){document.thisForm.HnA.disabled=a;document.thisForm.AGS0.disabled=a}function checkAGS0(a){if(a)if(document.thisForm.shp.selectedIndex)document.thisForm.AGS0.checked=false;else switchShape(0,1,document.thisForm.HnA.checked);else{document.thisForm.HnA.checked=false;switchShape(0,0,0)}EnableCut(document.thisForm.AGS0.checked)}function clickAGS0(){checkAGS0(document.thisForm.AGS0.checked)}function clickHnA(){checkHnA(document.thisForm.HnA.checked)}
function checkHnA(a){if(a)if(document.thisForm.shp.selectedIndex)document.thisForm.HnA.checked=false;else document.thisForm.AGS0.checked=true;switchShape(0,1,a);EnableCut(document.thisForm.AGS0.checked)}function EnableCut(a){if(document.thisForm.cut)if(a){document.thisForm.cut.selectedIndex=0;document.thisForm.cut2.selectedIndex=0;document.thisForm.cut.disabled=true;document.thisForm.cut2.disabled=true}else{document.thisForm.cut.disabled=false;document.thisForm.cut2.disabled=false}}
function checkEdit(a,b,c,e){var d=parseFloat(a.value);if(isNaN(d)||!(d<=e&&d>=c)){a.focus();alert("Invalid "+b+": "+a.value+"!\nPlease enter "+b+" from "+c+" to "+e);return 1}return 0}
function onSubmit(a){if(checkEdit(document.thisForm.crt,"Carat",0.2,30))return false;if(checkEdit(document.thisForm.crt2,"Carat",0.2,30))return false;if(document.thisForm.dpt){if(checkEdit(document.thisForm.dpt,"Depth %",40,90))return false;if(checkEdit(document.thisForm.dpt2,"Depth",40,90))return false;if(checkEdit(document.thisForm.tbl,"Table %",40,90))return false;if(checkEdit(document.thisForm.tbl2,"Table",40,90))return false}document.thisForm.action=a;return true};
