var newWindow
var totalCubicFeet
var output

function displayCalculation() {
	newWindow = window.open("","","status,height=250,width=350")
	var newContent = "<HTML><HEAD><TITLE>Storage Calculator</TITLE></HEAD>"
	newContent += "<BODY><p>Our Storage Calculator has estimated that your total storage adds up to approximately <B>" + totalCubicFeet + " cubic feet</B>."
	newContent += "We recommend that you use at least a <B>" + output + " unit</B>.</p>"  
	newContent += "<p>Be sure to check if we have this size available in the type storage you would like to rent.  For example, "
	newContent += "we currently provide a climate controlled 5X5 unit, but not a non-climate controlled 5X5 unit.  In this case, "
	newContent += "if you are interested in only non-climate controlled units, we would recommend moving up to the next size of the non-climate controlled units.</p>"
	newContent += "</BODY></HTML>"
	newWindow.document.write(newContent)
	newWindow.document.close()
}
function displaySuggestion() {
	newWindow = window.open("","","status,height=250,width=350")
	var newContent = "<HTML><HEAD><TITLE>Storage Calculator</TITLE></HEAD>"
	newContent += "<BODY><p>Our Storage Calculator has estimated that your total storage adds up to approximately <B>" + totalCubicFeet + " cubic feet</B>. "
	newContent += "We do not currently have a single unit that is capable of holding that amount of storage.  The amount specified will require more that one storage unit. "  
	newContent += "In this particular case it would be appropriate for you to contact us at <b><i>Fairfield Storage</i></b> to discuss options available."
	newContent += "</BODY></HTML>"
	newWindow.document.write(newContent)
	newWindow.document.close()
}
function calcStorage() {
	var cubicFeet5X5 = 125
	var cubicFeet5X10 = 250
	var cubicFeet5X15 = 375
	var cubicFeet10X10 = 500
	var cubicFeet10X15 = 750
	var cubicFeet10X20 = 1000
	var cubicFeet10X25 = 1250
	var cubicFeet10X30 = 1500
	var cubicFeet12X25 = 1500
	var cubicFeet15X15 = 1125
	var couch6ft_cubicFeet = 54
	var couch8ft_cubicFeet = 72
	var armChair_cubicFeet = 27
	var coffeeTable_cubicFeet = 23
	var endTable_cubicFeet = 10
	var tableLamp_cubicFeet = 6
	var floorLamp_cubicFeet = 6
	var refrigerator_cubicFeet = 31
	var stoveOven_cubicFeet = 25
	var dishWasher_cubicFeet = 15
	var diningTable_cubicFeet = 7
	var diningChair_cubicFeet = 14
	var dresser_cubicFeet = 21
	var dresserMirror_cubicFeet = 18
	var nightStand_cubicFeet = 6
	var armoire_cubicFeet = 20
	var queenHeadFootBoard_cubicFeet = 25
	var queenMattressBox_cubicFeet = 70
	var kingHeadFootBoard_cubicFeet = 35 
	var kingMattressBox_cubicFeet = 98
	var twinHeadFootBoard_cubicFeet = 5
	var twinMattressBox_cubicFeet = 21
	var smallSizeBox_cubicFeet = 1
	var mediumSizeBox_cubicFeet = 8
	var largeSizeBox_cubicFeet = 27
	var couch6ft = document.storageCalculator.couch6ft.value
	var couch8ft = document.storageCalculator.couch8ft.value
	var armChair = document.storageCalculator.armChair.value
	var coffeeTable = document.storageCalculator.coffeeTable.value
	var endTable = document.storageCalculator.endTable.value
	var tableLamp = document.storageCalculator.tableLamp.value
	var floorLamp = document.storageCalculator.floorLamp.value
	var refrigerator = document.storageCalculator.refrigerator.value
	var stoveOven = document.storageCalculator.stoveOven.value
	var dishWasher = document.storageCalculator.dishWasher.value
	var diningTable = document.storageCalculator.diningTable.value
	var diningChair = document.storageCalculator.diningChair.value
	var dresser = document.storageCalculator.dresser.value
	var dresserMirror = document.storageCalculator.dresserMirror.value
	var nightStand = document.storageCalculator.nightStand.value
	var armoire = document.storageCalculator.armoire.value
	var queenHeadFootBoard = document.storageCalculator.queenHeadFootBoard.value
	var queenMattressBox = document.storageCalculator.queenMattressBox.value
	var kingHeadFootBoard = document.storageCalculator.kingHeadFootBoard.value
	var kingMattressBox = document.storageCalculator.kingMattressBox.value
	var twinHeadFootBoard = document.storageCalculator.twinHeadFootBoard.value
	var twinMattressBox = document.storageCalculator.twinMattressBox.value
	var smallSizeBox = document.storageCalculator.smallSizeBox.value
	var mediumSizeBox = document.storageCalculator.mediumSizeBox.value
	var largeSizeBox = document.storageCalculator.largeSizeBox.value
	totalCubicFeet = (couch6ft_cubicFeet * couch6ft) + (couch8ft_cubicFeet * couch8ft) + (armChair_cubicFeet * armChair) +
						(coffeeTable_cubicFeet * coffeeTable) + (endTable_cubicFeet * endTable) + (tableLamp_cubicFeet * tableLamp) +
						(floorLamp_cubicFeet * floorLamp) + (refrigerator_cubicFeet * refrigerator) + (stoveOven_cubicFeet * stoveOven) +
						(dishWasher_cubicFeet * dishWasher) + (diningTable_cubicFeet * diningTable) +
						(diningChair_cubicFeet * diningChair) + (dresser_cubicFeet * dresser) + (dresserMirror_cubicFeet * dresserMirror) +
						(nightStand_cubicFeet * nightStand) + (armoire_cubicFeet * armoire) +
						(queenHeadFootBoard_cubicFeet * queenHeadFootBoard) + (queenMattressBox_cubicFeet * queenMattressBox) +
						(kingHeadFootBoard_cubicFeet * kingHeadFootBoard) + (kingMattressBox_cubicFeet * kingMattressBox) +
						(twinHeadFootBoard_cubicFeet * twinHeadFootBoard) + (twinMattressBox_cubicFeet * twinMattressBox) +
						(smallSizeBox_cubicFeet * smallSizeBox) + (mediumSizeBox_cubicFeet * mediumSizeBox) +
						(largeSizeBox_cubicFeet * largeSizeBox) 
	if (totalCubicFeet <= cubicFeet5X5) {
		output = "5X5"
		displayCalculation()
	} else {
		if (totalCubicFeet <= cubicFeet5X10) {
			output = "5X10"
			displayCalculation()
		} else {
			if (totalCubicFeet <= cubicFeet5X15) {
				output = "5X15"
				displayCalculation()
			} else {
				if (totalCubicFeet <= cubicFeet10X10) {
					output = "10X10"
					displayCalculation()
				} else {
					if (totalCubicFeet <= cubicFeet10X15) {
						output = "10X15"
						displayCalculation()
					} else {
						if (totalCubicFeet <= cubicFeet10X20) {
							output = "10X20"
							displayCalculation()
						} else {
							if (totalCubicFeet <= cubicFeet15X15) {
								output = "15X15"
								displayCalculation()
							} else {
								if (totalCubicFeet <= cubicFeet10X25) {
									output = "10X25"
									displayCalculation()
								} else {
									if (totalCubicFeet <= cubicFeet10X30) {
										output = "10X30 or 12X25"
										displayCalculation()
									} else { 
										displaySuggestion()
									}
								}
							}
						}
					}
				}
			}
		}
	}
}