﻿// JScript File

function slider1()
    {
//var slider1=0;
        var amount_slider1=window.document.getElementById("amount").value;
        //alert(amount_slider1);
        var minval_slider1 = amount_slider1.split("-");
        //alert(minval_slider1);
        var slider1_min=(minval_slider1[0].replace("$",""));
        var slider1_max=(minval_slider1[1].replace("$",""));
        SethdnSort_price(slider1_min,slider1_max);
}

    function slider_carat()
    {
//var slider1=0;
        var amount_slider_carat=window.document.getElementById("amount1").value;
        //alert(amount_slider_carat);
        var minval_slider_carat = amount_slider_carat.split("-");
        var carat_min=minval_slider_carat[0];
        var carat_max=minval_slider_carat[1];
        //alert(minval_slider_carat[0]);
        //alert(minval_slider_carat[1]);
        SethdnSort_carat(carat_min,carat_max);
    }


var slider1_min="";
var slider1_max="";
function SethdnSort_price(slider1_min,slider1_max)
{
    //alert("Min:" + slider1_min);
    //alert("Max:" + slider1_max);
    
    document.getElementById("Template5Search1_hdnslider1_min").value = slider1_min;
    document.getElementById("Template5Search1_hdnslider1_max").value = slider1_max;
    sortfilter();

}
var carat_min="";
var carat_max="";
function SethdnSort_carat(carat_min,carat_max)
{
    //alert("Carat Min:" + carat_min);
    //alert("Carat Max:" + carat_max);
    
    document.getElementById("Template5Search1_hdncarat_min").value = carat_min;
    document.getElementById("Template5Search1_hdncarat_max").value = carat_max;
    sortfilter();

}
    function SethdnM(metalval)
    {//debugger
        document.getElementById("Template5Search1_hdnmetal").value = metalval;
        sortfilter();
    }
    function SethdnS(shapeval)
    {
        document.getElementById("Template5Search1_hdnshape").value = shapeval;
        sortfilter();
    }
    function SethdnSo()
    {
        var Index3 = document.getElementById("Template5Search1_drpsort").selectedIndex;
        var strSort = document.getElementById("Template5Search1_drpsort").options[Index3].value;
        document.getElementById("Template5Search1_hdnsort").value = strSort;
        sortfilter();
    }
    var strShape="";
    function SethdnSlider()
    {
        var Index4 = document.getElementById("Template5Search1_drpShape").selectedIndex;
        strShape = document.getElementById("Template5Search1_drpShape").options[Index4].value;
        document.getElementById("Template5Search1_hdnshape").value = strShape;
        sortfilter();
    }
    var strQuality="";
    function SethdnQuality()
    {
        //debugger
        var Index5 = document.getElementById("Template5Search1_drpQuality").selectedIndex;
        strQuality = document.getElementById("Template5Search1_drpQuality").options[Index5].value;
        document.getElementById("Template5Search1_hdnQuality").value = strQuality;
        //alert(strQuality);
        sortfilter();
    }
    
    var strCert="";
    function SethdnCert()
    {
        var Index5 = document.getElementById("Template5Search1_drpcert").selectedIndex;
        strCert = document.getElementById("Template5Search1_drpcert").options[Index5].value;
        document.getElementById("Template5Search1_hdncert").value = strCert;
        //alert(strCert);
        sortfilter();
    }


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_SearchResultPCESBNnew.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)
{
//debugger
    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_SearchResultPCESBNnew.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;
        }
        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";
//        if(DivLeftRightImg=="Left")
//           {
//               try
//               {
//               document.getElementById('Img_Divright').src = 'D:/sid/peridot/images/DivPx.gif';
//               document.getElementById('Img_Divleft').src = 'D:/sid/peridot/images/Divleft.gif';
//               }
//               catch(err)
//               {}
//           }
//       else
//           {
//               try
//               {
//                   document.getElementById('Img_Divright').src = 'D:/sid/peridot/images/Divright.gif';
//                   document.getElementById('Img_Divleft').src = 'D:/sid/peridot/images/DivPx.gif';
//                   //document.getElementById("Img_Divleft").style.opacity= "0.5";
//               }
//               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


