/*Function added for Search */
	function QuickLink(Asset_Value_Name)
	{
		if (typeof document.forms[0].hidPageNum == 'object') 
		{
			document.forms[0].hidPageNum.value = '1';
		}
		if (typeof document.forms[0].hidSelectedQuickLink == 'object')
		{
 			document.forms[0].hidSelectedQuickLink.value	= 'banner_' + Asset_Value_Name +'_New2';
		}

		var strQuickLink="";
		var strFilterMainAttributeID="";
		var objhidSearch = document.getElementById('hidSearch');
		for(var i=0; i < strSubCatArray.length; i++)
		{
			if (Asset_Value_Name == strSubCatArray[i][2])
			{
			
				for (var j=0; j < strSubCatArray.length; j++)
				{
					
					if (strSubCatArray[i][0] == strSubCatArray[j][3] )
					{
						strQuickLink =  strSubCatArray[j][1]  ;
							
					}					
				}
				
				if (strQuickLink=="")
				{
					strQuickLink =	strSubCatArray[i][1];
					//strFilterMainAttributeID="," + GetMainAttributeId(strSubCatArray[i][1]);
				}
				else
				{
					strQuickLink =	strQuickLink + "~" + strSubCatArray[i][1] ; 
				}
					
			}
		}
		
		for(var i=0; i < strSubCatArray.length; i++)
		{
			if (Asset_Value_Name == strSubCatArray[i][2])
			{
			
				for (var j=0; j < strSubCatArray.length; j++)
				{
					
					if (strSubCatArray[i][0] == strSubCatArray[j][3] )
					{
						strFilterMainAttributeID="," +GetMainAttributeId(strSubCatArray[j][1])	
					}					
				}
				
				if (strQuickLink=="")
				{
					
					strFilterMainAttributeID = "," +GetMainAttributeId(strSubCatArray[i][1])	
				}
				else
				{
					strFilterMainAttributeID = strFilterMainAttributeID + "," + GetMainAttributeId(strSubCatArray[i][1])	
				}
					
			}
		}
		
		//strFilterMainAttributeID="," + GetMainAttributeId(strQuickLink)
		
		
		if(strFilterMainAttributeID!='')
		{
			document.getElementById('hidFilterMainAttributeID').value=strFilterMainAttributeID
		}
		else
		{
			document.getElementById('hidFilterMainAttributeID').value=document.getElementById('hidMainSearchId').value
		}
		document.getElementById('hidYearMainAttributeID').value=document.getElementById('hidYearMainSearchId').value
		
		
	
		document.getElementById('hidDyComps_Selected_Values_Name').value = Asset_Value_Name
		document.getElementById('hidDyComps_Selected_Values_Id').value = GetAttributeValueID(Asset_Value_Name)

		//SubmitForm()		
		document.getElementById('hidDyComps_Selected_Values').value = strQuickLink;
		document.getElementById('hidFilterMainAttributeID').value=strFilterMainAttributeID
	
		objhidSearch.value = "True";	
		window.document.forms[0].submit();		
	}
	function GetAttributeValueID(AttributeValueValue)
	{
		var strAttributeValueName
		for(var i=0; i < strSubCatArray.length; i++)
			{
				if (AttributeValueValue == strSubCatArray[i][2])
				{
				
					strAttributeValueName = strSubCatArray[i][1]
				}
			}
			return strAttributeValueName
	}
	
	
	function submitQuickLink(strCategory)
	{	
		var strQuickLink = "";
		if (strCategory.length > 0)
		{		
			var arrCategory = strCategory.split("/");
			if (arrCategory.length >0)
			{
				for (i=0 ; i < arrCategory.length; i++)
				{
					for(var j=0; j < strSubCatArray.length; j++)
					{
						if (arrCategory[i] == strSubCatArray[j][2])
						{
							if( strQuickLink == '')
							{strQuickLink = strSubCatArray[j][1];
							}
							else
							{strQuickLink = strQuickLink + "~" + strSubCatArray[j][1];
							}
						}
					}
				}
				strQuickLink = strQuickLink + '~0';
			}
			
			document.getElementById('hidDyComps_Selected_Values').value = strQuickLink;
			if (document.getElementById(document.getElementById('hidSearchText_ClientID').value)!= null)
			{
				document.getElementById(document.getElementById('hidSearchText_ClientID').value).value='';
			}
			document.getElementById('hidSearchText_Values').value = '';			
			window.document.forms[0].submit();		
			return false;
		}
	}
	
	function ValidateSearch()
	{
		SubmitForm();
		document.forms[0].submit();		
		return false;
	}
	function categoryComboChange(com1,com2,tnmFilterTable,tnmFilterTable2)
	{
		var CombTableId = "objContainerControl_objTemplateContainerControl_objSearch_tblSearchCombos"
		var CombTable =document.getElementById(CombTableId);
		var Com1 = document.getElementById(com1); 
		var Com2 = document.getElementById(com2);
		var TnmFilterTable = document.getElementById(tnmFilterTable); 
		var TnmFilterTable2= document.getElementById(tnmFilterTable2);
		
		var DisplayMod = document.getElementById('hidDisplayMod').value;
		var objhidDyComps_IDs = document.getElementById('hidDyComps_ClientID').value;
		var arrobjhidDyComps_IDs = objhidDyComps_IDs.split("~");

		var objhidDyFilterTable_IDs = document.getElementById('hidDyFilterTable_ClientID').value;
		var arrobjhidDyFilterTable_IDs = objhidDyFilterTable_IDs.split("~");
		if (Com2 != null)
		{ 
			if (DisplayMod == 'grayed')
			{
				if ( Com2.disabled == true )
				{
					Com2.disabled = false;				
				}
				else if ( Com2.disabled == false )
				{
					if (Com1.selectedIndex == 0 )
					{	
						var Com1_ID = parseInt(com1.substring(com1.length-1,com1.length)) + 1 ;
						var i;
						for(i=Com1_ID;i<arrobjhidDyComps_IDs.length;i++)
						{
							var tmpSelect =document.getElementById(arrobjhidDyComps_IDs[i]);
							var tmpFilterTable = document.getElementById(arrobjhidDyFilterTable_IDs[i]);
							tmpSelect.selectedIndex = 0;
							tmpSelect.disabled = true;						
						}
						if(typeof(CombTable) =='object')
						{
							CombTable.className = "SearchFilterTable"
						}
						return;
					}
					else
					{
						var Com1_ID = parseInt(com1.substring(com1.length-1,com1.length)) + 2 ;
						var i;
						for(i=Com1_ID;i<arrobjhidDyComps_IDs.length;i++)
						{
							var tmpSelect =document.getElementById(arrobjhidDyComps_IDs[i]);
							var tmpFilterTable = document.getElementById(arrobjhidDyFilterTable_IDs[i]);
							tmpSelect.selectedIndex = 0;
							tmpSelect.disabled = true;						
						}
						if(typeof(CombTable) =='object')
						{
							CombTable.className = "SearchFilterTableBorder"
						}
					}
				}
			}
			else if (DisplayMod == 'hide')
			{	
			
				if(TnmFilterTable2.style.display == 'none')
				{
					TnmFilterTable2.style.display = 'block';
				}
				else if( TnmFilterTable2.style.display == 'block' || TnmFilterTable2.style.display == '')
				{
					if (Com1.selectedIndex == 0 )
					{	
						var Com1_ID = parseInt(com1.substring(com1.length-1,com1.length)) + 1 ;
						var i;
						
						for(i=Com1_ID;i<arrobjhidDyComps_IDs.length;i++)
						{
							var tmpSelect =document.getElementById(arrobjhidDyComps_IDs[i]);
							var tmpFilterTable = document.getElementById(arrobjhidDyFilterTable_IDs[i]);
							tmpSelect.selectedIndex = 0;
							tmpFilterTable.style.display = 'none';						
						}
						if(typeof(CombTable) =='object')
						{
							CombTable.className = "SearchFilterTable"
						}
						return;
					}
					else
					{
						var Com1_ID = parseInt(com1.substring(com1.length-1,com1.length)) + 2 ;
						var i;
						for(i=Com1_ID;i<arrobjhidDyComps_IDs.length;i++)
						{
							var tmpSelect =document.getElementById(arrobjhidDyComps_IDs[i]);
							var tmpFilterTable = document.getElementById(arrobjhidDyFilterTable_IDs[i]);
							tmpSelect.selectedIndex = 0;
							tmpFilterTable.style.display = 'none';						
						}
						if(typeof(CombTable) =='object')
						{
							CombTable.className = "SearchFilterTableBorder"
						}
					}
				}
			}
		}

		var objCategory = document.getElementById(com1);
		if(typeof(objCategory) =='object')
		{
			var strCategory=objCategory.options[objCategory.selectedIndex].text;
			var nCategory=objCategory.options[objCategory.selectedIndex].value;
			var x=0;
			if(typeof(CombTable) =='object')
			{	if(nCategory != 0)
				{
					CombTable.className = "SearchFilterTableBorder"
				}else
				{
					CombTable.className = "SearchFilterTable"
				}
			}
			Com2.options.length=0;
			Com2.options[0]=new Option("--Show All--", "0");
			if (DisplayMod == 'grayed')
			{
				Com2.disabled = true;
			}
			else if (DisplayMod == 'hide')
			{
				TnmFilterTable2.style.display = 'none'
			}
			if( Com2 != null)
			{
				for(var i=0; i<strSubCatArray.length ;i++)
				{	

					if(nCategory==0)
					{
					}
					else
					{
						if(nCategory==strSubCatArray[i][1])
						{
							for(var j=0; j<strSubCatArray.length ;j++)
							{ 
								if(strSubCatArray[i][3] == strSubCatArray[j][0])
								{
									if (DisplayMod == 'grayed')
									{
										Com2.disabled = false;
									}
									else if (DisplayMod == 'hide')
									{
										TnmFilterTable2.style.display = 'block'
									}								
									x=x+1;
									Com2.options[x] = new Option(strSubCatArray[j][2],strSubCatArray[j][1]); 
								}
							}
						}
					}
				}
			}
			
		}
		
		
	}
	
	function PopulateFilters()
	{ 
		var objhidSearchText_ID=''
		var CombTableId = "objContainerControl_objTemplateContainerControl_objSearch_tblSearchCombos"
		var CombTable =document.getElementById(CombTableId);
		objhidSearchText_ID = document.getElementById('hidSearchText_ClientID');
		var strSearchText_Value =document.getElementById('hidSearchText_Values').value;
		if (objhidSearchText_ID.value!=	'')
		{
			document.getElementById(objhidSearchText_ID.value).value=strSearchText_Value;
				
		}
		var FilterSelectedValues = "";
		var YearFilterSelectedValue = "";
		if (typeof(document.getElementById('hidDyComps_Selected_Values')) =='object')
		{
			FilterSelectedValues = document.getElementById('hidDyComps_Selected_Values').value;
		}
		
		if ( document.getElementById('hidYearAttributeID') != null)
		{
			 YearFilterSelectedValue  = document.getElementById('hidYearAttributeID').value;
		}
		
				
		if (FilterSelectedValues != "")
		{
			var arrFilterSelectedValues = FilterSelectedValues.split("~");
			var objhidDyComps_IDs = document.getElementById('hidDyComps_ClientID').value; 
			var arrobjhidDyComps_IDs = objhidDyComps_IDs.split("~");
			
			var objhidDyFilterTable_IDs = document.getElementById('hidDyFilterTable_ClientID').value;
			var arrobjhidDyFilterTable_IDs = objhidDyFilterTable_IDs.split("~");
			if(typeof(CombTable) =='object')
			{
				CombTable.className = "SearchFilterTableBorder"
			}
			
			var i=0;
			
			for (i = 0 ; i< arrFilterSelectedValues.length ; i++)
			{
				if (i==0)
				{	FillCategory(arrFilterSelectedValues[i],document.getElementById(arrobjhidDyComps_IDs[i]));
				}
				if(arrFilterSelectedValues[i] == '0')
				{	
				break;	
				}
				else //populate filters.....
				{
					FillSubcategory(i+1,parseInt(arrFilterSelectedValues[i]),parseInt(arrFilterSelectedValues[i+1]),document.getElementById(arrobjhidDyComps_IDs[i+1]),document.getElementById(arrobjhidDyFilterTable_IDs[i+1]));
				}
			}
		}	
		else if (FilterSelectedValues == "")
		{
			var objhidDyComps_IDs = document.getElementById('hidDyComps_ClientID').value; 
			var arrobjhidDyComps_IDs = objhidDyComps_IDs.split("~");
			if (document.getElementById(arrobjhidDyComps_IDs[0]) != null)
			{
				document.getElementById(arrobjhidDyComps_IDs[0]).selectedIndex = 0;
			}
		}
		
		
		if (YearFilterSelectedValue != "" )
		{
			if (document.getElementById('hidYearFilter_ClinetID').value != '')
			{
				var objYearFilter = document.getElementById(document.getElementById('hidYearFilter_ClinetID').value);
				if (objYearFilter != null)
				{
					if (objYearFilter != '')
					{
						for(var i=0; i< objYearFilter.length;i++)
						{
							if(objYearFilter.options[i].value == YearFilterSelectedValue)
							{
								objYearFilter.selectedIndex=i;							
							}
						}			
					}		
				}
			}
		}
		else
		{
			if (document.getElementById('hidYearFilter_ClinetID').value != '')
			{
				var objYearFilter = document.getElementById(document.getElementById('hidYearFilter_ClinetID').value);
				if (objYearFilter != null)
				{
					if (objYearFilter != '')
					{
						objYearFilter.selectedIndex=0;							
					}		
				}
			}
		}
		var objhidDivActive = document.getElementById('hidDivActive');
		showDiv(objhidDivActive.value)
	}
	
	function FillCategory(nCategory,objCategory)
	{
		for (var i =0; i< objCategory.options.length ; i++)
		{
			if (objCategory.options[i].value==nCategory)
			{
				objCategory.selectedIndex = i;		
			}	
		}
	}
	
	function FillSubcategory(i,nCategory,nCategory2,objSubCategory,objFilterTable)
	{		
		if (objSubCategory != null &&  objFilterTable != null)
		{
			var x=0;
			var SelectedIndex = 0;
			var DisplayMod = document.getElementById('hidDisplayMod').value;
			objSubCategory.options.length=0;
			objSubCategory.options[0]=new Option("--Show All--", "0");
			if (DisplayMod == 'grayed')
			{
				objSubCategory.disabled = true;
			}
			else if (DisplayMod == 'hide')
			{
				objFilterTable.style.display = 'none'
			}
			if(typeof objSubCategory == 'object')
			{
				for(var i=0; i<strSubCatArray.length ;i++)
				{	

					if(nCategory==0)
					{
					}
					else
					{
						if(nCategory==strSubCatArray[i][1])
						{
							for(var j=0; j<strSubCatArray.length ;j++)
							{ 
								if(strSubCatArray[i][3] == strSubCatArray[j][0])
								{
									if (DisplayMod == 'grayed')
									{
										objSubCategory.disabled = false;
									}
									else if (DisplayMod == 'hide')
									{
										objFilterTable.style.display = 'block'
									}								
									x=x+1;
									objSubCategory.options[x] = new Option(strSubCatArray[j][2],strSubCatArray[j][1]); 
									if(parseInt(strSubCatArray[j][1])== nCategory2 )
									{	
										SelectedIndex = x;
									}
								}
							}													
						}
					}
				}			
				objSubCategory.selectedIndex = SelectedIndex;			
			}	
		}	
	}

	function SubmitForm()
	{
	
		if (typeof document.forms[0].hidPageNum == 'object') 
		{
			document.forms[0].hidPageNum.value = '1';
		}
		
		if (typeof document.forms[0].hidAssetTypeChanged == 'object') 
		{
		
			document.forms[0].hidAssetTypeChanged.value = "true";	
		}
		
		
		var objhidSearch = document.getElementById('hidSearch');
		var objhidSearchText_ID = document.getElementById('hidSearchText_ClientID');
		var objhidDyComps_IDs = document.getElementById('hidDyComps_ClientID').value; 
		
		if (objhidSearchText_ID.value!=	'')
		{
			var strSearchText_Value = document.getElementById(objhidSearchText_ID.value).value;
			if (strSearchText_Value =='')
			{
			strSearchText_Value = "<Enter Keyword(s)>";
			}
			if (strSearchText_Value != "<Enter Keyword(s)>")
			{
				document.getElementById('hidSearchText_Values').value = strSearchText_Value;
			}
			else
			{
				document.getElementById('hidSearchText_Values').value="";
			}
		}
		else
		{
			document.getElementById('hidSearchText_Values').value = '';
		}
		//alert(document.getElementById('hidSearchText_Values').value)
		var strSearchFilters = '';
		var strYearFilter = ''; 
		var strSearchFilterText='';
		var strFilterMainAttributeID=''
		var strYearMainAttributeID=''
		if(objhidDyComps_IDs!='')
		{
			var arrobjhidDyComps_IDs = objhidDyComps_IDs.split("~");
			var i;
			for(i=0;i<arrobjhidDyComps_IDs.length;i++)
			{
				var tmpSelect =document.getElementById(arrobjhidDyComps_IDs[i]);
				if (typeof(tmpSelect) =='object')
				{
					if (tmpSelect.selectedIndex > 0 )
					{
						if (strSearchFilters =="")
						{	
							strSearchFilters = tmpSelect.options[tmpSelect.selectedIndex].value ;	
							
						}
						else
						{	
							strSearchFilters = strSearchFilters + '~' + tmpSelect.options[tmpSelect.selectedIndex].value ;			
							if(i==1)
							{
								if (typeof document.forms[0].hidSelectedQuickLink == 'object')
								{
									document.forms[0].hidSelectedQuickLink.value	= 'banner_' + tmpSelect.options[tmpSelect.selectedIndex].text +'_New2';
									
								}
							}
						}
						
						strSearchFilterText = tmpSelect.options[tmpSelect.selectedIndex].value ;
					}
					else
					{
						if(i==1)
						{
							if (typeof document.forms[0].hidSelectedQuickLink == 'object')
							{
								document.forms[0].hidSelectedQuickLink.value	= '';
								
							}
						}
					}
				}
			}
		}
		if (document.getElementById('hidYearFilter_ClinetID').value != '')
		{
			var objYearFilter = document.getElementById(document.getElementById('hidYearFilter_ClinetID').value);
			if (objYearFilter != null)
			{	
				if (objYearFilter.options[objYearFilter.selectedIndex].value != 0) 
				{
					strYearFilter =objYearFilter.options[objYearFilter.selectedIndex].value ;
					strYearMainAttributeID=document.getElementById('hidYearMainSearchId').value;
				}
			}
		}
		
		
		
		if(objhidDyComps_IDs!='')
		{
			var arrobjhidDyComps_IDs = objhidDyComps_IDs.split("~");
			var i;
			
			for(i=0;i<arrobjhidDyComps_IDs.length;i++)
			{
				var tmpSelect =document.getElementById(arrobjhidDyComps_IDs[i]);
				
				if (typeof(tmpSelect) =='object')
				{
					if (tmpSelect.selectedIndex > 0 )
					{
						if (strFilterMainAttributeID =="")
						{	
							strFilterMainAttributeID =  ',' +GetMainAttributeId(tmpSelect.options[tmpSelect.selectedIndex].value)		
						}
						else
						{	
							strFilterMainAttributeID =  strFilterMainAttributeID + ',' + GetMainAttributeId(tmpSelect.options[tmpSelect.selectedIndex].value)
						}
					}
				}
			}
		}
		
		if(strFilterMainAttributeID!='')
		{
			document.getElementById('hidFilterMainAttributeID').value=strFilterMainAttributeID
		}
		else
		{
			document.getElementById('hidFilterMainAttributeID').value=document.getElementById('hidMainSearchId').value
		}
		if(strYearMainAttributeID!='')
		{
			document.getElementById('hidYearMainAttributeID').value=strYearMainAttributeID
		}
		else
		{
			document.getElementById('hidYearMainAttributeID').value=document.getElementById('hidYearMainSearchId').value
		}
		if (strSearchFilterText != '')
		{//alert(1)
			document.getElementById('hidDyComps_Selected_Values_Name').value = GetAttributeValueName(strSearchFilterText)
			document.getElementById('hidDyComps_Selected_Values_Id').value = strSearchFilterText
		}
		
		
		
			
		document.getElementById('hidDyComps_Selected_Values').value = strSearchFilters;
		document.getElementById('hidYearAttributeID').value=strYearFilter;
		//debugger
		
		if (strSearchFilters != ''  || strSearchText_Value != '<Enter Keyword(s)>' || strYearFilter != '')
		{
			objhidSearch.value = "True";	
			document.getElementById('hidSesionChange').value='true'		
		}
	}
	function GetAttributeValueName(AttributeValueID)
	{
		var strAttributeValueName
		for(var i=0; i < strSubCatArray.length; i++)
			{
				if (AttributeValueID == strSubCatArray[i][1])
				{
				
					strAttributeValueName = strSubCatArray[i][2]
				}
			}
			return strAttributeValueName
	}
	function catchKeyPressSearch(code) 
			{
				if( code == '13') 
				{
					SubmitForm()
				}
			}
	function GetMainAttributeId(AttributeValueIDs)
	{
	
		var strMainAttributeIds=''
	    if (AttributeValueIDs.length > 0)
		{		
			var arrAttributeValueIDs = AttributeValueIDs.split("~");
			if (arrAttributeValueIDs.length >0)
			{
				for(var i=0; i < arrAttributeValueIDs.length; i++)
				{
					for(var j=0; j < strSubCatArray.length; j++)
					{
						if (strSubCatArray[j][1]== arrAttributeValueIDs[i])
						{
							
							for(var k=0; k < strSubCatArray.length; k++)
							{
								if (strSubCatArray[k][0]== strSubCatArray[j][3])
								{
									
									if(strMainAttributeIds=='')
									{
										strMainAttributeIds = strSubCatArray[k][4]
										
									}
									
							
								}
							}
												
						}
					}
				}
			}
		}	
	   
		return strMainAttributeIds
	}
	
	function YearComboChange(objID)
	{
		var objFrmName =  'window.document.forms[0]';
		if (typeof document.getElementById('hidYear') == 'object')
				document.getElementById('hidYear').value	=objID.value
			
	}
	
	function RefinedResults(Attribute_Value_id,Attribute_Value_Name)
	{
		var strFilterMainAttributeID=''
		var strYearMainAttributeID=''
	    if (typeof document.forms[0].hidPageNum == 'object') 
		{
			document.forms[0].hidPageNum.value = '1';
		}

		var strQuickLink="";
		var objhidSearch = document.getElementById('hidSearch');

		for(var i=0; i < strSubCatArray.length; i++)
		{
			if (Attribute_Value_id == strSubCatArray[i][1])
			{
				document.getElementById('hidYearAttributeID').value = "";
				for (var j=0; j < strSubCatArray.length; j++)
				{
					if (strSubCatArray[i][0] == strSubCatArray[j][3] )
					{

					
						for (var k=0; k < strSubCatArray.length; k++)
						{
							if (strSubCatArray[j][0] == strSubCatArray[k][3] )
							{
								if( strQuickLink == '')
								{
									
									strQuickLink = strSubCatArray[k][1];
									strFilterMainAttributeID = "," +GetMainAttributeId(strSubCatArray[k][1])	
									
								}
								else
								{
									strQuickLink =  strSubCatArray[k][1] + "~" + strQuickLink ;
									strFilterMainAttributeID = strFilterMainAttributeID +"," + GetMainAttributeId(strSubCatArray[k][1])		
									
								}
							}					
						}
						
						if( strQuickLink == '')
						{
							
							strQuickLink = strSubCatArray[j][1];
							strFilterMainAttributeID = "," +GetMainAttributeId(strSubCatArray[j][1])	
							
						}
						else
						{
							strQuickLink =  strSubCatArray[j][1] + "~" + strQuickLink ;
							strFilterMainAttributeID = strFilterMainAttributeID +"," + GetMainAttributeId(strSubCatArray[j][1])		
							
						}
					}					
				}
				
				if (strQuickLink=="")
				{
					strQuickLink =	strSubCatArray[i][1];
					strFilterMainAttributeID= "," +GetMainAttributeId(strSubCatArray[i][1]);		
				}
				else
				{
					strQuickLink =	strQuickLink + "~" + strSubCatArray[i][1] ; 
					strFilterMainAttributeID= strFilterMainAttributeID + "," + GetMainAttributeId(strSubCatArray[i][1]);		
				}				
			}
		}
		
		if (document.getElementById('hidYearFilter_ClinetID').value != '')
		{
			var objYearFilter = document.getElementById(document.getElementById('hidYearFilter_ClinetID').value);
			if (objYearFilter != null)
			{
				if (objYearFilter != '')
				{
					for(var i=0; i< objYearFilter.length;i++)
					{
						if(objYearFilter.options[i].value == Attribute_Value_id)
						{
							strQuickLink='';
							document.getElementById('hidYearAttributeID').value=Attribute_Value_id;		
							strYearMainAttributeID	=document.getElementById('hidYearMainSearchId').value;				
						}
					}			
				}		
			}
		}
		if (strQuickLink == '')
		{
			for(var i=0; i < strSubCatArray.length; i++)
			{
				if (Attribute_Value_Name == strSubCatArray[i][2])
				{
				
					for (var j=0; j < strSubCatArray.length; j++)
					{
						
						if (strSubCatArray[i][0] == strSubCatArray[j][3] )
						{
							strQuickLink =  strSubCatArray[j][1]  ;
							strFilterMainAttributeID="," +GetMainAttributeId(strSubCatArray[j][1])	
						}					
					}
					
					if (strQuickLink=="")
					{
						strQuickLink =	strSubCatArray[i][1];
						strFilterMainAttributeID = "," +GetMainAttributeId(strSubCatArray[i][1])	
					}
					else
					{
						strQuickLink =	strQuickLink + "~" + strSubCatArray[i][1] ; 
						strFilterMainAttributeID = strFilterMainAttributeID + "," + GetMainAttributeId(strSubCatArray[i][1])	
					}
						
				}
		}
		
		}
		document.getElementById('hidDyComps_Selected_Values_Name').value = Attribute_Value_Name
		document.getElementById('hidDyComps_Selected_Values_Id').value = Attribute_Value_id
	
		document.getElementById('hidFilterMainAttributeID').value=strFilterMainAttributeID
		document.getElementById('hidYearMainAttributeID').value=strYearMainAttributeID
		document.getElementById('hidDyComps_Selected_Values').value = strQuickLink;
		
		objhidSearch.value = "True";	
		window.document.forms[0].submit();		
	}
	
	
	function CheckAttributeId(AttributeValueIDs)
	{
	var returnValue
		var strMainAttributeIds=''
	    if (AttributeValueIDs.length > 0)
		{		
			var arrAttributeValueIDs = AttributeValueIDs.split(",");
			if (arrAttributeValueIDs.length >0)
			{
				for(var i=0; i < arrAttributeValueIDs.length; i++)
				{
					for(var j=0; j < strSubCatArray.length; j++)
					{	if (arrAttributeValueIDs[i]!= '')
						{	
							if (strSubCatArray[j][4] == arrAttributeValueIDs[i])
							{
								
								return true		
							}
						}
					}
				}
				return false
			}
		}	
	   
		
	}
	//Your Result
	
	function NarrowResults(AssetType)
		{	
			var objFrm = window.document.forms[0];
			if (typeof document.forms[0].hidPageNum == 'object') 
			{
				objFrm.hidPageNum.value = '1';
			}
			var strURL='';
			document.getElementById('hidDyComps_Selected_Values_Name').value = document.getElementById('Search_Values_Name').value;
			document.getElementById('hidDyComps_Selected_Values_Id').value = document.getElementById('Search_Values_Id').value;
			
		
			if(AssetType == "Video")
			{
				
					if (typeof document.forms[0].hidAssetTypeChanged == 'object' && typeof document.forms[0].hidAssetTypeSelected == 'object') 
					{
						objFrm.hidAssetTypeChanged.value = "true";	
						objFrm.hidAssetTypeSelected.value = 1
						strURL="../Asset/VideoLibrary.aspx"
					}
					else
					{
						strURL="../Asset/VideoLibrary.aspx?hidAssetTypeSelected=1&hidAssetTypeChanged=true"
					}
				
			}
			else if(AssetType == "Stills")
			{
				
					if (typeof document.forms[0].hidAssetTypeChanged == 'object' && typeof document.forms[0].hidAssetTypeSelected == 'object') 
					{
						objFrm.hidAssetTypeChanged.value = "true";
						objFrm.hidAssetTypeSelected.value = 3
						strURL="../Asset/StillsLibrary.aspx"
					}
					else
					{
						strURL="../Asset/StillsLibrary.aspx?hidAssetTypeSelected=3&hidAssetTypeChanged=true"
					}
			
			}
			else if(AssetType == "Audio")
			{
				
					if (typeof document.forms[0].hidAssetTypeChanged == 'object' && typeof document.forms[0].hidAssetTypeSelected == 'object') 
					{
						objFrm.hidAssetTypeChanged.value = "true";	
						objFrm.hidAssetTypeSelected.value = 2
						strURL="../Asset/AudioLibrary.aspx"
					}
					else
					{
						strURL="../Asset/AudioLibrary.aspx?hidAssetTypeSelected=2&hidAssetTypeChanged=true"
					}
			
			}
			else if(AssetType == "Document")
			{
				
					if (typeof document.forms[0].hidAssetTypeChanged == 'object' && typeof document.forms[0].hidAssetTypeSelected == 'object')  
					{
						objFrm.hidAssetTypeChanged.value = "true";
						objFrm.hidAssetTypeSelected.value = 4
						strURL="../Asset/DocumentsLibrary.aspx"
					}
					else
					{
						strURL="../Asset/DocumentsLibrary.aspx?hidAssetTypeSelected=2&hidAssetTypeChanged=true"
					}
				
			}
			else if(AssetType == "Stories-0")
			{
			
					strURL="../Story/MultimediaPresspacks.aspx"
				
				
			}
			else if(AssetType == "Stories-1")
			{
			
					strURL="../Story/StoryListingPremium.aspx"
				
				
			}
			
			if (strURL !='')
			{
				document.forms[0].action=strURL;
				document.forms[0].submit();
			}
			else
			{
				objFrm.submit();
			}
			
		}
	function sort_by(source,nextsource,linkval,ImgPath)
			{
				if (typeof document.forms[0].hidPageNum == 'object') 
				{
					document.forms[0].hidPageNum.value = '1';
				}
				var objhidSearch = document.getElementById('hidSearch');
				
				
				if (typeof document.forms[0].hidAssetTypeChanged == 'object') 
				{
					document.forms[0].hidAssetTypeChanged.value = "true";
				}
				document.getElementById('hidDyComps_Selected_Values_Name').value = document.getElementById('Search_Values_Name').value;
				document.getElementById('hidDyComps_Selected_Values_Id').value = document.getElementById('Search_Values_Id').value;
			
				document.getElementById('hidDyComps_Selected_Values').value = document.getElementById('hidFilterValues').value;
				document.getElementById('hidYearAttributeID').value = document.getElementById('hidYearValues').value;
				document.getElementById('hidFilterMainAttributeID').value=document.getElementById('hidFilterRifineID').value;
				document.getElementById('hidYearMainAttributeID').value=document.getElementById('hidYearRifineID').value;
			
				try
				{
					var strImagePath = source.src;
				    strImagePath = strImagePath.substring(strImagePath.lastIndexOf("/")+1);		
					if(linkval == 'relevance')
					{
										
						if(strImagePath == 'Button_Relevance-on.gif')
						{							
							
							source.src = ImgPath + "Button_Relevance-off.gif";
						}
						else
						{
							source.src = ImgPath + "Button_Relevance-on.gif";
							
						}
						document.getElementById('hidSortType').value="relevance";	
						
						objhidSearch.value = "True";
										
						window.document.forms[0].submit();
					}
					else
					{
						
						if(strImagePath == 'Button_MostRecent-on.gif')
						{
							
							source.src = ImgPath + "Button_MostRecent-off.gif";
						}
						else
						{
							
							source.src =  ImgPath + "Button_MostRecent-on.gif";
						}
						
						document.getElementById('hidSortType').value="date";	
						objhidSearch.value = "True";	
						window.document.forms[0].submit();
					}
					
					return false; 
				}
				catch(ex)
				{
				
				}
			}
			function capture_spell_check_val(spell_check_name)
					{
						try
						{
						document.getElementById('hidDyComps_Selected_Values_Name').value = document.getElementById('Search_Values_Name').value;
						document.getElementById('hidDyComps_Selected_Values_Id').value = document.getElementById('Search_Values_Id').value;
			
							document.getElementById('hidSearchText_Values').value=spell_check_name;
							document.getElementById('hidFilterMainAttributeID').value=document.getElementById('hidFilterRifineID').value;
							document.getElementById('hidYearMainAttributeID').value=document.getElementById('hidYearRifineID').value;
							window.document.forms[0].submit();
						
						}
						catch(ex)
						{
						
						}
					}
					
			function ToggleRefineResultsList(Count)
			{
				var strImgId
				
				var strDivRefineResults = "objContainerControl_objTemplateContainerControl_objRefineResults_"
				//alert(document.getElementById("divMoreAndMoreVertical_" + Count).style.display)
				if(document.getElementById("divMoreVertical_" + Count).style.display =="block")
				{
					document.getElementById("divLessVertical_" + Count).style.display = "block";
					document.getElementById("divMoreVertical_" + Count).style.display = "none";
				}
				else
				{
					document.getElementById("divLessVertical_"+Count).style.display = "none";
					document.getElementById("divMoreVertical_"+Count).style.display = "block";
				}
				
				
			}
			
			function ToggleRefineResults(imgObj,ImgPath)
			{
				var strImgId = imgObj.id;
				var strDivRefineResults = strImgId.replace( "img", "div");

				//if MINUS is clicked
				if(document.getElementById(strDivRefineResults).style.display =="block")
				{
					document.getElementById(strDivRefineResults).style.display = "none";
					imgObj.src =  ImgPath + "img_plus.gif";
				}
				else
				{
					//if PLUS is clicked
					document.getElementById(strDivRefineResults).style.display = "block";
					imgObj.src = ImgPath + "img_minus.gif";
				}
			}
			
			
			function checkSearchTextbox(id,status)
			{
				/*
				Parameter : id
					values ("TextBox id")
				
				Parameter : status 
					values ("setFocus" or "lostFocus" or "buttonClick")
				
				*/

				var objTxt=document.getElementById(id);
				if(objTxt != null)
				{
					var s = objTxt.value.replace(/^s+/,"").replace(/s+$/,"");
					if(status == "setFocus")
					{
						if(s == "<Enter Keyword(s)>" || s == "<Please enter search text>")
						{
							objTxt.value = "";	
							return false;
						}
					}
					else if(status == "lostFocus")
					{
						s = objTxt.value.replace(/\s+/g,"");
						if(s.length == 0 || s == "*" || s=="<EnterKeyword(s)>" || s=="<Pleaseentersearchtext>")
						{
							objTxt.value = "<Enter Keyword(s)>";
							return false;
						}
					}
					else if(status == "buttonClick")
					{
						//remove all the spaces from text
						s = objTxt.value.replace(/\s+/g,"");
						if(s.length == 0 || s == "*" || s=="<EnterKeyword(s)>" || s=="<Pleaseentersearchtext>")
						{
							objTxt.value = "<Please enter search text>";
							return false;
						}
					}
					return true;
				}
			}
			
			
			function previousPage()
			{
				//Changes for hybrid starts
		if (typeof document.forms[0].hidFilterMainAttributeID  == 'object' && typeof document.forms[0].hidFilterRifineID == 'object' )
		{
			
			document.getElementById('hidFilterMainAttributeID').value=document.getElementById('hidFilterRifineID').value;
		}
		if (typeof document.forms[0].hidYearMainAttributeID  == 'object' && typeof document.forms[0].hidYearRifineID == 'object' )
		{
			document.getElementById('hidYearMainAttributeID').value=document.getElementById('hidYearRifineID').value;
		}
		if (typeof document.forms[0].hidDyComps_Selected_Values_Name  == 'object' && typeof document.forms[0].Search_Values_Name == 'object' )
		{
			document.getElementById('hidDyComps_Selected_Values_Name').value = document.getElementById('Search_Values_Name').value;
		}
		if (typeof document.forms[0].hidDyComps_Selected_Values_Id  == 'object' && typeof document.forms[0].Search_Values_Id == 'object' )
		{
			document.getElementById('hidDyComps_Selected_Values_Id').value = document.getElementById('Search_Values_Id').value;
		}
		//Changes for hybrid ends
			
				window.document.forms[0].hidPageNum.value= parseInt(window.document.forms[0].hidPageNum.value,10) - 1;
				setPostBack();
				window.document.forms[0].submit();
			}

			function NextPage()
			{
				
				//Changes for hybrid starts
		if (typeof document.forms[0].hidFilterMainAttributeID  == 'object' && typeof document.forms[0].hidFilterRifineID == 'object' )
		{
			
			document.getElementById('hidFilterMainAttributeID').value=document.getElementById('hidFilterRifineID').value;
		}
		if (typeof document.forms[0].hidYearMainAttributeID  == 'object' && typeof document.forms[0].hidYearRifineID == 'object' )
		{
			document.getElementById('hidYearMainAttributeID').value=document.getElementById('hidYearRifineID').value;
		}
		if (typeof document.forms[0].hidDyComps_Selected_Values_Name  == 'object' && typeof document.forms[0].Search_Values_Name == 'object' )
		{
			document.getElementById('hidDyComps_Selected_Values_Name').value = document.getElementById('Search_Values_Name').value;
		}
		if (typeof document.forms[0].hidDyComps_Selected_Values_Id  == 'object' && typeof document.forms[0].Search_Values_Id == 'object' )
		{
			document.getElementById('hidDyComps_Selected_Values_Id').value = document.getElementById('Search_Values_Id').value;
		}
		//Changes for hybrid ends			
				window.document.forms[0].hidPageNum.value= parseInt(window.document.forms[0].hidPageNum.value,10) + 1; 
				setPostBack(); 
				window.document.forms[0].submit();
			}
			
			function showDiv(DivType,strClickFrom)
			{
				var objtextDivId = document.getElementById('textDivId');
				var objcatDivId  = document.getElementById('catDivId');
				var objbtn1DivId  = document.getElementById('btn1DivId');
				var objbtn2DivId  = document.getElementById('btn2DivId');
				//var objkeywordId  = document.getElementById('keyword');
				//var objCategoryId  = document.getElementById('Category');
				//var objAdvanceId  = document.getElementById('Advance');
				
				var objhidDyComps_IDs = document.getElementById('hidDyComps_ClientID').value; 
				
				if(objhidDyComps_IDs!='')
				{
					var arrobjhidDyComps_IDs = objhidDyComps_IDs.split("~");
				}
				
				var objhidDyFilterTable_IDs = document.getElementById('hidDyFilterTable_ClientID').value;
				if(objhidDyFilterTable_IDs !='')
				{
					
					var arrobjhidDyFilterTable_IDs = objhidDyFilterTable_IDs.split("~");
				}
				
				var objhidSearchText_ID = document.getElementById('hidSearchText_ClientID');
				var objhidDivActive = document.getElementById('hidDivActive');
				objhidDivActive.value=DivType;
				
				if (DivType=='Keywords')
				{
					objtextDivId.style.display = 'block';
					objbtn1DivId.style.display = 'block';
					objcatDivId.style.display = 'none';
					//objkeywordId.className="SearchLinkActive"
					//objCategoryId.className="SearchLink"
					//objAdvanceId.className="SearchLink"
					if(strClickFrom	== 'Link')
					{
						var tmpSelect =document.getElementById(arrobjhidDyComps_IDs[0]);
						if(tmpSelect.selectedIndex != 0)
						{
							if (typeof(tmpSelect) =='object')
							{
								tmpSelect.selectedIndex=0 
							}
							categoryComboChange(arrobjhidDyComps_IDs[0],arrobjhidDyComps_IDs[1],arrobjhidDyFilterTable_IDs[0],arrobjhidDyFilterTable_IDs[1])
						}
					}
					
				}
				else if (DivType=='Category')
				{
					objtextDivId.style.display = 'none';
					objcatDivId.style.display = 'block';
					objbtn1DivId.style.display = 'none';
					objbtn2DivId.style.display = 'block';
					//objkeywordId.className="SearchLink"
					//objCategoryId.className="SearchLinkActive"
					//objAdvanceId.className="SearchLink"
					
					if (objhidSearchText_ID.value!=	'')
					{
						document.getElementById(objhidSearchText_ID.value).value = "<Enter Keyword(s)>";
					}
					
				}
				else if(DivType=='Advance')
				{
					objtextDivId.style.display = 'block';
					objbtn1DivId.style.display = 'block';
					objbtn2DivId.style.display = 'none';
					objcatDivId.style.display = 'block';
					//objkeywordId.className="SearchLink"
					//objCategoryId.className="SearchLink"
					//objAdvanceId.className="SearchLinkActive"
					if(strClickFrom	== 'Link')
					{
						var tmpSelect =document.getElementById(arrobjhidDyComps_IDs[0]);
						if(tmpSelect.selectedIndex != 0)
						{
							if (typeof(tmpSelect) =='object')
							{
								tmpSelect.selectedIndex=0 
							}
							categoryComboChange(arrobjhidDyComps_IDs[0],arrobjhidDyComps_IDs[1],arrobjhidDyFilterTable_IDs[0],arrobjhidDyFilterTable_IDs[1])
						}
					}
					if(strClickFrom	== 'Link')
					{
					if (objhidSearchText_ID.value!=	'')
					{
						document.getElementById(objhidSearchText_ID.value).value = "<Enter Keyword(s)>";
					}
					}
					
				}
				else
				{
					objtextDivId.style.display = 'block';
					objbtn1DivId.style.display = 'block';
					objcatDivId.style.display = 'none';
					//objkeywordId.className="SearchLinkActive"
					//objCategoryId.className="SearchLink"
					//objAdvanceId.className="SearchLink"
				}
			}
/*Function added for Search ends here*/
