/*  Photo Murals Main  * *******************************************************
 *
 *	Functions for the main Photo Murals Page
 *
 ***********************************************************************************/

// Globals **************************

	var fileSetupCost = 0;
	var photoMuralMinSqFt = 0;
	var activeTabLeft = null;
	var activeTabRight = null;
	var pageNumPhotoLibrary = 0;
	var pageNumPhotoCategories = 0;
	var currentQAndAId = "";
	
	// For Email ******************
	var emailMuralType  = "";
	var emailMuralSize	= "";
	var emailPhotoType	= "";
	var emailStockPhotoNo = "";
	var emailPhotoDescr	= "";
	var emailMediaType	= "";
	var emailLamType 	= "";
	var emailYourPrice  = 0;
	
	var tabOffset			= 0;
		
	if ((thisBrowser == "IE") & (thisBrowserVersion != 8))
	{
		tabOffset = 3;	
	}
	else
	{
		tabOffset = 2;
	}
	

// Load Event ***********************

	addLoadEvent(pageInit);
	
// Intialization **********************

	function pageInit()
	{
		// Hide Add To Cart Button
		hideElement("addToCartBtn");
		
		// Initial Values *********************
		photoMuralMinSqFt = parseInt(getElement("photoMuralMinSqFt").value);
		fileSetupCost = parseInt(getElement("fileSetupCost").value);
		
		setLoadingGraphic("stockPhotoCategories");
		
		// Set Default profile ************************
		getElement("photoMuralSizeType_standard").checked=true;
		setStandardMuralOptions();
		
		// Get State Data *****************************
		getInstantQuoteStateData();
		
		// Get Most Popluar Categories ***********************
		getPhotoCategories(1);
		
		// Category List for Photo Library View ********************
		setAjaxUrl("photoCategories", "/murals/ajaxPhotoMuralsMain.asp?action=getPhotoCategoryInfo", false, false);
		
		// Set Tab Actions ****************************************
		setTabActions();
		
		// Set Q and A Actions *************************************
		setQAndAActions();
		
		// Calculate Initial Cost for past data ********************
		updateInstantQuotePrice();
		
	}

/*  Clear Instant Quote * *******************************************************
 *
 *	TAKES:		NOTHING
 * 	RETURNS:	NOTHING
 *	NOTE:		
 *
 ***********************************************************************************/
 
	function clearInstantQuote()
	{
		emailMuralType  = "";
		emailMuralSize	= "";
		emailPhotoType	= "";
		emailMediaType	= "";
		emailLamType 	= "";
		emailYourPrice  = 0;
		
		// Mural Type ******************************************
		getElement("photoMuralSizeType_standard").checked = false
		getElement("photoMuralSizeType_custom").checked = false
		
		// Mural Size ******************************************
		getElement("muralWidth").value = "";
		getElement("muralHeight").value = "";
		getElement("muralSizeUnits").selectedIndex = 0;
		
		// Photo Type *************************
		clearPhotoType();
		
		var clearRadio = function(radioElement, index)
		{
			radioElement.checked = false;	
		}
		
		// Media Type ****************************
		iterateElementList(getTagGroup("input", "media"), clearRadio);
		
		// Laminate Type **************************
		iterateElementList(getTagGroup("input", "lam"), clearRadio);
		
		setCustomMuralOptions();
		updateInstantQuotePrice();
	}


/*  Clear Photo Type * *******************************************************
 *
 *	TAKES:		NOTHING
 * 	RETURNS:	NOTHING
 *	NOTE:		
 *
 ***********************************************************************************/
 
	function clearPhotoType()
	{
		getElement("photoMuralPhotoType_stockPhoto").checked 	= false;
		getElement("photoMuralPhotoType_myPhoto").checked 		= false;
		getElement("selectedStockPhotoThumb").src 				= "/images/selectStockPhotoThumb.jpg";
		getElement("selectedStockPhotoDescr").innerHTML 		= "No Description";
		getElement("selectedStockPhotoNo").innerHTML 			= "(No Photo Selected)";
		hideElement("selectedPhotoContainer");	
	}

/*  Set Tab Actions * *******************************************************
 *
 *	TAKES:		NOTHING
 * 	RETURNS:	NOTHING
 *	NOTE:		
 *
 ***********************************************************************************/
 
 	function setTabActions()
	{
		var instantQuoteTab = getElement("instantQuoteTab");
		var orderNowTab 	= getElement("orderNowTab");
		var photoLibraryTab = getElement("photoLibraryTab");
		var qAndATab	 	= getElement("qAndATab");
		
		var leftContentTable 	= getElement("leftContentTable");
		var tabCoverLeft		= getElement("tabCoverLeft");
		
		// Instant Quote Tab **********************
			
			//setPosY(instantQuoteTab, getElementY(instantQuoteTab) - getHeight(instantQuoteTab) + tabOffset);
			
			// Special Edge Tab *******************
			getElement("leftContentTableLeftTop").className = "contentTableYellowLeft";
			
			instantQuoteTab.onmouseover = function()
			{
				this.style.cursor = "pointer";
			}
			
			instantQuoteTab.onclick = function()
			{
				setInstantQuoteTabActions();
			}
			
			activeTabLeft = instantQuoteTab;
			
			
		// Order Now Tab **********************
			
			//setPosX(orderNowTab, getWidth(instantQuoteTab) + 62);
			//setPosY(orderNowTab, getElementY(instantQuoteTab) + tabOffset);
			
			orderNowTab.onmouseover = function()
			{
				this.style.cursor = "pointer";
			}
			
			orderNowTab.onclick = function()
			{
				getElement("leftContentTable").style.zIndex = "75";
				setOrderNowTab(this);
				
				// View Profiles: Instant Quote, Order Now View
				hideElement("instantQuoteSummaryView");
				showElement("orderNowView");
				showElement("instantQuoteView");
			}
			
		// Photo Library **************************
			
			//setPosY(photoLibraryTab, getElementY(photoLibraryTab) - getHeight(photoLibraryTab) + tabOffset);
			
			// Special Edge Tab *******************
			getElement("rightContentTableLeftTop").className = "contentTableOrangeLeft";
			
			photoLibraryTab.onmouseover = function()
			{
				this.style.cursor = "pointer";
			}
			
			photoLibraryTab.onclick = function()
			{
				if (activeTabRight != this)
				{
					activeTabRight = this;
					setContentTableClasses("rightContent", "Orange");
					
					// Set Content *************************
					hideElement("qAndAContent");
					showElement("photoLibraryContent");
					
					// Special Edge Tab *******************
					getElement("rightContentTableLeftTop").className = "contentTableOrangeLeft";
			
					// Set Positioning ******************
					var qAndATabElement = getElement("qAndATab");
					
					qAndATabElement.style.zIndex = "50";
					this.style.zIndex = "100";
					
					this.style.top = "3px";
					qAndATabElement.style.top = "5px";
					
					//setPosY(this, getElementY(this) - 2);
					//setPosY(qAndATabElement, getElementY(this) + 2);
					
				}
			}
			
			activeTabRight = photoLibraryTab;
			
			
		// Q and A *********************************
			
			//setPosX(qAndATab, getElementY(qAndATab) + 303);
			//setPosY(qAndATab, getElementY(photoLibraryTab) + tabOffset);
			
			qAndATab.onmouseover = function()
			{
				this.style.cursor = "pointer";
			}
			
			qAndATab.onclick = function()
			{
				qAndATabOnClickActions();
			}
			
			// Embed Flash: Scrolling Question ********************
			var flashvars =
			{ 
				scrollingQuestion1: "Are there any photos besides those shown here?",
				scrollingQuestion2: "How do I install my mural?",
				scrollingQuestion3: "Which media should I choose?",
				scrollingQuestion4: "Can I provide my own photo?"
			};
			
			var params =
			{
				menu: "false",
				wmode: "transparent"
			};
			
			var attributes =
			{
				id: "myDynamicContent",
				name: "myDynamicContent"
			};
			
			swfobject.embedSWF("/murals/scrollingText.swf", "scrollingQuestionContainer", "80", "30", "9.0.0","expressInstall.swf", flashvars, params, attributes);	
		
		
	}

/*  Set Content Table Classes * *******************************************************
 *
 *	TAKES:		NOTHING
 * 	RETURNS:	NOTHING
 *	NOTE:		
 *
 ***********************************************************************************/
 
	function setContentTableClasses(contentTableTag, classColor)
	{
		// Top Row *******************
		getElement(contentTableTag + "TableLeftTop").className = "contentTable" + classColor + "LeftTop";
		getElement(contentTableTag + "TableBodyTop").className = "contentTable" + classColor + "BodyTop";
		getElement(contentTableTag + "TableRightTop").className = "contentTable" + classColor + "RightTop";
		
		// Center Row *****************
		getElement(contentTableTag + "TableLeft").className = "contentTable" + classColor + "Left";
		getElement(contentTableTag + "TableBody").className = "contentTable" + classColor + "Body";
		getElement(contentTableTag + "TableRight").className = "contentTable" + classColor + "Right";
		
		// Bottom Row ******************
		getElement(contentTableTag + "TableLeftBottom").className = "contentTable" + classColor + "LeftBottom";
		getElement(contentTableTag + "TableBodyBottom").className = "contentTable" + classColor + "BodyBottom";
		getElement(contentTableTag + "TableRightBottom").className = "contentTable" + classColor + "RightBottom";
	}

