﻿//Start of Template5PPWA.js

// JScript File

var dragapproved = false;

function updatecookiepgIds(rep)
{
    var hdnDiaCmprIdsobj = document.getElementById("ctl00_ContentPlaceHolder1_Template5Search1_hdnDiaCmprIds");
    hdnDiaCmprIdsobj.value =rep;
     RetainCompareChecks('NUP');
    //alert(rep);
}
function retainremovedIDs(id)
{
    var hdnDiaCmprIdsobj = document.getElementById("ctl00_ContentPlaceHolder1_Template5Search1_hdnDiaCmprIds");
    var hdnfrom = document.getElementById("ctl00_ContentPlaceHolder1_Template5Search1_hdnfrom");
    var frm = document.forms["aspnetForm"];
    var from='NUP';       
    var arrhdnDiaCmprIdsobj=hdnDiaCmprIdsobj.value.split(',');
    //alert(arrhdnDiaCmprIdsobj.length);
    if(arrhdnDiaCmprIdsobj.length>1)
    {
            var dialids;
            dialids="";
            if(from=='NUP')        
                chkcollection = frm.elements["chkNUP"];
            if(chkcollection)
            {
                hdnDiaCmprIds = hdnDiaCmprIdsobj.value;
                arrDiaID = hdnDiaCmprIds.split(",");
                for(var i=0; i < chkcollection.length; i++)
                {
                   if(id == chkcollection[i].value)
                   {
                       chkcollection[i].checked = false;                 
                   }                   
                }                
                for(var j=0;j< arrhdnDiaCmprIdsobj.length;j++)
                {   
                    if(id== arrhdnDiaCmprIdsobj[j])
                    {                    }
                    else
                    { dialids+= arrhdnDiaCmprIdsobj[j]+",";   }
                }   
                dialids=dialids.substring(0,dialids.length-1);
                hdnDiaCmprIdsobj.value =dialids;   
                createCookie(hdnDiaCmprIdsobj.value);          
            }                   
     }
}
function CollectCompareIds(from,ID)
{   
    var diaidlist="";
    var arrDiaID = new Array();
    var arrDiaID1 = new Array();
    var flag = false;
    var hdnDiaCmprIdsobj = document.getElementById("ctl00_ContentPlaceHolder1_Template5Search1_hdnDiaCmprIds");
    var hdnDiaCmprIds = hdnDiaCmprIdsobj.value;
        
    var hdnfrom = document.getElementById("ctl00_Bottomnav_include1_hdnfrom");
    var frm = document.forms["aspnetForm"];
        if(from=='REC')        
            chkcollection = frm.elements["chk"];        
        if(from=='NUP')        
            chkcollection = frm.elements["chkNUP"];
        if(hdnfrom!=null)
                hdnfrom.value = from;
        if(chkcollection)
        {
              //Changes for comparison across pages
              hdnDiaCmprIds = hdnDiaCmprIdsobj.value;
              var remstr1 = "";
              var remstr2 = "";
              var remstr3 = "";
              var remstr4 = "";  
              var repl = "";
              var tworepl = "";
              
              for (var i=0; i < chkcollection.length; i++)
              {   
                  if (chkcollection[i].checked)
                  {     
                        if(i==chkcollection.length)
                        {
                            if(hdnDiaCmprIds.indexOf(chkcollection[i].value)==-1)
                                hdnDiaCmprIds += chkcollection[i].value + ",";
                        }
                        else
                        {   
                            var ndx = hdnDiaCmprIds.search(/,/);
                            if(ndx==-1)
                            {
                                if(hdnDiaCmprIds.indexOf(chkcollection[i].value)==-1)
                                    hdnDiaCmprIds += "," + chkcollection[i].value + ",";                            
                            }
                            else
                            {
                                if(hdnDiaCmprIds.indexOf(chkcollection[i].value)==-1)
                                    hdnDiaCmprIds += "," + chkcollection[i].value + ",";
                            }
                        }
                        flag = true;
                  }
                  if(chkcollection[i].checked==false)
                  { 
                    remstr4 = chkcollection[i].value;
                    if(hdnDiaCmprIds!="")
                    {
                        hdnDiaCmprIds = hdnDiaCmprIds.replaceAll(remstr4,',');
                    }
                  }
              }
              arrDiaID = hdnDiaCmprIds.split(",");              
              for(var k=0;k<arrDiaID.length;k++)
              {
                if(arrDiaID[k]!=null && arrDiaID[k]!="")
                    arrDiaID1[k] = arrDiaID[k];
              }
              arrDiaID = null;
              arrDiaID = arrDiaID1;
              for(var j=0;j<arrDiaID.length;j++)
              {
                if(j==arrDiaID.length-1)
                {
                    if(arrDiaID[j]!=null && arrDiaID[j]!="")
                        diaidlist += arrDiaID[j];
                }
                else
                {
                    if(arrDiaID[j]!=null)
                    {
                        if(arrDiaID[j]!="")
                            diaidlist += arrDiaID[j] + ",";
                    }
                }
              }
                hdnDiaCmprIdsobj.value =  diaidlist;
                createCookie(hdnDiaCmprIdsobj.value);
               // include_bottomnavintpg.GetDiamondCompareID(diaidlist,maintaincompareids);
        }
}
String.prototype.replaceAll=function(s1, s2) {return this.split(s1).join(s2)}

function SetCompareParameter(from)
{      
    var diaidlist="";
    var arrDiaID = new Array();
    var flag = false;
    var hdnDiaCmprIds = "";
    var hdnDiaCmprIdsobj = document.getElementById("ctl00_ContentPlaceHolder1_Template5Search1_hdnDiaCmprIds");

                if(hdnDiaCmprIdsobj.value!="")
                {
                    diaidlist = hdnDiaCmprIdsobj.value;
                    Templates_uc_Template5SearchPPWA.setCompareDiaIds(diaidlist);
                    flag = true;
                }

              if(flag==false || diaidlist=="")
              {
                alert("Please select diamonds to compare.");
                return;
              }
              
          include_bottomnavintpg.GetDiamondComparisonDatac(from,callbackremovecompare);
}

function RetainCompareChecks(from1)
{

    var from = "";
    var arrDiaID = new Array();
    var hdnDiaCmprIds = "";
    var hdnDiaCmprIdsobj = document.getElementById("ctl00_ContentPlaceHolder1_Template5Search1_hdnDiaCmprIds");
    var hdnfrom = document.getElementById("ctl00_ContentPlaceHolder1_Template5Search1_hdnfrom");
    var frm = document.forms["aspnetForm"];
    if(hdnfrom!=null)
        from = hdnfrom.value;  
        
    from = from1;      
    if(frm)
    {
        try
        {
            if(from=='REC')        
                chkcollection = frm.elements["chk"];        
            if(from=='NUP')        
                chkcollection = frm.elements["chkNUP"];
            if(chkcollection)
            {
                hdnDiaCmprIds = hdnDiaCmprIdsobj.value;
                arrDiaID = hdnDiaCmprIds.split(",");
                for(var j=0;j<arrDiaID.length;j++)
                {
                    for(var i=0; i < chkcollection.length; i++)
                    {
                        if(arrDiaID[j] == chkcollection[i].value)
                        {
                            chkcollection[i].checked = true;
                        }
                    }
                }
            }
        }
        catch(e)
        {
        alert(e.value);
        }
    }
}
  function SethdnP(page)
    {//debugger
        document.getElementById("ctl00_ContentPlaceHolder1_Template5Search1_hdnpageno").value = page;
        sortfilter();
    }
    function SethdnM(metalval)
    {//debugger
        document.getElementById("ctl00_ContentPlaceHolder1_Template5Search1_hdnmetal").value = metalval;
        sortfilter();
    }
    function SethdnS(shapeval)
    {
        document.getElementById("ctl00_ContentPlaceHolder1_Template5Search1_hdnshape").value = shapeval;
        sortfilter();
    }
    function SethdnSo()
    {
        var Index3 = document.getElementById("ctl00_ContentPlaceHolder1_Template5Search1_drpsort").selectedIndex;
        var strSort = document.getElementById("ctl00_ContentPlaceHolder1_Template5Search1_drpsort").options[Index3].value;
        document.getElementById("ctl00_ContentPlaceHolder1_Template5Search1_hdnsort").value = strSort;
        sortfilter();
    }
    function sortfilter()
    {   
        var pageval = document.getElementById("ctl00_ContentPlaceHolder1_Template5Search1_hdnpageno").value;
        var shapeval = document.getElementById("ctl00_ContentPlaceHolder1_Template5Search1_hdnshape").value;
        var metalval = document.getElementById("ctl00_ContentPlaceHolder1_Template5Search1_hdnmetal").value;
        var sortval = document.getElementById("ctl00_ContentPlaceHolder1_Template5Search1_hdnsort").value;       
//        var catid="<%=catid%>";
//        var template="<%=template%>";         
//       urlpath = "<%=strPath%>templates/template5PPWA.aspx";   
        // window.location=urlpath+catid+"/"+shapeval+"/"+metalval+"/"+sortval+"/"+pageval+"/";
        //window.location=urlpath+"?cat_id="+catid+"&template="+template+"&shape="+shapeval+"&metal="+metalval+"&sort="+sortval+"&page="+pageval;
        
	var urlpath11 = window.location.href;        
        path=urlpath11.split("/");
        urlpath11=urlpath+path[3]+"/";
	//alert(catid);
        window.location=urlpath11+catid+"/"+shapeval+"/"+metalval+"/"+sortval+"/"+pageval+"/";
   

 } 

