if( !ESET ) {
  var ESET = {};
}

ESET.ProductSelector = {

  prices: {
    ess: {
      1: {
        1: {price: '59.99', buyid: '1603'},
        2: {price: '89.99', buyid: '1650'}
      },
      2: {
        1: {price: '69.99', buyid: '1675'},
        2: {price: '103.99', buyid: '1678'}
      },
      3: {
        1: {price: '89.99', buyid: '1676'},
        2: {price: '133.99', buyid: '1679'}
      },
      4: {
        1: {price: '119.99', buyid: '1677'},
        2: {price: '179.99', buyid: '1680'}
      }
    },
    eav: {
      1: {
        1: {price: '39.99', buyid: '924'},
        2: {price: '58.99', buyid: '894'}
      },
      2: {
        1: {price: '55.99', buyid: '908'},
        2: {price: '82.99', buyid: '910'}
      },
      3: {
        1: {price: '71.99', buyid: '907'},
        2: {price: '106.99', buyid: '911'}
      },
      4: {
        1: {price: '95.99', buyid: '909'},
        2: {price: '143.99', buyid: '912'}
      }
    },
    esssmb: {
      1: {
        1: {price: '254.95', buyid: '1763'},
        2: {price: '384.95', buyid: '1784'}
      },
      2: {
        1: {price: '509.90', buyid: '1778'},
        2: {price: '769.90', buyid: '1785'}
      },
      3: {
        1: {price: '651.60', buyid: '1779'},
        2: {price: '970.35', buyid: '1786'}
      }
    },
    eavsmb: {
      1: {
        1: {price: '214.95', buyid: '837'},
        2: {price: '324.95', buyid: '838'}
      },
      2: {
        1: {price: '429.90', buyid: '840'},
        2: {price: '649.90', buyid: '839'}
      },
      3: {
        1: {price: '546.60', buyid: '841'},
        2: {price: '820.35', buyid: '842'}
      }
    },
    emav: {
      1: {
        1: {price: '24.95', buyid: '2897'},
        2: {price: '37.40', buyid: '2911'}
      }
    }
  },

  init: function() {
    // Set the onchange events for the dropdown boxes
    if(document.getElementById('ess_license')) {
      document.getElementById('ess_license').onchange = function() {
        document.getElementById('ess_buyid').value = ESET.ProductSelector.prices.ess[this.selectedIndex + 1][document.getElementById('ess_subscription').selectedIndex + 1].buyid;
        document.getElementById('ess_price').innerHTML = "$" + ESET.ProductSelector.prices.ess[this.selectedIndex + 1][document.getElementById('ess_subscription').selectedIndex + 1].price;
      }
  
      document.getElementById('ess_subscription').onchange = function() {
        document.getElementById('ess_buyid').value = ESET.ProductSelector.prices.ess[document.getElementById('ess_license').selectedIndex + 1][this.selectedIndex + 1].buyid;
        document.getElementById('ess_price').innerHTML = "$" + ESET.ProductSelector.prices.ess[document.getElementById('ess_license').selectedIndex + 1][this.selectedIndex + 1].price;
      }
      document.getElementById('ess_license').onchange();
    }

    if(document.getElementById('eav_license')) {
      document.getElementById('eav_license').onchange = function() {
        document.getElementById('eav_buyid').value = ESET.ProductSelector.prices.eav[this.selectedIndex + 1][document.getElementById('eav_subscription').selectedIndex + 1].buyid;
        document.getElementById('eav_price').innerHTML = "$" + ESET.ProductSelector.prices.eav[this.selectedIndex + 1][document.getElementById('eav_subscription').selectedIndex + 1].price;
      }
  
      document.getElementById('eav_subscription').onchange = function() {
        document.getElementById('eav_buyid').value = ESET.ProductSelector.prices.eav[document.getElementById('eav_license').selectedIndex + 1][this.selectedIndex + 1].buyid;
        document.getElementById('eav_price').innerHTML = "$" + ESET.ProductSelector.prices.eav[document.getElementById('eav_license').selectedIndex + 1][this.selectedIndex + 1].price;
      }
      document.getElementById('eav_license').onchange();
    }
    
    if(document.getElementById('esssmb_license')) {
      document.getElementById('esssmb_license').onchange = function() {
        document.getElementById('esssmb_buyid').value = ESET.ProductSelector.prices.esssmb[this.selectedIndex + 1][document.getElementById('esssmb_subscription').selectedIndex + 1].buyid;
        document.getElementById('esssmb_price').innerHTML = "$" + ESET.ProductSelector.prices.esssmb[this.selectedIndex + 1][document.getElementById('esssmb_subscription').selectedIndex + 1].price;
      }
  
      document.getElementById('esssmb_subscription').onchange = function() {
        document.getElementById('esssmb_buyid').value = ESET.ProductSelector.prices.esssmb[document.getElementById('esssmb_license').selectedIndex + 1][this.selectedIndex + 1].buyid;
        document.getElementById('esssmb_price').innerHTML = "$" + ESET.ProductSelector.prices.esssmb[document.getElementById('esssmb_license').selectedIndex + 1][this.selectedIndex + 1].price;
      }
      document.getElementById('esssmb_license').onchange();
    }

    if(document.getElementById('eavsmb_license')) {
      document.getElementById('eavsmb_license').onchange = function() {
        document.getElementById('eavsmb_buyid').value = ESET.ProductSelector.prices.eavsmb[this.selectedIndex + 1][document.getElementById('eavsmb_subscription').selectedIndex + 1].buyid;
        document.getElementById('eavsmb_price').innerHTML = "$" + ESET.ProductSelector.prices.eavsmb[this.selectedIndex + 1][document.getElementById('eavsmb_subscription').selectedIndex + 1].price;
      }
  
      document.getElementById('eavsmb_subscription').onchange = function() {
        document.getElementById('eavsmb_buyid').value = ESET.ProductSelector.prices.eavsmb[document.getElementById('eavsmb_license').selectedIndex + 1][this.selectedIndex + 1].buyid;
        document.getElementById('eavsmb_price').innerHTML = "$" + ESET.ProductSelector.prices.eavsmb[document.getElementById('eavsmb_license').selectedIndex + 1][this.selectedIndex + 1].price;
      }
      document.getElementById('eavsmb_license').onchange();
    }
    
    if(document.getElementById('emav_license')) {
      document.getElementById('emav_license').onchange = function() {
        document.getElementById('emav_buyid').value = ESET.ProductSelector.prices.emav[this.selectedIndex + 1][document.getElementById('emav_subscription').selectedIndex + 1].buyid;
        document.getElementById('emav_price').innerHTML = "$" + ESET.ProductSelector.prices.emav[this.selectedIndex + 1][document.getElementById('emav_subscription').selectedIndex + 1].price;
      }
  
      document.getElementById('emav_subscription').onchange = function() {
        document.getElementById('emav_buyid').value = ESET.ProductSelector.prices.emav[document.getElementById('emav_license').selectedIndex + 1][this.selectedIndex + 1].buyid;
        document.getElementById('emav_price').innerHTML = "$" + ESET.ProductSelector.prices.emav[document.getElementById('emav_license').selectedIndex + 1][this.selectedIndex + 1].price;
      }
      document.getElementById('emav_license').onchange();
    }
    
    if(document.getElementById('ess_home_license_double')) {
      document.getElementById('ess_home_license_double').onchange = function() {
        document.getElementById('ess_home_license_double_1').innerHTML = "$" + ESET.ProductSelector.prices.ess[document.getElementById('ess_home_license_double').selectedIndex + 1][1].price;
        document.getElementById('ess_home_license_double_2').innerHTML = "$" + ESET.ProductSelector.prices.ess[document.getElementById('ess_home_license_double').selectedIndex + 1][2].price;
        document.getElementById('ess_home_license_double_s1').onclick = function() {
          document.getElementById('ess_home_license_double_buyid').value = ESET.ProductSelector.prices.ess[document.getElementById('ess_home_license_double').selectedIndex + 1][1].buyid;
          addMboxProduct(document.getElementById('ess_home_license_double_buyid').parentNode.id, ESET.ProductSelector.prices.ess[document.getElementById('ess_home_license_double').selectedIndex + 1][1].price, ESET.ProductSelector.prices.ess[document.getElementById('ess_home_license_double').selectedIndex + 1][1].buyid);
        }
        document.getElementById('ess_home_license_double_s2').onclick = function() {
          document.getElementById('ess_home_license_double_buyid').value = ESET.ProductSelector.prices.ess[document.getElementById('ess_home_license_double').selectedIndex + 1][2].buyid;
          addMboxProduct(document.getElementById('ess_home_license_double_buyid').parentNode.id, ESET.ProductSelector.prices.ess[document.getElementById('ess_home_license_double').selectedIndex + 1][2].price, ESET.ProductSelector.prices.ess[document.getElementById('ess_home_license_double').selectedIndex + 1][2].buyid);
        }
      }
    }

    if(document.getElementById('ess_home_license_single')) {
      document.getElementById('ess_home_license_single').onchange = function() {
        document.getElementById('ess_home_license_single_1').innerHTML = "$" + ESET.ProductSelector.prices.ess[1][document.getElementById('ess_home_license_single').selectedIndex + 1].price;
        document.getElementById('ess_home_license_single_2').innerHTML = "$" + ESET.ProductSelector.prices.ess[2][document.getElementById('ess_home_license_single').selectedIndex + 1].price;
        document.getElementById('ess_home_license_single_3').innerHTML = "$" + ESET.ProductSelector.prices.ess[3][document.getElementById('ess_home_license_single').selectedIndex + 1].price;
        document.getElementById('ess_home_license_single_4').innerHTML = "$" + ESET.ProductSelector.prices.ess[4][document.getElementById('ess_home_license_single').selectedIndex + 1].price;

        document.getElementById('ess_home_license_single_s1').onclick = function() {
          document.getElementById('ess_home_license_single_buyid').value = ESET.ProductSelector.prices.ess[1][document.getElementById('ess_home_license_single').selectedIndex + 1].buyid;
        }

        document.getElementById('ess_home_license_single_s2').onclick = function() {
          document.getElementById('ess_home_license_single_buyid').value = ESET.ProductSelector.prices.ess[2][document.getElementById('ess_home_license_single').selectedIndex + 1].buyid;
        }

        document.getElementById('ess_home_license_single_s3').onclick = function() {
          document.getElementById('ess_home_license_single_buyid').value = ESET.ProductSelector.prices.ess[3][document.getElementById('ess_home_license_single').selectedIndex + 1].buyid;
        }

        document.getElementById('ess_home_license_single_s4').onclick = function() {
          document.getElementById('ess_home_license_single_buyid').value = ESET.ProductSelector.prices.ess[4][document.getElementById('ess_home_license_single').selectedIndex + 1].buyid;
        }

			}
    }

    if(document.getElementById('ess_business_license_double')) {
      document.getElementById('ess_business_license_double').onchange = function() {
        document.getElementById('ess_business_license_double_1').innerHTML = "$" + ESET.ProductSelector.prices.esssmb[document.getElementById('ess_business_license_double').selectedIndex + 1][1].price;
        document.getElementById('ess_business_license_double_2').innerHTML = "$" + ESET.ProductSelector.prices.esssmb[document.getElementById('ess_business_license_double').selectedIndex + 1][2].price;
        document.getElementById('ess_business_license_double_s1').onclick = function() {
          document.getElementById('ess_business_license_double_buyid').value = ESET.ProductSelector.prices.esssmb[document.getElementById('ess_business_license_double').selectedIndex + 1][1].buyid;
          addMboxProduct(document.getElementById('ess_business_license_double_buyid').parentNode.id, ESET.ProductSelector.prices.esssmb[document.getElementById('ess_business_license_double').selectedIndex + 1][1].price, ESET.ProductSelector.prices.esssmb[document.getElementById('ess_business_license_double').selectedIndex + 1][1].buyid);
        }
        document.getElementById('ess_business_license_double_s2').onclick = function() {
          document.getElementById('ess_business_license_double_buyid').value = ESET.ProductSelector.prices.esssmb[document.getElementById('ess_business_license_double').selectedIndex + 1][2].buyid;
          addMboxProduct(document.getElementById('ess_business_license_double_buyid').parentNode.id, ESET.ProductSelector.prices.esssmb[document.getElementById('ess_business_license_double').selectedIndex + 1][2].price, ESET.ProductSelector.prices.esssmb[document.getElementById('ess_business_license_double').selectedIndex + 1][2].buyid);
        }
      }
    }

    if(document.getElementById('eav_home_license_double')) {
      document.getElementById('eav_home_license_double').onchange = function() {
        document.getElementById('eav_home_license_double_1').innerHTML = "$" + ESET.ProductSelector.prices.eav[document.getElementById('eav_home_license_double').selectedIndex + 1][1].price;
        document.getElementById('eav_home_license_double_2').innerHTML = "$" + ESET.ProductSelector.prices.eav[document.getElementById('eav_home_license_double').selectedIndex + 1][2].price;
        document.getElementById('eav_home_license_double_s1').onclick = function() {
          document.getElementById('eav_home_license_double_buyid').value = ESET.ProductSelector.prices.eav[document.getElementById('eav_home_license_double').selectedIndex + 1][1].buyid;
          addMboxProduct(document.getElementById('eav_home_license_double_buyid').parentNode.id, ESET.ProductSelector.prices.eav[document.getElementById('eav_home_license_double_buyid').selectedIndex + 1][1].price, ESET.ProductSelector.prices.eav[document.getElementById('eav_home_license_double_buyid').selectedIndex + 1][1].buyid);
        }
        document.getElementById('eav_home_license_double_s2').onclick = function() {
          document.getElementById('eav_home_license_double_buyid').value = ESET.ProductSelector.prices.eav[document.getElementById('eav_home_license_double').selectedIndex + 1][2].buyid;
          addMboxProduct(document.getElementById('eav_home_license_double_buyid').parentNode.id, ESET.ProductSelector.prices.eav[document.getElementById('eav_home_license_double_buyid').selectedIndex + 1][2].price, ESET.ProductSelector.prices.eav[document.getElementById('eav_home_license_double_buyid').selectedIndex + 1][2].buyid);
        }
      }
    }

    if(document.getElementById('eav_business_license_double')) {
      document.getElementById('eav_business_license_double').onchange = function() {
        document.getElementById('eav_business_license_double_1').innerHTML = "$" + ESET.ProductSelector.prices.eavsmb[document.getElementById('eav_business_license_double').selectedIndex + 1][1].price;
        document.getElementById('eav_business_license_double_2').innerHTML = "$" + ESET.ProductSelector.prices.eavsmb[document.getElementById('eav_business_license_double').selectedIndex + 1][2].price;
        document.getElementById('eav_business_license_double_s1').onclick = function() {
          document.getElementById('eav_business_license_double_buyid').value = ESET.ProductSelector.prices.eavsmb[document.getElementById('eav_business_license_double').selectedIndex + 1][1].buyid;
          addMboxProduct(document.getElementById('eav_business_license_double_buyid').parentNode.id, ESET.ProductSelector.prices.eavsmb[document.getElementById('eav_business_license_double_buyid').selectedIndex + 1][1].price, ESET.ProductSelector.prices.eavsmb[document.getElementById('eav_business_license_double_buyid').selectedIndex + 1][1].buyid);
        }
        document.getElementById('eav_business_license_double_s2').onclick = function() {
          document.getElementById('eav_business_license_double_buyid').value = ESET.ProductSelector.prices.eavsmb[document.getElementById('eav_business_license_double').selectedIndex + 1][2].buyid;
          addMboxProduct(document.getElementById('eav_business_license_double_buyid').parentNode.id, ESET.ProductSelector.prices.eavsmb[document.getElementById('eav_business_license_double_buyid').selectedIndex + 1][2].price, ESET.ProductSelector.prices.eavsmb[document.getElementById('eav_business_license_double_buyid').selectedIndex + 1][2].buyid);
        }
      }
    }
    
    if(document.getElementById('eav_quad_form')) {
      document.getElementById('eav_home_license_quad').onchange = function() {

        document.getElementById('eav_home_license_quad_1').innerHTML = "$" + ESET.ProductSelector.prices.eav[1][document.getElementById('eav_home_license_quad').selectedIndex + 1].price;
        document.getElementById('eav_home_license_quad_2').innerHTML = "$" + ESET.ProductSelector.prices.eav[2][document.getElementById('eav_home_license_quad').selectedIndex + 1].price;
        document.getElementById('eav_home_license_quad_3').innerHTML = "$" + ESET.ProductSelector.prices.eav[3][document.getElementById('eav_home_license_quad').selectedIndex + 1].price;
        document.getElementById('eav_home_license_quad_4').innerHTML = "$" + ESET.ProductSelector.prices.eav[4][document.getElementById('eav_home_license_quad').selectedIndex + 1].price;

        document.getElementById('eav_home_license_quad_s1').onclick = function() {
          document.getElementById('eav_buyid').value = ESET.ProductSelector.prices.eav[1][document.getElementById('eav_home_license_quad').selectedIndex + 1].buyid;
          addMboxProduct(document.getElementById('eav_buyid').parentNode.id, ESET.ProductSelector.prices.eav[1][document.getElementById('eav_home_license_quad').selectedIndex + 1].price, ESET.ProductSelector.prices.eav[1][document.getElementById('eav_home_license_quad').selectedIndex + 1].buyid);
        }

        document.getElementById('eav_home_license_quad_s2').onclick = function() {
          document.getElementById('eav_buyid').value = ESET.ProductSelector.prices.eav[2][document.getElementById('eav_home_license_quad').selectedIndex + 1].buyid;
          addMboxProduct(document.getElementById('eav_buyid').parentNode.id, ESET.ProductSelector.prices.eav[2][document.getElementById('eav_home_license_quad').selectedIndex + 1].price, ESET.ProductSelector.prices.eav[2][document.getElementById('eav_home_license_quad').selectedIndex + 1].buyid);
        }

        document.getElementById('eav_home_license_quad_s3').onclick = function() {
          document.getElementById('eav_buyid').value = ESET.ProductSelector.prices.eav[3][document.getElementById('eav_home_license_quad').selectedIndex + 1].buyid;
          addMboxProduct(document.getElementById('eav_buyid').parentNode.id, ESET.ProductSelector.prices.eav[3][document.getElementById('eav_home_license_quad').selectedIndex + 1].price, ESET.ProductSelector.prices.eav[3][document.getElementById('eav_home_license_quad').selectedIndex + 1].buyid);
        }

        document.getElementById('eav_home_license_quad_s4').onclick = function() {
          document.getElementById('eav_buyid').value = ESET.ProductSelector.prices.eav[4][document.getElementById('eav_home_license_quad').selectedIndex + 1].buyid;
          addMboxProduct(document.getElementById('eav_buyid').parentNode.id, ESET.ProductSelector.prices.eav[4][document.getElementById('eav_home_license_quad').selectedIndex + 1].price, ESET.ProductSelector.prices.eav[4][document.getElementById('eav_home_license_quad').selectedIndex + 1].buyid);
        }
      }
    }


	
    if(document.getElementById('ess_quad_form')) {
      document.getElementById('ess_home_license_quad').onchange = function() {

        document.getElementById('ess_home_license_quad_1').innerHTML = "$" + ESET.ProductSelector.prices.ess[1][document.getElementById('ess_home_license_quad').selectedIndex + 1].price;
        document.getElementById('ess_home_license_quad_2').innerHTML = "$" + ESET.ProductSelector.prices.ess[2][document.getElementById('ess_home_license_quad').selectedIndex + 1].price;
        document.getElementById('ess_home_license_quad_3').innerHTML = "$" + ESET.ProductSelector.prices.ess[3][document.getElementById('ess_home_license_quad').selectedIndex + 1].price;
        document.getElementById('ess_home_license_quad_4').innerHTML = "$" + ESET.ProductSelector.prices.ess[4][document.getElementById('ess_home_license_quad').selectedIndex + 1].price;

        document.getElementById('ess_home_license_quad_s1').onclick = function() {
          document.getElementById('ess_buyid').value = ESET.ProductSelector.prices.ess[1][document.getElementById('ess_home_license_quad').selectedIndex + 1].buyid;
          addMboxProduct(document.getElementById('ess_buyid').parentNode.id, ESET.ProductSelector.prices.ess[1][document.getElementById('ess_home_license_quad').selectedIndex + 1].price, ESET.ProductSelector.prices.ess[1][document.getElementById('ess_home_license_quad').selectedIndex + 1].buyid);
        }

        document.getElementById('ess_home_license_quad_s2').onclick = function() {
          document.getElementById('ess_buyid').value = ESET.ProductSelector.prices.ess[2][document.getElementById('ess_home_license_quad').selectedIndex + 1].buyid;
          addMboxProduct(document.getElementById('ess_buyid').parentNode.id, ESET.ProductSelector.prices.ess[2][document.getElementById('ess_home_license_quad').selectedIndex + 1].price, ESET.ProductSelector.prices.ess[2][document.getElementById('ess_home_license_quad').selectedIndex + 1].buyid);
        }

        document.getElementById('ess_home_license_quad_s3').onclick = function() {
          document.getElementById('ess_buyid').value = ESET.ProductSelector.prices.ess[3][document.getElementById('ess_home_license_quad').selectedIndex + 1].buyid;
          addMboxProduct(document.getElementById('ess_buyid').parentNode.id, ESET.ProductSelector.prices.ess[3][document.getElementById('ess_home_license_quad').selectedIndex + 1].price, ESET.ProductSelector.prices.ess[3][document.getElementById('ess_home_license_quad').selectedIndex + 1].buyid);
        }

        document.getElementById('ess_home_license_quad_s4').onclick = function() {
          document.getElementById('ess_buyid').value = ESET.ProductSelector.prices.ess[4][document.getElementById('ess_home_license_quad').selectedIndex + 1].buyid;
          addMboxProduct(document.getElementById('ess_buyid').parentNode.id, ESET.ProductSelector.prices.ess[4][document.getElementById('ess_home_license_quad').selectedIndex + 1].price, ESET.ProductSelector.prices.ess[4][document.getElementById('ess_home_license_quad').selectedIndex + 1].buyid);
        }
      }
    }
    
  }
};

if (window.addEventListener) {
  window.addEventListener('load', function() { ESET.ProductSelector.init() }, false); 
} else if (window.attachEvent) {
  window.attachEvent('onload', function() { ESET.ProductSelector.init() });
}


function addMboxProduct(formid, mboxcost, mboxproduct) {
  if(document.getElementById(formid)) {
    if(formid == 'ns_form_1' || formid == 'ns_form_3' || formid == 'ess_quad_form') {
      document.getElementById(formid).action += '&mboxPageValue=' + parseInt(mboxcost, 10);
    }
    document.getElementById(formid).action += '&prod=' + mboxproduct;
  }
}
