
	/*<%-- JSON service calls --%>*/
	var gJsonDoorForOptions = gSiteRoot + '/services/ConfiguratorService.svc/GetDoorsForOptions';
	var gJsonGlassForSidelite = gSiteRoot + '/services/ConfiguratorService.svc/GetSideliteForOptions';
	var gJsonGlassForTransom = gSiteRoot + '/services/ConfiguratorService.svc/GetTransomForOptions';
	var gJsonDoorDimensionsForOptions = gSiteRoot + '/services/ConfiguratorService.svc/GetDoorDimensions';
	var gJsonGenerateLeadRequest = gSiteRoot + '/services/ConfiguratorService.svc/GenerateLeadRequest';

	/*<%-- thickbox iframe pages --%>*/
	var gDoorImagePreviewProvider = gSiteRoot + "/products/doordetail/fulldetailload.aspx";

	/*<%-- loading image paths --%>*/
	var gDoorLoadingImg = gSiteRoot + "/i/products/door/loader.gif";
	var gSideliteLoadingImg = gSiteRoot + "/i/products/sidelite/loader.gif";
	var gTransomLoadingImg = gSiteRoot + "/i/products/transom/loader.gif";

	/*<%-- hash keys --%>*/
	var gDoorStyleOptionKey = "dso";
	var gGlassOptionKey = "go";
	var gSideliteStyleOptionLeftKey = "ssol";
	var gSideliteStyleOptionRightKey = "ssor";
	var gTransomStyleOptionKey = "tso";

	/*<%-- sidelite orientations --%>*/
	var gOrientationLeft = "left";
	var gOrientationRight = "right";

	/*<%-- no glass and clear glass door style options --%>*/
	var gNoGlassOption = null;
	var gClearGlassOption = null;

	/*<%-- quote session id --%>*/
	var gQuoteSessionId = null;

	/*<%-- call to initialize the page --%>*/
	function initPage(quoteSessionId) 
	{
		/*<%-- initialize the gQuoteSessionId --%>*/
		gQuoteSessionId = quoteSessionId;
		
		initAccordian();
		initClueTips();
		initSelectedItems();
		initFilters();
		doorAndGlassSelectionController(false);
		toggleDoorProperties();
		showHideZoomButton();
		setZoomClickUrl();
		setGlassDetailLink(getSelectedGlass(), 'doorpropertiesminiglassmoreinfo');
		
		if(getSelectedDoorStyleOption() == null)
		{
		    updateDoorPreview(getImageInstructionsPlaceHolderImg());
        }

        initDoorPreviewMouseClick();


		/* show the door configuration details */
        if (document.URL.indexOf('showDoorConfig=true') > 0) {
        	$('#' + gZoomDetail).click();
        }

		
    }

    function initDoorPreviewMouseClick() 
    {
        /*<%-- add a click handler to the door preview image --%>*/
        $('#' + gZoomImgDetail).click(function() {
            /*<%-- clicking the door image is the same as clicking the zoom button --%>*/
            if ($('#' + gZoomDetail).attr('href') != '#') 
            {
                $('#' + gZoomDetail).click();
            }
        });
        /*<%-- add a mouse hover to the door preview image --%>*/
        $('#' + gZoomImgDetail).mouseover(function() {
            if ($('#' + gZoomDetail).attr('href') != '#') 
            {
                $('#' + gZoomImgDetail).attr('style', 'cursor:pointer;');
            }
            else {
                $('#' + gZoomImgDetail).attr('style', 'cursor:default;');
            }
        });
    }

	/*<%-- initialize the accordian animation --%>*/
	function initAccordian()
	{
		/*<%-- sets inital state of options --%>*/
		$('.option ul:not(:first)').hide();
		$('#doorHeader').addClass('down');
		$('#glass h3').addClass('down');
		$('#glass ul').show();

		/*<%-- toggles option containers on click --%>*/
		$('.option h3:not(:first)').click(function(){
			$(this).toggleClass('down');
			$(this).parent().find('ul').slideToggle("slow");
	
			
			 //Adds Auto-Collapse functionality to the page
			if( !$(this).is('#doorHeader, #glassHeader') ){
				//Adds Auto-Scroll functionality to the page
				$.scrollTo( $('#selectionsHeader') ,500, {onAfter:function(){  
					$('#doorStyles').slideUp(1000);
					$('#doorHeader').removeClass('down');
					$('#doorfilters').slideUp();
					$('#glassOptions').slideUp(1000);
					$('#glassHeader').removeClass('down');
				} } );
			}else{
				$('#sidelitesleft ul').slideUp(1000);
				$('#sidelitesleft h3').removeClass('down');
				$('#sidelitesright ul').slideUp(1000);
				$('#sidelitesright h3').removeClass('down');
				$('#transom ul').slideUp(1000);
				$('#transom h3').removeClass('down');
			}
			

			if ( !$(this).hasClass('down') && $(this).is('#doorHeader') ){ $('#doorfilters').slideUp(); }

			return false;
		});

		$('.option .filter').click(function(){
			$('#doorfilters').slideToggle("slow");
			//ensures if the filters are shown, the doors are shown
			if (!$('#doorHeader').hasClass('down')) {
				$('#doorStyles').slideDown();
				$('#doorHeader').addClass('down');
			}
			return false;
		});
	}

	/*<%-- initialize the clue tips --%>*/
	function initClueTips()
	{
	  $('.houdini').cluetip({
	    splitTitle: '|', // use the invoking element's title attribute to populate the clueTip...
	                     // ...and split the contents into separate divs where there is a "|"
	    showTitle: false, // hide the clueTip's heading
	    fx: {
          open: 'fadeIn',
          openSpeed:  ''
		},
		activation: 'click',
		sticky: true,
		closePosition: 'bottom',
		closeText: 'close',
		arrows: true,
		dropShadowSteps: 3

	  });
	}

	/*<%-- if the page was bookmarked, the selected selected door configuration options can be reloaded --%>*/
	function initSelectedItems()
	{
		/*<%-- update the selected door image --%>*/
		setPreviewDoor(getSelectedDoorStyleOption(), getSelectedGlass());

		/*<%-- update the selected sidelite image --%>*/
		setPreviewSidelite(getSelectedSideliteOptionRight(), gOrientationRight, getSelectedGlass());

		/*<%-- update the selected sidelite image --%>*/
		setPreviewSidelite(getSelectedSideliteOptionLeft(), gOrientationLeft, getSelectedGlass());

		/*<%-- update the selected transom image --%>*/
		setPreviewTransom(getSelectedTransomOption(), getSelectedGlass());
	}

	/*<%-- registers a click event for the element doorStyleOptionLinkId and passes the doorStyleOption to the doorClickHandler --%>*/
	function initDoorStyleOptionSelection(doorStyleOptionId, doorStyleOptionLinkId)
	{
		var doorLink = $('#' + doorStyleOptionLinkId);
		var doorStyleOption = gDoorStyleOptionHash[doorStyleOptionId];

		doorLink.bind('click', { doorStyleOption: doorStyleOption }, doorClickHandler);
		doorLink.attr('href', '#');

		doorLink.bind('click', {}, handleZoomClickUrl);
		doorLink.bind('click', {}, handleGlassDetailClickUrl);

		/*<%-- the hash for this option is indicated in the url, remember it to click on that link once the page loads --%>*/
		if(doorStyleOptionId == getDocumentHashValue(gDoorStyleOptionKey))
		{
			setLoadedDoorLinkId(doorStyleOptionLinkId);
		}
	}

	/*<%-- registers a click event for the element glassOptionLinkId and passes the glassOption to the glassClickHandler --%>*/
	function initGlassOptionSelection(glassOptionId, glassOptionLinkId, glassOptionDescriptionLinkId, glassOptionInfoImgLinkId)
	{
		var glassLink = $('#' + glassOptionLinkId);
		var glassDetail = $('#' + glassOptionDescriptionLinkId);
		var glassOption = gGlassOptionHash[glassOptionId];

		if(glassOption.GlassFamily.IsNoGlass)
		{
			gNoGlassOption = glassOption;
		}
		if(glassOption.GlassFamily.IsClear)
		{
			gClearGlassOption = glassOption;
		}

		glassLink.bind ('click', { glassOption: glassOption }, glassClickHandler);
		glassLink.attr('href', '#');

		/*<%-- set the thickbox url's for this glass option --%>*/
		setGlassDetailLink(glassOption, glassOptionDescriptionLinkId);
		setGlassDetailLink(glassOption, glassOptionInfoImgLinkId);

		glassLink.bind('click', {}, handleZoomClickUrl);
		glassLink.bind('click', {}, handleGlassDetailClickUrl);

		/*<%-- the hash for this option is indicated in the url, remember it to click on that link once the page loads --%>*/
		if(glassOptionId == getDocumentHashValue(gGlassOptionKey))
		{
			setLoadedGlassLinkId(glassOptionLinkId);
		}
	}

	/*<%-- registers click events for the left sidelite options --%>*/
	function initSideliteStyleOptionSelectionLeft(sideliteStyleOptionId, sideliteStyleOptionLinkId)
	{
		var sideliteLink = $('#' + sideliteStyleOptionLinkId);
		var sideliteStyleOption = gSideliteStyleOptionHash[sideliteStyleOptionId];

		sideliteLink.bind('click', { sideliteStyleOption: sideliteStyleOption, orientation: gOrientationLeft }, sideliteStyleOptionClickHandlerLeft);
		sideliteLink.attr('href', '#');

		sideliteLink.bind('click', {}, handleZoomClickUrl);

		/*<%-- the hash for this option is indicated in the url, remember it to click on that link once the page loads --%>*/
		if(sideliteStyleOptionId == getDocumentHashValue(gSideliteStyleOptionLeftKey))
		{
			setLoadedSideliteLeftLinkId(sideliteStyleOptionLinkId);
		}
	}

	/*<%-- registers click events for the right sidelite options --%>*/
	function initSideliteStyleOptionSelectionRight(sideliteStyleOptionId, sideliteStyleOptionLinkId)
	{
		var sideliteLink = $('#' + sideliteStyleOptionLinkId);
		var sideliteStyleOption = gSideliteStyleOptionHash[sideliteStyleOptionId];

		sideliteLink.bind ('click', { sideliteStyleOption: sideliteStyleOption, orientation: gOrientationRight }, sideliteStyleOptionClickHandlerRight);
		sideliteLink.attr('href', '#');

		sideliteLink.bind('click', {}, handleZoomClickUrl);

		/*<%-- the hash for this option is indicated in the url, remember it to click on that link once the page loads --%>*/
		if(sideliteStyleOptionId == getDocumentHashValue(gSideliteStyleOptionRightKey))
		{
			setLoadedSideliteRightLinkId(sideliteStyleOptionLinkId);
		}
	}

	function initTransomStyleOptionSelection(transomStyleOptionId, transomStyleOptionLinkId)
	{
		var transomLink = $('#' + transomStyleOptionLinkId);
		var transomStyleOption = gTransomStyleOptionHash[transomStyleOptionId];

		transomLink.bind ('click', { transomStyleOption: transomStyleOption }, transomStyleOptionClickHandler);
		transomLink.attr('href', '#');

		transomLink.bind('click', {}, handleZoomClickUrl);

		/*<%-- the hash for this option is indicated in the url, remember it to click on that link once the page loads --%>*/
		if(transomStyleOptionId == getDocumentHashValue(gTransomStyleOptionKey))
		{
			setLoadedTransomLinkId(transomStyleOptionLinkId);
		}
	}

	function initFilters()
	{
		$('#' + gCheckboxEnergyStar).bind('click', {}, doorFilterClickHandler);
		$('#' + gCheckboxImpactRated).bind('click', {}, doorFilterClickHandler);
		$('#' + gCheckboxFlushGlazed).bind('click', {}, doorFilterClickHandler);
	}


	function handleZoomClickUrl(event) 
	{
		setZoomClickUrl();
		showHideZoomButton();

		/*<%-- cancel the click event --%>*/
		event.preventDefault();
	}

	function setZoomClickUrl()
	{
		var args = {};
		args['doorSubLine'] = gDoorSubLine;
		if((getSelectedGlass() != null) && (getSelectedDoorStyleOption() != null))
		{
			args['glassFamily'] = getSelectedGlass().GlassFamily.Family;
			if(getSelectedDoorStyleOption() != null)
			{
				args['doorStyleShape'] = getSelectedDoorStyleOption().DoorStyle.StyleShape;
			}
			if(getSelectedSideliteOptionRight() != null)
			{
				args['sideliteRightStyleShape'] = getSelectedSideliteOptionRight().DoorStyle.StyleShape;
				args['sideliteRightStyleIsNoGlass'] = getSelectedSideliteOptionRight().IsNoGlass;

			}
			if(getSelectedSideliteOptionLeft() != null)
			{
				args['sideliteLeftStyleShape'] = getSelectedSideliteOptionLeft().DoorStyle.StyleShape;
				args['sideliteLeftStyleIsNoGlass'] = getSelectedSideliteOptionLeft().IsNoGlass;

			}
			if(getSelectedTransomOption() != null)
			{
				args['transomStyleShape'] = getSelectedTransomOption().DoorStyle.StyleShape;
				args['transomStyleIsNoGlass'] = getSelectedTransomOption().IsNoGlass;
			}
			args['doorHeight'] = escape(getDoorHeight());


			var qs = "quotesessionid=" + gQuoteSessionId;

			/*<%-- append existing query string parameters --%>*/
			for (var key in args) {
				qs += ('&' + key + '=' + args[key]);
			}
			/*<%-- add the current url to appear in any quote requests --%>*/
			qs += '&detailPath=' + escape(escape(document.location));

			/*<%-- set the thickbox url parameters --%>*/
			/*<%-- indicates this is an iframe, so printing works, querystring params need to be before 'TB_iframe=' --%>*/
			$('#' + gZoomDetail).attr('href', gDoorImagePreviewProvider + "?" + qs + "&TB_iframe=true&height=500&width=800&modal=false");
			$('#wheretobuycontact').attr('href', gDoorImagePreviewProvider + "?wtb=true&" + qs);
		}
		else
		{
			$('#' + gZoomDetail).attr('href', '#');
		}
	}

	function showHideZoomButton()
	{
		if((getSelectedGlass() != null) && (getSelectedDoorStyleOption() != null))
		{
			$('#' + gZoomDetail).show();
			//$('#' + gAvailableStyles).show();
		}
		else
		{
			$('#' + gZoomDetail).hide();
			//$('#' + gAvailableStyles).hide();
		}
	}

	/*<%-- handle door filtration actions --%>*/
	function doorFilterClickHandler(event)
	{
		setSelectedDoorStyleOption(null);
		setSelectedGlass(null);
		setSelectedSideliteOptionLeft(null);
		setSelectedSideliteOptionRight(null);
		setSelectedTransomOption(null);

		unshadeItem($('#glassOptions li'));
		setPreviewDoor(null, null);

		styleDoorPreviewDimensions(null, null);
		toggleDoorProperties();
		showHideZoomButton();
		setZoomClickUrl();

		highlightItems();
		filterDoorOptions();
		refreshStyleCounts();
	}

	function filterDoorOptions()
	{
		var isEnergyStarClick = (($('#' + gCheckboxEnergyStar).attr('checked') == null) ? false : $('#' + gCheckboxEnergyStar).attr('checked'));
		var isImpactRatedClick = (($('#' + gCheckboxImpactRated).attr('checked') == null) ? false : $('#' + gCheckboxImpactRated).attr('checked'));
		var isFlushGlazedClick = (($('#' + gCheckboxFlushGlazed).attr('checked') == null) ? false : $('#' + gCheckboxFlushGlazed).attr('checked'));

		/*<%-- build an array of classes matching the filter --%>*/
		var classes = new Array();
		if(isEnergyStarClick)
		{
			classes[classes.length] = 'IsEnergyStarAvailable-True';
		}
		if(isImpactRatedClick)
		{
			classes[classes.length] = 'IsImpactRatedDoorAvailable-True';
		}
		if(isFlushGlazedClick)
		{
			classes[classes.length] = 'IsFlushGlazedAvailable-True';
		}

		/*<%-- highlight the matching doors styles --%>*/
		$('#doorStyles li').each(function() {
			var matchCount = 0;
			/*<%-- count the number of classes this doorStyle matches --%>*/
			for(var i = 0; i < classes.length; i++)
			{
				if($(this).hasClass(classes[i]))
				{
					matchCount++;
				}
			}
			/*<%-- if the match count equals the number of classes, then all classes match this door style, highlight it --%>*/
			if(matchCount == classes.length)
			{
				unshadeItem($(this));
			}
			else
			{
				shadeItem($(this));
			}
		});
	}

	function clearFilters()
	{
		$('#' + gCheckboxEnergyStar).removeAttr('checked');
		$('#' + gCheckboxImpactRated).removeAttr('checked');
		$('#' + gCheckboxFlushGlazed).removeAttr('checked');
	}

	function doorClickHandler(event)
	{
		setSelectedDoorStyleOption(event.data.doorStyleOption);
		doorAndGlassSelectionController(true);

		/*<%-- cancel the click event --%>*/
		event.preventDefault();
	}

	function glassClickHandler(event)
	{
		setSelectedGlass(event.data.glassOption);
		doorAndGlassSelectionController(false);

		/*<%-- cancel the click event --%>*/
		event.preventDefault();
	}

	function doorAndGlassSelectionController(isDoorClick)
	{

		if((getSelectedDoorStyleOption() != null) && (getSelectedGlass() == null))
		{
			/*<%-- door is selected, but glass is not --%>*/
			handleDoorOnly();
		}
		else if((getSelectedGlass() != null) && (getSelectedDoorStyleOption() == null))
		{
			/*<%-- glass is selected, but door is not --%>*/
			handleGlassOnly();
		}
		else if((getSelectedDoorStyleOption() != null) && (getSelectedGlass() != null))
		{
			/*<%-- door and glass are selected --%>*/
			handleDoorAndGlass(isDoorClick);
		}
		else
		{
			/*<%-- neither door nor glass are selected --%>*/
		}

		/*<%-- clear selected sidelites and transoms if they are not valid for the glass or door selections --%>*/
		if(!isSideliteValidForGlassSelection(getSelectedSideliteOptionLeft(), getSelectedGlass()))
		{
			setSelectedSideliteOptionLeft(null);
		}
		if(!isSideliteValidForGlassSelection(getSelectedSideliteOptionRight(), getSelectedGlass()))
		{
			setSelectedSideliteOptionRight(null);
		}
		if(!isTransomValidForGlassSelection(getSelectedTransomOption(), getSelectedGlass()))
		{
			setSelectedTransomOption(null);
		}

		/*<%-- style the transoms --%>*/
		styleLeftSidelitesForGlass();
		styleRightSidelitesForGlass();

		/*<%-- style the transoms --%>*/
		styleTransomsForGlass();

		/*<%-- a door selection has been made, clear the filters --%>*/
		clearFilters();

		/*<%-- refresh style counts --%>*/
		refreshStyleCounts();

		/*<%-- highlight selected options --%>*/
		highlightItems();

		toggleDoorProperties();
	}

	function handleDoorOnly()
	{
		/*<%-- door selected, but no glass selected yet --%>*/

		if(getSelectedDoorStyleOption().IsNoGlass)
		{
			/*<%-- a solid door is selected --%>*/

			/*<%-- no door is selected, so only display solid doors and "no glass" --%>*/
			/*<%-- fade all the door options except the solid doors --%>*/
			shadeItem($('#doorStyles').find(".IsNoGlass-False"));
			unshadeItem($('#doorStyles').find(".IsNoGlass-True"));

			/*<%-- fade all the glass options except the no glass option --%>*/
			shadeItem($('#glassOptions').find(".IsNoGlass-False"));
			unshadeItem($('#glassOptions').find(".IsNoGlass-True"));

			/*<%-- set selected glass as "no glass" since it is the only possible choice --%>*/
			setSelectedGlass(getNoGlassOption());
		}
		else
		{
			/*<%-- a door with glass is selected --%>*/

			/*<%-- show all glass doors --%>*/
			shadeItem($('#doorStyles').find(".IsNoGlass-True"));
			unshadeItem($('#doorStyles').find(".IsNoGlass-False"));

			/*<%-- shade all glass options --%>*/
			shadeItem($("#glassOptions li"));

			if(getSelectedDoorStyleOption().IsGlassFamilyException)
			{
				/*<%-- set selected glass as the exception glass --%>*/
				setSelectedGlass(gGlassOptionHash[getSelectedDoorStyleOption().GlassFamilyException.Family.toLowerCase()]);
			}
			else
			{
				/*<%-- set selected glass as "clear" --%>*/
				setSelectedGlass(getClearGlassOption());
			}

			/*<%-- unshade the available glass options --%>*/
			unshadeAvailableGlass();

			/*<%-- fade all the solid door options --%>*/
			shadeItem($('#doorStyles').find(".IsNoGlass-True"));

			/*<%-- fade "no glass" glass options --%>*/
			shadeItem($('#glassOptions').find(".IsNoGlass-True"));
		}

		/*<%-- update the preview image --%>*/
		setPreviewDoor(getSelectedDoorStyleOption(), getSelectedGlass());
	}


	function handleGlassOnly()
	{
		/*<%-- glass is selected, but door is not --%>*/

		if(getSelectedGlass().GlassFamily.IsNoGlass)
		{
			/*<%-- "no glass" glass selected --%>*/

			/*<%-- only display solid doors and "no glass" --%>*/
			/*<%-- fade all the door options except the solid doors --%>*/
			shadeItem($("#doorStyles li"));
			unshadeItem($('#doorStyles').find(".IsNoGlass-True"));

			/*<%-- fade all the glass options except the no glass option --%>*/
			shadeItem($("#glassOptions li"));
			unshadeItem($('#glassOptions').find(".IsNoGlass-True"));
		}
		else
		{
			/*<%-- display everything except solid doors and "no glass" --%>*/

			/*<%-- fade all doors --%>*/
			shadeItem($("#doorStyles li"));

			/*<%-- show normal glass options --%>*/
			unshadeItem($('#glassOptions').find(".IsNoGlass-False"));

			/*<%-- unshade the available door options --%>*/
			unshadeAvailableDoors();

			/*<%-- fade all solid doors --%>*/
			shadeItem($('#doorStyles').find(".IsNoGlass-True"));

			/*<%-- fade "no glass" option --%>*/
			shadeItem($('#glassOptions').find(".IsNoGlass-True"));
		}

	}

	function handleDoorAndGlass(isDoorClick)
	{
		/*<%-- door and glass are selected --%>*/

		if((getSelectedDoorStyleOption().IsNoGlass) || (getSelectedGlass().GlassFamily.IsNoGlass))
		{
			/*<%-- door or glass are "no glass" options --%>*/

			/*<%-- fade all the door options except the solid doors --%>*/
			shadeItem($("#doorStyles li"));
			unshadeItem($('#doorStyles').find(".IsNoGlass-True"));

			/*<%-- fade all the glass options except the no glass option --%>*/
			shadeItem($("#glassOptions li"));
			unshadeItem($('#glassOptions').find(".IsNoGlass-True"));
		}

		if((getSelectedGlass().GlassFamily.IsNoGlass) && (getSelectedDoorStyleOption().IsNoGlass == false))
		{
			/*<%-- glass is "no glass", door has glass --%>*/

			if(isDoorClick)
			{
				/*<%-- "no glass" is selected and a door with glass was just clicked --%>*/

				/*<%-- display everything except solid doors and "no glass" --%>*/
				/*<%-- fade all solid doors --%>*/
				shadeItem($("#doorStyles li"));
				//unshadeItem($('#doorStyles').find(".IsNoGlass-False"));

				/*<%-- fade "no glass" option --%>*/
				shadeItem($("#glassOptions li"));
				unshadeItem($('#glassOptions').find(".IsNoGlass-False"));

				if(getSelectedDoorStyleOption().IsGlassFamilyException)
				{
					/*<%-- set selected glass as the exception glass --%>*/
					setSelectedGlass(gGlassOptionHash[getSelectedDoorStyleOption().GlassFamilyException.Family.toLowerCase()]);
				}
				else
				{
					/*<%-- set selected glass as "clear" --%>*/
					setSelectedGlass(getClearGlassOption());
				}

				/*<%-- unshade the available glass options --%>*/
				unshadeAvailableDoors();
			}
			else
			{
				/*<%-- a door with no glass was selected and "no glass" was just clicked --%>*/

				/*<%-- fade all glass doors --%>*/
				shadeItem($('#doorStyles').find(".IsNoGlass-False"));
				unshadeItem($('#doorStyles').find(".IsNoGlass-True"));

				/*<%-- fade normal glass options --%>*/
				shadeItem($('#glassOptions').find(".IsNoGlass-False"));
				unshadeItem($('#glassOptions').find(".IsNoGlass-True"));

				setSelectedDoorStyleOption(null);
			}
		}
		else if((getSelectedDoorStyleOption().IsNoGlass) && (getSelectedGlass().GlassFamily.IsNoGlass == false))
		{
			/*<%-- door is solid, glass is normal --%>*/

			if(isDoorClick)
			{
				/*<%-- a normal glass option was selected and a solid door was just clicked --%>*/

				/*<%-- only display solid doors and "no glass" --%>*/
				/*<%-- fade all the door options except the solid doors --%>*/
				shadeItem($('#doorStyles').find(".IsNoGlass-False"));
				unshadeItem($('#doorStyles').find(".IsNoGlass-True"));

				/*<%-- fade all the glass options except the no glass option --%>*/
				shadeItem($('#glassOptions').find(".IsNoGlass-False"));
				unshadeItem($('#glassOptions').find(".IsNoGlass-True"));

				/*<%-- set selected glass as "no glass" since it is the only possible choice --%>*/
				setSelectedGlass(getNoGlassOption());
			}
			else
			{
				/*<%-- a solid door was selected and a normal glass option was just clicked --%>*/

				/*<%-- display everything except solid doors and "no glass" --%>*/
				/*<%-- fade all doors --%>*/
				shadeItem($("#doorStyles li"));

				/*<%-- these selections are incompatible, reset the door --%>*/
				setSelectedDoorStyleOption(null);
				setSelectedSideliteOptionLeft(null);
				setSelectedSideliteOptionRight(null);
				setSelectedTransomOption(null);

				/*<%-- unshade the available door options --%>*/
				unshadeAvailableDoors();

				/*<%-- fade all solid doors --%>*/
				shadeItem($('#doorStyles').find(".IsNoGlass-True"));

				/*<%-- fade "no glass" option --%>*/
				shadeItem($('#glassOptions').find(".IsNoGlass-True"));

				/*<%-- show glass options --%>*/
				unshadeItem($('#glassOptions').find(".IsNoGlass-False"));

			}
		}
		else if((getSelectedDoorStyleOption().IsNoGlass == false) && (getSelectedGlass().GlassFamily.IsNoGlass == false))
		{
		    /*<%-- door has glass, glass is normal --%>*/

			/*<%-- shade all door and glass options --%>*/
			shadeItem($("#doorStyles li"));
			shadeItem($("#glassOptions li"));

			if(isDoorClick)
			{
			    /*<%-- a normal glass option was selected and a door with glass was just clicked --%>*/

				/*<%-- make sure the selected door is valid for the clicked glass --%>*/
				if(!isSelectedGlassValidForDoorSelection(getSelectedGlass(), getSelectedDoorStyleOption()))
				{
					if(getSelectedDoorStyleOption().IsGlassFamilyException)
					{
						/*<%-- set selected glass as the exception glass --%>*/
						setSelectedGlass(gGlassOptionHash[getSelectedDoorStyleOption().GlassFamilyException.Family.toLowerCase()]);
					}
					else
					{
						/*<%-- set selected glass as "clear" --%>*/
						setSelectedGlass(getClearGlassOption());
					}
					setSelectedSideliteOptionLeft(null);
					setSelectedSideliteOptionRight(null);
					setSelectedTransomOption(null);

					/*<%-- unshade the available glass options --%>*/
					unshadeAvailableDoors();
				}
			}
			else
			{
				/*<%-- a door with glass was selected and a normal glass option was just clicked --%>*/

				/*<%-- make sure the selected door is valid for the clicked glass --%>*/
				if(!isSelectedGlassValidForDoorSelection(getSelectedGlass(), getSelectedDoorStyleOption()))
				{
					setSelectedDoorStyleOption(null);
					setSelectedSideliteOptionLeft(null);
					setSelectedSideliteOptionRight(null);
					setSelectedTransomOption(null);

					/*<%-- unshade all normal glass options --%>*/
					unshadeItem($('#glassOptions').find(".IsNoGlass-False"));
				}

			}

			/*<%-- unshade the available door options --%>*/
			unshadeAvailableDoors();

			/*<%-- unshade the available glass options --%>*/
			unshadeAvailableGlass();

			/*<%-- fade all solid doors --%>*/
			shadeItem($('#doorStyles').find(".IsNoGlass-True"));

			/*<%-- fade "no glass" option --%>*/
			shadeItem($('#glassOptions').find(".IsNoGlass-True"));
		}

		/*<%-- update the preview image --%>*/
		setPreviewDoor(getSelectedDoorStyleOption(), getSelectedGlass());
	}

	function sideliteStyleOptionClickHandlerLeft(event)
	{
		var sideliteOption = event.data.sideliteStyleOption;

		if(getSelectedGlass() != null)
		{
			var deselect = false;
			if(getSelectedSideliteOptionLeft() != null)
			{
				if(sideliteOption.SideliteStyleOptionId == getSelectedSideliteOptionLeft().SideliteStyleOptionId)
				{
					deselect = true;
				}
			}

			if(deselect)
			{
				/*<%-- this sidelite is already selected, deselect it --%>*/
				setSelectedSideliteOptionLeft(null);
			}
			else
			{
				if(isSideliteValidForGlassSelection(sideliteOption, getSelectedGlass()))
				{
					/*<%-- select this sidelite --%>*/
					setSelectedSideliteOptionLeft(sideliteOption);
				}
			}

			/*<%-- refresh style counts --%>*/
			refreshStyleCounts();

			/*<%-- style the sidelites --%>*/
			styleLeftSidelitesForGlass();

			/*<%-- highlight selected options --%>*/
			highlightItems();
		}
		else
		{
			alert('Please select a Glass Style.');
		}

		/*<%-- cancel the click event --%>*/
		event.preventDefault();
	}

	function sideliteStyleOptionClickHandlerRight(event)
	{
		var sideliteOption = event.data.sideliteStyleOption;

		if(getSelectedGlass() != null)
		{
			var deselect = false;
			if(getSelectedSideliteOptionRight() != null)
			{
				if(sideliteOption.SideliteStyleOptionId == getSelectedSideliteOptionRight().SideliteStyleOptionId)
				{
					deselect = true;
				}
			}

			if(deselect)
			{
				/*<%-- this sidelite is already selected, deselect it --%>*/
				setSelectedSideliteOptionRight(null);
			}
			else
			{
				if(isSideliteValidForGlassSelection(sideliteOption, getSelectedGlass()))
				{
					/*<%-- select this sidelite --%>*/
					setSelectedSideliteOptionRight(sideliteOption);
				}
			}

			/*<%-- refresh style counts --%>*/
			refreshStyleCounts();

			/*<%-- style the sidelites --%>*/
			styleRightSidelitesForGlass();

			/*<%-- highlight selected options --%>*/
			highlightItems();
		}
		else
		{
			alert('Please select a Glass Style.');
		}

		/*<%-- cancel the click event --%>*/
		event.preventDefault();
	}

	function transomStyleOptionClickHandler(event)
	{
		var transomOption = event.data.transomStyleOption;

		if(getSelectedGlass() != null)
		{
			var deselect = false;
			if(getSelectedTransomOption() != null)
			{
				if(transomOption.TransomStyleOptionId == getSelectedTransomOption().TransomStyleOptionId)
				{
					deselect = true;
				}
			}

			if(deselect)
			{
				/*<%-- this transom is already selected, deselect it --%>*/
				setSelectedTransomOption(null);
			}
			else
			{
				if(isTransomValidForGlassSelection(transomOption, getSelectedGlass()))
				{
					/*<%-- select this transom --%>*/
					setSelectedTransomOption(transomOption);
				}
			}

			/*<%-- refresh style counts --%>*/
			refreshStyleCounts();

			/*<%-- style the transoms --%>*/
			styleTransomsForGlass();

			/*<%-- highlight selected options --%>*/
			highlightItems();
		}
		else
		{
			alert('Please select a Glass Style');
		}

		/*<%-- cancel the click event --%>*/
		event.preventDefault();
	}

	function unshadeAvailableDoors()
	{
		if(getSelectedGlass() != null)
		{
			/*<%-- unshade the available door style options --%>*/
			unshadeItem($('#doorStyles').find(".AvailableGlass-" + getSelectedGlass().GlassFamily.Family));
		}
	}

	function unshadeAvailableGlass()
	{
		if(getSelectedDoorStyleOption() != null)
		{
			/*<%-- unshade the available glass options --%>*/
			var availableGlassStyles = getSelectedDoorStyleOption().AvailableGlassOptions;
			for(var i = 0; i < availableGlassStyles.length; i++)
			{
				unshadeItem($('#glassOptions').find(".GlassFamily-" + availableGlassStyles[i].Family));
			}
		}
	}

	/*<%-- style the left sidelites for the selected door --%>*/
	function styleLeftSidelitesForGlass()
	{
		styleSidelitesForGlass(getSelectedGlass(), 'sideliteStylesLeft', 'sideliteStyleLeft');
		setPreviewSidelite(getSelectedSideliteOptionLeft(), gOrientationLeft, getSelectedGlass());
	}

	/*<%-- style the right sidelites for the selected door --%>*/
	function styleRightSidelitesForGlass()
	{
		styleSidelitesForGlass(getSelectedGlass(), 'sideliteStylesRight', 'sideliteStyleRight');
		setPreviewSidelite(getSelectedSideliteOptionRight(), gOrientationRight, getSelectedGlass());
	}

	/*<%-- style the sidelites based on the glass --%>*/
	function styleSidelitesForGlass(glassOption, sideliteStylesId, sideliteStyleLiId)
	{
		var sideliteOptionId = null;
		var sideliteOption = null;

		/*<%-- shade sidelite options --%>*/
		shadeItem($('#' + sideliteStylesId + ' li'));

		if(glassOption != null)
		{
			/*<%-- if the selected glass is "no glass", treat the sidelites as if clear glass was selected --%>*/
			if(glassOption.GlassFamily.IsNoGlass)
			{
				glassOption = getClearGlassOption();
			}

			$("#" + sideliteStylesId).find("li[@id^='" + sideliteStyleLiId + "-']").each(function () {
				/*<%-- get the sidelite --%>*/
				sideliteOptionId = $(this).attr('id').replace(sideliteStyleLiId + '-', '');
				sideliteOption = gSideliteStyleOptionHash[sideliteOptionId];

				if(isSideliteValidForGlassSelection(sideliteOption, glassOption))
				{
					unshadeItem($(this));
				}
			});
		}
		else
		{
			/*<%-- no glass selected and/or no door selected --%>*/
			shadeItem($('#' + sideliteStylesId + ' li'));
		}
	}

	function styleTransomsForGlass()
	{
		var transomOptionId = null;
		var transomOption = null;

		var glassOption = getSelectedGlass();

		/*<%-- shade all transom options --%>*/
		shadeItem($('#transomStyles li'));

		if(glassOption != null)
		{
			/*<%-- glass and door are selected --%>*/

			/*<%-- if the selected glass is "no glass", treat the transoms as if clear glass was selected --%>*/
			if(glassOption.GlassFamily.IsNoGlass)
			{
				glassOption = getClearGlassOption();
			}

			$("#transomStyles").find("li[@id^='transomStyle-']").each(function () {
				/*<%-- get the transom --%>*/
				transomOptionId = $(this).attr('id').replace('transomStyle-', '');
				transomOption = gTransomStyleOptionHash[transomOptionId];

				if(isTransomValidForGlassSelection(transomOption, glassOption))
				{
					unshadeItem($(this));
				}
			});
		}
		else
		{
			/*<%-- no glass selected and/or no door selected --%>*/
			shadeItem($('#transomStyles li'));
		}

		setPreviewTransom(getSelectedTransomOption(), getSelectedGlass());
	}

	function styleDoorPreviewDetails(door, glassOption)
	{
		if(glassOption != null)
		{
			$('#selectedGlass').html(glassOption.GlassFamily.FamilyDescription);
        }
		else
		{
			$('#selectedGlass').html('');
		}

		showHide($('#features'), (glassOption.GlassFamily.IsGrille));

		showHide($('#availableoptions'), (door.DoorConfigDetails.IsFlushGlazed || door.DoorConfigDetails.IsImpactRated));
		showHide($('#flushGlazed'), (door.DoorConfigDetails.IsFlushGlazed));
		showHide($('#impactRated'), (door.DoorConfigDetails.IsImpactRated));
		showHide($('#energyStar'), (door.DoorConfigDetails.IsEnergyStar));
		showHide($('#lowEGlass'), (door.DoorConfigDetails.IsLowE));

		return;
	}
	
	function showHide(obj, val)
	{
		if(val) {
			obj.show();
		}else {
			obj.hide();
		}
	}

	function styleDoorPreviewDimensions(doorStyleOption, glassOption)
	{
		$('#miniDimensions').hide();
		$('#sizeList').html('');

		if((doorStyleOption != null) && (glassOption != null))
		{
			var jsonArgs = {};
			jsonArgs['doorStyleShape'] = doorStyleOption.DoorStyle.StyleShape;
			jsonArgs['doorSubLine'] = gDoorSubLine;
			jsonArgs['glassFamily'] = glassOption.GlassFamily.Family;
			jsonArgs['doorHeight'] = getDoorHeight();

			$.getJSON(gJsonDoorDimensionsForOptions, jsonArgs, function data(dimensions) {
				var sizeList = '';
				for(var i = 0; i < dimensions.length; i++)
				{
					sizeList += "<li>" + dimensions[i].WidthDescription + " x " + dimensions[i].HeightDescription + "</li>\n";
				}
				$('#sizeList').html(sizeList);

				$('#miniDimensions').show();
			});
		}
	}

	/*<%--
		+ update the door image to display the loading image
		+ if the door is null, set the image to the placeholder image
		+ if the glass is null, set the image to the selected clear glass
		  door image - no need to make a JSON call since it is stored in the
		  selected door option
		+ if selected glass is clear, "no glass" or "exception glass" display
		  the selected door option image - no need to make a JSON call since
		  it is stored in the selected door option
		+ if none of the above are true, make a JSON call to find the selected door
		+ display the door preview details and door dimensions
	--%>*/
	function setPreviewDoor(doorStyleOption, glassOption)
	{
		/*<%-- display loading animation until JSON call completes --%>*/
		updateDoorPreview(gDoorLoadingImg);

		if(doorStyleOption == null)
		{
			/*<%-- replace the door with the placeholder image --%>*/
		    updateDoorPreview(getDoorPlaceHolderImg());
		}
		else
		{
			if(glassOption == null)
			{
				/*<%-- if the glass option hasn't been selected no need to make an ajax call --%>*/
				styleDoorPreviewDetails(doorStyleOption.ExampleDoor, glassOption);
				updateDoorPreview(doorStyleOption.ExampleDoor.ImagePathMedium);
			}
			else if(glassOption.GlassFamily.IsClear || glassOption.GlassFamily.IsNoGlass)
			{
				/*<%-- if the glass option is clear or solid no need to make an ajax call --%>*/
				styleDoorPreviewDetails(doorStyleOption.ExampleDoor, glassOption);
				updateDoorPreview(doorStyleOption.ExampleDoor.ImagePathMedium);
			}
			else
			{
				var jsonArgs = {};
				jsonArgs['doorStyleShape'] = doorStyleOption.DoorStyle.StyleShape;
				//jsonArgs['topCut'] = doorStyleOption.DoorStyle.TopCut.TopCut;
				jsonArgs['doorSubLine'] = gDoorSubLine;
				jsonArgs['glassFamily'] = glassOption.GlassFamily.Family;
				jsonArgs['doorHeight'] = getDoorHeight();
				/*<%-- JSON call --%>*/
				$.getJSON(gJsonDoorForOptions, jsonArgs, function data(door) {

					if(door != null)
					{
						styleDoorPreviewDetails(door, glassOption);
						updateDoorPreview(door.ImagePathMedium);
					}
					else
					{
					    updateDoorPreview(getDoorPlaceHolderImg());
					}
				});
			}
			styleDoorPreviewDimensions(doorStyleOption, glassOption);
		}
	}

	/*<%--
		+ update the sidelite image to display the loading image
		+ if the sidelite is null or the glass is null, set the image to the placeholder image
		+ if selected glass is "no glass" or sidelite does not contain glass display
		  the clear glass sidelite - no need to make a JSON call since it is stored in the
		  selected sidelite option
		+ if none of the above are true, make a JSON call to find the sidelite image path
	--%>*/
	function setPreviewSidelite(sideliteStyleOption, orientation, glassOption)
	{
		/*<%-- display loading animation until JSON call completes --%>*/
		if(orientation == gOrientationLeft)
		{
			updateSideliteLeftPreview(gSideliteLoadingImg);
		}
		else
		{
			updateSideliteRightPreview(gSideliteLoadingImg);
		}

		if(sideliteStyleOption == null)
		{
			if(orientation == gOrientationLeft)
			{
			    updateSideliteLeftPreview(getSidelitePlaceHolderImg());
			}
			else if(orientation == gOrientationRight)
			{
			    updateSideliteRightPreview(getSidelitePlaceHolderImg());
			}
		}
		else
		{
			if(glassOption == null)
			{
				if(orientation == gOrientationLeft)
				{
				    updateSideliteLeftPreview(getSidelitePlaceHolderImg());
				}
				else if(orientation == gOrientationRight)
				{
				    updateSideliteRightPreview(getSidelitePlaceHolderImg());
				}
			}
			else if((glassOption.GlassFamily.IsNoGlass) || (sideliteStyleOption.IsNoGlass))
			{
				/*<%-- if the no glass is selected OR the sidelite is solid, display the clear glass option --%>*/
				if(orientation == gOrientationLeft)
				{
					updateSideliteLeftPreview(sideliteStyleOption.ExampleSidelite.ImagePathMedium);
				}
				else if(orientation == gOrientationRight)
				{
					updateSideliteRightPreview(sideliteStyleOption.ExampleSidelite.ImagePathMedium);
				}
			}
			else
			{
				var jsonArgs = {};
				jsonArgs['doorStyleShape'] = sideliteStyleOption.DoorStyle.StyleShape;
				//jsonArgs['topCut'] = sideliteStyleOption.DoorStyle.TopCut.TopCut;
				jsonArgs['doorSubLine'] = gDoorSubLine;
				jsonArgs['glassFamily'] = glassOption.GlassFamily.Family;
				jsonArgs['doorHeight'] = getDoorHeight();

				/*<%-- JSON call --%>*/
				$.getJSON(gJsonGlassForSidelite, jsonArgs, function data(sidelite) {
					if(orientation == gOrientationLeft)
					{
						if(sidelite != null)
						{
							updateSideliteLeftPreview(sidelite);
						}
						else
						{
						    updateSideliteLeftPreview(getSidelitePlaceHolderImg());
						}
					}
					else if(orientation == gOrientationRight)
					{
						if(sidelite != null)
						{
							updateSideliteRightPreview(sidelite);
						}
						else
						{
						    updateSideliteRightPreview(getSidelitePlaceHolderImg());
						}
					}

				});
			}
		}
	}

	/*<%--
		+ update the transom image to display the loading image
		+ if the transom is null or the glass is null, set the image to the placeholder image
		+ if selected glass is "no glass" or transom does not contain glass display
		  the clear glass transom - no need to make a JSON call since it is stored in the
		  selected transom option
		+ if none of the above are true, make a JSON call to find the transom image path
	--%>*/
	function setPreviewTransom(transomOption, glassOption)
	{
		/*<%-- display loading animation until JSON call completes --%>*/
		updateTransomPreview(gTransomLoadingImg);

		if(transomOption == null)
		{
		    updateTransomPreview(getTransomPlaceHolderImg());
			$('#transomPreviewDiv').removeAttr('class');
        }
		else
		{
			if(glassOption == null)
			{
			    updateTransomPreview(getTransomPlaceHolderImg());
				/*<%-- clear classes on transom preview div --%>*/
				$('#transomPreviewDiv').removeAttr('class');
            }
			else if((glassOption.GlassFamily.IsNoGlass) || (transomOption.IsNoGlass))
			{
				/*<%-- if the no glass is selected OR transom is solid, display the clear glass option --%>*/
			    updateTransomPreview(transomOption.ExampleTransom.ImagePathMedium);
			    /*<%-- clear classes on transom preview div --%>*/
			    $('#transomPreviewDiv').removeAttr('class');
			    /*<%-- add style shape class to transom preview div --%>*/
			    $('#transomPreviewDiv').addClass('transomStyle-' + transomOption.ExampleTransom.DoorStyle.StyleShape);
			}
			else
			{
				var jsonArgs = {};
				jsonArgs['doorStyleShape'] = transomOption.DoorStyle.StyleShape;
				jsonArgs['doorSubLine'] = gDoorSubLine;
				jsonArgs['glassFamily'] = glassOption.GlassFamily.Family;

				/*<%-- JSON call  --%>*/
				$.getJSON(gJsonGlassForTransom, jsonArgs, function data(transom) {
					var transomImgPath = null;

					if(transom != null)
					{
						transomImgPath = transom;
					}
					else
					{
					    transomImgPath = getTransomPlaceHolderImg();
					}
					updateTransomPreview(transomImgPath);
					/*<%-- clear classes on transom preview div --%>*/
					$('#transomPreviewDiv').removeAttr('class');
					/*<%-- add style shape class to transom preview div --%>*/
					$('#transomPreviewDiv').addClass('transomStyle-' + transomOption.ExampleTransom.DoorStyle.StyleShape);
				});
			}
		}
	}

	/*<%-- determine if the selected glass and door options are compatible --%>*/
	function isSelectedGlassValidForDoorSelection(glassOption, doorStyleOption)
	{
		var isValidGlass = true;

		/*<%-- the door has just been selected (or changed) make sure the selected glass is available --%>*/
		if(glassOption != null)
		{
			if(glassOption.GlassFamily.IsNoGlass != doorStyleOption.IsNoGlass)
			{
				/*<%-- a solid door must not have glass --%>*/
			    isValidGlass = false;
			}
			else
			{
				isValidGlass = false;
				for(var i = 0; i < doorStyleOption.AvailableGlassOptions.length; i++)
				{
					var glassFamily = doorStyleOption.AvailableGlassOptions[i];
					if(glassOption.GlassFamily.Family == glassFamily.Family)
					{
						isValidGlass = true;
						break;
					}
				}
			}
		}

		return isValidGlass;
	}

	/*<%-- determine if the selected glass and sidelite options are compatible --%>*/
	function isSideliteValidForGlassSelection(sidelite, glassOption)
	{
		var isValid = false;

		if((glassOption != null) && (sidelite != null))
		{
			if(sidelite.IsNoGlass)
			{
				/*<%-- a solid sidelite should be available for all glass options --%>*/
				isValid = true;
			}
			else
			{
				/*<%-- if the selected glass is "no glass", treat the sidelite as if clear glass was selected --%>*/
				if(glassOption.GlassFamily.IsNoGlass)
				{
					glassOption = getClearGlassOption();
				}

				for(var i = 0; i < sidelite.AvailableGlassOptions.length; i++)
				{
					if(sidelite.AvailableGlassOptions[i].Family == glassOption.GlassFamily.Family)
					{
						isValid = true;
						break;
					}
				}
			}
		}

		return isValid;
	}

	/*<%-- determine if the selected glass and transom options are compatible --%>*/
	function isTransomValidForGlassSelection(transom, glassOption)
	{
		var isValid = false;

		if((glassOption != null) && (transom != null))
		{
			if(transom.IsNoGlass)
			{
				/*<%-- a solid transom should be available for all glass options --%>*/
				isValid = true;
			}
			else
			{
				/*<%-- if the selected glass is "no glass", treat the transoms as if clear glass was selected --%>*/
				if(glassOption.GlassFamily.IsNoGlass)
				{
					glassOption = getClearGlassOption();
				}

				for(var i = 0; i < transom.AvailableGlassOptions.length; i++)
				{
					if(transom.AvailableGlassOptions[i].Family == glassOption.GlassFamily.Family)
					{
						isValid = true;
						break;
					}
				}
			}
		}

		return isValid;
	}

	/*<%-- highlight all the selected items --%>*/
	function highlightItems()
	{
		if(getSelectedDoorStyleOption() != null)
		{
			highlightItem($('#doorStyle-' + getSelectedDoorStyleOption().DoorStyleOptionId));
		}
		if(getSelectedGlass() != null)
		{
			highlightItem($('#glassOption-' + getSelectedGlass().GlassOptionId));
		}
		if(getSelectedSideliteOptionLeft() != null)
		{
			highlightItem($('#sideliteStyleLeft-' + getSelectedSideliteOptionLeft().SideliteStyleOptionId));
		}
		if(getSelectedSideliteOptionRight() != null)
		{
			highlightItem($('#sideliteStyleRight-' + getSelectedSideliteOptionRight().SideliteStyleOptionId));
		}
		if(getSelectedTransomOption() != null)
		{
			highlightItem($('#transomStyle-' + getSelectedTransomOption().TransomStyleOptionId));
		}
	}

	/*<%-- set the thickbox url for the "more info" on the currently selected glass option --%>*/
	function handleGlassDetailClickUrl(event)
	{
		/*<%-- set the thickbox url for the "more info" on the currently selected glass option --%>*/
		setGlassDetailLink(getSelectedGlass(), 'doorpropertiesminiglassmoreinfo');

		/*<%-- cancel the click event --%>*/
		event.preventDefault();
	}

	/*<%-- set the url for the specified anchor and glass option --%>*/
	function setGlassDetailLink(glassOption, anchorId)
	{
		if(glassOption != null)
		{
			if(glassOption.GlassFamily.IsNoGlass)
			{
				if(anchorId == 'doorpropertiesminiglassmoreinfo')
				{
					$('#doorpropertiesminiglassmoreinfowrapper').hide();
				}
			}
			else
			{
				/*<%-- set the thickbox url parameters for the currently selected glass option --%>*/
				/*<%-- thickbox=true tells the glass detail page this is a thickbox request and not to display navigation --%>*/
				$('#' + anchorId).attr('href', glassOption.GlassFamily.ProductDetailPath + "?height=400&width=800&inlineId=glassdetail&thickbox=true");
				$('#doorpropertiesminiglassmoreinfowrapper').show();
			}
		}
		else
		{
			$('#' + anchorId).attr('href', '#');
		}
	}

	function refreshStyleCounts()
	{
		/*<%-- refresh number of available doors --%>*/
		$('#availabledoorstylescount').html(countedDisplayedItems($("#doorStyles li")) + ' Available Styles');

		/*<%-- refresh number of available glass families --%>*/
		$('#availableglassstylescount').html(countedDisplayedItems($("#glassOptions li")) + ' Available Styles');

		/*<%-- refresh number of available sidelites --%>*/
		$('#availablesideliteleftstylescount').html(countedDisplayedItems($("#sideliteStylesLeft li")) + ' Available Styles');
		$('#availablesideliterightstylescount').html(countedDisplayedItems($("#sideliteStylesRight li")) + ' Available Styles');

		/*<%-- refresh number of available transoms --%>*/
		$('#availabletransomstylescount').html(countedDisplayedItems($("#transomStyles li")) + ' Available Styles');
	}

	/*<%-- set the image src attribute for the door preview image --%>*/
	function updateDoorPreview(path)
	{
		$('#' + gDoorPreview).attr('src', gSiteRoot + path.replace('~', ''));
	}

	/*<%-- set the image src attribute for the left sidelite preview image --%>*/
	function updateSideliteLeftPreview(path)
	{
		$('#' + gSideliteLeftPreview).attr('src', gSiteRoot + path.replace('~', ''));
	}

	/*<%-- set the image src attribute for the right sidelite preview image --%>*/
	function updateSideliteRightPreview(path)
	{
		$('#' + gSideliteRightPreview).attr('src', gSiteRoot + path.replace('~', ''));
	}

	/*<%-- set the image src attribute for the transom preview image --%>*/
	function updateTransomPreview(path)
	{
		$('#' + gTransomPreview).attr('src', gSiteRoot + path.replace('~', ''));
	}

	/*<%--
		Hash consists of key value pairs, keys and values separated by colon ":"
		and key/value pairs separated by forward slashes "/".  The hash begins and
		ends with a forward slash "/"

		Example:
			http://server/path/document?query=value#<hash>

			where #<hash> format:
				#/key1:value1/key2:value2/key(n):value(n)/
	--%>*/
	function setDocumentHashValue(key, value)
	{
		var hash = document.location.hash;

		/*<%-- the hash is empty, add the key and value pairs --%>*/
		if((hash == '') || (hash == null))
		{
			hash = "/" + key + ":" + value + "/";
		}
		else
		{
			/*<%-- check to see if this hash value already exists --%>*/
			if(hash.indexOf('/' + key + ':') > -1)
			{
				/*<%-- replace the key's value with the new value --%>*/
				var regex = new RegExp('/' + key + ':[^/]*/', 'g');
				var replaceValue = '/' + key + ':' + value + '/';
				hash = hash.replace(regex, replaceValue);
			}
			else
			{
				/*<%-- append this key value pair to the hash --%>*/
				hash += key + ':' + value + '/';
			}
		}

		/*<%-- reset the hash --%>*/
		document.location.hash = hash;
		return;
	}

	/*<%-- removes the value from the document hash, see setDocumentHashValue --%>*/
	function removeDocumentHashValue(key)
	{
		if(document.location.hash.indexOf(key) > -1)
		{
			var value = getDocumentHashValue(key);
			var hash = document.location.hash;
			if(hash == ('#/' + key + ':' + value + '/'))
			{
				hash = '';
			}
			else
			{
				var regex = new RegExp('/' + key + ':' + value, 'g');
				hash = hash.replace(regex, '');
			}
			if((hash == null) || (hash == ''))
			{
				hash = '#/';  /*<%-- without the slash "/" the page jumps --%>*/
			}
			document.location.hash = hash;
		}
	}

	/*<%-- retrieves the value from the document hash, see setDocumentHashValue --%>*/
	function getDocumentHashValue(key)
	{
		var hash = document.location.hash;
		var value = null;

		/*<%-- the hash is empty, add the key and value pairs --%>*/
		if((hash != '') && (hash != null))
		{
			/*<%-- check to see if this hash value already exists --%>*/
			if(hash.indexOf('/' + key + ':') > -1)
			{
				var regex = new RegExp('/' + key + ':[^/]*/', 'g');
				value = hash.match(regex);

				if(value.length > 0)
				{
					value = value[0];
					value = value.substring((value.indexOf(':')+1), (value.length-1));
				}
			}
		}

		return value;
	}

	/*<%-- returns the number of items in the list that contain the class 'fadedItem' --%>*/
	function countedDisplayedItems(items)
	{
		var total = items.length;
		items.each(function() {
			if($(this).hasClass('fadedItem'))
			{
				total--;
			}
		});

		return total;
	}

	/*<%-- applies the class fadedItem to the selected item(s) --%>*/
	function shadeItem(item)
	{
		item.addClass('fadedItem');
		item.removeClass('highlightItem');
	}

	/*<%-- applies the class normalItem to the selected item(s)  --%>*/
	function unshadeItem(item)
	{
		item.removeClass('fadedItem');
		item.removeClass('highlightItem');
	}

	/*<%-- applies the class highlightItem to the selected item(s)  --%>*/
	function highlightItem(item)
	{
		item.addClass('highlightItem');
		item.removeClass('fadedItem');
	}

	/*<%-- display the door properties if a door and glass are selected --%>*/
	function toggleDoorProperties()
	{
		if((getSelectedGlass() == null) || (getSelectedDoorStyleOption() == null))
		{
			$('#doorpropertiesmini').hide();
			$('#energyStar').hide();
			$('#features').hide();
        }
		else
		{
			$('#doorpropertiesmini').show();
		}
	}

	/*<%-- remove the highlightItem class from the selected item(s) --%>*/
	function unhighlightItem(item)
	{
		item.removeClass('highlightItem');
	}

	/*<%-- the configured no glass option for this doorsubline --%>*/
	function getNoGlassOption()
	{
		return gNoGlassOption;
	}

	/*<%-- the configured clear glass option for this doorsubline --%>*/
	function getClearGlassOption()
	{
		return gClearGlassOption;
	}

	/*<%-- checks to see if the glass is a configured exception glass (such as Camino/Augustine for Rustic) --%>*/
	function isExceptionGlass(glassFamily)
	{
		var isMatch = false;
		for(var i = 0; i < gConfiguratorExceptions.length; i++)
		{
			if((gDoorSubLine == gConfiguratorExceptions[i].DoorSubLine.Abbreviation) && (glassFamily.Family == gConfiguratorExceptions[i].GlassFamily.Family))
			{
				isMatch = true;
				break;
			}
		}
		return isMatch;
	}


	var gSelectedDoorStyleOption = null;
	var gSelectedGlass = null;
	var gSelectedSideliteOptionRight = null;
	var gSelectedSideliteOptionLeft = null;
	var gSelectedTransomOption = null;

	var gLoadedDoorLinkId = null;
	var gLoadedGlassLinkId = null;
	var gLoadedTransomLinkId = null;
	var gLoadedSideliteLeftLinkId = null;
	var gLoadedSideliteRightLinkId = null;

	function getSelectedDoorStyleOption()
	{
		if(gSelectedDoorStyleOption == null)
		{
			gSelectedDoorStyleOption = gDoorStyleOptionHash[getDocumentHashValue(gDoorStyleOptionKey)];
		}
		return gSelectedDoorStyleOption;
	}
	function setSelectedDoorStyleOption(value)
	{
		gSelectedDoorStyleOption = value;

		if(value != null)
		{
			/*<%-- update the page hash with the selected door style option --%>*/
			setDocumentHashValue(gDoorStyleOptionKey, value.DoorStyleOptionId);
		}
		else
		{
			removeDocumentHashValue(gDoorStyleOptionKey);
		}
	}

	function getSelectedGlass()
	{
		if(gSelectedGlass == null)
		{
			gSelectedGlass = gGlassOptionHash[getDocumentHashValue(gGlassOptionKey)];
		}
		return gSelectedGlass;
	}
	function setSelectedGlass(value)
	{
		gSelectedGlass = value;

		if(value != null)
		{
			/*<%-- update the page hash with the selected glass option --%>*/
			setDocumentHashValue(gGlassOptionKey, value.GlassOptionId);
		}
		else
		{
			removeDocumentHashValue(gGlassOptionKey);
		}
	}

	function getSelectedSideliteOptionRight()
	{
		if(gSelectedSideliteOptionRight == null)
		{
			gSelectedSideliteOptionRight = gSideliteStyleOptionHash[getDocumentHashValue(gSideliteStyleOptionRightKey)];
		}
		return gSelectedSideliteOptionRight;
	}
	function setSelectedSideliteOptionRight(value)
	{
		gSelectedSideliteOptionRight = value;

		if(value != null)
		{
			/*<%-- update the page hash with the selected sidelite --%>*/
			setDocumentHashValue(gSideliteStyleOptionRightKey, value.SideliteStyleOptionId);
		}
		else
		{
			removeDocumentHashValue(gSideliteStyleOptionRightKey);
		}
	}

	function getSelectedSideliteOptionLeft()
	{
		if(gSelectedSideliteOptionLeft == null)
		{
			gSelectedSideliteOptionLeft = gSideliteStyleOptionHash[getDocumentHashValue(gSideliteStyleOptionLeftKey)];
		}
		return gSelectedSideliteOptionLeft;
	}
	function setSelectedSideliteOptionLeft(value)
	{
		gSelectedSideliteOptionLeft = value;

		if(value != null)
		{
			/*<%-- update the page hash with the selected sidelite --%>*/
			setDocumentHashValue(gSideliteStyleOptionLeftKey, value.SideliteStyleOptionId);
		}
		else
		{
			removeDocumentHashValue(gSideliteStyleOptionLeftKey);
		}
	}

	function getSelectedTransomOption()
	{
		if(gSelectedTransomOption == null)
		{
			gSelectedTransomOption = gTransomStyleOptionHash[getDocumentHashValue(gTransomStyleOptionKey)];
		}
		return gSelectedTransomOption;
	}
	function setSelectedTransomOption(value)
	{
		gSelectedTransomOption = value;

		if(value != null)
		{
			/*<%-- update the page hash with the selected transom --%>*/
			setDocumentHashValue(gTransomStyleOptionKey, value.TransomStyleOptionId);
		}
		else
		{
			removeDocumentHashValue(gTransomStyleOptionKey);
		}
	}

	function getLoadedDoorLinkId() { return gLoadedDoorLinkId; }
	function setLoadedDoorLinkId(value) { gLoadedDoorLinkId = value; }

	function getLoadedGlassLinkId() { return gLoadedGlassLinkId; }
	function setLoadedGlassLinkId(value) { gLoadedGlassLinkId = value; }

	function getLoadedTransomLinkId() { return gLoadedTransomLinkId; }
	function setLoadedTransomLinkId(value) { gLoadedTransomLinkId = value; }

	function getLoadedSideliteLeftLinkId() { return gLoadedSideliteLeftLinkId; }
	function setLoadedSideliteLeftLinkId(value) { gLoadedSideliteLeftLinkId = value; }

	function getLoadedSideliteRightLinkId() { return gLoadedSideliteRightLinkId; }
	function setLoadedSideliteRightLinkId(value) { gLoadedSideliteRightLinkId = value; }

	function getDoorHeight() { return gDoorHeight; }
	function isEightFootPage() {
	    return (getDoorHeight() == '8\'0\"');
	}

	function getDoorPlaceHolderImg() {
	    if (isEightFootPage()) {
	        return gPlaceholderImageDoor8Foot;
	    }
	    return gPlaceholderImageDoor;
	}

	function getTransomPlaceHolderImg() {
	    if (isEightFootPage()) {
	        return gPlaceholderImageTransom8Foot;
	    }
	    return gPlaceholderImageTransom;
	}

	function getSidelitePlaceHolderImg() {
	    if (isEightFootPage()) {
	        return gPlaceholderImageSidelite8Foot;
	    }
	    return gPlaceholderImageSidelite;
	}

	function getImageInstructionsPlaceHolderImg() {
	    if (isEightFootPage()) {
	        return gPlaceholderImageInstructions8Foot;
	    }
	    return gPlaceholderImageInstructions;
	}