//	function pricefillOnload() //this function called in cs file.
//    {
//    var tempSearchCatId ='<%=SearchQueryCatid%>';    
//    if(tempSearchCatId !="")
//        {            
//            Templates_uc_Template5SearchPPWA.fillprice(tempSearchCatId,callpricefillOnload) //calling ajax function for filling price dropdown according to product selected            
//        }
//    }	
//  
    function callpricefillOnload(response)//this function used for getting response from ajax based fillprice function.
    {
        frm=document.form1;
        var dataset=response.value;
        if(dataset==null || dataset==0)
             {
                 document.getElementById("Template5Search1_DDPrice").options[0] = new Option("Any Price","notset");
                 document.getElementById("Template5Search1_DDPrice").options[1] = new Option("$100 & Under","0,100");
                 document.getElementById("Template5Search1_DDPrice").options[2] = new Option("$250-$500","250,500");
                 document.getElementById("Template5Search1_DDPrice").options[3] = new Option("$500-$1000","500,1000");
                 document.getElementById("Template5Search1_DDPrice").options[4] = new Option("$1000-$2500","1000,2500");
                 document.getElementById("Template5Search1_DDPrice").options[5] = new Option("$2500-$5000","2500,5000");
                 document.getElementById("Template5Search1_DDPrice").options[6] = new Option("$5000 & Above","5000,");
             }
        else
             {
                 var totalRecord=dataset.Tables[0].Rows.length;
                 if(totalRecord<=0)
                    {
                    frm.Template5Search1_DDPrice.options[0] = new Option("Any Price","notset");
                    frm.Template5Search1_DDPrice.options[1] = new Option("$100 & Under","0,100");
                    frm.Template5Search1_DDPrice.options[2] = new Option("$250-$500","250,500");
                    frm.Template5Search1_DDPrice.options[3] = new Option("$500-$1000","500,1000");
                    frm.Template5Search1_DDPrice.options[4] = new Option("$1000-$2500","1000,2500");
                    frm.Template5Search1_DDPrice.options[5] = new Option("$2500-$5000","2500,5000");
                    frm.Template5Search1_DDPrice.options[6] = new Option("$5000 & Above","5000,");
                    }
                 else
                    {
                        while (frm.Template5Search1_DDPrice.options.length>0) //clear the previous value of price dropdown
				          {
	  				        frm.Template5Search1_DDPrice.options[frm.Template5Search1_DDPrice.options.length-1]=null;
				          }
                          for(var i=0;i<totalRecord;i++) //filling price drop down with new values based on product selected.
                            {
                                 var string = ""
                                 var valueString=""; 
                                 if(dataset.Tables[0].Rows[i].Price_From ==0)
                                  {
                                    string +="$"+ dataset.Tables[0].Rows[i].Price_To;
                                    string +=" & Under"; 
                                    valueString=dataset.Tables[0].Rows[i].Price_From + "," + dataset.Tables[0].Rows[i].Price_To;
                                  }
                                 else
                                  {
                                    string ="$"+dataset.Tables[0].Rows[i].Price_From;
                                    valueString=dataset.Tables[0].Rows[i].Price_From;
                                    if(dataset.Tables[0].Rows[i].Price_To !=null)
                                        {
                                            string +="-$"+ dataset.Tables[0].Rows[i].Price_To;
                                            valueString += ","+dataset.Tables[0].Rows[i].Price_To;
                                        }
                                    else
                                        {
                                            string +="& Above";
                                        }
                                  }
                                if(i==0)
                                    {
                                        document.getElementById("Template5Search1_DDPrice").options[0] = new Option("Any Price","notset");
                                    }
                                else
                                    {
                                        document.getElementById("Template5Search1_DDPrice").options[i] = new Option(string,valueString);
                                    }
                          
                            } 
                     }
             }
             for( var i=0; i<document.getElementById("Template5Search1_DDPrice").options.length; i++)
                {
                    
                    if(document.getElementById("Template5Search1_DDPrice").options[i].value ==document.getElementById("Template5Search1_HPrice").value)
                    {
                        document.getElementById("Template5Search1_DDPrice").selectedIndex=i;
                        break;
                    }
                }
    }  

	
        function callbackquery(resquery)
        {
        //debugger
            var pagesel = document.getElementById("hdnpagesel").value;
            document.getElementById("Template5Search1_show_items").value = resquery.value;
            setTimeout("getdatadisplayItem('"+pagesel+"')", 2000);
        }
        
        function SearchMetal1(metal,from,to)
        {
                                   
            var pagesel = document.getElementById("hdnpagesel").value;            
            var Index1 = document.getElementById("Template5Search1_drpgemstone").selectedIndex;
            var strGemstone = document.getElementById("Template5Search1_drpgemstone").options[Index1].value;
            if(strGemstone == "select")
            {
                strGemstone = "";
            }
            
            var Index2 = document.getElementById("Template5Search1_drpcolor").selectedIndex;
            var strColor = document.getElementById("Template5Search1_drpcolor").options[Index2].value;
            if(strColor == "select")
            {
                strColor = "";
            }
            
            var Index3 = document.getElementById("Template5Search1_drpsort").selectedIndex;
            var strSort = document.getElementById("Template5Search1_drpsort").options[Index3].value;
            var order_by = "asc"; 
            if(strSort == "select")
            {
              order_by = "asc";
            }
            else if(strSort == "LTH")
            {
                order_by = "asc";
            }
            else if(strSort == "HTL")
            {
                order_by = "desc";
            }
            else if(strSort == "PP")
            {
              order_by = "";
            }                
             
            if(from == "" && to == "")
            {
                document.getElementById("Template5Search1_show_items").value = "select distinct H.Item_ID, H.Item_name,H.Item_Price, H.Template_ID, H.Item_Image, isnull(IC.[order],'99') as Priority, H.IsRecommended, H.Item_Seo_link, H.NumberDays from Hitsview as H left outer join ItemAttribute_Gem_View as iagv on H.Item_id=iagv.Item_id left outer join ItemAttribute_Color_View as iacv on H.Item_id=iacv.Item_id LEFT OUTER JOIN ItemOrderbycatg as IC ON H.Item_id = IC.Item_Id and IC.Cat_ID = "+'<%=catid%>'+" where H.Cat_id = "+'<%=catid%>'+" and H.Item_Price >= 0 and (iacv.item_id is null or iacv.Item_Attribute_Value like '%" + strColor + "%')and (iagv.item_id is null or iagv.Item_Attribute_Value like '%" + strGemstone + "%')order by H.Item_Price "+ order_by;
                setTimeout("getdatadisplayItem('"+pagesel+"')", 2000);
            }
            else if(from != "" && to == "")
            {
             document.getElementById("Template5Search1_show_items").value = "select distinct H.Item_ID, H.Item_name,H.Item_Price, H.Template_ID, H.Item_Image, isnull(IC.[order],'99') as Priority, H.IsRecommended, H.Item_Seo_link, H.NumberDays from Hitsview as H left outer join ItemAttribute_Gem_View as iagv on H.Item_id=iagv.Item_id left outer join ItemAttribute_Color_View as iacv on H.Item_id=iacv.Item_id LEFT OUTER JOIN ItemOrderbycatg as IC ON H.Item_id = IC.Item_Id and IC.Cat_ID = "+'<%=catid%>'+" where H.Cat_id = "+'<%=catid%>'+" and H.Item_Price >= " + from + " and (iacv.item_id is null or iacv.Item_Attribute_Value like '%" + strColor + "%')and (iagv.item_id is null or iagv.Item_Attribute_Value like '%" + strGemstone + "%')order by H.Item_Price "+ order_by;
             setTimeout("getdatadisplayItem('"+pagesel+"')", 2000);                
            }
            else
            {
             document.getElementById("Template5Search1_show_items").value = "select distinct H.Item_ID, H.Item_name,H.Item_Price, H.Template_ID, H.Item_Image, isnull(IC.[order],'99') as Priority, H.IsRecommended, H.Item_Seo_link, H.NumberDays from Hitsview as H left outer join ItemAttribute_Gem_View as iagv on H.Item_id=iagv.Item_id left outer join ItemAttribute_Color_View as iacv on H.Item_id=iacv.Item_id LEFT OUTER JOIN ItemOrderbycatg as IC ON H.Item_id = IC.Item_Id and IC.Cat_ID = "+'<%=catid%>'+" where H.Cat_id = "+'<%=catid%>'+" and (H.Item_Price >= " + from + " and H.Item_Price <= " + to + ") and (iacv.item_id is null or iacv.Item_Attribute_Value like '%" + strColor + "%')and (iagv.item_id is null or iagv.Item_Attribute_Value like '%" + strGemstone + "%')order by H.Item_Price "+ order_by;
             setTimeout("getdatadisplayItem('"+pagesel+"')", 2000);
            }
        }

function GetSearchCriteria()
{
    
        strQurey = document.getElementById("Template5Search1_show_items").value;
        Templates_uc_SearchResultPPWA.GetTotalRecords(strQurey,GetSearchCallBack);
        setfocus();
}

