function set_limit(isform) {
        if (isform.totalregular.value*1+isform.totalcitronella.value*1 > isform.totalcoils.value*1){
                isform.totalcitronella.value = isform.totalcoils.value*1-isform.totalregular.value*1;
        }


        isform.totalregular.length  =isform.totalcoils.value*1+1;
        isform.totalcitronella.length=isform.totalcoils.value-isform.totalregular.value*1+1;


        for(i=0;i<isform.totalregular.length;i++){
             isform.totalregular[i].value=isform.totalregular[i].text=i;
        }
        for(i=0;i<isform.totalcitronella.length;i++){
             isform.totalcitronella[i].value=isform.totalcitronella[i].text=i;
        }
        if ((isform.totalcoils.value/16*6.50)%1==0){
             document.getElementById("coilstatus").innerHTML = "Add " + isform.totalcoils.value/8 + " coil holders for an additional $" + isform.totalcoils.value/16*6.50 +".00";
        }
        else {
             document.getElementById("coilstatus").innerHTML = "Add " + isform.totalcoils.value/8 + " coil holders for an additional $" + isform.totalcoils.value/16*6.50 +"0";
        }
}

function validate_form(isform) {
        if(isform.totalcoils.value == 0){
                alert("You have not selected any King Mosquito Coils to buy.");
                return false;
        }
        if(isform.totalcitronella.value != isform.totalcitronella.length - 1){
                alert("The amount of regular and citronella selected does not equal to the amount you would like to purchase!");
                return false;
        }
        if(isform.totalregular.value == 0 && isform.totalcitronella.value == 0){
                alert("Please reload page or press reset!");
                return false;
        }
        if(document.getElementById("add_coil_holders").checked == true) {
                // calculate final total
                document.getElementById('amount').value = isform.totalcoils.value/16*31+isform.totalcoils.value/16*6.50;
                // calculate name
                document.getElementById('item_name').value = isform.totalcoils.value + " King Mosquito Coils:  " + isform.totalregular.value + " regular and " + isform.totalcitronella.value + " citronella and " + isform.totalcoils.value/8 + " coil holders.";
        }
        else {
                // calculate final total
                document.getElementById('amount').value = isform.totalcoils.value/16*31;
                // calculate name
                document.getElementById('item_name').value = isform.totalcoils.value + " King Mosquito Coils:  " + isform.totalregular.value + " regular and " + isform.totalcitronella.value + " citronella.";
        }

        return true;
}

function reset_form(isform){
        isform.totalregular.length  =1;
        isform.totalcitronella.length=1;
        isform.totalcoils.value ="0";
        document.getElementById("add_coil_holders").checked = 0;
        document.getElementById("coilstatus").innerHTML = "Add 0 coil holders for an additional $0.00";
}