/*  Set Content Table Left Classes * *******************************************************
 *
 *	TAKES:		NOTHING
 * 	RETURNS:	NOTHING
 *	NOTE:		
 *
 ***********************************************************************************/
 
	function setContentTableLeftClasses(thisClassName)
	{
		getElement("leftContentTableLeftMuralType").className = thisClassName;
		getElement("leftContentTableLeftMuralSize").className = thisClassName;
		getElement("leftContentTableLeftPhoto").className = thisClassName;
		getElement("leftContentTableLeftMedia").className = thisClassName;
		getElement("leftContentTableLeftLaminate").className = thisClassName;
	}
	
/*  Get Photo Library * *******************************************************
 *
 *	TAKES:		Photo Category, Search Term
 * 	RETURNS:	NOTHING
 *	NOTE:		Sets up the Photo Library Popup menu, based onthe category or search
 *				term provided.
 *
 ***********************************************************************************/
 
 	function getPhotoLibrary(searchCat, searchCatName, searchTerm)
	{
		shadePageBackground("#000000", 55);
		showLoadingGraphic();
		
		var codeContainer = document.createElement("div");
		
		var photoLibraryContainer = document.createElement("div");
		photoLibraryContainer.className = "photoLibraryContainer";
		
			// Close Btn *******************
			var closeBtnComponent = document.createElement("div");
			closeBtnComponent.id = "closeBtn";
			closeBtnComponent.setAttribute("component", "imageButton");
			closeBtnComponent.setAttribute("image", "/images/closeBtn.png");
			closeBtnComponent.setAttribute("hoverImage", "/images/closeBtnHover.png");
			closeBtnComponent.setAttribute("onClickAction", "hideLoadingGraphic(); getElement('photoMuralPhotoType_stockPhoto').checked=true; restorePageBackground();");
			closeBtnComponent.align = "right";
			
			photoLibraryContainer.appendChild(closeBtnComponent);
			
			// Header ***********************
			var photoLibraryHeader = document.createElement("div");
			photoLibraryHeader.className = "photoLibraryHeader";
			photoLibraryHeader.innerHTML = "Photo Library";
			
			var photoLibrarySubHeader = document.createElement("div");
			photoLibrarySubHeader.className = "photoLibrarySubHeader";
			photoLibrarySubHeader.innerHTML = "Enter a search term below and select a category";
			
			photoLibraryContainer.appendChild(photoLibraryHeader);
			photoLibraryContainer.appendChild(photoLibrarySubHeader);
			
			// Search Bar ************************
			
			var searchBarTable 		= document.createElement("table");
			var searchBarTableRow 	= document.createElement("tr");
			
				var searchIconCol		= document.createElement("td");
				searchIconCol.align		= "center";
				searchIconCol.innerHTML = "<img src=\"/images/iconSearch.png\">";
				
				var searchFieldCol		= document.createElement("td");
				searchFieldCol.innerHTML = "<input type=\"text\" class=\"stockPhotoSearch\" value=\"" + searchTerm + "\" id=\"photoSearchTerm\" onfocus=\"clearSearchField(this); enterKeyAction='searchPhotoSubmit()';\">"; 
				
				var searchCatCol		= document.createElement("td");
				
				if (emailMuralType != "Standard")
				{
					searchCatCol.appendChild(getCategoryDropdownElement(searchCat));
				}
				
				var searchSubmitCol		= document.createElement("td");
				
					var searchBtnComponent = document.createElement("div");
					searchBtnComponent.id = "photoLibrarySearchBtn";
					searchBtnComponent.setAttribute("component", "imageButton");
					searchBtnComponent.setAttribute("image", "/images/photoLibrarySearchBtn.png");
					searchBtnComponent.setAttribute("hoverImage", "/images/photoLibrarySearchBtnHover.png");
					searchBtnComponent.setAttribute("onClickAction", "searchPhotoSubmit();");
					
				searchSubmitCol.appendChild(searchBtnComponent);
				
			searchBarTableRow.appendChild(searchIconCol);
			searchBarTableRow.appendChild(searchFieldCol);
			searchBarTableRow.appendChild(searchCatCol);
			searchBarTableRow.appendChild(searchSubmitCol);
			
			searchBarTable.appendChild(searchBarTableRow);
			
			photoLibraryContainer.appendChild(searchBarTable);
			
			// Photo Container *********************
			var photoContainer = document.createElement("div");
			photoContainer.className = "photoContainer";
			
				// Photo Container Header *************************
				var photoContainerHeader = document.createElement("div");
				photoContainerHeader.className = "photoContainerHeader";
				
				photoContainerHeader.innerHTML =  "Category: <span id=\"photoCategoryLabel\" style=\"color: #824a00;\"></span><br>";
				photoContainerHeader.innerHTML += "Search Results for Keyword: <span id=\"photoSearchTermLabel\" style=\"color: #824a00;\"></span>";
				
				photoContainer.appendChild(photoContainerHeader);
				
				// Standard Mural Message *************************
				var standardMuralMessage = document.createElement("div");
				standardMuralMessage.id = "standardMuralMessage";
				standardMuralMessage.className = "standardMuralMessage";
				
				messageTable 	= document.createElement("table");
				messageBody		= document.createElement("tbody");
				messageRow 		= document.createElement("tr");
					
					messageImageCol	= document.createElement("td");
					messageTextCol	= document.createElement("td");
					
					messageRow.vAlign = "middle";
					messageImageCol.innerHTML 	= "<img src=\"/images/construction.png\" height=\"25\"> ";
					messageImageCol.style.paddingLeft = "10px";
					
					messageTextCol.innerHTML 	= "In order to offer discount pricing, the selection of stock photos for <b>Standard Murals</b> is limited. To view our complete library<br>of stock photo for <b>Custom Size</b> murals <a href=\"javascript:setPhotoLibraryCustomMural();\">click here</a>.";
					messageTextCol.style.paddingLeft = "15px";
					
					messageRow.appendChild(messageImageCol);
					messageRow.appendChild(messageTextCol);
					
				messageBody.appendChild(messageRow);
				messageTable.appendChild(messageBody);
				
				standardMuralMessage.appendChild(messageTable);
				
				photoContainer.appendChild(standardMuralMessage);
				
				// Table *******************************************
				var photoContainerTable 	= document.createElement("table");
				var photoContainerTableBody = document.createElement("tbody");
				var photoContainerTableRow	= document.createElement("tr");
				
				photoContainerTableRow.vAlign = "top";
				
					var photoContainerTableLeftCol = document.createElement("td");
				
					// Photo Thumbnails Container **********************
					var photoThumbnailsContainer = document.createElement("div");
					photoThumbnailsContainer.className = "photoThumbnailsContainer";
					photoThumbnailsContainer.id = "photoThumbnailsContainer";
					
					var thumbnailUpdateElement = document.createElement("div");
					thumbnailUpdateElement.id = "thumbnailUpdateElement";
				
					photoThumbnailsContainer.appendChild(thumbnailUpdateElement);
					photoContainerTableLeftCol.appendChild(photoThumbnailsContainer);
					
					var photoContainerTableRightCol = document.createElement("td");
					photoContainerTableRightCol.style.borderLeft = "solid 1px #E7E7E7";
					
					// Photo Preview Container ************************
					var photoPreviewContainer = document.createElement("div");
					photoPreviewContainer.className = "photoPreviewContainer";
					
						var photoPreviewLabel = document.createElement("div");
						photoPreviewLabel.className = "photoPreviewLabel";
						photoPreviewLabel.innerHTML =  "Photo Preview";
						
						photoPreviewContainer.appendChild(photoPreviewLabel);
						
						// Photo Preview Image ****************************
						var photoPreviewImageContainer = document.createElement("div");
						photoPreviewImageContainer.align = "center";
						photoPreviewImageContainer.innerHTML = "<img src=\"/images/noPreview.jpg\" id=\"photoPreviewImage\" class=\"photoPreviewImage\">";
						
						photoPreviewContainer.appendChild(photoPreviewImageContainer);
						
						var photoPreviewDetail = document.createElement("div");
						photoPreviewDetail.className = "photoPreviewDetail";
						photoPreviewDetail.align = "center";
						
							// Photo Descr ****************************
							var photoPreviewDescr = document.createElement("div");
							photoPreviewDescr.style.color = "#1b5ca0";
							photoPreviewDescr.id = "photoPreviewDescr";
							
							photoPreviewDetail.appendChild(photoPreviewDescr);
							
							// Photo Stock No *************************
							var photoPreviewPhotoNo= document.createElement("div");
							photoPreviewPhotoNo.id = "photoPreviewPhotoNo";
							
							photoPreviewDetail.appendChild(photoPreviewPhotoNo);
							
						photoPreviewContainer.appendChild(photoPreviewDetail);
						
						var photoErrorPanel = document.createElement("div");
						photoErrorPanel.id = "photoErrorPanel";
						photoErrorPanel.className = "errorPanel";
						photoErrorPanel.style.marginTop = "10px";
						photoErrorPanel.align = "center";
						
						photoErrorPanel.innerHTML = "<table cellpadding=\"0\" cellspacing=\"0\"><tr><td valign=\"center\"><img src=\"/images/construction.png\" height=\"25\"></td><td style=\"padding-left: 10px;\">Click a thumbnail on the left to select a photo.</td></tr></table>";
						
						photoPreviewContainer.appendChild(photoErrorPanel);
						
						// Use this Photo Button *************************
						var photoPreviewBtnContainer = document.createElement("div");
						photoPreviewBtnContainer.align = "center";
						photoPreviewBtnContainer.style.paddingTop = "15px";
						
							var useBtnComponent = document.createElement("div");
							useBtnComponent.id = "photoLibraryUseBtn";
							useBtnComponent.setAttribute("component", "imageButton");
							useBtnComponent.setAttribute("image", "/images/photoLibraryUseBtn.png");
							useBtnComponent.setAttribute("hoverImage", "/images/photoLibraryUseBtnHover.png");
							useBtnComponent.setAttribute("onClickAction", "selectPreviewPhoto();");
						
							photoPreviewBtnContainer.appendChild(useBtnComponent);
						
						photoPreviewContainer.appendChild(photoPreviewBtnContainer);
							
					photoContainerTableRightCol.appendChild(photoPreviewContainer);
					
				photoContainerTableRow.appendChild(photoContainerTableLeftCol);
				photoContainerTableRow.appendChild(photoContainerTableRightCol);
				photoContainerTableBody.appendChild(photoContainerTableRow);
				
				photoContainerTable.appendChild(photoContainerTableBody);
				
				photoContainer.appendChild(photoContainerTable);
			
			photoLibraryContainer.appendChild(photoContainer);
			
				var indexContainer 		= document.createElement("div");
				indexContainer.id		= "photoIndexContainerMain";
				
				var indexLabel			= document.createTextNode("More Photos");
				
				var indexDiv			= document.createElement("div");
				indexDiv.id				= "photoIndexContainer";
				indexDiv.className 		= "photoIndexContainer";
				
				indexContainer.appendChild(indexLabel);
				indexContainer.appendChild(indexDiv);
				
			photoLibraryContainer.appendChild(indexContainer);
				
		codeContainer.appendChild(photoLibraryContainer);
		
		glassElement.innerHTML = "";
		glassElement.innerHTML = codeContainer.innerHTML;
		
		// Show Panel ***********************
		glassElement.style.display = "block";
		
		// Set Position **********************
		setPosY(glassElement, getPageYOffset() + 100);
		setPosX(glassElement, (getWindowWidth()/2) - (getWidth(glassElement)/2) );
		
		// Get Photos ****************
		if (emailMuralType != "Standard")
		{
			getPhotoThumbnails(1, searchCat, searchCatName, searchTerm);
			hideElement("standardMuralMessage");
		}
		else
		{
			getPhotoThumbnails(1, 78, "Standard", "");
			showElement("standardMuralMessage");
		}
		
		// Build Close Btn Component ************
		addImageButtonComponentMembers();
		setComponentImageButtonActions();
		
	}

