
function initialLoad1(){
	// Back Button Support
	dhtmlHistory.add("initialLoad1();", 'Listing Page [js]');
	var request= createRequest();

	// check if the product_id parameter was passed in, if so directly load a detail page
	// check if the search_type view_all is passed in and then run that
	// else count featured products for this center
	var productRequested = getURLParam('product_id');
	var searchType = getURLParam('search_type');
	if (productRequested != ""){
		request.open("GET", "/ProductCenter.bsci?method=product_detail&init=true&product_id=" + productRequested + "&url=" + location.pathname, true);
		request.onreadystatechange = function(){loadLeftDiv(request); loadDetailPage(request);}
	} else if (searchType != null && searchType == 'view_all') {
		document.getElementById("category_title").innerHTML = "View All";
		request.open("GET", "/ProductCenter.bsci?method=list_products&search_type=view_all&url=" + location.pathname, true);
		request.onreadystatechange = function(){loadLeftDiv(request); loadListPage(request);};						
	} else {
		request.open("GET", "/ProductCenter.bsci?method=count_products&url=" + location.pathname, true);
		request.onreadystatechange = function(){initialLoad2(request);}	
	}

	request.send(null);
}

// callback function for initialLoad1
function initialLoad2(request){
	// If the number of featured products is 1, load the detail page for that one, if it is 0 or many, load a list
	if (request.readyState == 4){
		if (request.status == 200){
			var request2 = createRequest();
			if (request.responseText == '1'){
				request2.open("GET", "/ProductCenter.bsci?method=product_detail&init=true&product_id=-1&url=" + location.pathname, true);	// id = -1 to find detail of selected
				request2.onreadystatechange = function(){loadLeftDiv(request2); loadDetailPage(request2);};
			} else {
				document.getElementById("category_title").innerHTML = "Featured Products";
				request2.open("GET", "/ProductCenter.bsci?method=list_products&init=true&search_type=featured&url=" + location.pathname, true);
				request2.onreadystatechange = function(){loadLeftDiv(request2); loadListPage(request2);};						
			}
			request2.send(null);
		}
	}
}

