function changeInnerBuy(innerID,value,isbn) {
//alert(value);
if (value=="") {value=1}; // set value at 1
var thisID = eval(innerID);
var thistext = '
' + value + '
';
thisID.innerHTML = thistext;
}
function changeInnerInspect(innerID,isbn) {
var thisID = eval(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();
document.forms['SubmitOrder'].OrderID.value = cookieReceipt;
var cookieEx = new Date();
cookieEx.setTime(cookieEx.getTime() + (1 * 60 * 60 * 1000 ));
setCookie('MacReceipt', 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;
}
}
}
// 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 cookieExpires = new Date();
cookieExpires.setTime(cookieExpires.getTime() + (10 * 365 * 24 * 1 * 60 * 60 * 1000 ));
setCookie('MacmillanDetails', detailsCookie, cookieExpires, '/');
}
else { // delete cookie
delCookie('MacmillanDetails','/')
}
}
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 getDiscount(price,series) {
//var strSeriesToDiscount = "Macquarie Revision Guides.; Macquarie Revision Guides;";
var strSeriesToDiscount = "";
if (strSeriesToDiscount.indexOf(unescape(series))!= -1 ) { // discount the price
var fix = price;
if (fix.indexOf('$')!=-1) {
fix = price.substring(1);
}
discount = String("$" + (Number(fix*0.9).toFixed(2)));
return discount;
}
else {
return price;
}
}
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 convISBN10toISBN13(str) {
var c;
var checkDigit = 0;
var result = "";
c = '9';
result += c;
checkDigit += (c - 0) * 1;
c = '7';
result += c;
checkDigit += (c - 0) * 3;
c = '8';
result += c;
checkDigit += (c - 0) * 1;
for ( i = 0; i < 9; i++ ) { // >
c = str.charAt(i);
if ( i % 2 == 0 )
checkDigit += (c - 0) * 3;
else
checkDigit += (c - 0) * 1;
result += c;
}
checkDigit = (10 - (checkDigit % 10)) % 10;
result += (checkDigit + "");
return ( result );
}
function preEditISBN(str)
{
var len = str.length;
var c;
var s;
if ( (str.substring(0,4) == 'ISBN') || (str.substring(0,4) == 'isbn') ) {
str = str.substring(4, len);
len = str.length;
}
s = "";
for ( i = 0; i < len; i++ ) { // >
c = str.charAt(i);
if ( (c == '-') || (c == ' ') )
continue;
s += c;
}
str = s;
return ( str );
}