/* Set Photo Library Custom Mural * *******************************************************
 *
 *	TAKES:		NOTHING
 * 	RETURNS:	NOTHING
 *	NOTE:		Sets the Mural Type to custom and relaunches the Photo Library
 *
 ***********************************************************************************/
 
	function setPhotoLibraryCustomMural()
	{
		getElement("photoMuralSizeType_custom").checked = true;
		setCustomMuralOptions();
		getPhotoLibrary("", "", "");
	}
	
/*  Get Photo Thumbnails * *******************************************************
 *
 *	TAKES:		Field Element
 * 	RETURNS:	NOTHING
 *	NOTE:		Clears the search field only if "Search" is the current value.
 *
 ***********************************************************************************/
 
	function getPhotoThumbnails(pageNum, searchCat, searchCatName, searchTerm)
	{
		pageNumPhotoLibrary = pageNum;
		
		// Set Loading Position ********************
		var thumbsContainer = getElement("photoThumbnailsContainer");
		
		setPosX(loadingElement, getElementX(thumbsContainer) + getWidth(thumbsContainer)/2);
		setPosY(loadingElement, getElementY(thumbsContainer) + (getHeight(thumbsContainer)*.35));
		loadingElement.style.display = "block";
		loadingElement.innerHTML = "<img src=\"/images/loadingGraphic1.gif\">";
		
		// Set Search Labels ***********************
		if (searchCatName == "")
		{
			searchCatName = "All Categories";
		}
		
		getElement("photoCategoryLabel").innerHTML = searchCatName;
		
		if (searchTerm != "")
		{
			getElement("photoSearchTermLabel").innerHTML = "\"" + searchTerm + "\"";
		}
		
		if (searchTerm == "undefined")
		{
			searchTerm = "";	
		}
		
		if (searchCatName == "All Categories")
		{
			searchCatName = "";
		}
		
		setAjaxUrl("thumbnailUpdateElement", "/murals/ajaxPhotoMuralsMain.asp?action=getPhotos&muralSize=" + emailMuralSize + "&pageNum=" + pageNum + "&searchTerm=" + searchTerm + "&searchCat=" + searchCat + "&searchCatName=" + searchCatName, false, "setPhotoLibraryIndex(); hideLoadingGraphic();");
			
	}

/*  Get Photo Categories * *******************************************************
 *
 *	TAKES:		Page Num
 * 	RETURNS:	NOTHING
 *	NOTE:		
 *
 ***********************************************************************************/
 
	function getPhotoCategories(pageNum)
	{
		pageNumPhotoCategories = pageNum;
		setAjaxUrl("stockPhotoCategories", "/murals/ajaxPhotoMuralsMain.asp?action=getPhotoCategories&pageNum=" + pageNum, "setCustomLoadingGraphic('stockPhotoCategories', '/images/loadingGraphic2.gif');", "hideElement('allCatHeader'); showElement('popularCatHeader');");
		
		// Set Scrollbar
		getElement("stockPhotoCategories").scrollTop = 0;
	}
	
/*  Get Photo Category List* *******************************************************
 *
 *	TAKES:		NOTHING
 * 	RETURNS:	NOTHING
 *	NOTE:		
 *
 ***********************************************************************************/
 
	function getPhotoCategoryList()
	{
		setAjaxUrl("stockPhotoCategories", "/murals/ajaxPhotoMuralsMain.asp?action=getPhotoCategoryList", "setCustomLoadingGraphic('stockPhotoCategories', '/images/loadingGraphic2.gif');", "hideElement('popularCatHeader'); showElement('allCatHeader');");
		
		// Set Scrollbar
		getElement("stockPhotoCategories").scrollTop = 0;

	}
	
/*  Set Photo Category Index * *******************************************************
 *
 *	TAKES:		NOTHING
 * 	RETURNS:	NOTHING
 *	NOTE:		
 *
 ***********************************************************************************/
 
	function setPhotoCategoryIndex()
	{
		var photoCategoryIndexElement = getElement("stockPhotoCategoriesIndex");
			
		// Clear the old index ********************
		photoCategoryIndexElement.innerHTML = "";
		
		// Set Prev Btn **************************
		var prevElement = getElement("browseCatPagingPrev");
		
		if (prevElement != null)
		{
			var containerPrevDiv = document.createElement("div");
			var indexSpan = document.createElement("span");
			indexSpan.id = "photoCategoryNextIndex" + prevElement.value;
			indexSpan.className = "browseCatPaging";
				
			if (prevElement.value != "")
			{	
				indexSpan.setAttribute("onmouseover", "this.style.cursor='pointer'; this.className='browseCatPagingHover';");
				indexSpan.setAttribute("onmouseout", "this.className='browseCatPaging';");
				indexSpan.setAttribute("onclick", "getPhotoCategories(" + prevElement.value + ")");
			}
			else
			{
				indexSpan.style.color = "#666666";	
			}
			
			indexSpan.innerHTML = "< Prev";
			
			containerPrevDiv.appendChild(indexSpan);
			
			photoCategoryIndexElement.innerHTML += containerPrevDiv.innerHTML;
		}
		
		var indexElements = getTagGroup("input", "browseCatPaging");
		
		// Function to Iterate over *****************
		var addIndexSpan = function(element, index)
		{
			if ((element.id != "browseCatPagingPrev") & (element.id != "browseCatPagingNext"))
			{
				var containerDiv = document.createElement("div");
				indexSpan = document.createElement("span");
				indexSpan.id = "photoCategoryIndex" + element.value;
				indexSpan.className = "browseCatPaging";
				indexSpan.setAttribute("onmouseover", "this.style.cursor='pointer'; this.className='browseCatPagingHover';");
				indexSpan.setAttribute("onmouseout", "this.className='browseCatPaging';");
				indexSpan.setAttribute("onclick", "getPhotoCategories(" + element.value + ")");
				indexSpan.innerHTML = element.value;
				
				containerDiv.appendChild(indexSpan);
				var photoCategoryIndexElement = getElement("stockPhotoCategoriesIndex");
				
				photoCategoryIndexElement.innerHTML += containerDiv.innerHTML;
			}
		}
		
		// Iterate over the Index Elements ******************
		iterateElementList(indexElements, addIndexSpan);
		
		
		// Set Next Btn **************************
		var nextElement = getElement("browseCatPagingNext");
		
		if (nextElement != null)
		{
			var containerNextDiv = document.createElement("div");
			indexSpan = document.createElement("span");
			indexSpan.id = "photoCategoryPrevIndex" + nextElement.value;
			indexSpan.className = "browseCatPaging";
				
			if (nextElement.value != "")
			{
				indexSpan.setAttribute("onmouseover", "this.style.cursor='pointer'; this.className='browseCatPagingHover';");
				indexSpan.setAttribute("onmouseout", "this.className='browseCatPaging';");
				indexSpan.setAttribute("onclick", "getPhotoCategories(" + nextElement.value + ")");
			}
			else
			{
				indexSpan.style.color = "#666666";	
			}
			
			indexSpan.innerHTML = "Next >";
			
			containerNextDiv.appendChild(indexSpan);
			
			photoCategoryIndexElement.innerHTML += containerNextDiv.innerHTML;
		}
	
		pageNumPhotoCategories
		
		// Set Current Index **************
		var currentIndexElement = getElement("photoCategoryIndex" + pageNumPhotoCategories);
		
		if (currentIndexElement != null)
		{
			currentIndexElement.style.fontWeight = "bold";	
		}
	}
	