function GetSearchCallBack(response)
{ var Ser_Price,Ser_Material,Ser_Prod,Ser_Metal;
    try
    {
         var w = document.getElementById("Template5Search1_DDProduct").selectedIndex;
         Ser_Prod = document.getElementById("Template5Search1_DDProduct").options[w].text;

    }catch(err){Ser_Prod="";}
    try
    {
        var w = document.getElementById("Template5Search1_DDMaterial").selectedIndex;
         Ser_Material = document.getElementById("Template5Search1_DDMaterial").options[w].text;

    }catch(err){Ser_Material=""; }
    try
    {
        var w = document.getElementById("Template5Search1_DDMetal").selectedIndex;
         Ser_Metal = document.getElementById("Template5Search1_DDMetal").options[w].text;

    }catch(err){ Ser_Metal=""; }
    try
    {
        var w = document.getElementById("Template5Search1_DDPrice").selectedIndex;
         Ser_Price = document.getElementById("Template5Search1_DDPrice").options[w].text;

    }catch(err){ Ser_Price=""; }    
    try
    {
    //document.getElementById("TotalSearchRecords").innerHTML="There Are Total "+response.value + " " + Ser_Prod + Ser_Material + Ser_Metal +" Items Matching "+Ser_Price +" Your Search Criteria." ;
    }catch(err){}
    
}
    function color_change(colorvalue)
    {
        if(colorvalue == "select")
        {
            
        }
        else
        {
            document.getElementById("Template5Search1_show_items").value = "select ia.item_attribute_value,Item.Item_ID, Item.Item_name,Item.Item_Desc, Item.Item_Price, Item.Template_ID, Item.Item_Image from Item Item left outer join Item_attribute ia on Item.Item_id=ia.Item_id where Item.isActive = 'T' and Item.Item_ID in (select Item_ID from Item_ParentCategory  where Cat_ID = "+'<%=catid%>'+") and item_attribute_value like '%"+colorvalue+"%'";
            setTimeout("getdatadisplayItem('1')", 2000);
        }
    }
    function gemstone_change(gemstonevalue)
    {   
        if(gemstonevalue == "select")
        {
            
        }
        else
        {
            document.getElementById("Template5Search1_show_items").value = "select ia.item_attribute_value,Item.Item_ID, Item.Item_name,Item.Item_Desc, Item.Item_Price, Item.Template_ID, Item.Item_Image from Item Item left outer join Item_attribute ia on Item.Item_id=ia.Item_id where Item.isActive = 'T' and Item.Item_ID in (select Item_ID from Item_ParentCategory  where Cat_ID = "+'<%=catid%>'+") and item_attribute_value like '%"+gemstonevalue+"%'";
            setTimeout("getdatadisplayItem('1')", 2000);
        }
    }

    function pricerange_change(value)        
    {       

          if(value == 'select')
          {
          
          }  
          if(value=='LTH')
          {
          document.getElementById("Template5Search1_show_items").value = "select Item.Item_ID, Item.Item_name,Item.Item_Desc, Item.Item_Price, Item.Template_ID, Item.Item_Image from Item where Item.isActive = 'T' and Item_ID in (select Item_ID from Item_ParentCategory  where Cat_ID ="+'<%=catid%>'+") order by Item_Price asc";
          setTimeout("getdatadisplayItem('1')", 2000);
          Templates_uc_SearchResultPPWA.DefaultedPrice('<%=catid %>',resp_price);
          }
          else if(value=='HTL')
          {
          document.getElementById("Template5Search1_show_items").value = "select Item.Item_ID, Item.Item_name,Item.Item_Desc, Item.Item_Price, Item.Template_ID, Item.Item_Image from Item where Item.isActive = 'T' and Item_ID in (select Item_ID from Item_ParentCategory  where Cat_ID ="+'<%=catid%>'+") order by Item_Price desc";
          setTimeout("getdatadisplayItem('1')", 2000);
          Templates_uc_SearchResultPPWA.DefaultedPrice('<%=catid %>',resp_price);
          }
          else if(value == 'PP')
          {
          document.getElementById("Template5Search1_show_items").value = "select distinct H.Item_ID,H.Item_Desc, H.Item_name, H.Item_Price, H.Template_ID, H.Item_Image, isnull(IC.[order],'99') as Priority, H.IsRecommended, H.Item_Seo_link, H.NumberDays from Hitsview as H LEFT OUTER JOIN ItemOrderbycatg as IC ON H.Item_id = IC.Item_Id and IC.Cat_ID = 107 where H.Cat_id =107 order by H.NumberDays desc,priority asc";
          setTimeout("getdatadisplayItem('1')", 2000);
          Templates_uc_SearchResultPPWA.DefaultedPrice('<%=catid %>',resp_price);
          }
        
    }
        function resp_price(resprice)
        {           
            //document.getElementById("LblDefaultPrice").style.visibility = 'visible';
            if(resprice.value != "")
            {
                
                document.getElementById("Template5Search1_LblDefaultPrice").style.visibility = "visible";            
                document.getElementById("Template5Search1_LblDefaultPrice").style.display = "block";
                var spanprice = document.getElementById("Template5Search1_LblDefaultPrice");
                spanprice.innerHTML = resprice.value;
                
            }
        }
        
         
    function getPagging1(res1)
    {
        document.getElementById("Searchres").innerHTML = res1.value;
        getSession();
        strQurey=document.getElementById("Template5Search1_show_items").value;
        Templates_uc_SearchResultPPWA.GetPaging(RecordNumber,strQurey,SetPagging);
        document.getElementById("DisplayLoading").style.visibility="hidden";
        document.getElementById("DisplayLoading").style.display="none";
        
    }
    function setajaxres()
    {
    
    //alert('hello');
    var frm=document.form1; 
    var a=document.getElementById("Template5Search1_HSearchval");
    var a1=document.getElementById("Template5Search1_HCat_ID");
    var a2=document.getElementById("Template5Search1_HPrice");
    var a3=document.getElementById("Template5Search1_HPrice");
    var a4=document.getElementById("Template5Search1_HMat");
    var a5=document.getElementById("Template5Search1_HMetal");
    var a6=document.getElementById("Template5Search1_HMCat_ID");
     
   
    if(a!=null){ var Searchval=a.value;}
    if(a1!=null){var Cat_ID=a1.value;}
    if(a2!=null){var PriceRange=a2.value;}
    if(a3!=null){var PriceRangequery=a3.value;}
    if(a4!=null){var Mat=a4.value;}
    if(a5!=null){var Metal=a5.value;}
    if(a6!=null){var MCat_ID=a6.value;}
    var prodsel="0";
    var matsal="";
    
    
    
   var chkSearchButton='<%=CheckSearchButton%>';   
   if(chkSearchButton=="True" || chkSearchButton=="true")
   {
        document.getElementById("btnTemplate5Search").style.visibility="visible";
   }
   else
   {
        document.getElementById("btnTemplate5Search").style.visibility="hidden";
   }
    if(Searchval=="notset")
        {
            var PriceRange="notset";          
        }
    else
        {   
            if(PriceRange=="notinquery")
             {
                var PriceRange="notset";
             }
           else 
            {
                 var PrieRange=frm.Template5Search1_DDPrice.options[frm.Template5Search1_DDPrice.selectedIndex].value;
            }     
             
        }         

    if(Searchval=="M")
       {
            var MaterialSelected=frm.Template5Search1_DDMaterial.options[frm.Template5Search1_DDMaterial.selectedIndex].value;
       }
    else
       {
           var MaterialSelected="notset";
       }
    if(Searchval=="P")
        {
            var ProductSelected=frm.Template5Search1_DDProduct.options[frm.Template5Search1_DDProduct.selectedIndex].value;
        }
       else 
        {
            var ProductSelected="notset";
        }
   //if(Metal=="notset")
   //     {
             var MetalSelected="notset";
    //    }
    //    else
    //    {
    //         var MetalSelected=frm.Template5Search1_DDMetal.options[frm.Template5Search1_DDMetal.selectedIndex].value;
    //    }
    if(Cat_ID != "notset")
        {
            if (ProductSelected == "notset")
            {
                prodsel = Cat_ID;
            }
            else
            {
                prodsel = ProductSelected;
            }
        }
        else
        {
            if (ProductSelected != "notset")
            {
                prodsel = ProductSelected;
            }            
        }
   
   if (Mat != "notset") //searchvalue==M
        {
            matsal = Mat;
            if (MaterialSelected != "notset")
            {
                matsal = MaterialSelected;
            }
        } 
    else
      {
            if (MaterialSelected != "notset")
                {
                    matsal = MaterialSelected;
                }
      }
      try
      {     
        for( var i=0; i<document.getElementById("Template5Search1_DDMaterial").options.length; i++)
            {            
                if(document.getElementById("Template5Search1_DDMaterial").options[i].value ==document.getElementById("Template5Search1_HMat").value)
                {
                    document.getElementById("Template5Search1_DDMaterial").selectedIndex=i;
                    break;
                }
            }
        }
        catch(err){}
        
//alert("Searchval="+Searchval+"cat_id="+Cat_ID+"prrange="+PriceRange+"mat="+Mat+"MCat_ID="+MCat_ID+"Metal="+Metal+"materialselected="+MaterialSelected+"productselet="+ProductSelected+"metalselected="+MetalSelected+"prodsel"+prodsel+"matsal"+matsal);
Templates_uc_Template5SearchPPWA.getitemset(Searchval,Cat_ID,PriceRange,MetalSelected,prodsel,matsal,callgetitemset) //calling ajax function getitemset.
    }
    

 

    function OnSearchClick()
    { 
       
    var frm1=document.form1;  
    var Searchval1=frm1.Template5Search1_HSearchval.value;
    var Cat_ID1=frm1.Template5Search1_HCat_ID.value;
    var PriceRange=frm1.Template5Search1_HPrice.value;
    var PriceRangequery=frm1.Template5Search1_HPrice.value;
    var Mat=frm1.Template5Search1_HMat.value;
    var Metal=frm1.Template5Search1_HMetal.value;
    var MCat_ID1=frm1.Template5Search1_HMCat_ID.value;
    var prodsel="0";
    var matsal="";
   document.getElementById("DisplayLoading").style.visibility="visible";
    if(Searchval1=="notset")
        {
            var PriceRange="notset";          
        }
    else
        {
            var PriceRange=frm1.Template5Search1_DDPrice.options[frm1.Template5Search1_DDPrice.selectedIndex].value;
        }
    if(Searchval1=="M")
       {
            var MaterialSelected=frm1.Template5Search1_DDMaterial.options[frm1.Template5Search1_DDMaterial.selectedIndex].value;
       }
    else
       {
           var MaterialSelected="notset";
       }
    if(Searchval1=="P")
        {
            var ProductSelected=frm1.Template5Search1_DDProduct.options[frm1.Template5Search1_DDProduct.selectedIndex].value;
        }
       else 
        {
            var ProductSelected="notset";
        }
   //if(Metal=="notset")
   //     {
             var MetalSelected="notset";
   //     }
        //else
        //{
        //     var MetalSelected=frm1.Template5Search1_DDMetal.options[frm1.Template5Search1_DDMetal.selectedIndex].value;
        //}
    if(Cat_ID1 != "notset")
        {
            if (ProductSelected == "notset")
            {
                prodsel = Cat_ID1;
            }
            else
            {
                prodsel = ProductSelected;
            }
        }
        else
        {
            if (ProductSelected != "notset")
            {
                prodsel = ProductSelected;
            }            
        }
   
   if (Mat != "notset") //searchvalue==M
        {
       // alert("MaterialSelected="+MaterialSelected);
       //     matsal = Mat;
      //      alert("matsal="+matsal);
            if (MaterialSelected != "notset")
            {
                matsal = MaterialSelected;
            }
        } 
    else
      {
        // alert("else --MaterialSelected="+MaterialSelected);
            if (MaterialSelected != "notset")
                {
                    matsal = MaterialSelected;
                }
      }      
//alert("Searchval1="+Searchval1+"Cat_ID1="+Cat_ID1+"prrange="+PriceRange+"mat="+Mat+"MCat_ID1="+MCat_ID1+"Metal="+Metal+"materialselected="+MaterialSelected+"productselet="+ProductSelected+"metalselected="+MetalSelected+"prodsel"+prodsel+"matsal"+matsal);
Templates_uc_Template5SearchPPWA.getitemset(Searchval1,Cat_ID1,PriceRange,MetalSelected,prodsel,matsal,SearchClickgetitemset) //calling ajax function getitemset.
    return false;
    }
   