// ----------New JavaScript from Templates/UC/SearchResultPCES.ascx
var dragapproved = false;
function updatecookiepgIds(rep)
{
    //alert(rep);
    var hdnDiaCmprIdsobj = document.getElementById("SearchResult1_hdnDiaCmprIds");
    hdnDiaCmprIdsobj.value =rep;
     RetainCompareChecks('NUP');

}
function retainremovedIDs(id)
{
    var hdnDiaCmprIdsobj = document.getElementById("SearchResult1_hdnDiaCmprIds");
    var hdnfrom = document.getElementById("SearchResult1_hdnfrom");
    var frm = document.forms["form1"];
    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)
{   
    //alert(ID);
    var diaidlist="";
    var arrDiaID = new Array();
    var arrDiaID1 = new Array();
    var flag = false;
    var hdnDiaCmprIdsobj = document.getElementById("SearchResult1_hdnDiaCmprIds");
    var hdnDiaCmprIds = hdnDiaCmprIdsobj.value;
        
    var hdnfrom = document.getElementById("SearchResult1_hdnfrom");
    var frm = document.forms["form1"];

        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("SearchResult1_hdnDiaCmprIds");
     if(hdnDiaCmprIdsobj.value!="")
    {
        diaidlist = hdnDiaCmprIdsobj.value;
        Templates_uc_SearchResultPCESBNnew.setCompareDiaIds(diaidlist);
        flag = true;
    }
                

  if(flag==false || diaidlist=="")
  {
    alert("Please select diamonds to compare.");
    return;
  }
  Templates_Template5PCESBNnew.GetDiamondComparisonDatac(from,callbackremovecompare);
        }

function RetainCompareChecks(from1)
{

    var from = "";
    var arrDiaID = new Array();
    var hdnDiaCmprIds = "";
    var hdnDiaCmprIdsobj = document.getElementById("SearchResult1_hdnDiaCmprIds");
    var hdnfrom = document.getElementById("SearchResult1_hdnfrom");
    var frm = document.forms["form1"];
    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);
        }
    }
}




<!--
var RecordNumber = 1;
var strQurey;

function GetSearchCriteria()
{
    
        strQurey = document.getElementById("Template5Search1_show_items").value;
        Templates_uc_SearchResultPCESBNnew.GetTotalRecords(strQurey,GetSearchCallBack);
        setfocus();
}

function Redirect4or16(Url)
{
    window.location.href=Url;
}

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
    {
    }catch(err){}
    
}
function getdatadisplayItem(rec)
{   
    //debugger
    document.getElementById("hdnpagesel").value= rec;           
    //document.getElementById("Template5Search1_lblnorecord").style.visibility = "hidden"
    document.getElementById("Template5Search1_lblnorecord").style.display = "none"
    RecordNumber =  rec;
    strQurey=document.getElementById("Template5Search1_show_items").value;
    //document.getElementById("DisplayLoading").style.visibility="visible";
    //document.getElementById("DisplayLoading").style.display="block";
    document.getElementById("DisplayLoading").style.display="inline";
    var ids=document.getElementById("SearchResult1_hdnDiaCmprIds").value;
    //alert(ids);
    Templates_uc_SearchResultPCESBNnew.displayItem(RecordNumber,strQurey,ids,getPagging);    
    GetSearchCriteria();
}
function setfocus()
{document.getElementById("SearchResult").focus();
}

