// quotes.js
// handles the javascript quotes stuff

var showDoorBevels = false;

var glassTypes = new Array();
glassTypes[0] = new Array("Please Select", "4mm Float","4mm Clear Toughened","4mm Obscure","4mm Obscure Toughened","6.4mm Clear Laminate","6.4mm Obscure Stippolyte Laminate","6mm Clear Toughened","4mm Polycarbonate Clear","6mm Polycarbonate Clear","4mm Polycarbonate Obscure","6mm Polycarbonate Obscure","10mm Polycarbonate Clear","7mm Georgian Wired Polished Plate (Safety)","7mm Georgian Wired Rough Cast (Safety)","8.8mm Laminated","8mm Clear Toughened","10mm Clear Toughened","4mm Mirror Safety Backed","6mm Mirror Safety Backed","6.4mm Clear Laminated","6.4mm White Laminated","6.4mm Bronze Laminated","6.4mm Grey Laminated","6.8mm Clear Laminated","6.8mm Stippolyte Laminated","7.5mm Clear Laminated","8.8mm Clear Laminated","9.5mm Clear Laminated","10.8mm Clear Laminated","11.5mm Clear Laminated","12.8mm Clear Laminated","13.5mm Clear Laminated","6.4mm Green Laminated","4mm Clear Toughened","8mm Clear Toughened","12mm Clear Toughened","4mm Antisun Blue Toughened","6mm Antisun Toughened","6mm Clear K Toughened","4mm Blue Active Toughened","6mm Blue Active Toughened","4mm Satin Toughened","6mm Satin Toughened","6mm Clear Toughened","10mm Clear Toughened","4mm Antisun Toughened","6mm Antisun Blue Toughened","4mm Active Toughened","6mm Active Toughened","6mm Rough Cast Toughened", "Other (Please Specify)");
glassTypes[1] = new Array("Please Select", "4mm Clear","4mm Clear K","4mm Clear K Toughened","4mm Clear Lexan","4mm Clear Toughened","4mm Obscure","4mm Obscure K","4mm Obscure Lexan","4mm Obscure Toughened","4mm Obscure Toughened K","6.4mm Clear Laminate","6.4mm Clear Laminate K","6mm Georgian Wired Polished Plate (Safety)","7mm Georgian Wired Rough Cast (Safety)","6.4mm Laminated / 4mm Float","6.4mm Laminated / 4mm K","6.4mm Laminated / 4mm Obscure","6.4mm Laminated / 4mm Obscure Toughened","6.4mm Laminated / 4mm Toughened","6.4mm Laminated / 4mm Toughened K","6.4mm Laminated / 6mm Lexan","6.4mm Laminated / 6mm Obs Lexan","6.4mm Laminated / 6mm Toughened","6.4mm Laminated / 7mm Georgian Wired Polished Plate (Safety)","6.4mm Laminated K / 4mm Float","6.4mm Laminated K / 4mm Obscure  -","6.4mm Laminated K / 4mm Obscure Toughened","6.4mm Laminated K / 4mm Toughened","6.4mm Obscure Stippolyte Laminate","6.4mm Obscure Stippolyte Laminate K","6mm Clear Lexan","4mm Clear Lexan","6mm Clear Toughened","6mm Clear Toughened K","6mm Georgian Wired Polished Plate (Safety) / 4mm Float","6mm Lexan / 4mm Float","6mm Lexan / 4mm Obscure","6mm Lexan / 4mm Toughened","6mm Obscure Lexan", "Other (Please Specify)");
glassTypes[2] = new Array("Please Select", "6mm Active Toughened","4mm Active Toughened","4mm Antisun Blue Toughened","6mm Antisun Blue Toughened","6mm Antisun Toughened","4mm Antisun Toughened","4mm Blue Active Toughened","6mm Blue Active Toughened","6.4mm Bronze Laminated","6mm Clear K Toughened","4mm Clear K Toughened","8.8mm Clear Laminated","9.5mm Clear Laminated","10.8mm Clear Laminated","11.5mm Clear Laminated","4.4mm Clear Laminated","6.8mm Clear Laminated","13.5mm Clear Laminated","12.8mm Clear Laminated","7.5mm Clear Laminated","10.8mm Clear Laminated K","8.8mm Clear Laminated K","8mm Clear Toughened","12mm Clear Toughened","6mm Clear Toughened","4mm Clear Toughened","10mm  Clear Toughened","6.4mm Green Laminated","6.4mm Grey Laminated","6.4mm K Laminated","4mm Obscured Toughened","4mm Clear Float","6mm Clear Float","4mm Arctic Blue","6mm Clear Float Tint","4mm Clear Float Tint","4mm Oriel Toughened","4mm Pilkington Active","4mm Pilkington Active Blue","4mm Clear K","4mm Mirror (Safety Backed)","6mm Mirror (Safety Backed)","6.4mm Clear Laminated","6.8mm Obscure Laminated Stippolyte","6.4mm Laminated White","6mm Georgian Wired Polish Plate Safe","7mm Georgian Wired Rough Cast Safe","4mm Satin","4mm Obscure","6mm Georgian Wired Rough Cast Toughened","4mm Satin Toughened","6mm Satin Toughened","6.8mm Stippolyte Laminated","4mm Warwick Toughened","4mm Clear Lexan","6mm Clear Lexan","10mm  Clear Lexan", "Other (Please Specify)");
glassTypes[3] = new Array("Please Select", "6mm Active Toughened","4mm Active Toughened","4mm Antisun Blue Toughened","6mm Antisun Blue Toughened","6mm Antisun Toughened","4mm Antisun Toughened","4mm Blue Active Toughened","6mm Blue Active Toughened","6.4mm Bronze Laminated","6mm Clear K Toughened","4mm Clear K Toughened","8.8mm Clear Laminated","9.5mm Clear Laminated","10.8mm Clear Laminated","11.5mm Clear Laminated","4.4mm Clear Laminated","6.8mm Clear Laminated","13.5mm Clear Laminated","12.8mm Clear Laminated","7.5mm Clear Laminated","10.8mm Clear Laminated K","8.8mm Clear Laminated K","8mm Clear Toughened","12mm Clear Toughened","6mm Clear Toughened","4mm Clear Toughened","10mm  Clear Toughened","6.4mm Green Laminated","6.4mm Grey Laminated","6.4mm K Laminated","4mm Obscured Toughened","4mm Clear Float","6mm Clear Float","4mm Arctic Blue","6mm Clear Float Tint","4mm Clear Float Tint","4mm Oriel Toughened","4mm Pilkington Active","4mm Pilkington Active Blue","4mm Clear K","4mm Mirror (Safety Backed)","6mm Mirror (Safety Backed)","6.4mm Clear Laminated","6.8mm Obscure Laminated Stippolyte","6.4mm Laminated White","6mm Georgian Wired Polish Plate Safe","7mm Georgian Wired Rough Cast Safe","4mm Satin","4mm Obscure","6mm Georgian Wired Rough Cast Toughened","4mm Satin Toughened","6mm Satin Toughened","6.8mm Stippolyte Laminated","4mm Warwick Toughened","4mm Clear Lexan","6mm Clear Lexan","10mm  Clear Lexan", "Other (Please Specify)");