function SearchMetal(MetalSelected,PriceSelected)
    {   
        var frm1=document.form1;  
        var Searchval1=frm1.Template5Search1_HSearchval.value;
        var Cat_ID1=frm1.Template5Search1_HCat_ID.value;
        var PriceRange=frm1.Template5Search1_HPrice.value;
        var PriceRangequery=frm1.Template5Search1_HPrice.value;
        var Mat=frm1.Template5Search1_HMat.value;
        var Metal=frm1.Template5Search1_HMetal.value;
        var MCat_ID1=frm1.Template5Search1_HMCat_ID.value;
        var prodsel="0";
        var matsal="";
        var PriceRange="";
       document.getElementById("DisplayLoading").style.visibility="visible";
       
       if(PriceSelected=="")
            {
                PriceRange="notset";
            }
            else
            {
                PriceRange=PriceSelected;
            }
        if(Searchval1=="M")
           {
                var MaterialSelected=frm1.Template5Search1_DDMaterial.options[frm1.Template5Search1_DDMaterial.selectedIndex].value;
           }
        else
           {
               var MaterialSelected="notset";
           }
        if(Searchval1=="P")
            {
                var ProductSelected=frm1.Template5Search1_DDProduct.options[frm1.Template5Search1_DDProduct.selectedIndex].value;
            }
           else 
            {
                var ProductSelected="notset";
            }
   
        if(Cat_ID1 != "notset")
            {
                if (ProductSelected == "notset")
                {
                    prodsel = Cat_ID1;
                }
                else
                {
                    prodsel = ProductSelected;
                }
            }
            else
            {
                if (ProductSelected != "notset")
                {
                    prodsel = ProductSelected;
                }            
            }
   
       if (Mat != "notset") //searchvalue==M
            {      
                if (MaterialSelected != "notset")
                {
                    matsal = MaterialSelected;
                }
            } 
        else
          {       
                if (MaterialSelected != "notset")
                    {
                        matsal = MaterialSelected;
                    }
          }
        if (MetalSelected == "")
            {
                MetalSelected = "notset";
            }
            
        //alert("Searchval1="+Searchval1+"Cat_ID1="+Cat_ID1+"prrange="+PriceRange+"mat="+Mat+"MCat_ID1="+MCat_ID1+"Metal="+Metal+"materialselected="+MaterialSelected+"productselet="+ProductSelected+"metalselected="+MetalSelected+"prodsel"+prodsel+"matsal"+matsal);
        Templates_uc_Template5SearchPPWA.getitemset(Searchval1,Cat_ID1,PriceRange,MetalSelected,prodsel,matsal,SearchClickgetitemset) //calling ajax function getitemset.
        //return false;
    }
   
 


function callgetitemset(response) //getting response from ajax function call
    {
          document.getElementById("Template5Search1_show_items").value=response.value;
          setTimeout("getdatadisplayItem('1')", 2000);
    }
    function SearchClickgetitemset(response) //getting response from ajax function call
    {
           //alert(response.value);
          document.getElementById("Template5Search1_show_items").value=response.value;
          //getdatadisplayItem('1');
          setTimeout("getdatadisplayItem('1')", 2000);
    }
   function pricefill() //this function called in cs file.
    {
        var prdid=document.getElementById("Template5Search1_DDProduct").value;
        //alert("--prdid="+prdid+"--");
        Templates_uc_Template5SearchPPWA.fillprice(prdid,callpricefill) //calling ajax function for filling price dropdown according to product selected
    }
   function callpricefill(response)//this function used for getting response from ajax based fillprice function.
    {
        frm=document.form1;
        var dataset=response.value;
        if(dataset==null || dataset==0)
             {
                 document.getElementById("Template5Search1_DDPrice").options[0] = new Option("Any Price","notset");
                 document.getElementById("Template5Search1_DDPrice").options[1] = new Option("$100 & Under","0,100");
                 document.getElementById("Template5Search1_DDPrice").options[2] = new Option("$250-$500","250,500");
                 document.getElementById("Template5Search1_DDPrice").options[3] = new Option("$500-$1000","500,1000");
                 document.getElementById("Template5Search1_DDPrice").options[4] = new Option("$1000-$2500","1000,2500");
                 document.getElementById("Template5Search1_DDPrice").options[5] = new Option("$2500-$5000","2500,5000");
                 document.getElementById("Template5Search1_DDPrice").options[6] = new Option("$5000 & Above","5000,");
             }
        else
             {
                 var totalRecord=dataset.Tables[0].Rows.length;
                 if(totalRecord<=0)
                    {
                    frm.Template5Search1_DDPrice.options[0] = new Option("Any Price","notset");
                    frm.Template5Search1_DDPrice.options[1] = new Option("$100 & Under","0,100");
                    frm.Template5Search1_DDPrice.options[2] = new Option("$250-$500","250,500");
                    frm.Template5Search1_DDPrice.options[3] = new Option("$500-$1000","500,1000");
                    frm.Template5Search1_DDPrice.options[4] = new Option("$1000-$2500","1000,2500");
                    frm.Template5Search1_DDPrice.options[5] = new Option("$2500-$5000","2500,5000");
                    frm.Template5Search1_DDPrice.options[6] = new Option("$5000 & Above","5000,");
                    }
                 else
                    {
                        while (frm.Template5Search1_DDPrice.options.length>0) //clear the previous value of price dropdown
				          {
	  				        frm.Template5Search1_DDPrice.options[frm.Template5Search1_DDPrice.options.length-1]=null;
				          }
                          for(var i=0;i<totalRecord;i++) //filling price drop down with new values based on product selected.
                            {
                                 var string = ""
                                 var valueString=""; 
                                 if(dataset.Tables[0].Rows[i].Price_From ==0)
                                  {
                                    string +="$"+ dataset.Tables[0].Rows[i].Price_To;
                                    string +=" & Under"; 
                                    valueString=dataset.Tables[0].Rows[i].Price_From + "," + dataset.Tables[0].Rows[i].Price_To;
                                  }
                                 else
                                  {
                                    string ="$"+dataset.Tables[0].Rows[i].Price_From;
                                    valueString=dataset.Tables[0].Rows[i].Price_From;
                                    if(dataset.Tables[0].Rows[i].Price_To !=null)
                                        {
                                            string +="-$"+ dataset.Tables[0].Rows[i].Price_To;
                                            valueString += ","+dataset.Tables[0].Rows[i].Price_To;
                                        }
                                    else
                                        {
                                            string +="& Above";
                                        }
                                  }
                                if(i==0)
                                    {
                                        document.getElementById("Template5Search1_DDPrice").options[0] = new Option("Any Price","notset");
                                    }
                                else
                                    {
                                        document.getElementById("Template5Search1_DDPrice").options[i] = new Option(string,valueString);
                                    }
                          
                            } 
                     }
             }
    } 


function RetainCompareChecks(from1)
{

    var from = "";
    var arrDiaID = new Array();
    var hdnDiaCmprIds = "";
    var hdnDiaCmprIdsobj = document.getElementById("ctl00_ContentPlaceHolder1_Template5Search1_hdnDiaCmprIds");
    var hdnfrom = document.getElementById("ctl00_ContentPlaceHolder1_Template5Search1_hdnfrom");
    var frm = document.forms["aspnetForm"];
    if(hdnfrom!=null)
        from = hdnfrom.value;  
        
    from = from1;      
    if(frm)
    {
        try
        {
            if(from=='REC')        
                chkcollection = frm.elements["chk"];        
            if(from=='NUP')        
                chkcollection = frm.elements["chkNUP"];
            if(chkcollection)
            {
                hdnDiaCmprIds = hdnDiaCmprIdsobj.value;
                arrDiaID = hdnDiaCmprIds.split(",");
                for(var j=0;j<arrDiaID.length;j++)
                {
                    for(var i=0; i < chkcollection.length; i++)
                    {
                        if(arrDiaID[j] == chkcollection[i].value)
                        {
                            chkcollection[i].checked = true;
                        }
                    }
                }
            }
        }
        catch(e)
        {
        alert(e.value);
        }
    }
}



//End of template5PPWA.js 
//Strat of ItemDisplayPPWA.js
// JScript File
if(navigator.appName == "Netscape")
{BroweserType="FIREFOX";}
if(navigator.appName == "Microsoft Internet Explorer")
{BroweserType="IE";}

var isDOM=document.getElementById?1:0,isIE=document.all?1:0,isNS4=navigator.appName=='Netscape'&&!isDOM?1:0,isOp=self.opera?1:0,isDyn=isDOM||isIE||isNS4;
if(!self.page) var page={win:self,minW:0,minH:0,MS:isIE&&!isOp};

page.db=function(p)
{
    with(this.win.document) return(isDOM?documentElement[p]:0)||body[p]||0;
};

page.winW=function()
{
    with(this) return Math.max(minW,MS?db('clientWidth'):win.innerWidth);
};
page.winH=function()
{
    with(this) return Math.max(minH,MS?db('clientHeight'):win.innerHeight);
};
page.scrollX=function()
{
    with(this) return MS?db('scrollLeft'):win.pageXOffset;
};
page.scrollY=function()
{
    with(this) return MS?db('scrollTop'):win.pageYOffset;
};