function getdatadisplayItemnotFound(rec)
{       
    RecordNumber =  rec;
    strQurey=document.getElementById("Template5Search1_show_items").value;    
    //document.getElementById("DisplayLoading").style.display="block";
    //Templates_uc_SearchResultPCESBNnew.displayItem(RecordNumber,strQurey,getPaggingNotFound); 
    var ids=document.getElementById("SearchResult1_hdnDiaCmprIds").value;
    //alert(ids);
    Templates_uc_SearchResultPCESBNnew.displayItem(RecordNumber,strQurey,ids,getPaggingNotFound);       
    GetSearchCriteria();
}
function getPaggingNotFound(res)
{
   document.getElementById("Searchres").innerHTML = res.value;
    getSession();
    strQurey=document.getElementById("Template5Search1_show_items").value;
    Templates_uc_SearchResultPCESBNnew.GetPaging(RecordNumber,strQurey,SetPagging);
    //document.getElementById("DisplayLoading").style.visibility="hidden";
    //document.getElementById("DisplayLoading").style.display="none";
}
function defaultvalue()
{
      document.getElementById("Template5Search1_hdnsort").value="select";      
      document.getElementById("Template5Search1_hdnshape").value="select";
      document.getElementById("Template5Search1_hdnQuality").value="All";
      document.getElementById("Template5Search1_hdncert").value="select";

}
function getPagging(res)
{
//debugger
     try
     {    
         var ress = res.value;

         var int1 = ress.search("Found");
         var pagenum="";
            try
            {
		
                pagenum = document.getElementById("hdnpagesel").value;
             }
             catch(err){pagenum ="1";}
             

             //alert("page no:"+pagenum+ " int1"+int1);
             if(int1 != "-1")
             {//debugger
             //defaultvalue();
		document.getElementById("hdnpagesel").value=1;
         	pagenum = document.getElementById("hdnpagesel").value;
          //setTimeout("sortfilter()", 1000);
             setTimeout("getdatadisplayItemnotFound('"+pagenum+"')", 1000);
		//alert("test"+pagenum);
            return "not";
            }
            document.getElementById("Searchres").innerHTML = res.value;
    getSession();
                strQurey=document.getElementById("Template5Search1_show_items").value;
                //alert(pagenum+" "+strQurey);
                Templates_uc_SearchResultPCESBNnew.GetPaging(pagenum,strQurey,SetPagging);
                //document.getElementById("DisplayLoading").style.visibility="hidden";
                document.getElementById("DisplayLoading").style.display="none";
             //}
readPgloadcookie();
     }
     catch(err){}
    
}
function getPaggingold(res)
{    
    try
    {    
    var ress = res.value;
    //alert(ress);
    var int1 = ress.search("Found");
    var pagenum = document.getElementById("hdnpagesel").value;
    if(int1 != "-1")
    {
        
        var Index1 = document.getElementById("Template5Search1_drpgemstone").selectedIndex;
        var strGemstone = document.getElementById("Template5Search1_drpgemstone").options[Index1].value;
        document.getElementById("Template5Search1_drpgemstone").selectedIndex=0;
        if(strGemstone == "select")
        {
            strGemstone = "";
        }
        
        var Index2 = document.getElementById("Template5Search1_drpcolor").selectedIndex;
        var strColor = document.getElementById("Template5Search1_drpcolor").options[Index2].value;
        document.getElementById("Template5Search1_drpcolor").selectedIndex=0;
        if(strColor == "select")
        {
            strColor = "";
        }
        
        var Index3 = document.getElementById("Template5Search1_drpsort").selectedIndex;
        var strSort = document.getElementById("Template5Search1_drpsort").options[Index3].value;
        document.getElementById("Template5Search1_drpsort").selectedIndex=0;
        document.getElementById("Template5Search1_lblnorecord").style.visibility = "visible";
        document.getElementById("Template5Search1_lblnorecord").style.display = '';
        
        document.getElementById("Template5Search1_lblnorecord").innerHTML = "<b>Record not found for filter</b> " +strColor;
        setajaxres();
//        if(strSort == "select")
//        {
//            document.getElementById("Template5Search1_show_items").value = "select distinct H.Item_ID, H.Item_name,H.Item_Price, H.Template_ID, H.Item_Image_Large, isnull(IC.[order],'99') as Priority, H.IsRecommended, H.Item_Seo_link, H.NumberDays from Hitsview as H left outer join ItemAttribute_Metal_View as iagv on H.Item_id=iagv.Item_id left outer join ItemAttribute_Shape_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 (iacv.item_id is null or iacv.Item_Attribute_Value like '%%')and (iagv.item_id is null or iagv.Item_Attribute_Value like '%%') order by H.NumberDays desc,priority asc";
//        }
//        else if(strSort == "LTH")
//        {
//            document.getElementById("Template5Search1_show_items").value = "select distinct H.Item_ID, H.Item_name,H.Item_Price, H.Template_ID, H.Item_Image_Large, isnull(IC.[order],'99') as Priority, H.IsRecommended, H.Item_Seo_link, H.NumberDays from Hitsview as H left outer join ItemAttribute_Metal_View as iagv on H.Item_id=iagv.Item_id left outer join ItemAttribute_Shape_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 (iacv.item_id is null or iacv.Item_Attribute_Value like '%%')and (iagv.item_id is null or iagv.Item_Attribute_Value like '%%') order by H.Item_Price asc";
//        }
//        else if(strSort == "HTL")
//        {
//            document.getElementById("Template5Search1_show_items").value = "select distinct H.Item_ID, H.Item_name,H.Item_Price, H.Template_ID, H.Item_Image_Large, isnull(IC.[order],'99') as Priority, H.IsRecommended, H.Item_Seo_link, H.NumberDays from Hitsview as H left outer join ItemAttribute_Metal_View as iagv on H.Item_id=iagv.Item_id left outer join ItemAttribute_Shape_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 (iacv.item_id is null or iacv.Item_Attribute_Value like '%%')and (iagv.item_id is null or iagv.Item_Attribute_Value like '%%') order by H.Item_Price desc";
//        }
//        else if(strSort == "PP")
//        {
//            document.getElementById("Template5Search1_show_items").value = "select distinct H.Item_ID, H.Item_name,H.Item_Price, H.Template_ID, H.Item_Image_Large, isnull(IC.[order],'99') as Priority, H.IsRecommended, H.Item_Seo_link, H.NumberDays from Hitsview as H left outer join ItemAttribute_Metal_View as iagv on H.Item_id=iagv.Item_id left outer join ItemAttribute_Shape_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 (iacv.item_id is null or iacv.Item_Attribute_Value like '%%')and (iagv.item_id is null or iagv.Item_Attribute_Value like '%%') order by H.NumberDays desc,priority asc";
//        }
        
        setTimeout("getdatadisplayItemnotFound('"+pagenum+"')", 1000);
        return "not";
    }
    document.getElementById("Searchres").innerHTML = res.value;
    getSession();
    strQurey=document.getElementById("Template5Search1_show_items").value;
    //alert(strQurey);
    Templates_uc_SearchResultPCESBNnew.GetPaging(RecordNumber,strQurey,SetPagging);
    //document.getElementById("DisplayLoading").style.visibility="hidden";
    document.getElementById("DisplayLoading").style.display="none";
    }
    catch(err){}
    
}
        function record_resp_price(resp_price)
        {     
                
            if(resp_price.value != "")
            {
                
                document.getElementById("Template5Search1_LblDefaultPrice").style.visibility = "visible";            
                document.getElementById("Template5Search1_LblDefaultPrice").style.display = "block";
                var spanprice = document.getElementById("Template5Search1_LblDefaultPrice");
                spanprice.innerHTML = resp_price.value;
                
            }
        }