function framesOnChange(index, arrayIndex)
{
	var doorPanelObj = document.getElementById("doorpaneloption");
	var frameDesignObj = document.getElementById("framedesignoption");
	var glassBevelObj = document.getElementById("glassbeveloptionrow");
	var glassBevelObj2 = document.getElementById("glassbeveloptionrow2");
	var glassOptionsObj = document.getElementById("glassoptions");
	var attributesObj = document.getElementById("attributes");
	var conservatoryObj = document.getElementById("conservatorytext");
	var noneDoorObj = document.getElementById("nonedoor");
	var toughGlassObj = document.getElementById("toughglassrow");

	if (index == 0)
	{
		doorPanelObj.innerHTML = "";
		glassBevelObj.innerHTML = "";
		frameDesignObj.innerHTML = "";
		glassOptionsObj.style.display = "none";
		glassOptionsObj.style.visibility = "hidden"
		toughGlassObj.style.display = "block";
		toughGlassObj.style.visibility = "visible";
		noneDoorObj.style.display = "block";
		noneDoorObj.style.visibility = "visible";
		attributesObj.style.display = "block";
		attributesObj.style.visibility = "visible";
		conservatoryObj.innerHTML = "";
	}
	else if (index == 1)
	{
		// doors
		doorPanelObj.innerHTML = '<input type="hidden" id="paneltype" name="paneltype" /><input type="hidden" id="doorIndex" name="doorIndex" /><input type="hidden" id="currentDoor" name="currentDoor" /><span class="formlabel"><label for="paneltype">Panel Type:</label></span><span class="forminput"><img src="" name="doorImage" id="doorImage" width="72" height="150" border="1" alt="Door Frame" title="Door image" /><br /><div class="doorRow"><span class="col33l"><a href="javascript:previousDoor()"><img src="images/arrowleft.gif" width="10" height="12" alt="&lt;" border="0" align="absmiddle" /></a></span><span class="col33c" id="doorText"></span><span class="col33r"><a href="javascript:nextDoor()"><img src="images/arrowright.gif" width="10" height="12" alt="&gt;" border="0" align="absmiddle" /></a></span></div></span>';
		frameDesignObj.innerHTML = "";
		glassOptionsObj.style.display = "none";
		glassOptionsObj.style.visibility = "hidden"
		conservatoryObj.innerHTML = "";

		glassBevelObj.innerHTML = '<div class="formrow"><span class="formlabel"><label for="glassbeveloptionselect">Glass Bevel:</label></span><span class="forminput"><select name="glassbeveloptionselect" id="glassbeveloptionselect" onchange="bevelOnChange(this.selectedIndex)"><option value="No Bevel">No Bevel</option><option value="Yes">Yes</option></select></span></div>';

		showDoorImage();

		bevelArrayIndex = 2;

		toughGlassObj.style.display = "block";
		toughGlassObj.style.visibility = "visible";
		noneDoorObj.style.display = "none";
		noneDoorObj.style.visibility = "hidden";
		attributesObj.style.display = "block";
		attributesObj.style.visibility = "visible";

	}
	else if (index == 2)
	{
		// frenchdoor
		doorPanelObj.innerHTML = "";
		frameDesignObj.innerHTML = "";

		glassBevelObj.innerHTML = '<span class="formlabel"><label for="glassbeveloption">Glass Bevel:</label></span><span class="forminput"><select name="glassbeveloption" id="glassbeveloption" onchange="bevelOnChange(this.selectedIndex)"><option value="No Bevel">No Bevel</option><option value="Yes">Yes</option></select></span>';

		showDoorBevels = true;

		glassOptionsObj.style.display = "none";
		glassOptionsObj.style.visibility = "hidden"
		noneDoorObj.style.display = "block";
		noneDoorObj.style.visibility = "visible";
		toughGlassObj.style.display = "none";
		toughGlassObj.style.visibility = "hidden";
		attributesObj.style.display = "block";
		attributesObj.style.visibility = "visible";
		conservatoryObj.innerHTML = "";
	}
	else if (index == 3)
	{
		// patiodoor
		doorPanelObj.innerHTML = "";
		frameDesignObj.innerHTML = "";
		glassBevelObj.innerHTML = '<span class="formlabel"><label for="glassbeveloption">Glass Bevel:</label></span><span class="forminput"><select name="glassbeveloption" id="glassbeveloption" onchange="bevelOnChange(this.selectedIndex)"><option value="No Bevel">No Bevel</option><option value="Yes">Yes</option></select></span>';

		showDoorBevels = true;
		glassOptionsObj.style.display = "none";
		glassOptionsObj.style.visibility = "hidden"
		noneDoorObj.style.display = "block";
		noneDoorObj.style.visibility = "visible";
		toughGlassObj.style.display = "none";
		toughGlassObj.style.visibility = "hidden";
		attributesObj.style.display = "block";
		attributesObj.style.visibility = "visible";
		conservatoryObj.innerHTML = "";
	}
	else if (index == 4)
	{
		// window
		if (arrayIndex != null)
		{
			currentFrame = arrayIndex;
		}
		else
		{
			currentFrame = 1;
		}

		doorPanelObj.innerHTML = "";
		glassOptionsObj.style.display = "none";
		glassOptionsObj.style.visibility = "hidden"
		conservatoryObj.innerHTML = "";
		frameDesignObj.innerHTML = '<input type="hidden" id="framedesign" name="framedesign" /><span class="formlabel"><label for="framedesign">Frame Design:</label></span><span class="forminput"><img src="" name="frameImage" id="frameImage" width="133" height="132" border="1" alt="Window Frame" /><br /><div class="frameRow"><span class="col33l"><a href="javascript:previousFrame()"><img src="images/arrowleft.gif" width="10" height="12" alt="&lt;" border="0" align="absmiddle" /></a></span><span class="col33c" id="frameText"></span><span class="col33r"><a href="javascript:nextFrame()"><img src="images/arrowright.gif" width="10" height="12" alt="&gt;" border="0" align="absmiddle" /></a></span></div></span>';

		showFrameImage();

		glassBevelObj.innerHTML = '<span class="formlabel"><label for="glassbeveloption">Glass Bevel:</label></span><span class="forminput"><select name="glassbeveloption" id="glassbeveloption" onchange="bevelOnChange(this.selectedIndex)"><option value="No Bevel">No Bevel</option><option value="Yes">Yes</option></select></span>';

		showDoorBevels = false;

		if (bevelArrayIndex == 2)
		{
			bevelArrayIndex = 0;
			currentBevel = 0;
		}

		toughGlassObj.style.display = "block";
		toughGlassObj.style.visibility = "visible";
		noneDoorObj.style.display = "block";
		noneDoorObj.style.visibility = "visible";
		attributesObj.style.display = "block";
		attributesObj.style.visibility = "visible";
	}
	else if (index == 5)
	{
		// glass only
		doorPanelObj.innerHTML = "";
		frameDesignObj.innerHTML = "";
		glassBevelObj.innerHTML = "";
		conservatoryObj.innerHTML = "";
		glassBevelObj2.innerHTML = '<div class="formrow"><span class="formlabel"><label for="glassbeveloptionselect">Glass Bevel:</label></span><span class="forminput"><select name="glassbeveloptionselect" id="glassbeveloptionselect" onchange="bevelOnChange(this.selectedIndex, 1)"><option value="No Bevel">No Bevel</option><option value="Yes">Yes</option></select></span></div>';

		glassOptionsObj.style.display = "block";
		glassOptionsObj.style.visibility = "visible"
		toughGlassObj.style.display = "block";
		toughGlassObj.style.visibility = "visible";
		attributesObj.style.display = "none";
		attributesObj.style.visibility = "hidden";

		glassUnitOnChange(document.getElementById("glassunit").selectedIndex);

	}
	else if (index == 6 || index == 7)
	{
		if (index == 6)
		{
			conservatoryObj.innerHTML = "<p>Conservatories are subject to survey, please provide as much information below as possible</p>";
		}
		else
		{
			conservatoryObj.innerHTML = "";
		}

		// conservatories/other
		doorPanelObj.innerHTML = "";
		frameDesignObj.innerHTML = "";
		glassBevelObj.innerHTML = "";
		glassOptionsObj.style.display = "none";
		glassOptionsObj.style.visibility = "hidden"
		toughGlassObj.style.display = "block";
		toughGlassObj.style.visibility = "visible";
		attributesObj.style.display = "none";
		attributesObj.style.visibility = "hidden";
	}
}

