function calcClearTile()
{

document.ceramictile.width.value = ""
document.ceramictile.length.value = ""
document.getElementById("TotalArea").innerHTML = ""
document.getElementById("NumberOfTiles").innerHTML = ""
document.ceramictile.TileSize.selectedIndex = 0

GetSize()
}

function GetSize()
{
var TileAreaSelected = document.ceramictile.TileSize.selectedIndex;
document.ceramictile.Tile.value = document.ceramictile.TileSize.options[TileAreaSelected].value;
}

function CalculateTile(object)
{
var width = parseFloat(document.ceramictile.width.value); 
var length = parseFloat(document.ceramictile.length.value);
var TileArea = parseFloat(document.ceramictile.Tile.value);

var Msg="";	
// Check for values	in the form
	
	if(document.ceramictile.width.value < 1)
		
		{
		Msg +="\t Width\n";
		}
			
	if(document.ceramictile.length.value < 1)
			
		{
		Msg+="\t Length\n";
		}
	

	if(Msg.length > 2)
			
		{
		strMsg="You need to fill out the following field(s)\n ";
		window.alert(strMsg + Msg);
		}

	else
		{
		var TotalArea = ((width * 12) * (length * 12)); 
		var NumTiles = TotalArea/TileArea;
		
		NumTiles = Math.ceil(NumTiles)
		SquareFeet = TotalArea/144
		SquareFeet = Math.round(SquareFeet*Math.pow(10,2))/Math.pow(10,2)
		
		document.getElementById("TotalArea").innerHTML = SquareFeet
		document.getElementById("NumberOfTiles").innerHTML = NumTiles
		}
}

function getCarpet(){
	//convert ft to inches
	var length1 = document.calcCarpet.length1.value * 12;
	var width1 = document.calcCarpet.width1.value * 12;
	
	//these are in inches
	var length2 = document.calcCarpet.length2.value;
	var width2 = document.calcCarpet.width2.value;
	
	if (length2 == "" || width2 == "" || length1 == "" || width1 == ""){
		length2 = "0";
		width2 = "0";
		length1 = "0";
		width1 = "0";
	}
			
	var total1, total2, total3, totalYards;
		
		total1 = (parseInt(length1) + parseInt(length2)) / 12;
		total2 = (parseInt(width1) + parseInt(width2)) / 12;
		total3 = (total1 * total2).toFixed(1);
		
		totalYards = (total3 / 9).toFixed(1);			

	
	var x = document.getElementById("sqFeet");
	x.innerHTML = total3;
	var y = document.getElementById("sqYards");
	y.innerHTML = totalYards;

}
function clearCalcCarpet(){
	document.calcCarpet.reset();
	document.getElementById("sqFeet").innerHTML  = "";
	document.getElementById("sqYards").innerHTML = "";
}

function getWood(){
	//numbers in feet
	var length1 = document.calcWood.length1.value;
	var width1 = document.calcWood.width1.value;

	
	if (length1 == "" || width1 == ""){
		length1 = "0";
		width1 = "0";
	}
			
	var total1, total3, totalYards;
		
	if (length1 != "" || width1 != ""){
		total = (parseInt(length1) * parseInt(width1)).toFixed(1);
	
		totalYards = (total / 9).toFixed(1);			
	}
	
	var x = document.getElementById("sqFeet");
	x.innerHTML = total;
	var y = document.getElementById("sqYards");
	y.innerHTML = totalYards;

}

function Round(number,X) 
{
// rounds number to X decimal places
return Math.round(number*Math.pow(10,X))/Math.pow(10,X);
}

function CalculateWallpaper(object)
{
// Get the form values
var roomperimeter = parseFloat(document.wallpaper.roomperimeter.value); 
var wallheight = parseFloat(document.wallpaper.wallheight.value);
var numsdoors = parseFloat(document.wallpaper.numsdoors.value); 
var numddoors = parseFloat(document.wallpaper.numddoors.value);
var numswindows = parseFloat(document.wallpaper.numswindows.value); 
var numlwindows = parseFloat(document.wallpaper.numlwindows.value);
var excludedarea = parseFloat(document.wallpaper.excludedarea.value); 
var rollsize = parseFloat(document.wallpaper.rollsize.value);

// The error message for missing fields
var Msg="";		
// Check for values	in the form
	
	if(document.wallpaper.roomperimeter.value < 1)
		
		{
		Msg +="\t Room Perimeter\n";
		}
			
	if(document.wallpaper.wallheight.value < 1)
			
		{
		Msg+="\t Wall Height\n";
		}
		
// If any fields are empty alert the empty fields			

	if(Msg.length > 2)
			
		{
		strMsg="You need to fill out the following field(s)\n ";
		window.alert(strMsg + Msg);
		}

// else go ahead and run the formula		

	else
		{
		var area = roomperimeter * wallheight;
		
		var singledoors = numsdoors * 20;
		var doubledoors = numddoors * 40;
		var smallwindows = numswindows * 10;
		var largewindows = numlwindows * 25;
		
		var totalarea = area - (singledoors + doubledoors + smallwindows + largewindows + excludedarea);
		var rollsneeded = totalarea / rollsize;
		
		rollsneeded = Round(rollsneeded,2)
		document.getElementById("rollsneeded").innerHTML = rollsneeded
		}
}

function clearCalcWallpaper(){
	document.calcWallpaper.reset();
	document.getElementById("rollsneeded").innerHTML  = "";

}
