var eval_ship_total=0;
function M(x) {
return document.getElementById(x);
}
function addEvent(obj, evType, fn) {
if (obj.addEventListener) {
obj.addEventListener(evType,fn,false);
return true;
}
else if (obj.attachEvent) {
var r=obj.attachEvent("on"+evType,fn);
return r;
}
else
return false;
}
function eval_all() {
eval_country();
eval_toggle();
eval_name();
eval_product();
}
function eval_country() {
var state, country;
var names=["b", "s"];
for (var i in names) {
if (M(names[i]+'_country') == null)
continue;
country=M(names[i]+'_country').value;
state=M(names[i]+'_state').value;
if (country != '') {
if (country != 'US' && country != 'CA')
state='~~';
else if (state == '~~')
state='';
M(names[i]+'_state').value=state;
}
if (state == '~~') {
M(names[i]+'_region').style.display="";
M(names[i]+'_state').style.display="none";
M(names[i]+'_prov').style.display="none";
}
else {
M(names[i]+'_region').style.display="none";
if (country == 'US') {
M(names[i]+'_state').style.display="";
M(names[i]+'_prov').style.display="none";
}
else {
M(names[i]+'_state').style.display="none";
M(names[i]+'_prov').style.display="";
}
}
}
}
function eval_toggle() {
var display, i;
if (M('b_diff').checked)
display="";
else
display="none";
for (i=0;i<7;i++)
M('s_div_'+i).style.display=display;
}
function eval_name() {
var terms, str;
if ((terms=M('terms_name1'))) {
if ((str=M('b_name').value))
terms.innerHTML=''+str+'';
}
if ((terms=M('terms_name2'))) {
if ((str=M('b_name').value))
terms.innerHTML=''+str+'';
}
}
function eval_product() {
var offer, index, str, param, ship, total, checked;
if (!(offer=M('offer')))
return;
index=offer.selectedIndex;
str=offer.options[index].title;
param=str.split("|");
switch (param[0]) {
case 'normal':
if (M('terms_normal'))
M('terms_normal').style.display="";
if (M('terms_trial'))
M('terms_trial').style.display="none";
if (M('terms_trial_left'))
M('terms_trial_left').style.display="none";
checked=1;
break;
case 'trial':
if (M('terms_normal'))
M('terms_normal').style.display="none";
if (M('terms_trial'))
M('terms_trial').style.display="";
if (M('terms_trial_left'))
M('terms_trial_left').style.display="";
checked=0;
break;
}
if (param[1] == '1') {
M('shipping').innerHTML="Free";
ship=0;
}
else {
M('shipping').innerHTML="$"+eval_ship_total;
ship=eval_ship_total;
}
total=parseFloat(ship)+parseFloat(param[2]);
M('total').innerHTML='$'+eval_round(total,2).toFixed(2);
//M('terms').checked=checked;
}
function eval_product_page1() {
M('topform').action=M('product').value;
return 1;
}
function eval_set_ship(ship) {
eval_ship_total=ship;
}
function eval_round(num, dec) {
return Math.round(num*Math.pow(10,dec))/Math.pow(10,dec);
}
addEvent(window,'load',eval_country);
3101