function bevelOnChange(index, which)
{
	var id = (which == null) ? "glassbeveloption2" : "glassbeveloption3";

	var bevelObj = document.getElementById(id);

	if (index == 0)
	{
		bevelObj.innerHTML = "";
	}
	else
	{
		bevelObj.innerHTML = '<input type="hidden" id="glassbevel" name="glassbevel" /><input type="hidden" id="bevelIndex" name="bevelIndex" /><input type="hidden" id="currentBevel" name="currentBevel" /><span class="formlabel"><label for="paneltype">Glass Bevel Style:</label></span><span class="forminput"><img src="" name="bevelImage" id="bevelImage" width="115" height="100" border="1" alt="Bevel Image" title="Bevel" /><br /><div class="bevelRow"><span class="col33l"><a href="javascript:previousBevel()"><img src="images/arrowleft.gif" width="10" height="12" alt="&lt;" border="0" align="absmiddle" /></a></span><span class="col33c" id="bevelText"></span><span class="col33r"><a href="javascript:nextBevel()"><img src="images/arrowright.gif" width="10" height="12" alt="&gt;" border="0" align="absmiddle" /></a></span></div></span>';

		currentBevel = bevels[bevelArrayIndex].length - 1;

		showDoorBevels = true;

		showBevelImage();
	}
}

