var Items = new Item(null,null,0,0,0.0,'c'); var nullItem = new Item(null,null,0,0,0.0); var currentNumItems = 0; var credit = 0; var paypal = 0; var sale_total = 0; var US_ship = 1; var discount = 1; var counted=0; var weight_total=0; var first; var total = 0; var email = " "; var expired = new Date() expired.setTime(expired.getTime() - 2000); var expString = "; expires=" + expired.toGMTString(); // 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 var cost_per_pound = new Array(4.80,7.70,10.35,12.65,14.75,16.25,18.25,19.80,21.55,23.45,25.20,26.50,27.55,29.15,29.45,30.10,30.85,31.45,32.25,32.85,33.45,34.20,34.80,35.60,36.15,36.90,37.45,38.00,38.50,39.05,39.55,40.50,41.65,42.80,43.95); function SetCookie(cook, value) { document.cookie = cook + "=" + escape(value); } function saveValue(item,item_num) { SetCookie("order"+item_num,item.page+"|"+item.name+"|"+item.points+"|"+item.number+"|"+item.weight+"|"+item.size+"|"); } // returns value of cookie or null if cookie does not exist function GetCookie(name) { var result = null; var myCookie = " " + document.cookie + ";"; var searchName = " " + name + "="; var startOfCookie = myCookie.indexOf(searchName); var endOfCookie; if (startOfCookie != -1) { startOfCookie += searchName.length; // skip past name of cookie endOfCookie = myCookie.indexOf(";", startOfCookie); result = unescape(myCookie.substring(startOfCookie, endOfCookie)); } return result; } function clearVars () { document.cookie = "checkout_total=0"+expString; currentNumItems = 0; sale_total = 0; US_ship = 1; discount = 1; counted=0; weight_total=0; Items = new Item(null,null,0,0,0.0,'c'); } function doClear() { clearVars(); ResetVars(); self.main.body.location = "trade.html"; first = 1; } function Item (page, name, points, number, weight, size) { this.page = page; this.name = name; this.points = points; this.number = number; this.weight = weight; this.size = size; } function ResetVars (where,page) { if ((top == window) && (where)) { top.location.href = 'http://'+where+'.chuckpint.com?'+page; } updateWindow(); updateTotals(); if (self.main.body != null) { if (self.main.body.document.forms[0] != null) { if ((self.main.body.document.forms[0].name == "checkout") || (self.main.body.document.forms[0].name == "auction")) { self.main.body.location.reload(); } } } } function doMessage(element,message) { alert(message); element.focus(); element.value = ""; } function updateTotals() { total = 0; sales = 0; set_or_bags = 0; weight_total = 0; negative = 0; commons = 0; uncommons = 0; for (i = 0;i < currentNumItems;i++) { if (Items[i].page == "sales") { if ((Items[i].name.indexOf("bag") == -1) && (Items[i].name.indexOf("Set") == -1)) { sales += Items[i].number * Items[i].points; } else { set_or_bags += Items[i].number * Items[i].points; } } else { if (Items[i].number < 0) { negative = 1; } if (Items[i].size == 'c') { commons += Items[i].number * 1; } if (Items[i].size == 'u') { uncommons += Items[i].number * 1; } total += Items[i].number * Items[i].points; } weight_total += Items[i].number * Items[i].weight; } sale_total = sales; if (total > 0) { if (!negative && ((commons > 49) || (uncommons > 24))) { sale_total += total / 5; discount = 0.80; } else { sale_total += total / 4; discount = 1; } } if (negative && (sales == 0) && (set_or_bags == 0)) { shipping = 0; } else if (!US_ship) { shipping = -1; } else if (weight_total == 0) { shipping = 0; } else if (weight_total <= 1) { shipping = 0.80; } else if ((weight_total <= 13) && (sales == 0)) { shipping = 0.80 + parseInt(weight_total - 1) * 0.17; } else if (weight_total < 16) { shipping = 4.80; } else if {weight_total < (16*35)) { temp = parseInt((weight_total - 16) / 16); shipping = cost_per_pound[temp]; } else { temp = parseInt((weight_total - 16) / 16) - 35; shipping = cost_per_pound[35] + temp; } sale_total = sale_total + set_or_bags; if (shipping > 0) { shipping += 1.00; // handling shipping += 0.50 + (sale_total * 0.03); //PayPal shipping = parseInt(shipping * 100) / 100.0; sale_total += shipping; } if (self.credit) { sale_total *= 1.10; } sale_total = parseInt(sale_total * 100 + 0.5)/100; weight_total = parseInt(weight_total * 10 + 0.5)/10; if (self.main.bottom != null) { with (self.main.bottom.document) { open("text/html","replace"); if (currentNumItems == 0) { writeln(''); writeln('') writeln(''); writeln('Send '); writeln("" + "Chuck Pint" + ""); writeln(' a message if you want to buy or trade. © 1998-2007.'); } else { writeln(''); if ((sale_total == 0) && (total == 0)) { writeln(""); } else { if (total != 0) { writeln(""); } writeln(""); if (US_ship) { if (shipping < 0) { writeln(""); } writeln('
Even TradeTotal points = "+total+"Total cost (shipping included) = $"+sale_total+"Shipping cost = ???"); } if (shipping == 0) { writeln("Shipping cost = Free"); } else { writeln("Shipping cost = $"+shipping); } } else { writeln("shipping weight = "+weight_total+"oz."); } writeln("
'); } close(); } } if (self.main.extra != null) { with (self.main.extra.document) { open("text/html","replace"); if (currentNumItems != 0) { writeln(''); writeln(''); writeln(''); } close(); } } } function doTotal(element,points,totals,threshold,weight,size) { if (element == null) { return; } trade_ok = (totals < 0) ? 1 : 0; if (totals >= 1000) { trade_ok = 1; totals -= 1000; } if (totals == -1000) { totals = 0; } if (totals == -2000) { totals = -2; } if (element.value != "") { amount = parseInt(element.value); amount = amount + " "; amount = amount.substring(0,amount.length - 1); if (amount.length != element.value.length) { doMessage(element,'Only enter integer numbers.'); return; } if ((element.value < 0) && (!trade_ok)) { doMessage(element,'I will not take any in trade.'); return; } i = totals - threshold; if ((element.value < 0) && (i > element.value) && (points < 100)) { doMessage(element,'I will not take more than '+(-i)+' in trade.'); return; } if ((element.value > 0) && (element.value > totals)) { doMessage(element,'I do not have that many to '+((element.form.name == 'sales')?'sell.':'trade.')); return; } } for (i = 0;i < currentNumItems;i++) { if ((Items[i].name == element.name) && (Items[i].page == element.form.name)) { if (element.value != 0) { Items[i].number = element.value; saveValue(Items[i],i); } else { for (; i < (currentNumItems - 1);i++) { Items[i] = Items[i+1]; saveValue(Items[i],i); } element.value = ""; currentNumItems--; } break; } } if (i == currentNumItems) { if (element.value == 0) { element.value = ""; } else { Items[currentNumItems] = new Item(element.form.name,element.name,points,element.value,weight,size); // saveValue(Items[currentNumItems],currentNumItems); currentNumItems++; } } updateTotals(); } function returnAmount(page, name) { for (j = 0;j < currentNumItems;j++) { if ((Items[j].page == page) && (Items[j].name == name)) { return(Items[j].number); } } return(""); } function updateWindow() { if (self.main.body == null) { return; } with (self.main.body.document) { if (forms[0] == null) { return; } for (i = 0;i < forms[0].elements.length;i++) { if (forms[0].elements[i].type == "text") { forms[0].elements[i].value = returnAmount(forms[0].name,forms[0].elements[i].name); } } } updateTotals(); } if (first == 0) { doClear(); }