// the image path to use, with an {ITEMID} placeholder embedded in it
var WOWstrCoverPath = "http://contentcafe2.btol.com/ContentCafe/Jacket.aspx?Return=1&Type=S&Value={ITEMID}&userID=III51&password=BT0051";
// the widget's width (in pixels)
var WOWiWidgetWidth=300;
// the widget's height
var WOWiWidgetHeight=135;
// the slide speed (larger is faster 1-10)
var WOWslidespeed=2;
// cycles to pause per title
var WOWiPause=100;
// max width of visible titles in characters - however, a more precise method is used to ensure title fits onscreen
var WOWiTitleMaxShowingLength = 70;
// configure S curve - this is really percentages
var WOWarraySpeedRamp = new Array(-0.50,-0.37,-0.26,-0.17,-0.10,-0.05,-0.02,-0.01,0,0.01,0.02,0.05,0.10,0.17,0.26,0.37);
// bar-separated list of ASIN-or-ISBN/WowbraryURL/Title (no final bar)
var WOWstrRawData = "9780446563048|http://www.wowbrary.org/l.aspx?l=2786&c=1201343&i=9780446563048&t=Delivering+Happiness%3a+A+Path+to+Profits%2c+Passion%2c+and+Purpose&widget|Delivering Happiness: A Path to Profits, Passion, and Purpose|9780446545921|http://www.wowbrary.org/l.aspx?l=2786&c=1201317&i=9780446545921&t=The+I+Hate+to+Cook+Book%3a+50th+Anniversary+Edition&widget|The I Hate to Cook Book: 50th Anniversary Edition|9780060852580|http://www.wowbrary.org/l.aspx?l=2786&c=1201249&i=9780060852580&t=The+Lacuna%3a+A+Novel+(P.S.)&widget|The Lacuna: A Novel (P.S.)|9781416563723|http://www.wowbrary.org/l.aspx?l=2786&c=1201415&i=9781416563723&t=The+Red+Queen%3a+A+Novel+(The+Cousins%27+War)&widget|The Red Queen: A Novel (The Cousins\' War)|9780553807240|http://www.wowbrary.org/l.aspx?l=2786&c=1201330&i=9780553807240&t=Live+to+Tell%3a+A+Detective+D.+D.+Warren+Novel&widget|Live to Tell: A Detective D. D. Warren Novel|9781400066407|http://www.wowbrary.org/l.aspx?l=2786&c=1201311&i=9781400066407&t=Super+Sad+True+Love+Story%3a+A+Novel&widget|Super Sad True Love Story: A Novel|9781416563105|http://www.wowbrary.org/l.aspx?l=2786&c=1201380&i=9781416563105&t=Tough+Customer%3a+A+Novel&widget|Tough Customer: A Novel|9780805093384|http://www.wowbrary.org/l.aspx?l=2786&c=1201331&i=9780805093384&t=In+a+Heartbeat%3a+Sharing+the+Power+of+Cheerful+Giving&widget|In a Heartbeat: Sharing the Power of Cheerful Giving|9780345484178|http://www.wowbrary.org/l.aspx?l=2786&c=1201429&i=9780345484178&t=Bearers+of+the+Black+Staff+(Legends+of+Shannara)&widget|Bearers of the Black Staff (Legends of Shannara)|9780312605391|http://www.wowbrary.org/l.aspx?l=2786&c=1201345&i=9780312605391&t=Love+In+The+Afternoon+(Hathaways)&widget|Love In The Afternoon (Hathaways)|9780439845007|http://www.wowbrary.org/l.aspx?l=2786&c=1201238&i=9780439845007&t=Bob+Books%2c+Set+1%3a+Beginning+Readers&widget|Bob Books, Set 1: Beginning Readers|9780061995033|http://www.wowbrary.org/l.aspx?l=2786&c=1201342&i=9780061995033&t=The+Upside+of+Irrationality%3a+The+Unexpected+Benefits+of+Defying+Logic+at+Work+and+at+Home&widget|The Upside of Irrationality: The Unexpected Benefits of Defying Logic at Work and at Home|9780805090567|http://www.wowbrary.org/l.aspx?l=2786&c=1201328&i=9780805090567&t=Eaarth%3a+Making+a+Life+on+a+Tough+New+Planet&widget|Eaarth: Making a Life on a Tough New Planet|9781419873379|http://www.wowbrary.org/l.aspx?l=2786&c=1201293&i=9781419873379&t=The+Outsiders&widget|The Outsiders|9786312328520|http://www.wowbrary.org/l.aspx?l=2786&c=1201295&i=9786312328520&t=Rebecca&widget|Rebecca|9780375429873|http://www.wowbrary.org/l.aspx?l=2786&c=1201396&i=9780375429873&t=The+Best+373+Colleges%2c+2011+Edition+(College+Admissions+Guides)&widget|The Best 373 Colleges, 2011 Edition (College Admissions Guides)|9780393068474|http://www.wowbrary.org/l.aspx?l=2786&c=1201446&i=9780393068474&t=Packing+for+Mars%3a+The+Curious+Science+of+Life+in+the+Void&widget|Packing for Mars: The Curious Science of Life in the Void|9781596916104|http://www.wowbrary.org/l.aspx?l=2786&c=1201351&i=9781596916104&t=Merchants+of+Doubt%3a+How+a+Handful+of+Scientists+Obscured+the+Truth+on+Issues+from+Tobacco+Smoke+to+Global+Warming&widget|Merchants of Doubt: How a Handful of Scientists Obscured the Truth on Issues from Tobacco Smoke to Global Warming|9780061804090|http://www.wowbrary.org/l.aspx?l=2786&c=1201360&i=9780061804090&t=Country+Driving%3a+A+Journey+Through+China+from+Farm+to+Factory&widget|Country Driving: A Journey Through China from Farm to Factory|9780061723759|http://www.wowbrary.org/l.aspx?l=2786&c=1201362&i=9780061723759&t=Bounce%3a+Mozart%2c+Federer%2c+Picasso%2c+Beckham%2c+and+the+Science+of+Success&widget|Bounce: Mozart, Federer, Picasso, Beckham, and the Science of Success";
// gap between each image (use HTML):
var WOWimagegap=" "
var WOWslidebgcolor="white";
var WOWiMoveDirection = 1; // -1, 0, 1
var WOWarraySlideWidths = new Array();
var WOWstrSlideContents = "";
var WOWarrayRawData = WOWstrRawData.split("|");
for (WOWi = 0; WOWi < WOWarrayRawData.length; WOWi += 3)
WOWstrSlideContents += "
";
WOWstrSlideContents += '';
var WOWiedom=document.all||document.getElementById;
if (WOWiedom) document.write(''+WOWstrSlideContents+'')
var WOWiSlides = 0;
var WOWarraySlideCenters = new Array();
var WOWarraySlideTitles = new Array();
var WOWactualwidth;
var WOWcross_slide, WOWcross_slide2, WOWns_slide, WOWns_slide2;
// this isn't called until all images have loaded
function WOWfillup(){
// figure out which images loaded and use just those to create the title array, eliminate gaps in the width array,
// recreate WOWstrSlideContents for display, sum the image widths, and count valid slides
var iTotalWidths = 0;
WOWstrSlideContents = "";
WOWiSlides = 0;
var i;
for (i = 0; i < WOWarrayRawData.length; i += 3)
if (document.getElementById("WOWimage" + i).width > 1) {
WOWarraySlideTitles[WOWiSlides] = WOWarrayRawData[i+2],
WOWarraySlideWidths[WOWiSlides] = document.getElementById("WOWimage" + i).width;
iTotalWidths += WOWarraySlideWidths[WOWiSlides];
WOWstrSlideContents += "![Click to see more about " + WOWarrayRawData[i+2] + "](" +
WOWstrCoverPath.replace("{ITEMID}", WOWarrayRawData[i]) +
")
"; // +WOWimagegap;
WOWiSlides++;
}
WOWstrSlideContents += '';
// for unclear reasons, sometimes the slides haven't really loaded in yet, so if none have arrived, exit and try again later
if (WOWiSlides == 0) {
setTimeout("WOWfillup()",100);
return;
}
if (WOWiedom){
WOWcross_slide = document.getElementById? document.getElementById("WOWtest2") : document.all.WOWtest2;
WOWcross_slide2 = document.getElementById? document.getElementById("WOWtest3") : document.all.WOWtest3;
WOWcross_slide.innerHTML = WOWcross_slide2.innerHTML = WOWstrSlideContents;
// bug: Firefox reports wrong .offsetWidth initially (it takes it a bit to calculate it) - so we use a different method
// WOWactualwidth = document.all ? WOWcross_slide.offsetWidth : document.getElementById("WOWtest2").offsetWidth;
WOWactualwidth = iTotalWidths + 10*WOWiSlides;
WOWcross_slide2.style.left = WOWactualwidth + "px";
}
else if (document.layers){
WOWns_slide=document.ns_slidemenu.document.ns_slidemenu2;
WOWns_slide2=document.ns_slidemenu.document.ns_slidemenu3;
WOWns_slide.document.write(WOWstrSlideContents);
WOWns_slide.document.close();
WOWactualwidth=WOWns_slide.document.width;
WOWns_slide2.left=WOWactualwidth;
WOWns_slide2.document.write(WOWstrSlideContents);
WOWns_slide2.document.close();
}
// alert("WOWactualwidth: " + WOWactualwidth + "; slides: " + WOWiSlides + "; sum of widths: " + iTotalWidths + "; widths: " + strWidths);
// alert("try2: WOWactualwidth: " + WOWcross_slide.offsetWidth);
// compute the distance between each image (this is slightly off)
// var fDistanceBetweenImages = (WOWactualwidth - iTotalWidths)/WOWiSlides;
// compute the mid position of each slide
var fSpot = 0;
var strWidths = "";
var i;
for (i = 0; i < WOWiSlides; i++) {
WOWarraySlideCenters[i] = Math.round(fSpot + WOWarraySlideWidths[i]/2);
fSpot += WOWarraySlideWidths[i] + 10;
strWidths += WOWarraySlideWidths[i] + ":" + WOWarraySlideCenters[i] + " ";
}
// alert(strWidths + ' | ' + WOWiSlides + ' ' + iTotalWidths + ' | ' + WOWarrayRawData.length + ' ' + WOWstrSlideContents);
// use timer to start slides moving
lefttime=setInterval("WOWmoveSlides()",30);
}
function WOWAddOnload()
{
if(window.addEventListener) window.addEventListener('load', WOWfillup, false);
else if(window.attachEvent) window.attachEvent('onload', WOWfillup);
else window.onload = WOWfillup;
}
// put self into calling chain
WOWAddOnload()
// converts a number up to 255 to a two-digit hex representation
function WOWtoHex(iValue) {
var strHex = "0123456789ABCDEF";
return String(strHex.charAt(Math.floor(iValue / 16))) + String(strHex.charAt(iValue % 16));
}
// low level: simply sets slide 1 or 2 so that its iPosition'th part is at the left of the slider area
function WOWsetSlide(iSlide, iPosition) {
// determine the slide
var slide = WOWiedom ? (iSlide == 1 ? WOWcross_slide : WOWcross_slide2) : (iSlide == 1 ? WOWns_slide : WOWns_slide2);
// put the new position in
if (WOWiedom) slide.style.left = -iPosition + "px"; else slide.left = -iPosition;
}
// sets the two slides to the indicated position
function WOWsetPosition(iPosition) {
// the first slide goes at the position
WOWsetSlide(1, iPosition);
// the second slide goes after it if necessary, or else before
WOWsetSlide(2, iPosition + (WOWactualwidth - iPosition >= WOWiWidgetWidth ? WOWactualwidth : -WOWactualwidth));
}
// returns the x position associated with the given step, using ramping
function WOWStepToX(WOWiStep)
{
// determine which slides we are between
var bBeforeSlide = (WOWiStep % WOWarraySpeedRamp.length) < (WOWarraySpeedRamp.length / 2);
var iSlide1 = Math.floor(WOWiStep / WOWarraySpeedRamp.length);
var iSlide2 = (bBeforeSlide ? iSlide1 - 1 + WOWiSlides : iSlide1 + 1) % WOWiSlides;
// compute the distance between the slides, taking into account that iSlide1 may be before or after iSlide2 AND they may be on opposing ends of the slider
var iDistance = Math.min(Math.abs(WOWarraySlideCenters[iSlide1] - WOWarraySlideCenters[iSlide2]),
Math.min((WOWarraySlideCenters[iSlide1] - WOWarraySlideCenters[iSlide2] + WOWactualwidth) % WOWactualwidth,
(WOWarraySlideCenters[iSlide2] - WOWarraySlideCenters[iSlide1] + WOWactualwidth) % WOWactualwidth));
// return the x position
return Math.round(WOWarraySlideCenters[iSlide1] + iDistance*WOWarraySpeedRamp[WOWiStep % WOWarraySpeedRamp.length]);
}
// returns the slide nearest to the given step - this can be off if a wide slide is near a thin one
function WOWStepToSlide(WOWiStep)
{
// step 0 .. WOWarraySpeedRamp.length - 1 is slide 0, etc.
return Math.floor(WOWiStep / WOWarraySpeedRamp.length);
}
// returns the distance as a percentage to the nearest slide (0 means on top of it and 1 means between slides) - this can be off if a wide slide is near a thin one
function WOWDistanceToSlide(WOWiStep)
{
return Math.abs(WOWarraySpeedRamp[WOWiStep % WOWarraySpeedRamp.length]*2.0);
}
var WOWiSlideShowing = -1; // this causes the first slide to roll in immediately
var WOWbSuspended = false;
var WOWiPausing = 0;
var WOWiPauseSuppression = 0; // number of next steps to not pause during
var WOWiStep = 0;
function WOWmoveSlides() {
// do nothing if suspended
if (WOWbSuspended) return;
// reduce pause suppression if it's on
if (WOWiPauseSuppression > 0) WOWiPauseSuppression--;
// countdown timer for when paused on an image
if (WOWiPausing > 0) {
WOWiPausing--;
return;
}
// do nothing if not supposed to move
if (!WOWiMoveDirection) return;
// advance the step
var iTotalSteps = WOWiSlides*WOWarraySpeedRamp.length;
WOWiStep = (WOWiStep + WOWiMoveDirection + iTotalSteps) % iTotalSteps;
// if this puts us at a slide, pause unless pause suppression is in place
if (WOWDistanceToSlide(WOWiStep) == 0 && WOWiPauseSuppression == 0) WOWiPausing = WOWiPause;
// set the new position
WOWsetPosition((WOWStepToX(WOWiStep) - WOWiWidgetWidth/2) % WOWactualwidth);
// see if the slide has changed
if (WOWStepToSlide(WOWiStep) != WOWiSlideShowing) {
// set the new slide
WOWiSlideShowing = WOWStepToSlide(WOWiStep);
// shorten titles initially
var strTitle = WOWarraySlideTitles[WOWiSlideShowing];
while (strTitle.length > WOWiTitleMaxShowingLength) strTitle = strTitle.replace(/ [^ ]*( ...)?$/," ...");
// put the possibly shortened title in place
document.getElementById("WOWTitle").innerHTML = strTitle;
// if the title is too long, truncate it (20 is used for the height because the type is set at 16 pt below
while (document.getElementById("WOWTitle").offsetWidth > WOWiWidgetWidth || document.getElementById("WOWTitle").offsetHeight > 20)
document.getElementById("WOWTitle").innerHTML = document.getElementById("WOWTitle").innerHTML.replace(/ [^ ]*( ...)?$/," ...");
}
// adjust the title color
var iIntensity = Math.round(WOWDistanceToSlide(WOWiStep)*255);
document.getElementById("WOWTitle").style.color = "#" + WOWtoHex(iIntensity) + WOWtoHex(iIntensity)+ WOWtoHex(iIntensity);
}
function WOWsetSpeed(iSpeedNew)
{
WOWiMoveDirection = iSpeedNew;
WOWiPausing = 0;
if (iSpeedNew) WOWiPauseSuppression = Math.round(WOWarraySpeedRamp.length/3);
}
// write out material for the area
if (WOWiedom||document.layers){
with (document){
write('
| Newest Arrivals |
| |
')
if (WOWiedom){
write('')
write(' '); //
write(' ')
write(' ')
write(' ')
}
else if (document.layers){
write('')
write(''); // onMouseover="copyspeed=0" onMouseout="copyspeed=WOWslidespeed"
write(''); // onMouseover="copyspeed=0" onMouseout="copyspeed=WOWslidespeed"
write('')
}
write(' |
| ');
write('    |
')
write('
')
}
}