// callback function for loading a detail page
function loadDetailPage(request){
	if (request.readyState == 4){
		if (request.status == 200){

			var xmlDoc = request.responseXML.documentElement;
			
			// Set styles for detail page
			
			var rightColumn = document.getElementById("rightColumn");
			var resultsBox = document.getElementById("product_results_box");
			var column1 = document.getElementById("column1");
			var column2 = document.getElementById("column2");
			var overviewDiv = document.getElementById("product_overview_text");
			var prescriptiveInfo = document.getElementById("prescriptive_details");

			document.getElementById("category_title").style.display = "none";
			
			resultsBox.style.display = 'none';

			overviewDiv.style.display = "block";

			while (resultsBox.getElementsByTagName("div").length > 0){
				resultsBox.removeChild(resultsBox.getElementsByTagName("div").item(0));
			}

			// Empty prescriptive info, and add the link back to details page

			while(prescriptiveInfo.firstChild)
				prescriptiveInfo.removeChild(prescriptiveInfo.firstChild);


			var linkToDetailPage = document.createElement("a");
			var prod_id = xmlDoc.getElementsByTagName("product-list").item(0).getElementsByTagName("product-id").item(0).firstChild.nodeValue;
			linkToDetailPage.id = "link_to_detail_overview";
			linkToDetailPage.style.cssFloat = "right";
			linkToDetailPage.style.fontSize = "0.814em";
			linkToDetailPage.href = location.pathname + "?product_id=" + prod_id;
			linkToDetailPage.innerHTML = "Return to product overview >>";
			prescriptiveInfo.appendChild(linkToDetailPage);
			
			

			column1.style.display = "block";
			column1.style.padding = "0px 20px 0px 22px";

			column2.style.display = "block";
			
			prescriptiveInfo.style.display = "none";

			document.getElementById("product_title_and_overview").getElementsByTagName("h5").item(0).style.display = "block";
			document.getElementById("image_gallery").style.display = "block";

			// Load slideshow
			
			var slideshowImageElements = xmlDoc.getElementsByTagName("slideshow-image");
			
			loadSlideShow(slideshowImageElements);		

			// Delete old promotions
			
			var oldPromotions = getElementsByClassName(column2, "promotion");
			var oldPromotionsLength = oldPromotions.length;
			for (var i = 0; i < oldPromotionsLength; i++){
				column2.removeChild(oldPromotions[i]);
			}
			
			// Populate promotions
			
			var callouts_root = xmlDoc.getElementsByTagName("callouts").item(0);
			if (callouts_root != null){
				var callouts = callouts_root.getElementsByTagName("callout");
				for (var i = 0; i < callouts.length; i++){
					populatePromotion(callouts.item(i));
				}
			}

			// Populate overview information
			
			var title = xmlDoc.getElementsByTagName("product-list").item(0).getElementsByTagName("title").item(0).firstChild.nodeValue;
			var overviewText;
			if (xmlDoc.getElementsByTagName("product-overview").length > 0 && xmlDoc.getElementsByTagName("product-overview").item(0).childNodes.length > 0){
				overviewText = xmlDoc.getElementsByTagName("product-overview").item(0).firstChild.nodeValue;
				document.getElementById("product_overview_text").innerHTML = overviewText;		
			} else {
				document.getElementById("product_overview_text").innerHTML = '';
			}
		
			document.getElementById("product_title").innerHTML = title;
		
			// Populate product details
			var detailsList = xmlDoc.getElementsByTagName("product-detail");
			var detailsDiv = document.getElementById("product_details");
			detailsDiv.style.display = "block";
			while (detailsDiv.firstChild)
				detailsDiv.removeChild(detailsDiv.firstChild);
			for (var i = 0; i < detailsList.length; i++){
				loadProductDetail(detailsList.item(i), detailsDiv);
			}			
			// Populate prescriptive information
			
			var rightMenuPrescriptiveDiv = document.getElementById("prescriptiveInformationDiv");
			
			while (rightMenuPrescriptiveDiv.childNodes.length > 0)
			  rightMenuPrescriptiveDiv.removeChild(rightMenuPrescriptiveDiv.firstChild);
			
			rightMenuPrescriptiveDiv.className = "productRightMenuSection";
			var rightMenuPrescriptiveTitle = document.createElement("h4");
			rightMenuPrescriptiveTitle.id = "prescriptive_info_text";
			rightMenuPrescriptiveTitle.innerHTML = "Prescriptive Information";
			rightMenuPrescriptiveDiv.appendChild(rightMenuPrescriptiveTitle);
			var rightMenuPrescriptiveBody1 = document.createElement("span");
			rightMenuPrescriptiveBody1.id = "on_click_div";
			rightMenuPrescriptiveBody1.innerHTML = "View prescriptive information"
			rightMenuPrescriptiveBody1.onmouseover = function(){this.style.cursor = 'pointer'};
			rightMenuPrescriptiveBody1.onclick = function(){viewPrescriptiveInfo(request);};
			var rightMenuPrescriptiveBody2 = document.createElement("div");
			rightMenuPrescriptiveDiv.appendChild(rightMenuPrescriptiveBody1);			
			if (xmlDoc.getElementsByTagName("ifu-link-path").length > 0){
				var prescriptiveIfuDownloadHtml = "<a href='" + xmlDoc.getElementsByTagName("ifu-link-path").item(0).firstChild.nodeValue + "'>" + xmlDoc.getElementsByTagName("ifu-link-text").item(0).firstChild.nodeValue + "</a>";
				rightMenuPrescriptiveBody2.innerHTML = prescriptiveIfuDownloadHtml;
				rightMenuPrescriptiveDiv.appendChild(rightMenuPrescriptiveBody2);			
			}
			
			// Set the selected product in the finder
			setProductFinder(prod_id);
			
			
		}
	}
}

