
/*************************************************************************
* Custom Fireplace Door Size Selection script
* Set Up to pick the correct custom size or alert for quotes
* Resets fields as required
* Created 17 Sep 07 - LM
* Modified 28 Oct 07 - LM
*   function names updated to prevent interference from FPD-size-selcte.js
*   Calculate function added to update kit price when applicable
* Modified 6 Nov 07 - LM
*   Added CustSizeSelect1() Function1 for Custom Z-Decor and Z-Door fireplace doors
**************************************************************************/

//Declare variables
var FPWidth, TWidthWhole, TWidthFract, BWidthWhole, BWidthFract, TWidth, BWidth
var FPHeight, LHeightWhole, LHeightFract, RHeightWhole, RHeightFract, LHeight, RHeight

/******************************************************************************
* Thermo-Rite Custom Fireplace Doors
*******************************************************************************/
function CustSizeSelect(formobj){
CustOptionReset();
//get values from form fields
TWidthWhole = parseFloat(document.frmKitUpgrades.Twidth.value)
TWidthFract = parseFloat(document.frmKitUpgrades.TwidthFraction.value)
BWidthWhole = parseFloat(document.frmKitUpgrades.Bwidth.value)
BWidthFract = parseFloat(document.frmKitUpgrades.BwidthFraction.value)
LHeightWhole = parseFloat(document.frmKitUpgrades.Lheight.value)
LHeightFract = parseFloat(document.frmKitUpgrades.LheightFraction.value)
RHeightWhole = parseFloat(document.frmKitUpgrades.Rheight.value)
RHeightFract = parseFloat(document.frmKitUpgrades.RheightFraction.value)

//concatenate fractions to whole numbers
TWidth = eval(TWidthWhole + TWidthFract)
//alert(TWidth);
BWidth = eval(BWidthWhole + BWidthFract)
//alert(BWidth);
LHeight = eval(LHeightWhole + LHeightFract)
//alert(LHeight);
RHeight = eval(RHeightWhole + RHeightFract)
//alert(RHeight);

	//compare widths to get that largest
	if (TWidth >= BWidth)
		{
		FPWidth = TWidth
		//alert("top width is greater");
		}
	else
		{
		FPWidth = BWidth
		//alert("bottom width is greater");
		}
	
	//compare heigths to get that largest
	if (LHeight >= RHeight)
		{
		FPHeight = LHeight
		//alert("Left Height is greater");
		}
	else
		{
		FPHeight = RHeight
		//alert("Right Height is greater");
		}

//Determine door size and write back to select fields of the form
if (FPWidth <= 44 &&  FPHeight <= 31)
	{
	//select 5TH-CUS-FA-4431
	document.frmKitUpgrades.sel1.options[1].selected = true;
	document.getElementById("available").style.visibility="visible";
	//Added to calculate price change when required 28 Oct 07 - LM
	Calculate();
	}
else if (FPWidth <= 50 &&  FPHeight <= 39)
	//select 5TH-CUS-FA-5039
	{
	document.frmKitUpgrades.sel1.options[2].selected = true;
	document.getElementById("available").style.visibility="visible";
//alert("5039");
	//Added to calculate price change when required 28 Oct 07 - LM
	Calculate();
	}

//validate size to notify if exceeds 50" W X 39" H
if (FPWidth > 50)
	{
	//In place to roll the select back to default should customer use dropdown before using the button
	document.frmKitUpgrades.sel1.options[0].selected = true;
	//Display out of size range message
	document.getElementById("widthQ").style.visibility="visible";
	document.getElementById("heightQ").style.visibility="hidden";
	}
else if (FPHeight > 39)
	{
	//In place to roll the select back to default should customer use dropdown before using the button
	document.frmKitUpgrades.sel1.options[0].selected = true;
	//Display out of size range message
	document.getElementById("heightQ").style.visibility="visible";
	document.getElementById("widthQ").style.visibility="hidden";
	}
}
/******************************************************************************/


	
/******************************************************************************
* Thermo-Rite Z-Door/Z-Decor Custom Fireplace Doors
*******************************************************************************/	
function CustSizeSelect1(formobj){

//get values from form fields
TWidthWhole = parseFloat(document.frmKitUpgrades.Twidth.value)
TWidthFract = parseFloat(document.frmKitUpgrades.TwidthFraction.value)
BWidthWhole = parseFloat(document.frmKitUpgrades.Bwidth.value)
BWidthFract = parseFloat(document.frmKitUpgrades.BwidthFraction.value)
LHeightWhole = parseFloat(document.frmKitUpgrades.Lheight.value)
LHeightFract = parseFloat(document.frmKitUpgrades.LheightFraction.value)
RHeightWhole = parseFloat(document.frmKitUpgrades.Rheight.value)
RHeightFract = parseFloat(document.frmKitUpgrades.RheightFraction.value)

//concatenate fractions to whole numbers
TWidth = eval(TWidthWhole + TWidthFract)
//alert(TWidth);
BWidth = eval(BWidthWhole + BWidthFract)
//alert(BWidth);
LHeight = eval(LHeightWhole + LHeightFract)
//alert(LHeight);
RHeight = eval(RHeightWhole + RHeightFract)
//alert(RHeight);

	//compare widths to get that largest
	if (TWidth >= BWidth)
		{
		FPWidth = TWidth
		//alert("top width is greater");
		}
	else
		{
		FPWidth = BWidth
		//alert("bottom width is greater");
		}
	
	//compare heigths to get that largest
	if (LHeight >= RHeight)
		{
		FPHeight = LHeight
		//alert("Left Height is greater");
		}
	else
		{
		FPHeight = RHeight
		//alert("Right Height is greater");
		}

//Determine door size and write back to select fields of the form
if (FPWidth <= 36 &&  FPHeight <= 24)
	{
	//select 5TH-SIZ-ZD-3624
	document.frmKitUpgrades.sel1.options[1].selected = true;
	document.getElementById("available").style.visibility="visible";
	//Calculates price change when required
	Calculate();
	}
else if (FPWidth <= 42 &&  FPHeight <= 28)
	//select 5TH-SIZ-ZD-4228
	{
	document.frmKitUpgrades.sel1.options[2].selected = true;
	document.getElementById("available").style.visibility="visible";
//alert("4228");
	//Calculates price change when required
	Calculate();
	}
else if (FPWidth <= 48 &&  FPHeight <= 29)
	//select 5TH-SIZ-ZD-4829
	{
	document.frmKitUpgrades.sel1.options[3].selected = true;
	document.getElementById("available").style.visibility="visible";
//alert("4829");
	//Calculates price change when required
	Calculate();
	}
	
//validate size to notify if it exceeds 48" W X 29" H
if (FPWidth > 48)
	{
	//In place to roll the select back to default should customer use dropdown before using the button
	document.frmKitUpgrades.sel1.options[0].selected = true;
	//Display out of size range message
	document.getElementById("widthQ").style.visibility="visible";
	document.getElementById("heightQ").style.visibility="hidden";
	}
else if (FPHeight > 29)
	{
	//In place to roll the select back to default should customer use dropdown before using the button
	document.frmKitUpgrades.sel1.options[0].selected = true;
	//Display out of size range message
	document.getElementById("heightQ").style.visibility="visible";
	document.getElementById("widthQ").style.visibility="hidden";
	}
Calculate();
}
/******************************************************************************/

