// Images we have photo's available for var bedPhotos = new Array(); bedPhotos['321p.jpg'] = true; bedPhotos['327000030p.jpg'] = true; bedPhotos['321000090p.jpg'] = true; bedPhotos['321000000p.jpg'] = true; bedPhotos['327000090p.jpg'] = true; bedPhotos['068p.jpg'] = true; bedPhotos['327000000p.jpg'] = true; bedPhotos['06800000p.jpg'] = true; bedPhotos['321000030p.jpg'] = true; bedPhotos['068000000p.jpg'] = true; bedPhotos['068000030p.jpg'] = true; bedPhotos['068000090p.jpg'] = true; bedPhotos['327p.jpg'] = true; // Movies we have flv's available for var bedFlvs = new Array(); // Map of Size Names var sizeNames = new Array(); sizeNames['E. King'] = 'EK'; sizeNames['Cal King'] = 'CK'; sizeNames['Queen'] = 'QU'; sizeNames['Std/Double'] = 'ST'; sizeNames['Twin'] = 'TW'; sizeNames['Twin Long'] = 'TL'; sizeNames['Dual King'] = 'DK'; // Default Values currentDisplay = 'Bed'; currentImage = 'ImageName'; var animateSteps=new Array(); var returnPiece = 0; var clipLoop = 0; var box = 7; var firstRun = true; var imgArray=new Array(); var imgLoading=new Array(); lastItem = 0; var AdviceMap = new Array(0,0,1,0,2,3,2); var checkImageTimeout = ''; function doneLoading(x) { imgArray.shift(); //alert(imgArray.length); if(imgArray.length == 0) { var LocalTimer = setTimeout("closeLoading()", 0); } } var img1 = new Image(); var img2 = new Image(); var img3 = new Image(); var img4 = new Image(); var img5 = new Image(); var img6 = new Image(); var img7 = new Image(); var img8 = new Image(); var img9 = new Image(); // Wrap our images in jquery $(function () { $(img1).load(function () {doneLoading(1);}).attr('src', getLayerImage(0)); $(img2).load(function () {doneLoading(2);}).attr('src', getLayerImage(1)); $(img3).load(function () {doneLoading(3);}).attr('src', getLayerImage(2)); $(img4).load(function () {doneLoading(4);}).attr('src', getLayerImage(3)); $(img5).load(function () {doneLoading(5);}).attr('src', getLayerImage(4)); $(img6).load(function () {doneLoading(6);}).attr('src', getLayerImage(5)); $(img7).load(function () {doneLoading(7);}).attr('src', getLayerImage(6)); $(img8).load(function () {doneLoading(8);}).attr('src', getLayerImage(7)); $(img9).load(function () {doneLoading(9);}).attr('src', getLayerImage(8)); }); // Used to open firmness advisor function openmypage(url){ urlItems = '/firmness_advisor/index.htm?submittype=ajax&Deluxe='; var curName = document.getElementById('SelectAMattress').options[document.getElementById('SelectAMattress').selectedIndex].value.split("|")[0]; if (curName.match("Deluxe")) { urlItems = urlItems + 'True'; } else { urlItems = urlItems + 'False'; } urlItems = urlItems + '&Mattress=' + document.getElementById('SelectAMattress').options[document.getElementById('SelectAMattress').selectedIndex].value.split("|")[2]; urlItems = urlItems + '&SizeCode=' + sizeNames[document.getElementById('SubmitSize').value]; urlItems = urlItems + '&Type=Latex'; addDebug(urlItems); ajaxwin=dhtmlwindow.open("firmadvicediv", "ajax", urlItems, "Firmness Advisor", "width=750px,height=550px,left=300px,top=100px,resize=0,scrolling=1"); ajaxwin.moveTo('middle', 'middle'); } // Get Firmness from DHTML Window function loadFirmnessResult(LoadType) { if(LoadType != 'goBack') { var names = ["SubmitType","NoMattress","mattress","SizeCode","Side1Name","Height1","lbs1","Sex1","SideBackFront1","NormallyLike1","Natural1","Side2Name","Height2","lbs2","Sex2","SideBackFront2","NormallyLike2","Natural2","Submitted","FormName","Twin"]; url = '/firmness_advisor/index.htm?&DeLuXe='; var curName = document.getElementById('SelectAMattress').options[document.getElementById('SelectAMattress').selectedIndex].value.split("|")[0]; if (curName.match("Deluxe")) { url = url + 'True'; } else { url = url + 'False'; } for ( var i in names ) { var selectObject = document.getElementById(names[i]); if (selectObject != null) { if(selectObject.type == "select") { var selIndex = selectObject.selectedIndex; var selValue = selectObject.options[selIndex].value; } else { selValue = selectObject.value; } var url = url + "&" + names[i] + "=" + escape(selValue); } } } else { url = '/firmness_advisor/index.htm?&DeLuXe='; var curName = document.getElementById('SelectAMattress').options[document.getElementById('SelectAMattress').selectedIndex].value.split("|")[0]; if (curName.match("Deluxe")) { url = url + 'True'; } else { url = url + 'False'; } url = url + '&Mattress=' + document.getElementById('SelectAMattress').options[document.getElementById('SelectAMattress').selectedIndex].value.split("|")[2]; url = url + '&SizeCode=' + sizeNames[document.getElementById('SubmitSize').value]; url = url + '&Type=Latex'; } ajaxwin.load('ajax',url, 'Firm Advice Results'); return false; } function getLayerImage(x) { if(document.BedOptionsBasic.ImageName.value.charAt(x) == '0') { if(x==8) { return('https://www.flobeds.com/bed-images-base/pixel.gif'); } } newName = '000eeee0000.png'; if(x==3) { newName = newName.substr(0,9) + document.BedOptionsBasic.ImageName.value.charAt(9) + document.BedOptionsBasic.ImageName.value.charAt(10); //} else { // newName = '000eeee00.png'; } newName = newName.substr(0,x) + document.BedOptionsBasic.ImageName.value.charAt(x) + newName.substr(x+1); //newName = newName.replace("eeee", "0000"); if(x==8) { return('https://www.flobeds.com/showimage.lasso?nodecal=true&obackground=true&isize=spaceship&image=' + newName); } else if(x==5) { if(document.BedOptionsBasic.ImageName.value.charAt(7) == 0) { newName = newName.replace("e/g", "0"); newName = newName.replace("00.png", "w.png"); if(document.getElementById('SelectAMattress')) { bedName = document.getElementById('SelectAMattress').options[document.getElementById('SelectAMattress').selectedIndex].value.split("|")[0].split(" - ")[0]; if(bedName.match('Deluxe')) { newName = newName.replace(document.BedOptionsBasic.ImageName.value.charAt(x),'d'); } newName = newName.replace(/e/g, "0"); } return('https://www.flobeds.com/bed-images-base/' + newName); } else { return('https://www.flobeds.com/showimage.lasso?nodecal=true&HideFirmnessNames=true&nobackground=true&isize=spaceship&image=' + newName); } } else { return('https://www.flobeds.com/showimage.lasso?nodecal=true&HideFirmnessNames=true&nobackground=true&isize=spaceship&image=' + newName); } } // Switch from photo to illustration and back function showImage (imageType) { currentImage = imageType; if(imageType == "PhotoName" && bedPhotos[document.getElementById('PhotoName').value]){ document.getElementById('image0').src = 'https://www.flobeds.com/bed-images-base/' + document.getElementById('PhotoName').value; } else { resetPiece(); } if(bedPhotos[document.getElementById('PhotoName').value]) { document.getElementById('showImageButton').style.display = 'block'; } else { document.getElementById('showImageButton').style.display = 'none'; } var curName = document.getElementById('SelectAMattress').options[document.getElementById('SelectAMattress').selectedIndex].value.split("|")[0]; if (curName.match("Deluxe")) { currentMap = 'Deluxe'; } else { currentMap = 'Regular'; } if(currentImage == "PhotoName" && bedPhotos[document.getElementById('PhotoName').value]) {currentMap = (currentMap + 'Photo');} if(currentMap.match('Regular') && curName.match('vZone')) {currentMap = 'Deluxe'}; if(document.getElementById('FoundationChoice').selectedIndex != 0) {currentMap = (currentMap + 'Foundation');} if(currentMap == 'DeluxePhotoFoundation' && curName.match('vZone')) {currentMap = 'VZonePhotoFoundation';} changeMap(currentMap); } // Show div if there is options for the foundation function ShowDivSpecial(theValue){ HideFoundation(); document.getElementById('Foundation' + theValue.split("|")[2]).style.display = "Block"; } // Hide all divs that are Foundation related function HideFoundation() { var FoundationDivs = document.getElementById('FoundationDivs').value.split("|"); for ( var i in FoundationDivs ) { document.getElementById(FoundationDivs[i]).style.display = "None"; } } // Show div if there is options for legs function ShowDivLeg(theValue){ HideSupport(); document.getElementById('Support' + theValue.split("|")[2]).style.display = "Block"; } // Hide all divs that are support related function HideSupport() { var SupportDivs = document.getElementById('SupportDivs').value.split("|"); for ( var i in SupportDivs ) { document.getElementById(SupportDivs[i]).style.display = "None"; } } // Change the image displayed function UpdateNameBasic(x){ FoundationCheckBox = 'Foundation' + (document.getElementById('FoundationChoice').value.split("|")[2]) + 'Check'; if(document.getElementById(FoundationCheckBox)) {if(document.getElementById(FoundationCheckBox).checked == true) {FoundationChoice = 2} else {FoundationChoice = 0};} else {FoundationChoice = 0} PhotoImageArray = [document.BedOptionsBasic.Topper.value, document.BedOptionsBasic.ComfortTopper.value, document.BedOptionsBasic.ZoneComfort.value, 0, 0, 0, 0, document.BedOptionsBasic.FoundationChoice.value.split("|")[1].split(",")[FoundationChoice], 0]; BedImageArray = [document.BedOptionsBasic.Topper.value, document.BedOptionsBasic.ComfortTopper.value, document.BedOptionsBasic.ZoneComfort.value, document.BedOptionsBasic.UpperCoreR.value, document.BedOptionsBasic.UpperCoreL.value, document.BedOptionsBasic.LowerCoreR.value, document.BedOptionsBasic.LowerCoreL.value, document.BedOptionsBasic.FoundationChoice.value.split("|")[1].split(",")[FoundationChoice], document.BedOptionsBasic.Legs.value.split("|")[1]]; var curName = document.getElementById('SelectAMattress').options[document.getElementById('SelectAMattress').selectedIndex].value.split("|")[0]; var curImageCode = document.getElementById('SelectAMattress').options[document.getElementById('SelectAMattress').selectedIndex].value.split("|")[1]; if (curName.match("Deluxe")) { BedImageArray.push(document.getElementById('DeluxeCoreL').options[document.getElementById('DeluxeCoreL').selectedIndex].value); BedImageArray.push(document.getElementById('DeluxeCoreR').options[document.getElementById('DeluxeCoreR').selectedIndex].value); } var BedImage=BedImageArray.join(""); var PhotoImage=PhotoImageArray.join(""); //document.getElementById('loading').style.display = 'Block'; document.getElementById('PhotoName').value = PhotoImage + 'p.jpg'; document.BedOptionsBasic.ImageName.value = BedImage; checkAdvise(); showImage(currentImage); describeBed(); } function closeLoading() { $("#loading").fadeOut("slow"); } // Gets item position within window function getPosition(e){ var left = 0; var top = 0; while (e.offsetParent){ left += e.offsetLeft; top += e.offsetTop; e = e.offsetParent; } left += e.offsetLeft; top += e.offsetTop; return {x:left, y:top}; } function addDebug(x) { document.getElementById('debug').innerHTML = x + '
' + document.getElementById('debug').innerHTML; } function checkDone(x) { addDebug(animateSteps); if(x) { var n = $("#"+x).queue(); if(n) { if(n.length != 0) { //alert('Stopping for ' + x); // This is the pause between steps 500 = half second, 1000 = one second checkImageTimeout = setTimeout ( "nextStep()", 50 ); addDebug('Waiting on ' + x); return(false); } } } addDebug('Complete: ' + x); return true; } function checkImagesDone() { if(imgLoading.length != 0) { addDebug('Wating on image array' + imgLoading); return(false); } else { return true; } for (i=0;i<=9;i++) { x = "image" + i; addDebug('Check Done:' + x); var n = $("#"+x).queue(); if(n) { if(n.length != 0) { //alert('Stopping for ' + x);\ addDebug('Waiting on ' + x); return(false); } } } return true; } // Do next job in queue function nextStep(x) { var currentTime = new Date(); if(x == 'Go' || document.getElementById('StepAuto').checked) { // Manual Run addDebug('Go at ' + currentTime); } else { return confirm('Next Step was called'); } //document.getElementById('debug').innerHTML = animateSteps; //document.getElementById('debug').style.display = 'block'; if(animateSteps.length < 3) { //document.getElementById('debug').style.display = 'none'; return; } //if(x != 'break') { alert('Pausing.');} var curItem = animateSteps.shift(); var curFunc = animateSteps.shift(); var curValu = animateSteps.shift(); addDebug('Next Step is trying to: ' + curFunc + ' on field: ' + curItem + ' with a value of: ' + curValu); if(checkDone(lastItem)){ lastItem = curItem; } else { animateSteps.unshift(curItem, curFunc, curValu); addDebug('waiting on ' + lastItem + '\r' + curItem + ' is next.'); return; } if(curFunc == 'left'|| curFunc == 'top') { addDebug('Start ' + curItem + ': ' + curFunc + '=' + curValu); eval('$(\'#'+ curItem + '\').animate({' + curFunc + ':\'+=' + curValu + '\'},1000, function(){addDebug(\'' + curItem + '\');nextStep()});'); } if(curFunc == 'waitImages') { if(checkImagesDone()) { nextStep(); } else { animateSteps.unshift(curItem, curFunc, curValu); return; } } if(curFunc == 'leftFast' || curFunc == 'topFast') { curFunc = curFunc.replace('Fast', ''); eval('$(\'#'+ curItem + '\').animate({' + curFunc + ':\'+=' + curValu + '\'},200, function(){nextStep()});'); } if(curFunc == 'leftMed' || curFunc == 'topMed') { curFunc = curFunc.replace('Med', ''); eval('$(\'#'+ curItem + '\').animate({' + curFunc + ':\'+=' + curValu + '\'},400, function(){nextStep()});'); } if(curFunc == 'z') { document.getElementById(curItem).style.zIndex = curValu; nextStep(); } if(curFunc == 'selectIndex') { document.getElementById(curItem).selectedIndex = curValu; nextStep(); } if(curFunc == 'src') { document.getElementById('spinner').style.display = 'block'; imgLoading.push(curItem); addDebug('$(\'#'+ curItem + '\').load(function(){checkImageArray();}).attr(\'src\', \'' + curValu + '\').error(function() {checkImageArray();});'); eval('$(\'#'+ curItem + '\').load(function(){checkImageArray()}).attr(\'src\', \'' + curValu + '\').error(function() {checkImageArray()});'); lastItem = 0; nextStep(); } if(curFunc == 'alert') { alert(curItem); lastItem = 0; nextStep(); } if(curFunc == 'reset') { resetPiece(); lastItem = 0; nextStep(); } if(curFunc == 'eval') { eval(curValu); lastItem = 0; nextStep(); } if(curFunc == 'show') { document.getElementById(curItem).style.display = 'none'; document.getElementById(curItem).style.visibility = 'visible'; eval('$(\'#'+ curItem + '\').fadeIn(\'slow\', function(){nextStep();});'); } if(curFunc == 'hide') { //alert('Hiding: ' + curItem); //eval('$(\'#'+ curItem + '\').fadeOut(\'slow\', function(){nextStep();});'); document.getElementById(curItem).style.visibility = 'hidden'; lastItem = 0; nextStep(); } } // Pause/Wait function function pausecomp(millis) { return; //alert("Pausing "); var date = new Date(); var curDate = null; do { curDate = new Date(); } while(curDate-date < millis); return; } var droppingBed = false; function dropBed(x,ModelIndex) { droppingBed = true; var zIndexList = new Array(10,9,8,7,6,5,4,3,2,1); animateSteps = new Array; var imageName = document.getElementById('ImageName').value; animateSteps.unshift('image0', 'hide', ''); for (i=0;i<=9;i++) { //$('#box' + i).clearQueue(); $('#box' + i).stop(); currentImage = document.getElementById('image' + i); currentBox = document.getElementById('box' + i); currentBox.style.zIndex = zIndexList[i]; currentBox.style.left = '0px'; if(x=='down') { currentBox.style.top = '-1000px'; animateSteps.unshift('box' + i, 'topMed', '1000'); //animateSteps.unshift('', 'alert', 'Pause'); } else { currentBox.style.top = '0px'; animateSteps.push('box' + i, 'topFast', '-1000'); } } if(x=='up'){ animateSteps.push('loading', 'show', ''); animateSteps.push('SelectAMattress', 'selectIndex', ModelIndex); animateSteps.push('', 'waitImages', ''); animateSteps.push('', 'eval', 'selectBed(1);'); animateSteps.push('', 'eval', 'dropBed(\'down\');'); animateSteps.push('image0', 'show', ''); } else { animateSteps.push('', 'eval', 'checkAdvise(\'Left\');'); animateSteps.push('', 'eval', 'checkAdvise(\'Right\');'); animateSteps.unshift('loading', 'hide', ''); animateSteps.push('image0', 'show', ''); } addDebug(animateSteps); nextStep(); //var LocalTimer = setTimeout("waitFor()", 200); document.getElementById('image0').src = 'https://www.flobeds.com/showimage.lasso?image=' + document.BedOptionsBasic.ImageName.value + '.png&isize=spaceship&FirmnessLabelOnly=true'; //document.getElementById('image0').src = 'https://www.flobeds.com/bed-images-base/labels/decal.png'; } function resetPiece(x) { var zIndexList = new Array(0,9,8,7,6,5,4,3,2,1); if(x==1) {animateSteps = new Array;}; var addSteps = new Array; for (i=1;i<=9;i++) { //$('#box' + i).clearQueue(); $('#box' + i).stop(); currentImage = document.getElementById('image' + i); currentBox = document.getElementById('box' + i); newImage = getLayerImage(i-1); if(newImage != currentImage.src) { addSteps.push('image' + i, 'src', newImage); } currentBox.style.zIndex = zIndexList[i]; currentBox.style.left = '0px'; currentBox.style.top = '0px'; currentBox.style.display = 'block'; } addSteps.push('', 'waitImages', ''); if(!droppingBed) { addSteps.push('loading', 'hide', ''); } animateSteps = addSteps.concat(animateSteps); addSteps.push('spinner', 'hide', ''); //var LocalTimer = setTimeout("waitFor()", 200); document.getElementById('image0').src = 'https://www.flobeds.com/showimage.lasso?image=' + document.BedOptionsBasic.ImageName.value + '.png&isize=spaceship&FirmnessLabelOnly=true'; document.getElementById('ComponentMovie').style.display = 'none'; //document.getElementById('image0').src = 'https://www.flobeds.com/bed-images-base/labels/decal.png'; nextStep(); } function popPiece(x) { document.getElementById('debug').innerHTML=''; var zIndexList = new Array(0,9,8,7,6,5,4,3,2,1); bedName = document.getElementById('SelectAMattress').options[document.getElementById('SelectAMattress').selectedIndex].value.split("|")[0].split(" - ")[0]; y = x; z = x; x--; var imageName = document.getElementById('ImageName').value; if(y == returnPiece) { var newName = getLayerImage(x); var reversePiece = true; returnPiece = 0; document.getElementById('ComponentMovie').style.display = 'none'; document.getElementById('box' + returnPiece).style.display = 'block'; document.getElementById('Text').style.display = 'none'; document.getElementById('Text2').style.display = 'none'; document.getElementById('Text3').style.display = 'block'; }else{ var origName = '000000000w.png'; var sideNameTemplate = ''; if(bedName.match('Deluxe')) { if(y==1) { z = 10; } if(y==2) { z = 1; } if(y==6) { z = 10; } if(y==7) { z = 9; } if(y==4) { z = 5; } if(y==5) { z = 6; } if(y==10) { z = 3; y=3; x=3; sideNameTemplate='X0';side2NameTemplate='0X';} if(y==11) { z = 4; y=3; x=2; sideNameTemplate='0X';side2NameTemplate='X0';} } else if(bedName.match('vZone')) { if(y==10) { z = 3; y=3; x=3; sideNameTemplate='X0';side2NameTemplate='0X';} if(y==11) { z = 4; y=3; x=2; sideNameTemplate='0X';side2NameTemplate='X0';} } else { z = y; } if(sideNameTemplate == '') { var newName = origName.substr(0,x) + imageName.charAt(x) + origName.substr(y); } else { var newName = origName.substr(0,9) + sideNameTemplate.replace('X', imageName.charAt(2)) + 'w.png'; var newName2 = origName.substr(0,9) + side2NameTemplate.replace('X', imageName.charAt(2)) + '.png'; animateSteps.push('image10', 'src', 'https://www.flobeds.com/bed-images-base/w/' + newName2); } bedName = document.getElementById('SelectAMattress').options[document.getElementById('SelectAMattress').selectedIndex].value.split("|")[0].split(" - ")[0]; if(bedName.match('Deluxe')) { if(y==4 || y==5 || y==6 || y==7 || y==10 || y==11) { newName = newName.replace(document.BedOptionsBasic.ImageName.value.charAt(x),document.BedOptionsBasic.ImageName.value.charAt(z)); addDebug("x: " + x + " y: " + y + " z: " + z + " newName: " + newName + " ImageName: " + document.BedOptionsBasic.ImageName.value); } } var flvName = newName.replace('.png', '.flv'); if(bedFlvs[flvName]) { if(bedName.match('Natural')) { animateSteps.push('ComponentMovieFrame', 'src', 'movie.html?video=' + flvName + '&natural=true'); } else { animateSteps.push('ComponentMovieFrame', 'src', 'movie.html?video=' + flvName); } //animateSteps.push('ComponentMovie', 'show', ''); animateSteps.push('ComponentMoviePlay', 'show', ''); } else { animateSteps.push('ComponentMoviePlay', 'hide', ''); } newName = 'https://www.flobeds.com/bed-images-base/w/' + newName; returnPiece = y; //resetPiece(); } boxId = ('box' + y); if(x%2==1 || x==11){ if(reversePiece != true){ animateSteps.push('image' + y, 'src', newName); animateSteps.push('', 'waitImages', ''); animateSteps.push('box' + y, 'left', '50'); animateSteps.push('box' + y, 'z', '20'); animateSteps.push('box' + y, 'top', '50'); //animateSteps.push('box' + y, 'left', '-50'); animateSteps.push('TabNavUL','hide', ''); animateSteps.push('ComponentInfo','show', ''); animateSteps.push('BedLayer','show', ''); animateSteps.push('BedLayerReturn','show', ''); //animateSteps.push('bedMoreInfo','hide', ''); if(bedFlvs[flvName]) { //animateSteps.push('box' + y,'hide', ''); } } else { animateSteps.push('box' + y,'show', ''); animateSteps.push('ComponentInfo','hide', ''); animateSteps.push('ComponentMoviePlay', 'hide', ''); animateSteps.push('BedLayer','hide', ''); animateSteps.push('BedLayerReturn','hide', ''); //animateSteps.push('bedMoreInfo','show', ''); animateSteps.push('TabNavUL','show', ''); animateSteps.push('box' + y, 'z', zIndexList[y]); animateSteps.push('box' + y, 'left', '-50'); animateSteps.push('box' + y, 'top', '-50'); //animateSteps.push('box' + y, 'left', '50'); animateSteps.push('image' + y, 'src', newName); } } else { if(reversePiece != true){ animateSteps.push('image' + y, 'src', newName); animateSteps.push('', 'waitImages', ''); //animateSteps.push('box' + y, 'left', '-50'); animateSteps.push('box' + y, 'z', '20'); animateSteps.push('box' + y, 'top', '50'); //animateSteps.push('box' + y, 'left', '50'); animateSteps.push('ComponentInfo','show', ''); animateSteps.push('BedLayer','show', ''); animateSteps.push('BedLayerReturn','show', ''); //animateSteps.push('bedMoreInfo','hide', ''); animateSteps.push('TabNavUL','hide', ''); if(bedFlvs[flvName]) { //animateSteps.push('box' + y,'hide', ''); } } else { animateSteps.push('box' + y,'show', ''); animateSteps.push('ComponentInfo','hide', ''); animateSteps.push('ComponentMoviePlay', 'hide', ''); animateSteps.push('BedLayer','hide', ''); animateSteps.push('BedLayerReturn','hide', ''); //animateSteps.push('bedMoreInfo','show', ''); animateSteps.push('TabNavUL','show', ''); animateSteps.push('box' + y, 'z', zIndexList[y]); //animateSteps.push('box' + y, 'left', '-50'); animateSteps.push('box' + y, 'top', '-50'); //animateSteps.push('box' + y, 'left', '50'); animateSteps.push('image' + y, 'src', newName); animateSteps.push('','reset', ''); } } if(reversePiece == true) { animateSteps.push('image10', 'src', 'https://www.flobeds.com/bed-images-base/pixel.gif'); } document.getElementById('Text').innerHTML = ''; document.getElementById('Text2').innerHTML = ''; document.getElementById('Text3').innerHTML = ''; bedName = document.getElementById('SelectAMattress').options[document.getElementById('SelectAMattress').selectedIndex].value.split("|")[0].split(" - ")[0]; if(bedName.match('Deluxe') || bedName.match('vZone')) { if(y==1) { document.getElementById('Text').innerHTML = '' + document.getElementById('CoverName').value + ''; document.getElementById('Text2').innerHTML = document.getElementById('CoverDescription1').value document.getElementById('Text3').innerHTML = document.getElementById('CoverDescription2').value } if(y==2) { document.getElementById('Text').innerHTML = 'Convolute'; if(bedName.match('Natural')) { document.getElementById('Text2').innerHTML = document.getElementById('ConvoluteNaturalDescription1').value; document.getElementById('Text3').innerHTML = document.getElementById('ConvoluteNaturalDescription2').value; } else { document.getElementById('Text2').innerHTML = document.getElementById('ConvoluteDescription1').value; document.getElementById('Text3').innerHTML = document.getElementById('ConvoluteDescription2').value; } } if(y==3 && bedName.match('vZone')) { document.getElementById('Text').innerHTML = 'vZone'; if(bedName.match('Natural')) { document.getElementById('Text2').innerHTML = document.getElementById('vZoneNaturalDescription1').value; document.getElementById('Text3').innerHTML = document.getElementById('vZoneNaturalDescription2').value; } else { document.getElementById('Text2').innerHTML = document.getElementById('vZoneDescription1').value; document.getElementById('Text3').innerHTML = document.getElementById('vZoneDescription2').value; } } if(y==3 && bedName.match('Deluxe')) { var coreNum = imageName.charAt(z)-1; if(bedName.match('Natural')) { var tempName = document.getElementById('LatexNameNatural').value; document.getElementById('Text').innerHTML = '' + tempName.split("|")[coreNum] + ''; document.getElementById('Text2').innerHTML = document.getElementById('LatexDescriptionNatural').value.split("|")[coreNum]; document.getElementById('Text3').innerHTML = document.getElementById('LatexDescriptionNatural2').value.split("|")[coreNum]; } else { document.getElementById('Text').innerHTML = '' + document.getElementById('LatexName').value.split("|")[coreNum] + ''; document.getElementById('Text2').innerHTML = document.getElementById('LatexDescription').value.split("|")[coreNum]; document.getElementById('Text3').innerHTML = document.getElementById('LatexDescription2').value.split("|")[coreNum]; } } } else { if(y==2) { document.getElementById('Text').innerHTML = '' + document.getElementById('CoverName').value + ''; document.getElementById('Text2').innerHTML = document.getElementById('CoverDescription1').value document.getElementById('Text3').innerHTML = document.getElementById('CoverDescription2').value } if(y==3) { document.getElementById('Text').innerHTML = 'Convolute'; if(bedName.match('Natural')) { document.getElementById('Text2').innerHTML = document.getElementById('ConvoluteNaturalDescription1').value; document.getElementById('Text3').innerHTML = document.getElementById('ConvoluteNaturalDescription2').value; } else { document.getElementById('Text2').innerHTML = document.getElementById('ConvoluteDescription1').value; document.getElementById('Text3').innerHTML = document.getElementById('ConvoluteDescription2').value; } } } if(y>3 && y < 8) { if(bedName.match('Deluxe')) { var coreNum = imageName.charAt(z)-1; } else { var coreNum = imageName.charAt(z-1)-1; } addDebug('image: ' + imageName); addDebug('coreNum: ' + coreNum); addDebug('z: ' + z + x + y); if(bedName.match('Natural')) { var tempName = document.getElementById('LatexNameNatural').value; document.getElementById('Text').innerHTML = '' + tempName.split("|")[coreNum] + ''; document.getElementById('Text2').innerHTML = document.getElementById('LatexDescriptionNatural').value.split("|")[coreNum]; document.getElementById('Text3').innerHTML = document.getElementById('LatexDescriptionNatural2').value.split("|")[coreNum]; } else { document.getElementById('Text').innerHTML = '' + document.getElementById('LatexName').value.split("|")[coreNum] + ''; document.getElementById('Text2').innerHTML = document.getElementById('LatexDescription').value.split("|")[coreNum]; document.getElementById('Text3').innerHTML = document.getElementById('LatexDescription2').value.split("|")[coreNum]; } } if(y==8){ foundationName = document.getElementById('FoundationChoice').options[document.getElementById('FoundationChoice').selectedIndex].value.split("|")[0]; foundationDescription = document.getElementById('FoundationChoice').options[document.getElementById('FoundationChoice').selectedIndex].value.split("|")[4]; document.getElementById('Text').innerHTML = '' + foundationName + ''; document.getElementById('Text2').innerHTML = foundationDescription; } if(y==9){ supportName = document.getElementById('Legs').options[document.getElementById('Legs').selectedIndex].value.split("|")[0]; supportDescription = document.getElementById('Legs').options[document.getElementById('Legs').selectedIndex].value.split("|")[4]; document.getElementById('Text').innerHTML = '' + supportName + ''; document.getElementById('Text2').innerHTML = supportDescription; } document.getElementById('Text3').innerHTML = document.getElementById('Text').innerHTML + "
" + document.getElementById('Text2').innerHTML + "

" + document.getElementById('Text3').innerHTML; nextStep(); return; } function checkSubmit() { document.getElementById('SubmitMattress').value = document.getElementById('SelectAMattress').options[document.getElementById('SelectAMattress').selectedIndex].value.split("|")[2]; document.getElementById('Support').value = document.getElementById('Legs').options[document.getElementById('Legs').selectedIndex].value.split("|")[2]; foundationOptCheckbox = "Foundation" + document.getElementById('FoundationChoice').options[document.getElementById('FoundationChoice').selectedIndex].value.split("|")[2]; document.getElementById('a1').value = document.getElementById('UpperCoreL').value; document.getElementById('a2').value = document.getElementById('LowerCoreL').value; document.getElementById('b1').value = document.getElementById('UpperCoreR').value; document.getElementById('b2').value = document.getElementById('LowerCoreR').value; bedName = document.getElementById('SelectAMattress').options[document.getElementById('SelectAMattress').selectedIndex].value.split("|")[0].split(" - ")[0]; if(bedName.match('Deluxe')) { document.getElementById('a3').value = document.getElementById('DeluxeCoreL').value; document.getElementById('b3').value = document.getElementById('DeluxeCoreR').value; } else { document.getElementById('a3').value = ''; document.getElementById('b3').value = ''; } if(document.getElementById(foundationOptCheckbox + "Check").checked == true){document.getElementById('Foundation').value = document.getElementById(foundationOptCheckbox + "Check").value;} else {document.getElementById('Foundation').value = document.getElementById('FoundationChoice').options[document.getElementById('FoundationChoice').selectedIndex].value.split("|")[2];} } function activateBox(x) { if(x=='1') {document.getElementById('boxA').style.display = 'None';} if(x=='5') {document.getElementById('boxB').style.display = 'None';} if(x=='4') {document.getElementById('boxC').style.display = 'None';} if(x=='8') {document.getElementById('boxD').style.display = 'None';} if(currentDisplay == 'Bed') { //currentDisplay = 'Component'; imagename = ''; for (i=1;ix;i--) { imagename = imagename + 0} if(imagename != '000000000') { imagename = 'component.lasso?id=' + imagename + '.png'; document.getElementById('cover').style.display='block'; component=dhtmlwindow.open('componentdiv', 'iframe', imagename, 'Component', 'width=800px,height=520px,left=300px,top=30px,resize=0,scrolling=1'); component.onclose=function(){ //Run custom code when window is being closed (return false to cancel action): closeComponent();return true; } } else { selectBed(); currentDisplay = 'Bed'; } //document.getElementById('overlay').style.display = 'block'; } } function closeComponent() { document.getElementById('moveableBox').style.display='none'; document.getElementById('staticBox').style.display='block'; document.getElementById('cover').style.display='none'; } function bold(x) { if(document.getElementById('menu' + x)) { document.getElementById('menu' + x).style.fontWeight = "bold"; } } function normal(x) { if(document.getElementById('menu' + x)) { document.getElementById('menu' + x).style.fontWeight = "normal"; } } function updateBeds(selectedBed){ var sizetoUse = selectedBed; document.getElementById('LowerCoreL').options.length=0; for (i=0; iReset'; } else { document.getElementById('LeftSide').innerHTML = 'We Recommend'; } if( document.getElementById('UpperCoreR').selectedIndex+1 != rc2.charAt(0) || document.getElementById('LowerCoreR').selectedIndex+1 != rc2.charAt(1) || (document.getElementById('DeluxeCoreR').selectedIndex+1 != rc2.charAt(2) && curName.match("Deluxe")) ) { // Non recommented Right Size document.getElementById('RightSide').innerHTML = 'Your Selections
Reset'; } else { document.getElementById('RightSide').innerHTML = 'We Recommend'; } } function selectBed(x) { currentDisplay = 'Bed'; document.getElementById('bedImagediv').style.display = 'Block'; document.getElementById('bedOptions').style.display = 'Block'; if(document.getElementById('mattressImages')) { document.getElementById('mattressImages').style.display = 'none'; } document.getElementById('instructions').style.display = 'none'; var curName = document.getElementById('SelectAMattress').options[document.getElementById('SelectAMattress').selectedIndex].value.split("|")[0]; var curProdID = document.getElementById('SelectAMattress').options[document.getElementById('SelectAMattress').selectedIndex].value.split("|")[2]; var curNamePart = curName.split(" - ")[0]; document.getElementById('BedName').innerHTML = ('' + curName + ' - ' + curNamePart + ''); if (curName.match("Deluxe")) { document.getElementById('Deluxe1').style.display = 'Block'; document.getElementById('Deluxe2').style.display = 'Block'; } else { document.getElementById('Deluxe1').style.display = 'None'; document.getElementById('Deluxe2').style.display = 'None'; } if(curName.match("Natural-NowAvailable")) { // Remove Super Firm if Available var firmOptions = new Array('UpperCoreL', 'UpperCoreR', 'LowerCoreR', 'LowerCoreL', 'DeluxeCoreL', 'DeluxeCoreR'); for (var elId in firmOptions) { var elSel = document.getElementById(firmOptions[elId]); if (elSel.length > 4) { if(elSel.selectedIndex == 4) {elSel.selectedIndex=3;} elSel.remove(elSel.length - 1); } } } else { // Replace Super Firm if now Available var firmOptions = new Array('UpperCoreL', 'UpperCoreR', 'LowerCoreR', 'LowerCoreL', 'DeluxeCoreL', 'DeluxeCoreR'); for (var elId in firmOptions) { var elSel = document.getElementById(firmOptions[elId]); if (elSel.length < 5) { var elOptNew = document.createElement('option'); elOptNew.text = 'Super Firm Latex'; elOptNew.value = '5'; try { elSel.add(elOptNew, null); // standards compliant; doesn't work in IE } catch(ex) { elSel.add(elOptNew); // IE only } } } } document.BedOptionsBasic.Topper.value = document.getElementById('SelectAMattress').options[document.getElementById('SelectAMattress').selectedIndex].value.split("|")[1].charAt(0); document.BedOptionsBasic.ComfortTopper.value = document.getElementById('SelectAMattress').options[document.getElementById('SelectAMattress').selectedIndex].value.split("|")[1].charAt(1); document.BedOptionsBasic.ZoneComfort.value = document.getElementById('SelectAMattress').options[document.getElementById('SelectAMattress').selectedIndex].value.split("|")[1].charAt(2); if(firstRun == true){ firstRun = false; //fadebox(); } UpdateNameBasic(x); } function describeBed() { var bedSizeMap = []; bedSizeMap["E. King"] = "76x80"; bedSizeMap["Cal King"] = "72x84"; bedSizeMap["Queen"] = "60X80"; bedSizeMap["Std/Double"] = "54x75"; bedSizeMap["Twin"] = "38x75"; bedSizeMap["Twin Long"] = "38x80"; bedSizeMap["Dual King"] = "2@38x80"; bedSize = document.getElementById('SubmitSize').value + ' ' + bedSizeMap[document.getElementById('SubmitSize').value]; regPrice = document.getElementById('SelectAMattress').options[document.getElementById('SelectAMattress').selectedIndex].value.split("|")[3]; bedName = document.getElementById('SelectAMattress').options[document.getElementById('SelectAMattress').selectedIndex].value.split("|")[0].split(" - ")[0]; bedShortD = document.getElementById('SelectAMattress').options[document.getElementById('SelectAMattress').selectedIndex].value.split("|")[5]; bedMedD = document.getElementById('SelectAMattress').options[document.getElementById('SelectAMattress').selectedIndex].value.split("|")[6]; salePrice = document.getElementById('SelectAMattress').options[document.getElementById('SelectAMattress').selectedIndex].value.split("|")[4]; foundationName = document.getElementById('FoundationChoice').options[document.getElementById('FoundationChoice').selectedIndex].value.split("|")[0]; supportName = document.getElementById('Legs').options[document.getElementById('Legs').selectedIndex].value.split("|")[0]; if (foundationName != '') { foundationPrice = document.getElementById('FoundationChoice').options[document.getElementById('FoundationChoice').selectedIndex].value.split("|")[3]; foundationOptCheckbox = "Foundation" + document.getElementById('FoundationChoice').options[document.getElementById('FoundationChoice').selectedIndex].value.split("|")[2]; if(document.getElementById(foundationOptCheckbox + "Price")) { foundationOptPrice = document.getElementById(foundationOptCheckbox + "Price").value;} else { foundationOptPrice = 0;} if(document.getElementById(foundationOptCheckbox + "Description")) {foundationOptionDescription = document.getElementById(foundationOptCheckbox + "Description").value;} else {foundationOptionDescription = ''}; } if (supportName != '') { supportPrice = document.getElementById('Legs').options[document.getElementById('Legs').selectedIndex].value.split("|")[3]; supportOptCheckbox = "Support" + document.getElementById('Legs').options[document.getElementById('Legs').selectedIndex].value.split("|")[2]; if(document.getElementById(supportOptCheckbox + "Price")){ supportOptPrice = document.getElementById(supportOptCheckbox + "Price").value; supportOptionDescription = document.getElementById(supportOptCheckbox + "Description").value; } } bedPrice = parseFloat(salePrice); bedDescription = "
" + bedShortD + "

"; if (regPrice == salePrice) {bedDescription = bedDescription + "" + bedName + " " + bedSize +"
$" + regPrice + "
";} else { bedDescription = bedDescription + "" + bedName + " " + bedSize +"
$" + regPrice + " $" + salePrice + "
";} if (foundationName != '') { bedDescription = bedDescription + "
" + foundationName + "
$" + foundationPrice + "
"; bedPrice = bedPrice+parseFloat(foundationPrice); if(document.getElementById(foundationOptCheckbox + "Check")) { if(document.getElementById(foundationOptCheckbox + "Check").checked == true){ bedDescription = bedDescription + "
" + foundationOptionDescription + "
$" + foundationOptPrice + "
"; bedPrice = bedPrice+parseFloat(foundationOptPrice); } } } if (supportName != '') { bedDescription = bedDescription + "
" + supportName + "
$" + supportPrice + "
"; bedPrice = bedPrice+parseFloat(supportPrice); if(document.getElementById(supportOptCheckbox + "Check")){ if(document.getElementById(supportOptCheckbox + "Check").checked == true){ bedDescription = bedDescription + "
" + supportOptionDescription + "
$" + supportOptPrice + "
"; bedPrice = bedPrice+parseFloat(supportOptPrice); } } } bedDescription = bedDescription + "

Total:
$" + bedPrice + "
"; //bedDescription = bedDescription + "
" + bedMedD + "

"; document.getElementById('BedPrice').innerHTML = bedDescription; } function changeMap(mapName){ if (document.all) document.all.image0.setAttribute('useMap', ('#' + mapName)) else if (document.getElementById) document.getElementById('image0').useMap = ('#' + mapName); } function fadebox() { if(box>0) { $("#box" + box).fadeIn("slow", fadebox); box = box-1; alert('minus ' + box); } else { box = box+1; cutbox(); } } function cutbox() { if(box<10) { imageSrc = document.getElementById("image" + box).src; newImageSrc = imageSrc.replace("w.png", ".png"); document.getElementById("image" + box).src = newImageSrc; box = box+1; setTimeout("cutbox()",1000); } } // Copy Firmness Values form Firm Advisor function AjaxCopyFirmnessValues () { document.getElementById('UpperCoreL').selectedIndex = (document.getElementById('FAa1').value - 1); document.getElementById('LowerCoreL').selectedIndex = (document.getElementById('FAa2').value - 1); if(document.getElementById('FAa3')) { document.getElementById('DeluxeCoreL').selectedIndex = (document.getElementById('FAa3').value - 1); } document.getElementById('LowerCoreR').selectedIndex = (document.getElementById('FAb2').value - 1); if(document.getElementById('LowerCoreR').selectedIndex < 0) {document.getElementById('LowerCoreR').selectedIndex = 0;} document.getElementById('UpperCoreR').selectedIndex = (document.getElementById('FAb1').value - 1); if(document.getElementById('UpperCoreR').selectedIndex < 0) {document.getElementById('UpperCoreR').selectedIndex = 0;} if(document.getElementById('FAa3')) { document.getElementById('DeluxeCoreR').selectedIndex = (document.getElementById('FAb3').value - 1); } document.getElementById('rcv').value = document.getElementById('CV').value; document.getElementById('rfv').value = document.getElementById('FV').value; document.getElementById('firmAdviceQuote').innerHTML = 'Change Answers'; UpdateNameBasic(); checkAdvise(); ajaxwin.close(); } function showDiv(x) { document.getElementById(x).style.display = 'block'; } function hideDiv(x) { document.getElementById(x).style.display = 'none'; } function checkImageArray () { addDebug('Check Image Array was run:' + imgLoading); var startingLength = imgLoading.length; imgLoading.shift(); var arLen=imgLoading.length; if(imgArray.length == 0) { document.getElementById('spinner').style.display = 'none'; } if(animateSteps.length < 3 || startingLength == 0) { addDebug('exited Check image. No remaining steps'); return; } checkImageTimeout = setTimeout ( "nextStep()", 500 ); } function playMovie (x) { if(document.getElementById('ComponentMovie').style.display == 'none') { document.getElementById('ComponentMovie').style.display = 'block'; document.getElementById('ComponentStart').style.display = 'none'; document.getElementById('ComponentStop').style.display = 'block'; document.getElementById('box' + returnPiece).style.display = 'none'; document.getElementById('Text').style.display = 'none'; document.getElementById('Text2').style.display = 'none'; document.getElementById('Text3').style.display = 'none'; } else { document.getElementById('ComponentMovie').style.display = 'none'; document.getElementById('box' + returnPiece).style.display = 'block'; document.getElementById('ComponentStart').style.display = 'block'; document.getElementById('ComponentStop').style.display = 'none'; document.getElementById('Text').style.display = 'none'; document.getElementById('Text2').style.display = 'none'; document.getElementById('Text3').style.display = 'block'; wimpyButtonPause(); } } function startList() { if (document.all&&document.getElementById) { navRoot = document.getElementById("tabnav"); for (i=0; i