function SetPagging(res)
{    
//alert("SetPagging");
    var pagging = "";
    pagging = res.value;   
    try
    { 
    if(pagging == "1&nbsp;" || pagging == "")
    {       
        document.getElementById("topPager").innerHTML= "";
        document.getElementById("topPager").style.display="none";       
        document.getElementById("SearchResult1_bottomPager").innerHTML= "";
        document.getElementById("SearchResult1_bottomPager").style.display="none";
    
    }
    else
    {
//debugger
        pagging = pagging.replace("funcpages()","funcpages(1)");
        document.getElementById("topPager").innerHTML= pagging;
        document.getElementById("topPager").style.display="block";

        pagging = pagging.replace("funcpages(1)","funcpages(2)");
        pagging = pagging.replace("drppage","drppage1");
        document.getElementById("SearchResult1_bottomPager").innerHTML= pagging;  //pagging.substr(j+1,pagging.length);        
        document.getElementById("SearchResult1_bottomPager").style.display="block";
       
    } 
    }
    catch(errsetpg)   
    { alert(errserpg.description);}
document.getElementById("DisplayLoading").style.display="none";
}
function SetPaggingold(res)
{    
    var pagging = "";
    pagging = res.value;    
    if(pagging == "1&nbsp;" || pagging == "")
    {       
        document.getElementById("topPager").innerHTML= "";
        document.getElementById("topPager").style.display="none";
        document.getElementById("SearchResult1_bottomPager").innerHTML= "";
        document.getElementById("SearchResult1_bottomPager").style.display="none";
    
    }
    else
    {
        document.getElementById("topPager").innerHTML= pagging;
        document.getElementById("topPager").style.display="block";
        document.getElementById("SearchResult1_bottomPager").innerHTML= pagging;  //pagging.substr(j+1,pagging.length);        
        document.getElementById("SearchResult1_bottomPager").style.display="block";
       
    }    

}