/*  Set Photo Library Index * *******************************************************
 *
 *	TAKES:		NOTHING
 * 	RETURNS:	NOTHING
 *	NOTE:		
 *
 ***********************************************************************************/
 
	function setPhotoLibraryIndex()
	{
		var photoIndexElement = getElement("photoIndexContainer");
		
		// Get Search Values **********************
		var searchCatElement = getElement("photoSearchCat");
		
		if (emailMuralType != "Standard")
		{
			var searchCat		= searchCatElement.options[searchCatElement.selectedIndex].value;
			var searchCatName	= searchCatElement.options[searchCatElement.selectedIndex].text;
		}
		else
		{
			var searchCat = 78;
			var searchCatName = "Standard";
		}
		
		
		var searchTerm 		= getElement("photoSearchTerm").value;
		
		// Clear the old index ********************
		photoIndexElement.innerHTML = "";
		
		// Set Prev Btn **************************
		var prevElement = getElement("browsePhotosPagingPrev");
		
		if (prevElement != null)
		{
			var containerPrevDiv = document.createElement("div");
			var indexSpan = document.createElement("span");
			indexSpan.className = "browseCatPaging";
			
			if (prevElement.value != "")
			{
				indexSpan.id = "photoLibraryIndexPrev" + prevElement.value;
				indexSpan.setAttribute("onmouseover", "this.style.cursor='pointer'; this.className='browseCatPagingHover';");
				indexSpan.setAttribute("onmouseout", "this.className='browseCatPaging';");
				indexSpan.setAttribute("onclick", "getPhotoThumbnails(" + prevElement.value + ", '" + searchCat + "', '" + searchCatName + "', '" + searchTerm + "');");
			}
			else
			{
				indexSpan.style.color = "#666666";		
			}
			
			indexSpan.innerHTML = "< Prev";
			
			containerPrevDiv.appendChild(indexSpan);
			
			photoIndexElement.innerHTML += containerPrevDiv.innerHTML;
		}
		
		var indexElements = getTagGroup("input", "browsePhotosPaging");
		
		// Function to Iterate over *****************
		var addIndexSpan = function(element, index)
		{
			if ((element.id != "browsePhotosPagingPrev") & (element.id != "browsePhotosPagingNext"))
			{
				var containerDiv = document.createElement("div");
				indexSpan = document.createElement("span");
				indexSpan.id = "photoLibraryIndex" + element.value;
				indexSpan.className = "browseCatPaging";
				indexSpan.setAttribute("onmouseover", "this.style.cursor='pointer'; this.className='browseCatPagingHover';");
				indexSpan.setAttribute("onmouseout", "this.className='browseCatPaging';");
				indexSpan.setAttribute("onclick", "getPhotoThumbnails(" + element.value + ", '" + searchCat + "', '" + searchCatName + "', '" + searchTerm + "');");
				indexSpan.innerHTML = element.value;
				
				containerDiv.appendChild(indexSpan);
				var photoCategoryIndexElement = getElement("photoIndexContainer");
				
				photoIndexElement.innerHTML += containerDiv.innerHTML;
			}
		}
	
		// Iterate over the Index Elements ******************
		iterateElementList(indexElements, addIndexSpan);
		
		// Set Next Btn **************************
		var nextElement = getElement("browsePhotosPagingNext");
		
		if (nextElement != null)
		{
			var containerNextDiv = document.createElement("div");
			indexSpan = document.createElement("span");
			indexSpan.className = "browseCatPaging";
			
			if (nextElement.value != "")
			{
				indexSpan.id = "photoLibraryIndexNext" + nextElement.value;
				indexSpan.setAttribute("onmouseover", "this.style.cursor='pointer'; this.className='browseCatPagingHover';");
				indexSpan.setAttribute("onmouseout", "this.className='browseCatPaging';");
				indexSpan.setAttribute("onclick", "getPhotoThumbnails(" + nextElement.value + ", '" + searchCat + "', '" + searchCatName + "', '" + searchTerm + "');");
			}
			else
			{
				indexSpan.style.color = "#666666";
			}
			
			indexSpan.innerHTML = "Next >";
			
			containerNextDiv.appendChild(indexSpan);
			
			photoIndexElement.innerHTML += containerNextDiv.innerHTML;
		}
		
		// Set Current Index **************
		var currentIndexElement = getElement("photoLibraryIndex" + pageNumPhotoLibrary);
		
		if (currentIndexElement != null)
		{
			currentIndexElement.style.fontWeight = "bold";	
		}
	}
	

/*  Clear Search Field * *******************************************************
 *
 *	TAKES:		Field Element
 * 	RETURNS:	NOTHING
 *	NOTE:		Clears the search field only if "Search" is the current value.
 *
 ***********************************************************************************/
 
	function clearSearchField(fieldElement)
	{
		if (fieldElement.value == "Search by Keyword")
		{
			fieldElement.value = "";	
		}
	}

/*  Get Category Dropdown Element * *******************************************************
 *
 *	TAKES:		NOTHING
 * 	RETURNS:	Dropdowm Element
 *	NOTE:		Clears the search field only if "Search" is the current value.
 *
 ***********************************************************************************/
 
	function getCategoryDropdownElement(searchCat)
	{
		var dropdownElement = document.createElement("select");
		dropdownElement.id = "photoSearchCat";
		dropdownElement.className = "stockPhotoSearchCat";
		
		var optionElement = document.createElement("option");
		optionElement.text = "All Categories";
		optionElement.value = "";
		
		if (IE)
		{
			dropdownElement.add(optionElement);
		}
		else
		{
			dropdownElement.add(optionElement, null);
		}
		
		var categoryElements = getTagGroup("input", "photoCategoryInfo");
		var categoryElement = "";
		
		for(var ctr=0; ctr<categoryElements.length; ctr++)
		{
			categoryElement = categoryElements[ctr];
			
			var arraySplit = categoryElement.value.split(", ");
			var optionValue = arraySplit[1];
			var optionText	= arraySplit[0];
			
			optionElement = document.createElement("option");
			optionElement.text = optionText;
			optionElement.value = optionValue;
			
			if (IE)
			{
				dropdownElement.add(optionElement);
			}
			else
			{
				dropdownElement.add(optionElement, null);
			}
			
			if (searchCat == optionElement.value)
			{
				dropdownElement.selectedIndex = ctr+1;	
			}
		}
		
		return dropdownElement;
	}

/*  Set Photo Preview * *******************************************************
 *
 *	TAKES:		Photo Url
 * 	RETURNS:	NOTHING
 *	NOTE:		
 *
 ***********************************************************************************/
 
	function setPhotoPreview(photoUrl, photoDescr, photoStockNo)
	{
		var previewElement = getElement("photoPreviewImage");
		previewElement.src = photoUrl;
		
		getElement("photoPreviewDescr").innerHTML = photoDescr;
		getElement("photoPreviewPhotoNo").innerHTML = "Stock No. " + photoStockNo;
		
		hideElement("photoErrorPanel");	
	}


/*  Set Preview Photo  *******************************************************
 *
 *	TAKES:		NOTHING
 * 	RETURNS:	NOTHING
 *	NOTE:		
 *
 ***********************************************************************************/
 
	function selectPreviewPhoto()
	{
		if (getElement("photoPreviewImage").src != "http://www.blueriverdigital.com/images/noPreview.jpg")
		{
			var photoStockNo = getElement("photoPreviewPhotoNo").innerHTML;
			var photoDescr = getElement("photoPreviewDescr").innerHTML;
			
			photoStockNo = photoStockNo.replace("Stock No. ", "");
			
			setStockPhoto(photoStockNo, photoDescr);
			
			restorePageBackground();
			updateInstantQuotePrice();
		}
		else
		{
			showElement("photoErrorPanel");	
		}
	}

/* Set Stock Photo *******************************************************
 *
 *	TAKES:		Stock Photo No, Photo Description
 * 	RETURNS:	NOTHING
 *	NOTE:		
 *
 ***********************************************************************************/
 
	function setStockPhoto(photoStockNo, photoDescr)
	{
		if (photoStockNo != "(No Photo Selected)")
		{
			getElement("selectedStockPhotoDescr").innerHTML = photoDescr;
			getElement("selectedStockPhotoNo").innerHTML = photoStockNo;
			getElement("selectedStockPhotoThumb").src = "/murals/thumbnails/" + photoStockNo + ".jpg";
			getElement("photoMuralPhotoType_stockPhoto").checked = true;
			showElement("selectedPhotoContainer");
		}
	}