// callback function for loading a list page
function loadListPage(request){
	if (request.readyState == 4){
		if (request.status == 200){
						
			// set styles for list page
			var rightColumn = document.getElementById("rightColumn");
						
			var resultsBox = document.getElementById("product_results_box");
			resultsBox.style.display = "block";

			document.getElementById("category_title").style.display = "block";

			while (resultsBox.getElementsByTagName("div").length > 0){
				resultsBox.removeChild(resultsBox.getElementsByTagName("div").item(0));
			}

			var column1 = document.getElementById("column1");
			var column2 = document.getElementById("column2");
			var prescriptiveInfo = document.getElementById("prescriptive_details");
			
			column1.style.display = "none";

			if (document.getElementById("prescriptive_information") != null)
				column1.removeChild(document.getElementById("prescriptive_information"));

			column2.style.display = "none";

			while (prescriptiveInfo.firstChild)
				prescriptiveInfo.removeChild(prescriptiveInfo.firstChild);
				
			prescriptiveInfo.style.display = "none";
			
			// Load search results

			var xmlDoc = request.responseXML.documentElement;
			var productsList = xmlDoc.getElementsByTagName("product");
			for (var i = 0; i < productsList.length; i++){
				loadListItem(productsList[i]);
			}
			
		}
	}
}

// Function for loading the prescriptive information page

function viewPrescriptiveInfo(request) {
	// Back Button Support
	dhtmlHistory.add("viewPrescriptiveInfo(" + request + ");", 'Prescriptive Information Page [js]');
	
	// Update styles for prescriptive information page
	
	var column1Div = document.getElementById("column1");
	var productOverviewDiv = document.getElementById("product_overview_text");
	var imageGalleryDiv = document.getElementById("image_gallery");
	var productDetailsDiv = document.getElementById("product_details");
	var prescriptiveInformationDiv = document.getElementById("prescriptive_details");
	
	prescriptiveInformationDiv.style.display = "block";
	productOverviewDiv.style.display = "none";
	document.getElementById("product_title_and_overview").getElementsByTagName("h5").item(0).style.display = "none";
	imageGalleryDiv.style.display = "none";
	productDetailsDiv.style.display = "none";
		
	// Load prescriptive information details
	
	var xmlDoc = request.responseXML.documentElement;
	var prescriptiveDetailList = xmlDoc.getElementsByTagName("prescriptive-information-detail");
	
	// Cycle through the XML and call utility function to put in prescriptive info details
	for (var i = 0; i < prescriptiveDetailList.length; i++){
		loadPrescriptiveInfoDetail(prescriptiveDetailList.item(i), prescriptiveInformationDiv);
	}
	
	// Remove onclick from link to prescriptive info to prevent double-loading
	
	var onClickDiv = document.getElementById("on_click_div");
	onClickDiv.onclick = function(){};
}

// Called to drill down from list page to detail page
function productDetailPage(product_id){

	// Back Button Support
	dhtmlHistory.add("productDetailPage(" + product_id + ");", 'Detail Page [js]');

	var request = createRequest();
	request.open("GET", "/ProductCenter.bsci?method=product_detail&product_id=" + product_id + "&url=" + location.pathname, true);
	request.onreadystatechange = function(){loadDetailPage(request);};
	request.send(null);
}

// Called to run search: view all, featured, procedure_category
function filter(search_type, param){
	
	// Back Button Support
	var back = "leftHandColumnSelect2('" + search_type + "','" + document.getElementById("category_title").innerHTML + "');";	
	back = back + "filter('" + search_type + "'," + param + ");"
	dhtmlHistory.add(escape(back), 'Product Finder [js]');
	
	
	var request = createRequest();
	if (search_type == 'category_procedure'){
		request.open("GET", "/ProductCenter.bsci?method=list_products&search_type=category_procedure&category_procedure=" + param + "&url=" + location.pathname, true);
	} else {
		request.open("GET", "/ProductCenter.bsci?method=list_products&search_type=" + search_type +"&url=" + location.pathname, true);
	}
	request.onreadystatechange = function(){loadListPage(request);};
	request.send(null);
}