//--------- Code from Templarte/uc/Template5SearchPCES.ascx

 var dshape="no";
    var dmetal="no";
    function defaultshape()
    {
        dshape="yes";
        sortfilter();        
    }
    function defaultmetal()
    {
        dmetal="yes";
        sortfilter();
    }
    
    
    function MinMaxprice()
    {
      
      sortfilter();
    }
    function cbcontent(res)
    {
    
    }
    function cbquery(res)
    {
        //alert(res.value);
        document.getElementById("Template5Search1_show_items").value=res.value;
	var pagenum="";
            try
            {
                pagenum = document.getElementById("hdnpagesel").value;
             }
             catch(err){pagenum ="1";}
              setTimeout("getdatadisplayItem('"+pagenum+"')", 1);
	//alert(pagenum);
        //getdatadisplayItem('"+pagenum+"');
	//getdatadisplayItem('1');
    }
     var Cat_ID="<%=catid%>";  
    function sortfilter()
    {        
    
    var minprc,maxprc;
      
      //minprc = document.getElementById("price-min-value").value;
      //maxprc = document.getElementById("price-max-value").value;
      //var minprccomma = minprc.replace( ',', '')
      //var maxprccomma = maxprc.replace( ',', '')
      //var pagesel = document.getElementById("hdnpagesel").value;
      
      var Index3 = document.getElementById("Template5Search1_drpsort").selectedIndex;
      document.getElementById("Template5Search1_hdnsort").value = document.getElementById("Template5Search1_drpsort").options[Index3].value;
        
      strSort = document.getElementById("Template5Search1_hdnsort").value;
      strMetal=document.getElementById("Template5Search1_hdnmetal").value;
      strShape=document.getElementById("Template5Search1_hdnshape").value;
      strQuality=document.getElementById("Template5Search1_hdnQuality").value;
      slider1_min=document.getElementById("Template5Search1_hdnslider1_min").value;
      slider1_max=document.getElementById("Template5Search1_hdnslider1_max").value;
      strCert=document.getElementById("Template5Search1_hdncert").value;
      carat_min= document.getElementById("Template5Search1_hdncarat_min").value;
      carat_max= document.getElementById("Template5Search1_hdncarat_max").value;
      
     if (strMetal=="All Metal" || strMetal=="" )
     {
        strMetal="";
     }
    if (strQuality=="All" || strQuality=="" )
     {
        strQuality="";
     }
      if (strCert=="select" || strCert=="" || strCert=="All")
     {
        strCert="";
     }
     if (strShape=="All Shape" || strShape=="select" || strShape=="" )
     {
        strShape="";
     }
     //alert("Sort="+strSort);
     // alert("Shape="+strShape);
      //alert("strQuality="+strQuality);
     // alert("slider1_min="+slider1_min);
     // alert("slider1_max="+slider1_max);
     // alert("strCert="+strCert);
      //alert("carat_min="+carat_min);
      //alert("carat_max="+carat_max);
      
      //var urlpath = window.location.href;                 
     //var urlpath2=urlpath.split("?");
     // var path=urlpath2[1].split("&");
       //window.location=urlpath+catid+"/"+shapeval+"/"+metalval+"/"+sortval+"/"+pageval+"/";
     //window.location=urlpath2[0]+"?"+path[0]+"&"+path[1]+"&shape="+strShape+"&metal="+metalval+"&sort="+sortval+"&page=1"+"&quality="+strQuality+"&cert="+strCert+"&min_price="+slider1_min+"&max_price="+slider1_max+"&min_carat="+carat_min++"&min_carat="+carat_max;
        Templates_uc_Template5SearchPCESBNnew.DefaultQuery(Cat_ID,strSort,strShape,strMetal,strQuality,strCert,slider1_min,slider1_max,carat_min,carat_max,cbquery);
      
//        if(dshape=="yes")
//        {
//            pagesel="1";
//            document.getElementById("Template5Search1_drpgemstone").selectedIndex=0;
//            document.getElementById("Template5Search1_drpsort").selectedIndex=0;
//            dshape="no";
//        }
//        if(dmetal=="yes")
//        {
//            pagesel="1";
//            document.getElementById("Template5Search1_drpcolor").selectedIndex=0;
//            document.getElementById("Template5Search1_drpsort").selectedIndex=0;
//            dmetal="no";
//        } 
//        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;
//        var result="";
//        if(strColor == "select")
//        {
//            strColor = "";
//        }
//        if(strColor=="")
//        {        
//            document.getElementById("Template5Search1_crumshape").innerHTML = "<div onclick='defaultshape();'><b>All Shape</b></div>";
//            document.getElementById("currentshape").innerHTML = "<div onclick='defaultshape();'><b>All Shape</b></div>";
//            result += "<div class='top_links'>-</div><div class='top_links grey'>" + document.getElementById("Template5Search1_crumshape").innerHTML + "</div>";          
//        }
//        else
//        {
//            document.getElementById("Template5Search1_crumshape").innerHTML = "<div onclick='sortfilter();'><b>" + strColor + "</b></div>"; 
//            document.getElementById("currentshape").innerHTML = "<div onclick='sortfilter();'><b>" + strColor + "</b></div>"; 
//            result += "<div class='top_links'>-</div><div class='top_links grey'>" + document.getElementById("Template5Search1_crumshape").innerHTML + "</div>";          
//        }
//        if(strGemstone == ""||strGemstone=="select")
//        {
//            strGemstone="";
//            document.getElementById("Template5Search1_crummetal").innerHTML = "<div onclick='defaultmetal();'><b>All Metal</b></div>"; 
//            document.getElementById("currentmetal").innerHTML =  "<div onclick='defaultmetal();'><b>All Metal</b></div>";
//            result += "<div class='top_links'>-</div><div class='top_links grey'>" + document.getElementById("Template5Search1_crummetal").innerHTML + "</div>";      
//        }
//        else
//        {
//            document.getElementById("Template5Search1_crummetal").innerHTML = "<div onclick='sortfilter();'><b>" + strGemstone + "</b></div>";  
//            document.getElementById("currentmetal").innerHTML = "<div onclick='sortfilter();'><b>" + strGemstone + "</b></div>";
//            result += "<div class='top_links'>-</div><div class='top_links grey'>" + document.getElementById("Template5Search1_crummetal").innerHTML + "</div>";          
//        }                       
//        document.getElementById("Topnav_include1_shapemetal").innerHTML=result;
//        var Index3 = document.getElementById("Template5Search1_drpsort").selectedIndex;
//        var strSort = document.getElementById("Template5Search1_drpsort").options[Index3].value;
//        
//        if(strSort == "select")
//        {
//         
//            
//            
//            document.getElementById("Template5Search1_show_items").value = "select distinct H.Item_ID, H.Item_name,H.Item_Price, H.Template_ID, H.Item_Image,H.Item_Image_Large, isnull(IC.[order],'99') as Priority, H.IsRecommended, H.Item_Seo_link, H.NumberDays from Hitsview as H left outer join ItemAttribute_Metal_View as iagv on H.Item_id=iagv.Item_id left outer join ItemAttribute_Shape_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 (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.NumberDays desc,priority asc";
//            
//            setTimeout("getdatadisplayItem('"+pagesel+"')", 1);
//           
//        }
//        else if(strSort == "LTH")
//        {
//           
//            
//            
//            document.getElementById("Template5Search1_show_items").value = "select distinct H.Item_ID, H.Item_name,H.Item_Price, H.Template_ID, H.Item_Image,H.Item_Image_Large, isnull(IC.[order],'99') as Priority, H.IsRecommended, H.Item_Seo_link, H.NumberDays from Hitsview as H left outer join ItemAttribute_Metal_View as iagv on H.Item_id=iagv.Item_id left outer join ItemAttribute_Shape_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 (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 asc";
//            setTimeout("getdatadisplayItem('"+pagesel+"')", 1);
//           
//        }
//        else if(strSort == "HTL")
//        {
//           
//            
//            document.getElementById("Template5Search1_show_items").value = "select distinct H.Item_ID, H.Item_name,H.Item_Price, H.Template_ID, H.Item_Image,H.Item_Image_Large, isnull(IC.[order],'99') as Priority, H.IsRecommended, H.Item_Seo_link, H.NumberDays from Hitsview as H left outer join ItemAttribute_Metal_View as iagv on H.Item_id=iagv.Item_id left outer join ItemAttribute_Shape_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 (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 desc";
//            setTimeout("getdatadisplayItem('"+pagesel+"')", 1);
//           
//        }
//        else if(strSort == "PP")
//        {
        
          
         // document.getElementById("Template5Search1_show_items").value = "select distinct H.Item_ID, H.Item_name,H.Item_Price, H.Template_ID, H.Item_Image,H.Item_Image_Large, isnull(IC.[order],'99') as Priority, H.IsRecommended, H.Item_Seo_link, H.NumberDays from Hitsview as H left outer join ItemAttribute_Metal_View as iagv on H.Item_id=iagv.Item_id left outer join ItemAttribute_Shape_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 (iacv.item_id is null or iacv.Item_Attribute_Value like '%%')and (iagv.item_id is null or iagv.Item_Attribute_Value like '%%') and (H.Item_Price >= "+ minprccomma +" and H.Item_Price <= "+ maxprccomma + ")order by H.NumberDays desc,priority asc";
          
        //  setTimeout("getdatadisplayItem('"+pagesel+"')", 1);
//        }
 
        
    }
        
        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,H.Item_Image_Large, 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+"')", 1);
            }
            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,H.Item_Image_Large, 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+"')", 1);                
            }
            else
            {
             
             
             document.getElementById("Template5Search1_show_items").value = "select distinct H.Item_ID, H.Item_name,H.Item_Price, H.Template_ID, H.Item_Image,H.Item_Image_Large, 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+"')", 1);
            }
        }