function glassUnitOnChange(index)
{
	var singleOptions = document.getElementById('singleglassoptions');
	var doubleOptions = document.getElementById('doubleglazedoptions');
	var customDoubleOptions = document.getElementById('doubleglazedcustomoptions');
	var customOptions = document.getElementById('custommadeoptions');


	if (index == 0)
	{
		var glassTypeSelect = document.getElementById('glasstype');

		glassTypeSelect.options.length = 0;

		for (loop = 0; loop < glassTypes[index].length; loop++)
		{
			glassTypeSelect.options[loop] = new Option(glassTypes[index][loop],glassTypes[index][loop]);
		}

		glassTypeSelect.selectedIndex = 0;

		singleOptions.style.display = "block";
		singleOptions.style.visibility = "visible";
		doubleOptions.style.display = "none";
		doubleOptions.style.visibility = "hidden";
		customDoubleOptions.style.display = "none";
		customDoubleOptions.style.visibility = "hidden";
		customOptions.style.display = "none";
		customOptions.style.visibility = "hidden";

		glassTypeOnChange(0, 0);
	}
	else if (index == 1)
	{
		var glassTypeSelect = document.getElementById('glasstypepane1');

		glassTypeSelect.options.length = 0;

		for (loop = 0; loop < glassTypes[index].length; loop++)
		{
			glassTypeSelect.options[loop] = new Option(glassTypes[index][loop],glassTypes[index][loop]);
		}

		glassTypeSelect.selectedIndex = 0;

		singleOptions.style.display = "none";
		singleOptions.style.visibility = "hidden";
		doubleOptions.style.display = "block";
		doubleOptions.style.visibility = "visible";
		customDoubleOptions.style.display = "none";
		customDoubleOptions.style.visibility = "hidden";
		customOptions.style.display = "none";
		customOptions.style.visibility = "hidden";

		glassTypeOnChange(0, 1);
		glassSpacerColourOnChange(document.getElementById('glassspacercolour').selectedIndex, 1);
		glassSpacerSizeOnChange(document.getElementById('glassspacersize'), 1);
	}
	else if (index == 2)
	{
		var glassTypeSelect = document.getElementById('glasstypepane2');
		var glassTypeSelect2 = document.getElementById('glasstypepane3');

		glassTypeSelect.options.length = 0;
		glassTypeSelect2.options.length = 0;

		for (loop = 0; loop < glassTypes[index].length; loop++)
		{
			glassTypeSelect.options[loop] = new Option(glassTypes[index][loop],glassTypes[index][loop]);
			glassTypeSelect2.options[loop] = new Option(glassTypes[index][loop],glassTypes[index][loop]);
		}

		glassTypeSelect.selectedIndex = 0;
		glassTypeSelect2.selectedIndex = 0;

		singleOptions.style.display = "none";
		singleOptions.style.visibility = "hidden";
		doubleOptions.style.display = "none";
		doubleOptions.style.visibility = "hidden";
		customDoubleOptions.style.display = "block";
		customDoubleOptions.style.visibility = "visible";
		customOptions.style.display = "none";
		customOptions.style.visibility = "hidden";

		glassTypeOnChange(0, 2);
		glassTypeOnChange(0, 3);
		glassSpacerColourOnChange(document.getElementById('glassspacercolour2').selectedIndex, 2);
		glassSpacerSizeOnChange(document.getElementById('glassspacersize2'), 2);
	}
	else if (index == 3)
	{
		var glassTypeSelect = document.getElementById('glasstypepane2');
		var glassTypeSelect2 = document.getElementById('glasstypepane3');
		var glassTypeSelect3 = document.getElementById('glasstypepane4');

		glassTypeSelect.options.length = 0;
		glassTypeSelect2.options.length = 0;
		glassTypeSelect3.options.length = 0;

		for (loop = 0; loop < glassTypes[index].length; loop++)
		{
			glassTypeSelect.options[loop] = new Option(glassTypes[index][loop],glassTypes[index][loop]);
			glassTypeSelect2.options[loop] = new Option(glassTypes[index][loop],glassTypes[index][loop]);
			glassTypeSelect3.options[loop] = new Option(glassTypes[index][loop],glassTypes[index][loop]);
		}

		glassTypeSelect.selectedIndex = 0;
		glassTypeSelect2.selectedIndex = 0;
		glassTypeSelect3.selectedIndex = 0;

		singleOptions.style.display = "none";
		singleOptions.style.visibility = "hidden";
		doubleOptions.style.display = "none";
		doubleOptions.style.visibility = "hidden";
		customDoubleOptions.style.display = "block";
		customDoubleOptions.style.visibility = "visible";
		customOptions.style.display = "block";
		customOptions.style.visibility = "visible";

		glassTypeOnChange(0, 2);
		glassTypeOnChange(0, 3);
		glassTypeOnChange(0, 4);

		glassSpacerColourOnChange(document.getElementById('glassspacercolour2').selectedIndex, 2);
		glassSpacerColourOnChange(document.getElementById('glassspacercolour3').selectedIndex, 3);

		glassSpacerSizeOnChange(document.getElementById('glassspacersize2'), 2);
		glassSpacerSizeOnChange(document.getElementById('glassspacersize3'), 3);
	}
}

