// JavaScript Document
function hideDiv(id){
document.getElementById(id).style.visibility = "hidden";
}
function showClue(id, position){
var html = '<span class="clue">To see more details fill out the form</span>';
document.getElementById(id).innerHTML = html;
document.getElementById(id).style.top = position;
document.getElementById(id).style.visibility = "visible";
}
function addCommas(nStr)
{
	nStr += '';
	x = nStr.split('.');
	x1 = x[0];
	x2 = x.length > 1 ? '.' + x[1] : '';
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(x1)) {
		x1 = x1.replace(rgx, '$1' + ',' + '$2');
	}
	return x1 + x2;
}

function countPieces(lFeet, lInches, wFeet, wInches){
	var lenFeet = document.getElementById(lFeet).value;
	var lenInches = document.getElementById(lInches).value;
	var widFeet =  document.getElementById(wFeet).value;
	var widInches = document.getElementById(wInches).value;

	var text=/^\d+$/;
	
	if(text.test(lenFeet) && (lenFeet != 0 || widInches != 0) && text.test(lenInches) && text.test(widFeet) && text.test(widInches)){
	
		if(lenInches==0 && widInches==0){
			
			var lenghtArea = Math.floor(lenFeet/2)*2;
			var widthArea = Math.floor(widFeet/2)*2;
			var totalArea = Math.floor(lenFeet/2) * Math.floor(widFeet/2);
			var borderArea = (Math.floor(lenFeet/2) - 2)*2 + (Math.floor(widFeet/2) - 2)*2;
			var insideArea = (Math.floor(lenFeet/2) - 2)*(Math.floor(widFeet/2) - 2);
			
			var num = new Number(lenFeet);
			var num1 = new Number(widFeet);
			
			var lenghtPLArea = num - 1;
			var widthPLArea = num1 - 1;
			var lenghtPLWall = num; 
			var widthPLWall = num1;
			var totalPLArea = lenghtPLArea * widthPLArea;
			var totalPLWall = lenghtPLWall * widthPLWall;

			var totalWall = Math.ceil(lenFeet/2) *  Math.ceil(widFeet/2);
			var lenghtWall = Math.ceil(lenFeet/2)*2;
			var widthWall = Math.ceil(widFeet/2)*2;
			var borderWall = (Math.ceil(lenFeet/2) - 2)*2 + (Math.ceil(widFeet/2) - 2)*2;
			var insideWall = (Math.ceil(lenFeet/2) - 2)*(Math.ceil(widFeet/2) - 2);
			
			var total4by4Area = Math.floor(lenFeet/4) * Math.floor(widFeet/4);
			var lenght4by4Area = Math.floor(lenFeet/4)*4;
			var width4by4Area =  Math.floor(widFeet/4)*4;
			
                        var total4by4Wall = Math.ceil(lenFeet/4) *  Math.ceil(widFeet/4);
                        var lenght4by4Wall = Math.ceil(lenFeet/4)*4;
                        var width4by4Wall =  Math.ceil(widFeet/4)*4;
			
                        var total1mby1mArea = Math.floor(lenFeet/3.375) * Math.floor(widFeet/3.28);
                        var lenght1mby1mArea = Math.floor(lenFeet/3.375)*3.375;
                        var width1mby1mArea = Math.floor(widFeet/3.375)*3.375;
			
                        var total1mby1mWall = Math.ceil(lenFeet/3.375) *  Math.ceil(widFeet/3.375);
                        var lenght1mby1mWall = Math.ceil(lenFeet/3.375)*3.375;
                        var width1mby1mWall = Math.ceil(widFeet/3.375)*3.375;
			var html='';
			html+='Area Rug '+totalArea+'\nWall to Wall '+totalWall+'\n4by4 Area Rug '+total4by4Area+'\n4b4 Wall to Wall '+total4by4Wall+'\n1m by 1m Area Rug '+total1mby1mArea+'\n1m by 1m Wall To Wall '+total1mby1mWall+'';
		
	}
	else if(lenInches!=0 && widInches==0){
		
		if(lenInches>=12){
		alert('Please convert your dimensions to feet and inches');
		
		}else{
			
			var num = new Number(lenFeet);
			var num1 = new Number(lenInches);
			var numa = new Number(widFeet);
			var lenFeetArea1 = num - num1 + num1;
			var lenFeetWall1 = num + 1;
			
			if(lenInches <= 6){
				if(lenInches == 6){
				var lenghtPLArea = num;
				var widthPLArea = numa - 1;
				}else{
				var lenghtPLArea = num - 1;
				var widthPLArea = numa - 1;
				}
				var lenghtPLWall = num;
				var widthPLWall = numa;
				}else{
				var lenghtPLArea = num;
				var widthPLArea = numa - 1;
				var lenghtPLWall = num + 1;
				var widthPLWall = widFeet;
					}
			
			var totalPLArea = lenghtPLArea * widthPLArea;
			var totalPLWall = lenghtPLWall * widthPLWall;
			
			var lenghtArea = Math.floor(lenFeetArea1/2)*2;
			var widthArea = Math.floor(widFeet/2)*2;
			var totalArea = Math.floor(lenFeetArea1/2) * Math.floor(widFeet/2);
			var borderArea = (Math.floor(lenFeetArea1/2) - 2)*2 + (Math.floor(widFeet/2) - 2)*2;
			var insideArea = (Math.floor(lenFeetArea1/2) - 2)*(Math.floor(widFeet/2) - 2);
			
			var lenghtWall = Math.ceil(lenFeetWall1/2)*2;
			var widthWall = Math.ceil(widFeet/2)*2;
			var totalWall = Math.ceil(lenFeetWall1/2) *  Math.ceil(widFeet/2);
			var borderWall = (Math.ceil(lenFeetWall1/2) - 2)*2 + (Math.ceil(widFeet/2) - 2)*2;
			var insideWall = (Math.ceil(lenFeetWall1/2) - 2)*(Math.ceil(widFeet/2) - 2);
			
			var total4by4Area = Math.floor(lenFeetArea1/4) * Math.floor(widFeet/4);
			var lenght4by4Area = Math.floor(lenFeetArea1/4)*4;
			var width4by4Area =  Math.floor(widFeet/4)*4;
			
                        var total4by4Wall = Math.ceil(lenFeetWall1/4) *  Math.ceil(widFeet/4);
			var lenght4by4Wall = Math.ceil(lenFeetWall1/4)*4;
                        var width4by4Wall =  Math.ceil(widFeet/4)*4;
			
                        var total1mby1mArea = Math.floor(lenFeetArea1/3.375) * Math.floor(widFeet/3.375);
                        var lenght1mby1mArea = Math.floor(lenFeetArea1/3.3758)*3.375;
                        var width1mby1mArea = Math.floor(widFeet/3.375)*3.375;
			
                        var total1mby1mWall = Math.ceil(lenFeetWall1/3.375) *  Math.ceil(widFeet/3.375);
			var lenght1mby1mWall = Math.ceil(lenFeetWall1/3.375)*3.375;
                        var width1mby1mWall = Math.ceil(widFeet/3.375)*3.375;
			var html='';
			html+='Area Rug '+totalArea+'\nWall to Wall '+totalWall+'\n4by4 Area Rug '+total4by4Area+'\n4b4 Wall to Wall '+total4by4Wall+'\n1m by 1m Area Rug '+total1mby1mArea+'\n1m by 1m Wall To Wall '+total1mby1mWall+'';
			//alert(html);
		}
			}
			else if(lenInches==0 && widInches!=0){
				
				if(widInches>=12){
				alert('Please convert your dimensions to feet and inches');
				}else{
					
					var num = new Number(widFeet);
					var numa = new Number(lenFeet);
					var num1 = new Number(widInches);
					var widFeetArea1 = num - num1 + num1;
					var widFeetWall1 = num+1;
					
					if(widInches <= 6){
					if(widInches == 6){
						var lenghtPLArea = numa - 1;
						var widthPLArea = num;
						}else{	
						var lenghtPLArea = numa - 1;
						var widthPLArea = num - 1;
						}
					var lenghtPLWall = numa;
					var widthPLWall = num;
					}else{
					var lenghtPLArea = numa -1;
					var widthPLArea = num;
					var lenghtPLWall = numa;
					var widthPLWall = num+1;
					}
			
			var totalPLArea = lenghtPLArea * widthPLArea;
			var totalPLWall = lenghtPLWall * widthPLWall;
					
					
					
					var lenghtArea = Math.floor(lenFeet/2)*2;
					var widthArea = Math.floor(widFeetArea1/2)*2;
					var totalArea = Math.floor(lenFeet/2) * Math.floor(widFeetArea1/2);
					var borderArea = (Math.floor(lenFeet/2) - 2)*2 + (Math.floor(widFeetArea1/2) - 2)*2;
					var insideArea = (Math.floor(lenFeet/2) - 2)*(Math.floor(widFeetArea1/2) - 2);
					
					var lenghtWall = Math.ceil(lenFeet/2)*2;
					var widthWall = Math.ceil(widFeetWall1/2)*2;
					var totalWall = Math.ceil(lenFeet/2) *  Math.ceil(widFeetWall1/2);
					var borderWall = (Math.ceil(lenFeet/2) - 2)*2 + (Math.ceil(widFeetWall1/2) - 2)*2;
					var insideWall = (Math.ceil(lenFeet/2) - 2)*(Math.ceil(widFeetWall1/2) - 2);
					
					var total4by4Area = Math.floor(lenFeet/4) * Math.floor(widFeetArea1/4);
					var lenght4by4Area = Math.floor(lenFeet/4)*4;
			                var width4by4Area =  Math.floor(widFeetArea1/4)*4;
					
                                        var total4by4Wall = Math.ceil(lenFeet/4) *  Math.ceil(widFeetWall1/4);
                                        var lenght4by4Wall = Math.ceil(lenFeet/4)*4;
                                        var width4by4Wall =  Math.ceil(widFeetWall1/4)*4;
                                        
					var total1mby1mArea = Math.floor(lenFeet/3.375) * Math.floor(widFeetArea1/3.375);
					var lenght1mby1mArea = Math.floor(lenFeet/3.375)*3.375;
                                        var width1mby1mArea = Math.floor(widFeetArea1/3.375)*3.375;
					
                                        var total1mby1mWall = Math.ceil(lenFeet/3.375) *  Math.ceil(widFeetWall1/3.375);
                                        var lenght1mby1mWall = Math.ceil(lenFeet/3.375)*3.375;
                                        var width1mby1mWall = Math.ceil(widFeetWall1/3.375)*3.375;
					var html='';
					html+='Area Rug '+totalArea+'\nWall to Wall '+totalWall+'\n4by4 Area Rug '+total4by4Area+'\n4b4 Wall to Wall '+total4by4Wall+'\n1m by 1m Area Rug '+total1mby1mArea+'\n1m by 1m Wall To Wall '+total1mby1mWall+'';
					//alert(html);
					}
}
	else{
	if(lenInches>=12 || widInches>=12){
	alert('Please convert your dimensions to feet and inches');
	}else{
		var num = new Number(lenFeet);
		var numa = new Number(lenInches);
		var lenFeetArea1 = num - numa + numa;
		var lenFeetWall1 = num + 1;
		var num1 = new Number(widFeet);
		var num1a = new Number(widInches);
		var widFeetArea1 = num1 - num1a + num1a;
		var widFeetWall1 = num1 + 1;
		
		if(lenInches <=6 && widInches <=6){
			if(lenInches == 6 && widInches != 6){
				var lenghtPLArea = num;
				var widthPLArea = num1 - 1;
			}else if(lenInches != 6 && widInches == 6){
				var lenghtPLArea = num - 1;
				var widthPLArea = num1;
				}else if(lenInches == 6 && widInches == 6){
				var lenghtPLArea = num;	
				var widthPLArea = num1;	
			}else{
			var lenghtPLArea = num - 1;
			var widthPLArea = num1 - 1;
			}
			var lenghtPLWall = num;
			var widthPLWall = num1;
		}else if(lenInches>6 && widInches <=6){
			if(widInches == 6){
				var widthPLArea = num1;
				}else{
				var widthPLArea = num1 - 1;	
					}
			var lenghtPLArea = num;
			
			var lenghtPLWall = num+1;
			var widthPLWall = num1;
		}else if(lenInches <= 6 && widInches > 6){
		      if(lenInches == 6){
                      var lenghtPLArea = num;
                      }else{
			var lenghtPLArea = num-1;
			}
			var widthPLArea = num1;
			var lenghtPLWall = num;
			var widthPLWall = num1+1;
		}else if(lenInches>6 && widInches > 6){
			var lenghtPLArea = num;
			var widthPLArea = num1;
			var lenghtPLWall = num+1;
			var widthPLWall = num1+1;
			}
		
		var totalPLArea = lenghtPLArea * widthPLArea;
		var totalPLWall = lenghtPLWall * widthPLWall;
		
		var lenghtArea = Math.floor(lenFeetArea1/2)*2;
		var widthArea = Math.floor(widFeetArea1/2)*2;
		var totalArea = Math.floor(lenFeetArea1/2) * Math.floor(widFeetArea1/2);
		var borderArea = (Math.floor(lenFeetArea1/2) - 2)*2 + (Math.floor(widFeetArea1/2) - 2)*2;
		var insideArea = (Math.floor(lenFeetArea1/2) - 2)*(Math.floor(widFeetArea1/2) - 2);
		
		var lenghtWall = Math.ceil(lenFeetWall1/2)*2;
		var widthWall = Math.ceil(widFeetWall1/2)*2;
		var totalWall = Math.ceil(lenFeetWall1/2) *  Math.ceil(widFeetWall1/2);
		var borderWall = (Math.ceil(lenFeetWall1/2) - 2)*2 + (Math.ceil(widFeetWall1/2) - 2)*2;
		var insideWall = (Math.ceil(lenFeetWall1/2) - 2)*(Math.ceil(widFeetWall1/2) - 2);
		
                var total4by4Area = Math.floor(lenFeetArea1/4) * Math.floor(widFeetArea1/4);
                var lenght4by4Area = Math.floor(lenFeetArea1/4)*4;
                var width4by4Area =  Math.floor(widFeetArea1/4)*4;
                
		var total4by4Wall = Math.ceil(lenFeetWall1/4) *  Math.ceil(widFeetWall1/4);
		var lenght4by4Wall = Math.ceil(lenFeetWall1/4)*4;
                var width4by4Wall =  Math.ceil(widFeetWall1/4)*4;
		
                var total1mby1mArea = Math.floor(lenFeetArea1/3.375) * Math.floor(widFeetArea1/3.28);
                var lenght1mby1mArea = Math.floor(lenFeetArea1/3.375)*3.375;
                var width1mby1mArea = Math.floor(widFeetArea1/3.375)*3.375;
		
                var total1mby1mWall = Math.ceil(lenFeetWall1/3.375) *  Math.ceil(widFeetWall1/3.375);
                var lenght1mby1mWall = Math.ceil(lenFeetWall1/3.375)*3.375;
                var width1mby1mWall = Math.ceil(widFeetWall1/3.375)*3.375;
		var html='';
		html+='Area Rug '+totalArea+'\nWall to Wall '+totalWall+'\n4by4 Area Rug '+total4by4Area+'\n4b4 Wall to Wall '+total4by4Wall+'\n1m by 1m Area Rug '+total1mby1mArea+'\n1m by 1m Wall To Wall '+total1mby1mWall+'';
		//alert(html);
		}
	}
//Prices per piece
var costSF = 7.80;
var costERSF1 = 4.04;
var costERSF2 = 4.32;
var costSW = 11.80;
var costSC = 15.80;
var costESC = 8.36;
var costST = 9.92;
var costSR = 15.84;
var costJRSF2 = 8.84;
var costJRSF2by1 = 10.32;
var costJRSF1mby1m = 20.64;
var costJRSF4 = 40.96;

document.getElementById('total1').innerHTML = totalArea;
document.getElementById('total1').value = totalArea;
document.getElementById('total1w').innerHTML = totalWall;
document.getElementById('total1w').value = totalWall;
document.getElementById('borderArea').value = borderArea;
document.getElementById('insideArea').value = insideArea;
document.getElementById('borderWall').value = borderWall;
document.getElementById('insideWall').value = insideWall;

document.getElementById('lenghtArea').value = lenghtArea;
document.getElementById('widthArea').value = widthArea;
document.getElementById('lenghtWall').value = lenghtWall;
document.getElementById('widthWall').value = widthWall;

costs(totalArea, costSF, 'cost1');
costs(totalWall, costSF, 'cost1w');

document.getElementById('total2').innerHTML = totalArea;
document.getElementById('total2').value = totalArea;
document.getElementById('total2w').innerHTML = totalWall;
document.getElementById('total2w').value = totalWall;
costs(totalArea, costERSF1, 'cost2');
costs(totalWall, costERSF1, 'cost2w');

document.getElementById('total3').innerHTML = totalArea;
document.getElementById('total3').value = totalArea;
document.getElementById('total3w').innerHTML = totalWall;
document.getElementById('total3w').value = totalWall;
costs(totalArea, costERSF2, 'cost3');
costs(totalWall, costERSF2, 'cost3w');

document.getElementById('total4').innerHTML = totalPLArea;
document.getElementById('total4').value = totalPLArea;
document.getElementById('total4w').innerHTML = totalPLWall;
document.getElementById('total4w').value = totalPLWall;

document.getElementById('lenghtPLArea').value = lenghtPLArea;
document.getElementById('widthPLArea').value = widthPLArea;
document.getElementById('lenghtPLWall').value = lenghtPLWall;
document.getElementById('widthPLWall').value = widthPLWall;

document.getElementById('total5').innerHTML = totalArea;
document.getElementById('total5').value = totalArea;
document.getElementById('total5w').innerHTML = totalWall;
document.getElementById('total5w').value = totalWall;
costs(totalArea, costSW, 'cost5');
costs(totalWall, costSW, 'cost5w');

document.getElementById('total6').innerHTML = totalArea;
document.getElementById('total6').value = totalArea;
document.getElementById('total6w').innerHTML = totalWall;
document.getElementById('total6w').value = totalWall;
costs(totalArea, costSC, 'cost6');
costs(totalWall, costSC, 'cost6w');


document.getElementById('total7').innerHTML = totalArea;
document.getElementById('total7').value = totalArea;
document.getElementById('total7w').innerHTML = totalWall;
document.getElementById('total7w').value = totalWall;
costs(totalArea, costESC, 'cost7');
costs(totalWall, costESC, 'cost7w');

document.getElementById('total8').innerHTML = totalArea;
document.getElementById('total8').value = totalArea;
document.getElementById('total8w').innerHTML = totalWall;
document.getElementById('total8w').value = totalWall;
costs(totalArea, costST, 'cost8');
costs(totalWall, costST, 'cost8w');

document.getElementById('total9').innerHTML = totalArea;
document.getElementById('total9').value = totalArea;
document.getElementById('total9w').innerHTML = totalWall;
document.getElementById('total9w').value = totalWall;
costs(totalArea, costSR, 'cost9');
costs(totalWall, costSR, 'cost9w');

document.getElementById('total10').innerHTML = totalArea;
document.getElementById('total10').value = totalArea;
document.getElementById('total10w').innerHTML = totalWall;
document.getElementById('total10w').value = totalWall;
costs(totalArea, costJRSF2, 'cost10');
costs(totalWall, costJRSF2, 'cost10w');

document.getElementById('total11').innerHTML = totalArea;
document.getElementById('total11').value = totalArea;
document.getElementById('total11w').innerHTML = totalWall;
document.getElementById('total11w').value = totalWall;
costs(totalArea, costJRSF2by1, 'cost11');
costs(totalWall, costJRSF2by1, 'cost11w');

document.getElementById('total12').innerHTML = total1mby1mArea;
document.getElementById('total12').value = total1mby1mArea;
document.getElementById('total12w').innerHTML = total1mby1mWall;
document.getElementById('total12w').value = total1mby1mWall;

document.getElementById('lenght1mby1mArea').value = lenght1mby1mArea;
document.getElementById('width1mby1mArea').value = width1mby1mArea;
document.getElementById('lenght1mby1mWall').value = lenght1mby1mWall;
document.getElementById('width1mby1mWall').value = width1mby1mWall;

costs(total1mby1mArea, costJRSF1mby1m, 'cost12');
costs(total1mby1mWall, costJRSF1mby1m, 'cost12w');

document.getElementById('total13').innerHTML = total4by4Area;
document.getElementById('total13').value = total4by4Area;
document.getElementById('total13w').innerHTML = total4by4Wall;
document.getElementById('total13w').value = total4by4Wall;

document.getElementById('lenght4by4Area').value = lenght4by4Area;
document.getElementById('width4by4Area').value = width4by4Area;
document.getElementById('lenght4by4Wall').value = lenght4by4Wall;
document.getElementById('width4by4Wall').value = width4by4Wall;

costs(total4by4Area, costJRSF4, 'cost13');
costs(total4by4Wall, costJRSF4, 'cost13w');

document.getElementById('wyniki').style.visibility="visible";

}else{
alert('Please convert your dimensions to feet and inches');
}

}

