var payTypeAB; function submitOrder(oEvent) { var target = stopEvent(oEvent); var payTypeList = document.forms['SubmitOrder'].CustomField_4; for(var i=0; i < payTypeList.length; i++) { if(payTypeList[i].checked)payTypeAB = payTypeList[i].value; } var oOrder = document.forms['SubmitOrder'].overseasOrder; for(var i=0; i < oOrder.length; i++) { if(oOrder[i].checked)var fOverseasOrder = oOrder[i].value; } //if((payTypeAB == '2' || payTypeAB == '3') && isMixedOrder() == false) if((payTypeAB == '2' || payTypeAB == '3') && fOverseasOrder == "0") { var promptedUser = true; var confirmCRPay = confirm('Please be advised when you confirm your order your credit card will be debited and your order will not be refundable unless we are notified within 14 days that an item is faulty or incorrectly supplied.'); } if(!promptedUser || (promptedUser && confirmCRPay == true)) { SubmitSecurePay(payTypeAB); } /* } else { loadHiddenInputs(); var oForm = document.forms['SubmitOrder']; oForm.Comments.value = getHiddenCommentText(); delCookie('MacPrimary','/'); delCookie('MacmillanDetailsNew','/'); oForm.submit(); } */ } function getCartFormFields() { var payTypeList = document.forms['SubmitOrder'].CustomField_4; for(var i=0; i < payTypeList.length; i++) { if(payTypeList[i].checked)payTypeAB = payTypeList[i].value; } loadHiddenInputs(); if(payTypeAB == "3") { changeInputsForPayType3(); } var oForm = document.forms['SubmitOrder']; oForm.Comments.value = getHiddenCommentText(); delCookie('MacPrimary','/'); } function loadHiddenInputs() { var oForm = document.forms['SubmitOrder']; //Load order price if((typeof checkTC != "undefined")&& (checkTC == true)) { oForm.OrderPrice.value = "$" + oCart.getEClubTotal(); } else { oForm.OrderPrice.value = "$" + oCart.getTotal(); } oForm.Quantity.value = oCart.getItemsQuantity(); //----------oForm.SpecialOffer.value = ""; } function changeInputsForPayType3() { var oForm = document.forms['SubmitOrder']; var fElements = new Array(); fElements.push(['CardType','S_CType',oForm.CardType.value]); fElements.push(['CardNumber','S_CNumber',oForm.CardNumber.value]); fElements.push(['CardName','S_CName',oForm.CardName.value]); fElements.push(['CardMonth','S_CMonth',oForm.CardMonth.value]); fElements.push(['CardYear','S_CYear',oForm.CardYear.value]); fElements.push(['Inv_Order_Number','Card_ONumber',oForm.Inv_Order_Number.value]); fElements.push(['Inv_Order_AccountCode','Card_OAccountCode',oForm.Inv_Order_AccountCode.value]); for(var i=0; i < fElements.length; i++) { var oElement = oForm.eval(fElements[i][0]); oElement.name = fElements[i][1]; oElement.id = fElements[i][1]; oElement.value = fElements[i][2]; } } function getCommentIsbnString(isbn) { if(isbn.length == 10) { return (isbn + ' (' + isbn10to13(isbn) + ')'); } return isbn; } function getIsbn13(isbn) { if(isbn.length == 10) { return isbn10to13(isbn); } return isbn; } function getHiddenCommentText() { var oForm = document.forms['SubmitOrder']; var sComments = "Teacher e-club discount applied: No\n\n"; if((typeof checkTC != "undefined")&& (checkTC == true)) { sComments = "Teacher e-club discount applied: Yes\n\n"; } //Load items for(var i=0; i < oCart.items.length; i++) { sComments += "Order: " + (i+1) + "\n"; sComments += "ISBN: " + getCommentIsbnString(oCart.items[i].isbn) + "\n"; sComments += "Title: " + oCart.items[i].title + "\n"; if(oCart.items[i].buyInspect.substring(1) == "I") { sComments += "Price: -" + "\n"; sComments += "Type: Inspection Copy" + "\n"; } else { if(oCart.items[i].isEClub()&&((typeof checkTC != "undefined")&&(checkTC == true))) { sComments += "Price: $" + oCart.eClubPrice(i) + " (eClub)\n"; } else { sComments += "Price: $" + oCart.items[i].price + "\n"; } sComments += "Type: Buy Copy" + "\n"; } sComments += "Quantity: " + oCart.items[i].quantity + "\n\n"; } sComments += "====================================\n\n\n"; sComments += "Other information\n"; sComments += "====================================\n"; sComments += "Position: " + oForm.CustomField_2.value + " \n"; sComments += "Fax: " + oForm.CustomField_3.value + " \n\n"; sComments += "Additional comments: \n"; sComments += "====================================\n"; sComments += oForm.Comments_1.value + "\n\n\n"; sComments += "Payment details\n"; sComments += "====================================\n"; if(payTypeAB == "2")//credit card payment { sComments += "Payment method: Personal Credit Card\n\n"; if((typeof checkTC != "undefined")&& (checkTC == true)) { sComments += "TOTAL PURCHASE PRICE = $" + oCart.getEClubTotal() + "\n"; } else { sComments += "TOTAL PURCHASE PRICE = $" + oCart.getTotal() + "\n"; } if (!checkTC) { sComments += "Handling fee of $" + oCart.handlingCharge + " applied to this order.\n\n"; } else { sComments += "No handling fee applies to this order.\n\n"; } sComments += "Card Type: " + oForm.CardType.value + " \n"; sComments += "Card Holder Name: " + oForm.CardName.value + " \n"; sComments += "Card Number: " + oForm.CardNumber.value + " \n"; sComments += "Card Expiry: " + oForm.CardMonth.value + " / " + oForm.CardYear.value + " \n\n"; } else if(payTypeAB == "4")//invoice payment { sComments += "Payment method: Invoice\n\n"; if((typeof checkTC != "undefined")&& (checkTC == true)) { sComments += "TOTAL PURCHASE PRICE = $" + oCart.getEClubTotal() + "\n"; } else { sComments += "TOTAL PURCHASE PRICE = $" + oCart.getTotal() + "\n"; } sComments += "Customer Order Number: " + oForm.Inv_Order_Number.value + " \n\n"; sComments += "Account Code: " + oForm.Inv_Order_AccountCode.value + " \n\n"; } else if(payTypeAB == "3")//credit card + invoice payment { sComments += "Payment method: School Credit Card\n\n"; if((typeof checkTC != "undefined")&& (checkTC == true)) { sComments += "TOTAL PURCHASE PRICE = $" + oCart.getEClubTotal() + "\n"; } else { sComments += "TOTAL PURCHASE PRICE = $" + oCart.getTotal() + "\n"; } sComments += "\nCard Type: " + oForm.CardType.value + " \n"; sComments += "Card Holder Name: " + oForm.CardName.value + " \n"; sComments += "Card Number: " + oForm.CardNumber.value + " \n"; sComments += "Card Expiry: " + oForm.CardMonth.value + " / " + document.forms['SubmitOrder'].CardYear.value + " \n\n"; sComments += "Customer Order Number: " + oForm.Inv_Order_Number.value + " \n\n"; sComments += "Account Code: " + oForm.Inv_Order_AccountCode.value + " \n\n"; } if (oForm.MoreInfo.checked == true) { sComments += "Please send me further info on Macmillan products? Yes\n"; } else { sComments += "Please send me further info on Macmillan products? No\n"; } return sComments; } function SubmitSecurePay(payType) { if(document.getElementById('securePayForm')) { document.body.removeChild(document.getElementById('securePayForm')); } var oForm = document.forms['SubmitOrder']; var hiddenInputs = new Array(); //sender details hiddenInputs.push(new HiddenInput('WebSiteName','MEA Primary')); var eClub = ''; if(typeof checkTC != 'undefined' && checkTC)eClub = oForm.EmailAddress.value; hiddenInputs.push(new HiddenInput('eClub',eClub)); hiddenInputs.push(new HiddenInput('ISBNBundleCode','')); hiddenInputs.push(new HiddenInput('OrgName','')); hiddenInputs.push(new HiddenInput('DiscountCode','')); //add fields from step one hiddenInputs.push(new HiddenInput('FirstName',oForm.Firstname.value)); hiddenInputs.push(new HiddenInput('LastName',oForm.Lastname.value)); hiddenInputs.push(new HiddenInput('Position',oForm.CustomField_2.value)); //var orgType = oForm.orgType.getElementsByTagName('option')[oForm.orgType.selectedIndex].value; if(oForm.Organisation.value.length > 0) { //hiddenInputs.push(new HiddenInput('SchoolName',orgType + oForm.Organisation.value)); var orgName = (oForm.Organisation.value.toLowerCase().indexOf('school') != -1) ? oForm.Organisation.value : ('School ' + oForm.Organisation.value); hiddenInputs.push(new HiddenInput('SchoolName',orgName)); } else { hiddenInputs.push(new HiddenInput('SchoolName','')); } hiddenInputs.push(new HiddenInput('SalesRepCode',oForm.SalesRepCode.value)); hiddenInputs.push(new HiddenInput('PostalAddress',oForm.PostalAddress.value)); hiddenInputs.push(new HiddenInput('PostalCity',oForm.PostalCity.value)); var oOrder = document.forms['SubmitOrder'].overseasOrder; for(var i=0; i < oOrder.length; i++) { if(oOrder[i].checked)var fOverseasOrder = oOrder[i].value; } var fPostalState = document.forms['SubmitOrder'].PostalState.getElementsByTagName('option')[document.forms['SubmitOrder'].PostalState.selectedIndex].value; if(fOverseasOrder == "1")fPostalState = "International"; hiddenInputs.push(new HiddenInput('PostalState',fPostalState)); hiddenInputs.push(new HiddenInput('PostalCode',oForm.PostalCode.value)); //hiddenInputs.push(new HiddenInput('OverseasOrder',fOverseasOrder)); hiddenInputs.push(new HiddenInput('PhoneNumber',oForm.PhoneNumber.value)); hiddenInputs.push(new HiddenInput('FaxNumber',oForm.CustomField_3.value)); hiddenInputs.push(new HiddenInput('EmailAddress',oForm.EmailAddress.value)); var moreInfo = "False"; if(oForm.MoreInfo.checked)moreInfo = "True"; hiddenInputs.push(new HiddenInput('FurtherInfo',moreInfo)); //var contactType = oForm.ContactType.getElementsByTagName('option')[oForm.ContactType.selectedIndex].value; // 1=email 2=phone 3=postal hiddenInputs.push(new HiddenInput('PreferredContactType',oForm.ContactType.selectedIndex + 1)); hiddenInputs.push(new HiddenInput('Comments',oForm.Comments_1.value)); hiddenInputs.push(new HiddenInput('PaymentType',payType)); hiddenInputs.push(new HiddenInput('ST','F')); //payment details if(payType == '2') { if((typeof checkTC != "undefined")&& (checkTC == true)) { hiddenInputs.push(new HiddenInput('Handling','0')); } else { hiddenInputs.push(new HiddenInput('Handling',oCart.handlingCharge)); } } else { hiddenInputs.push(new HiddenInput('Handling','0')); } hiddenInputs.push(new HiddenInput('Freight',0)); if((typeof checkTC != "undefined")&& (checkTC == true)) { //alert('Total price: ' + oCart.getEClubTotal()); hiddenInputs.push(new HiddenInput('Total',oCart.getEClubTotal())); //hiddenInputs.push(new HiddenInput('Total','100.00')); //var oPrice = Math.round(oCart.getEClubTotal()).toFixed(2); } else { //alert('Total price: ' + oCart.getTotal()); hiddenInputs.push(new HiddenInput('Total',oCart.getTotal())); //hiddenInputs.push(new HiddenInput('Total','100.00')); //var oPrice = Math.round(oCart.getTotal()).toFixed(2); } //hiddenInputs.push(new HiddenInput('Total',oPrice)); //invoice details if(payType == '3' || payType == '4') { hiddenInputs.push(new HiddenInput('Inv_Order_Number',oForm.Inv_Order_Number.value)); hiddenInputs.push(new HiddenInput('Inv_Order_AccountCode',oForm.Inv_Order_AccountCode.value)); } //cart items for(var i=0; i < oCart.items.length; i++) { hiddenInputs.push(new HiddenInput(('book' + (i+1)) + '_ProdId',getIsbn13(oCart.items[i].isbn))); //hiddenInputs.push(new HiddenInput(('book' + (i+1)) + '_ProdId',oCart.items[i].isbn); hiddenInputs.push(new HiddenInput(('book' + (i+1)) + '_Desc','\"' + oCart.items[i].title + '\".\"' + oCart.getBookAuthor(oCart.items[i].isbn) + '\"')); /* if(oCart.items[i].available) { if(oCart.items[i].buyInspect.substring(1) == "I") { hiddenInputs.push(new HiddenInput(('book' + (i+1)) + '_OrderType','2'));// 1=buy 2=inspect 3=request } else { hiddenInputs.push(new HiddenInput(('book' + (i+1)) + '_OrderType','1')); } } else { hiddenInputs.push(new HiddenInput(('book' + (i+1)) + '_OrderType','3')); } */ switch(oCart.items[i].buyInspect.substring(1)) { case 'B': { if(oCart.items[i].available) { var sValue = '1'; break; } else { var sValue = '3'; break; } } case 'I': var sValue = '2'; break; case 'R': var sValue = '3'; break; default: var sValue = ''; } hiddenInputs.push(new HiddenInput(('book' + (i+1)) + '_OrderType',sValue)); if(oCart.items[i].isEClub()&&((typeof checkTC != "undefined")&&(checkTC == true))) { hiddenInputs.push(new HiddenInput(('book' + (i+1)) + '_RRP',oCart.eClubPrice(i))); var disc = '10'; } else { hiddenInputs.push(new HiddenInput(('book' + (i+1)) + '_RRP',oCart.items[i].price)); var disc = '0'; } hiddenInputs.push(new HiddenInput(('book' + (i+1)) + '_Disc',disc)); hiddenInputs.push(new HiddenInput(('book' + (i+1)) + '_QTY',oCart.items[i].quantity)); } var oForm = document.createElement('form'); oForm.action = 'http://macmillan.itechne.com/'; oForm.method = 'post'; oForm.id = 'securePayForm'; //var str = "Secure Pay:\n\n"; for(var i = 0; i < hiddenInputs.length; i++) { switch(hiddenInputs[i].id) { case 'Comments': var oText = document.createElement('textarea'); oText.style.display = 'none'; oText.name = hiddenInputs[i].id; oText.id = hiddenInputs[i].id; oText.appendChild(document.createTextNode(hiddenInputs[i].val)); oForm.appendChild(oText); break; default: var oInput = document.createElement('input'); oInput.type = 'hidden'; oInput.name = hiddenInputs[i].id; oInput.id = hiddenInputs[i].id; oInput.value = hiddenInputs[i].val; oForm.appendChild(oInput); } } document.body.appendChild(oForm); setTimeout('document.getElementById(\'securePayForm\').submit()',1000); } function isMixedOrder() { for(var i=0;i