/******************************************************************************
* Thermo-Rite Z-Track Stock Door
*******************************************************************************/
function StockSizeSelectZTRACK(){
FPWidthWhole = parseFloat(document.frmKitUpgrades.FPWidth.value)
FPWidthFract = parseFloat(document.frmKitUpgrades.FPWidthFraction.value)
FPHeightWhole = parseFloat(document.frmKitUpgrades.FPHeight.value)
FPHeightFract = parseFloat(document.frmKitUpgrades.FPHeightFraction.value)

FPWidth = eval(FPWidthWhole + FPWidthFract)
FPHeight = eval(FPHeightWhole + FPHeightFract)

if (FPWidth <= 36 &&  FPHeight <= 24)
	{
	document.frmKitUpgrades.sel1.options[1].selected = true;
	document.getElementById("available").style.visibility="visible";
	Calculate();
	}
else if (FPWidth <= 42 &&  FPHeight <= 28)
	{
	document.frmKitUpgrades.sel1.options[2].selected = true;
	document.getElementById("available").style.visibility="visible";
	Calculate();
	}
else if (FPWidth <= 48 &&  FPHeight <= 29)
	{
	document.frmKitUpgrades.sel1.options[3].selected = true;
	document.getElementById("available").style.visibility="visible";
	Calculate();
	}

if (FPWidth > 48)
	{
	document.frmKitUpgrades.sel1.options[0].selected = true;
	document.getElementById("widthQ").style.visibility="visible";
	document.getElementById("heightQ").style.visibility="hidden";
	}
else if (FPHeight > 29)
	{
	document.frmKitUpgrades.sel1.options[0].selected = true;
	document.getElementById("heightQ").style.visibility="visible";
	document.getElementById("widthQ").style.visibility="hidden";
	}
}
/******************************************************************************/