function costs(total, price, id){

	var cost = addCommas((total * price).toFixed(2));
	document.getElementById(id).innerHTML = '$'+cost+'';
	document.getElementById(id).value = cost;
}

function countBoxes(totalArea, totalWall, pieces, thick1piece, weight1p, weight25p, widthTotal, heightTotal,thickTotal, costArea, costWall, sqft1, position, sqftOnePice, thickOnePiece, price, name, ident, header ){
	
	if(totalArea==0 || totalWall==0){
		alert('Insert dimensions');
	}else{
	
	 
		var lenghtArea = document.getElementById('lenghtArea').value;
		var widthArea = document.getElementById('widthArea').value;
		var lenghtWall = document.getElementById('lenghtWall').value;
		var widthWall = document.getElementById('widthWall').value;
		
		
		
		if(ident==0){
			var a =  document.getElementById(totalArea).value;
			var b = document.getElementById(totalWall).value;
			var lenghtArea = document.getElementById('lenghtArea').value;
			var widthArea = document.getElementById('widthArea').value;
			var lenghtWall = document.getElementById('lenghtWall').value;
			var widthWall = document.getElementById('widthWall').value;
			
			var corner =4;
			var borderArea = document.getElementById('borderArea').value;
			var insideArea =  document.getElementById('insideArea').value;
			var borderWall = document.getElementById('borderWall').value;
			var insideWall =  document.getElementById('insideWall').value;
			var textArea = '<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="http://www.alessco.com/images/breakdown.png"></span></div><div class="leftSide"><span class="popTextBlack">'+corner+' Corners + '+borderArea+ ' Borders + '+insideArea+' Insides = &nbsp;'+a+' Pieces</span></div>';
			var textWall = '<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="http://www.alessco.com/images/breakdown.png"></span></div><div class="leftSide"><span class="popTextBlack">'+corner+' Corners + '+borderWall+ ' Borders + '+insideWall+' Insides = &nbsp;'+b+' Pieces</span></div>';
			
		}else if(ident==2){
		var a =  document.getElementById(totalArea).value;
			var b = document.getElementById(totalWall).value;
			var textArea = '<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="http://www.alessco.com/images/breakdown.png"></span></div><div class="leftSide"><span class="popTextBlack">'+a/4+' Sets of 4 x 1\' x 1\' x 5/8 \" </span></div>';
			var textWall = '<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="http://www.alessco.com/images/breakdown.png"></span></div><div class="leftSide"><span class="popTextBlack">'+b/4+' Sets of 4 x 1\' x 1\' x 5/8 \"</span></div>';

                }
                else{
                
			var a =  document.getElementById(totalArea).value;
			var b = document.getElementById(totalWall).value;
			var textArea = '<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="http://www.alessco.com/images/breakdown.png"></span></div><div class="leftSide"><span class="popTextBlack">'+a+' Insides with detatchable Corner / Border pieces</span></div>';
			var textWall = '<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="http://www.alessco.com/images/breakdown.png"></span></div><div class="leftSide"><span class="popTextBlack">'+b+' Insides with detatchable Corner / Border piece</span></div>';
		}
		
		var totalArea = document.getElementById(totalArea).value;
		var costArea = document.getElementById(costArea).value;
		var totalWall = document.getElementById(totalWall).value;
		var costWall = document.getElementById(costWall).value;
		var sqftArea = Math.round(totalArea*sqft1);
		var sqftWall = Math.round(totalWall*sqft1);
		
		var count = 0;
		var count1 = 0;
		var totalWeightArea = 0;
		var totalWeightWall = 0;
		
		var masterCartonArea = Math.floor(totalArea/pieces);
		var partialCartonArea = totalArea - pieces*masterCartonArea;
		var masterCartonWall = Math.floor(totalWall/pieces);
		var partialCartonWall = totalWall - pieces*masterCartonWall;
		
                //AREA RUG HEADER
		var html = '<div class="popMainTitle"><img name="piecesImage" src="images/head'+header+'.png"></div>';
		html+= '<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/pieces.png"></span></div><div class="leftSide"><span class="popTextBlack">'+totalArea+'</span></div>';
		html+='<div>'+textArea+'</div>';
		html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/size.png"></span></div><div class="leftSide"><span class="popTextBlack">'+lenghtArea+'\' x '+widthArea+'\' = '+sqftArea+' sq.ft.</span></div>';
		html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/cost.png"></span></div><div class="leftSide"><span class="popTextRed">$'+	addCommas(costArea)+'&nbsp;&nbsp;&nbsp;($'+price+' sq.ft. or $'+(price*sqft1).toFixed(2)+' per piece)</span></div>';
		
		
		//FIRST CASE
		if(partialCartonArea != 0 && partialCartonWall != 0){
		var thickArea = Math.round(partialCartonArea*thick1piece);
		var weightArea = Math.round(partialCartonArea*weight1p);
		var thickWall =  Math.round(partialCartonWall*thick1piece);
		var weightWall = Math.round(partialCartonWall*weight1p);		
		count+=1;
		totalWeightArea+=weightArea;
		for(var i=1; i<=masterCartonArea; i++){
		var masterCarton1Area = pieces;
		j = i+1;
		
		count+=1;
		}
		totalWeightArea+=(count-1)*weight25p;
		if(count == 1){
		html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/box.png"></span></div><div class="leftSide"><span class="popTextBlack">1 of '+count+' &nbsp;&nbsp;&nbsp;'+partialCartonArea+' pieces &nbsp;&nbsp;'+widthTotal+'\" x '+heightTotal+'\" x '+thickArea+'\" &nbsp;&nbsp;'+Math.round(weightArea)+' lbs</span></div>';
		var boxA = 'box';
                }else{
                var boxA = 'boxes';
                html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/box.png"></span></div><div class="leftSide"><span class="popTextBlack"> 1 of '+count+' &nbsp;&nbsp;&nbsp;'+partialCartonArea+' pieces &nbsp;&nbsp;'+widthTotal+'\" x '+heightTotal+'\" x '+thickArea+'\" &nbsp;&nbsp;'+Math.round(weightArea)+' lbs</span></div>';
                html+='<div class="leftSide"><span class="popTextBlack"> 2 to '+count+' &nbsp;&nbsp;&nbsp;'+pieces+' pieces &nbsp;&nbsp;'+widthTotal+'\" x '+heightTotal+'\" x '+thickTotal+'\" &nbsp;&nbsp;&nbsp;'+weight25p+' lbs</span></div>';
                }
		html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/total.png"></span></div><div class="leftSide"><span class="popTextBlack">'+count+' '+boxA+' &nbsp;&nbsp;'+totalArea+' pieces &nbsp;&nbsp;'+totalWeightArea+' lbs</span></div>';
		
                //WALL TO WALL HEADER		
		html += '<div class="popMainTitle"><img name="piecesImage" src="images/head'+header+'a.png"></div>';
		html+= '<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/pieces.png"></span></div><div class="leftSide"><span class="popTextBlack">'+totalWall+'</span></div>';
		html+='<div>'+textWall+'</div>';
		html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/size.png"></span></div><div class="leftSide"><span class="popTextBlack">'+lenghtWall+'\' x '+widthWall+'\' = '+sqftWall+' sq.ft.</span></div>';
	        html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/cost.png"></span></div><div class="leftSide"><span class="popTextRed">$'+	addCommas(costWall)+'&nbsp;&nbsp;&nbsp;($'+price+' sq.ft. or $'+(price*sqft1).toFixed(2)+' per piece)</span></div>';
		
		//html+='<p>Box 1: &nbsp;&nbsp;'+partialCartonWall+' pieces &nbsp;&nbsp;'+widthTotal+'\" x '+heightTotal+'\" x '+thickWall+'\" &nbsp;&nbsp;'+Math.round(weightWall)+' lbs.</p>';
		count1+=1;
		totalWeightWall+=weightWall;
		for(var i=1; i<=masterCartonWall; i++){
		var masterCarton1Wall = pieces;
		k = i+1;
		/*html+='<p>Box '+k+': &nbsp;&nbsp;'+pieces+' pieces &nbsp;&nbsp;'+widthTotal+'\" x '+heightTotal+'\" x '+thickTotal+'\" &nbsp;&nbsp;'+weight25p+' lbs.</p>';*/
		count1+=1;
		}
		totalWeightWall+=(count1-1)*weight25p;
		if(count1 == 1){
		html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/box.png"></span></div><div class="leftSide"><span class="popTextBlack">1 of '+count1+' &nbsp;&nbsp;&nbsp;'+partialCartonWall+' pieces &nbsp;&nbsp;'+widthTotal+'\" x '+heightTotal+'\" x '+thickWall+'\" &nbsp;&nbsp;'+Math.round(weightWall)+' lbs</span></div>';
		var boxW = 'box';
                }else{
                var boxW = 'boxes';
                html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/box.png"></span></div><div class="leftSide"><span class="popTextBlack">1 of '+count+' &nbsp;&nbsp;&nbsp;'+partialCartonWall+' pieces &nbsp;&nbsp;'+widthTotal+'\" x '+heightTotal+'\" x '+thickWall+'\" &nbsp;&nbsp;'+Math.round(weightWall)+' lbs</span></div>';
                html+='<div class="leftSide"><span class="popTextBlack"> 2 to '+count1+'&nbsp;&nbsp;&nbsp;'+pieces+' pieces &nbsp;&nbsp;'+widthTotal+'\" x '+heightTotal+'\" x '+thickTotal+'\" &nbsp;&nbsp;&nbsp;'+weight25p+' lbs</span></div>';
                }
		html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/total.png"></span></div><div class="leftSide"><span class="popTextBlack">'+count1+' '+boxW+' &nbsp;&nbsp;'+totalWall+' pieces &nbsp;&nbsp;'+totalWeightWall+' lbs</span></div>';
		}

                //SECOND CASE
                else if(partialCartonArea != 0 && partialCartonWall == 0){
		var thickArea = Math.round(partialCartonArea*thick1piece);
		var weightArea = Math.round(partialCartonArea*weight1p);
		var thickWall =  Math.round(thickTotal);
		
		
		count+=1;
		totalWeightArea+=weightArea;
		for(var i=1; i<=masterCartonArea; i++){
		var masterCarton1Area = pieces;
		j = i+1;
		count+=1;
		}
		
		if(count == 1){
		html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/box.png"></span></div><div class="leftSide"><span class="popTextBlack">1 of '+count+' &nbsp;&nbsp;&nbsp;'+partialCartonArea+' pieces &nbsp;&nbsp;'+widthTotal+'\" x '+heightTotal+'\" x '+thickArea+'\" &nbsp;&nbsp;'+Math.round(weightArea)+' lbs</span></div>';
		var boxA = 'box';
                }else{
                var boxA = 'boxes';
                html+='<div class="rightSide"><span class="popTextGreyBold">BOX</span></div><div class="leftSide"><span class="popTextBlack"> 1 of '+count+' &nbsp;&nbsp;&nbsp;'+partialCartonArea+' pieces &nbsp;&nbsp;'+widthTotal+'\" x '+heightTotal+'\" x '+thickArea+'\" &nbsp;&nbsp;'+Math.round(weightArea)+' lbs</span></div>';
                html+='<div class="leftSide"><span class="popTextBlack"> 2 to '+count+' &nbsp;&nbsp;&nbsp;'+pieces+' pieces &nbsp;&nbsp;'+widthTotal+'\" x '+heightTotal+'\" x '+thickTotal+'\" &nbsp;&nbsp;&nbsp;'+weight25p+' lbs</span></div>';
                }
		totalWeightArea+=(count-1)*weight25p;
		html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/total.png"></span></div><div class="leftSide"><span class="popTextBlack">'+count+' '+boxA+' &nbsp;&nbsp;'+totalArea+' pieces &nbsp;&nbsp;'+totalWeightArea+' lbs</span></div>';
		
		//WALL TO WALL HEADER
                html += '<div class="popMainTitle"><img name="piecesImage" src="images/head'+header+'a.png"></div>';
		html+= '<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/pieces.png"></span></div><div class="leftSide"><span class="popTextBlack">'+totalWall+'</span></div>';
		html+='<div>'+textWall+'</div>';
		html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/size.png"></span></div><div class="leftSide"><span class="popTextBlack">'+lenghtWall+'\' x '+widthWall+'\' = '+sqftWall+' sq.ft.</span></div>';
	        html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/cost.png"></span></div><div class="leftSide"><span class="popTextRed">$'+	addCommas(costWall)+'&nbsp;&nbsp;&nbsp;($'+price+' sq.ft. or $'+(price*sqft1).toFixed(2)+' per piece)</span></div>';
		
                for(var i=1; i<=masterCartonWall; i++){
		k = i+1;
		
		count1+=1;
		}
		totalWeightWall+=(count1)*weight25p;
                if(count1 == 1){
                var boxW = 'box';
                html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/box.png"></span></div><div class="leftSide"><span class="popTextBlack">1 of '+count1+'&nbsp;&nbsp;&nbsp;'+pieces+' pieces &nbsp;&nbsp;'+widthTotal+'\" x '+heightTotal+'\" x '+thickTotal+'\" &nbsp;&nbsp;&nbsp;'+weight25p+' lbs</span></div>';
                }else{
                var boxW = 'boxes';
                html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/box.png"></span></div><div class="leftSide"><span class="popTextBlack">1 to '+count1+'&nbsp;&nbsp;&nbsp;'+pieces+' pieces &nbsp;&nbsp;'+widthTotal+'\" x '+heightTotal+'\" x '+thickTotal+'\" &nbsp;&nbsp;&nbsp;'+weight25p+' lbs</span></div>';
                }
		html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/total.png"></span></div><div class="leftSide"><span class="popTextBlack">'+count1+' '+boxW+' &nbsp;&nbsp;'+totalWall+' pieces &nbsp;&nbsp;'+totalWeightWall+' lbs</span></div>';
                }

                //THIRD CASE
                else if(partialCartonArea == 0 && partialCartonWall != 0){
		var thickWall =  Math.round(partialCartonWall*thick1piece);
		var weightWall = Math.round(partialCartonWall*weight1p);
		
                for(var i=1; i<=masterCartonArea; i++){
		count+=1;
		}
		totalWeightArea+=(count)*weight25p;
		if(count == 1){
                var boxA = 'box';
                html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/box.png"></span></div><div class="leftSide"><span class="popTextBlack">1 of '+count+'&nbsp;&nbsp;&nbsp;'+pieces+' pieces &nbsp;&nbsp;'+widthTotal+'\" x '+heightTotal+'\" x '+thickTotal+'\" &nbsp;&nbsp;&nbsp;'+weight25p+' lbs</span></div>';
                }else{
                var boxA = 'boxes';
                html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/box.png"></span></div><div class="leftSide"><span class="popTextBlack">1 to '+count+'&nbsp;&nbsp;&nbsp;'+pieces+' pieces &nbsp;&nbsp;'+widthTotal+'\" x '+heightTotal+'\" x '+thickTotal+'\" &nbsp;&nbsp;&nbsp;'+weight25p+' lbs</span></div>';
                }
		html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/total.png"></span></div><div class="leftSide"><span class="popTextBlack">'+count+' '+boxA+' &nbsp;&nbsp;'+totalArea+' pieces &nbsp;&nbsp;'+totalWeightArea+' lbs</span></div>';

	        //WALL TO WALL HEADER
		html += '<div class="popMainTitle"><img name="piecesImage" src="images/head'+header+'a.png"></div>';
		html+= '<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/pieces.png"></span></div><div class="leftSide"><span class="popTextBlack">'+totalWall+'</span></div>';
		html+='<div>'+textWall+'</div>';
		html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/size.png"></span></div><div class="leftSide"><span class="popTextBlack">'+lenghtWall+'\' x '+widthWall+'\' = '+sqftWall+' sq.ft.</span></div>';
	        html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/cost.png"></span></div><div class="leftSide"><span class="popTextRed">$'+	addCommas(costWall)+'&nbsp;&nbsp;&nbsp;($'+price+' sq.ft. or $'+(price*sqft1).toFixed(2)+' per piece)</span></div>';
		
		count1+=1;
		totalWeightWall+=weightWall;
		for(var i=1; i<=masterCartonWall; i++){
		var masterCarton1Wall = pieces;
		k = i+1;
		count1+=1;
		}
		totalWeightWall+=(count1-1)*weight25p;
		if(count1 == 1){
		html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/box.png"></span></div><div class="leftSide"><span class="popTextBlack">1 of '+count1+' &nbsp;&nbsp;&nbsp;'+partialCartonWall+' pieces &nbsp;&nbsp;'+widthTotal+'\" x '+heightTotal+'\" x '+thickWall+'\" &nbsp;&nbsp;'+Math.round(weightWall)+' lbs</span></div>';
		var boxW = 'box';
                }else{
                var boxW = 'boxes';
                html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/box.png"></span></div><div class="leftSide"><span class="popTextBlack">1 of '+count1+' &nbsp;&nbsp;&nbsp;'+partialCartonWall+' pieces &nbsp;&nbsp;'+widthTotal+'\" x '+heightTotal+'\" x '+thickWall+'\" &nbsp;&nbsp;'+Math.round(weightWall)+' lbs</span></div>';
                html+='<div class="leftSide"><span class="popTextBlack"> 2 to '+count1+' &nbsp;&nbsp;&nbsp;'+pieces+' pieces &nbsp;&nbsp;'+widthTotal+'\" x '+heightTotal+'\" x '+thickTotal+'\" &nbsp;&nbsp;&nbsp;'+weight25p+' lbs</span></div>';
                }
		html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/total.png"></span></div><div class="leftSide"><span class="popTextBlack">'+count1+' '+boxW+' &nbsp;&nbsp;'+totalWall+' pieces &nbsp;&nbsp;'+totalWeightWall+' lbs</span></div>';
		}

                //FOURTH CASE
                else if(partialCartonArea == 0 && partialCartonWall == 0){
		for(var i=1; i<=masterCartonArea; i++){
		count+=1;
		}
		totalWeightArea+=(count)*weight25p;
		if(count == 1){
                var boxA = 'box';
                html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/box.png"></span></div><div class="leftSide"><span class="popTextBlack">1 of '+count+'&nbsp;&nbsp;&nbsp;'+pieces+' pieces &nbsp;&nbsp;'+widthTotal+'\" x '+heightTotal+'\" x '+thickTotal+'\" &nbsp;&nbsp;&nbsp;'+weight25p+' lbs</span></div>';
                }else{
                var boxA = 'boxes';
                html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/box.png"></span></div><div class="leftSide"><span class="popTextBlack">1 to '+count+'&nbsp;&nbsp;&nbsp;'+pieces+' pieces &nbsp;&nbsp;'+widthTotal+'\" x '+heightTotal+'\" x '+thickTotal+'\" &nbsp;&nbsp;&nbsp;'+weight25p+' lbs</span></div>';
                }
		html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/total.png"></span></div><div class="leftSide"><span class="popTextBlack">'+count+' '+boxA+' &nbsp;&nbsp;'+totalArea+' pieces &nbsp;&nbsp;'+totalWeightArea+' lbs</span></div>';
		
		//WALL TO WALL HEADER
                html += '<div class="popMainTitle"><img name="piecesImage" src="images/head'+header+'a.png"></div>';
		html+= '<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/pieces.png"></span></div><div class="leftSide"><span class="popTextBlack">'+totalWall+'</span></div>';
                html+='<div>'+textWall+'</div>';
                html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/size.png"></span></div><div class="leftSide"><span class="popTextBlack">'+lenghtWall+'\' x '+widthWall+'\' = '+sqftWall+' sq.ft.</span></div>';
		html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/cost.png"></span></div><div class="leftSide"><span class="popTextRed">$'+	addCommas(costWall)+'&nbsp;&nbsp;&nbsp;($'+price+' sq.ft. or $'+(price*sqft1).toFixed(2)+' per piece)</span></div>';
                
		
		for(var i=1; i<=masterCartonWall; i++){
		k = i+1;
		/*html+='<p>Box '+k+': &nbsp;&nbsp;'+pieces+' pieces &nbsp;&nbsp;'+widthTotal+'\" x '+heightTotal+'\" x '+thickTotal+'\" &nbsp;&nbsp;'+weight25p+' lbs.</p>';*/
		count1+=1;
		}
		totalWeightWall+=(count1)*weight25p;
                if(count1 == 1){
                var boxW = 'box';
                html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/box.png"></span></div><div class="leftSide"><span class="popTextBlack">1 of '+count1+'&nbsp;&nbsp;&nbsp;'+pieces+' pieces &nbsp;&nbsp;'+widthTotal+'\" x '+heightTotal+'\" x '+thickTotal+'\" &nbsp;&nbsp;&nbsp;'+weight25p+' lbs</span></div>';
                }else{
                var boxW = 'boxes';
                html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/box.png"></span></div><div class="leftSide"><span class="popTextBlack">1 to '+count1+'&nbsp;&nbsp;&nbsp;'+pieces+' pieces &nbsp;&nbsp;'+widthTotal+'\" x '+heightTotal+'\" x '+thickTotal+'\" &nbsp;&nbsp;&nbsp;'+weight25p+' lbs</span></div>';
                }
		html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/total.png"></span></div><div class="leftSide"><span class="popTextBlack">'+count1+' '+boxW+' &nbsp;&nbsp;'+totalWall+' pieces &nbsp;&nbsp;'+totalWeightWall+' lbs</span></div>';
		}
		
		document.getElementById('boxes').innerHTML = html;
		document.getElementById('boxes').style.top = position;
		document.getElementById('boxes').style.visibility="visible";
		
		}
}
/**************************************************/
function countBoxes4(totalArea, totalWall, pieces, thick1piece, weight1p, weight25p, widthTotal, heightTotal,thickTotal, costArea, costWall, sqft1, position, sqftOnePice, thickOnePiece, price, name, ident, header ){
	
	if(totalArea==0 || totalWall==0){
		alert('Insert dimensions');
	}else{
		var lenghtArea = document.getElementById('lenght4by4Area').value;
		var widthArea = document.getElementById('width4by4Area').value;
		var lenghtWall = document.getElementById('lenght4by4Wall').value;
		var widthWall = document.getElementById('width4by4Wall').value;
		
		
		
		if(ident==0){
			var a =  document.getElementById(totalArea).value;
			var b = document.getElementById(totalWall).value;
			var lenghtArea = document.getElementById('lenghtArea').value;
			var widthArea = document.getElementById('widthArea').value;
			var lenghtWall = document.getElementById('lenghtWall').value;
			var widthWall = document.getElementById('widthWall').value;
			
			var corner =4;
			var borderArea = document.getElementById('borderArea').value;
			var insideArea =  document.getElementById('insideArea').value;
			var borderWall = document.getElementById('borderWall').value;
			var insideWall =  document.getElementById('insideWall').value;
			var textArea = '<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/breakdown.png"></span></div><div class="leftSide"><span class="popTextBlack">'+corner+' Corners + '+borderArea+ ' Borders + '+insideArea+' Insides = &nbsp;'+a+' Pieces</span></div>';
			var textWall = '<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/breakdown.png"></span></div><div class="leftSide"><span class="popTextBlack">'+corner+' Corners + '+borderWall+ ' Borders + '+insideWall+' Insides = &nbsp;'+b+' Pieces</span></div>';
			
		}else{
			var a =  document.getElementById(totalArea).value;
			var b = document.getElementById(totalWall).value;
			var textArea = '<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/breakdown.png"></span></div><div class="leftSide"><span class="popTextBlack">'+a+' Insides with detatchable Corner / Border pieces</span></div>';
			var textWall = '<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/breakdown.png"></span></div><div class="leftSide"><span class="popTextBlack">'+b+' Insides with detatchable Corner / Border piece</span></div>';
		}
		
		var totalArea = document.getElementById(totalArea).value;
		var costArea = document.getElementById(costArea).value;
		var totalWall = document.getElementById(totalWall).value;
		var costWall = document.getElementById(costWall).value;
		var sqftArea = Math.round(totalArea*sqft1);
		var sqftWall = Math.round(totalWall*sqft1);
		
		var count = 0;
		var count1 = 0;
		var totalWeightArea = 0;
		var totalWeightWall = 0;
		
		var masterCartonArea = Math.floor(totalArea/pieces);
		var partialCartonArea = totalArea - pieces*masterCartonArea;
		var masterCartonWall = Math.floor(totalWall/pieces);
		var partialCartonWall = totalWall - pieces*masterCartonWall;
		
                //AREA RUG HEADER
		var html = '<div class="popMainTitle"><img name="piecesImage" src="images/head'+header+'.png"></div>';
		html+= '<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/pieces.png"></span></div><div class="leftSide"><span class="popTextBlack">'+totalArea+'</span></div>';
		html+='<div>'+textArea+'</div>';
		html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/size.png"></span></div><div class="leftSide"><span class="popTextBlack">'+lenghtArea+'\' x '+widthArea+'\' = '+sqftArea+' sq.ft.</span></div>';
		html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/cost.png"></span></div><div class="leftSide"><span class="popTextRed">$'+	addCommas(costArea)+'&nbsp;&nbsp;&nbsp;($'+price+' sq.ft. or $'+(price*sqft1).toFixed(2)+' per piece)</span></div>';
		
		
		//FIRST CASE
		if(partialCartonArea != 0 && partialCartonWall != 0){
		var thickArea = Math.round(partialCartonArea*thick1piece);
		var weightArea = Math.round(partialCartonArea*weight1p);
		var thickWall =  Math.round(partialCartonWall*thick1piece);
		var weightWall = Math.round(partialCartonWall*weight1p);		
		count+=1;
		totalWeightArea+=weightArea;
		for(var i=1; i<=masterCartonArea; i++){
		var masterCarton1Area = pieces;
		j = i+1;
		
		count+=1;
		}
		totalWeightArea+=(count-1)*weight25p;
		if(count == 1){
		html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/box.png"></span></div><div class="leftSide"><span class="popTextBlack">1 of '+count+' &nbsp;&nbsp;&nbsp;'+partialCartonArea+' pieces &nbsp;&nbsp;'+widthTotal+'\" x '+heightTotal+'\" x '+thickArea+'\" &nbsp;&nbsp;'+Math.round(weightArea)+' lbs</span></div>';
		var boxA = 'box';
                }else{
                var boxA = 'boxes';
                html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/box.png"></span></div><div class="leftSide"><span class="popTextBlack"> 1 of '+count+' &nbsp;&nbsp;&nbsp;'+partialCartonArea+' pieces &nbsp;&nbsp;'+widthTotal+'\" x '+heightTotal+'\" x '+thickArea+'\" &nbsp;&nbsp;'+Math.round(weightArea)+' lbs</span></div>';
                html+='<div class="leftSide"><span class="popTextBlack"> 2 to '+count+' &nbsp;&nbsp;&nbsp;'+pieces+' pieces &nbsp;&nbsp;'+widthTotal+'\" x '+heightTotal+'\" x '+thickTotal+'\" &nbsp;&nbsp;&nbsp;'+weight25p+' lbs</span></div>';
                }
		html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/total.png"></span></div><div class="leftSide"><span class="popTextBlack">'+count+' '+boxA+' &nbsp;&nbsp;'+totalArea+' pieces &nbsp;&nbsp;'+totalWeightArea+' lbs</span></div>';
		
                //WALL TO WALL HEADER		
		html += '<div class="popMainTitle"><img name="piecesImage" src="images/head'+header+'a.png"></div>';
		html+= '<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/pieces.png"></span></div><div class="leftSide"><span class="popTextBlack">'+totalWall+'</span></div>';
		html+='<div>'+textWall+'</div>';
		html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/size.png"></span></div><div class="leftSide"><span class="popTextBlack">'+lenghtWall+'\' x '+widthWall+'\' = '+sqftWall+' sq.ft.</span></div>';
	        html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/cost.png"></span></div><div class="leftSide"><span class="popTextRed">$'+	addCommas(costWall)+'&nbsp;&nbsp;&nbsp;($'+price+' sq.ft. or $'+(price*sqft1).toFixed(2)+' per piece)</span></div>';
		
		//html+='<p>Box 1: &nbsp;&nbsp;'+partialCartonWall+' pieces &nbsp;&nbsp;'+widthTotal+'\" x '+heightTotal+'\" x '+thickWall+'\" &nbsp;&nbsp;'+Math.round(weightWall)+' lbs.</p>';
		count1+=1;
		totalWeightWall+=weightWall;
		for(var i=1; i<=masterCartonWall; i++){
		var masterCarton1Wall = pieces;
		k = i+1;
		/*html+='<p>Box '+k+': &nbsp;&nbsp;'+pieces+' pieces &nbsp;&nbsp;'+widthTotal+'\" x '+heightTotal+'\" x '+thickTotal+'\" &nbsp;&nbsp;'+weight25p+' lbs.</p>';*/
		count1+=1;
		}
		totalWeightWall+=(count1-1)*weight25p;
		if(count1 == 1){
		html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/box.png"></span></div><div class="leftSide"><span class="popTextBlack">1 of '+count1+' &nbsp;&nbsp;&nbsp;'+partialCartonWall+' pieces &nbsp;&nbsp;'+widthTotal+'\" x '+heightTotal+'\" x '+thickWall+'\" &nbsp;&nbsp;'+Math.round(weightWall)+' lbs</span></div>';
		var boxW = 'box';
                }else{
                var boxW = 'boxes';
                html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/box.png"></span></div><div class="leftSide"><span class="popTextBlack">1 of '+count+' &nbsp;&nbsp;&nbsp;'+partialCartonWall+' pieces &nbsp;&nbsp;'+widthTotal+'\" x '+heightTotal+'\" x '+thickWall+'\" &nbsp;&nbsp;'+Math.round(weightWall)+' lbs</span></div>';
                html+='<div class="leftSide"><span class="popTextBlack"> 2 to '+count1+'&nbsp;&nbsp;&nbsp;'+pieces+' pieces &nbsp;&nbsp;'+widthTotal+'\" x '+heightTotal+'\" x '+thickTotal+'\" &nbsp;&nbsp;&nbsp;'+weight25p+' lbs</span></div>';
                }
		html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/total.png"></span></div><div class="leftSide"><span class="popTextBlack">'+count1+' '+boxW+' &nbsp;&nbsp;'+totalWall+' pieces &nbsp;&nbsp;'+totalWeightWall+' lbs</span></div>';
		}

                //SECOND CASE
                else if(partialCartonArea != 0 && partialCartonWall == 0){
		var thickArea = Math.round(partialCartonArea*thick1piece);
		var weightArea = Math.round(partialCartonArea*weight1p);
		var thickWall =  Math.round(thickTotal);
		
		
		count+=1;
		totalWeightArea+=weightArea;
		for(var i=1; i<=masterCartonArea; i++){
		var masterCarton1Area = pieces;
		j = i+1;
		count+=1;
		}
		
		if(count == 1){
		html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/box.png"></span></div><div class="leftSide"><span class="popTextBlack">1 of '+count+' &nbsp;&nbsp;&nbsp;'+partialCartonArea+' pieces &nbsp;&nbsp;'+widthTotal+'\" x '+heightTotal+'\" x '+thickArea+'\" &nbsp;&nbsp;'+Math.round(weightArea)+' lbs</span></div>';
		var boxA = 'box';
                }else{
                var boxA = 'boxes';
                html+='<div class="rightSide"><span class="popTextGreyBold">BOX</span></div><div class="leftSide"><span class="popTextBlack"> 1 of '+count+' &nbsp;&nbsp;&nbsp;'+partialCartonArea+' pieces &nbsp;&nbsp;'+widthTotal+'\" x '+heightTotal+'\" x '+thickArea+'\" &nbsp;&nbsp;'+Math.round(weightArea)+' lbs</span></div>';
                html+='<div class="leftSide"><span class="popTextBlack"> 2 to '+count+' &nbsp;&nbsp;&nbsp;'+pieces+' pieces &nbsp;&nbsp;'+widthTotal+'\" x '+heightTotal+'\" x '+thickTotal+'\" &nbsp;&nbsp;&nbsp;'+weight25p+' lbs</span></div>';
                }
		totalWeightArea+=(count-1)*weight25p;
		html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/total.png"></span></div><div class="leftSide"><span class="popTextBlack">'+count+' '+boxA+' &nbsp;&nbsp;'+totalArea+' pieces &nbsp;&nbsp;'+totalWeightArea+' lbs</span></div>';
		
		//WALL TO WALL HEADER
                html += '<div class="popMainTitle"><img name="piecesImage" src="images/head'+header+'a.png"></div>';
		html+= '<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/pieces.png"></span></div><div class="leftSide"><span class="popTextBlack">'+totalWall+'</span></div>';
		html+='<div>'+textWall+'</div>';
		html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/size.png"></span></div><div class="leftSide"><span class="popTextBlack">'+lenghtWall+'\' x '+widthWall+'\' = '+sqftWall+' sq.ft.</span></div>';
	        html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/cost.png"></span></div><div class="leftSide"><span class="popTextRed">$'+	addCommas(costWall)+'&nbsp;&nbsp;&nbsp;($'+price+' sq.ft. or $'+(price*sqft1).toFixed(2)+' per piece)</span></div>';
		
                for(var i=1; i<=masterCartonWall; i++){
		k = i+1;
		
		count1+=1;
		}
		totalWeightWall+=(count1)*weight25p;
                if(count1 == 1){
                var boxW = 'box';
                html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/box.png"></span></div><div class="leftSide"><span class="popTextBlack">1 of '+count1+'&nbsp;&nbsp;&nbsp;'+pieces+' pieces &nbsp;&nbsp;'+widthTotal+'\" x '+heightTotal+'\" x '+thickTotal+'\" &nbsp;&nbsp;&nbsp;'+weight25p+' lbs</span></div>';
                }else{
                var boxW = 'boxes';
                html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/box.png"></span></div><div class="leftSide"><span class="popTextBlack">1 to '+count1+'&nbsp;&nbsp;&nbsp;'+pieces+' pieces &nbsp;&nbsp;'+widthTotal+'\" x '+heightTotal+'\" x '+thickTotal+'\" &nbsp;&nbsp;&nbsp;'+weight25p+' lbs</span></div>';
                }
		html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/total.png"></span></div><div class="leftSide"><span class="popTextBlack">'+count1+' '+boxW+' &nbsp;&nbsp;'+totalWall+' pieces &nbsp;&nbsp;'+totalWeightWall+' lbs</span></div>';
                }

                //THIRD CASE
                else if(partialCartonArea == 0 && partialCartonWall != 0){
		var thickWall =  Math.round(partialCartonWall*thick1piece);
		var weightWall = Math.round(partialCartonWall*weight1p);
		
                for(var i=1; i<=masterCartonArea; i++){
		count+=1;
		}
		totalWeightArea+=(count)*weight25p;
		if(count == 1){
                var boxA = 'box';
                html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/box.png"></span></div><div class="leftSide"><span class="popTextBlack">1 of '+count+'&nbsp;&nbsp;&nbsp;'+pieces+' pieces &nbsp;&nbsp;'+widthTotal+'\" x '+heightTotal+'\" x '+thickTotal+'\" &nbsp;&nbsp;&nbsp;'+weight25p+' lbs</span></div>';
                }else{
                var boxA = 'boxes';
                html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/box.png"></span></div><div class="leftSide"><span class="popTextBlack">1 to '+count+'&nbsp;&nbsp;&nbsp;'+pieces+' pieces &nbsp;&nbsp;'+widthTotal+'\" x '+heightTotal+'\" x '+thickTotal+'\" &nbsp;&nbsp;&nbsp;'+weight25p+' lbs</span></div>';
                }
		html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/total.png"></span></div><div class="leftSide"><span class="popTextBlack">'+count+' '+boxA+' &nbsp;&nbsp;'+totalArea+' pieces &nbsp;&nbsp;'+totalWeightArea+' lbs</span></div>';

	        //WALL TO WALL HEADER
		html += '<div class="popMainTitle"><img name="piecesImage" src="images/head'+header+'a.png"></div>';
		html+= '<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/pieces.png"></span></div><div class="leftSide"><span class="popTextBlack">'+totalWall+'</span></div>';
		html+='<div>'+textWall+'</div>';
		html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/size.png"></span></div><div class="leftSide"><span class="popTextBlack">'+lenghtWall+'\' x '+widthWall+'\' = '+sqftWall+' sq.ft.</span></div>';
	        html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/cost.png"></span></div><div class="leftSide"><span class="popTextRed">$'+	addCommas(costWall)+'&nbsp;&nbsp;&nbsp;($'+price+' sq.ft. or $'+(price*sqft1).toFixed(2)+' per piece)</span></div>';
		
		count1+=1;
		totalWeightWall+=weightWall;
		for(var i=1; i<=masterCartonWall; i++){
		var masterCarton1Wall = pieces;
		k = i+1;
		count1+=1;
		}
		totalWeightWall+=(count1-1)*weight25p;
		if(count1 == 1){
		html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/box.png"></span></div><div class="leftSide"><span class="popTextBlack">1 of '+count1+' &nbsp;&nbsp;&nbsp;'+partialCartonWall+' pieces &nbsp;&nbsp;'+widthTotal+'\" x '+heightTotal+'\" x '+thickWall+'\" &nbsp;&nbsp;'+Math.round(weightWall)+' lbs</span></div>';
		var boxW = 'box';
                }else{
                var boxW = 'boxes';
                html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/box.png"></span></div><div class="leftSide"><span class="popTextBlack">1 of '+count1+' &nbsp;&nbsp;&nbsp;'+partialCartonWall+' pieces &nbsp;&nbsp;'+widthTotal+'\" x '+heightTotal+'\" x '+thickWall+'\" &nbsp;&nbsp;'+Math.round(weightWall)+' lbs</span></div>';
                html+='<div class="leftSide"><span class="popTextBlack"> 2 to '+count1+' &nbsp;&nbsp;&nbsp;'+pieces+' pieces &nbsp;&nbsp;'+widthTotal+'\" x '+heightTotal+'\" x '+thickTotal+'\" &nbsp;&nbsp;&nbsp;'+weight25p+' lbs</span></div>';
                }
		html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/total.png"></span></div><div class="leftSide"><span class="popTextBlack">'+count1+' '+boxW+' &nbsp;&nbsp;'+totalWall+' pieces &nbsp;&nbsp;'+totalWeightWall+' lbs</span></div>';
		}

                //FOURTH CASE
                else if(partialCartonArea == 0 && partialCartonWall == 0){
		for(var i=1; i<=masterCartonArea; i++){
		count+=1;
		}
		totalWeightArea+=(count)*weight25p;
		if(count == 1){
                var boxA = 'box';
                html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/box.png"></span></div><div class="leftSide"><span class="popTextBlack">1 of '+count+'&nbsp;&nbsp;&nbsp;'+pieces+' pieces &nbsp;&nbsp;'+widthTotal+'\" x '+heightTotal+'\" x '+thickTotal+'\" &nbsp;&nbsp;&nbsp;'+weight25p+' lbs</span></div>';
                }else{
                var boxA = 'boxes';
                html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/box.png"></span></div><div class="leftSide"><span class="popTextBlack">1 to '+count+'&nbsp;&nbsp;&nbsp;'+pieces+' pieces &nbsp;&nbsp;'+widthTotal+'\" x '+heightTotal+'\" x '+thickTotal+'\" &nbsp;&nbsp;&nbsp;'+weight25p+' lbs</span></div>';
                }
		html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/total.png"></span></div><div class="leftSide"><span class="popTextBlack">'+count+' '+boxA+' &nbsp;&nbsp;'+totalArea+' pieces &nbsp;&nbsp;'+totalWeightArea+' lbs</span></div>';
		
		//WALL TO WALL HEADER
                html += '<div class="popMainTitle"><img name="piecesImage" src="images/head'+header+'a.png"></div>';
		html+= '<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/pieces.png"></span></div><div class="leftSide"><span class="popTextBlack">'+totalWall+'</span></div>';
                html+='<div>'+textWall+'</div>';
                html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/size.png"></span></div><div class="leftSide"><span class="popTextBlack">'+lenghtWall+'\' x '+widthWall+'\' = '+sqftWall+' sq.ft.</span></div>';
		html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/cost.png"></span></div><div class="leftSide"><span class="popTextRed">$'+	addCommas(costWall)+'&nbsp;&nbsp;&nbsp;($'+price+' sq.ft. or $'+(price*sqft1).toFixed(2)+' per piece)</span></div>';

		
		for(var i=1; i<=masterCartonWall; i++){
		k = i+1;
		/*html+='<p>Box '+k+': &nbsp;&nbsp;'+pieces+' pieces &nbsp;&nbsp;'+widthTotal+'\" x '+heightTotal+'\" x '+thickTotal+'\" &nbsp;&nbsp;'+weight25p+' lbs.</p>';*/
		count1+=1;
		}
		totalWeightWall+=(count1)*weight25p;
                if(count1 == 1){
                var boxW = 'box';
                html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/box.png"></span></div><div class="leftSide"><span class="popTextBlack">1 of '+count1+'&nbsp;&nbsp;&nbsp;'+pieces+' pieces &nbsp;&nbsp;'+widthTotal+'\" x '+heightTotal+'\" x '+thickTotal+'\" &nbsp;&nbsp;&nbsp;'+weight25p+' lbs</span></div>';
                }else{
                var boxW = 'boxes';
                html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/box.png"></span></div><div class="leftSide"><span class="popTextBlack">1 to '+count1+'&nbsp;&nbsp;&nbsp;'+pieces+' pieces &nbsp;&nbsp;'+widthTotal+'\" x '+heightTotal+'\" x '+thickTotal+'\" &nbsp;&nbsp;&nbsp;'+weight25p+' lbs</span></div>';
                }
		html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/total.png"></span></div><div class="leftSide"><span class="popTextBlack">'+count1+' '+boxW+' &nbsp;&nbsp;'+totalWall+' pieces &nbsp;&nbsp;'+totalWeightWall+' lbs</span></div>';
		}
		
		document.getElementById('boxes').innerHTML = html;
		document.getElementById('boxes').style.top = position;
		document.getElementById('boxes').style.visibility="visible";
		
		
		}
}
/******************************************************/
function countBoxes1(totalArea, totalWall, pieces, thick1piece, weight1p, weight25p, widthTotal, heightTotal,thickTotal, costArea, costWall, sqft1, position, sqftOnePice, thickOnePiece, price, name, ident, header ){
	
	if(totalArea==0 || totalWall==0){
		alert('Insert dimensions');
	}else{
	
		var lenghtArea = document.getElementById('lenght1mby1mArea').value;
		var widthArea = document.getElementById('width1mby1mArea').value;
		var lenghtWall = document.getElementById('lenght1mby1mWall').value;
		var widthWall = document.getElementById('width1mby1mWall').value;
		
		var lenghtAreaFeet =  Math.floor(lenghtArea);
		var lenghtAreaInch =  ((lenghtArea - lenghtAreaFeet)*12).toFixed(0);
		var widthAreaFeet = Math.floor(widthArea);
		var widthAreaInch =  ((widthArea - widthAreaFeet)*12).toFixed(0);
                var lenghtWallFeet =  Math.floor(lenghtWall);
		var lenghtWallInch =  ((lenghtWall - lenghtWallFeet)*12).toFixed(0);
		var widthWallFeet = Math.floor(widthWall);
		var widthWallInch =  ((widthWall - widthWallFeet)*12).toFixed(0);
		
		if(ident==0){
			var a =  document.getElementById(totalArea).value;
			var b = document.getElementById(totalWall).value;
			var lenghtArea = document.getElementById('lenghtArea').value;
			var widthArea = document.getElementById('widthArea').value;
			var lenghtWall = document.getElementById('lenghtWall').value;
			var widthWall = document.getElementById('widthWall').value;
			
			var corner =4;
			var borderArea = document.getElementById('borderArea').value;
			var insideArea =  document.getElementById('insideArea').value;
			var borderWall = document.getElementById('borderWall').value;
			var insideWall =  document.getElementById('insideWall').value;
			var textArea = '<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/breakdown.png"></span></div><div class="leftSide"><span class="popTextBlack">'+corner+' Corners + '+borderArea+ ' Borders + '+insideArea+' Insides = &nbsp;'+a+' Pieces</span></div>';
			var textWall = '<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/breakdown.png"></span></div><div class="leftSide"><span class="popTextBlack">'+corner+' Corners + '+borderWall+ ' Borders + '+insideWall+' Insides = &nbsp;'+b+' Pieces</span></div>';
			
		}else{
			var a =  document.getElementById(totalArea).value;
			var b = document.getElementById(totalWall).value;
			var textArea = '<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/breakdown.png"></span></div><div class="leftSide"><span class="popTextBlack">'+a+' Insides with detatchable Corner / Border pieces</span></div>';
			var textWall = '<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/breakdown.png"></span></div><div class="leftSide"><span class="popTextBlack">'+b+' Insides with detatchable Corner / Border piece</span></div>';
		}
		
		var totalArea = document.getElementById(totalArea).value;
		var costArea = document.getElementById(costArea).value;
		var totalWall = document.getElementById(totalWall).value;
		var costWall = document.getElementById(costWall).value;
		var sqftArea = Math.round(totalArea*sqft1);
		var sqftWall = Math.round(totalWall*sqft1);
		
		var count = 0;
		var count1 = 0;
		var totalWeightArea = 0;
		var totalWeightWall = 0;
		
		var masterCartonArea = Math.floor(totalArea/pieces);
		var partialCartonArea = totalArea - pieces*masterCartonArea;
		var masterCartonWall = Math.floor(totalWall/pieces);
		var partialCartonWall = totalWall - pieces*masterCartonWall;
		
                //AREA RUG HEADER
		var html = '<div class="popMainTitle"><img name="piecesImage" src="images/head'+header+'.png"></div>';
		html+= '<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/pieces.png"></span></div><div class="leftSide"><span class="popTextBlack">'+totalArea+'</span></div>';
		html+='<div>'+textArea+'</div>';
		html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/size.png"></span></div><div class="leftSide"><span class="popTextBlack">'+lenghtAreaFeet+'\' '+lenghtAreaInch+'\" x '+widthAreaFeet+'\' '+widthAreaInch+'\" = '+sqftArea+' sq.ft.</span></div>';
		html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/cost.png"></span></div><div class="leftSide"><span class="popTextRed">$'+addCommas(costArea)+'&nbsp;&nbsp;&nbsp;($'+price+' sq.ft. or $'+(price*sqft1).toFixed(2)+' per piece)</span></div>';
		
		
		//FIRST CASE
		if(partialCartonArea != 0 && partialCartonWall != 0){
		var thickArea = Math.round(partialCartonArea*thick1piece);
		var weightArea = Math.round(partialCartonArea*weight1p);
		var thickWall =  Math.round(partialCartonWall*thick1piece);
		var weightWall = Math.round(partialCartonWall*weight1p);		
		count+=1;
		totalWeightArea+=weightArea;
		for(var i=1; i<=masterCartonArea; i++){
		var masterCarton1Area = pieces;
		j = i+1;
		
		count+=1;
		}
		totalWeightArea+=(count-1)*weight25p;
		if(count == 1){
		html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/box.png"></span></div><div class="leftSide"><span class="popTextBlack">1 of '+count+' &nbsp;&nbsp;&nbsp;'+partialCartonArea+' pieces &nbsp;&nbsp;'+widthTotal+'\" x '+heightTotal+'\" x '+thickArea+'\" &nbsp;&nbsp;'+Math.round(weightArea)+' lbs</span></div>';
		var boxA = 'box';
                }else{
                var boxA = 'boxes';
                html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/box.png"></span></div><div class="leftSide"><span class="popTextBlack"> 1 of '+count+' &nbsp;&nbsp;&nbsp;'+partialCartonArea+' pieces &nbsp;&nbsp;'+widthTotal+'\" x '+heightTotal+'\" x '+thickArea+'\" &nbsp;&nbsp;'+Math.round(weightArea)+' lbs</span></div>';
                html+='<div class="leftSide"><span class="popTextBlack"> 2 to '+count+' &nbsp;&nbsp;&nbsp;'+pieces+' pieces &nbsp;&nbsp;'+widthTotal+'\" x '+heightTotal+'\" x '+thickTotal+'\" &nbsp;&nbsp;&nbsp;'+weight25p+' lbs</span></div>';
                }
		html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/total.png"></span></div><div class="leftSide"><span class="popTextBlack">'+count+' '+boxA+' &nbsp;&nbsp;'+totalArea+' pieces &nbsp;&nbsp;'+totalWeightArea+' lbs</span></div>';
		
                //WALL TO WALL HEADER		
		html += '<div class="popMainTitle"><img name="piecesImage" src="images/head'+header+'a.png"></div>';
		html+= '<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/pieces.png"></span></div><div class="leftSide"><span class="popTextBlack">'+totalWall+'</span></div>';
		html+='<div>'+textWall+'</div>';
		html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/size.png"></span></div><div class="leftSide"><span class="popTextBlack">'+lenghtWallFeet+'\' '+lenghtWallInch+'\" x '+widthWallFeet+'\' '+widthWallInch+'\" = '+sqftWall+' sq.ft.</span></div>';
	        html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/cost.png"></span></div><div class="leftSide"><span class="popTextRed">$'+	addCommas(costWall)+'&nbsp;&nbsp;&nbsp;($'+price+' sq.ft. or $'+(price*sqft1).toFixed(2)+' per piece)</span></div>';
		
		//html+='<p>Box 1: &nbsp;&nbsp;'+partialCartonWall+' pieces &nbsp;&nbsp;'+widthTotal+'\" x '+heightTotal+'\" x '+thickWall+'\" &nbsp;&nbsp;'+Math.round(weightWall)+' lbs.</p>';
		count1+=1;
		totalWeightWall+=weightWall;
		for(var i=1; i<=masterCartonWall; i++){
		var masterCarton1Wall = pieces;
		k = i+1;
		/*html+='<p>Box '+k+': &nbsp;&nbsp;'+pieces+' pieces &nbsp;&nbsp;'+widthTotal+'\" x '+heightTotal+'\" x '+thickTotal+'\" &nbsp;&nbsp;'+weight25p+' lbs.</p>';*/
		count1+=1;
		}
		totalWeightWall+=(count1-1)*weight25p;
		if(count1 == 1){
		html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/box.png"></span></div><div class="leftSide"><span class="popTextBlack">1 of '+count1+' &nbsp;&nbsp;&nbsp;'+partialCartonWall+' pieces &nbsp;&nbsp;'+widthTotal+'\" x '+heightTotal+'\" x '+thickWall+'\" &nbsp;&nbsp;'+Math.round(weightWall)+' lbs</span></div>';
		var boxW = 'box';
                }else{
                var boxW = 'boxes';
                html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/box.png"></span></div><div class="leftSide"><span class="popTextBlack">1 of '+count+' &nbsp;&nbsp;&nbsp;'+partialCartonWall+' pieces &nbsp;&nbsp;'+widthTotal+'\" x '+heightTotal+'\" x '+thickWall+'\" &nbsp;&nbsp;'+Math.round(weightWall)+' lbs</span></div>';
                html+='<div class="leftSide"><span class="popTextBlack"> 2 to '+count1+'&nbsp;&nbsp;&nbsp;'+pieces+' pieces &nbsp;&nbsp;'+widthTotal+'\" x '+heightTotal+'\" x '+thickTotal+'\" &nbsp;&nbsp;&nbsp;'+weight25p+' lbs</span></div>';
                }
		html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/total.png"></span></div><div class="leftSide"><span class="popTextBlack">'+count1+' '+boxW+' &nbsp;&nbsp;'+totalWall+' pieces &nbsp;&nbsp;'+totalWeightWall+' lbs</span></div>';
		}

                //SECOND CASE
                else if(partialCartonArea != 0 && partialCartonWall == 0){
		var thickArea = Math.round(partialCartonArea*thick1piece);
		var weightArea = Math.round(partialCartonArea*weight1p);
		var thickWall =  Math.round(thickTotal);
		
		
		count+=1;
		totalWeightArea+=weightArea;
		for(var i=1; i<=masterCartonArea; i++){
		var masterCarton1Area = pieces;
		j = i+1;
		count+=1;
		}
		
		if(count == 1){
		html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/box.png"></span></div><div class="leftSide"><span class="popTextBlack">1 of '+count+' &nbsp;&nbsp;&nbsp;'+partialCartonArea+' pieces &nbsp;&nbsp;'+widthTotal+'\" x '+heightTotal+'\" x '+thickArea+'\" &nbsp;&nbsp;'+Math.round(weightArea)+' lbs</span></div>';
		var boxA = 'box';
                }else{
                var boxA = 'boxes';
                html+='<div class="rightSide"><span class="popTextGreyBold">BOX</span></div><div class="leftSide"><span class="popTextBlack"> 1 of '+count+' &nbsp;&nbsp;&nbsp;'+partialCartonArea+' pieces &nbsp;&nbsp;'+widthTotal+'\" x '+heightTotal+'\" x '+thickArea+'\" &nbsp;&nbsp;'+Math.round(weightArea)+' lbs</span></div>';
                html+='<div class="leftSide"><span class="popTextBlack"> 2 to '+count+' &nbsp;&nbsp;&nbsp;'+pieces+' pieces &nbsp;&nbsp;'+widthTotal+'\" x '+heightTotal+'\" x '+thickTotal+'\" &nbsp;&nbsp;&nbsp;'+weight25p+' lbs</span></div>';
                }
		totalWeightArea+=(count-1)*weight25p;
		html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/total.png"></span></div><div class="leftSide"><span class="popTextBlack">'+count+' '+boxA+' &nbsp;&nbsp;'+totalArea+' pieces &nbsp;&nbsp;'+totalWeightArea+' lbs</span></div>';
		
		//WALL TO WALL HEADER
                html += '<div class="popMainTitle"><img name="piecesImage" src="images/head'+header+'a.png"></div>';
		html+= '<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/pieces.png"></span></div><div class="leftSide"><span class="popTextBlack">'+totalWall+'</span></div>';
		html+='<div>'+textWall+'</div>';
		html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/size.png"></span></div><div class="leftSide"><span class="popTextBlack">'+lenghtWallFeet+'\' '+lenghtWallInch+'\" x '+widthWallFeet+'\' '+widthWallInch+'\" = '+sqftWall+' sq.ft.</span></div>';
	        html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/cost.png"></span></div><div class="leftSide"><span class="popTextRed">$'+	addCommas(costWall)+'&nbsp;&nbsp;&nbsp;($'+price+' sq.ft. or $'+(price*sqft1).toFixed(2)+' per piece)</span></div>';
		
                for(var i=1; i<=masterCartonWall; i++){
		k = i+1;
		
		count1+=1;
		}
		totalWeightWall+=(count1)*weight25p;
                if(count1 == 1){
                var boxW = 'box';
                html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/box.png"></span></div><div class="leftSide"><span class="popTextBlack">1 of '+count1+'&nbsp;&nbsp;&nbsp;'+pieces+' pieces &nbsp;&nbsp;'+widthTotal+'\" x '+heightTotal+'\" x '+thickTotal+'\" &nbsp;&nbsp;&nbsp;'+weight25p+' lbs</span></div>';
                }else{
                var boxW = 'boxes';
                html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/box.png"></span></div><div class="leftSide"><span class="popTextBlack">1 to '+count1+'&nbsp;&nbsp;&nbsp;'+pieces+' pieces &nbsp;&nbsp;'+widthTotal+'\" x '+heightTotal+'\" x '+thickTotal+'\" &nbsp;&nbsp;&nbsp;'+weight25p+' lbs</span></div>';
                }
		html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/total.png"></span></div><div class="leftSide"><span class="popTextBlack">'+count1+' '+boxW+' &nbsp;&nbsp;'+totalWall+' pieces &nbsp;&nbsp;'+totalWeightWall+' lbs</span></div>';
                }

                //THIRD CASE
                else if(partialCartonArea == 0 && partialCartonWall != 0){
		var thickWall =  Math.round(partialCartonWall*thick1piece);
		var weightWall = Math.round(partialCartonWall*weight1p);
		
                for(var i=1; i<=masterCartonArea; i++){
		count+=1;
		}
		totalWeightArea+=(count)*weight25p;
		if(count == 1){
                var boxA = 'box';
                html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/box.png"></span></div><div class="leftSide"><span class="popTextBlack">1 of '+count+'&nbsp;&nbsp;&nbsp;'+pieces+' pieces &nbsp;&nbsp;'+widthTotal+'\" x '+heightTotal+'\" x '+thickTotal+'\" &nbsp;&nbsp;&nbsp;'+weight25p+' lbs</span></div>';
                }else{
                var boxA = 'boxes';
                html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/box.png"></span></div><div class="leftSide"><span class="popTextBlack">1 to '+count+'&nbsp;&nbsp;&nbsp;'+pieces+' pieces &nbsp;&nbsp;'+widthTotal+'\" x '+heightTotal+'\" x '+thickTotal+'\" &nbsp;&nbsp;&nbsp;'+weight25p+' lbs</span></div>';
                }
		html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/total.png"></span></div><div class="leftSide"><span class="popTextBlack">'+count+' '+boxA+' &nbsp;&nbsp;'+totalArea+' pieces &nbsp;&nbsp;'+totalWeightArea+' lbs</span></div>';

	        //WALL TO WALL HEADER
		html += '<div class="popMainTitle"><img name="piecesImage" src="images/head'+header+'a.png"></div>';
		html+= '<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/pieces.png"></span></div><div class="leftSide"><span class="popTextBlack">'+totalWall+'</span></div>';
		html+='<div>'+textWall+'</div>';
		html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/size.png"></span></div><div class="leftSide"><span class="popTextBlack">'+lenghtWallFeet+'\' '+lenghtWallInch+'\" x '+widthWallFeet+'\' '+widthWallInch+'\" = '+sqftWall+' sq.ft.</span></div>';
	        html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/cost.png"></span></div><div class="leftSide"><span class="popTextRed">$'+	addCommas(costWall)+'&nbsp;&nbsp;&nbsp;($'+price+' sq.ft. or $'+(price*sqft1).toFixed(2)+' per piece)</span></div>';
		
		count1+=1;
		totalWeightWall+=weightWall;
		for(var i=1; i<=masterCartonWall; i++){
		var masterCarton1Wall = pieces;
		k = i+1;
		count1+=1;
		}
		totalWeightWall+=(count1-1)*weight25p;
		if(count1 == 1){
		html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/box.png"></span></div><div class="leftSide"><span class="popTextBlack">1 of '+count1+' &nbsp;&nbsp;&nbsp;'+partialCartonWall+' pieces &nbsp;&nbsp;'+widthTotal+'\" x '+heightTotal+'\" x '+thickWall+'\" &nbsp;&nbsp;'+Math.round(weightWall)+' lbs</span></div>';
		var boxW = 'box';
                }else{
                var boxW = 'boxes';
                html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/box.png"></span></div><div class="leftSide"><span class="popTextBlack">1 of '+count1+' &nbsp;&nbsp;&nbsp;'+partialCartonWall+' pieces &nbsp;&nbsp;'+widthTotal+'\" x '+heightTotal+'\" x '+thickWall+'\" &nbsp;&nbsp;'+Math.round(weightWall)+' lbs</span></div>';
                html+='<div class="leftSide"><span class="popTextBlack"> 2 to '+count1+' &nbsp;&nbsp;&nbsp;'+pieces+' pieces &nbsp;&nbsp;'+widthTotal+'\" x '+heightTotal+'\" x '+thickTotal+'\" &nbsp;&nbsp;&nbsp;'+weight25p+' lbs</span></div>';
                }
		html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/total.png"></span></div><div class="leftSide"><span class="popTextBlack">'+count1+' '+boxW+' &nbsp;&nbsp;'+totalWall+' pieces &nbsp;&nbsp;'+totalWeightWall+' lbs</span></div>';
		}

                //FOURTH CASE
                else if(partialCartonArea == 0 && partialCartonWall == 0){
		for(var i=1; i<=masterCartonArea; i++){
		count+=1;
		}
		totalWeightArea+=(count)*weight25p;
		if(count == 1){
                var boxA = 'box';
                html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/box.png"></span></div><div class="leftSide"><span class="popTextBlack">1 of '+count+'&nbsp;&nbsp;&nbsp;'+pieces+' pieces &nbsp;&nbsp;'+widthTotal+'\" x '+heightTotal+'\" x '+thickTotal+'\" &nbsp;&nbsp;&nbsp;'+weight25p+' lbs</span></div>';
                }else{
                var boxA = 'boxes';
                html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/box.png"></span></div><div class="leftSide"><span class="popTextBlack">1 to '+count+'&nbsp;&nbsp;&nbsp;'+pieces+' pieces &nbsp;&nbsp;'+widthTotal+'\" x '+heightTotal+'\" x '+thickTotal+'\" &nbsp;&nbsp;&nbsp;'+weight25p+' lbs</span></div>';
                }
		html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/total.png"></span></div><div class="leftSide"><span class="popTextBlack">'+count+' '+boxA+' &nbsp;&nbsp;'+totalArea+' pieces &nbsp;&nbsp;'+totalWeightArea+' lbs</span></div>';
		
		//WALL TO WALL HEADER
                html += '<div class="popMainTitle"><img name="piecesImage" src="images/head'+header+'a.png"></div>';
		html+= '<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/pieces.png"></span></div><div class="leftSide"><span class="popTextBlack">'+totalWall+'</span></div>';
                html+='<div>'+textWall+'</div>';
                html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/size.png"></span></div><div class="leftSide"><span class="popTextBlack">'+lenghtWallFeet+'\' '+lenghtWallInch+'\" x '+widthWallFeet+'\' '+widthWallInch+'\" = '+sqftWall+' sq.ft.</span></div>';
		html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/cost.png"></span></div><div class="leftSide"><span class="popTextRed">$'+	addCommas(costWall)+'&nbsp;&nbsp;&nbsp;($'+price+' sq.ft. or $'+(price*sqft1).toFixed(2)+' per piece)</span></div>';

		
		for(var i=1; i<=masterCartonWall; i++){
		k = i+1;
		/*html+='<p>Box '+k+': &nbsp;&nbsp;'+pieces+' pieces &nbsp;&nbsp;'+widthTotal+'\" x '+heightTotal+'\" x '+thickTotal+'\" &nbsp;&nbsp;'+weight25p+' lbs.</p>';*/
		count1+=1;
		}
		totalWeightWall+=(count1)*weight25p;
                if(count1 == 1){
                var boxW = 'box';
                html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/box.png"></span></div><div class="leftSide"><span class="popTextBlack">1 of '+count1+'&nbsp;&nbsp;&nbsp;'+pieces+' pieces &nbsp;&nbsp;'+widthTotal+'\" x '+heightTotal+'\" x '+thickTotal+'\" &nbsp;&nbsp;&nbsp;'+weight25p+' lbs</span></div>';
                }else{
                var boxW = 'boxes';
                html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/box.png"></span></div><div class="leftSide"><span class="popTextBlack">1 to '+count1+'&nbsp;&nbsp;&nbsp;'+pieces+' pieces &nbsp;&nbsp;'+widthTotal+'\" x '+heightTotal+'\" x '+thickTotal+'\" &nbsp;&nbsp;&nbsp;'+weight25p+' lbs</span></div>';
                }
		html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/total.png"></span></div><div class="leftSide"><span class="popTextBlack">'+count1+' '+boxW+' &nbsp;&nbsp;'+totalWall+' pieces &nbsp;&nbsp;'+totalWeightWall+' lbs</span></div>';
		}
		
		document.getElementById('boxes').innerHTML = html;
		document.getElementById('boxes').style.top = position;
		document.getElementById('boxes').style.visibility="visible";
		
		}
}

