function changeInnerBuy(caller,innerID,value,isbn)
{
if (value=="") {value=1}; // set value at 1
var thisID = document.getElementById(innerID);
var thistext = '
' + value + '
';
thisID.innerHTML = thistext;
}
function changeInnerInspect(innerID,isbn) {
var thisID = document.getElementById(innerID);
var thistext = '
1
';
thisID.innerHTML = thistext;
}
function setReceipt() {
var receiptTime = new Date();
var receiptName = document.forms['SubmitOrder'].Lastname.value.substring(0,5).toUpperCase();
var cookieReceipt = receiptName + receiptTime.valueOf();
if (document.forms['SubmitOrder'].SpecialOffer.value!="") {
cookieReceipt += "SO"
}
document.forms['SubmitOrder'].OrderID.value = cookieReceipt;
var cookieEx = new Date();
cookieEx.setTime(cookieEx.getTime() + (1 * 60 * 60 * 1000 ));
setCookie('MacPrimaryReceipt', cookieReceipt, cookieEx, '/');
}
function getRadioValue(thisElement)
{
var i;
var listingType = document.forms['SubmitOrder'].elements[thisElement];
var value = "";
for (i=0; i < listingType.length; i++)
{
if (listingType[i].checked)
{
return listingType[i].value;
}
}
}
function getOffer()
{
if (typeof(document.forms['SubmitOrder'].offer)!='undefined') {
var offerType = getRadioValue('offer');
}
else {
var offerType = "No offer";
}
return offerType;
}
// yes
function rememberDetails() {
if (document.forms['SubmitOrder'].Remember.checked) {
var which = document.forms['SubmitOrder'];
detailsCookie = which.Firstname.value + ";"
detailsCookie += which.Lastname.value + ";"
detailsCookie += which.CustomField_2.value + ";"
detailsCookie += which.Organisation.value + ";"
detailsCookie += which.MoreInfo.checked + ";"
detailsCookie += which.PostalAddress.value + ";"
detailsCookie += which.PostalCity.value + ";"
detailsCookie += which.PostalState.value + ";"
detailsCookie += which.PostalCode.value + ";"
detailsCookie += which.PhoneNumber.value + ";"
detailsCookie += which.CustomField_3.value + ";"
detailsCookie += which.EmailAddress.value + ";"
detailsCookie += which.ContactType.value + ";"
var overOrder = document.forms['SubmitOrder'].overseasOrder;
for(var i=0; i < overOrder.length; i++)
{
if(overOrder[i].checked)var fOverseasOrder = overOrder[i].value;
}
detailsCookie += fOverseasOrder + ";"
var payType = document.forms['SubmitOrder'].CustomField_4;
for(var i=0; i < payType.length; i++)
{
if(payType[i].checked)var paymentType = payType[i].value;
}
detailsCookie += paymentType + ";"
var cookieExpires = new Date();
cookieExpires.setTime(cookieExpires.getTime() + (10 * 365 * 24 * 1 * 60 * 60 * 1000 ));
setCookie('MacmillanDetailsNew', detailsCookie, cookieExpires, '/');
}
else { // delete cookie
delCookie('MacmillanDetailsNew','/')
}
}
function num2money(n_value) {
// validate input
if (isNaN(Number(n_value)))
return 'ERROR';
// save the sign
var b_negative = Boolean(n_value < 0);
n_value = Math.abs(n_value);
// round to 1/100 precision, add ending zeroes if needed
var s_result = String(Math.round(n_value*1e2)%1e2 + '00').substring(0,2);
// separate all orders
var b_first = true;
var s_subresult;
while (n_value > 1) {
s_subresult = (n_value >= 1e3 ? '00' : '') + Math.floor(n_value%1e3);
s_result = s_subresult.slice(-3) + (b_first ? '.' : ',') + s_result;
b_first = false;
n_value = n_value/1e3;
}
// add at least one integer digit
if (b_first)
s_result = '0.' + s_result;
// apply formatting and return
return b_negative
? '($' + s_result + ')'
: '$' + s_result;
}
function checkNewSeries(date) { // checks to see if a book is less than 6 months old
if (date!="") {
var thisPageDateSplit = date.split('/');
thisDay = thisPageDateSplit[0];
thisMonth = thisPageDateSplit[1] - 1;
thisYear = thisPageDateSplit[2];
var bookDate = new Date();
bookDate.setFullYear(thisYear, thisMonth, thisDay);
}
else {
var bookDate = new Date();
bookDate.setMonth(bookDate.getMonth()-6);
}
oldDate = new Date(); // 6 months before today's date
oldDate.setMonth(oldDate.getMonth()-6);
if (oldDate < bookDate) {
document.write('
');
}
}
function checkIsAvailable(date) { // checks to see if a book is released yet
if (date!="") {
var thisPageDateSplit = date.split('/');
thisDay = thisPageDateSplit[0];
thisMonth = thisPageDateSplit[1] - 1;
thisYear = thisPageDateSplit[2];
var bookDate = new Date();
bookDate.setFullYear(thisYear, thisMonth, thisDay);
}
else {
return true;
}
currentDate = new Date();
if (currentDate < bookDate) {
return false;
}
return true;
}
function getOfferLabels(formValue) {
strValues = "1A; 1B; 1C; 2A; 2B; 2C; 3A; 3B; 3C; 3D; 3E; 3F; 3G; 4A; 4B; 4C; 4D; 4E; ";
strNames = "3 x Macmillan Australian Student Dictionary (0 7329 9973 1); 1 x Kids and Co Set 1 (1420203460); 1 x Kids and Co Set 2 (1420203479); 8 x Macmillan Australian Primary Dictionary (0 7329 9972 3); 1 x Girlz Rock! Set 1 (0 7329 9876 X); 1 x Antarctica Series x 4 books (1420209353); 1 x Trekkers Blue Pack (0 7329 9969 3); 1 x Trekkers Yellow Pack (0 7329 9970 7); 1 x Trekkers Green Pack (0 7329 9971 5); 1 x The Media Series (1420209361); 20 x Other Words (0 7329 2568 1); 10 x Macmillan Australian Student Dictionary (0 7329 9973 1); 1 x Artists At Work Series (142020937X); Boyz Rule Set 1, and 2 and 3 (1420209477); 4 x Kids and Co Set 1 (1 4202 0346 0); 4 x Kids and Co Set 2 (1 4202 0347 9); 15 x Macmillan Australian Student Dictionary (0 7329 9973 1); Our Neighbours Boxed Set (0 7329 8924 8); ";
var fromlist = strValues.split('; ');
var tolist = strNames.split('; ');
for (var i = 0; i < fromlist.length; i++ ) {
if (fromlist[i] == formValue) {
return tolist[i];
}
}
return formValue
}
function getNumItems() {
var tmp = splitCookie('MacPrimary');
var numItems = 0;
for (var i=0;i