/******************************************************************************
* Thermo-Rite Z-Laser Stock Door
*******************************************************************************/
function StockSizeSelectZLaser(){
//get values from form fields
FPWidthWhole = parseFloat(document.frmKitUpgrades.FPWidth.value)
FPWidthFract = parseFloat(document.frmKitUpgrades.FPWidthFraction.value)
FPHeightWhole = parseFloat(document.frmKitUpgrades.FPHeight.value)
FPHeightFract = parseFloat(document.frmKitUpgrades.FPHeightFraction.value)

//concatenate fractions with whole numbers
FPWidth = eval(FPWidthWhole + FPWidthFract)
FPHeight = eval(FPHeightWhole + FPHeightFract)
if (FPWidth <= 44 &&  FPHeight <= 27)
	{
	document.frmKitUpgrades.sel1.options[1].selected = true;
	document.getElementById("available").style.visibility="visible";
	Calculate();
	}
else if (FPWidth <= 50 &&  FPHeight <= 31)
	{
	document.frmKitUpgrades.sel1.options[2].selected = true;
	document.getElementById("available").style.visibility="visible";
	Calculate();
	}
if (FPWidth > 50)
	{
	document.frmKitUpgrades.sel1.options[0].selected = true;
	document.getElementById("widthQ").style.visibility="visible";
	document.getElementById("heightQ").style.visibility="hidden";
	}
else if (FPHeight > 31)
	{
	document.frmKitUpgrades.sel1.options[0].selected = true;
	document.getElementById("heightQ").style.visibility="visible";
	document.getElementById("widthQ").style.visibility="hidden";
	}
}

/******************************************************************************/

/******************************************************************************
* Thermo-Rite Z-Classic Stock Door
*******************************************************************************/
function StockSizeSelectZClassic(){
//get values from form fields
FPWidthWhole = parseFloat(document.frmKitUpgrades.FPWidth.value)
FPWidthFract = parseFloat(document.frmKitUpgrades.FPWidthFraction.value)
FPHeightWhole = parseFloat(document.frmKitUpgrades.FPHeight.value)
FPHeightFract = parseFloat(document.frmKitUpgrades.FPHeightFraction.value)

//concatenate fractions with whole numbers
FPWidth = eval(FPWidthWhole + FPWidthFract)
FPHeight = eval(FPHeightWhole + FPHeightFract)

//Determine door size and write back to select fields of the form	
if (FPWidth <= 42 &&  FPHeight <= 25)
	{
	document.frmKitUpgrades.sel1.options[1].selected = true;
	document.getElementById("available").style.visibility="visible";
	Calculate();
	}
else if (FPWidth <= 48 &&  FPHeight <= 29)
	{
	document.frmKitUpgrades.sel1.options[2].selected = true;
	document.getElementById("available").style.visibility="visible";
	Calculate();
	}
if (FPWidth > 48)
	{
	document.frmKitUpgrades.sel1.options[0].selected = true;
	document.getElementById("widthQ").style.visibility="visible";
	document.getElementById("heightQ").style.visibility="hidden";
	}
else if (FPHeight > 29)
	{
	document.frmKitUpgrades.sel1.options[0].selected = true;
	document.getElementById("heightQ").style.visibility="visible";
	document.getElementById("widthQ").style.visibility="hidden";
	}
}
/******************************************************************************/

