//Some basic info about the store used by cookie.js for saving cookies var cart_cookie_name = "CFEA_cart"; //Non-inline frame cart requires these to be set var cart_count = 0; var basket = ""; //Set the store tracker cookie var expdate = new Date(); FixCookieDate(expdate); //fix date for Macs expdate.setTime(expdate.getTime() + (24 * 60 * 60 * 1000)); //24 hours from now SetCookie("gs_st","38.107.191.103-1283855379",expdate,"/",null,false); //build the pid objects //basic info will be need to display on the form var pid_list = new Array; //This keeps track of the type of subs we have //This way we can turn on and off certain type of subscription services var sub_type_pids = new Array; var pid_details = new Object; pid_details.pid = 440; pid_details.name = "Oct. 2009 / Sep. 2010 Grain Trader's Guide PDF"; pid_details.price = 64.95; pid_details.msrp = 64.95; pid_details.is_sub = "0"; pid_details.bit_flag = "-7"; pid_details.savings = 0.00; pid_details.savings_percent = 0; pid_details.pairs = new Array(); pid_details.rates = new Array(); pid_list[440] = pid_details; var pid_details = new Object; pid_details.pid = 441; pid_details.name = "2009 / 2010 Livestock Trader's Guide PDF"; pid_details.price = 64.95; pid_details.msrp = 64.95; pid_details.is_sub = "0"; pid_details.bit_flag = "-7"; pid_details.savings = 0.00; pid_details.savings_percent = 0; pid_details.pairs = new Array(); pid_details.rates = new Array(); pid_list[441] = pid_details; var pid_details = new Object; pid_details.pid = 442; pid_details.name = "2007 / 2008 Grain Market Outlook and Review"; pid_details.price = 49.95; pid_details.msrp = 49.95; pid_details.is_sub = "0"; pid_details.bit_flag = "-7"; pid_details.savings = 0.00; pid_details.savings_percent = 0; pid_details.pairs = new Array(); pid_details.rates = new Array(); pid_list[442] = pid_details; var pid_details = new Object; pid_details.pid = 443; pid_details.name = "2009 Complete Trader's Guide Bundle PDF"; pid_details.price = 279.50; pid_details.msrp = 179.85; pid_details.is_sub = "0"; pid_details.bit_flag = "--1"; pid_details.savings = -99.65; pid_details.savings_percent = 0; pid_details.pairs = new Array(); pid_details.rates = new Array(); pid_list[443] = pid_details; var pid_details = new Object; pid_details.pid = 444; pid_details.name = "2009 Trader's Guide Bundle PDF"; pid_details.price = 99.95; pid_details.msrp = 129.9; pid_details.is_sub = "0"; pid_details.bit_flag = "--1"; pid_details.savings = 29.95; pid_details.savings_percent = 23.1; pid_details.pairs = new Array(); pid_details.rates = new Array(); pid_list[444] = pid_details; var pid_details = new Object; pid_details.pid = 86; pid_details.name = "Commodity Almanac Newsletter Subscription - Fixed Term"; pid_details.price = 0.00; pid_details.msrp = 59.85; pid_details.is_sub = "1"; pid_details.bit_flag = "-6"; pid_details.savings = 59.85; pid_details.savings_percent = 100.0; pid_details.pairs = new Array(); pid_details.rates = new Array(); var rate_86 = new Object; rate_86.rate_id = "173"; rate_86.name = "3 Months"; rate_86.rate = "0.00"; rate_86.mon_rate = "0.00"; rate_86.msrp = "59.85"; rate_86.savings = "0"; rate_86.savings_percent = "0"; rate_86.tl = "3"; pid_details.rates.push(rate_86); pid_list[86] = pid_details; var pid_details = new Object; pid_details.pid = 300; pid_details.name = "Commodity Almanac Newsletter Subscription"; pid_details.price = 19.95; pid_details.msrp = 19.95; pid_details.is_sub = "1"; pid_details.bit_flag = "-6"; pid_details.savings = 0.00; pid_details.savings_percent = 0; pid_details.pairs = new Array(); pid_details.rates = new Array(); var rate_300 = new Object; rate_300.rate_id = "209"; rate_300.name = "2 Year Auto-Renewal"; rate_300.rate = "449.10"; rate_300.mon_rate = "18.71"; rate_300.msrp = "598.80"; rate_300.savings = "149.70"; rate_300.savings_percent = "25"; rate_300.tl = "24"; pid_details.rates.push(rate_300); var rate_300 = new Object; rate_300.rate_id = "208"; rate_300.name = "1 Year Auto-Renewal"; rate_300.rate = "249.50"; rate_300.mon_rate = "20.79"; rate_300.msrp = "299.40"; rate_300.savings = "49.90"; rate_300.savings_percent = "17"; rate_300.tl = "12"; pid_details.rates.push(rate_300); var rate_300 = new Object; rate_300.rate_id = "207"; rate_300.name = "1 Month Auto-Renewal"; rate_300.rate = "24.95"; rate_300.mon_rate = "24.95"; rate_300.msrp = "24.95"; rate_300.savings = "0.00"; rate_300.savings_percent = "0"; rate_300.tl = "1"; pid_details.rates.push(rate_300); pid_list[300] = pid_details; //Used to keep subscriptions and non-subs organized var ptype = new Array(2); function formBuilder() { //No one loaded storetracker with any products if(pid_list.length == 0){ alert("No Product Ids were loaded in Store Tracker to build a form with. Cannot build the form"); return(false); //They are trying to build a form without any products/services } else if(arguments.length == 0){ alert("No Product Ids were passed in to build a form with. Cannot build the form"); return(false); } //This is for the two type of forms we have to build //Non-Sub are not categorized by type... very simple //Sub forms have groups and service types ptype[0] = new Array; //Non-Sub ptype[1] = new Array; //Sub //begin writing the basic stuff for the form document.writeln("
"); document.writeln("
"); document.writeln(""); document.writeln(""); //If only 1 product is passed in, we do a simply "Add to Cart" button add form if(arguments.length == 1 && (pid_list[arguments[0]].is_sub == 0 || (pid_list[arguments[0]].is_sub == 1 && pid_list[arguments[0]].rates.length == 1))){ writePid(loadPid(arguments[0]),"hidden"); //Otherwise, we use checkboxes along with the "Add to Cart" button } else { //Sort out the non-subs from the subs for(var a=0; a
"); document.writeln(""); } function loadPid(pid) { //Make sure the product we are loading has been declared and grab the details for the item being loaded //This protects against hybrid product ids for subscriptions //ie product_id-rate_id if(pid.toString().match(/-/g)) pid = pid.split(/-/)[0]; if(pid_list.length < pid || pid_list[pid] == undefined){ alert("Sorry... Product id: "+pid+" was not loaded in the store_tracker declaration. Cannot build the form."); return(false); } return(pid_list[pid]); } function writePid(d,pid_form_type) { //Show the product document.writeln("
"); if((ptype[0].length + ptype[1].length) > 1) document.writeln(""+d.name+"