function GetSearchCriteria()
{
    
        strQurey = document.getElementById("Template5Search1_show_items").value;
        Templates_uc_SearchResultPCESBNnew.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')", 1);
        }
    }
    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')", 1);
        }
    }

    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')", 1);
          Templates_uc_Template5SearchPCESBN.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')", 1);
          Templates_uc_Template5SearchPCESBN.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')", 1);
          Templates_uc_Template5SearchPCESBN.DefaultedPrice(CatID ,resp_price);
          }
        
    }
        function resp_price(resprice)
        {           
 
            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_SearchResultPCESBNnew.GetPaging(RecordNumber,strQurey,SetPagging);
        document.getElementById("DisplayLoading").style.visibility="hidden";
        document.getElementById("DisplayLoading").style.display="none";
        
    }
    
    
     
     
     
    //  2nd Second from Template5PCES.ascx
    
    
     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";
        }
  
             var MetalSelected="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
      {
        // alert("else --MaterialSelected="+MaterialSelected);
            if (MaterialSelected != "notset")
                {
                    matsal = MaterialSelected;
                }
      }      

Templates_uc_Template5SearchPCESBN.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_Template5SearchPCESBN.getitemset(Searchval1,Cat_ID1,PriceRange,MetalSelected,prodsel,matsal,SearchClickgetitemset) //calling ajax function getitemset.
        //return false;
    }
      
 