// Call from product finder
function callProductFinder(){
	var productFinderSelect = document.getElementsByTagName("select")[0];
	var product_id = productFinderSelect.options[productFinderSelect.selectedIndex].value;
 	if (product_id != -1)
		productDetailPage(product_id);
}

// Utility function for loading a single product on the list page
function loadListItem(productElement){


	// Get data to insert
	var title = productElement.getElementsByTagName("title").item(0).firstChild.nodeValue;
	var productId = productElement.getElementsByTagName("product-id").item(0).firstChild.nodeValue;
	var imagePath = '';
	var imageAlt = '';
	var shortDescription = '';
	
	if (productElement.getElementsByTagName("image").item(0).getElementsByTagName("path").length > 0 && productElement.getElementsByTagName("image").item(0).getElementsByTagName("path").item(0).childNodes.length > 0){
		imagePath = productElement.getElementsByTagName("image").item(0).getElementsByTagName("path").item(0).firstChild.nodeValue;	
	}

	if (productElement.getElementsByTagName("image").item(0).getElementsByTagName("alt").length > 0 && productElement.getElementsByTagName("image").item(0).getElementsByTagName("alt").item(0).childNodes.length > 0){
		imageAlt = productElement.getElementsByTagName("image").item(0).getElementsByTagName("alt").item(0).firstChild.nodeValue;	
	}

	if (productElement.getElementsByTagName("short-description").length > 0 && productElement.getElementsByTagName("short-description").item(0).childNodes.length > 0){
		shortDescription = productElement.getElementsByTagName("short-description").item(0).firstChild.nodeValue;
	} 
	
	// Add to page
	var resultsBox = document.getElementById("product_results_box");
	var resultDiv = document.createElement("div");
	resultDiv.className = "product_result";

	var productIdDiv = document.createElement("div");
	productIdDiv.className = "product_id";
	productIdDiv.innerHTML = productId;  
	resultDiv.appendChild(productIdDiv);

	if (imagePath != ''){
		var resultsImage = document.createElement("img");
		resultsImage.className = "result_image";
		resultsImage.style.border = "1px black solid";
		resultsImage.setAttribute("src", imagePath);
		resultsImage.setAttribute("alt", imageAlt);	
		resultsImage.onmouseover = function(){resultsImage.style.cursor='pointer'};
		resultDiv.appendChild(resultsImage);
	}

	var resultsRightDiv = document.createElement("div");
	resultsRightDiv.className = "results_right";
	resultDiv.appendChild(resultsRightDiv);

	var resultsTitleDiv = document.createElement("div");
	resultsTitleDiv.className = "results_title";
	resultsTitleDiv.innerHTML = title;
	resultsTitleDiv.onclick = function(){productDetailPage(productId);};
	resultsTitleDiv.onmouseover = function(){resultsTitleDiv.style.cursor='pointer'};
	resultsRightDiv.appendChild(resultsTitleDiv);

	var resultsDescriptionDiv = document.createElement("div");
	resultsDescriptionDiv.className = "product_description";
	resultsDescriptionDiv.innerHTML = shortDescription;
	resultsRightDiv.appendChild(resultsDescriptionDiv);
	resultsBox.appendChild(resultDiv);
	
}

// Utility function for loading a single product detail on the detail page
function loadProductDetail(detailElement, detailsDiv){

	var detailDiv = document.createElement("div");
	detailDiv.className = "product_detail";
	detailsDiv.appendChild(detailDiv);


	var detailDivTitle = document.createElement("h5");
	if (detailElement.getElementsByTagName("detail-title").item(0).firstChild)
		detailDivTitle.innerHTML = detailElement.getElementsByTagName("detail-title").item(0).firstChild.nodeValue;
	detailDiv.appendChild(detailDivTitle);

	var detailDivContent = document.createElement("div");
	detailDivContent.className = "product_detail_content";
	if (detailElement.getElementsByTagName("content").item(0).firstChild)
	detailDivContent.innerHTML = detailElement.getElementsByTagName("content").item(0).firstChild.nodeValue;
	detailDiv.appendChild(detailDivContent);
	
}

