function selectModel(pn) {
var size = pn.substr(0, 1);
var conn = pn.substr(6, 1);
var hand = pn.substr(7);
// alert('size: '+size+' conn: '+conn+' hand: '+hand );
//----------------------------------- SELECT SIZE NPT ----------------------------
if (conn == "N") {
if (size == "C") {
document.codeform.size[0].checked=true;
}
if (size == "D") {
document.codeform.size[1].checked=true;
}
if (size == "E") {
document.codeform.size[2].checked=true;
}
if (size == "F") {
document.codeform.size[3].checked=true;
}
if (size == "G") {
document.codeform.size[4].checked=true;
}
if (size == "H") {
document.codeform.size[5].checked=true;
}
}
//----------------------------------- SELECT SIZE Solder ----------------------------
if (conn == "S") {
if (size == "C") {
document.codeform.size[6].checked=true;
}
if (size == "D") {
document.codeform.size[7].checked=true;
}
if (size == "E") {
document.codeform.size[8].checked=true;
}
if (size == "F") {
document.codeform.size[9].checked=true;
}
if (size == "G") {
document.codeform.size[10].checked=true;
}
if (size == "H") {
document.codeform.size[11].checked=true;
}
}
//----------------------------------- SELECT Handle ----------------------------
if (hand == "M") {
document.codeform.handle[0].checked=true;
}
if (hand == "ML") {
document.codeform.handle[1].checked=true;
}
if (hand == "ME") {
document.codeform.handle[2].checked=true;
}
if (hand == "MT") {
document.codeform.handle[3].checked=true;
}
if (hand == "MO") {
document.codeform.handle[4].checked=true;
}
changeCode();
}
function changeCode() {
// set vars that don't change and initialize others
var sol = "";
var seal = "";
var bodyMat = "";
var voltage = "";
var fail = "";
var pic = "VAX";
var solVolt = "";
var solType = "";
var solCon = "";
var bodyMatDescrip = "";
var sizeDescrip = "";
var sealDescrip = "";
var solDescrip = "";
var solConDescrip = "";
var solVoltDescrip = "";
var solTypeDescrip = "";
var solRatingDescrip = "";
var accessDescrip = ""; // ----------- actuator accesories on assembly
var accessoryDescrip = ""; // ------- accesories that ship loose
var actpic = "";
var solpic = "";
var failPos = "";
var accPrice = 0;
var priceSum = "Pricing:";
var weightSum = "Weight:";
var ways = "";
var solPrice = 0;
var solWeight = 0;
var price = 0;
var accessPrice = 0;
var accessoryPrice = 0;
var assemblyWeight = 0;
var accessWeight = 0;
var accessoryWeight = 0;
var actcad = "";
var S4mod = "";
var S4bat = "";
var S4din = "";
var s4kitName = "";
var step1summary = "";
var step2summary = "";
var step3summary = "";
var alertNote = "";
// ====================== reset classes of all selection divs and table cells to UN-selected state
resetSizeDivs();
resetHandDivs();
// ================= reset summary boxes ==========================
document.getElementById('priceSummary').innerHTML = "Error!";
document.getElementById('weightSummary').innerHTML = "Error!";
// ================================================ SIZE ====================================================
if (document.codeform.size[0].checked) {
document.getElementById('size1').className="selectionChecked";
var siz = "C"; var con = "N"; var sizeDescrip = "1/2 inch NPT"; }
if (document.codeform.size[1].checked) {
document.getElementById('size2').className="selectionChecked";
var siz = "D"; var con = "N"; var sizeDescrip = "3/4 inch NPT"; }
if (document.codeform.size[2].checked) {
document.getElementById('size3').className="selectionChecked";
var siz = "E"; var con = "N"; var sizeDescrip = "1 inch NPT"; }
if (document.codeform.size[3].checked) {
document.getElementById('size4').className="selectionChecked";
var siz = "F"; var con = "N"; var sizeDescrip = "1 1/4 inch NPT"; }
if (document.codeform.size[4].checked) {
document.getElementById('size5').className="selectionChecked";
var siz = "G"; var con = "N"; var sizeDescrip = "1 1/2 inch NPT"; }
if (document.codeform.size[5].checked) {
document.getElementById('size6').className="selectionChecked";
var siz = "H"; var con = "N"; var sizeDescrip = "2 inch NPT"; }
if (document.codeform.size[6].checked) {
document.getElementById('size7').className="selectionChecked";
var siz = "C"; var con = "S"; var sizeDescrip = "1/2 inch Solder"; }
if (document.codeform.size[7].checked) {
document.getElementById('size8').className="selectionChecked";
var siz = "D"; var con = "S"; var sizeDescrip = "3/4 inch Solder"; }
if (document.codeform.size[8].checked) {
document.getElementById('size9').className="selectionChecked";
var siz = "E"; var con = "S"; var sizeDescrip = "1 inch Solder"; }
if (document.codeform.size[9].checked) {
document.getElementById('size10').className="selectionChecked";
var siz = "F"; var con = "S"; var sizeDescrip = "1 1/4 inch Solder"; }
if (document.codeform.size[10].checked) {
document.getElementById('size11').className="selectionChecked";
var siz = "G"; var con = "S"; var sizeDescrip = "1 1/2 inch Solder"; }
if (document.codeform.size[11].checked) {
document.getElementById('size12').className="selectionChecked";
var siz = "H"; var con = "S"; var sizeDescrip = "2 inch Solder"; }
// =================== exceptions for certain sizes =================
if (siz == "F" || siz == "G" || siz == "H" || siz == "I" || siz == "J" || siz == "K") {
disableTee();
}
if (siz == "I" || siz == "J" || siz == "K") {
disableOval();
}
if ((siz == "I" || siz == "J" || siz == "K") && con != "N") {
disableLock();
}
if ((siz == "K") && con != "N") {
disableExt();
}
// =================== Step 1 Summary =================
var flowTube = "Flow Tube: Stainless Steel (wetted)";
var bodyMatDescrip = "Valve Body: Lead Free Brass";
var sizeDescrip = "Size and Connection: "+sizeDescrip;
var step1summary = bodyMatDescrip + "
"+sizeDescrip;
document.getElementById('step1summary').innerHTML = step1summary;
// ======================================================== SET step 2 summary ==================================================
// ================================================ HANDLE TYPE ====================================================
if (document.codeform.handle[0].checked) { document.getElementById('handle1').className="selectionChecked"; var act = "M"; var actDescrip = "Basic Lever"; }
if (document.codeform.handle[1].checked) { document.getElementById('handle2').className="selectionChecked"; var act = "ML"; var actDescrip = "Locking Lever (lock NOT included)"; }
if (document.codeform.handle[2].checked) { document.getElementById('handle3').className="selectionChecked"; var act = "ME"; var actDescrip = "Lever with Extension"; }
if (document.codeform.handle[3].checked) { document.getElementById('handle4').className="selectionChecked"; var act = "MT"; var actDescrip = "Tee"; }
if (document.codeform.handle[4].checked) { document.getElementById('handle5').className="selectionChecked"; var act = "MO"; var actDescrip = "Oval"; }
var actDescrip = "Handle: "+actDescrip;
var step2summary = actDescrip;
document.getElementById('step2summary').innerHTML = step2summary;
// ======================================================== SET step 3 summary ==================================================
// ==================== SET DIME PAGE =====================
if (con == "N") {
document.codeform.dimPage.value ="2";
}
if (con == "S") {
document.codeform.dimPage.value ="3";
}
// =========================================================== SET MODEL CODE =============================================
var mc=siz+"282LF"+con+act;
var valveBody= siz+"282LF"+con+act;
var pic = con+act;
var CADmc=siz+"VAX"+bodyMat+ways+act;
document.getElementById('PN').innerHTML =mc;
document.codeform.id.value=mc;
document.getElementById('MClinks').innerHTML =mc;
document.getElementById('mainIMG').src = "/lead-free-ball-valves/models/"+pic+".jpg";
document.codeform.imgsrc.value="/lead-free-ball-valves/models/"+pic+".jpg";
// =========================================================== SET PRICING =============================================
var qty = document.codeform.qty.value;
// VALVE =--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
var basePrice = eval(valveBody+".price");
var baseWeight = eval(valveBody+".weight");
var priceSum = priceSum + "
Valve Price: "+basePrice+" ("+valveBody+")";
var weightSum = weightSum + "
Valve: "+baseWeight+" ("+valveBody+")";
// SOLENOID =--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
if (sol != "") {
if (solCon == "1" || solCon == "2") {
solPrice = eval(sol+".price")+LABUNIT.price;
solWeight = eval(sol+".weight");
var priceSum = priceSum + "
Solenoid Price: "+solPrice+" ("+sol+")";
var weightSum = weightSum + "
Solenoid: "+solWeight+" ("+sol+")";
} else {
solBase = solType + solVolt;
if (solCon == "3") { var solConID = "VEP_1005_70_HC"; }
if (solCon == "4") { var solConID = "VEP_1005_70_HCC"; }
if (solCon == "5") { var solConID = "CA5J560_000_US0G"; }
if (solCon == "6") { var solConID = "CA5J5F0_000_US0G"; }
solPrice = eval(solBase+".price") + eval(solConID+".price")+LABUNIT.price;
solWeight = eval(solBase+".weight") + eval(solConID+".weight");
var priceSum = priceSum + "
Solenoid Price: "+solPrice+" ("+solBase+", "+solConID+")";
var weightSum = weightSum + "
Solenoid: "+solWeight+" ("+solBase+", "+solConID+")";
}
}
// LABOR =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
if (sol != "") {
var mountLab = 0;
} else {
var mountLab = 1;
}
//alert(priceSum);
var mountPrice= mountLab * LABUNIT.price;
var fullPrice = Math.ceil(basePrice + solPrice);
var fullWeight = Math.ceil(baseWeight + solWeight);
document.getElementById('price').innerHTML = fullPrice;
document.codeform.price.value=fullPrice;
document.codeform.weight.value=fullWeight;
document.getElementById('priceSummary').innerHTML = priceSum;
document.getElementById('weightSummary').innerHTML = weightSum+"
TOTAL: "+fullWeight+" lbs.";
var totalPrice = (fullPrice + accessPrice) * qty;
document.getElementById('totalPrice').innerHTML = totalPrice;
// =========================================================== SET DESCRIPTION =============================================
var fullSummary = step1summary + "
" + step2summary + "
" + step3summary;
if (alertNote != "") {
// alert(alertNote+ 'oooooops');
var fullSummary = fullSummary + "
" + alertNote;
}
document.getElementById('fullSummary').innerHTML = fullSummary;
document.codeform.info.value=fullSummary;
if (accessoryPrice != 0) {
document.getElementById('accessoryPriceText').style.display="block";
document.getElementById('accessoryPrice').innerHTML=accessoryPrice;
document.getElementById('accessorySummary').innerHTML=accessoryDescrip;
} else {
document.getElementById('accessoryPriceText').style.display="none";
}
}
// ========================================================== END OF MAIN FUNCTION ============================================================
// ============================================================= OTHER FUNCTIONS =========================================================
function addToCart() {
document.codeform.submit();
}
function showHideAccess(item) {
if (document.getElementById(item+"BOX").style.display == "none") {
document.getElementById(item+"BOX").style.display = "block";
document.getElementById(item+"HEAD").className = "accessHeadOpen";
document.getElementById(item).checked = 1;
} else {
document.getElementById(item+"BOX").style.display = "none";
document.getElementById(item+"HEAD").className = "accessHead";
document.getElementById(item).checked = 0;
}
}
function resetSizeDivs() {
document.getElementById('size1').className="selection";
document.getElementById('size2').className="selection";
document.getElementById('size3').className="selection";
document.getElementById('size4').className="selection";
document.getElementById('size4').className="selection";
document.getElementById('size5').className="selection";
document.getElementById('size6').className="selection";
document.getElementById('size7').className="selection";
document.getElementById('size8').className="selection";
document.getElementById('size9').className="selection";
document.getElementById('size10').className="selection";
document.getElementById('size11').className="selection";
document.getElementById('size12').className="selection";
}
function resetHandDivs() {
document.getElementById('handle1').className="selection";
document.getElementById('handle2').className="selection";
document.getElementById('handle3').className="selection";
document.getElementById('handle4').className="selection";
document.getElementById('handle5').className="selection";
}
function disableTee() {
if (document.codeform.handle[3].checked) {
document.codeform.handle[0].checked = 1;
}
document.getElementById('handle4').className="selectionDisabled";
}
function disableOval() {
if (document.codeform.handle[4].checked) {
document.codeform.handle[0].checked = 1;
}
document.getElementById('handle5').className="selectionDisabled";
}
function disableExt() {
if (document.codeform.handle[2].checked) {
document.codeform.handle[0].checked = 1;
}
document.getElementById('handle3').className="selectionDisabled";
}
function disableLock() {
if (document.codeform.handle[1].checked) {
document.codeform.handle[0].checked = 1;
}
document.getElementById('handle2').className="selectionDisabled";
}
function closeStep(step) {
document.getElementById('step'+step+'close').style.display="none";
document.getElementById('step'+step+'edit').style.display="block";
document.getElementById('step'+step+'section').style.display="none";
document.getElementById('step'+step+'summary').style.display="block";
}
function editStep(step) {
document.getElementById('step'+step+'close').style.display="block";
document.getElementById('step'+step+'edit').style.display="none";
document.getElementById('step'+step+'section').style.display="block";
document.getElementById('step'+step+'summary').style.display="none";
}