function topproductideasInitLibrary() {      // Begin library code wrapper. Goes all the way to the bottom of the file
if (window.goN2LibMon) { goN2LibMon.beginLoad('topproductideas','topproductideasLibs'); }
var tpifwOutputDiv = 'tpiilhw-output';
var tpiIlhwDULock = 1;
var tpiIsIE = 0;
var tpiEdgeLock = 0;
var tpiTimeoutId;
var tpiLoadingImage;
var tpiCornerLeftSelectedImage;
var tpiCornerLeftNotSelectedImage;
var tpiCornerLeftHoverImage;
var tpiCornerRightSelectedImage;
var tpiCornerRightNotSelectedImage;
var tpiCornerRightHoverImage;
var tpiButtonLeftButton = new Image();
var tpiButtonLeftDimButtonImage = new Image();
var tpiButtonLeftPressedButtonImage = new Image();
var tpiButtonLeftCurrentDisplayed = 'dimmed';
var tpiButtonRightButton = new Image();
var tpiButtonRightDimButtonImage = new Image();
var tpiButtonRightPressedButtonImage = new Image();
var tpiButtonRightCurrentDisplayed = 'default';
var tpiStep;
var tpiStripLeftMostElement = 0;
var tpiStripRightMostElement = -10000;
var tpiStripSlideTimer;
var tpiCurrentSelectedTab = 1;
var tpiLastSliceNumber;
var tpiCurrentOnHoverTab = 0;
var tpiAnimateSpeed = 150; // Higher Number = Faster Animation
var tpifX = null; // Final x position
var tpicX = null; // Current x position
var tpidX = null;
var tpiStepX = null;
window.tpiInitGlobals = function(animationStep,crp) {
tpiStep = animationStep;
tpiIlhwDULock = 0;
crp = crp;
}
window.tpiSetTotalNumberOfSlices = function(tpiTotalSoS) {
tpiLastSliceNumber = tpiTotalSoS;
}
window.tpiSetLeftButtonImages = function(tpiBtn, tpiDim, tpiPress) {
tpiButtonLeftButton.src = tpiBtn;
tpiButtonLeftDimButtonImage.src = tpiDim;
tpiButtonLeftPressedButtonImage.src = tpiPress;
}
window.tpiSetRightButtonImages = function(tpiBtn, tpiDim, tpiPress) {
tpiButtonRightButton.src = tpiBtn;
tpiButtonRightDimButtonImage.src = tpiDim;
tpiButtonRightPressedButtonImage.src = tpiPress;
}
window.tpiSetLeftCornerImages = function(tpiSelect, tpiNotSelect, tpiHover) {
tpiCornerLeftSelectedImage = tpiSelect;
tpiCornerLeftNotSelectedImage = tpiNotSelect;
tpiCornerLeftHoverImage = tpiHover;
}
window.tpiSetRightCornerImages = function(tpiSelect, tpiNotSelect, tpiHover) {
tpiCornerRightSelectedImage = tpiSelect;
tpiCornerRightNotSelectedImage = tpiNotSelect;
tpiCornerRightHoverImage = tpiHover;
}
window.tpiSetGeneralImages = function(tpiLoading) {
tpiLoadingImage = tpiLoading;
}
window.tpifwDelayedDU = function( e, ASIN, sr, sn, sh, crp, plu, plt, no, index ) {
if (goN2U.expDivProcessing) return;
if (tpiIlhwDULock) return;
if(!e) e=window.event;
if(e.fromElement){
tnRefObj = e.fromElement;
tnRefObj = document.getElementById('tpiilhwref_' + index);
tpiIsIE = 1;
}
if(e.target){
tnRefObj = e.target;
}
if(!tnRefObj) return;
tpiDUObj = new tpiCreateTOObj(tnRefObj.id, ASIN, sr, sn, sh, crp, plu, plt, no, index);
tpiTimeoutId = setTimeout("tpiDUObj.tpifwRequestDU()" , 200 );
}
window.tpifwDelayDUClear = function() {
if(!tpiTimeoutId) return;
clearTimeout( tpiTimeoutId );
tpiTimeoutId = undefined;
}
window.tpiClearEdgeLock = function () {
tpiEdgeLock = 0;
}
window.tpiCreateTOObj = function(tnRefObjId, ASIN, sr, sn, sh, crp, plu, plt, no, index){
this.tnRefObjId = tnRefObjId;
this.ASIN = ASIN;
this.sr = sr;
this.sn = sn;
this.sh = sh;
this.crp = crp;
this.plu = plu;
this.plt = plt;
this.no = no;
this.index = index;
this.tpifwRequestDU = function() {
if (goN2U.expDivProcessing) return;
if (tpiIlhwDULock) return;
if(!tnRefObjId) return;
var tnRefObj = document.getElementById(this.tnRefObjId);
if(!tnRefObj) return;
var tnLoadCnt = document.getElementById('tpiilhwimage_' + this.index);
var edgeOffset = tpiGetEdgeOffset( tnRefObj );
if(edgeOffset[0] && tpiEdgeLock) return;
if(edgeOffset[1] == 'hidden') return;
if(edgeOffset[0]){
tpiEdgeLock = 1;
setTimeout('tpiClearEdgeLock()', 1000);
tpiAdjustIlhwX(tnRefObj);
}
var loadingMsg =  tpiIlhwLoadingMsg( tnLoadCnt );
var oDUTPI;
oDUTPI = new N2DynUpObject('goDUTPIFWROpen');
oDUTPI.setHandler('/gp/du/tpiw-update-handler', 'xd');
oDUTPI.setTargetElementID(tpifwOutputDiv);
oDUTPI.newRequestsCancelExisting(1);
oDUTPI.setLoadingMessage( loadingMsg );
var params = {};
params.isDynamicUpdate = 1;
params.cacheResponses = 1;
params.ASIN = this.ASIN;
params.sr = this.sr;
params.sn = this.sn;
params.sh = this.sh;
params.crp = this.crp;
params.plu = this.plu;
params.plt = this.plt;
params.no = this.no;
params.index = this.index;
tpiMoveIlhw( tnRefObj );
oDUTPI.requestUpdate('ips', null, null, params);
document.getElementById('tpianbmainstrip').style.zoom = '1';
document.getElementById(tpifwOutputDiv).style.visibility = "visible";
document.getElementById('tpianbmainstrip').style.zoom = '0';
oDUTPI.onRequestSuccess = function (aHTML, aJSFunctions, nStatus, sRequestID) {
document.getElementById('tpianbmainstrip').style.zoom = '1';
tpiMoveIlhw( tnRefObj );
oDUTPI._onRequestSuccess(aHTML, aJSFunctions, nStatus, sRequestID);
document.getElementById('tpianbmainstrip').style.zoom = '0';
}
}
}
window.tpifwForceClose = function(){
document.getElementById('tpianbmainstrip').style.zoom = '1';
document.getElementById('tpiilhw-output').style.visibility = "hidden";
document.getElementById('tpianbmainstrip').style.zoom = '0';
}
window.tpiMoveIlhw = function( tpiIlhwRefObj ){
var tpiilhwRef = tpiGetAbsolutePos( tpiIlhwRefObj );
tpiilhwRef[1] = tpiilhwRef[1] - (tpiIsIE ? 21 : 21);
tpiilhwRef[0] = tpiilhwRef[0] - (tpiIsIE ? 61 : 59);
document.getElementById(tpifwOutputDiv).style.top = tpiilhwRef[1] + 'px';
document.getElementById(tpifwOutputDiv).style.left = tpiilhwRef[0] + 'px';
}
window.tpiIlhwLoadingMsg = function( refObj ) {
return '<div class="tpiilhwimage"><img src="' + refObj.src + '" border="0" /><br /><br />' + tpiLoadingImage + '</div>';
}
window.tpiAdjustIlhwX = function( tpiRefObj ) {
var edgeOffset = tpiGetEdgeOffset( tpiRefObj );
if(edgeOffset[0]){
moveAnimateStrip( edgeOffset[1] , edgeOffset[2]);
}
}
window.tpiIlhwOnMouseOut = function(e) {
if(!e) e=window.event;
if(!e.relatedTarget && e.toElement)
{
e.relatedTarget=e.toElement;
}
if(!e.relatedTarget){
tpifwForceClose();
return;
}
var isChild = tpiIsChildOf(tpifwOutputDiv, e.relatedTarget);
if(!isChild) {
tpifwForceClose();
}
}
window.tpiInitMouseEvents = function() {
element = document.getElementById(tpifwOutputDiv);
if(element.addEventListener) {
element.addEventListener("mouseout", tpiIlhwOnMouseOut, false);
}
else if(element.attachEvent) {
element.attachEvent("onmouseout", tpiIlhwOnMouseOut);
}
}
window.tpiIsChildOf = function(oId, oN) {
var oCN = oN;
if(oN && oN.id == oId) return 1;
while( oCN.tagName != "BODY" ){
oCN = oCN.offsetParent;
if(oCN && oCN.id == oId) return 1;
}
return 0;
}
window.tpiGetEdgeOffset = function( tpiRefObj ) {
var tpiFrame = document.getElementById('tpianbcentercontent');
var tpiFrameOffset = tpiGetAbsolutePos( tpiFrame );
var tpiFrameLeftBound = tpiFrameOffset[0];
var tpiFrameRightBound = tpiFrameLeftBound + tpiFrame.offsetWidth;
var tpiRefObjOffset = tpiGetAbsolutePos( tpiRefObj );
var tpiRefObjLeftBound = tpiRefObjOffset[0];
var tpiRefObjRightBound = tpiRefObjLeftBound + tpiRefObj.offsetWidth;
if( (tpiRefObjRightBound < tpiFrameLeftBound) || (tpiRefObjLeftBound > tpiFrameRightBound) ){
return [0, 'hidden', 0];
}
var edgeMargin = 45;
if( tpiRefObjLeftBound - edgeMargin < tpiFrameLeftBound){
return [1, 'right', tpiFrameLeftBound - tpiRefObjLeftBound + edgeMargin];
}
if( tpiRefObjRightBound + edgeMargin > tpiFrameRightBound){
return [1, 'left', tpiRefObjRightBound - tpiFrameRightBound + edgeMargin];
}
return [0,undefined,0];
}
window.tpiGetAbsolutePos = function(oN) {
var oCN = oN;
var iL = 0;
var iT = 0;
while( oCN.tagName != "BODY" ){
iL += oCN.offsetLeft;
iT += oCN.offsetTop;
oCN = oCN.offsetParent;
}
return [iL,iT];
}
window.tpianbStopSlide = function() {
clearInterval(tpiStripSlideTimer);
updateANBButtons();
tpiIlhwDULock = 0;
}
window.tpianbLeftClicked = function() {
tpiIlhwDULock = 1;
clearInterval(tpiStripSlideTimer);
tpiStripSlideTimer = setInterval('updateANBButtons("left")', 15);
}
window.tpianbRightClicked = function() {
tpiIlhwDULock = 1;
clearInterval(tpiStripSlideTimer);
tpiStripSlideTimer = setInterval('updateANBButtons("right")', 15);
}
window.tpianbTabsClicked = function(tabClicked) {
clearInterval(tpiStripSlideTimer);
changeTabs(tabClicked);
}
window.tpianbTabsOnHover = function(tabOnHover) {
if (tabOnHover == tpiCurrentSelectedTab) return;
document.getElementById('tpianbmainstrip').style.zoom = '1';
tpiCurrentOnHoverTab = tabOnHover;
var oldTabHoverObject = goN2U.getElement('tpianbsostab-'+tpiCurrentOnHoverTab);
if (oldTabHoverObject.className == 'tpianbsosmiddletab') oldTabHoverObject.className = 'tpianbsosmiddletabhover';
else oldTabHoverObject.className = 'tpianbsostabhover';
if (tpiCurrentOnHoverTab == 1) goN2U.getElement('tpisanbsosleftcorner').src = tpiCornerLeftHoverImage;
else if (tpiCurrentOnHoverTab == tpiLastSliceNumber) goN2U.getElement('tpisanbsosrightcorner').src = tpiCornerRightHoverImage;
document.getElementById('tpianbmainstrip').style.zoom = '0';
}
window.tpianbTabsNotHover = function(){
if (tpiCurrentOnHoverTab == tpiCurrentSelectedTab || tpiCurrentOnHoverTab == 0) return;
document.getElementById('tpianbmainstrip').style.zoom = '1';
var oldTabHoverObject = goN2U.getElement('tpianbsostab-'+tpiCurrentOnHoverTab);
if (oldTabHoverObject.className == 'tpianbsosmiddletabhover') oldTabHoverObject.className = 'tpianbsosmiddletab';
else oldTabHoverObject.className = 'tpianbsostab';
if (tpiCurrentOnHoverTab == 1) goN2U.getElement('tpisanbsosleftcorner').src = tpiCornerLeftNotSelectedImage;
else if (tpiCurrentOnHoverTab == tpiLastSliceNumber) goN2U.getElement('tpisanbsosrightcorner').src = tpiCornerRightNotSelectedImage;
tpiCurrentOnHoverTab = 0;
document.getElementById('tpianbmainstrip').style.zoom = '0';
}
window.updateANBButtons = function(direction) {
if (goN2U.getElement('tpianbsliceofselection-1'))
tpiStripLeftMostElement = - (goN2U.getElement('tpianbsliceofselection-1').offsetLeft + goN2U.getElementWidth('tpianbsliceofselection-1'));
if (goN2U.getElement('tpianbstripend') && goN2U.getElement('tpianbcentercontent'))
tpiStripRightMostElement = goN2U.getElementWidth('tpianbcentercontent') - goN2U.getElement('tpianbstripend').offsetLeft;
var currentLeft = goN2U.getElement('tpianbstripcontainer').offsetLeft;
var newLeft;
tpifwForceClose();
if (direction == 'left') {
if (currentLeft >= tpiStripLeftMostElement) {
clearInterval(tpiStripSlideTimer);
tpiIlhwDULock = 0;
} else {
newLeft = currentLeft + tpiStep;
goN2U.getElement('tpianbstripcontainer').style.left = newLeft+"px";
var tpiCurrentSelectedTabLeft = - goN2U.getElement('tpianbsliceofselection-'+tpiCurrentSelectedTab).offsetLeft;
if (newLeft > tpiCurrentSelectedTabLeft) {
if (tpiCurrentSelectedTab > 1) {
var newSelectedTab = tpiCurrentSelectedTab - 1;
changeTabs(newSelectedTab);
}
}
}
} else if (direction == 'right') {
if (currentLeft <= tpiStripRightMostElement) {
clearInterval(tpiStripSlideTimer);
tpiIlhwDULock = 0;
} else {
newLeft = currentLeft - tpiStep;
goN2U.getElement('tpianbstripcontainer').style.left = newLeft+"px";
if (tpiCurrentSelectedTab < tpiLastSliceNumber) {
var nextSelectedTab = tpiCurrentSelectedTab + 1;
var nextSelectedTabLeft = - goN2U.getElement('tpianbsliceofselection-'+nextSelectedTab).offsetLeft;
if (newLeft < nextSelectedTabLeft) {
var newSelectedTab = tpiCurrentSelectedTab + 1;
changeTabs(newSelectedTab);
}
}
}
} else if (direction == 'both') {
var tpiCurrentSelectedTabLeft = - goN2U.getElement('tpianbsliceofselection-'+tpiCurrentSelectedTab).offsetLeft;
if (tpiCurrentSelectedTab < tpiLastSliceNumber) {
var nextSelectedTab = tpiCurrentSelectedTab + 1;
var nextSelectedTabLeft = - goN2U.getElement('tpianbsliceofselection-'+nextSelectedTab).offsetLeft;
if (goN2U.getElement('tpianbstripcontainer').offsetLeft < nextSelectedTabLeft) {
var newSelectedTab = tpiCurrentSelectedTab + 1;
changeTabs(newSelectedTab);
}
} else if (goN2U.getElement('tpianbstripcontainer').offsetLeft > tpiCurrentSelectedTabLeft) {
if (tpiCurrentSelectedTab > 1) {
var newSelectedTab = tpiCurrentSelectedTab - 1;
changeTabs(newSelectedTab);
}
}
}
var parent = goN2U.getElement('tpianbleftcontent');
if (goN2U.getElement('tpianbstripcontainer').offsetLeft >= tpiStripLeftMostElement) {
if (tpiButtonLeftCurrentDisplayed != 'dimmed' && tpiButtonLeftDimButtonImage.complete) {
parent.innerHTML = '<img src="'+tpiButtonLeftDimButtonImage.src+'">';
tpiButtonLeftCurrentDisplayed = 'dimmed';
}
} else if (direction == 'left') {
if (tpiButtonLeftCurrentDisplayed != 'pressed' && tpiButtonLeftPressedButtonImage.complete) {
parent.innerHTML = '<img src="'+tpiButtonLeftPressedButtonImage.src+'">';
tpiButtonLeftCurrentDisplayed = 'pressed';
}
} else {
if (tpiButtonLeftCurrentDisplayed != 'default' && tpiButtonLeftButton.complete) {
parent.innerHTML = '<img src="'+tpiButtonLeftButton.src+'">';
tpiButtonLeftCurrentDisplayed = 'default';
}
}
parent = goN2U.getElement('tpianbrightcontent');
if (goN2U.getElement('tpianbstripcontainer').offsetLeft <= tpiStripRightMostElement) {
if (tpiButtonRightCurrentDisplayed != 'dimmed' && tpiButtonRightDimButtonImage.complete) {
parent.innerHTML = '<img src="'+tpiButtonRightDimButtonImage.src+'">';
tpiButtonRightCurrentDisplayed = 'dimmed';
}
} else if (direction == 'right') {
if (tpiButtonRightCurrentDisplayed != 'pressed' && tpiButtonRightPressedButtonImage.complete) {
parent.innerHTML = '<img src="'+tpiButtonRightPressedButtonImage.src+'">';
tpiButtonRightCurrentDisplayed = 'pressed';
}
} else {
if (tpiButtonRightCurrentDisplayed != 'default' && tpiButtonRightButton.complete) {
parent.innerHTML = '<img src="'+tpiButtonRightButton.src+'">';
tpiButtonRightCurrentDisplayed = 'default';
}
}
}
window.moveAnimateStrip = function(direction,distance) {
document.getElementById('tpianbmainstrip').style.zoom = '0';
tpicX = goN2U.getElement('tpianbstripcontainer').offsetLeft;
if (direction == 'left') tpifX = tpicX - distance;
else if (direction == 'right') tpifX = tpicX + distance;
tpidX = Math.abs(tpifX-tpicX);
if (tpicX < tpifX) tpiStepX = tpiAnimateSpeed;
else if (tpicX > tpifX) tpiStepX = - tpiAnimateSpeed;
tpiIlhwDULock = 1;
tpifwForceClose();
animateStrip('both');
document.getElementById('tpianbmainstrip').style.zoom = '1';
}
window.initAnimateStrip = function(destObjectID) {
var object = goN2U.getElement(destObjectID);
tpifX = -(object.offsetLeft + goN2U.getElementWidth(destObjectID));
tpicX = goN2U.getElement('tpianbstripcontainer').offsetLeft;
tpidX = Math.abs(tpifX-tpicX);
if (tpicX < tpifX) tpiStepX = tpiAnimateSpeed;
else if (tpicX > tpifX) tpiStepX = - tpiAnimateSpeed;
tpiIlhwDULock = 1;
tpifwForceClose();
animateStrip('');
}
window.animateStrip = function(direction) {
document.getElementById('tpianbmainstrip').style.zoom = '1';
if (tpidX > tpiAnimateSpeed) {
goN2U.getElement('tpianbstripcontainer').style.left = Math.round(tpicX) + 'px';
tpicX = tpicX + tpiStepX;
tpidX = tpidX - Math.abs(tpiStepX);
setTimeout ('animateStrip('+direction+')',0);
} else {
goN2U.getElement('tpianbstripcontainer').style.left = tpifX + 'px';
updateANBButtons(direction);
tpiIlhwDULock = 0;
}
document.getElementById('tpianbmainstrip').style.zoom = '0';
return;
}
window.changeTabs = function(newSelectedTab) {
if (tpiCurrentSelectedTab) {
var oldTabObject = goN2U.getElement('tpianbsostab-'+tpiCurrentSelectedTab);
if (oldTabObject.className == 'tpianbsosmiddletabactive' || oldTabObject.className == 'tpianbsosmiddletabhover' || oldTabObject.className == 'tpianbsosmiddletab') oldTabObject.className = 'tpianbsosmiddletab';
else oldTabObject.className = 'tpianbsostab';
if (tpiCurrentSelectedTab == 1) goN2U.getElement('tpisanbsosleftcorner').src = tpiCornerLeftNotSelectedImage;
else if (tpiCurrentSelectedTab == tpiLastSliceNumber) goN2U.getElement('tpisanbsosrightcorner').src = tpiCornerRightNotSelectedImage;
if (tpiCurrentSelectedTab > 1)
goN2U.getElement('tpianbsostabdivider-'+tpiCurrentSelectedTab).className = 'tpianbsostabdivider';
var tpiCurrentSelectedTabNext = tpiCurrentSelectedTab + 1;
if (tpiCurrentSelectedTab < tpiLastSliceNumber)
goN2U.getElement('tpianbsostabdivider-'+tpiCurrentSelectedTabNext).className = 'tpianbsostabdivider';
}
var newTabObject = goN2U.getElement('tpianbsostab-'+newSelectedTab);
if (newTabObject.className == 'tpianbsosmiddletabhover' || newTabObject.className == 'tpianbsosmiddletab' || newTabObject.className == 'tpianbsosmiddletabactive') newTabObject.className = 'tpianbsosmiddletabactive';
else newTabObject.className = 'tpianbsostabactive';
tpiCurrentSelectedTab = newSelectedTab;
if (tpiCurrentSelectedTab == 1) goN2U.getElement('tpisanbsosleftcorner').src = tpiCornerLeftSelectedImage;
else if (tpiCurrentSelectedTab == tpiLastSliceNumber) goN2U.getElement('tpisanbsosrightcorner').src = tpiCornerRightSelectedImage;
if (tpiCurrentSelectedTab > 1) goN2U.getElement('tpianbsostabdivider-'+tpiCurrentSelectedTab).className = 'tpianbsosselectedtabdivider';
var tpiCurrentSelectedTabNext = tpiCurrentSelectedTab + 1;
if (tpiCurrentSelectedTab < tpiLastSliceNumber) goN2U.getElement('tpianbsostabdivider-'+tpiCurrentSelectedTabNext).className = 'tpianbsosselectedtabdivider';
}
window.realignThumbnailStrip = function() {
if ( goN2U.isIE() ) {
if ( goN2U.getElement('tpianbrightcontent') && goN2U.getElement('tpianbcentercontent') ) {
var leftOffsetRight = goN2U.getElementWidth('tpianbleftcontent') + goN2U.getElement('tpianbleftcontent').offsetLeft;
var gapLeftCenter = goN2U.getElement('tpianbcentercontent').offsetLeft - leftOffsetRight;
var centerOffsetRight = goN2U.getElementWidth('tpianbcentercontent') + goN2U.getElement('tpianbcentercontent').offsetLeft;
var gapCenterRight = goN2U.getElement('tpianbrightcontent').offsetLeft - centerOffsetRight;
var marginValue = (gapLeftCenter + gapCenterRight) / 2;
goN2U.getElement('tpianbcentercontent').style.marginLeft = marginValue;
goN2U.getElement('tpianbcentercontent').style.marginRight = marginValue;
}
if ( goN2U.getElement('tpitabs') && goN2U.getElement('tpisanbsosrightcornercontainer') ) {
var tabsWidth = goN2U.getElementWidth('tpitabs');
var rightCornerOffSet = goN2U.getElement('tpisanbsosrightcornercontainer').offsetLeft;
goN2U.getElement('tpisanbsosrightcornercontainer').style.right = ( rightCornerOffSet + goN2U.getElementWidth('tpisanbsosrightcornercontainer') ) - tabsWidth;
}
}
}
window.resizeWidget = function() {
realignThumbnailStrip();
updateANBButtons();
}
if (window.goN2LibMon) { goN2LibMon.endLoad('topproductideas'); }
} // END library code wrapper
n2RunIfLoaded("dynupdate", topproductideasInitLibrary, "topproductideas");