/*Function added for Search */
	function QuickLink(Asset_Value_Name)
	{
		if (typeof document.forms[0].hidPageNum == 'object') 
		{
			document.forms[0].hidPageNum.value = '1';
		}
		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] ; 
				}
					
			}
		}
		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
		
		//SubmitForm()	
		document.getElementById('hidDyComps_Selected_Values_Name').value = Asset_Value_Name
			
		document.getElementById('hidDyComps_Selected_Values').value = strQuickLink;
		document.getElementById('hidFilterMainAttributeID').value=strFilterMainAttributeID
		document.getElementById('hidBeatsId').value=GetBeatsID()
		document.getElementById('hidSourceId').value=GetSourceID()
		objhidSearch.value = "True";	
		window.document.forms[0].submit();		
	}

	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"
						}
						ValidateSearch()
						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"
						}
						ValidateSearch()
						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]); 
								}
							}
						}
					}
				}
			}
			
		}
		
		ValidateSearch()
	}
	
	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;							
					}		
				}
			}
		}
	}
	
	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;			
			}	
		}	
	}
	/* Comment for SubmitForm()  function 

	If you want to changed "defaultText" within <FreeKeywordSearch> tag in "Core.XML", 
	than you have to change the "strSearchText_Value" value in this function accordingly.
	*/

	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 ;			
						}
						
						strSearchFilterText = tmpSelect.options[tmpSelect.selectedIndex].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 = GetMainAttributeId(tmpSelect.options[tmpSelect.selectedIndex].value)+ strFilterMainAttributeID
						}
					}
				}
			}
		}
		
		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
		}
		
		document.getElementById('hidDyComps_Selected_Values_Name').value = GetAttributeValueName(strSearchFilterText)
		
		document.getElementById('hidDyComps_Selected_Values').value = strSearchFilters;
		document.getElementById('hidYearAttributeID').value=strYearFilter;
		document.getElementById('hidBeatsId').value=GetBeatsID()
		document.getElementById('hidSourceId').value=GetSourceID()
		//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] )
					{
						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('hidFilterMainAttributeID').value=strFilterMainAttributeID
		document.getElementById('hidYearMainAttributeID').value=strYearMainAttributeID
		document.getElementById('hidDyComps_Selected_Values').value = strQuickLink;
		document.getElementById('hidBeatsId').value=GetBeatsID()
		document.getElementById('hidSourceId').value=GetSourceID()
		
		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]!= '')
						{	//alert(strSubCatArray[j][4] + '  '+ arrAttributeValueIDs[i])
							if (strSubCatArray[j][4] == arrAttributeValueIDs[i])
							{
								//alert(1)
								return true		
							}
						}
					}
				}
				return false
			}
		}	
	   
		
	}
	
	/* Comment for NarrowResults() function
	
	Change "strURL" variable value for redirect the page URL as per BRs requirements.  
	
	*/
	function NarrowResults(AssetType)
		{	
			var objFrm = window.document.forms[0];
			if (typeof document.forms[0].hidPageNum == 'object') 
			{
				objFrm.hidPageNum.value = '1';
			}
			// Don't change the following strURL value. This is varibale declaration.
			var strURL='';
			
			if (AssetType==document.getElementById('hidFirstRifineAsset').value)
			{
				document.getElementById('hidFilterMainAttributeID').value=document.getElementById('hidFirstFilterRifineID').value
			}
			
		
			if(AssetType == "Video")
			{
				if(typeof document.forms[0].hidWhichTabSelected == 'object')
				{
					if (typeof document.forms[0].hidAssetTypeChanged == 'object' && typeof document.forms[0].hidAssetTypeSelected == 'object') 
					{
						objFrm.hidAssetTypeChanged.value = "true";	
						objFrm.hidAssetTypeSelected.value = 1
						// Can change the "strURL" variable value.
						strURL="../CommonPages/StoriesAssetsListing.aspx"
					}
					else
					{	// Can change the "strURL" variable value.
						strURL="../CommonPages/StoriesAssetsListing.aspx?hidAssetTypeSelected=1&hidAssetTypeChanged=true"
					}
				}
				else
				{
					if (typeof document.forms[0].hidAssetTypeChanged == 'object' && typeof document.forms[0].hidAssetTypeSelected == 'object') 
					{
						objFrm.hidAssetTypeChanged.value = "true";	
						objFrm.hidAssetTypeSelected.value = 1
						// Can change the "strURL" variable value.
						strURL="../Asset/AssetListing.aspx"
					}
					else
					{	// Can change the "strURL" variable value.
						strURL="../Asset/AssetListing.aspx?hidAssetTypeSelected=1&hidAssetTypeChanged=true"
					}
				}
			}
			else if(AssetType == "Stills")
			{
				if(typeof document.forms[0].hidWhichTabSelected == 'object')
				{
					if (typeof document.forms[0].hidAssetTypeChanged == 'object' && typeof document.forms[0].hidAssetTypeSelected == 'object') 
					{
						objFrm.hidAssetTypeChanged.value = "true";
						objFrm.hidAssetTypeSelected.value = 3
						// Can change the "strURL" variable value.
						strURL="../CommonPages/StoriesAssetsListing.aspx"
					}
					else
					{	// Can change the "strURL" variable value.
						strURL="../CommonPages/StoriesAssetsListing.aspx?hidAssetTypeSelected=3&hidAssetTypeChanged=true"
					}
				}
				else
				{
					if (typeof document.forms[0].hidAssetTypeChanged == 'object' && typeof document.forms[0].hidAssetTypeSelected == 'object') 
					{
						objFrm.hidAssetTypeChanged.value = "true";
						objFrm.hidAssetTypeSelected.value = 3
						// Can change the "strURL" variable value.
						strURL="../Asset/AssetListing.aspx"
					}
					else
					{	// Can change the "strURL" variable value.
						strURL="../Asset/AssetListing.aspx?hidAssetTypeSelected=3&hidAssetTypeChanged=true"
					}
				}
			}
			else if(AssetType == "Audio")
			{
				if(typeof document.forms[0].hidWhichTabSelected == 'object')
				{
					if (typeof document.forms[0].hidAssetTypeChanged == 'object' && typeof document.forms[0].hidAssetTypeSelected == 'object') 
					{
						objFrm.hidAssetTypeChanged.value = "true";	
						objFrm.hidAssetTypeSelected.value = 2
						// Can change the "strURL" variable value.
						strURL="../CommonPages/StoriesAssetsListing.aspx"
					}
					else
					{	// Can change the "strURL" variable value.
						strURL="../CommonPages/StoriesAssetsListing.aspx?hidAssetTypeSelected=2&hidAssetTypeChanged=true"
					}
				}
				else
				{
					if (typeof document.forms[0].hidAssetTypeChanged == 'object' && typeof document.forms[0].hidAssetTypeSelected == 'object') 
					{
						objFrm.hidAssetTypeChanged.value = "true";	
						objFrm.hidAssetTypeSelected.value = 2
						// Can change the "strURL" variable value.
						strURL="../Asset/AssetListing.aspx"
					}
					else
					{	// Can change the "strURL" variable value.
						strURL="../Asset/AssetListing.aspx?hidAssetTypeSelected=2&hidAssetTypeChanged=true"
					}
				}
			}
			else if(AssetType == "Document")
			{
				if(typeof document.forms[0].hidWhichTabSelected == 'object')
				{
					if (typeof document.forms[0].hidAssetTypeChanged == 'object' && typeof document.forms[0].hidAssetTypeSelected == 'object')  
					{
						objFrm.hidAssetTypeChanged.value = "true";
						objFrm.hidAssetTypeSelected.value = 4
						// Can change the "strURL" variable value.
						strURL="../CommonPages/StoriesAssetsListing.aspx"
					}
					else
					{	// Can change the "strURL" variable value.
						strURL="../CommonPages/StoriesAssetsListing.aspx?hidAssetTypeSelected=4&hidAssetTypeChanged=true"
					}
				}
				else
				{
					if (typeof document.forms[0].hidAssetTypeChanged == 'object' && typeof document.forms[0].hidAssetTypeSelected == 'object')  
					{
						objFrm.hidAssetTypeChanged.value = "true";
						objFrm.hidAssetTypeSelected.value = 4
						// Can change the "strURL" variable value.
						strURL="../Asset/AssetListing.aspx"
					}
					else
					{	// Can change the "strURL" variable value.
						strURL="../Asset/AssetListing.aspx?hidAssetTypeSelected=4&hidAssetTypeChanged=true"
					}
				}
			}
			else if(AssetType == "Stories")
			{
			if(typeof document.forms[0].hidWhichTabSelected == 'object')
				{
					objFrm.hidWhichTabSelected.value='Stories'
					// Can change the "strURL" variable value.
					strURL="../CommonPages/StoriesAssetsListing.aspx"
				}
				else
				{	// Can change the "strURL" variable value.
					strURL="../Story/StoryListing.aspx"
				}
				
			}
			//alert(document.getElementById('hidFilterMainAttributeID').value)
			if (strURL !='')
			{
				document.forms[0].action=strURL;
				document.forms[0].submit();
			}
			else
			{
				objFrm.submit();
			}
			
		}
	function sort_by(source,nextsource,linkval,ImgPath)
			{//debugger
				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;
				document.getElementById('hidBeatsId').value=GetBeatsID()
				document.getElementById('hidSourceId').value=GetSourceID()
			
				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('hidSearchText_Values').value=spell_check_name;
							document.getElementById('hidFilterMainAttributeID').value=document.getElementById('hidFilterRifineID').value;
							document.getElementById('hidYearMainAttributeID').value=document.getElementById('hidYearRifineID').value;
							document.getElementById('hidBeatsId').value=GetBeatsID()
							document.getElementById('hidSourceId').value=GetSourceID()
							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";
				}
			}
			
			
			/* Comment for checkSearchTextbox() function 

			If you want to changed "defaultText" within <FreeKeywordSearch> tag in "Core.XML", 
			than you have to change the "s" value in this function accordingly.
			Parameter : id
				values ("TextBox id")
			
			Parameter : status 
				values ("setFocus" or "lostFocus" or "buttonClick")
			*/
			function checkSearchTextbox(id,status)
			{
				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()
			{
				document.getElementById('hidFilterMainAttributeID').value=document.getElementById('hidFilterRifineID').value;
				document.getElementById('hidYearMainAttributeID').value=document.getElementById('hidYearRifineID').value;
				document.getElementById('hidBeatsId').value=GetBeatsID()
				document.getElementById('hidSourceId').value=GetSourceID()
				window.document.forms[0].hidPageNum.value= parseInt(window.document.forms[0].hidPageNum.value,10) - 1;
				setPostBack();
				window.document.forms[0].submit();
			}

			function NextPage()
			{
				document.getElementById('hidFilterMainAttributeID').value=document.getElementById('hidFilterRifineID').value;
				document.getElementById('hidYearMainAttributeID').value=document.getElementById('hidYearRifineID').value;				
				document.getElementById('hidBeatsId').value=GetBeatsID()
				document.getElementById('hidSourceId').value=GetSourceID()
				window.document.forms[0].hidPageNum.value= parseInt(window.document.forms[0].hidPageNum.value,10) + 1; 
				setPostBack(); 
				window.document.forms[0].submit();
			}
			
			function GetBeatsID()
			{
				var strBeatsId=""
				//var strBeatsId=18  //For testing changes value 8,18,33 for adidas
				//Write your code here for fatch beats id from dropdown
				return strBeatsId
			}
			
			function GetSourceID()
			{
				var strSourceId=""
				//var strSourceId="1203" //for testing
				//Write your code here for fatch source id from dropdown
				return strSourceId
			}
/*Function added for Search ends here*/