//  3rd Javascript from Template5Search.aspx



    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')", 1);
    }
   function pricefill() //this function called in cs file.
    {
        var prdid=document.getElementById("Template5Search1_DDProduct").value;
        //alert("--prdid="+prdid+"--");
        Templates_uc_Template5SearchPCESBN.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);
                                    }
                          
                            } 
                     }
             }
             //alert(document.getElementById("Template5Search1_DDPrice").options.lenght);
             //alert(document.getElementById("Template5Search1_DDPrice").options.length);
             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;
                    }
                }
    }  
     
    
    
    
    //-------------Include/Meat_data.ascx

// JScript File
var strMainKeywords1="<%= strMainKeywords1%>";
var strMainKeywords2="<%= strMainKeywords2%>";
var strMainKeywords3="<%= strMainKeywords3%>";
var strMainKeywords="<%= strMainKeywords%>";

// fill the alt tags of the named img tags mainkeywords1,2,3 dynamically with mainkey words
function setkeyword()
{
    //var main = document.getElementsByTagNameNS('http://www.w3.org/1999/xhtml', 'body');
    //alert("hi");
    var main = document.getElementsByName("MainKeywords");
    var output = main.length;
    for(var i=0;i<output;i++)
    {
       // alert(main[i].id);
       var d = document.getElementById(main[i].id).attributes;
        d.getNamedItem("alt").value =strMainKeywords;
    }
      main = document.getElementsByName("MainKeywords1");
     output = main.length;
    for(var i=0;i<output;i++)
    {
       // alert(main[i].id);
     var   d = document.getElementById(main[i].id).attributes;
        d.getNamedItem("alt").value =strMainKeywords1;
    }
     main = document.getElementsByName("MainKeywords2");
     output = main.length;
    for(var i=0;i<output;i++)
    {
       // alert(main[i].id);
     var   d = document.getElementById(main[i].id).attributes;
        d.getNamedItem("alt").value =strMainKeywords2;
    }
      main = document.getElementsByName("MainKeywords3");
     output = main.length;
    for(var i=0;i<output;i++)
    {
       // alert(main[i].id);
     var   d = document.getElementById(main[i].id).attributes;
        d.getNamedItem("alt").value =strMainKeywords3;
    }
}