//Function for displaying details of Item
function ViewSearchItem(ItemId,e)
{

try
    {
       var left1=null;
       var top1=null;
       var nn6=document.getElementById&&!document.all;       
       try
       {
           if(nn6 == true)
           {
              left1 = e.pageX;
              top1 = e.pageY;              
            }
           else
           {
                  var  sX=page.scrollX();
                  var  sY=page.scrollY();  
                 left1 = event.clientX;
                 top1 =  event.clientY;
                top1=top1+sY;            
            }
        }
    catch(err)
    {
        //alert("error1="+err.source+ err.description+err.message);
    }
    try
    {
        top1=top1-300;
        document.getElementById("ItemDisplayLarge").style.visibility="hidden";
        document.getElementById("ItemDisplayLarge").style.display="none";
        document.getElementById("ItemDisplayLarge").style.top=top1+"px";
        }
    catch(err)
    {
        //alert("error2="+err.source+ err.description+err.message);
    }
    try
    {
        if(left1 > 400)
            {
              var x=left1-200;
              document.getElementById("ItemDisplayLarge").style.left=x+"px";
            }
       else 
          {document.getElementById("ItemDisplayLarge").style.left=left1+"px";}
       }
    catch(err)
    {
        //alert("error3="+err.source+ err.description+err.message);
    }
    
      Templates_uc_Template5SearchPPWA.show_detail(ItemId,res_callback);
    }
    catch(err)
    {
        //alert("error4="+err.source+ err.description+err.message);
    }
    return false;
}

function res_callback(resp)
{   
    var result=resp.value;
    document.getElementById("ItemDisplayLarge").innerHTML=result;
    document.getElementById("ItemDisplayLarge").style.visibility="visible";
    document.getElementById("ItemDisplayLarge").style.display="block";
}

function SearchItemInMozilla(e)
{
    var evtObj = nn6 ? e.target : event.srcElement;
	var evt = nn6 ? e : event;
    //alert(e);
}

//*****************************Function for closing div tag*************************************


function ItDispClose()
{
    document.getElementById("ItemDisplayLarge").style.visibility="hidden";
    document.getElementById("ItemDisplayLarge").style.display="none";
    return false;
}

//**********************************************************************************************

// Tool Tip Display 

var timerID=null;
var DivLeftRightImg="";
function Display_ToolTip(e)
{
    clearInterval(timerID);
    var var_x=null;
    var var_y=null;
    var ToolTip_event=null;
    if(dragapproved==true)
    {return;}
    var nn6=document.getElementById&&!document.all;
    if(nn6)
    {
      ToolTip_event=e.target;
    }
    else
    {ToolTip_event=event.srcElement;}
    var cords=ToolTip_cord(ToolTip_event);
    var_id=ToolTip_event.id.toString();    
    var var_ItemId=var_id.substring(2);
    var_x=cords.x;
    var_y=cords.y;
    Templates_uc_Template5SearchPPWA.GetToolTip(var_ItemId,DivLeftRightImg,ToolTip_callback);
    timerID = setInterval("ToolTip_show("+var_x+","+var_y+")",1000);    
   
}
    
function  ToolTip_callback(response)
{
    var result=response.value;    
    document.getElementById("div_ToolTip").innerHTML=result;
}

function ToolTip_cord(ToolTip_event)
    {
        var var_x1=null;
        var var_y1=null;
        var docw=ToolTip_event.offsetWidth;
        var doch=ToolTip_event.offsetHeight;
        var doct=getdoctop(ToolTip_event);
        var docl=getdocleft(ToolTip_event);
        var_x1 += docl;
           if(var_x1>325)
               {
                DivLeftRightImg="Left";
                var_x1 -= 350;
               }
           else
               {
               DivLeftRightImg="Right";
                  var_x1 +=docw;
                  var_x1+= 50;}
        var rely=null;
        rely += doct;
        rely = rely +(doch/2);
        var_y1=rely;
     return {x:var_x1 , y:var_y1};
    }
function ToolTip_show(var_x,var_y)
     {
     if(dragapproved==true)
        {
            Hide_ToolTip();
            return;
        }
	try{
        document.getElementById("div_ToolTip").style.position="absolute";
       var h=document.getElementById("div_ToolTip").offsetHeight;
       var_y-=h/2;
        document.getElementById("div_ToolTip").style.left=var_x-20+"px";
        document.getElementById("div_ToolTip").style.top=var_y+200+"px";
        document.getElementById("div_ToolTip").style.visibility="visible";}
	catch(err){}

    }
function Hide_ToolTip(e)
    { try{
     clearInterval(timerID);
     document.getElementById("div_ToolTip").style.left="0px";
     document.getElementById("div_ToolTip").style.top="0px";
     document.getElementById("div_ToolTip").style.visibility="hidden";
     document.getElementById("div_ToolTip").innerHTML="";}
	catch(err){}
    }
    
function getdoctop(e)
{
    var abstop=null;
    if(e.offsetParent)
       {
        while(e.offsetParent)
            {
            abstop += e.offsetTop;
            e=e.offsetParent;
            }
       }
    else if(e.x)
       {
       abstop+=e.x;
       }
  return abstop;
}

function getdocleft(e)
{
    var absleft=null;
    if(e.offsetParent)
        {
            while(e.offsetParent)
                {
                    absleft += e.offsetLeft;
                    e=e.offsetParent;
                }
        }        
      else if(e.x)
            absleft+=e.x;
    return absleft;
}


///// Tool Tip Display Ends=============================================

// javascript coding transfered from uc/js/Template5SearchPPWA.ascx page by econn===================