function playLearn(totalArea, totalWall, header){
	
	
	var lenghtArea = document.getElementById('lenghtPLArea').value;
	var widthArea = document.getElementById('widthPLArea').value;
	var lenghtWall = document.getElementById('lenghtPLWall').value;
	var widthWall = document.getElementById('widthPLWall').value;
	
	var lenght1310 = 26;
	var width1310 = 15;
	var height1310 = 14;
	var weight1310 = 13;
	
	var lenght1311 = 26;
	var width1311 = 25;
	var height1311 = 14;
	var weight1311 = 24;
	
	var position = '325px'; 
	
	var area = document.getElementById(totalArea).value;
	var wall = document.getElementById(totalWall).value;
	
	var edgesArea = 2*lenghtArea + 2*widthArea;
	var edgesWall = 2*lenghtWall + 2*widthWall;
	
	var cost1310 = 86.15;
	var cost1311 = 151.15;
	var moreBoxesArea = '';
	
	/*ARE   RUG*/
	var html = '<div class="popMainTitle"><img name="piecesImage" src="images/head'+header+'.png"></div>';
	html+= '<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/pieces.png"></span></div><div class="leftSide"><span class="popTextBlack">'+area+' Pieces 1\' x 1\' + '+edgesArea+' Edges + 4 Corners</span></div>';
	/*COUNTING AREA PIECES*/
	if(area <= 36){
		if(area < 36){
		var extraPiecesArea = 36-area;
		html+= '<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/breakdown.png"></span></div><div class="leftSide"><span class="popTextBlack">1 Set of Style 1310 = '+36+' total pieces minus '+area+' needed pieces = <span class="popRoyalBlue">'+extraPiecesArea+' extra pieces*</span></span></div>';
		}else{
		html+= '<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/breakdown.png"></span></div><div class="leftSide"><span class="popTextBlack">1 Set of Style 1310 = '+36+' total pieces</span></div>';
	        }
		html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/size.png"></span></div><div class="leftSide"><span class="popTextBlack">'+lenghtArea+'\' 6\" x '+widthArea+'\' 6\"</span></div>';	
		var costArea = cost1310;
		var commentArea = '($86.15 per set of style 1310)';
		html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/cost.png"></span></div><div class="leftSide"><span class="popTextRed">$'+costArea+' '+commentArea+'</span></div>';
		
		var boxArea ='1 of 1&nbsp;&nbsp;&nbsp; 36 pieces&nbsp;&nbsp;&nbsp; 26\" x 15\" x 14\"&nbsp;&nbsp;&nbsp; 13lbs';
		html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/box.png"></span></div><div class="leftSide"><span class="popTextBlack">'+boxArea+'</span></div>';
		var totalA = '1 box &nbsp;&nbsp;&nbsp; 36 pieces&nbsp;&nbsp;&nbsp; 13lbs';
		html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/total.png"></span></div><div class="leftSide"><span class="popTextBlack">'+totalA+'</span></div>';
		if(area<36){
			html+='<div class="popMainTitle1"><div class="leftSide"><span class="popRoyalBlue"><span class = "popBlueTitle">*extra pieces can be used for cubes, names, walls, etc.</span></span></div></div>';
			
		}
	
	}else if(area > 36 && area < 72 || area == 72){
	      var costArea = cost1311;
	      var commentArea = '($151.15 per set of style 1311)';
	      var boxArea ='1 of 1&nbsp;&nbsp;&nbsp; 72 pieces&nbsp;&nbsp;&nbsp; 26\" x 25\" x 14\"&nbsp;&nbsp;&nbsp; 24lbs';
              var totalA = '1 box &nbsp;&nbsp;&nbsp; 72 pieces&nbsp;&nbsp;&nbsp; 24lbs';
              if(area == 72){
              html+= '<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/breakdown.png"></span></div><div class="leftSide"><span class="popTextBlack">1 Set of Style 1311 = 72 total pieces</span></div>';
              }else if(area > 36 && area < 72){
              var extraPiecesArea = 72 - area;
              html+= '<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/breakdown.png"></span></div><div class="leftSide"><span class="popTextBlack">1 Set of Style 1311 = '+72+' total pieces minus '+area+' needed pieces = <span class="popRoyalBlue">'+extraPiecesArea+' extra pieces*</span></span></div>';
              }
              html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/size.png"></span></div><div class="leftSide"><span class="popTextBlack">'+lenghtArea+'\' 6\" x '+widthArea+'\' 6\"</span></div>';
              html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/cost.png"></span></div><div class="leftSide"><span class="popTextRed">$'+costArea+' '+commentArea+'</span></div>';
              html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/box.png"></span></div><div class="leftSide"><span class="popTextBlack">'+boxArea+'</span></div>';
              html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/total.png"></span></div><div class="leftSide"><span class="popTextBlack">'+totalA+'</span></div>';
              if(area > 36 && area < 72){
              html+='<div class="popMainTitle1"><div class="leftSide"><span class="popRoyalBlue"><span class = "popBlueTitle">*extra pieces can be used for cubes, names, walls, etc.</span></span></div></div>';
              }


        }else if(area > 72){
              var setArea = Math.floor(area/72);
              var difArea = area - 72*setArea;
              if(setArea == 1 ){var set = 'Set';}else{var set = 'Sets';}
        if(difArea <= 36 && difArea != 0){
              var totalSet = setArea*72 + 36;
              var extraPieces = totalSet - area;
              var totalBoxArea = setArea +1;
              var totalWeight = weight1311*setArea + weight1310;		
              var costArea = addCommas((setArea*cost1311 + cost1310).toFixed(2));
              var commentArea = '($86.15 per set of style 1310 and $151.15 per set of style 1311)';
              var boxArea ='1 of '+totalBoxArea+'&nbsp;&nbsp;&nbsp; 36 pieces&nbsp;&nbsp;&nbsp; 26\" x 15\" x 14\"&nbsp;&nbsp;&nbsp; 13lbs';
              var moreBoxesArea = '2 to '+totalBoxArea+'&nbsp;&nbsp;&nbsp; 72 pieces&nbsp;&nbsp;&nbsp; 26\" x 25\" x 14\"&nbsp;&nbsp;&nbsp; 24lbs';
              var totalA = ''+totalBoxArea+' boxes &nbsp;&nbsp;&nbsp;'+totalSet+' pieces&nbsp;&nbsp;&nbsp; '+totalWeight+'lbs';
              if(difArea == 36){
              html+= '<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/breakdown.png"></span></div><div class="leftSide"><span class="popTextBlack">Combine 1 Set of Style 1310 + '+setArea+' '+set+' of Style 1311 = '+totalSet+' total pieces</span></div>';
              }else{
              html+= '<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/breakdown.png"></span></div><div class="leftSide"><span class="popTextBlack">Combine 1 Set of Style 1310 + '+setArea+' '+set+' of Style 1311 = '+totalSet+' total pieces minus '+area+' needed pieces = <span class="popRoyalBlue">'+extraPieces+' extra pieces*</span></span></div>';
              }
              html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/size.png"></span></div><div class="leftSide"><span class="popTextBlack">'+lenghtArea+'\' 6\" x '+widthArea+'\' 6\"</span></div>';
              html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/cost.png"></span></div><div class="leftSide"><span class="popTextRed">$'+costArea+' '+commentArea+'</span></div>';		
	      html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/box.png"></span></div><div class="leftSide"><span class="popTextBlack">'+boxArea+'</span></div>';
              html+='<div class="leftSide"><span class="popTextBlack">'+moreBoxesArea+'</span></div>';
              html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/total.png"></span></div><div class="leftSide"><span class="popTextBlack">'+totalA+'</span></div>';
              if(difArea != 36){
              html+='<div class="popMainTitle1"><div class="leftSide"><span class="popRoyalBlue"><span class = "popBlueTitle">*extra pieces can be used for cubes, names, walls, etc.</span></span></div></div>';
              }
        }else if(difArea == 0){
              var totalSet = setArea*72;
              var extraPieces = totalSet - area;
              var costArea = addCommas((setArea*cost1311).toFixed(2));
              var totalWeight = weight1311*setArea;
              var commentArea = '($151.15 per set of style 1311)';
              var boxArea ='1 to '+setArea+'&nbsp;&nbsp;&nbsp; 72 pieces&nbsp;&nbsp;&nbsp; 26\" x 25\" x 14\"&nbsp;&nbsp;&nbsp; 24lbs';
              var totalA = ''+setArea+' boxes &nbsp;&nbsp;&nbsp; '+totalSet+' pieces&nbsp;&nbsp;&nbsp; '+totalWeight+'lbs';
              html+= '<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/breakdown.png"></span></div><div class="leftSide"><span class="popTextBlack">Combine '+setArea+' '+set+' of Style 1311 = '+totalSet+' total pieces</span></span></div>';
              html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/size.png"></span></div><div class="leftSide"><span class="popTextBlack">'+lenghtArea+'\' 6\" x '+widthArea+'\' 6\"</span></div>';
              html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/cost.png"></span></div><div class="leftSide"><span class="popTextRed">$'+costArea+' '+commentArea+'</span></div>';		
	      html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/box.png"></span></div><div class="leftSide"><span class="popTextBlack">'+boxArea+'</span></div>';
              html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/total.png"></span></div><div class="leftSide"><span class="popTextBlack">'+totalA+'</span></div>';
			
			  
        }else if(difArea > 36){
              setArea += 1;
              var totalSet = setArea*72;
              var costArea = addCommas((setArea*cost1311).toFixed(2));
              var commentArea = '($151.15 per set of style 1311)';
              var totalWeight = weight1311 * setArea;
              var extraPieces = totalSet - area;
              var totalA = ''+setArea+' boxes &nbsp;&nbsp;&nbsp; '+totalSet+' pieces&nbsp;&nbsp;&nbsp;'+totalWeight+' lbs';
              html+= '<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/breakdown.png"></span></div><div class="leftSide"><span class="popTextBlack">Combine '+setArea+' Sets of Style 1311 = '+totalSet+' total pieces minus '+area+' needed pieces = <span class="popRoyalBlue">'+extraPieces+' extra pieces*</span> </span></div>';
              html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/size.png"></span></div><div class="leftSide"><span class="popTextBlack">'+lenghtArea+'\' 6\" x '+widthArea+'\' 6\"</span></div>';
              html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/cost.png"></span></div><div class="leftSide"><span class="popTextRed">$'+costArea+' '+commentArea+'</span></div>';
	      var boxArea ='1 to '+setArea+'&nbsp;&nbsp;&nbsp; 72 Pieces&nbsp;&nbsp;&nbsp; 26\" x 25\" x 14\"&nbsp;&nbsp;&nbsp; 24lbs';
	      html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/box.png"></span></div><div class="leftSide"><span class="popTextBlack">'+boxArea+'</span></div>';
              html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/total.png"></span></div><div class="leftSide"><span class="popTextBlack">'+totalA+'</span></div>';
              html+='<div class="popMainTitle1"><div class="leftSide"><span class="popRoyalBlue"><span class = "popBlueTitle">*extra pieces can be used for cubes, names, walls, etc.</span></span></div></div>';
              }
			
        }
	
       	
	/*WALL   TO   WALL*/
	html += '<div class="popMainTitle"><img name="piecesImage" src="images/head'+header+'a.png"></div>';
	html+= '<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/pieces.png"></span></div><div class="leftSide"><span class="popTextBlack">'+wall+' Pieces 1\' x 1\' + '+edgesWall+' Edges + 4 Corners</span></div>';
	/*COUNTING WALL TO WALL*/
	if(wall <= 36){
		if(wall < 36){
		var extraPiecesWall = 36-wall;
		html+= '<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/breakdown.png"></span></div><div class="leftSide"><span class="popTextBlack">1 Set of Style 1310 = '+36+' total pieces minus '+wall+' needed pieces = <span class="popRoyalBlue">'+extraPiecesWall+' extra pieces*</span></span></div>';
		}else{
		html+= '<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/breakdown.png"></span></div><div class="leftSide"><span class="popTextBlack">1 Set of Style 1310 = '+36+' total pieces</span></div>';
	        }
		html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/size.png"></span></div><div class="leftSide"><span class="popTextBlack">'+lenghtWall+'\' 6\" x '+widthWall+'\' 6\"</span></div>';	
		var costWall = cost1310;
		var commentWall = '($86.15 per set of style 1310)';
		html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/cost.png"></span></div><div class="leftSide"><span class="popTextRed">$'+costWall+' '+commentWall+'</span></div>';
		
		var boxWall ='1 of 1&nbsp;&nbsp;&nbsp; 36 pieces&nbsp;&nbsp;&nbsp; 26\" x 15\" x 14\"&nbsp;&nbsp;&nbsp; 13lbs';
		html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/box.png"></span></div><div class="leftSide"><span class="popTextBlack">'+boxWall+'</span></div>';
		var totalW = '1 box &nbsp;&nbsp;&nbsp; 36 pieces&nbsp;&nbsp;&nbsp; 13lbs';
		html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/total.png"></span></div><div class="leftSide"><span class="popTextBlack">'+totalW+'</span></div>';
		if(wall<36){
			html+='<div class="popMainTitle1"><div class="leftSide"><span class="popRoyalBlue"><span class = "popBlueTitle">*extra pieces can be used for cubes, names, walls, etc.</span></span></div></div>';
			
		}
	
	}else if(wall > 36 && wall < 72 || wall == 72){
	      var costWall = cost1311;
	      var commentWall = '($151.15 per set of style 1311)';
	      var boxWall ='1 of 1&nbsp;&nbsp;&nbsp; 72 pieces&nbsp;&nbsp;&nbsp; 26\" x 25\" x 14\"&nbsp;&nbsp;&nbsp; 24lbs';
              var totalW = '1 box &nbsp;&nbsp;&nbsp; 72 pieces&nbsp;&nbsp;&nbsp; 24lbs';
              if(wall == 72){
              html+= '<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/breakdown.png"></span></div><div class="leftSide"><span class="popTextBlack">1 Set of Style 1311 = 72 total pieces</span></div>';
              }else if(wall > 36 && wall < 72){
              var extraPiecesWall = 72 - wall;
              html+= '<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/breakdown.png"></span></div><div class="leftSide"><span class="popTextBlack">1 Set of Style 1311 = '+72+' total pieces minus '+wall+' needed pieces = <span class="popRoyalBlue">'+extraPiecesWall+' extra pieces*</span></span></div>';
              }
              html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/size.png"></span></div><div class="leftSide"><span class="popTextBlack">'+lenghtWall+'\' 6\" x '+widthWall+'\' 6\"</span></div>';
              html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/cost.png"></span></div><div class="leftSide"><span class="popTextRed">$'+costWall+' '+commentWall+'</span></div>';
              html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/box.png"></span></div><div class="leftSide"><span class="popTextBlack">'+boxWall+'</span></div>';
              html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/total.png"></span></div><div class="leftSide"><span class="popTextBlack">'+totalW+'</span></div>';
              if(wall > 36 && wall < 72){
              html+='<div class="popMainTitle1"><div class="leftSide"><span class="popRoyalBlue"><span class = "popBlueTitle">*extra pieces can be used for cubes, names, walls, etc.</span></span></div></div>';
              }


        }else if(wall > 72){
              var setWall = Math.floor(wall/72);
              var difWall = wall - 72*setWall;
              if(setWall == 1 ){var set = 'Set';}else{var set = 'Sets';}
        if(difWall <= 36 && difWall != 0){
              var totalSet = setWall*72 + 36;
              var extraPieces = totalSet - wall;
              var totalBoxWall = setWall +1;
              var totalWeight = weight1311*setWall + weight1310;		
              var costWall = addCommas((setWall*cost1311 + cost1310).toFixed(2));
              var commentWall = '($86.15 per set of style 1310 and $151.15 per set of style 1311)';
              var boxWall ='1 of '+totalBoxWall+'&nbsp;&nbsp;&nbsp; 36 pieces&nbsp;&nbsp;&nbsp; 26\" x 15\" x 14\"&nbsp;&nbsp;&nbsp; 13lbs';
              var moreBoxesWall = '2 to '+totalBoxWall+'&nbsp;&nbsp;&nbsp; 72 pieces&nbsp;&nbsp;&nbsp; 26\" x 25\" x 14\"&nbsp;&nbsp;&nbsp; 24lbs';
              var totalW = ''+totalBoxWall+' boxes &nbsp;&nbsp;&nbsp;'+totalSet+' pieces&nbsp;&nbsp;&nbsp; '+totalWeight+'lbs';
              if(difWall == 36){
              html+= '<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/breakdown.png"></span></div><div class="leftSide"><span class="popTextBlack">Combine 1 Set of Style 1310 + '+setWall+' '+set+' of Style 1311 = '+totalSet+' total pieces</span></div>';
              }else{
              html+= '<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/breakdown.png"></span></div><div class="leftSide"><span class="popTextBlack">Combine 1 Set of Style 1310 + '+setWall+' '+set+' of Style 1311 = '+totalSet+' total pieces minus '+wall+' needed pieces = <span class="popRoyalBlue">'+extraPieces+' extra pieces*</span></span></div>';
              }
              html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/size.png"></span></div><div class="leftSide"><span class="popTextBlack">'+lenghtWall+'\' 6\" x '+widthWall+'\' 6\"</span></div>';
              html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/cost.png"></span></div><div class="leftSide"><span class="popTextRed">$'+costWall+' '+commentWall+'</span></div>';		
	      html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/box.png"></span></div><div class="leftSide"><span class="popTextBlack">'+boxWall+'</span></div>';
              html+='<div class="leftSide"><span class="popTextBlack">'+moreBoxesWall+'</span></div>';
              html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/total.png"></span></div><div class="leftSide"><span class="popTextBlack">'+totalW+'</span></div>';
              if(difWall != 36){
              html+='<div class="popMainTitle1"><div class="leftSide"><span class="popRoyalBlue"><span class = "popBlueTitle">*extra pieces can be used for cubes, names, walls, etc.</span></span></div></div>';
              }
        }else if(difWall == 0){
              var totalSet = setWall*72;
              var extraPieces = totalSet - wall;
              var costWall = addCommas((setWall*cost1311).toFixed(2));
              var totalWeight = weight1311*setWall;
              var commentWall = '($151.15 per set of style 1311)';
              var boxWall ='1 to '+setWall+'&nbsp;&nbsp;&nbsp; 72 pieces&nbsp;&nbsp;&nbsp; 26\" x 25\" x 14\"&nbsp;&nbsp;&nbsp; 24lbs';
              var totalW = ''+setWall+' boxes &nbsp;&nbsp;&nbsp; '+totalSet+' pieces&nbsp;&nbsp;&nbsp; '+totalWeight+'lbs';
              html+= '<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/breakdown.png"></span></div><div class="leftSide"><span class="popTextBlack">Combine '+setWall+' '+set+' of Style 1311 = '+totalSet+' total pieces</span></span></div>';
              html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/size.png"></span></div><div class="leftSide"><span class="popTextBlack">'+lenghtWall+'\' 6\" x '+widthWall+'\' 6\"</span></div>';
              html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/cost.png"></span></div><div class="leftSide"><span class="popTextRed">$'+costWall+' '+commentWall+'</span></div>';		
	      html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/box.png"></span></div><div class="leftSide"><span class="popTextBlack">'+boxWall+'</span></div>';
              html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/total.png"></span></div><div class="leftSide"><span class="popTextBlack">'+totalW+'</span></div>';
			
			
        }else if(difWall > 36){
              setWall += 1;
              var totalSet = setWall*72;
              var costWall = addCommas((setWall*cost1311).toFixed(2));
              var commentWall = '($151.15 per set of style 1311)';
              var totalWeight = weight1311 * setWall;
              var extraPieces = totalSet - wall;
              var totalW = ''+setWall+' boxes &nbsp;&nbsp;&nbsp; '+totalSet+' pieces&nbsp;&nbsp;&nbsp;'+totalWeight+' lbs';
              html+= '<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/breakdown.png"></span></div><div class="leftSide"><span class="popTextBlack">Combine '+setWall+' Sets of Style 1311 = '+totalSet+' total pieces minus '+wall+' needed pieces = <span class="popRoyalBlue">'+extraPieces+' extra pieces*</span> </span></div>';
              html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/size.png"></span></div><div class="leftSide"><span class="popTextBlack">'+lenghtWall+'\' 6\" x '+widthWall+'\' 6\"</span></div>';
              html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/cost.png"></span></div><div class="leftSide"><span class="popTextRed">$'+costWall+' '+commentWall+'</span></div>';
	      var boxWall ='1 to '+setWall+'&nbsp;&nbsp;&nbsp; 72 Pieces&nbsp;&nbsp;&nbsp; 26\" x 25\" x 14\"&nbsp;&nbsp;&nbsp; 24lbs';
              html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/box.png"></span></div><div class="leftSide"><span class="popTextBlack">'+boxWall+'</span></div>';
              html+='<div class="rightSide"><span class="popTextGreyBold"><img name="piecesImage" src="images/total.png"></span></div><div class="leftSide"><span class="popTextBlack">'+totalW+'</span></div>';
              html+='<div class="popMainTitle1"><div class="leftSide"><span class="popRoyalBlue"><span class = "popBlueTitle">*extra pieces can be used for cubes, names, walls, etc.</span></span></div></div>';
              }
			
        }
	
	
	
	
        document.getElementById('boxes').innerHTML = '<div id="boxContent">'+html+'</div>';
	document.getElementById('boxes').style.top = position;
	document.getElementById('boxes').style.visibility="visible";
	
	}

/********SoftMats************/
function countBoxesMats(position, header){
	
	
        var html = '<div class="popMainTitle"><img name="piecesImage" src="images/head'+header+'.png"></div>';
        html += '<div class="popMainTitle"><img name="piecesImage" src="images/head'+header+'a.png"></div>';

        document.getElementById('boxes').innerHTML = html;
	document.getElementById('boxes').style.top = position;
	document.getElementById('boxes').style.visibility="visible";
		
}