function glassSpacerColourOnChange(index, which)
{
	var id = (which == 1) ? "glassspacercolourotherrow" : "glassspacercolourotherrow" + which;

	if (index == 4)
	{
		document.getElementById(id).style.display = "block";
	}
	else
	{
		document.getElementById(id).style.display = "none";
	}
}

function glassSpacerSizeOnChange(index, which)
{
	var id = (which == 1) ? "glassspacersizeotherotherrow" : "glassspacersizeotherrow" + which;

	if (index == 8)
	{
		document.getElementById(id).style.display = "block";
	}
	else
	{
		document.getElementById(id).style.display = "none";
	}
}

function glassTypeOnChange(index, which)
{
	var whichType = document.getElementById("glassunit").selectedIndex;
	var obscureGlassSelector = null;

	// show/hide the other rows
	if (which == 0)
	{
		if (index == glassTypes[whichType].length - 1)
		{
			document.getElementById("glasstypepaneotherrow").style.display = "block";
		}
		else
		{
			document.getElementById("glasstypepaneotherrow").style.display = "none";
		}

		obscureGlassSelector = document.getElementById("obscureglassoption2");
	}
	else if (which == 1)
	{
		if (index == glassTypes[whichType].length - 1)
		{
			document.getElementById("glasstypepane1otherrow").style.display = "block";
		}
		else
		{
			document.getElementById("glasstypepane1otherrow").style.display = "none";
		}

		obscureGlassSelector = document.getElementById("obscureglassoption3");
	}
	else if (which == 2)
	{
		if (index == glassTypes[whichType].length - 1)
		{
			document.getElementById("glasstypepane2otherrow").style.display = "block";
		}
		else
		{
			document.getElementById("glasstypepane2otherrow").style.display = "none";
		}

		obscureGlassSelector = document.getElementById("obscureglassoption4");
	}
	else if (which == 3)
	{
		if (index == glassTypes[whichType].length - 1)
		{
			document.getElementById("glasstypepane3otherrow").style.display = "block";
		}
		else
		{
			document.getElementById("glasstypepane3otherrow").style.display = "none";
		}

		obscureGlassSelector = document.getElementById("obscureglassoption5");
	}
	else if (which == 4)
	{
		if (index == glassTypes[whichType].length - 1)
		{
			document.getElementById("glasstypepane4otherrow").style.display = "block";
		}
		else
		{
			document.getElementById("glasstypepane4otherrow").style.display = "none";
		}

		obscureGlassSelector = document.getElementById("obscureglassoption6");
	}

	if ((whichType == 0 && (index == 3 || index == 4)) ||
		(whichType == 1 && (index == 6 || index == 7 || index == 9 || index == 10 || index == 17 || index == 18 || index == 26 || index == 27 || index == 37)) ||
		(whichType == 2 && (index == 31 || index == 49)) ||
		(whichType == 3 && (index == 31 || index == 49)))
	{
		obscureGlassSelector.innerHTML = '<input type="hidden" id="obscurestyle' + which + '" name="obscurestyle' + which + '" /><input type="hidden" id="obscureIndex' + which + '" name="obscureIndex' + which + '" /><span class="formlabel"><label for="obscurestyle' + which + '">Obscure Glass Style:</label></span><span class="forminput"><img src="" name="obscureImage' + which + '" id="obscureImage' + which + '" width="130" height="95" border="1" alt="Obscure Glass Image" /><br /><div class="obscureRow"><span class="col33l"><a href="javascript:previousObscure(' + which + ')"><img src="images/arrowleft.gif" width="10" height="12" alt="&lt;" border="0" align="absmiddle" /></a></span><span class="col33c" id="obscureText' + which + '"></span><span class="col33r"><a href="javascript:nextObscure(' + which + ')"><img src="images/arrowright.gif" width="10" height="12" alt="&gt;" border="0" align="absmiddle" /></a></span></div></span>';

		showObscureImage(which);
	}
	else
	{
		obscureGlassSelector.innerHTML = "";
	}
}