// Utility function for loading a single prescriptive information detail on the detail page
function loadPrescriptiveInfoDetail(detailElement, detailsDiv){
	
	var detailDiv = document.createElement("div");
	detailDiv.className = "prescriptive_information_detail";
	detailsDiv.appendChild(detailDiv);

	var detailDivTitle = document.createElement("h5");
	if (detailElement.getElementsByTagName("title").item(0).firstChild)
		detailDivTitle.innerHTML = detailElement.getElementsByTagName("title").item(0).firstChild.nodeValue;
	detailDiv.appendChild(detailDivTitle);

	var detailDivContent = document.createElement("div");
	detailDivContent.className = "prescriptive_information_detail_content";
	if (detailElement.getElementsByTagName("content").item(0).firstChild)
		detailDivContent.innerHTML = detailElement.getElementsByTagName("content").item(0).firstChild.nodeValue;
	detailDiv.appendChild(detailDivContent);
	
}


// Utility function for loading a single category onto the left side product page
function loadCategory(categoryElement, categoriesDiv){
	var categoryDiv = document.createElement("div");
	categoryDiv.className = "product_category";
	categoryDiv.innerHTML = categoryElement.getElementsByTagName("category-name").item(0).firstChild.nodeValue;
	categoryDiv.onclick = function(){leftHandColumnSelect(this); filter('category_procedure', categoryElement.getElementsByTagName("category-id").item(0).firstChild.nodeValue);};
	categoryDiv.onmouseover = function(){categoryDiv.style.cursor='pointer'};
	categoriesDiv.appendChild(categoryDiv);
}

// Utility function for loading a single procedure onto the left side product page
function loadProcedure(procedureElement, proceduresDiv){
	var procedureDiv = document.createElement("div");
	procedureDiv.className = "product_category";
	procedureDiv.innerHTML = procedureElement.getElementsByTagName("procedure-name").item(0).firstChild.nodeValue;
	procedureDiv.onclick = function(){leftHandColumnSelect(this); filter('category_procedure', procedureElement.getElementsByTagName("procedure-id").item(0).firstChild.nodeValue);};
	procedureDiv.onmouseover = function(){procedureDiv.style.cursor='pointer'};
	proceduresDiv.appendChild(procedureDiv);
}

// Utility function for loading a single promotion on a detail page
function populatePromotion(callout){
	var newPromotion = document.createElement("div");
	newPromotion.className = "productRightMenuSection promotion";
	var header = document.createElement("h4");
	header.innerHTML = callout.getElementsByTagName("callout-title").item(0).firstChild.nodeValue;
	var content = document.createElement("div");
	content.innerHTML = callout.getElementsByTagName("callout-description").item(0).firstChild.nodeValue;
	newPromotion.appendChild(header);
	newPromotion.appendChild(content);
	document.getElementById("column2").appendChild(newPromotion);
}