function CollectCompareIds(from,ID)
{   
    var diaidlist="";
    var arrDiaID = new Array();
    var arrDiaID1 = new Array();
    var flag = false;
    var hdnDiaCmprIdsobj = document.getElementById("ctl00_ContentPlaceHolder1_Template5Search1_hdnDiaCmprIds");
    var hdnDiaCmprIds = hdnDiaCmprIdsobj.value;
        
    var hdnfrom = document.getElementById("ctl00_Bottomnav_include1_hdnfrom");
    var frm = document.forms["aspnetForm"];
        if(from=='REC')        
            chkcollection = frm.elements["chk"];        
        if(from=='NUP')        
            chkcollection = frm.elements["chkNUP"];
        if(hdnfrom!=null)
                hdnfrom.value = from;
        if(chkcollection)
        {
              //Changes for comparison across pages
              hdnDiaCmprIds = hdnDiaCmprIdsobj.value;
              var remstr1 = "";
              var remstr2 = "";
              var remstr3 = "";
              var remstr4 = "";  
              var repl = "";
              var tworepl = "";
              
              for (var i=0; i < chkcollection.length; i++)
              {   
                  if (chkcollection[i].checked)
                  {     
                        if(i==chkcollection.length)
                        {
                            if(hdnDiaCmprIds.indexOf(chkcollection[i].value)==-1)
                                hdnDiaCmprIds += chkcollection[i].value + ",";
                        }
                        else
                        {   
                            var ndx = hdnDiaCmprIds.search(/,/);
                            if(ndx==-1)
                            {
                                if(hdnDiaCmprIds.indexOf(chkcollection[i].value)==-1)
                                    hdnDiaCmprIds += "," + chkcollection[i].value + ",";                            
                            }
                            else
                            {
                                if(hdnDiaCmprIds.indexOf(chkcollection[i].value)==-1)
                                    hdnDiaCmprIds += "," + chkcollection[i].value + ",";
                            }
                        }
                        flag = true;
                  }
                  if(chkcollection[i].checked==false)
                  { 
                    remstr4 = chkcollection[i].value;
                    if(hdnDiaCmprIds!="")
                    {
                        hdnDiaCmprIds = hdnDiaCmprIds.replaceAll(remstr4,',');
                    }
                  }
              }
              arrDiaID = hdnDiaCmprIds.split(",");              
              for(var k=0;k<arrDiaID.length;k++)
              {
                if(arrDiaID[k]!=null && arrDiaID[k]!="")
                    arrDiaID1[k] = arrDiaID[k];
              }
              arrDiaID = null;
              arrDiaID = arrDiaID1;
              for(var j=0;j<arrDiaID.length;j++)
              {
                if(j==arrDiaID.length-1)
                {
                    if(arrDiaID[j]!=null && arrDiaID[j]!="")
                        diaidlist += arrDiaID[j];
                }
                else
                {
                    if(arrDiaID[j]!=null)
                    {
                        if(arrDiaID[j]!="")
                            diaidlist += arrDiaID[j] + ",";
                    }
                }
              }
                hdnDiaCmprIdsobj.value =  diaidlist;
createCookie(hdnDiaCmprIdsobj.value);
        }
}
String.prototype.replaceAll=function(s1, s2) {return this.split(s1).join(s2)}
function SetCompareParameter(from)
{      
    var diaidlist="";
    var arrDiaID = new Array();
    var flag = false;
    var hdnDiaCmprIds = "";
    var hdnDiaCmprIdsobj = document.getElementById("ctl00_ContentPlaceHolder1_Template5Search1_hdnDiaCmprIds");

                if(hdnDiaCmprIdsobj.value!="")
                {
                    diaidlist = hdnDiaCmprIdsobj.value;
                    Templates_uc_Template5SearchPPWA.setCompareDiaIds(diaidlist);
                    flag = true;
                }

              if(flag==false || diaidlist=="")
              {
                alert("Please select diamonds to compare.");
                return;
              }
              
          include_bottomnavintpg.GetDiamondComparisonDatac(from,callbackremovecompare);
}
    function SethdnP(page)
    {//debugger
        document.getElementById("ctl00_ContentPlaceHolder1_Template5Search1_hdnpageno").value = page;
        sortfilter();
    }
    function SethdnM(metalval)
    {//debugger
        document.getElementById("ctl00_ContentPlaceHolder1_Template5Search1_hdnmetal").value = metalval;
        sortfilter();
    }
    function SethdnS(shapeval)
    {
        document.getElementById("ctl00_ContentPlaceHolder1_Template5Search1_hdnshape").value = shapeval;
        sortfilter();
    }
    function SethdnSo()
    {
        var Index3 = document.getElementById("ctl00_ContentPlaceHolder1_Template5Search1_drpsort").selectedIndex;
        var strSort = document.getElementById("ctl00_ContentPlaceHolder1_Template5Search1_drpsort").options[Index3].value;
        document.getElementById("ctl00_ContentPlaceHolder1_Template5Search1_hdnsort").value = strSort;
        sortfilter();
    }
    function sortfilters()
    {   //debugger
        var pageval = document.getElementById("ctl00_ContentPlaceHolder1_Template5Search1_hdnpageno").value;
        var shapeval = document.getElementById("ctl00_ContentPlaceHolder1_Template5Search1_hdnshape").value;
        var metalval = document.getElementById("ctl00_ContentPlaceHolder1_Template5Search1_hdnmetal").value;
        var sortval = document.getElementById("ctl00_ContentPlaceHolder1_Template5Search1_hdnsort").value;       
//        var catid="<%=catid%>";
//        var template="<%=template%>";         
//        urlpath = "<%=strPath%>templates/template5ppwa.aspx";        
        window.location=urlpath+"?cat_id="+catid+"&template="+template+"&shape="+shapeval+"&metal="+metalval+"&sort="+sortval+"&page="+pageval;
    }
        function callbackquery(resquery)
        {
        //debugger
            var pagesel = document.getElementById("hdnpagesel").value;
            document.getElementById("Template5Search1_show_items").value = resquery.value;
            setTimeout("getdatadisplayItem('"+pagesel+"')", 2000);
        }
        
        function SearchMetal1(metal,from,to)
        {
                                   
            var pagesel = document.getElementById("hdnpagesel").value;            
            var Index1 = document.getElementById("Template5Search1_drpgemstone").selectedIndex;
            var strGemstone = document.getElementById("Template5Search1_drpgemstone").options[Index1].value;
            if(strGemstone == "select")
            {
                strGemstone = "";
            }
            
            var Index2 = document.getElementById("Template5Search1_drpcolor").selectedIndex;
            var strColor = document.getElementById("Template5Search1_drpcolor").options[Index2].value;
            if(strColor == "select")
            {
                strColor = "";
            }
            
            var Index3 = document.getElementById("Template5Search1_drpsort").selectedIndex;
            var strSort = document.getElementById("Template5Search1_drpsort").options[Index3].value;
            var order_by = "asc"; 
            if(strSort == "select")
            {
              order_by = "asc";
            }
            else if(strSort == "LTH")
            {
                order_by = "asc";
            }
            else if(strSort == "HTL")
            {
                order_by = "desc";
            }
            else if(strSort == "PP")
            {
              order_by = "";
            }                
             
            if(from == "" && to == "")
            {
                document.getElementById("Template5Search1_show_items").value = "select distinct H.Item_ID, H.Item_name,H.Item_Price, H.Template_ID, H.Item_Image, isnull(IC.[order],'99') as Priority, H.IsRecommended, H.Item_Seo_link, H.NumberDays from Hitsview as H left outer join ItemAttribute_Gem_View as iagv on H.Item_id=iagv.Item_id left outer join ItemAttribute_Color_View as iacv on H.Item_id=iacv.Item_id LEFT OUTER JOIN ItemOrderbycatg as IC ON H.Item_id = IC.Item_Id and IC.Cat_ID = "+ catid +" where H.Cat_id = "+ catid +" and H.Item_Price >= 0 and (iacv.item_id is null or iacv.Item_Attribute_Value like '%" + strColor + "%')and (iagv.item_id is null or iagv.Item_Attribute_Value like '%" + strGemstone + "%')order by H.Item_Price "+ order_by;
                setTimeout("getdatadisplayItem('"+pagesel+"')", 2000);
            }
            else if(from != "" && to == "")
            {
             document.getElementById("Template5Search1_show_items").value = "select distinct H.Item_ID, H.Item_name,H.Item_Price, H.Template_ID, H.Item_Image, isnull(IC.[order],'99') as Priority, H.IsRecommended, H.Item_Seo_link, H.NumberDays from Hitsview as H left outer join ItemAttribute_Gem_View as iagv on H.Item_id=iagv.Item_id left outer join ItemAttribute_Color_View as iacv on H.Item_id=iacv.Item_id LEFT OUTER JOIN ItemOrderbycatg as IC ON H.Item_id = IC.Item_Id and IC.Cat_ID = "+ catid +" where H.Cat_id = "+ catid +" and H.Item_Price >= " + from + " and (iacv.item_id is null or iacv.Item_Attribute_Value like '%" + strColor + "%')and (iagv.item_id is null or iagv.Item_Attribute_Value like '%" + strGemstone + "%')order by H.Item_Price "+ order_by;
             setTimeout("getdatadisplayItem('"+pagesel+"')", 2000);                
            }
            else
            {
             document.getElementById("Template5Search1_show_items").value = "select distinct H.Item_ID, H.Item_name,H.Item_Price, H.Template_ID, H.Item_Image, isnull(IC.[order],'99') as Priority, H.IsRecommended, H.Item_Seo_link, H.NumberDays from Hitsview as H left outer join ItemAttribute_Gem_View as iagv on H.Item_id=iagv.Item_id left outer join ItemAttribute_Color_View as iacv on H.Item_id=iacv.Item_id LEFT OUTER JOIN ItemOrderbycatg as IC ON H.Item_id = IC.Item_Id and IC.Cat_ID = "+ catid +" where H.Cat_id = "+ catid +" and (H.Item_Price >= " + from + " and H.Item_Price <= " + to + ") and (iacv.item_id is null or iacv.Item_Attribute_Value like '%" + strColor + "%')and (iagv.item_id is null or iagv.Item_Attribute_Value like '%" + strGemstone + "%')order by H.Item_Price "+ order_by;
             setTimeout("getdatadisplayItem('"+pagesel+"')", 2000);
            }
        }

function GetSearchCriteria()
{
    
        strQurey = document.getElementById("Template5Search1_show_items").value;
        Templates_uc_SearchResultPPWA.GetTotalRecords(strQurey,GetSearchCallBack);
        setfocus();
}