function glassOnChange(index, arrayIndex)
{
	var obscureGlassSelector = document.getElementById("obscureglassoption");

	if (index == 0 || index == 1)
	{
		obscureGlassSelector.innerHTML = "";
	}
	else if (index == 2)
	{
		obscureGlassSelector.innerHTML = '<input type="hidden" id="obscurestyle" name="obscurestyle" /><input type="hidden" id="obscureIndex" name="obscureIndex" /><span class="formlabel"><label for="obscurestyle">Obscure Glass Style:</label></span><span class="forminput"><img src="" name="obscureImage" id="obscureImage" width="130" height="95" border="1" alt="Obscure Glass Image" /><br /><div class="obscureRow"><span class="col33l"><a href="javascript:previousObscure()"><img src="images/arrowleft.gif" width="10" height="12" alt="&lt;" border="0" align="absmiddle" /></a></span><span class="col33c" id="obscureText"></span><span class="col33r"><a href="javascript:nextObscure()"><img src="images/arrowright.gif" width="10" height="12" alt="&gt;" border="0" align="absmiddle" /></a></span></div></span>';

		if (arrayIndex != null)
		{
			currentObscure = arrayIndex;
		}
		else
		{

			currentObscure = 0;
		}

		showObscureImage();
	}
}

function glassDecorationOnChange(index, which)
{
	if (which == null) which = "";
	var glassDecorationOption = document.getElementById("glassdecorationoption" + which);

	if (index == 0)
	{
		glassDecorationOption.innerHTML = "";
	}
	else if (index == 2)
	{
		glassDecorationOption.innerHTML = '<span class="formlabel"><label for="glassdecorationother">Glass Decoration Other:</label></span><span class="forminput"><input id="glassdecorationother" type="text" name="glassdecorationother" size="20" maxlength="255" value="" /></span>';
	}
	else
	{
		glassDecorationOption.innerHTML = '<input type="hidden" id="glassdecoration" name="glassdecoration" /><input type="hidden" id="decorationIndex" name="decorationIndex" /><span class="formlabel"><label for="glassdecoration">Glass Decoration Style:</label></span><span class="forminput"><img src="" name="decorationImage" id="decorationImage" width="125" height="125" border="1" alt="Glass Decoration Image" /><br /><div class="decorationRow"><span class="col33l"><a href="javascript:previousDecoration()"><img src="images/arrowleft.gif" width="10" height="12" alt="&lt;" border="0" align="absmiddle" /></a></span><span class="col33c" id="decorationText"></span><span class="col33r"><a href="javascript:nextDecoration()"><img src="images/arrowright.gif" width="10" height="12" alt="&gt;" border="0" align="absmiddle" /></a></span></div></span>';
		showDecorationImage();
	}
}

