//Written by Manuel Villanueva 3/15/05

//updated 7/13/05 includes BB 1-at-at-time
//updated 7/4/05 includes rentals/week
//updated 6/25/05 includes turnaround time
//updated 4/27/05 included Netflix 2-at-a-time "unlimited"
//updated 4/22/05 added Netflix 1-at-a-time plan
//updated 4/5/05 forgot GC 3-at-a-time plan
//updated 5/8/06 BB new prices, added BB 2-at-time plan and GC 1-at-a-time plan
//updated 9/2/07 updated pricing plans
//updated 1/2/08 updated bb pricing plans

function doIt(form) {

//cut offs: plan2=4, plan3=8, plan4=11, plan5=14, plan6=17, plan7=20 plan8=23

var total = form.total.value;
var tax = form.tax.value;
var turnaroundDays = 30.4368499 / total;
var displayTurnaroundDays = turnaroundDays.toFixed(1);
var turnaroundWks = total / 4.34812141;
var displayTurnaroundWks = turnaroundWks.toFixed(1);

form.turnaround.value = displayTurnaroundDays + " days";
form.rentalsperweek.value = displayTurnaroundWks;

//NF

var plan1 = (4.99 * tax / 100 + 4.99) / total;
var plan1b = (8.99 * tax / 100 + 8.99) / total;
var plan2 = (13.99 * tax / 100 + 13.99) / total;
var plan3 = (16.99 * tax / 100 + 16.99) / total;
var plan4 = (23.99 * tax / 100 + 23.99) / total;
var plan5 = (29.99 * tax / 100 + 29.99) / total;
var plan6 = (35.99 * tax / 100 + 35.99) / total;
var plan7 = (41.99 * tax / 100 + 41.99) / total;
var plan8 = (47.99 * tax / 100 + 47.99) / total;

var plan1f = "$" + plan1.toFixed(2);
var plan1fb = "$" + plan1b.toFixed(2);
var plan2f = "$" + plan2.toFixed(2);
var plan3f = "$" + plan3.toFixed(2);
var plan4f = "$" + plan4.toFixed(2);
var plan5f = "$" + plan5.toFixed(2);
var plan6f = "$" + plan6.toFixed(2);
var plan7f = "$" + plan7.toFixed(2);
var plan8f = "$" + plan8.toFixed(2);

//BB
var bbplan1 = (3.99 * tax / 100 + 3.99) / total;
var bbplan1b = (8.99 * tax / 100 + 8.99) / total;
var bbplan1c = (9.99 * tax / 100 + 9.99) / total;
var bbplan1d = (11.99 * tax / 100 + 11.99) / total;
var bbplan1e = (21.99 * tax / 100 + 21.99) / total;
var bbplan2 = (13.99 * tax / 100 + 13.99) / total;
var bbplan2b = (16.99 * tax / 100 + 16.99) / total;
var bbplan2c = (29.99 * tax / 100 + 29.99) / total;
var bbplan3 = (15.99 * tax / 100 + 15.99) / total;
var bbplan3b = (19.99 * tax / 100 + 19.99) / total;
var bbplan3c = (34.99 * tax / 100 + 34.99) / total;

var bbplan1f = "$" + bbplan1.toFixed(2);
var bbplan1fb = "$" + bbplan1b.toFixed(2);
var bbplan1fc = "$" + bbplan1c.toFixed(2);
var bbplan1fd = "$" + bbplan1d.toFixed(2);
var bbplan1fe = "$" + bbplan1e.toFixed(2);
var bbplan2f = "$" + bbplan2.toFixed(2);
var bbplan2fb = "$" + bbplan2b.toFixed(2);
var bbplan2fc = "$" + bbplan2c.toFixed(2);
var bbplan3f = "$" + bbplan3.toFixed(2);
var bbplan3fb = "$" + bbplan3b.toFixed(2);
var bbplan3fc = "$" + bbplan3c.toFixed(2);

//GC
var gcplan1 = (9.95 * tax / 100 + 9.95) / total;
var gcplan2 = (14.95 * tax / 100 + 14.95) / total;
var gcplan3 = (21.95 * tax / 100 + 21.95) / total;
var gcplan4 = (27.95 * tax / 100 + 27.95) / total;
var gcplan5 = (33.95 * tax / 100 + 33.95) / total;
var gcplan8 = (49.95 * tax / 100 + 49.95) / total;
var gcplan10 = (59.95 * tax / 100 + 59.95) / total;


var gcplan1f = "$" + gcplan1.toFixed(2);
var gcplan2f = "$" + gcplan2.toFixed(2);
var gcplan3f = "$" + gcplan3.toFixed(2);
var gcplan4f = "$" + gcplan4.toFixed(2);
var gcplan5f = "$" + gcplan5.toFixed(2);
var gcplan8f = "$" + gcplan8.toFixed(2);
var gcplan10f = "$" + gcplan10.toFixed(2);

//NETFLIX
// 1. 1-at-a-time (2 max)

if (form.D1.selectedIndex == 1){
form.answer.value = plan1f;
}

// 2. 1-at-a-time

else if (form.D1.selectedIndex == 2){
form.answer.value = plan1fb;
}

// 3. 2-at-a-time

else if (form.D1.selectedIndex == 3){
form.answer.value = plan2f;
}

// 4. 3-at-a-time

else if (form.D1.selectedIndex == 4){
form.answer.value = plan3f;
}

// 5. 4-at-a-time

else if (form.D1.selectedIndex == 5){
form.answer.value = plan4f;
}

// 6. 5-at-a-time

else if (form.D1.selectedIndex == 6){
form.answer.value = plan5f;
}

// 7. 6-at-a-time

else if (form.D1.selectedIndex == 7){
form.answer.value = plan6f;
}

// 8. 7-at-a-time

else if (form.D1.selectedIndex == 8){
form.answer.value = plan7f;
}

// 9. 8-at-a-time

else if (form.D1.selectedIndex == 9){
form.answer.value = plan8f;
}


//BLOCKBUSTER
// 10. 1-at-a-time A BB

else if (form.D1.selectedIndex == 10){
form.answer.value = bbplan1f;
}

// 11. 1-at-a-time B BB

else if (form.D1.selectedIndex == 11){
form.answer.value = bbplan1fb;
}

// 12. 1-at-a-time C BB

else if (form.D1.selectedIndex == 12){
form.answer.value = bbplan1fc;
}
// 13. 1-at-a-time D BB

else if (form.D1.selectedIndex == 13){
form.answer.value = bbplan1fd;
}

// 14. 1-at-a-time E BB

else if (form.D1.selectedIndex == 14){
form.answer.value = bbplan1fe;
}

// 15. 2-at-a-time A BB

else if (form.D1.selectedIndex == 15){
form.answer.value = bbplan2f;
}

// 16. 2-at-a-time B BB

else if (form.D1.selectedIndex == 16){
form.answer.value = bbplan2fb;
}

// 17. 2-at-a-time B BB

else if (form.D1.selectedIndex == 17){
form.answer.value = bbplan2fc;
}

// 18. 3-at-a-time A BB

else if (form.D1.selectedIndex == 18){
form.answer.value = bbplan3f;
}

// 19. 3-at-a-time B BB

else if (form.D1.selectedIndex == 19){
form.answer.value = bbplan3fb;
}

// 20. 3-at-a-time C BB

else if (form.D1.selectedIndex == 20){
form.answer.value = bbplan3fc;
}

// 21. 1-at-a-time GC

else if (form.D1.selectedIndex == 21){
form.answer.value = gcplan1f;
}

// 22. 2-at-a-time GC

else if (form.D1.selectedIndex == 22){
form.answer.value = gcplan2f;
}

// 23. 3-at-a-time GC

else if (form.D1.selectedIndex == 23){
form.answer.value = gcplan3f;
}

// 24. 4-at-a-time GC

else if (form.D1.selectedIndex == 24){
form.answer.value = gcplan4f;
}

// 25. 5-at-a-time GC

else if (form.D1.selectedIndex == 25){
form.answer.value = gcplan5f;
}

// 26. 8-at-a-time GC

else if (form.D1.selectedIndex == 26){
form.answer.value = gcplan8f;
}

// 27. 10-at-a-time GC

else if (form.D1.selectedIndex == 27){
form.answer.value = gcplan10f;
}

//none of the above

else {
form.answer.value = "ERROR";
}

//alerts
if((form.total.value==null)||(form.total.value=="")||(isNaN(form.total.value))){
alert('Enter the number of rentals.\nPlease enter numbers only.');
form.total.focus();
form.total.select();
return false
}
if((form.tax.value==null)||(form.tax.value=="")||(isNaN(form.tax.value))){
alert('Enter any applicable sales tax.\nPlease enter numbers only.');
form.tax.focus();
form.tax.select();
return false
}
if(form.D1.selectedIndex ==0){
alert('Please select your plan');
form.D1.focus();
return false
}
}