/*  Update Instant Quote Price *******************************************************
 *
 *	TAKES:		NOTHING
 * 	RETURNS:	NOTHING
 *	NOTE:		
 *
 ***********************************************************************************/
 
	function updateInstantQuotePrice()
	{
		// Reset Email Values *************
		emailMuralType  = "";
		emailMuralSize	= "";
		emailPhotoType	= "";
		emailMediaType	= "";
		emailLamType 	= "";
		emailStockPhotoNo = "";
		emailPhotoDescr = "";
	
		var muralSizeType 	= "";
		var muralWidth 		= 0;
		var muralHeight 	= 0;
		var muralSizeUnits 	= "";
		var muralSqFt	 	= 0;
		var muralMediaPrice	= 0;
		
		var muralPhotoType	= "";
		var selectedPhotoNo = "";
		
		var muralMedia		= "";
		var muralLaminate	= "";
		var muralLamPrice	= 0;
		
		var muralBasePrice	= 0;
		
		var instantQuotePrice = 0;
		
		// Hide Errors ***************************************
		hideElement("instantQuoteError");
		hideElement("stockPhotoError");	
		
		// Mural Size *********************************************
		if (getElement("photoMuralSizeType_standard").checked == true)
		{
			// Hide Proof Option ************
			enableProofOption(false);
			
			muralSizeType = "standard";
			muralSizeUnits = "feet";
			
			var muralSizeElement = getElement("standardMuralSize");
			var muralSizeValue = muralSizeElement.options[muralSizeElement.selectedIndex].value;
			var arrayHolder = muralSizeValue.split(" x ");
			
			muralWidth = arrayHolder[0];
			muralHeight = arrayHolder[1];
			
			switch(muralSizeValue)
			{
				case "6 x 4":
					muralBasePrice = 69.95;
					break;

				case "8 x 6":
					muralBasePrice = 129.95;
					break;
					
				case "10 x 8":
					muralBasePrice = 219.95;
					break;
				
				case "12 x 9":
					muralBasePrice = 299.95;
					break;
			}
			
			// Email Values ****************
			emailMuralType = "Standard";
			emailMuralSize = muralSizeValue + " " + muralSizeUnits;
			
			hideElement("minimumSizeNote");
			
		}
		else if (getElement("photoMuralSizeType_custom").checked == true)
		{
			// Show Proof Option ************
			enableProofOption(true);
			
			muralSizeType = "custom";
			
			muralWidth = getElement("muralWidth").value;
			muralHeight = getElement("muralHeight").value;
			
			
			// Convert Fractions
			if (muralWidth != "")
			{
				muralWidth = fractionToDecimal(muralWidth);
			}
			
			if (muralHeight != "")
			{
				muralHeight = fractionToDecimal(muralHeight);
			}
			
			// Validate Width and Height
			if ((dataIsValid(muralWidth, "float") != true) & (muralWidth != ""))
			{
				muralWidth = 1;
				getElement("muralWidth").value = muralWidth;
			}
			
			if ((dataIsValid(muralHeight, "float") != true)  & (muralHeight != ""))
			{
				muralHeight = 1;
				getElement("muralHeight").value = muralHeight;
			}
			
			var muralSizeUnitsElement = getElement("muralSizeUnits");
			muralSizeUnits = muralSizeUnitsElement.options[muralSizeUnitsElement.selectedIndex].text;
			
			if (muralSizeUnits == "inches")
			{
				muralSqFt = (muralWidth * muralHeight)/144;	
			}
			else
			{
				muralSqFt = (muralWidth * muralHeight);
			}
			
			if ((muralSqFt < photoMuralMinSqFt) & ((muralWidth != "") & muralHeight != "")) 
			{
				muralSqFt = photoMuralMinSqFt;
				showElement("minimumSizeNote");
			}
			else
			{
				hideElement("minimumSizeNote");
			}
			
			// Email Values ****************
			emailMuralType = "Custom";
			
			if ((muralWidth != "") & (muralHeight != ""))
			{
				emailMuralSize = muralWidth + " x " + muralHeight + " " + muralSizeUnits;
			}
		}
		
		// Mural Photo *****************************/************************
		if (getElement("photoMuralPhotoType_stockPhoto").checked == true)
		{
			muralPhotoType = "stockPhoto";
			emailPhotoType = "Blue River Digital - Stock Photo";
			selectedPhotoNo = getElement("selectedStockPhotoNo").innerHTML;
			emailStockPhotoNo = selectedPhotoNo;
			emailPhotoDescr = getElement("selectedStockPhotoDescr").innerHTML;
		}
		else if (getElement("photoMuralPhotoType_myPhoto").checked == true)
		{
			muralPhotoType = "myPhoto";
			emailPhotoType = "My Photo (add $49.00 setup)";
			muralBasePrice += fileSetupCost;
		}
		
		
		// Mural Media ****************************************************
		var mediaElements = document.getElementsByName("photoMuralMediaType");
		var mediaElement = "";
		
		for(var ctr=0; ctr<mediaElements.length; ctr++)
		{
			mediaElement = mediaElements[ctr];
			
			if (mediaElement.checked == true)
			{
				muralMedia = mediaElement.value;
				emailMediaType =  "isChecked";
				
				switch(muralMedia)
				{
					case "U-Glue Digital Wallpaper":
						muralMediaPrice = 2.95;
						break;
						
					case "ValueTuff Photo Satin":
						muralMediaPrice = 4.95;
						break;
						
					case "PremiumVinyl":
						muralMediaPrice = 7.95;
						break;
						
					case "Backlit Vinyl":
						muralMediaPrice = 10.95;
						
						// Hide Proof Option ************
						enableProofOption(false);
						
						break;
						
					case "JumboVinyl":
						muralMediaPrice = 7.95;
						
						// Hide Proof Option ************
						enableProofOption(false);
						
						break;
						
					case "Celtic Cloth fabric":
						muralMediaPrice = 11.95;
						break;
				}
				
				muralBasePrice += (muralSqFt * muralMediaPrice);
				
				// Email Values ******************************
				if (emailMuralType == "Custom")
				{
					emailMediaType = muralMedia + " ($" + muralMediaPrice + " /sq.ft.)";
				}
				else
				{
					emailMediaType = muralMedia;
				}
				
			}
		}
			
		// Mural Laminate ****************************************
		var lamElements = document.getElementsByName("photoMuralLamType");
		var lamElement = "";
		emailLamType = "";
		
		for(var ctr=0; ctr<lamElements.length; ctr++)
		{
			lamElement = lamElements[ctr];
			
			if ((lamElement.checked == true) & (lamElement.value != ""))
			{
				muralLaminate = lamElement.value; 
				
				switch(muralLaminate)
				{
					case "SuperColor UV Gloss":
						muralLamPrice = 2.25;
						break;
						
					case "LoGlare UV Satin":
						muralLamPrice = 2.25;
						break;
						
					case "ZeroGlare UV Matte":
						muralLamPrice = 2.25;
						break;
					
				}
				
				muralBasePrice += (muralSqFt * muralLamPrice);
				
				// Email Values ******************************
				if (emailMuralType == "Custom")
				{
					emailLamType = muralLaminate + " (add $" + muralLamPrice + " /sq.ft.)";
				}
				else
				{
					emailLamType = muralLaminate;
				}
				
			}
			
		}
		
		if (activeTabLeft != null)
		{
			if (activeTabLeft.id == "orderNowTab")
			{
				// Proofs ******************************************
				var sectionalProofElement 	= getElement("muralSectionalProof");
				var scaleProofElement 		= getElement("muralScaleProof");
				
				if (sectionalProofElement.checked)
				{
					muralBasePrice += 25;
				}
				
				if (scaleProofElement.checked)
				{
					muralBasePrice += 25;
				}
				
				// Mural Quantity ***********************************
				var muralQtyValue = getElement("muralQuantity").value;
				
				if ((dataIsValid(muralQtyValue, "integer") != true) || (muralQtyValue < 1))
				{
					muralQtyValue = 1;
					getElement("muralQuantity").value = muralQtyValue;
				}
				
				muralBasePrice *= muralQtyValue;
			}
		}
		
		// Post the Price ***********************************
		
		getElement("instantQuotePrice").innerHTML = roundFloat(muralBasePrice, 2);
		emailYourPrice = roundFloat(muralBasePrice, 2);
		
		// Set Summary View Values **************
		getElement("instantQuoteSummaryMuralType").innerHTML 	= emailMuralType;
		getElement("instantQuoteSummaryMuralSize").innerHTML 	= emailMuralSize;
		getElement("instantQuoteSummaryMedia").innerHTML 		= emailMediaType;
		
		if (emailLamType != "")
		{
			getElement("instantQuoteSummaryLaminate").innerHTML 	= emailLamType;
			
			showElement("instantQuoteSummaryLaminate");
			showElement("summaryLaminateLabel");
		}
		else
		{
			hideElement("instantQuoteSummaryLaminate");
			hideElement("summaryLaminateLabel");
		}
		
		if (emailPhotoType == "Blue River Digital - Stock Photo")
		{
			getElement("selectedStockPhotoThumbSummary").src 		= getElement("selectedStockPhotoThumb").src
			getElement("selectedStockPhotoDescrSummary").innerHTML 	= getElement("selectedStockPhotoDescr").innerHTML;
			getElement("selectedStockPhotoNoSummary").innerHTML 	= getElement("selectedStockPhotoNo").innerHTML;
			
			hideElement("instantQuoteSummaryPhotoType");
			showElement("instantQuoteSummaryPhotoTypeThumb");
		}
		else
		{
			getElement("instantQuoteSummaryPhotoType").innerHTML 	= emailPhotoType;
			
			hideElement("instantQuoteSummaryPhotoTypeThumb");
			showElement("instantQuoteSummaryPhotoType");
		}
		
	}
	