String.prototype.ucwords = function()
{
   // Split the string into words if string contains multiple words.
   var x = this.split(/\s+/g);
   for(var i = 0; i < x.length; i++)
   {
      // Splits the word into two parts. One part being the first letter,
      // second being the rest of the word.
      var parts = x[i].match(/(\w)(\w*)/);

      // Put it back together but uppercase the first letter and lowercase the rest of thw word.
      x[i] = parts[1].toUpperCase() + parts[2].toLowerCase();
   }

   // Rejoin the string and return.
   return x.join(' ');
};

var currentFrame = 1;
var currentDoor = 0;
var doorArrayIndex = 0;
var currentDecoration = 0;

function showDoorImage()
{
	var shortName = doors[doorArrayIndex][currentDoor].substring(0, doors[doorArrayIndex][currentDoor].length - 4).ucwords();

	if (doorArrayIndex == 0)
	{
		document.getElementById("doorImage").src = "images/quotedoors/cosmopolitan/" + doors[doorArrayIndex][currentDoor];
		document.getElementById("paneltype").value = "Cosmopolitan - " + shortName;
		document.getElementById("doorText").innerHTML = "Cosmopolitan<br />" + shortName;
	}
	else if (doorArrayIndex == 1)
	{
		document.getElementById("doorImage").src = "images/quotedoors/perfectiondoors/" + doors[doorArrayIndex][currentDoor];
		document.getElementById("paneltype").value = "Perfection Doors - " + shortName;
		document.getElementById("doorText").innerHTML = "Perfection Doors<br />" + shortName;
	}
	else if (doorArrayIndex == 2)
	{
		document.getElementById("doorImage").src = "images/quotedoors/plainbackingglass/" + doors[doorArrayIndex][currentDoor];
		document.getElementById("paneltype").value = "Plain Backing Glass - " + shortName;
		document.getElementById("doorText").innerHTML = "Plain Backing Glass<br />" + shortName;
	}
	else if (doorArrayIndex == 3)
	{
		document.getElementById("doorImage").src = "images/quotedoors/rock/" + doors[doorArrayIndex][currentDoor];
		document.getElementById("paneltype").value = "Rockdoor - " + shortName;
		document.getElementById("doorText").innerHTML = "Rockdoor<br />" + shortName;
	}

	document.getElementById("doorIndex").value = doorArrayIndex;
	document.getElementById("currentDoor").value = currentDoor;

}

function nextDoor()
{
	currentDoor++;

	if (currentDoor >= doors[doorArrayIndex].length)
	{
		currentDoor = 0;
		doorArrayIndex++;

		if (doorArrayIndex >= doors.length)
		{
			doorArrayIndex = doors.length - 1;
			currentDoor = doors[doorArrayIndex].length - 1;
		}
	}

	showDoorImage();
}

function previousDoor()
{
	currentDoor--;

	if (currentDoor < 0)
	{
		doorArrayIndex--;

		if (doorArrayIndex < 0)
		{
			doorArrayIndex = 0;
			currentDoor = 0;
		}
		else
		{
			currentDoor = doors[doorArrayIndex].length - 1;
		}
	}

	showDoorImage();
}

var currentBevel = 0;
var bevelArrayIndex = 0;

function showBevelImage()
{
	var shortName = bevels[bevelArrayIndex][currentBevel].substring(0, bevels[bevelArrayIndex][currentBevel].length - 4);

	if (shortName == "_No Bevel")
	{
		shortName = "No Bevel";
	}

	if (bevelArrayIndex == 0)
	{
		document.getElementById("bevelImage").src = "images/quotebevels/colouredbevels/" + bevels[bevelArrayIndex][currentBevel];
		document.getElementById("glassbevel").value = "Coloured - " + shortName;
	}
	else if (bevelArrayIndex == 1)
	{
		document.getElementById("bevelImage").src = "images/quotebevels/diamondbevels/" + bevels[bevelArrayIndex][currentBevel];
		document.getElementById("glassbevel").value = "Diamond - " + shortName;
	}
	else if (bevelArrayIndex == 2)
	{
		document.getElementById("bevelImage").src = "images/quotebevels/doorbevels/" + bevels[bevelArrayIndex][currentBevel];
		document.getElementById("glassbevel").value = "Door - " + shortName;
	}
	else if (bevelArrayIndex == 3)
	{
		document.getElementById("bevelImage").src = "images/quotebevels/fanlightbevels/" + bevels[bevelArrayIndex][currentBevel];
		document.getElementById("glassbevel").value = "Fan Light - " + shortName;
	}
	else if (bevelArrayIndex == 4)
	{
		document.getElementById("bevelImage").src = "images/quotebevels/gluechipbevels/" + bevels[bevelArrayIndex][currentBevel];
		document.getElementById("glassbevel").value = "Glue Chip - " + shortName;
	}

	document.getElementById("bevelIndex").value = bevelArrayIndex;
	document.getElementById("currentBevel").value = currentBevel;

	document.getElementById("bevelText").innerHTML = shortName;
}