/******************************************************************************
* Thermo-Rite Z-Phantom Stock Door
*******************************************************************************/
function StockSizeSelectZPhantom(){
//get values from form fields
FPWidthWhole = parseFloat(document.frmKitUpgrades.FPWidth.value)
FPWidthFract = parseFloat(document.frmKitUpgrades.FPWidthFraction.value)
FPHeightWhole = parseFloat(document.frmKitUpgrades.FPHeight.value)
FPHeightFract = parseFloat(document.frmKitUpgrades.FPHeightFraction.value)

//concatenate fractions with whole numbers
FPWidth = eval(FPWidthWhole + FPWidthFract)
FPHeight = eval(FPHeightWhole + FPHeightFract)

//Determine door size and write back to select fields of the form	
if (FPWidth <= 42 &&  FPHeight <= 28)
	{
	document.frmKitUpgrades.sel1.options[1].selected = true;
	document.getElementById("available").style.visibility="visible";
	Calculate();
	}
else if (FPWidth <= 48 &&  FPHeight <= 29)
	{
	document.frmKitUpgrades.sel1.options[2].selected = true;
	document.getElementById("available").style.visibility="visible";
	Calculate();
	}
if (FPWidth > 48)
	{
	document.frmKitUpgrades.sel1.options[0].selected = true;
	document.getElementById("widthQ").style.visibility="visible";
	document.getElementById("heightQ").style.visibility="hidden";
	}
else if (FPHeight > 29)
	{
	document.frmKitUpgrades.sel1.options[0].selected = true;
	document.getElementById("heightQ").style.visibility="visible";
	document.getElementById("widthQ").style.visibility="hidden";
	}
}
/******************************************************************************/

/******************************************************************************
* Thermo-Rite Z-Heritage Stock Door
*******************************************************************************/
function StockSizeSelectZHeritage(){
//get values from form fields
FPWidthWhole = parseFloat(document.frmKitUpgrades.FPWidth.value)
FPWidthFract = parseFloat(document.frmKitUpgrades.FPWidthFraction.value)
FPHeightWhole = parseFloat(document.frmKitUpgrades.FPHeight.value)
FPHeightFract = parseFloat(document.frmKitUpgrades.FPHeightFraction.value)

//concatenate fractions with whole numbers
FPWidth = eval(FPWidthWhole + FPWidthFract)
FPHeight = eval(FPHeightWhole + FPHeightFract)

//Determine door size and write back to select fields of the form	
if (FPWidth <= 44 &&  FPHeight <= 27)
	{
	document.frmKitUpgrades.sel1.options[1].selected = true;
	document.getElementById("available").style.visibility="visible";
	Calculate();
	}
else if (FPWidth <= 50 &&  FPHeight <= 31)
	{
	document.frmKitUpgrades.sel1.options[2].selected = true;
	document.getElementById("available").style.visibility="visible";
	Calculate();
	}
if (FPWidth > 50)
	{
	document.frmKitUpgrades.sel1.options[0].selected = true;
	document.getElementById("widthQ").style.visibility="visible";
	document.getElementById("heightQ").style.visibility="hidden";
	}
else if (FPHeight > 31)
	{
	document.frmKitUpgrades.sel1.options[0].selected = true;
	document.getElementById("heightQ").style.visibility="visible";
	document.getElementById("widthQ").style.visibility="hidden";
	}
}
/******************************************************************************/