/*  Set Standard Mural Options * *******************************************************
 *
 *	TAKES:		NOTIHNG
 * 	RETURNS:	NOTHING
 *	NOTE:		
 *
 ***********************************************************************************/
 
 	function setStandardMuralOptions()
	{
		// Set Size
		hideElement("muralSizeCustom");
		showElement("muralSizeStandard");
		
		// Set Media 
		getElement("media1").checked = true;
		
		// Set Lam
		getElement("lam1").checked = true;
		
		hideElement("mediaCustomValues");
		hideElement("lamCustomValues");
		showElement("mediaStandardValues");
		showElement("lamStandardValues");
		
		// Disable myPhoto Option
		if (getElement("selectedStockPhotoNo").innerHTML.indexOf("X") == -1)
		{														 
			clearPhotoType();
		}
		
		getElement("photoMuralPhotoType_myPhotoText").style.color = "#AAAAAA";
		getElement("photoMuralPhotoType_myPhotoTextPrice").style.color = "#AAAAAA";
		getElement("photoMuralPhotoType_myPhotoText").onclick = function() { return false; }
		getElement("photoMuralPhotoType_myPhoto").onclick = function() { this.checked=false; return false; }
		
		updateInstantQuotePrice(); 
	}
	
/*  Set Custom Mural Options * *******************************************************
 *
 *	TAKES:		NOTIHNG
 * 	RETURNS:	NOTHING
 *	NOTE:		
 *
 ***********************************************************************************/
 
 	function setCustomMuralOptions()
	{
		// Set Size
		hideElement("muralSizeStandard");
		showElement("muralSizeCustom");
		
		hideElement("mediaStandardValues");
		hideElement("lamStandardValues");
		showElement("mediaCustomValues");
		showElement("lamCustomValues");
		
		// Enable myPhoto Option
		getElement("photoMuralPhotoType_myPhoto").disabled = false;
		getElement("photoMuralPhotoType_myPhotoText").style.color = "#000000";
		getElement("photoMuralPhotoType_myPhotoTextPrice").style.color = "#666666";
		getElement("photoMuralPhotoType_myPhotoText").onclick = muralMyPhotoActions;
		getElement("photoMuralPhotoType_myPhoto").onclick = muralMyPhotoActions;
		
		var photoNo = getStockNoFromImageFile(getElement("selectedStockPhotoThumb").src);
		
		if (photoNo.indexOf("X") != -1)
		{
			clearPhotoType();
		}
		
		updateInstantQuotePrice(); 
		
	}
	
/*  Email Photo Mural Quote * *******************************************************
 *
 *	TAKES:		NOTIHNG
 * 	RETURNS:	NOTHING
 *	NOTE:		
 *
 ***********************************************************************************/
 
 	function emailPhotoMuralQuote()
	{
		// Update Values **********************
		updateInstantQuotePrice(); 
		
		if (checkInstantQuoteValues())
		{
			// Save current values *********************
			saveInstantQuoteState();
			
			getEmailPopup("Photo Mural Quote", "sendPhotoMuralQuoteEmail()", true, true);	
		}
		else
		{
			showElement("instantQuoteError");
		}
	}

/*  Email Photo Mural Quote * *******************************************************
 *
 *	TAKES:		NOTIHNG
 * 	RETURNS:	NOTHING
 *	NOTE:		
 *
 ***********************************************************************************/
 
	function sendPhotoMuralQuoteEmail()
	{
		// Get Validated Values ****************
		var emailToValue 	= getElement("emailTo").value;
		var emailFromValue	= "";
		var commentsValue	= "";
		var emailPhotoTypeTemp = "";
		
		var emailFromElement = getElement("emailFrom");
		var commentsElement	= getElement("commentsField");
		
		if (emailFromElement != null)
		{
			emailFromValue = encodeQueryString(emailFromElement.value);	
		}
		
		if (commentsElement != null)
		{
			commentsValue = commentsValue.replace("\n", "<br>");
			commentsValue = encodeQueryString(commentsElement.value);	
		}
		
		// Get Stock Photo ************************
		if (emailPhotoType != "My Photo (add $49.00 setup)")
		{
			var photoNo = getStockNoFromImageFile(getElement("selectedStockPhotoThumb").src);
				
			if (photoNo)
			{
				emailPhotoTypeTemp = emailPhotoType + " - " +  photoNo;
			}
			else
			{
				emailPhotoTypeTemp = emailPhotoType;
			}
			
		}
		else
		{
			emailPhotoTypeTemp = emailPhotoType;
		}
		
		setAjaxUrl("updateData", "/includes/api/brdApiEmail.asp?action=sendPhotoMuralQuoteEmail&emailMuralType=" + emailMuralType + "&emailMuralSize=" + emailMuralSize + "&emailPhotoType=" + emailPhotoType + " - " +  photoNo + "&emailMediaType=" + emailMediaType + "&emailLamType=" + emailLamType + "&emailTo=" + emailToValue + "&emailFrom=" + emailFromValue + "&comments=" + commentsValue + "&emailYourPrice=" + emailYourPrice, false, "alertShadedPopup('Email Product Page Status', 'E-mail Sent Successfully!');");
		
	}
	
/*  Email Stock Photo List * *******************************************************
 *
 *	TAKES:		NOTIHNG
 * 	RETURNS:	NOTHING
 *	NOTE:		
 *
 ***********************************************************************************/
 
 	function emailStockPhotoList()
	{
		var contentTitle = "Stock Photo List Request";
		var contentElement = document.createElement("div");
		
		
		
		contentElementPopup(contentTitle, contentElement);
		
	}
	
/*  Print Photo Mural Quote * *******************************************************
 *
 *	TAKES:		NOTIHNG
 * 	RETURNS:	NOTHING
 *	NOTE:		
 *
 ***********************************************************************************/
 
	function printPhotoMuralQuote()
	{
		// Update Values **********************
		updateInstantQuotePrice(); 
		
		var emailPhotoTypeTemp = "";
		
		if (checkInstantQuoteValues())
		{
			// Save current values *********************
			saveInstantQuoteState();
		
			// Get Stock Photo ************************
			
			if (emailPhotoType != "My Photo (add $49.00 setup)")
			{
				var photoNo = getStockNoFromImageFile(getElement("selectedStockPhotoThumb").src);
				
				if (photoNo)
				{
					emailPhotoTypeTemp = emailPhotoType + " - " +  photoNo;
				}
				else
				{
					emailPhotoTypeTemp = emailPhotoType;
				}
			}
			else
			{
				emailPhotoTypeTemp = emailPhotoType;
			}
			
			setAjaxUrl("printContent", "/includes/api/brdApiEmail.asp?action=sendPhotoMuralQuoteEmail&printThis=true&emailMuralType=" + emailMuralType + "&emailMuralSize=" + emailMuralSize + "&emailPhotoType=" + emailPhotoTypeTemp + "&emailMediaType=" + emailMediaType + "&emailLamType=" + emailLamType + "&emailYourPrice=" + emailYourPrice, false, "getPrintWindow('Blue River Digital - Photo Mural Instant Quote');");
			
		}
		else
		{
			showElement("instantQuoteError");
		}
		
	}

/*  Save Instant Quote State * *******************************************************
 *
 *	TAKES:		NOTHING
 * 	RETURNS:	NOTHING
 *	NOTE:		Saves the state in case a popup blocker erases the data
 *
 ***********************************************************************************/

	function saveInstantQuoteState()
	{
		setAjaxUrl("updateData", "/murals/ajaxPhotoMuralsMain.asp?action=saveInstantQuoteState&emailMuralType=" + emailMuralType + "&emailMuralSize=" + emailMuralSize + "&emailPhotoType=" + emailPhotoType + "&emailStockPhotoNo=" + emailStockPhotoNo + "&emailPhotoDescr=" + emailPhotoDescr + "&emailMediaType=" + emailMediaType + "&emailLamType=" + emailLamType + "&emailYourPrice=" + emailYourPrice, false, false);
	}
	
/*  Destroy Instant Quote State * *******************************************************
 *
 *	TAKES:		NOTHING
 * 	RETURNS:	NOTHING
 *	NOTE:		Destroys the state
 *
 ***********************************************************************************/

	function destroyInstantQuoteState()
	{
		setAjaxUrl("updateData", "/murals/ajaxPhotoMuralsMain.asp?action=destroyInstantQuoteState", false, false);
	}
	
/*  Get Instant Quote State Data * *******************************************************
 *
 *	TAKES:		NOTHING
 * 	RETURNS:	NOTHING
 *	NOTE:		
 *
 ***********************************************************************************/

	function getInstantQuoteStateData()
	{
		setAjaxUrl("instantQuoteState", "/murals/ajaxPhotoMuralsMain.asp?action=getInstantQuoteStateData", false, "setInstantQuoteStateData();");
	}
	