"); document.writeln("
"); //This keeps the name and the prices in line //otherwise, a checkbox may cause them to not line up as nice var tab = ""; if(!pid_form_type.match(/hidden/g)) tab = "     "; //If there is a savings to promote... do it! if(d.savings > 0) document.writeln("
"+tab+"Regularly $"+d.msrp+" Save $"+d.savings+"
"); //Finally show then the final price... rock bottom prices everyday :) document.writeln("
"+tab+"Only $"+d.price+"

"); } //Ok this one is fun... function writeSubs(list) { //list should be an array of service pids... //This array keeps each type of services separate... ie Futures is not the same as Options //likewise newsletters are not the same as data services //since you have a futures and options service and since all form fields are named 'pid'... this causes problems //because in a radio button world, you can only have one unless you use separate forms or separate form field names //we could use check boxes... but would be misleading... can I really have a monthly and an annual at once? //yah, yah, yah... we can control selecting both, but radio buttons are a better fit. //we will use separate form field names based on type and then put the into the correct names during submission //loop through all of the services we have for(var i=0; i"+d.name+""); document.writeln(""); //if the service matches the type... then show it. for(var r=0; r"); document.writeln(""); document.writeln(""); document.writeln(""); //This keeps an idex of where all services are for the type //this way when we want to turn on only the Futures services... we now to turn on pid_1[0] - pid_1[2] and so forth // sub_type_pids[t].push(found); // found++; } document.writeln("
"+rate.name+":Avg $"+rate.mon_rate+"/mo"); if(rate.savings > 0) document.writeln("SAVE "+rate.savings_percent+"%!"); document.writeln("

"); } //Show the man how much he is spending for all of his services... especially how much he is saving //document.writeln("

Service Total: $

"); } //This allows us to turn on and off all of the services for a given service type. function enableSubs(form,sub_type) { var status = true; if(sub_type.checked) status = false; var pid = sub_type.value; var found = 0; for(var f=0; f 0) tot_obj.savings_percent = (tot_obj.savings_percent/tot_obj.found); var tot_txt = tot_obj.total.toFixed(2); if(tot_obj.savings > 0) tot_txt += " ... Total Savings: $"+tot_obj.savings.toFixed(2)+" ( "+tot_obj.savings_percent.toFixed(1)+"% )"; if(form.service_total) form.service_total.value = tot_txt; function updateSubSave(form,pid,tot_obj) { var rate_found = 0; for(var f=0; f