function GetSearchCallBack(response)
{ var Ser_Price,Ser_Material,Ser_Prod,Ser_Metal;
    try
    {
         var w = document.getElementById("Template5Search1_DDProduct").selectedIndex;
         Ser_Prod = document.getElementById("Template5Search1_DDProduct").options[w].text;

    }catch(err){Ser_Prod="";}
    try
    {
        var w = document.getElementById("Template5Search1_DDMaterial").selectedIndex;
         Ser_Material = document.getElementById("Template5Search1_DDMaterial").options[w].text;

    }catch(err){Ser_Material=""; }
    try
    {
        var w = document.getElementById("Template5Search1_DDMetal").selectedIndex;
         Ser_Metal = document.getElementById("Template5Search1_DDMetal").options[w].text;

    }catch(err){ Ser_Metal=""; }
    try
    {
        var w = document.getElementById("Template5Search1_DDPrice").selectedIndex;
         Ser_Price = document.getElementById("Template5Search1_DDPrice").options[w].text;

    }catch(err){ Ser_Price=""; }    
    try
    {
    //document.getElementById("TotalSearchRecords").innerHTML="There Are Total "+response.value + " " + Ser_Prod + Ser_Material + Ser_Metal +" Items Matching "+Ser_Price +" Your Search Criteria." ;
    }catch(err){}
    
}
    function color_change(colorvalue)
    {
        if(colorvalue == "select")
        {
            
        }
        else
        {
            document.getElementById("Template5Search1_show_items").value = "select ia.item_attribute_value,Item.Item_ID, Item.Item_name,Item.Item_Desc, Item.Item_Price, Item.Template_ID, Item.Item_Image from Item Item left outer join Item_attribute ia on Item.Item_id=ia.Item_id where Item.isActive = 'T' and Item.Item_ID in (select Item_ID from Item_ParentCategory  where Cat_ID = "+ catid +") and item_attribute_value like '%"+colorvalue+"%'";
            setTimeout("getdatadisplayItem('1')", 2000);
        }
    }
    function gemstone_change(gemstonevalue)
    {   
        if(gemstonevalue == "select")
        {
            
        }
        else
        {
            document.getElementById("Template5Search1_show_items").value = "select ia.item_attribute_value,Item.Item_ID, Item.Item_name,Item.Item_Desc, Item.Item_Price, Item.Template_ID, Item.Item_Image from Item Item left outer join Item_attribute ia on Item.Item_id=ia.Item_id where Item.isActive = 'T' and Item.Item_ID in (select Item_ID from Item_ParentCategory  where Cat_ID = "+ catid +") and item_attribute_value like '%"+gemstonevalue+"%'";
            setTimeout("getdatadisplayItem('1')", 2000);
        }
    }

    function pricerange_change(value)        
    {       
//        var RecordNumber1 = 1;
//        //var strQurey = "select Item.Item_ID, Item.Item_name,Item.Item_Desc, Item.Item_Price, Item.Template_ID, Item.Item_Image from Item where Item.isActive = 'T' and Item_ID in (select Item_ID from Item_ParentCategory  where Cat_ID = 107) order by Item_Price desc"
//        strQurey1=document.getElementById("Template5Search1_show_items").value;
//        document.getElementById("DisplayLoading").style.visibility="visible";
//        document.getElementById("DisplayLoading").style.display="block";
//        Templates_uc_Template5Search.displayItem(RecordNumber1,strQurey1,getPagging1);    
//        GetSearchCriteria();
          if(value == 'select')
          {
          
          }  
          if(value=='LTH')
          {
          document.getElementById("Template5Search1_show_items").value = "select Item.Item_ID, Item.Item_name,Item.Item_Desc, Item.Item_Price, Item.Template_ID, Item.Item_Image from Item where Item.isActive = 'T' and Item_ID in (select Item_ID from Item_ParentCategory  where Cat_ID ="+ catid +") order by Item_Price asc";
          setTimeout("getdatadisplayItem('1')", 2000);
          Templates_uc_SearchResultPPWA.DefaultedPrice(catid,resp_price);
          }
          else if(value=='HTL')
          {
          document.getElementById("Template5Search1_show_items").value = "select Item.Item_ID, Item.Item_name,Item.Item_Desc, Item.Item_Price, Item.Template_ID, Item.Item_Image from Item where Item.isActive = 'T' and Item_ID in (select Item_ID from Item_ParentCategory  where Cat_ID ="+ catid +") order by Item_Price desc";
          setTimeout("getdatadisplayItem('1')", 2000);
          Templates_uc_SearchResultPWA.DefaultedPrice(catid,resp_price);
          }
          else if(value == 'PP')
          {
          document.getElementById("Template5Search1_show_items").value = "select distinct H.Item_ID,H.Item_Desc, H.Item_name, H.Item_Price, H.Template_ID, H.Item_Image, isnull(IC.[order],'99') as Priority, H.IsRecommended, H.Item_Seo_link, H.NumberDays from Hitsview as H LEFT OUTER JOIN ItemOrderbycatg as IC ON H.Item_id = IC.Item_Id and IC.Cat_ID = 107 where H.Cat_id =107 order by H.NumberDays desc,priority asc";
          setTimeout("getdatadisplayItem('1')", 2000);
          Templates_uc_SearchResultPPWA.DefaultedPrice(catid,resp_price);
          }
        
    }
        function resp_price(resprice)
        {           
            //document.getElementById("LblDefaultPrice").style.visibility = 'visible';
            if(resprice.value != "")
            {
                
                document.getElementById("Template5Search1_LblDefaultPrice").style.visibility = "visible";            
                document.getElementById("Template5Search1_LblDefaultPrice").style.display = "block";
                var spanprice = document.getElementById("Template5Search1_LblDefaultPrice");
                spanprice.innerHTML = resprice.value;
                
            }
        }
        
         
    function getPagging1(res1)
    {
        document.getElementById("Searchres").innerHTML = res1.value;
        getSession();
        strQurey=document.getElementById("Template5Search1_show_items").value;
        Templates_uc_SearchResultPPWA.GetPaging(RecordNumber,strQurey,SetPagging);
        document.getElementById("DisplayLoading").style.visibility="hidden";
        document.getElementById("DisplayLoading").style.display="none";
        
    }
    function setajaxres()
    {
    
    //alert('hello');
    var frm=document.form1; 
    var a=document.getElementById("Template5Search1_HSearchval");
    var a1=document.getElementById("Template5Search1_HCat_ID");
    var a2=document.getElementById("Template5Search1_HPrice");
    var a3=document.getElementById("Template5Search1_HPrice");
    var a4=document.getElementById("Template5Search1_HMat");
    var a5=document.getElementById("Template5Search1_HMetal");
    var a6=document.getElementById("Template5Search1_HMCat_ID");
     

    
    
    if(a!=null){ var Searchval=a.value;}
    if(a1!=null){var Cat_ID=a1.value;}
    if(a2!=null){var PriceRange=a2.value;}
    if(a3!=null){var PriceRangequery=a3.value;}
    if(a4!=null){var Mat=a4.value;}
    if(a5!=null){var Metal=a5.value;}
    if(a6!=null){var MCat_ID=a6.value;}
    var prodsel="0";
    var matsal="";
    
    
    
  // var chkSearchButton='<%=CheckSearchButton%>';//transfered on page load   
   if(chkSearchButton=="True" || chkSearchButton=="true")
   {
        document.getElementById("btnTemplate5Search").style.visibility="visible";
   }
   else
   {
        document.getElementById("btnTemplate5Search").style.visibility="hidden";
   }
    if(Searchval=="notset")
        {
            var PriceRange="notset";          
        }
    else
        {   
            if(PriceRange=="notinquery")
             {
                var PriceRange="notset";
             }
           else 
            {
                 var PrieRange=frm.Template5Search1_DDPrice.options[frm.Template5Search1_DDPrice.selectedIndex].value;
            }     
             
        }         

    if(Searchval=="M")
       {
            var MaterialSelected=frm.Template5Search1_DDMaterial.options[frm.Template5Search1_DDMaterial.selectedIndex].value;
       }
    else
       {
           var MaterialSelected="notset";
       }
    if(Searchval=="P")
        {
            var ProductSelected=frm.Template5Search1_DDProduct.options[frm.Template5Search1_DDProduct.selectedIndex].value;
        }
       else 
        {
            var ProductSelected="notset";
        }
   //if(Metal=="notset")
   //     {
             var MetalSelected="notset";
    //    }
    //    else
    //    {
    //         var MetalSelected=frm.Template5Search1_DDMetal.options[frm.Template5Search1_DDMetal.selectedIndex].value;
    //    }
    if(Cat_ID != "notset")
        {
            if (ProductSelected == "notset")
            {
                prodsel = Cat_ID;
            }
            else
            {
                prodsel = ProductSelected;
            }
        }
        else
        {
            if (ProductSelected != "notset")
            {
                prodsel = ProductSelected;
            }            
        }
   
   if (Mat != "notset") //searchvalue==M
        {
            matsal = Mat;
            if (MaterialSelected != "notset")
            {
                matsal = MaterialSelected;
            }
        } 
    else
      {
            if (MaterialSelected != "notset")
                {
                    matsal = MaterialSelected;
                }
      }
      try
      {     
        for( var i=0; i<document.getElementById("Template5Search1_DDMaterial").options.length; i++)
            {            
                if(document.getElementById("Template5Search1_DDMaterial").options[i].value ==document.getElementById("Template5Search1_HMat").value)
                {
                    document.getElementById("Template5Search1_DDMaterial").selectedIndex=i;
                    break;
                }
            }
        }
        catch(err){}
        
//alert("Searchval="+Searchval+"cat_id="+Cat_ID+"prrange="+PriceRange+"mat="+Mat+"MCat_ID="+MCat_ID+"Metal="+Metal+"materialselected="+MaterialSelected+"productselet="+ProductSelected+"metalselected="+MetalSelected+"prodsel"+prodsel+"matsal"+matsal);
Templates_uc_Template5SearchPPWA.getitemset(Searchval,Cat_ID,PriceRange,MetalSelected,prodsel,matsal,callgetitemset) //calling ajax function getitemset.
    }
    

 

    function OnSearchClick()
    { 
       
    var frm1=document.form1;  
    var Searchval1=frm1.Template5Search1_HSearchval.value;
    var Cat_ID1=frm1.Template5Search1_HCat_ID.value;
    var PriceRange=frm1.Template5Search1_HPrice.value;
    var PriceRangequery=frm1.Template5Search1_HPrice.value;
    var Mat=frm1.Template5Search1_HMat.value;
    var Metal=frm1.Template5Search1_HMetal.value;
    var MCat_ID1=frm1.Template5Search1_HMCat_ID.value;
    var prodsel="0";
    var matsal="";
   document.getElementById("DisplayLoading").style.visibility="visible";
    if(Searchval1=="notset")
        {
            var PriceRange="notset";          
        }
    else
        {
            var PriceRange=frm1.Template5Search1_DDPrice.options[frm1.Template5Search1_DDPrice.selectedIndex].value;
        }
    if(Searchval1=="M")
       {
            var MaterialSelected=frm1.Template5Search1_DDMaterial.options[frm1.Template5Search1_DDMaterial.selectedIndex].value;
       }
    else
       {
           var MaterialSelected="notset";
       }
    if(Searchval1=="P")
        {
            var ProductSelected=frm1.Template5Search1_DDProduct.options[frm1.Template5Search1_DDProduct.selectedIndex].value;
        }
       else 
        {
            var ProductSelected="notset";
        }
   //if(Metal=="notset")
   //     {
             var MetalSelected="notset";
   //     }
        //else
        //{
        //     var MetalSelected=frm1.Template5Search1_DDMetal.options[frm1.Template5Search1_DDMetal.selectedIndex].value;
        //}
    if(Cat_ID1 != "notset")
        {
            if (ProductSelected == "notset")
            {
                prodsel = Cat_ID1;
            }
            else
            {
                prodsel = ProductSelected;
            }
        }
        else
        {
            if (ProductSelected != "notset")
            {
                prodsel = ProductSelected;
            }            
        }
   
   if (Mat != "notset") //searchvalue==M
        {
       // alert("MaterialSelected="+MaterialSelected);
       //     matsal = Mat;
      //      alert("matsal="+matsal);
            if (MaterialSelected != "notset")
            {
                matsal = MaterialSelected;
            }
        } 
    else
      {
        // alert("else --MaterialSelected="+MaterialSelected);
            if (MaterialSelected != "notset")
                {
                    matsal = MaterialSelected;
                }
      }      
//alert("Searchval1="+Searchval1+"Cat_ID1="+Cat_ID1+"prrange="+PriceRange+"mat="+Mat+"MCat_ID1="+MCat_ID1+"Metal="+Metal+"materialselected="+MaterialSelected+"productselet="+ProductSelected+"metalselected="+MetalSelected+"prodsel"+prodsel+"matsal"+matsal);
Templates_uc_Template5SearchPPWA.getitemset(Searchval1,Cat_ID1,PriceRange,MetalSelected,prodsel,matsal,SearchClickgetitemset) //calling ajax function getitemset.
    return false;
    }
   