function nextBevel()
{
	currentBevel++;

	if (currentBevel >= bevels[bevelArrayIndex].length)
	{
		currentBevel = 0;

		if (showDoorBevels)
		{
			bevelArrayIndex = 2;
		}
		else
		{
			bevelArrayIndex++;

			if (bevelArrayIndex == 2)
			{
				bevelArrayIndex++;
			}
		}

		if (bevelArrayIndex >= bevels.length)
		{
			bevelArrayIndex = bevels.length - 1;
			currentBevel = bevels[bevelArrayIndex].length - 1;
		}
	}

	showBevelImage();
}

function previousBevel()
{
	currentBevel--;

	if (currentBevel < 0)
	{
		if (showDoorBevels)
		{
			bevelArrayIndex = 2;
		}
		else
		{
			bevelArrayIndex--;

			if (bevelArrayIndex == 2) bevelArrayIndex--;
		}

		if (bevelArrayIndex < 0)
		{
			bevelArrayIndex = 0;
			currentBevel = 0;
		}
		else
		{
			currentBevel = bevels[bevelArrayIndex].length - 1;
		}
	}

	showBevelImage();
}

var currentObscure = 0;

function showObscureImage(which)
{
	if (which == null) which = "";

	var shortName = obscure[currentObscure].substring(0, obscure[currentObscure].length - 4).ucwords();

	document.getElementById("obscureImage" + which).src = "images/obscureglassquote/" + obscure[currentObscure];
	document.getElementById("obscurestyle" + which).value = shortName;
	document.getElementById("obscureIndex" + which).value = currentObscure;

	document.getElementById("obscureText" + which).innerHTML = shortName;
}

function nextObscure(which)
{
	currentObscure++;

	if (currentObscure >= obscure.length) currentObscure = obscure.length - 1;

	showObscureImage(which);
}

function previousObscure(which)
{
	currentObscure--;

	if (currentObscure < 0) currentObscure = 0;

	showObscureImage(which);
}

function showDecorationImage()
{
	var shortName = decoration[currentDecoration].substring(0, decoration[currentDecoration].length - 4).ucwords();

	document.getElementById("decorationImage").src = "images/quotedecoration/" + decoration[currentDecoration];
	document.getElementById("glassdecoration").value = shortName;
	document.getElementById("decorationIndex").value = currentDecoration;

	document.getElementById("decorationText").innerHTML = shortName;
}

function nextDecoration()
{
	currentDecoration++;

	if (currentDecoration >= decoration.length) currentDecoration = decoration.length - 1;

	showDecorationImage();
}

function previousDecoration()
{
	currentDecoration--;

	if (currentDecoration < 0) currentDecoration = 0;

	showDecorationImage();
}

function showFrameImage()
{
	document.getElementById("framedesign").value = currentFrame;

	document.getElementById("frameImage").src = "images/frames/" + currentFrame + ".gif";

	document.getElementById("frameText").innerHTML = "Frame " + currentFrame;
}

function previousFrame()
{
	if (currentFrame == "Other")
	{
		currentFrame = 192;
	}
	else if (currentFrame == 1)
	{
		currentFrame = "Other";
	}
	else if (currentFrame == 185)
	{
		currentFrame = 183;
	}
	else if (currentFrame == 177)
	{
		currentFrame = 172;
	}
	else if (currentFrame == 160)
	{
		currentFrame = 154;
	}
	else if (currentFrame == 154)
	{
		currentFrame = 149;
	}
	else if (currentFrame == 110)
	{
		currentFrame = 40;
	}
	else
	{
		currentFrame--;
	}

	showFrameImage();
}

function nextFrame()
{
	if (currentFrame == "Other")
	{
		currentFrame = 1;
	}
	else if (currentFrame == 192)
	{
		currentFrame = "Other";
	}
	else if (currentFrame == 183)
	{
		currentFrame = 185;
	}
	else if (currentFrame == 172)
	{
		currentFrame = 177;
	}
	else if (currentFrame == 154)
	{
		currentFrame = 160;
	}
	else if (currentFrame == 149)
	{
		currentFrame = 154;
	}
	else if (currentFrame == 40)
	{
		currentFrame = 110;
	}
	else
	{
		currentFrame++;
	}

	showFrameImage();
}

function addQuote()
{
	document.getElementById("action").value = "addquote";
	document.getElementById("quoteform").submit();
}

function onSubmit()
{
	document.getElementById("action").value = "send";

	return true;
}

