// calculate.js is going to do the math for shipping-and-handling.html // we are removing the additional services from the shipping price function calculate_total(){ // grab values and convert integers to integers qty = ($('#project_qty').attr("value")) * 1; bnw = ($('#project_pages').attr("value")) * 1; clrpgs = ($('#color_pages').attr("value")) * 1; bsize = ($('#book_size_selection').attr("value")) * 1; zip = $('#customer_zip').attr("value"); paper = $('#paper_weight').attr("value"); bbinding = $('#project_binding').attr("value"); // start with some error checking if( qty == 0 || qty < 24 ){ alert("Please enter a minimum order of 24 books"); return false; } if( bnw == 0 && clrpgs == 0 ){ alert("Please enter the number of b&w and color pages of your book"); return false; } if( clrpgs > 0 && paper == '50' ){ alert("We require 60# or 70# paper for color book printing, we've updated your selection to 60# Offset White"); $('#paper_weight').val("60-W"); calculate_total(); return; } // establish our variables for the math and zero out var qty_factor = 0; var size_factor = 0; var colorfact = 0; var base_price = 0; var paper_upgrade = 0; var binding = 0; var additional = 0; var rush = 0; var shipping = 0; var per_book = 0; var total_pages = (clrpgs + bnw); // step 1 get qty/size factors factors = get_qty_size(bsize,qty); factors = factors.split(":"); qty_factor = factors[0] * 1; size_factor = factors[1] * 1; colorfact = factors[2] * 1; // grab color charges var color_charges_now = (get_color_charges(clrpgs,colorfact)); // $('#color_upcharge_price').text("$" + (color_charges_now).toFixed(2)); // step 2 get the ** per book base price including color charge per_book = get_book_price(total_pages,qty_factor,size_factor,clrpgs,qty,colorfact); base_price = per_book * qty; // step 3 get the ** per book paper upgrade fee per book is a percentage markeup based on per_book pase price and paper weight paper_upgrade = paper_upcharge(paper) * per_book; // step 4 binding charges ** per book binding = get_binding(bbinding,total_pages); // step 5 additional services // additional = get_upcharges(qty); // step 6 rush service charge is % upcharge for total so far // rush_total = ( per_book * qty ) + (paper_upgrade*qty) + (binding*qty) + (additional*1); rush_total = ( per_book * qty ) + (paper_upgrade*qty) + (binding*qty); rush = get_rush(rush_total); // step 7 shipping ship_total = rush_total + rush; shipping = get_shipping2(qty,bsize,total_pages,paper,ship_total,zip,"03"); // ground shipping1 = get_shipping2(qty,bsize,total_pages,paper,ship_total,zip,"12"); // 3 day shipping2 = get_shipping2(qty,bsize,total_pages,paper,ship_total,zip,"02"); // 2 day shipping3 = get_shipping2(qty,bsize,total_pages,paper,ship_total,zip,"01"); // overnight //alert("total for shipping " + ship_total); //alert("1 " + shipping + ", 2 " + shipping1 + ", 3 " +shipping2 + ", 4 " + shipping3); per_book = ship_total / qty; // step 8 fill in all values // fills the calculator area cor_base = base_price; $('#base-price').text("$" + (cor_base).toFixed(2)); $('#PricingBase').attr('value',(cor_base).toFixed(2)); $('#paper-upgrade').text("$" + (paper_upgrade*qty).toFixed(2)); $('#PricingPaper').attr('value', (paper_upgrade*qty).toFixed(2)); $('#binding-cost').text("$" + (binding*qty).toFixed(2)); $('#PricingBinding').attr('value', (binding*qty).toFixed(2)); $('#PricingColor').attr('value', get_color_charges(clrpgs,colorfact) ); // [ this is what you are changing ] //$('#additional-services').text("$" + additional.toFixed(2) ); // $('#PricingAdditional').attr('value', additional); $('#rush-service').text("$" + rush.toFixed(2) ); $('#PricingRush').attr("value", rush.toFixed(2) ); $('#calc-qty').text(qty); $('#PricingQty').attr('value',qty); $('#per-book').text("$" + per_book.toFixed(2) ); $('#PricingEach').attr('value', per_book.toFixed(2) ); $('#printing_total').text("$" + ship_total.toFixed(2) ); $('#PricingPrinting').attr('value', ship_total.toFixed(2) ); // $('#shipping-serv-charge').html(""); $('#shipping-serv-charge').text("$" + shipping ); $('#shipping-serv-charge-3day').text("$" + shipping1 ); $('#shipping-serv-charge-2day').text("$" + shipping2 ); $('#shipping-serv-charge-overnight').text("$" + shipping3 ); total = (ship_total * 1) + (shipping * 1); $('#project-total-price').text("$" + (total).toFixed(2) ); $('#PricingTotal').attr('value', total.toFixed(2) ); // $('#PricingZip').attr('value', zip); $('#PricingShipping').attr('value', shipping ); // fills the top $('#per_book').text("$" + per_book.toFixed(2) ); // $('#shipping_cost').html(""); $('#shipping_cost').text("$" + shipping ); // $('#total_cost').text("$" + (total).toFixed(2) ); $('#total_cost').text("$" + (total.toFixed(2))); get_upcharges(); return; } function calculate_total2(qty,bnw,clrpgs,bsize,thiszip,paper,bbinding,method){ // alert(qty + " " + bnw + " " + clrpgs + " " + bsize + " " + thiszip + " " + paper + " " + bbinding + " " + method); // grab values and convert integers to integers qty = qty * 1; bnw = bnw * 1; clrpgs = clrpgs * 1; bsize = bsize * 1; zip = thiszip; paper = paper; bbinding = bbinding; // start with some error checking if( qty == 0 || qty < 24 ){ alert("Please enter a minimum order of 24 books"); return false; } if( bnw == 0 && clrpgs == 0 ){ alert("Please enter the number of b&w and color pages of your book"); return false; } if( clrpgs > 0 && paper == '50' ){ alert("We require 60# or 70# paper for color book printing, we've updated your selection to 60# Offset White"); return false; } // establish our variables for the math and zero out var qty_factor = 0; var size_factor = 0; var colorfact = 0; var base_price = 0; var paper_upgrade = 0; var binding = 0; var additional = 0; var rush = 0; var shipping = 0; var per_book = 0; var total_pages = (clrpgs + bnw); // step 1 get qty/size factors factors = get_qty_size(bsize,qty); factors = factors.split(":"); qty_factor = factors[0] * 1; size_factor = factors[1] * 1; colorfact = factors[2] * 1; // step 2 get the ** per book base price including color charge per_book = get_book_price(total_pages,qty_factor,size_factor,clrpgs,qty,colorfact); base_price = per_book * qty; // step 3 get the ** per book paper upgrade fee per book is a percentage markeup based on per_book pase price and paper weight paper_upgrade = paper_upcharge(paper) * per_book; // step 4 binding charges ** per book binding = get_binding(bbinding,total_pages); // step 5 additional services // additional = get_upcharges(qty); // step 6 rush service charge is % upcharge for total so far rush_total = ( per_book * qty ) + (paper_upgrade*qty) + (binding*qty); rush_total = ( per_book * qty ) + (paper_upgrade*qty) + (binding*qty); rush = get_rush(rush_total); // step 7 shipping ship_total = rush_total + rush; // alert(qty + " " + bsize + " " + total_pages + " " + paper + " " + ship_total + " " + zip); shipping = get_shipping2(qty,bsize,total_pages,paper,ship_total,zip,method); per_book = ship_total / qty; return shipping; // step 8 fill in all values // fills the calculator area $('#base-price').text("$" + (base_price).toFixed(2)); $('#paper-upgrade').text("$" + (paper_upgrade*qty).toFixed(2)); $('#binding-cost').text("$" + (binding*qty).toFixed(2)); //$('#additional-services').text("$" + additional.toFixed(2) ); $('#rush-service').text("$" + rush.toFixed(2) ); $('#calc-qty').text(qty); $('#per-book').text("$" + per_book.toFixed(2) ); $('#printing_total').text("$" + ship_total.toFixed(2) ); // $('#shipping-serv-charge').html(""); $('#shipping-serv-charge').text("$" + shipping ); total = (ship_total * 1) + (shipping * 1); $('#project-total-price').text("$" + (total).toFixed(2) ); // fills the top $('#per_book').text("$" + per_book.toFixed(2) ); // $('#shipping_cost').html(""); $('#shipping_cost').text("$" + shipping ); $('#total_cost').text("$" + (total).toFixed(2) ); return; } // used by place-order function calculate_total3(qty,bnw,clrpgs,bsize,thiszip,paper,bbinding,misc_charges,newtotal,method){ // alert(qty + " " + bnw + " " + clrpgs + " " + bsize + " " + thiszip + " " + paper + " " + bbinding + " " + misc_charges + " " + method); // grab values and convert integers to integers qty = qty * 1; bnw = bnw * 1; clrpgs = clrpgs * 1; bsize = bsize * 1; zip = thiszip; paper = paper; bbinding = bbinding; misc_charges = 0; // start with some error checking if( qty == 0 || qty < 24 ){ alert("Please enter a minimum order of 24 books"); return false; } if( bnw == 0 && clrpgs == 0 ){ alert("Please enter the number of b&w and color pages of your book"); return false; } if( clrpgs > 0 && paper == '50' ){ alert("We require 60# or 70# paper for color book printing, we've updated your selection to 60# Offset White"); return false; } // establish our variables for the math and zero out var qty_factor = 0; var size_factor = 0; var colorfact = 0; var base_price = 0; var paper_upgrade = 0; var binding = 0; var additional = 0; var rush = 0; var shipping = 0; var per_book = 0; var total_pages = (clrpgs + bnw); // step 1 get qty/size factors factors = get_qty_size(bsize,qty); factors = factors.split(":"); qty_factor = factors[0] * 1; size_factor = factors[1] * 1; colorfact = factors[2] * 1; // step 2 get the ** per book base price including color charge per_book = get_book_price(total_pages,qty_factor,size_factor,clrpgs,qty,colorfact); base_price = per_book * qty; // step 3 get the ** per book paper upgrade fee per book is a percentage markeup based on per_book pase price and paper weight paper_upgrade = paper_upcharge(paper) * per_book; // step 4 binding charges ** per book binding = get_binding(bbinding,total_pages); // step 5 additional services // additional = misc_charges * 1; // step 6 rush service charge is % upcharge for total so far rush_total = ( per_book * qty ) + (paper_upgrade*qty) + (binding*qty); rush = get_rush(rush_total); // step 7 shipping ship_total = (rush_total * 1) + (rush *1); // alert(qty + " " + bsize + " " + total_pages + " " + paper + " " + ship_total + " " + zip); shipping = get_shipping2(qty,bsize,total_pages,paper,ship_total,zip,method); per_book = ship_total / qty; return shipping; // step 8 fill in all values // fills the calculator area $('#base-price').text("$" + (base_price).toFixed(2)); $('#paper-upgrade').text("$" + (paper_upgrade*qty).toFixed(2)); $('#binding-cost').text("$" + (binding*qty).toFixed(2)); // $('#additional-services').text("$" + additional.toFixed(2) ); $('#rush-service').text("$" + rush.toFixed(2) ); $('#calc-qty').text(qty); $('#per-book').text("$" + per_book.toFixed(2) ); $('#printing_total').text("$" + ship_total.toFixed(2) ); // $('#shipping-serv-charge').html(""); $('#shipping-serv-charge').text("$" + shipping ); total = (ship_total * 1) + (shipping * 1); $('#project-total-price').text("$" + (total).toFixed(2) ); // fills the top $('#per_book').text("$" + per_book.toFixed(2) ); // $('#shipping_cost').html(""); $('#shipping_cost').text("$" + shipping ); $('#total_cost').text("$" + (total).toFixed(2) ); return; } function calculate_total4(qty,bnw,clrpgs,bsize,paper,bbinding,misc_charges){ // alert(qty + " " + bnw + " " + clrpgs + " " + bsize + " " + paper + " " + bbinding ); // grab values and convert integers to integers qty = qty * 1; bnw = bnw * 1; clrpgs = clrpgs *1; bsize = bsize * 1; paper = paper; bbinding = bbinding misc_charges = 0; // start with some error checking /* removed the error checking */ // establish our variables for the math and zero out var qty_factor = 0; var size_factor = 0; var colorfact = 0; var base_price = 0; var paper_upgrade = 0; var binding = 0; var additional = 0; var rush = 0; var shipping = 0; var per_book = 0; var total_pages = (clrpgs + bnw); // step 1 get qty/size factors factors = get_qty_size(bsize,qty); if( factors != '' ){ factors = factors.split(":"); } else { return; } qty_factor = factors[0] * 1; size_factor = factors[1] * 1; colorfact = factors[2] * 1; // step 2 get the ** per book base price including color charge per_book = get_book_price(total_pages,qty_factor,size_factor,clrpgs,qty,colorfact); base_price = per_book * qty; // step 3 get the ** per book paper upgrade fee per book is a percentage markeup based on per_book pase price and paper weight paper_upgrade = paper_upcharge(paper) * per_book; // step 4 binding charges ** per book binding = get_binding(bbinding,total_pages); // step 5 additional services //additional = misc_charges * 1; // step 6 rush service charge is % upcharge for total so far rush_total = ( per_book * qty ) + (paper_upgrade*qty) + (binding*qty); rush = get_rush( rush_total ); // step 6-7 add values to form $('input[name$="base_price"]').attr("value", (base_price - (get_color_charges(clrpgs,colorfact)) ) ); $('input[name$="printing_total"]').attr('value', (rush_total)); $('input[name$="production_speed_charge"]').attr("value", rush); $('input[name$="color_charge"]').attr("value", get_color_charges(clrpgs,colorfact)); $('input[name$="paper_charge"]').attr('value', paper_upgrade); $('#post_binding_charge').attr("value", (binding*qty)); // step 7 shipping ship_total = rush_total + rush; //alert(rush_total + " " + rush + " " + (rush_total + rush)); return ship_total; } function get_shipping(q,b,t,p,s,z){ // quantity, booksize, totalpages, paper, shiptotal$, zip ship = 0; switch(b){ // switches beetween book sizes case 1: switch(p){ case "50": page_factor = 0.0050000; cover_factor = 1.0000000; page_thick = 0.0038990; cover = 0.0077980; break; case "60-N": page_factor = 0.0060000; cover_factor = 1.0000000; page_thick = 0.0047960; cover = 0.0095920; break; case "60-W": page_factor = 0.0060000; cover_factor = 1.0000000; page_thick = 0.0045980; cover = 0.0091960; break; case "70-S": page_factor = 0.0065000; cover_factor = 1.0000000; page_thick = 0.0054040; cover = 0.0108080; break; } per_row = 4; box_width = 11; box_height = 7; box_length = 17; break; case 2: switch(p){ case "50": page_factor = 0.0060000; cover_factor = 1.2500000; page_thick = 0.0038990; cover = 0.0077980; break; case "60-N": page_factor = 0.0070000; cover_factor = 1.2500000; page_thick = 0.0047960; cover = 0.0095920; break; case "60-W": page_factor = 0.0070000; cover_factor = 1.2500000; page_thick = 0.0045980; cover = 0.0091960; break; case "70-S": page_factor = 0.0075000; cover_factor = 1.2500000; page_thick = 0.0054040; cover = 0.0108080; break; } per_row = 4; box_width = 12; box_height = 7; box_length = 18; break; case 3: switch(p){ case "50": page_factor = 0.0100000; cover_factor = 1.5000000; page_thick = 0.0038990; cover = 0.0077980; break; case "60-N": page_factor = 0.0120000; cover_factor = 1.5000000; page_thick = 0.0047960; cover = 0.0095920; break; case "60-W": page_factor = 0.0120000; cover_factor = 1.5000000; page_thick = 0.0045980; cover = 0.0091960; break; case "70-S": page_factor = 0.0130000; cover_factor = 1.5000000; page_thick = 0.0054040; cover = 0.0108080; break; } per_row = 2; box_width = 11; box_height = 7; box_length = 17; break; } // we use those to get the weight total and per book total_weight = 0; total_weight = ( q * (cover_factor*1/16) ) + (q * page_factor * (t/2) ); book_weight = total_weight / q; book_height = (page_thick * (t/2) ) + cover; books_per_col = Math.floor( (7/book_height) ); // total full books fit per column books_per_box = Math.floor( books_per_col * per_row ); // total books per full box total_boxes = Math.ceil( q / books_per_box ); full_boxes = Math.floor( q / books_per_box ); // incase they aren't all full price_each = s / q; // price per book ship_addy = "/shipping/new_shipping.php?total_boxes=" + total_boxes; ship_addy += "&full_boxes=" + full_boxes; ship_addy += "&box_length=" + box_length; ship_addy += "&box_width=" + box_width; ship_addy += "&box_height=" + box_height; ship_addy += "&price_each=" + price_each; ship_addy += "&weight_each=" + book_weight; ship_addy += "&books_per_box=" + books_per_box; ship_addy += "&total_books=" + q; ship_addy += "&dest=" + z; // alert("Book Height: " + book_height + " Books per col: " + books_per_col + " Books Per Box: " + books_per_box); // alert(ship_addy); var response_text = ""; response_text = $.ajax({type: "GET", url: ""+ship_addy+"", async: false }).responseText; return response_text; } function get_shipping2(q,b,t,p,s,z,m){ // quantity, booksize, totalpages, paper, shiptotal$, zip var page_factor, cover_factor, page_thick, cover; page_factor = ""; cover_factor = ""; page_thick = ""; cover = ""; ship = 0; switch(b){ // switches beetween book sizes case 1: switch(p){ case "50": page_factor = 0.0050000; cover_factor = 1.0000000; page_thick = 0.0038990; cover = 0.0077980; break; case "60-N": page_factor = 0.0060000; cover_factor = 1.0000000; page_thick = 0.0047960; cover = 0.0095920; break; case "60-W": page_factor = 0.0060000; cover_factor = 1.0000000; page_thick = 0.0045980; cover = 0.0091960; break; case "70-S": page_factor = 0.0065000; cover_factor = 1.0000000; page_thick = 0.0054040; cover = 0.0108080; break; } per_row = 4; box_width = 11; box_height = 7; box_length = 17; break; case 2: switch(p){ case "50": page_factor = 0.0060000; cover_factor = 1.2500000; page_thick = 0.0038990; cover = 0.0077980; break; case "60-N": page_factor = 0.0070000; cover_factor = 1.2500000; page_thick = 0.0047960; cover = 0.0095920; break; case "60-W": page_factor = 0.0070000; cover_factor = 1.2500000; page_thick = 0.0045980; cover = 0.0091960; break; case "70-S": page_factor = 0.0075000; cover_factor = 1.2500000; page_thick = 0.0054040; cover = 0.0108080; break; } per_row = 4; box_width = 12; box_height = 7; box_length = 18; break; case 3: switch(p){ case "50": page_factor = 0.0100000; cover_factor = 1.5000000; page_thick = 0.0038990; cover = 0.0077980; break; case "60-N": page_factor = 0.0120000; cover_factor = 1.5000000; page_thick = 0.0047960; cover = 0.0095920; break; case "60-W": page_factor = 0.0120000; cover_factor = 1.5000000; page_thick = 0.0045980; cover = 0.0091960; break; case "70-S": page_factor = 0.0130000; cover_factor = 1.5000000; page_thick = 0.0054040; cover = 0.0108080; break; } per_row = 2; box_width = 11; box_height = 7; box_length = 17; break; } // we use those to get the weight total and per book total_weight = 0; total_weight = ( q * (cover_factor*1/16) ) + (q * page_factor * (t/2) ); book_weight = total_weight / q; book_height = (page_thick * (t/2) ) + cover; books_per_col = Math.floor( (7/book_height) ); // total full books fit per column books_per_box = Math.floor( books_per_col * per_row ); // total books per full box total_boxes = Math.ceil( q / books_per_box ); full_boxes = Math.floor( q / books_per_box ); // incase they aren't all full price_each = s / q; // price per book //alert(price_each); ship_addy = "/shipping/new_shipping.php?total_boxes=" + total_boxes; ship_addy += "&full_boxes=" + full_boxes; ship_addy += "&box_length=" + box_length; ship_addy += "&box_width=" + box_width; ship_addy += "&box_height=" + box_height; ship_addy += "&price_each=" + price_each; ship_addy += "&weight_each=" + book_weight; ship_addy += "&books_per_box=" + books_per_box; ship_addy += "&total_books=" + q; ship_addy += "&dest=" + z; ship_addy += "&method=" + m; //alert(ship_addy); // alert("Book Height: " + book_height + " Books per col: " + books_per_col + " Books Per Box: " + books_per_box); // alert(ship_addy); var response_text = ""; response_text = $.ajax({type: "GET", url: ""+ship_addy+"", async: false }).responseText; return response_text; } function get_rush(rtotal){ rcharge = 0; rushtype = $('#production_speed').attr("value"); switch(rushtype){ case "rush": rcharge = (rtotal*0.1000); // add 10% for rush processing break; case "super": rcharge = (rtotal*0.2000); // add 20% for super rush break; case "normal": rcharge = rtotal * 0.0000; break; } return rcharge; } function get_upcharges(uqty){ misc = 0; // reset the list of additional services $('#addy_svc_calc').html(""); $('#addy_svc_calc_r').html(""); uqty = $('#project_qty').attr('value'); total_addit = 0; var_unbound = $('#misc_id_unbound').attr("class"); if( var_unbound == "radios radiosO" ){ misc += 40.00; $('#val_misc_unbound').attr('value','yes'); total_addit += 40.00;} $('#additional-services').html("$" + (total_addit.toFixed(2))); $('#new_order_total').html("$" + ( total_addit + ( $('#printing_total').html().replace("$","") * 1 ) ).toFixed(2) ); var_comlayout = $('#misc_id_comlayout').attr("class"); if( var_comlayout == "radios radiosO" ){ misc += 399.00; $('#val_misc_comlayout').attr('value','yes'); total_addit += 399.00;} $('#additional-services').html("$" + (total_addit.toFixed(2))); $('#new_order_total').html("$" + ( total_addit + ( $('#printing_total').html().replace("$","") * 1 ) ).toFixed(2) ); var_bwinsidecov = $('#misc_id_bwinsidecov').attr("class"); if( var_bwinsidecov == "radios radiosO" ){ misc += (0.40* uqty); $('#val_misc_bwinsidecov').attr('value','yes'); total_addit += 0.40 * uqty;} $('#additional-services').html("$" + (total_addit.toFixed(2))); $('#new_order_total').html("$" + ( total_addit + ( $('#printing_total').html().replace("$","") * 1 ) ).toFixed(2) ); var_rushunbound = $('#misc_id_rushunbound').attr("class"); if( var_rushunbound == "radios radiosO" ){ misc += 55.00; $('#val_misc_rushunbound').attr('value','yes'); total_addit += 55.00;} $('#additional-services').html("$" + (total_addit.toFixed(2))); $('#new_order_total').html("$" + ( total_addit + ( $('#printing_total').html().replace("$","") * 1 ) ).toFixed(2) ); var_rushboundproof = $('#misc_id_rushboundproof').attr("class"); if( var_rushboundproof == "radios radiosO" ){ misc += 100.00; $('#val_misc_rushboundproof').attr('value','yes'); total_addit += 100.00;} $('#additional-services').html("$" + (total_addit.toFixed(2))); $('#new_order_total').html("$" + ( total_addit + ( $('#printing_total').html().replace("$","") * 1 ) ).toFixed(2) ); var_colorinside = $('#misc_id_colorinside').attr("class"); if( var_colorinside == "radios radiosO" ){ misc += (1.00* uqty); $('#val_misc_colorinside').attr('value','yes'); total_addit += 1.00 * uqty;} $('#additional-services').html("$" + (total_addit.toFixed(2))); $('#new_order_total').html("$" + ( total_addit + ( $('#printing_total').html().replace("$","") * 1 ) ).toFixed(2) ); var_freecover = $('#misc_id_freecover').attr("class"); if( var_freecover == "radios radiosO" ){ misc += 0.00; $('#val_misc_freecover').attr('value','yes'); total_addit += 0.00;} $('#additional-services').html("$" + (total_addit.toFixed(2))); $('#new_order_total').html("$" + ( total_addit + ( $('#printing_total').html().replace("$","") * 1 ) ).toFixed(2) ); var_boundproof = $('#misc_id_boundproof').attr("class"); if( var_boundproof == "radios radiosO" ){ misc += 80.00; $('#val_misc_boundproof').attr('value','yes'); total_addit += 80.00;} $('#additional-services').html("$" + (total_addit.toFixed(2))); $('#new_order_total').html("$" + ( total_addit + ( $('#printing_total').html().replace("$","") * 1 ) ).toFixed(2) ); $('#PricingAdditional').attr("value",(total_addit.toFixed(2))); return misc; } function get_binding(which,howmany){ if( which != 'spiral' ){ return 0; } else{ if( howmany < 0 ){ charge = 1.50; } else if( howmany < 101 ){ charge = 1.65 } else if( howmany < 151 ){ charge = 1.85 } else if( howmany < 201 ){ charge = 2.00 } else if( howmany < 251 ){ charge = 2.25 } else if( howmany < 301 ){ charge = 2.50 } else if( howmany < 351 ){ charge = 2.75 } else{ charge = max($bprice); } return charge; } return; } function paper_upcharge(which){ // alert(which); switch(which){ case "50": return 0; break; case "60-N": return 0.12; break; case "60-W": return 0.015; break; case "70-S": return 0.16; break; } } function get_book_price(tp,qf,sf,cp,bq,cf){ //totalpages,qtyfactor,sizefactor,clrpages,qty,color factor // get the base price of 1 book books = 0; color_charge = 0; black_white = tp - cp; if( cp > 0 ){ // if there are color pages add the per book charge ($30/bookquantity) + (perpage * color_charge_each) color_charge = 30/bq; // split upcharge in to each book books += color_charge; // addon = ( (100 * .06) + 1.55 ) = 7.55 addon = ( (cp*cf) ); books += addon; } if( black_white > 0 ){ bwcharge = ( (black_white*qf) ); // add in the cost of the books books += bwcharge; } books += sf; return books; } function get_color_charges(cp,cf){ books = 0; color_charge = 0; if( cp > 0 ){ // if there are color pages add the per book charge ($30/bookquantity) + (perpage * color_charge_each) color_charge = 30; // split upcharge in to each book addon = ( (cp*cf) ); color_charge += addon; } else { color_charge = 0; } return color_charge; } function get_qty_size(which,bqty){ /* this function fetches the qty factor and size factor for the rest of the math */ switch(which){ // loop book sizes case 1: if( bqty > 0 && bqty <= 49){ qty_factor = 0.0242000; size_factor = 3.9500000; color_factor = 0.080000; } else if( bqty >= 50 && bqty <= 74 ){ qty_factor = 0.0185000; size_factor = 2.3800000; color_factor = 0.080000; } else if( bqty >= 75 && bqty <= 99 ){ qty_factor = 0.0171000; size_factor = 1.8300000; color_factor = 0.080000; } else if( bqty >= 100 && bqty <= 149 ){ qty_factor = 0.0163000; size_factor = 1.5500000; color_factor = 0.060000; } else if( bqty >= 150 && bqty <= 199 ){ qty_factor = 0.0153000; size_factor = 1.2760000; color_factor = 0.060000; } else if( bqty >= 200 && bqty <= 249 ){ qty_factor = 0.0148500; size_factor = 1.1100000; color_factor = 0.050000; } else if( bqty >= 250 && bqty <= 299 ){ qty_factor = 0.0145000; size_factor = 1.0920000; color_factor = 0.050000; } else if( bqty >= 300 && bqty <= 349 ){ qty_factor = 0.0143000; size_factor = 1.0600000; color_factor = 0.050000; } else if( bqty >= 350 && bqty <= 399 ){ qty_factor = 0.0141000; size_factor = 1.0200000; color_factor = 0.050000; } else if( bqty >= 400 && bqty <= 449 ){ qty_factor = 0.0139000; size_factor = 0.9840000; color_factor = 0.050000; } else if( bqty >= 450 && bqty <= 499 ){ qty_factor = 0.0135000; size_factor = 0.9600000; color_factor = 0.050000; } else if( bqty >= 500 && bqty <= 749 ){ qty_factor = 0.0124200; size_factor = 0.8560000; color_factor = 0.050000; } else if( bqty >= 750 && bqty <= 999 ){ qty_factor = 0.0123000; size_factor = 0.8160000; color_factor = 0.050000; } else if( bqty >= 1000 && bqty <= 10000000 ){ qty_factor = 0.0112000; size_factor = 0.7540000; color_factor = 0.050000; } return qty_factor + ":" + size_factor + ":" + color_factor; break; case 2: if( bqty > 0 && bqty <= 49){ qty_factor = 0.0277000; size_factor = 4.3420000; color_factor = 0.097000; } else if( bqty >= 50 && bqty <= 74 ){ qty_factor = 0.0212500; size_factor = 2.6400000; color_factor = 0.097000; } else if( bqty >= 74 && bqty <= 99 ){ qty_factor = 0.0198300; size_factor = 2.0140000; color_factor = 0.097000; } else if( bqty >= 100 && bqty <= 149 ){ qty_factor = 0.0188000; size_factor = 1.5100000; color_factor = 0.070000; } else if( bqty >= 150 && bqty <= 199 ){ qty_factor = 0.0180000; size_factor = 1.3400000; color_factor = 0.070000; } else if( bqty >= 200 && bqty <= 249 ){ qty_factor = 0.0170000; size_factor = 1.2400000; color_factor = 0.060000; } else if( bqty >= 250 && bqty <= 299 ){ qty_factor = 0.0169000; size_factor = 1.2280000; color_factor = 0.060000; } else if( bqty >= 300 && bqty <= 349 ){ qty_factor = 0.0167000; size_factor = 1.1640000; color_factor = 0.060000; } else if( bqty >= 350 && bqty <= 399 ){ qty_factor = 0.0165000; size_factor = 1.1310000; color_factor = 0.060000; } else if( bqty >= 400 && bqty <= 449 ){ qty_factor = 0.0164000; size_factor = 1.1130000; color_factor = 0.060000; } else if( bqty >= 450 && bqty <= 499 ){ qty_factor = 0.0163000; size_factor = 1.0960000; color_factor = 0.060000; } else if( bqty >= 500 && bqty <= 749 ){ qty_factor = 0.0150000; size_factor = 0.9800000; color_factor = 0.060000; } else if( bqty >= 750 && bqty <= 999 ){ qty_factor = 0.0148000; size_factor = 0.9300000; color_factor = 0.060000; } else if( bqty >= 1000 && bqty <= 1000000 ){ qty_factor = 0.0135000; size_factor = 0.8400000; color_factor = 0.060000; } return qty_factor + ":" + size_factor + ":" + color_factor; break; case 3: if( bqty > 0 && bqty <= 49){ qty_factor = 0.0375000; size_factor = 3.7500000; color_factor = 0.160000; } else if( bqty >= 50 && bqty <= 74 ){ qty_factor = 0.0342500; size_factor = 2.1500000; color_factor = 0.160000; } else if( bqty >= 75 && bqty <= 99 ){ qty_factor = 0.0313500; size_factor = 2.0920000; color_factor = 0.160000; } else if( bqty >= 100 && bqty <= 149 ){ qty_factor = 0.0280000; size_factor = 1.8200000; color_factor = 0.120000; } else if( bqty >= 150 && bqty <= 199 ){ qty_factor = 0.0275000; size_factor = 1.5680000; color_factor = 0.120000; } else if( bqty >= 200 && bqty <= 249 ){ qty_factor = 0.0270000; size_factor = 1.4400000; color_factor = 0.100000; } else if( bqty >= 250 && bqty <= 299 ){ qty_factor = 0.0220000; size_factor = 1.3720000; color_factor = 0.100000; } else if( bqty >= 300 && bqty <= 349 ){ qty_factor = 0.0219000; size_factor = 1.3250000; color_factor = 0.100000; } else if( bqty >= 350 && bqty <= 399 ){ qty_factor = 0.0218000; size_factor = 1.2890000; color_factor = 0.100000; } else if( bqty >= 400 && bqty <= 449 ){ qty_factor = 0.0218000; size_factor = 1.2650000; color_factor = 0.100000; } else if( bqty >= 450 && bqty <= 499 ){ qty_factor = 0.0218000; size_factor = 1.2460000; color_factor = 0.100000; } else if( bqty >= 500 && bqty <= 749 ){ qty_factor = 0.0200000; size_factor = 0.8500000; color_factor = 0.100000; } else if( bqty >= 750 && bqty <= 999 ){ qty_factor = 0.0180000; size_factor = 0.7500000; color_factor = 0.100000; } else if( bqty >= 1000 && bqty <= 1000000 ){ qty_factor = 0.0174000; size_factor = 0.7000000; color_factor = 0.100000; } return qty_factor + ":" + size_factor + ":" + color_factor; break; } }