// Utility function for loading slideshow images
function loadSlideShow(slideshowImageElements){

	var firstLoad = true;
	if (imageSlideShows["image_slideshow"] != undefined)
		firstLoad = false;

	var key = 'image_slideshow';
	var interval = 8;
	if (slideshowImageElements.length > 0){
		document.getElementById("image_gallery").style.display = "block";
	} else {
		document.getElementById("image_gallery").style.display = "none";
	}
		

	try {
		imageSlideShows = new Array();
		var imageSlideShow = new ImageSlideShow(key, interval);
		// load the images from the XML
		for (var i = 0; i < slideshowImageElements.length; i++){
			var imageTitle = '';
			if (slideshowImageElements.item(i).getElementsByTagName("image-title").item(0).firstChild)
				imageTitle = slideshowImageElements.item(i).getElementsByTagName("image-title").item(0).firstChild.nodeValue;
			var imageDescription = '';
			if (slideshowImageElements.item(i).getElementsByTagName("image-description").item(0).firstChild)
				imageDescription = slideshowImageElements.item(i).getElementsByTagName("image-description").item(0).firstChild.nodeValue;
			var imagePath = '';
			if (slideshowImageElements.item(i).getElementsByTagName("image-path").item(0).firstChild)
				imagePath = slideshowImageElements.item(i).getElementsByTagName("image-path").item(0).firstChild.nodeValue;
			imageSlideShow.addSlide(imagePath, imageTitle, '#', imageTitle, imageDescription);			
		}

	} catch (missingDependencies) {
  		 alert('Image Slideshow with Graphic Buttons Component: The /iwov-resources/scripts/foundation/effects.js and /iwov-resources/scripts/foundation/image-slideshow.js files must be available on pages that use this component.');	
	}
	if (firstLoad == false){
		clearInterval(imageSlideShows["image_slideshow"].timer);
	} else {
		imageSlideShow.togglePause();
	}
	imageSlideShow.updateDiv();
	imageSlideShow.setPauseBtnLabels("/SEO-Test/assets/images/common/slideshow/bsc_pause_button.png","/SEO-Test/assets/images/common/slideshow/bsc_play_button.png");
}

function loadLeftDiv(request){
	if (request.readyState == 4){
		if (request.status == 200){


			var xmlDoc = request.responseXML.documentElement;
			var productFinderInput = document.getElementById("product_finder_selector");
			
			// Back Button Suppport - make sure no entries are in the product finder when reloading on back button click
			if(productFinderInput.hasChildNodes())
			{
				removeChildNodes(productFinderInput);
			}

			var optionElement = document.createElement("option");
			optionElement.innerHTML = "";
			optionElement.value = -1;
			productFinderInput.appendChild(optionElement);

			var productFinderList = xmlDoc.getElementsByTagName("product-option");
			for (var i = 0; i < productFinderList.length; i++){
				var optionElement = document.createElement("option");
				optionElement.innerHTML = productFinderList.item(i).childNodes.item(1).firstChild.nodeValue;
				optionElement.value = productFinderList.item(i).childNodes.item(0).firstChild.nodeValue;
				productFinderInput.appendChild(optionElement);
			}
			
			var featuredProductsDiv = document.getElementById("product_search").getElementsByTagName("div")[0];
			featuredProductsDiv.onclick = function(){leftHandColumnSelect(this); filter('featured', null);};
			featuredProductsDiv.onmouseover = function(){featuredProductsDiv.style.cursor='pointer'};

			var viewAllProductsDiv = document.getElementById("product_search").getElementsByTagName("div")[1];
			viewAllProductsDiv.onclick = function(){leftHandColumnSelect(this); filter('view_all', null);};
			viewAllProductsDiv.onmouseover = function(){viewAllProductsDiv.style.cursor='pointer'};

			var categoryDiv = document.getElementById("product_categories");
			var procedureDiv = document.getElementById("product_procedures");
			
			// Back Button Support
			// If Categories and Products are already listed, do not reload
			if(getElementsByClassName(categoryDiv, "product_category").length ==0)
			{
				var categoryList = xmlDoc.getElementsByTagName("category");

				if (categoryList.length > 0){
					categoryDiv.style.display = "block";
				} else {
					categoryDiv.style.display = "none";
				}

				for (var i = 0; i < categoryList.length; i++){
					loadCategory(categoryList.item(i), categoryDiv);
				}
			}
			
			if(getElementsByClassName(procedureDiv, "product_category").length ==0)
			{
				var procedureList = xmlDoc.getElementsByTagName("procedure");
				
				if (procedureList.length > 0){
					procedureDiv.style.display = "block";
				} else {
					procedureDiv.style.display = "none";
				}
	
				
				for (var i = 0; i < procedureList.length; i++){
					loadProcedure(procedureList.item(i), procedureDiv);
				}
			}

		}
	}
}

