/****************************************************************************************************/
/* Date created    Author           Comments ********************************************************/
/****************************************************************************************************/
/* 01/25/2008      Harish S. Ram  This file is created for FindHomeNationalSearch.aspx to call the Omniture Site Catalyst*/
/****************************************************************************************************/


		function SetOmnitureValuesforSearch()
		{
			try
			{
			var searchStaus = document.getElementById("hidSearchStatus") ;
			
			//To check whether Search is requested
			if (searchStaus.value == "1")
			{
				//Change the Search status to "0"
				searchStaus.value = "0"
				
				//To get the Selected Division and Neighborhood Name
				var sDivName = document.getElementById("hidDivName").value ;
				var sNeighName = document.getElementById("hidNeighName").value ;
				var sDivId = document.getElementById("hidDivId").value ;
				var sNeighId = document.getElementById("hidNeighId").value ;
				
				var sOmniValues = document.getElementById("hidCallOmniture").value ;
				//alert(sOmniValues);
				
				var sResultCount = document.getElementById("hidCount").value ;
				var sNeighborhoodNames = document.getElementById("hidName").value ;
												
				var sDivision = document.getElementById("ddlDivision")
				var sNeighbourhood = document.getElementById("ddlNeighborhood")
				
				var sddlPriceMin = document.getElementById("ddlPriceMin")
				var sddlPriceMax = document.getElementById("ddlPriceMax")
				var sddlSizeMin = document.getElementById("ddlSizeMin")
				var sddlSizeMax = document.getElementById("ddlSizeMax")
				var sddlBedroomsMin = document.getElementById("ddlBedroomsMin")
				var sddlBedroomsMax = document.getElementById("ddlBedroomsMax")
				var sddlStoriesMin = document.getElementById("ddlStoriesMin")
				var sddlStoriesMax = document.getElementById("ddlStoriesMax")
				var sddlCategories = document.getElementById("ddlCategories")
					
					
				/*Get the String and Pass it to an Array and set the selected values 
					to the array and pass the string to the Omniture Js Function
						
				Create a Array by spliting the dellimiters from the string */
				var OmniArray = new Array(sOmniValues)
				OmniArray = sOmniValues.split("|");
					
				//Since the first index of the array is a blank space, so delete it
				OmniArray.shift()
							
				var sNewOmniValues = "" ;
				
				//To get the selected Division and Neighborhood Names
				if (sDivId !=0)
				{
					//sDivision.value = sDivId ;
					
					//Assign the selected text from the Division Drop down to the array
					OmniArray[4] = sDivName ;
				}
				else
				{
					OmniArray[4] = "" ;
				}
				
				if (sNeighId !=0)
				{
					//sNeighbourhood.value = sNeighId ;
					OmniArray[5] = sNeighName ;
				}
				else
				{
					OmniArray[5] = "" ;
				}						
								
				if (sResultCount == 0)
				{
					OmniArray[11] = "zero" ;
				}
				else
				{
					OmniArray[11] = sResultCount ;
				}
				//OmniArray[11] = sResultCount ;
				OmniArray[32] =	 sNeighborhoodNames ;	
							
				//To check whether the User has selected any Search criteria			
				if ((sDivId == 0) && 
					(sNeighId == 0)&& 
					(sddlPriceMin.selectedIndex == 0)&& 
					(sddlPriceMax.selectedIndex == 0)&& 
					(sddlSizeMin.selectedIndex == 0)&& 
					(sddlSizeMax.selectedIndex == 0)&& 
					(sddlBedroomsMin.selectedIndex == 0)&& 
					(sddlBedroomsMax.selectedIndex == 0)&& 
					(sddlStoriesMin.selectedIndex == 0)&& 
					(sddlStoriesMax.selectedIndex == 0)&&
					(sddlCategories.selectedIndex == 0)	)
				{
					//If no search criteria selected
					OmniArray[4] = "no search criteria" ;
					OmniArray[5] = "" ;
				}
				
					
				//Iterate through the array and conatenate each value to a string 
				//seperated by "|" and pass the string to the CallOmniture() Javascript function
				for (i=0;i<OmniArray.length;i++)
				{
					sNewOmniValues = sNewOmniValues +'|' + OmniArray[i] 
				}
					
				//Call the Omniture function by passing the parameters in string
				CallOmniture(sNewOmniValues) ;
			}
			}
				catch(err)
				{
				}
			
		}
		
		
		
		//To identify the search Event
		function SetSearchStatus()
		{
			var searchStaus = document.getElementById("hidSearchStatus") ;
			searchStaus.value = "1" ;
			
			var sDivision = document.getElementById("ddlDivision")
			var sNeighbourhood = document.getElementById("ddlNeighborhood")
			
			var sDivName = document.getElementById("hidDivName") ;
			var sNeighName = document.getElementById("hidNeighName") ;
				
			sDivName.value = sDivision.options[sDivision.selectedIndex].text
			sNeighName.value = sNeighbourhood.options[sNeighbourhood.selectedIndex].text
		}
		
		
		
		
		
		
			


	