/*  Set Instant Quote State Data * *******************************************************
 *
 *	TAKES:		NOTHING
 * 	RETURNS:	NOTHING
 *	NOTE:		
 *
 ***********************************************************************************/

	function setInstantQuoteStateData()
	{
		emailMuralType = getElement("emailMuralType").value;
		emailMuralSize = getElement("emailMuralSize").value;
		emailPhotoType = getElement("emailPhotoType").value;
		emailStockPhotoNo = getElement("emailStockPhotoNo").value;
		emailPhotoDescr = getElement("emailPhotoDescr").value;
		emailMediaType = getElement("emailMediaType").value;
		emailLamType = getElement("emailLamType").value;
		
		// Mural Type ********************************
		if (emailMuralType == "Standard")
		{
			getElement("photoMuralSizeType_standard").checked = true;
			
			// Mural Size ********************************
			var sizeData = emailMuralSize.replace(" feet", "");
			var standardMuralSizeDropdown = getElement("standardMuralSize");
			var selectOptions = standardMuralSizeDropdown;
			
			for(var ctr=0; ctr<selectOptions.length; ctr++)
			{	
				if (selectOptions[ctr].value == sizeData)
				{
					standardMuralSizeDropdown.selectedIndex = ctr;
					break;
				}
			}
			
		}
		else if (emailMuralType == "Custom")
		{
			getElement("photoMuralSizeType_custom").checked = true;
			
			// Mural Size ********************************
			var sizeArray = emailMuralSize.split(" x ");
			getElement("muralWidth").value = sizeArray[0];
			
			var unitsArray = sizeArray[1].split(" ");
			getElement("muralHeight").value = unitsArray[0];
			
			// Mural Units ********************************
			if (unitsArray[1] == "feet")
			{
				getElement("muralSizeUnits").selectedIndex = 0;
			}
			else
			{
				getElement("muralSizeUnits").selectedIndex = 1;
			}
			
		}
		
		
		// Mural Photo ********************************
		if (emailPhotoType.indexOf("Stock Photo") != -1)
		{
			getElement("photoMuralPhotoType_stockPhoto").checked = true;
			showElement("selectedPhotoContainer");
			
			if ((emailStockPhotoNo != "") & (emailPhotoDescr != ""))
			{
				setStockPhoto(emailStockPhotoNo, emailPhotoDescr);
			}
		}
		else if (emailPhotoType.indexOf("My Photo") != -1)
		{
			getElement("photoMuralPhotoType_myPhoto").checked = true;
		}

		// Mural Media ********************************
		if (emailMediaType != "")
		{
			var mediaElements = getTagGroup("input", "media");
			var mediaTypeValue = emailMediaType.split(" (");
			
			mediaTypeValue = mediaTypeValue[0];
			
			var iterateAction = function (mediaElement, index)
			{
				if (mediaElement.value == mediaTypeValue)
				{
					mediaElement.checked = true;	
				}
			}
			
			iterateElementList(mediaElements, iterateAction);
		}
		
		// Mural Lam ********************************
		if (emailLamType != "")
		{
			var lamElements = getTagGroup("input", "media");
			var lamTypeValue = emailLamType.split(" (");
			
			lamTypeValue = lamTypeValue[0];
			
			var iterateAction = function (lamElement, index)
			{
				if (lamElement.value == lamTypeValue)
				{
					lamElement.checked = true;	
				}
			}
			
			iterateElementList(lamElements, iterateAction);
		}
		
 		// Set Actions *******************
		if (emailMuralType == "Standard")
		{
			setStandardMuralOptions();
		}
		else if (emailMuralType == "Custom")
		{
			setCustomMuralOptions();
			
			if ((emailMediaType.indexOf("U-GLue") != -1) || (emailMediaType.indexOf("ValueTuff") != -1))
			{
				displayLaminate(true);	
			}
			else
			{
				displayLaminate(false);	
			}
		}
		
	}
	
/*  Get Stock No From Image File * *******************************************************
 *
 *	TAKES:		Image File
 * 	RETURNS:	Photo No. extracted from the image file path.
 *	NOTE:		
 *
 ***********************************************************************************/
 
	function getStockNoFromImageFile(imageFile)
	{
		var photoNo = false;
		
		if (imageFile != "")
		{
			var photoNoArray = imageFile.split("/");
			
			if (photoNoArray.length > 0)
			{
				photoNo = photoNoArray[photoNoArray.length-1];
				photoNo = photoNo.replace(".jpg", "");
			}
		}
		
		return photoNo;
	}

/*  Get Print Window * *******************************************************
 *
 *	TAKES:		NOTIHNG
 * 	RETURNS:	NOTHING
 *	NOTE:		
 *
 ***********************************************************************************/
 
	function getPrintWindow(printTitle)
	{
		var printWindow = window.open("/includes/printContent.asp?opid=" + new Date().getTime() + "&printTitle=" + printTitle,  "printWindow", "status = 1, height = 230, width = 448, resizable = 1, scrollbars=0" );
		hideElement("printContent");
	}

/*  Search Category Submit * *******************************************************
 *
 *	TAKES:		NOTHING
 * 	RETURNS:	NOTHING
 *	NOTE:		
 *
 ***********************************************************************************/
 
	function searchCategorySubmit()
	{
		var searchTerm = getElement("stockPhotoSearch").value;
		
		if (searchTerm == "Search by Keyword")
		{
			searchTerm = "";	
		}
		
		getPhotoLibrary("", "", searchTerm);	
	}
	
/*  Search Photo Submit * *******************************************************
 *
 *	TAKES:		NOTHING
 * 	RETURNS:	NOTHING
 *	NOTE:		
 *
 ***********************************************************************************/
 
	function searchPhotoSubmit()
	{
		var catDropdownElement = getElement("photoSearchCat");
		var categoryValue = "";
		var categoryText = "";
		
		if ((catDropdownElement != "undefined") & (catDropdownElement != null))
		{
			categoryValue = catDropdownElement.options[catDropdownElement.selectedIndex].value;
			categoryText = catDropdownElement.options[catDropdownElement.selectedIndex].text
		}
		else
		{
			categoryValue = 78;
			categoryText = "Standard";
		}
		
		getPhotoThumbnails(1, categoryValue, categoryText, getElement("photoSearchTerm").value);
	}
	
/*  Check Instant Quote Values * *******************************************************
 *
 *	TAKES:		NOTHING
 * 	RETURNS:	NOTHING
 *	NOTE:		
 *
 ***********************************************************************************/
 
	function checkInstantQuoteValues()
	{
		var valueInstantQuoteValues = true;
		
		if (emailMuralType == "")
		{
			valueInstantQuoteValues = false;
			showContentLeftError("leftContentTableLeftMuralType", true);
		}
		else
		{
			showContentLeftError("leftContentTableLeftMuralType", false);
		}
		
		if (emailMuralSize == "")
		{
			valueInstantQuoteValues = false;
			showContentLeftError("leftContentTableLeftMuralSize", true);
		}
		else
		{
			showContentLeftError("leftContentTableLeftMuralSize", false);
		}
		
		if (emailPhotoType == "")
		{
			valueInstantQuoteValues = false;
			showContentLeftError("leftContentTableLeftPhoto", true);
		}
		else
		{
			showContentLeftError("leftContentTableLeftPhoto", false);
		}
		
		if (emailMediaType == "")
		{
			valueInstantQuoteValues = false;
			showContentLeftError("leftContentTableLeftMedia", true);
		}
		else
		{
			showContentLeftError("leftContentTableLeftMedia", false);
		}
		
		return valueInstantQuoteValues;
	}

	
/*  Show Content Left Error * *******************************************************
 *
 *	TAKES:		Content Left Id, Show Error
 * 	RETURNS:	NOTHING
 *	NOTE:		
 *
 ***********************************************************************************/
 
	function showContentLeftError(contentLeftId, showError)
	{
		var contentLeftElement = getElement(contentLeftId);
		
		if (contentLeftElement)
		{
			if (showError)
			{
				if (contentLeftElement.className.indexOf("Error") == -1)
				{
					contentLeftElement.className += "Error";
				}
			}
			else
			{
				contentLeftElement.className = contentLeftElement.className.replace("Error", "");
			}
		}
	}

/*  Display Laminate * *******************************************************
 *
 *	TAKES:		Display This (true | false)
 * 	RETURNS:	NOTHING
 *	NOTE:		
 *
 ***********************************************************************************/
 
	function displayLaminate(displayThis)
	{
		
		if (displayThis)
		{
			showElement("lamCustomValues");
			hideElement("lamStandardValues");
		}
		else
		{
			// No Lam
			getElement("lam1").checked = true;
			hideElement("lamCustomValues");
			showElement("lamStandardValues");
		}
	}