function SearchMetal(MetalSelected,PriceSelected)
    {   
        var frm1=document.form1;  
        var Searchval1=frm1.Template5Search1_HSearchval.value;
        var Cat_ID1=frm1.Template5Search1_HCat_ID.value;
        var PriceRange=frm1.Template5Search1_HPrice.value;
        var PriceRangequery=frm1.Template5Search1_HPrice.value;
        var Mat=frm1.Template5Search1_HMat.value;
        var Metal=frm1.Template5Search1_HMetal.value;
        var MCat_ID1=frm1.Template5Search1_HMCat_ID.value;
        var prodsel="0";
        var matsal="";
        var PriceRange="";
       document.getElementById("DisplayLoading").style.visibility="visible";
       
       if(PriceSelected=="")
            {
                PriceRange="notset";
            }
            else
            {
                PriceRange=PriceSelected;
            }
        if(Searchval1=="M")
           {
                var MaterialSelected=frm1.Template5Search1_DDMaterial.options[frm1.Template5Search1_DDMaterial.selectedIndex].value;
           }
        else
           {
               var MaterialSelected="notset";
           }
        if(Searchval1=="P")
            {
                var ProductSelected=frm1.Template5Search1_DDProduct.options[frm1.Template5Search1_DDProduct.selectedIndex].value;
            }
           else 
            {
                var ProductSelected="notset";
            }
   
        if(Cat_ID1 != "notset")
            {
                if (ProductSelected == "notset")
                {
                    prodsel = Cat_ID1;
                }
                else
                {
                    prodsel = ProductSelected;
                }
            }
            else
            {
                if (ProductSelected != "notset")
                {
                    prodsel = ProductSelected;
                }            
            }
   
       if (Mat != "notset") //searchvalue==M
            {      
                if (MaterialSelected != "notset")
                {
                    matsal = MaterialSelected;
                }
            } 
        else
          {       
                if (MaterialSelected != "notset")
                    {
                        matsal = MaterialSelected;
                    }
          }
        if (MetalSelected == "")
            {
                MetalSelected = "notset";
            }
            
        //alert("Searchval1="+Searchval1+"Cat_ID1="+Cat_ID1+"prrange="+PriceRange+"mat="+Mat+"MCat_ID1="+MCat_ID1+"Metal="+Metal+"materialselected="+MaterialSelected+"productselet="+ProductSelected+"metalselected="+MetalSelected+"prodsel"+prodsel+"matsal"+matsal);
        Templates_uc_Template5SearchPPWA.getitemset(Searchval1,Cat_ID1,PriceRange,MetalSelected,prodsel,matsal,SearchClickgetitemset) //calling ajax function getitemset.
        //return false;
    }


    function pricefillOnload() //this function called in cs file.
    {
    //var tempSearchCatId ='<%=SearchQueryCatid%>';  // variable declared at page load
    //alert(tempSearchCatId);
    if(tempSearchCatId !="")
        {            
            Templates_uc_Template5SearchPPWA.fillprice(tempSearchCatId,callpricefillOnload) //calling ajax function for filling price dropdown according to product selected            
        }
    }
    function callgetitemset(response) //getting response from ajax function call
    {
          document.getElementById("Template5Search1_show_items").value=response.value;
          setTimeout("getdatadisplayItem('1')", 2000);
    }
    function SearchClickgetitemset(response) //getting response from ajax function call
    {
           //alert(response.value);
          document.getElementById("Template5Search1_show_items").value=response.value;
          //getdatadisplayItem('1');
          setTimeout("getdatadisplayItem('1')", 2000);
    }
   function pricefill() //this function called in cs file.
    {
        var prdid=document.getElementById("Template5Search1_DDProduct").value;
        //alert("--prdid="+prdid+"--");
        Templates_uc_Template5SearchPPWA.fillprice(prdid,callpricefill) //calling ajax function for filling price dropdown according to product selected
    }
   function callpricefill(response)//this function used for getting response from ajax based fillprice function.
    {
        frm=document.form1;
        var dataset=response.value;
        if(dataset==null || dataset==0)
             {
                 document.getElementById("Template5Search1_DDPrice").options[0] = new Option("Any Price","notset");
                 document.getElementById("Template5Search1_DDPrice").options[1] = new Option("$100 & Under","0,100");
                 document.getElementById("Template5Search1_DDPrice").options[2] = new Option("$250-$500","250,500");
                 document.getElementById("Template5Search1_DDPrice").options[3] = new Option("$500-$1000","500,1000");
                 document.getElementById("Template5Search1_DDPrice").options[4] = new Option("$1000-$2500","1000,2500");
                 document.getElementById("Template5Search1_DDPrice").options[5] = new Option("$2500-$5000","2500,5000");
                 document.getElementById("Template5Search1_DDPrice").options[6] = new Option("$5000 & Above","5000,");
             }
        else
             {
                 var totalRecord=dataset.Tables[0].Rows.length;
                 if(totalRecord<=0)
                    {
                    frm.Template5Search1_DDPrice.options[0] = new Option("Any Price","notset");
                    frm.Template5Search1_DDPrice.options[1] = new Option("$100 & Under","0,100");
                    frm.Template5Search1_DDPrice.options[2] = new Option("$250-$500","250,500");
                    frm.Template5Search1_DDPrice.options[3] = new Option("$500-$1000","500,1000");
                    frm.Template5Search1_DDPrice.options[4] = new Option("$1000-$2500","1000,2500");
                    frm.Template5Search1_DDPrice.options[5] = new Option("$2500-$5000","2500,5000");
                    frm.Template5Search1_DDPrice.options[6] = new Option("$5000 & Above","5000,");
                    }
                 else
                    {
                        while (frm.Template5Search1_DDPrice.options.length>0) //clear the previous value of price dropdown
				          {
	  				        frm.Template5Search1_DDPrice.options[frm.Template5Search1_DDPrice.options.length-1]=null;
				          }
                          for(var i=0;i<totalRecord;i++) //filling price drop down with new values based on product selected.
                            {
                                 var string = ""
                                 var valueString=""; 
                                 if(dataset.Tables[0].Rows[i].Price_From ==0)
                                  {
                                    string +="$"+ dataset.Tables[0].Rows[i].Price_To;
                                    string +=" & Under"; 
                                    valueString=dataset.Tables[0].Rows[i].Price_From + "," + dataset.Tables[0].Rows[i].Price_To;
                                  }
                                 else
                                  {
                                    string ="$"+dataset.Tables[0].Rows[i].Price_From;
                                    valueString=dataset.Tables[0].Rows[i].Price_From;
                                    if(dataset.Tables[0].Rows[i].Price_To !=null)
                                        {
                                            string +="-$"+ dataset.Tables[0].Rows[i].Price_To;
                                            valueString += ","+dataset.Tables[0].Rows[i].Price_To;
                                        }
                                    else
                                        {
                                            string +="& Above";
                                        }
                                  }
                                if(i==0)
                                    {
                                        document.getElementById("Template5Search1_DDPrice").options[0] = new Option("Any Price","notset");
                                    }
                                else
                                    {
                                        document.getElementById("Template5Search1_DDPrice").options[i] = new Option(string,valueString);
                                    }
                          
                            } 
                     }
             }
    }    
    function callpricefillOnload(response)//this function used for getting response from ajax based fillprice function.
    {
        frm=document.form1;
        var dataset=response.value;
        if(dataset==null || dataset==0)
             {
                 document.getElementById("Template5Search1_DDPrice").options[0] = new Option("Any Price","notset");
                 document.getElementById("Template5Search1_DDPrice").options[1] = new Option("$100 & Under","0,100");
                 document.getElementById("Template5Search1_DDPrice").options[2] = new Option("$250-$500","250,500");
                 document.getElementById("Template5Search1_DDPrice").options[3] = new Option("$500-$1000","500,1000");
                 document.getElementById("Template5Search1_DDPrice").options[4] = new Option("$1000-$2500","1000,2500");
                 document.getElementById("Template5Search1_DDPrice").options[5] = new Option("$2500-$5000","2500,5000");
                 document.getElementById("Template5Search1_DDPrice").options[6] = new Option("$5000 & Above","5000,");
             }
        else
             {
                 var totalRecord=dataset.Tables[0].Rows.length;
                 if(totalRecord<=0)
                    {
                    frm.Template5Search1_DDPrice.options[0] = new Option("Any Price","notset");
                    frm.Template5Search1_DDPrice.options[1] = new Option("$100 & Under","0,100");
                    frm.Template5Search1_DDPrice.options[2] = new Option("$250-$500","250,500");
                    frm.Template5Search1_DDPrice.options[3] = new Option("$500-$1000","500,1000");
                    frm.Template5Search1_DDPrice.options[4] = new Option("$1000-$2500","1000,2500");
                    frm.Template5Search1_DDPrice.options[5] = new Option("$2500-$5000","2500,5000");
                    frm.Template5Search1_DDPrice.options[6] = new Option("$5000 & Above","5000,");
                    }
                 else
                    {
                        while (frm.Template5Search1_DDPrice.options.length>0) //clear the previous value of price dropdown
				          {
	  				        frm.Template5Search1_DDPrice.options[frm.Template5Search1_DDPrice.options.length-1]=null;
				          }
                          for(var i=0;i<totalRecord;i++) //filling price drop down with new values based on product selected.
                            {
                                 var string = ""
                                 var valueString=""; 
                                 if(dataset.Tables[0].Rows[i].Price_From ==0)
                                  {
                                    string +="$"+ dataset.Tables[0].Rows[i].Price_To;
                                    string +=" & Under"; 
                                    valueString=dataset.Tables[0].Rows[i].Price_From + "," + dataset.Tables[0].Rows[i].Price_To;
                                  }
                                 else
                                  {
                                    string ="$"+dataset.Tables[0].Rows[i].Price_From;
                                    valueString=dataset.Tables[0].Rows[i].Price_From;
                                    if(dataset.Tables[0].Rows[i].Price_To !=null)
                                        {
                                            string +="-$"+ dataset.Tables[0].Rows[i].Price_To;
                                            valueString += ","+dataset.Tables[0].Rows[i].Price_To;
                                        }
                                    else
                                        {
                                            string +="& Above";
                                        }
                                  }
                                if(i==0)
                                    {
                                        document.getElementById("Template5Search1_DDPrice").options[0] = new Option("Any Price","notset");
                                    }
                                else
                                    {
                                        document.getElementById("Template5Search1_DDPrice").options[i] = new Option(string,valueString);
                                    }
                          
                            } 
                     }
             }

             for( var i=0; i<document.getElementById("Template5Search1_DDPrice").options.length; i++)
                {
                    
                    if(document.getElementById("Template5Search1_DDPrice").options[i].value ==document.getElementById("Template5Search1_HPrice").value)
                    {
                        document.getElementById("Template5Search1_DDPrice").selectedIndex=i;
                        break;
                    }
                }
    }  
   