				
				function HeaderSearch(searchword)
				{
					//
					document.location.href = "Search.aspx?search=" + searchword;
					
									
					//alert(searchword)
					//GetResults()
					
				
				}
				
				function onSearchKeyUp(e)
				{
					if (e.keyCode == 13) // enter key
					{
						HeaderSearch(document.getElementById("searchField").value)
					}
				}
				
				//Get checkboxes search criteria Masonry Types
				//Get checkboxes search criteria Conditions
				function GetCheckBoxSet(cb)
				{
					//alert("step1");
					var cb = cb//document.Form1.ProjectCondition
					var sCheckBoxValues='';
					
					for(i=0;i<cb.length;i++)
					{
						//alert("step4" + cb[i].checked);
						if (cb[i].checked)
						{
							if(sCheckBoxValues.length > 0)
							{
								sCheckBoxValues = sCheckBoxValues + ':' + cb[i].value;
							}
							else
							{
								sCheckBoxValues = cb[i].value;
							}
						}
					}
					//alert(sCheckBoxValues);
					return sCheckBoxValues;/*sCheckBoxValues;*/
				}
				/*Create URL for GetProducts.aspx query*/
				function CreateUrl()
				{
					//alert(document.location);
					//var mtIDs = GetCheckBoxSet(document.Form1.MasonryType);
					//var pcIDs = GetCheckBoxSet(document.Form1.ProjectCondition);
					var searchwords = document.Form1.pName.value;
					var Url = 'http://www.cathedralstone.com/GetProducts.aspx?';
					var currenturl = document.location;
					var localurl = currenturl.toString().search(/localhost/i);
					var wwwcathurl = currenturl.toString().search(/http:\/\/www\.cathedralstone\.com/i)
					var cathurl = currenturl.toString().search(/http:\/\/cathedralstone\.com/i)
					var wwwjahnurl = currenturl.toString().search(/http:\/\/www\.jahnmortars\.com/i)
					var jahnurl = currenturl.toString().search(/http:\/\/jahnmortars\.com/i)
					
					//if (localurl > -1)
					//{
					Url = 'GetProducts.aspx?';					
					//}
					//else if (wwwcathurl > -1)
					//{
					//Url = 'http://www.cathedralstone.com/GetProducts.aspx?';					
					//}
					//else if (cathurl > -1)
					//{
					//Url = 'http://cathedralstone.com/GetProducts.aspx?';					
					//}
					//else if (wwwjahnurl > -1)
					//{
					//Url = 'http://www.jahnmortars.com/GetProducts.aspx?';					
					//}
					//else if (jahnurl > -1)
					//{
					//			Url = 'http://jahnmortars.com/GetProducts.aspx?';					
					//}
					
					//alert("constructed" + Url);
					
					if (searchwords.length > 0)
					{
						if (searchwords.search(/all products/i) == 0)
						{
							Url = Url + "searchwords=all&"
						}
						else
						{
							Url = Url + "searchwords=" + searchwords + "&"
						}	
					}
					else
					{
						Url = Url + "searchwords=all&"
					}
					
					//if ((mtIDs.length > 0) && (pcIDs.length > 0))
					//{
					//	Url = Url + 'MasonryTypeIDs=' + mtIDs + '&ConditionIDs=' + pcIDs;
					//}
					//else if (mtIDs.length > 0 && pcIDs.length <= 0)
					//{
					//	Url = Url + 'MasonryTypeIDs=' + mtIDs;
					//}
					//else if (mtIDs.length <= 0 && pcIDs.length > 0)
					//{
					//	Url = Url + 'ConditionIDs=' + pcIDs;
					//}
					//else
					//{
					//}
					
					//alert('URL: ' + Url);
					return Url;
				}
				
				function GetResults()
				{
				
					
				//alert('getresults1');
					Url=CreateUrl()
					ProductUrl = Url + "&PageType=Product"
					//CaseStudyUrl = Url + "&PageType=CaseStudy"
					
					//alert(ProductUrl)
					//alert(CaseStudyUrl)
					
					//Check if there is any checkboxes for the filters checked
					if (Url.search(/searchwords/) >= 0)
					{
						//ProdDiv = document.getElementById('DivProd')
						//ProdDiv.InnerHtml = 
						if (window.XMLHttpRequest)
						{
							//xmlhttpcase = new XMLHttpRequest()
							//xmlhttpcase.onreadystatechange=xmlhttpCaseChange
							//xmlhttpcase.open("GET",CaseStudyUrl,true)
							//xmlhttpcase.send(null)
							
							xmlhttp=new XMLHttpRequest()
							xmlhttp.onreadystatechange=xmlhttpChangeS
							xmlhttp.open("GET",ProductUrl,true)
							xmlhttp.send(null)
						}
						else if (window.ActiveXObject)
						{
							//xmlhttpcase=new ActiveXObject("Microsoft.XMLHTTP")
							//if (xmlhttpcase)
							//{
							//	xmlhttpcase.onreadystatechange=xmlhttpCaseChange
							//	xmlhttpcase.open("GET",CaseStudyUrl,true)
							//	xmlhttpcase.setRequestHeader("myserver","yippee");
							//	xmlhttpcase.send()
							//}
							
							xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
							if (xmlhttp)
							{
								xmlhttp.onreadystatechange=xmlhttpChangeS
								xmlhttp.open("GET",ProductUrl,true)
								xmlhttp.send()
							}
						}
					}
					else
					{
						ProdResultDiv = document.getElementById('DivProd')
						ProdResultDiv.innerHTML = ""
						ProdResultDiv.innerHTML = "<div class=NoProdDiv><span class=HowToSearch><b>Search for a product in 1 of 3 ways</b><br><br>1. Search product information by search words.<br><br> 2. Search products associated with a Masonry Type(s) <br><br> 3. Search products associated with a Project Condition</span></div>" 
					
					}
				}
				
				function xmlhttpChangeS()
				{
				// if xmlhttp shows "loaded"
				if (xmlhttp.readyState==4)
					{
					// if "OK"
					if (xmlhttp.status==200)
						{	
								//Get Div to put html
								//Get html (GetProducts.aspx?ConditionIDs=3:2:5:6:6:3:19&MasonryTypeIDs=3:5:6:7
								//Put Html into the Div
							document.getElementById('DivProd').innerHTML = ""
							document.getElementById('DivProd').innerHTML = xmlhttp.responseText
						}
					else
						{
							//alert("Problem retrieving XML data" + xmlhttp.status + "<br>" + xmlhttp.responseText)
							document.getElementById('DivProd').innerHTML = xmlhttp.responseText
						}
					}
				}		
				
				function xmlhttpCaseChange()
				{
				// if xmlhttp shows "loaded"
				if (xmlhttpcase.readyState==4)
					{
					// if "OK"
					if (xmlhttpcase.status==200)
						{	
								//Get Div to put html
								//Get html (GetProducts.aspx?ConditionIDs=3:2:5:6:6:3:19&MasonryTypeIDs=3:5:6:7
								//Put Html into the Div
							document.getElementById('DivCase').innerHTML = ""
							document.getElementById('DivCase').innerHTML = xmlhttpcase.responseText
						}
					else
						{
							//alert("Problem retrieving XML data" + xmlhttp.status + "<br>" + xmlhttpcase.responseText)
							document.getElementById('DivCase').innerHTML = xmlhttpcase.responseText
						}
					}
				}		
				
				function selectall(cb)
				{
				  var cbCont = document.Form1.MasonryType;
					var sCheckBoxValues='';
					if (cb == 'm')
					{
						cbCont = document.Form1.MasonryType
					}
					else if (cb == 'p')
					{
						cbCont = document.Form1.ProjectCondition
					}
				
					for(i=0;i<cbCont.length;i++)
					{
						cbCont[i].checked = true;	
					}
					
					GetResults();
				}
				
				function selectnone(cb)
				{
				  var cbCont = document.Form1.MasonryType;
					var sCheckBoxValues='';
					if (cb == 'm')
					{
						cbCont = document.Form1.MasonryType
					}
					else if (cb == 'p')
					{
						cbCont = document.Form1.ProjectCondition
					}
				
					for(i=0;i<cbCont.length;i++)
					{
						cbCont[i].checked = false;	
					}
					
					GetResults();
				}
				
				function removeValue()
				{
					//alert('ctrl.value: ' + document.Form1.pName.value.search(/all/i));
					if (document.Form1.pName.value.search(/all/i) == 0)
					{
						document.Form1.pName.value = "";
					}
				}