/*  Set Instant Quote Tab Actions * *******************************************************
 *
 *	TAKES:		NOTHING
 * 	RETURNS:	NOTHING
 *	NOTE:		
 *
 ***********************************************************************************/
 
	function setInstantQuoteTabActions()
	{
		var instantQuoteTabElement = getElement("instantQuoteTab");
		
		if (activeTabLeft != instantQuoteTabElement)
		{
			activeTabLeft = instantQuoteTabElement;
			
			setContentTableClasses("leftContent", "Yellow");
			setContentTableLeftClasses("photoMuralQuoteTableLeft");
			
			// Clear Form Link *********************
			showElement("clearFormLink");
			
			// Special Edge Tab *******************
			getElement("leftContentTableLeftTop").className = "contentTableYellowLeft";
			
			// Set Positioning ******************
			var orderNowTabElement = getElement("orderNowTab"); 
			
			orderNowTabElement.style.zIndex = "50";
			instantQuoteTabElement.style.zIndex = "100";
			
			orderNowTabElement.style.top = "5px";
			instantQuoteTabElement.style.top = "3px";
			
			//setPosY(instantQuoteTabElement, getElementY(instantQuoteTabElement) - 2);
			//setPosY(orderNowTabElement, getElementY(instantQuoteTabElement) + 2);
		}
		
		// Show Email, Print Quote Buttons
		showElement("emailQuoteBtn");
		showElement("printQuoteBtn");
		
		// View Profiles: Instant Quote
		hideElement("instantQuoteSummaryView");
		hideElement("orderNowView");
		showElement("instantQuoteView");
		
		// Show the Order Now Buttons
		hideElement("addToCartBtn");
		showElement("orderNowBtn");
		
		updateInstantQuotePrice();	
	}

/*  Order Now Button Actions * *******************************************************
 *
 *	TAKES:		NOTHING
 * 	RETURNS:	NOTHING
 *	NOTE:		
 *
 ***********************************************************************************/
 
	function orderNowButtonActions()
	{
		var orderNowTabElement = getElement("orderNowTab");
		
		if (checkInstantQuoteValues())
		{
			if ( (emailPhotoType.indexOf("Stock Photo") != -1) & (getElement("selectedStockPhotoNo").innerHTML == "(No Photo Selected)") )
			{
				showElement("stockPhotoError");	
			}
			else
			{
				setOrderNowTab(orderNowTabElement);
				
				// Save current values *********************
				saveInstantQuoteState();
				
				// View Profiles: Instant Quote Summary, Order Now Options
				hideElement("instantQuoteView");
				showElement("instantQuoteSummaryView");
				showElement("orderNowView");
			}	
	
		}
		else
		{
			if ( (emailPhotoType.indexOf("Stock Photo") != -1) & (getElement("selectedStockPhotoNo").innerHTML == "(No Photo Selected)") )
			{
				showElement("stockPhotoError");	
			}
			else
			{
				setOrderNowTab(orderNowTabElement);
			
				// View Profiles: Instant Quote View, Order Now Options
				hideElement("instantQuoteSummaryView");
				showElement("instantQuoteView");
				showElement("orderNowView");
			}
		}
		
	}

/* Set Order Now Tab * *******************************************************
 *
 *	TAKES:		Tab Element
 * 	RETURNS:	NOTHING
 *	NOTE:		
 *
 ***********************************************************************************/
 
	function setOrderNowTab(tabElement)
	{
		if (activeTabLeft != tabElement)
		{
			activeTabLeft = tabElement;
			setContentTableClasses("leftContent", "Green");
			setContentTableLeftClasses("photoMuralOrderNowTableLeft");
			
			// Clear Form Link *********************
			hideElement("clearFormLink");
			
			// Set Positioning ******************
			var instantQuoteTabElement = getElement("instantQuoteTab"); 
			
			instantQuoteTabElement.style.zIndex = "50";
			tabElement.style.zIndex = "100";
			
			instantQuoteTabElement.style.top = "5px";
			tabElement.style.top = "3px";
			
			//setPosY(instantQuoteTabElement, getElementY(instantQuoteTabElement)  + 2);
			//setPosY(tabElement, getElementY(instantQuoteTabElement) - 2);
		}
		
		// Hide Email, Print Quote Buttons
		hideElement("emailQuoteBtn");
		hideElement("printQuoteBtn");
		
		// Change Order Now Button to Add to Cart
		hideElement("orderNowBtn");
		showElement("addToCartBtn");
		
		updateInstantQuotePrice();
	}

/* Q and A Tab OnClick Actions * *******************************************************
 *
 *	TAKES:		Tab Element
 * 	RETURNS:	NOTHING
 *	NOTE:		
 *
 ***********************************************************************************/
 
	function qAndATabOnClickActions()
	{
		var tabElement = getElement("qAndATab");
		
		if (activeTabRight != tabElement)
		{
			activeTabRight = tabElement;
			setContentTableClasses("rightContent", "Blue");
			
			// Set Content *************************
			hideElement("photoLibraryContent");
			showElement("qAndAContent");
			
			// Set Positioning ******************
			var photoLibraryTabElement = getElement("photoLibraryTab");
			
			photoLibraryTabElement.style.zIndex = "50";
			tabElement.style.zIndex = "100";
			
			photoLibraryTabElement.style.top = "5px";
			tabElement.style.top = "3px";
			
			//setPosY(photoLibraryTabElement, getElementY(photoLibraryTabElement) + 2);
			//setPosY(tabElement, getElementY(photoLibraryTabElement) - 2);
			
			// Set Default Question
			if (currentQAndAId == "")
			{
				var indexId = "4.1";
				var answerElement = getElement("qAndAAnswer" + indexId);
				
				getElement("qAndAQuestion" + indexId).className = "qAndAQuestionClicked";
				showElement(answerElement.id);
				currentQAndAId = answerElement.id;	
			}
		}
		
	}

/* Set Q and A Actions * *******************************************************
 *
 *	TAKES:		NOTHING
 * 	RETURNS:	NOTHING
 *	NOTE:		
 *
 ***********************************************************************************/
 
	function setQAndAActions()
	{
		var questionElements = getTagGroup("div", "qAndAQuestion");
		
		// Function to Iterate over *****************
		var iterateAction = function(questionElement, index)
		{
			questionElement.onmouseover = function()
			{
				this.style.cursor = "pointer";	
			}
			
			questionElement.onclick = function()
			{
				var indexId = this.id.replace("qAndAQuestion", "");
				var answerElement = getElement("qAndAAnswer" + indexId);
				
				if (currentQAndAId != "")
				{
					getElement("qAndAQuestion" + currentQAndAId.replace("qAndAAnswer", "")).className = "qAndAQuestion";
					hideElement(currentQAndAId);
				}
				
				this.className = "qAndAQuestionClicked";
				showElement(answerElement.id);
				currentQAndAId = answerElement.id;
				
			}
			
		}
		
		iterateElementList(questionElements, iterateAction);
	}

/* Add To Cart Button Actions * *******************************************************
 *
 *	TAKES:		NOTHING
 * 	RETURNS:	NOTHING
 *	NOTE:		
 *
 ***********************************************************************************/
 
	function addToCartBtnActions()
	{
		// Update Values **********************
		updateInstantQuotePrice(); 
		
		if (checkInstantQuoteValues())
		{
			if ( (emailPhotoType.indexOf("Stock Photo") != -1) & (getElement("selectedStockPhotoNo").innerHTML == "(No Photo Selected)") )
			{
				showElement("stockPhotoError");	
			}
			else
			{
				destroyInstantQuoteState(); 
				
				var sizeArray = emailMuralSize.split(" x ");
				var muralWidth = sizeArray[0];
				var muralHeight = sizeArray[1];
				
				var unitsArray = muralHeight.split(" ");
				muralHeight = unitsArray[0];
				sizeUnits = unitsArray[1];
				
				var sectionalProof = "";
				var scaleProof = "";
				
				if (getElement("muralSectionalProof").checked)
				{
					sectionalProof = true;	
				}
				
				if (getElement("muralScaleProof").checked)
				{
					scaleProof = true;	
				}
				
				var thisStockNo = getElement("selectedStockPhotoNo").innerHTML;
				
				if (thisStockNo == "(No Photo Selected)")
				{
					thisStockNo = "";
				}
				
				var queryVars = "&muralQty=" + getElement("muralQuantity").value;
				queryVars += "&muralType=" + emailMuralType;
				queryVars += "&muralWidth=" + muralWidth;
				queryVars += "&muralHeight=" + muralHeight;
				queryVars += "&stockNo=" + thisStockNo;
				queryVars += "&sizeUnits=" + sizeUnits;
				queryVars += "&mediaValue=" + emailMediaType.split("(")[0];
				queryVars += "&lamValue=" + emailLamType.split("(")[0];
				queryVars += "&sectionalProof=" + sectionalProof;
				queryVars += "&scaleProof=" + scaleProof;
				
				// Save current values *********************
				
				setAjaxUrl("updateData", "/murals/ajaxPhotoMuralsMain.asp?action=addMuralToCart" + queryVars, false, "location.href='/shop/shopcart.asp'");
			}
		}
		else
		{
			showElement("instantQuoteError");
		}
		
		
	}

/* Enable Proof Option * *******************************************************
 *
 *	TAKES:		Proof Toggle (true | false)
 * 	RETURNS:	NOTHING
 *	NOTE:		
 *
 ***********************************************************************************/
 
	function enableProofOption(showProof)
	{
		if (showProof)
		{
			showElement("orderNowViewProofs");	
		}
		else
		{
			getElement("muralSectionalProof").checked = false;
			getElement("muralScaleProof").checked = false;
			hideElement("orderNowViewProofs");
		}
	}

/* Mural My Photo Actions * *******************************************************
 *
 *	TAKES:		Proof Toggle (true | false)
 * 	RETURNS:	NOTHING
 *	NOTE:		
 *
 ***********************************************************************************/
 
	function muralMyPhotoActions()
	{
		getElement("photoMuralPhotoType_myPhoto").checked = true;
		updateInstantQuotePrice();
		hideElement("selectedPhotoContainer");	
	}
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	