function getURLParam(strParamName){
  var strReturn = "";
  var strHref = window.location.href;
  if ( strHref.indexOf("?") > -1 ){
    var strQueryString = strHref.substr(strHref.indexOf("?")).toLowerCase();
    var aQueryString = strQueryString.split("&");
    for ( var iParam = 0; iParam < aQueryString.length; iParam++ ){
      if (aQueryString[iParam].indexOf(strParamName.toLowerCase() + "=") > -1 ){
        var aParam = aQueryString[iParam].split("=");
        strReturn = aParam[1];
        break;
      }
    }
  }
  return unescape(strReturn);
} 

// Standard AJAX create request function
function createRequest(){
	var ajaxRequest; 
	try {
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		try {
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e)	{
			try {
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e)	{
				alert("Your browser does not support Ajax.  Please update your browser");
			}
		}
	}
	return ajaxRequest;
}

  // Not supported in IE6 so we have to manually define
  
  function getElementsByClassName(node, classname)
  {
      var a = [];
      var re = new RegExp('\\b' + classname + '\\b');
      var els = node.getElementsByTagName("*");
      for(var i=0,j=els.length; i<j; i++)
      {
      	
          if(re.test(els[i].className))
          {
          	a.push(els[i]);
          }
      }
      return a;
}

// Utility function to turn the left hand side items to nonselected color and select the passed in item

function leftHandColumnSelect2(type, selected_cat){
	
	// Based on type, set the values on the page accordingly
	var categories = getElementsByClassName(document.documentElement, "product_category");
	document.getElementById("category_title").innerHTML = selected_cat; 
	if(type == 'view_all')
	{
		// View All selected
		document.getElementById("featured_products_text").style.color = "#4EB1DF";
		document.getElementById("view_all_products_text").style.color = "#555555";
		for (var x=0, y=categories.length; x<y; x++){ 
			categories[x].style.color = "#4EB1DF";
		}
	}
	else if(type == 'featured')
	{
		// Featured products selected
		document.getElementById("featured_products_text").style.color = "#555555";
		document.getElementById("view_all_products_text").style.color = "#4EB1DF";
		for (var x=0, y=categories.length; x<y; x++){
			categories[x].style.color = "#4EB1DF";
		}
	}
	else
	{
		// Category or procedure selected
		document.getElementById("featured_products_text").style.color = "#4EB1DF";
		document.getElementById("view_all_products_text").style.color = "#4EB1DF";
		for (var x=0; x<categories.length; x++){
			if(categories[x].innerHTML == selected_cat)
			{
				categories[x].style.color = "#555555";
			}
			else
			{
				categories[x].style.color = "#4EB1DF";
			}
		}
	}
	
}
	
	function leftHandColumnSelect(selectedCategory){
		document.getElementById("featured_products_text").style.color = "#4EB1DF";
		document.getElementById("view_all_products_text").style.color = "#4EB1DF";
		var categories = getElementsByClassName(document.documentElement, "product_category");
		for (var x=0, y=categories.length; x<y; x++){
			categories[x].style.color = "#4EB1DF";
		}
		if (selectedCategory != null ){
			selectedCategory.style.color = "#555555";
			document.getElementById("category_title").innerHTML = selectedCategory.innerHTML; 
		}
	
	
	}
	
function removeChildNodes(ctrl)
{
  while (ctrl.childNodes[0])
  {
    ctrl.removeChild(ctrl.childNodes[0]);
  }
}

function setProductFinder(prod_id)
{
	var productFinderSelect = document.getElementsByTagName("select")[0];
	for(i=0; i< productFinderSelect.options.length; i++)
	{
		if(productFinderSelect[i].value == prod_id)
		{
			productFinderSelect.selectedIndex = i;
			return;
		}
	}
}