/******************************************************************************
* FDM Custom Fireplace Doors
*******************************************************************************/	
function CustSizeSelect2(formobj){

//get values from form fields
TWidthWhole = parseFloat(document.frmKitUpgrades.Twidth.value)
TWidthFract = parseFloat(document.frmKitUpgrades.TwidthFraction.value)
BWidthWhole = parseFloat(document.frmKitUpgrades.Bwidth.value)
BWidthFract = parseFloat(document.frmKitUpgrades.BwidthFraction.value)
LHeightWhole = parseFloat(document.frmKitUpgrades.Lheight.value)
LHeightFract = parseFloat(document.frmKitUpgrades.LheightFraction.value)
RHeightWhole = parseFloat(document.frmKitUpgrades.Rheight.value)
RHeightFract = parseFloat(document.frmKitUpgrades.RheightFraction.value)

//concatenate fractions to whole numbers
TWidth = eval(TWidthWhole + TWidthFract)
//alert(TWidth);
BWidth = eval(BWidthWhole + BWidthFract)
//alert(BWidth);
LHeight = eval(LHeightWhole + LHeightFract)
//alert(LHeight);
RHeight = eval(RHeightWhole + RHeightFract)
//alert(RHeight);

	//compare widths to get that largest
	if (TWidth >= BWidth)
		{
		FPWidth = TWidth
		//alert("top width is greater");
		}
	else
		{
		FPWidth = BWidth
		//alert("bottom width is greater");
		}
	
	//compare heigths to get that largest
	if (LHeight >= RHeight)
		{
		FPHeight = LHeight
		//alert("Left Height is greater");
		}
	else
		{
		FPHeight = RHeight
		//alert("Right Height is greater");
		}

//Determine door size and write back to select fields of the form
if (FPWidth <= 40 &&  FPHeight <= 30)
	{
	//select 5FM-CUS-CL-4030
	document.frmKitUpgrades.sel1.options[1].selected = true;
	document.getElementById("available").style.visibility="visible";
	//Calculates price change when required
	Calculate();
	}
else if (FPWidth <= 48 &&  FPHeight <= 33)
	//select 5FM-CUS-CL-4833
	{
	document.frmKitUpgrades.sel1.options[2].selected = true;
	document.getElementById("available").style.visibility="visible";
//alert("4228");
	//Calculates price change when required
	Calculate();
	}
else if (FPWidth <= 56 &&  FPHeight <= 36)
	//select 5FM-CUS-CL-5636
	{
	document.frmKitUpgrades.sel1.options[3].selected = true;
	document.getElementById("available").style.visibility="visible";
//alert("4829");
	//Calculates price change when required
	Calculate();
	}
	
//validate size to notify if it exceeds 48" W X 29" H
if (FPWidth > 56)
	{
	//In place to roll the select back to default should customer use dropdown before using the button
	document.frmKitUpgrades.sel1.options[0].selected = true;
	//Display out of size range message
	document.getElementById("widthQ").style.visibility="visible";
	document.getElementById("heightQ").style.visibility="hidden";
	}
else if (FPHeight > 36)
	{
	//In place to roll the select back to default should customer use dropdown before using the button
	document.frmKitUpgrades.sel1.options[0].selected = true;
	//Display out of size range message
	document.getElementById("heightQ").style.visibility="visible";
	document.getElementById("widthQ").style.visibility="hidden";
	}
Calculate();
}
/******************************************************************************/

function CustOptionReset(){

}

function Calculate(){

 len = document.frmKitUpgrades.elements.length;
 
 for(i=0;i<=parseInt(len)-1;i++)	{
			if((document.frmKitUpgrades.elements[i].type.substring(0,3) == "sel") && (document.frmKitUpgrades.elements[i].selectedIndex > -1) && (document.frmKitUpgrades.elements[i].id != "999")) {	

 len2 =  document.frmKitUpgrades.elements[i].options.length;
		
	for(j=0;j<=parseInt(len2)-1;j++)	{

					CalculateTotal(document.frmKitUpgrades.hiddenprice.value ,'T','1033','0.00');
					//alert(document.frmKitUpgrades.elements[i].value);
/*					SwapImage1('image1',document.frmKitUpgrades.elements[i].value);
					document.frmKitUpgrades.elements[7].disabled = true;*/
}
}
}
}