﻿// 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_SearchResult.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_SearchResult.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




//############JavaScript from  Templates/UC/Tewmplate5Search


  
    function defaultshape()
    {
        dshape="yes";
        sortfilter();        
    }
    function defaultmetal()
    {
        dmetal="yes";
        sortfilter();
    }    
    function sortfilter()
    {        
        var pagesel = document.getElementById("hdnpagesel").value;
        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;
        if(strColor == "select")
        {
            strColor = "";
        }
        
        var Index3 = document.getElementById("Template5Search1_drpsort").selectedIndex;
        var strSort = document.getElementById("Template5Search1_drpsort").options[Index3].value;
        var result="";
        
        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'>All Shape</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'>" + strColor + "</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'>All Metal</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'>" + strGemstone + "</div>";          
        }                       
        document.getElementById("Topnav_include1_shapemetal").innerHTML=result;
        
        if(strSort == "select")
        {
            //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 '%"+strGemstone+"%' and item_attribute_value like '%"+strColor+"%'";
            //document.getElementById("Template5Search1_show_items").value = "select distinct H.NumberDays,isnull(IC.[order],'99') as Priority,Item.Item_ID, Item.Item_name,Item.Item_Price, Item.Template_ID, Item.Item_Image from Item  left outer join Item_attribute ia on Item.Item_id=ia.Item_id left outer join Hitsview as H on H.Item_id=Item.Item_id LEFT OUTER JOIN ItemOrderbycatg as IC ON Item.Item_id = IC.Item_Id and IC.Cat_ID = "+ CatID +" where Item.isActive = 'T' and Item.Item_ID in (select Item_ID from Item_ParentCategory  where Cat_ID = "+ CatID +") and item_attribute_value like '%"+strGemstone+"%' and item_attribute_value like '%"+strColor+"%'"

            //document.getElementById("Template5Search1_show_items").value = "select distinct Item.Item_ID, Item.Item_name,Item.Item_Price, Item.Template_ID, Item.Item_Image from Item  left outer join Item_attribute ia on Item.Item_id=ia.Item_id left outer join Hitsview as H on H.Item_id=Item.Item_id LEFT OUTER JOIN ItemOrderbycatg as IC ON Item.Item_id = IC.Item_Id and IC.Cat_ID = "+ CatID +" where Item.isActive = 'T' and Item.Item_ID in (select Item_ParentCategory.Item_ID from Item_ParentCategory  where Cat_ID = "+ CatID +") and item.item_id in (select item_attribute.item_id from item_attribute where item_attribute_value like '%"+strGemstone+"%' and attribute_id = '111') and item.item_id in (select item_attribute.item_id from item_attribute where (item_attribute_value like '%"+strColor+"%' or item_attribute_value is null) and attribute_id = '120')";
            
            
            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_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);
            //Templates_uc_Template5Search.DefaultedPrice('<%=catid %>',strGemstone,strColor,'asc',resp_price);
        }
        else if(strSort == "LTH")
        {
            //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 '%"+strGemstone+"%' and item_attribute_value like '%"+strColor+"%' order by Item_Price asc";
            //document.getElementById("Template5Search1_show_items").value = "select distinct H.NumberDays,isnull(IC.[order],'99') as Priority,Item.Item_ID, Item.Item_name,Item.Item_Price, Item.Template_ID, Item.Item_Image from Item  left outer join Item_attribute ia on Item.Item_id=ia.Item_id left outer join Hitsview as H on H.Item_id=Item.Item_id LEFT OUTER JOIN ItemOrderbycatg as IC ON Item.Item_id = IC.Item_Id and IC.Cat_ID = "+ CatID +" where Item.isActive = 'T' and Item.Item_ID in (select Item_ID from Item_ParentCategory  where Cat_ID = "+ CatID +") and item_attribute_value like '%"+strGemstone+"%' and item_attribute_value like '%"+strColor+"%' order by Item.Item_Price asc"
            
            //document.getElementById("Template5Search1_show_items").value = "select distinct Item.Item_ID, Item.Item_name,Item.Item_Price, Item.Template_ID, Item.Item_Image from Item  left outer join Item_attribute ia on Item.Item_id=ia.Item_id left outer join Hitsview as H on H.Item_id=Item.Item_id LEFT OUTER JOIN ItemOrderbycatg as IC ON Item.Item_id = IC.Item_Id and IC.Cat_ID = "+ CatID +" where Item.isActive = 'T' and Item.Item_ID in (select Item_ParentCategory.Item_ID from Item_ParentCategory  where Cat_ID = "+ CatID +") and item.item_id in (select item_attribute.item_id from item_attribute where item_attribute_value like '%"+strGemstone+"%' and attribute_id = '111') and item.item_id in (select item_attribute.item_id from item_attribute where (item_attribute_value like '%"+strColor+"%' or item_attribute_value is null) and attribute_id = '120') order by Item.Item_Price asc";
            
            
            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_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);
            //Templates_uc_Template5Search.DefaultedPrice('<%=catid %>',strGemstone,strColor,'asc',resp_price);
        }
        else if(strSort == "HTL")
        {
            //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 '%"+strGemstone+"%' and item_attribute_value like '%"+strColor+"%' order by Item_Price desc";
            //document.getElementById("Template5Search1_show_items").value = "select distinct H.NumberDays,isnull(IC.[order],'99') as Priority,Item.Item_ID, Item.Item_name,Item.Item_Price, Item.Template_ID, Item.Item_Image from Item  left outer join Item_attribute ia on Item.Item_id=ia.Item_id left outer join Hitsview as H on H.Item_id=Item.Item_id LEFT OUTER JOIN ItemOrderbycatg as IC ON Item.Item_id = IC.Item_Id and IC.Cat_ID = "+ CatID +" where Item.isActive = 'T' and Item.Item_ID in (select Item_ID from Item_ParentCategory  where Cat_ID = "+ CatID +") and item_attribute_value like '%"+strGemstone+"%' and item_attribute_value like '%"+strColor+"%' order by Item.Item_Price desc"
            
            //document.getElementById("Template5Search1_show_items").value = "select distinct Item.Item_ID, Item.Item_name,Item.Item_Price, Item.Template_ID, Item.Item_Image from Item  left outer join Item_attribute ia on Item.Item_id=ia.Item_id left outer join Hitsview as H on H.Item_id=Item.Item_id LEFT OUTER JOIN ItemOrderbycatg as IC ON Item.Item_id = IC.Item_Id and IC.Cat_ID = "+ CatID +" where Item.isActive = 'T' and Item.Item_ID in (select Item_ParentCategory.Item_ID from Item_ParentCategory  where Cat_ID = "+ CatID +") and item.item_id in (select item_attribute.item_id from item_attribute where item_attribute_value like '%"+strGemstone+"%' and attribute_id = '111') and item.item_id in (select item_attribute.item_id from item_attribute where (item_attribute_value like '%"+strColor+"%' or item_attribute_value is null) and attribute_id = '120') order by Item.Item_Price desc";
            
            
            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_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);
            //Templates_uc_Template5Search.DefaultedPrice('<%=catid %>',strGemstone,strColor,'desc',resp_price);
        }
        else if(strSort == "PP")
        {
        
          //document.getElementById("Template5Search1_show_items").value = "select distinct H.NumberDays,isnull(IC.[order],'99') as Priority,Item.Item_ID, Item.Item_name,Item.Item_Desc, Item.Item_Price, Item.Template_ID, Item.Item_Image from Item  left outer join Item_attribute ia on Item.Item_id=ia.Item_id left outer join Hitsview as H on H.Item_id=Item.Item_id LEFT OUTER JOIN ItemOrderbycatg as IC ON Item.Item_id = IC.Item_Id and IC.Cat_ID = "+ CatID +" where Item.isActive = 'T' and Item.Item_ID in (select Item_ID from Item_ParentCategory  where Cat_ID = "+ CatID +") and item_attribute_value like '%"+strGemstone+"%' and item_attribute_value like '%"+strColor+"%' order by H.NumberDays desc,priority asc"
          //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";
          
          //document.getElementById("Template5Search1_show_items").value = "select distinct H.NumberDays,isnull(IC.[order],'99') as Priority,Item.Item_ID, Item.Item_name,Item.Item_Price, Item.Template_ID, Item.Item_Image from Item  left outer join Item_attribute ia on Item.Item_id=ia.Item_id left outer join Hitsview as H on H.Item_id=Item.Item_id LEFT OUTER JOIN ItemOrderbycatg as IC ON Item.Item_id = IC.Item_Id and IC.Cat_ID = "+ CatID +" where Item.isActive = 'T' and Item.Item_ID in (select Item_ID from Item_ParentCategory  where Cat_ID = "+ CatID +") and item_attribute_value like '%"+strGemstone+"%' and item_attribute_value like '%"+strColor+"%' order by H.NumberDays desc,priority asc";
          
          //latest//document.getElementById("Template5Search1_show_items").value = "select distinct H.NumberDays,isnull(IC.[order],'99') as Priority,Item.Item_ID, Item.Item_name,Item.Item_Price, Item.Template_ID, Item.Item_Image from Item  left outer join Item_attribute ia on Item.Item_id=ia.Item_id left outer join Hitsview as H on H.Item_id=Item.Item_id LEFT OUTER JOIN ItemOrderbycatg as IC ON Item.Item_id = IC.Item_Id and IC.Cat_ID = "+ CatID +" where Item.isActive = 'T' and Item.Item_ID in (select Item_ParentCategory.Item_ID from Item_ParentCategory  where Cat_ID = "+ CatID +") and item.item_id in (select item_attribute.item_id from item_attribute where item_attribute_value like '%"+strGemstone+"%' and attribute_id = '111') and item.item_id in (select item_attribute.item_id from item_attribute where (item_attribute_value like '%"+strColor+"%' or item_attribute_value is null) and attribute_id = '120') order by H.NumberDays desc,priority asc";
          //document.getElementById("Template5Search1_show_items").value = "select distinct isnull(IC.[order],'99') as Priority,Item.Item_ID, Item.Item_name,Item.Item_Price, Item.Template_ID, Item.Item_Image from Item  left outer join Item_attribute ia on Item.Item_id=ia.Item_id left outer join Hitsview as H on H.Item_id=Item.Item_id LEFT OUTER JOIN ItemOrderbycatg as IC ON Item.Item_id = IC.Item_Id and IC.Cat_ID = "+ CatID +" where Item.isActive = 'T' and Item.Item_ID in (select Item_ParentCategory.Item_ID from Item_ParentCategory  where Cat_ID = "+ CatID +") and item.item_id in (select item_attribute.item_id from item_attribute where item_attribute_value like '%"+strGemstone+"%' and attribute_id = '111') and item.item_id in (select item_attribute.item_id from item_attribute where (item_attribute_value like '%"+strColor+"%' or item_attribute_value is null) and attribute_id = '120') order by priority asc"
          
          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_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);
        }
        //alert(strGemstone);
        //alert(strColor);
    }
        
        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 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.item_price >= 0 and item_attribute_value like '%" + strGemstone + "%' and item_attribute_value like '%" + strColor + "%' order by Item_price "+ order_by;
                //document.getElementById("Template5Search1_show_items").value = "select * from Item i left outer join Item_ParentCategory ip on i.item_id = ip.item_id left outer join Item_attribute ia on i.Item_id=ia.Item_id where cat_id=  "+ CatID +" and item_price >= 0  and item_attribute_value like '%" + strGemstone + "%' and item_attribute_value like '%" + strColor + "%' order by Item_price " + order_by;
                
                //document.getElementById("Template5Search1_show_items").value = "select distinct H.NumberDays,isnull(IC.[order],'99') as Priority,Item.Item_ID, Item.Item_name,Item.Item_Price, Item.Template_ID, Item.Item_Image from Item  left outer join Item_attribute ia on Item.Item_id=ia.Item_id left outer join Hitsview as H on H.Item_id=Item.Item_id LEFT OUTER JOIN ItemOrderbycatg as IC ON Item.Item_id = IC.Item_Id and IC.Cat_ID = "+ CatID +" where Item.isActive = 'T' and Item.Item_ID in (select Item_ID from Item_ParentCategory  where Cat_ID = "+ CatID +")and Item.Item_Price >= 0 and item_attribute_value like '%" + strGemstone + "%' and item_attribute_value like '%" + strColor + "%' order by Item.Item_Price "+ order_by;
                
                //document.getElementById("Template5Search1_show_items").value = "select distinct Item.Item_ID, Item.Item_name,Item.Item_Price, Item.Template_ID, Item.Item_Image from Item  left outer join Item_attribute ia on Item.Item_id=ia.Item_id left outer join Hitsview as H on H.Item_id=Item.Item_id LEFT OUTER JOIN ItemOrderbycatg as IC ON Item.Item_id = IC.Item_Id and IC.Cat_ID = "+ CatID +" where Item.isActive = 'T' and Item.Item_ID in (select Item_ParentCategory.Item_ID from Item_ParentCategory  where Cat_ID = "+ CatID +") and Item.Item_Price >= 0 and item.item_id in (select item_attribute.item_id from item_attribute where item_attribute_value like '%"+strGemstone+"%' and attribute_id = '111') and item.item_id in (select item_attribute.item_id from item_attribute where (item_attribute_value like '%"+strColor+"%' or item_attribute_value is null) and attribute_id = '120') order by Item.Item_Price "+ order_by;
                
                
                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+"')", 1);
            }
            else if(from != "" && to == "")
            {
               //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_price >= " + from + " and item_attribute_value like '%" + strGemstone + "%' and item_attribute_value like '%" + strColor + "%' order by Item_price "+ order_by; 
             //document.getElementById("Template5Search1_show_items").value = "select * from Item i left outer join Item_ParentCategory ip on i.item_id = ip.item_id left outer join Item_attribute ia on i.Item_id=ia.Item_id where cat_id=  "+ CatID +" and item_price >= " + from + " and item_attribute_value like '%" + strGemstone + "%' and item_attribute_value like '%" + strColor + "%' order by Item_price " + order_by;
             
             //document.getElementById("Template5Search1_show_items").value = "select distinct H.NumberDays,isnull(IC.[order],'99') as Priority,Item.Item_ID, Item.Item_name,Item.Item_Price, Item.Template_ID, Item.Item_Image from Item  left outer join Item_attribute ia on Item.Item_id=ia.Item_id left outer join Hitsview as H on H.Item_id=Item.Item_id LEFT OUTER JOIN ItemOrderbycatg as IC ON Item.Item_id = IC.Item_Id and IC.Cat_ID = "+ CatID +" where Item.isActive = 'T' and Item.Item_ID in (select Item_ID from Item_ParentCategory  where Cat_ID = "+ CatID +") and Item.Item_Price >= " + from + " and item_attribute_value like '%" + strGemstone + "%' and item_attribute_value like '%" + strColor + "%' order by Item.Item_Price "+ order_by;
             //document.getElementById("Template5Search1_show_items").value = "select distinct Item.Item_ID, Item.Item_name,Item.Item_Price, Item.Template_ID, Item.Item_Image from Item  left outer join Item_attribute ia on Item.Item_id=ia.Item_id left outer join Hitsview as H on H.Item_id=Item.Item_id LEFT OUTER JOIN ItemOrderbycatg as IC ON Item.Item_id = IC.Item_Id and IC.Cat_ID = "+ CatID +" where Item.isActive = 'T' and Item.Item_ID in (select Item_ParentCategory.Item_ID from Item_ParentCategory  where Cat_ID = "+ CatID +") and Item.Item_Price >= " + from + " and item.item_id in (select item_attribute.item_id from item_attribute where item_attribute_value like '%"+strGemstone+"%' and attribute_id = '111') and item.item_id in (select item_attribute.item_id from item_attribute where (item_attribute_value like '%"+strColor+"%' or item_attribute_value is null) and attribute_id = '120') order by Item.Item_Price "+ order_by;
             
             
             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+"')", 1);                
            }
            else
            {
             //document.getElementById("Template5Search1_show_items").value = "select * from Item i left outer join Item_ParentCategory ip on i.item_id = ip.item_id left outer join Item_attribute ia on i.Item_id=ia.Item_id where cat_id=  "+ CatID +" and (item_price >= " + from + " and item_price <= " + to + ") and item_attribute_value like '%" + strGemstone + "%' and item_attribute_value like '%" + strColor + "%' order by Item_price " + order_by;
             //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_price >= " + from + " and item_price <= " + to + ") and item_attribute_value like '%" + strGemstone + "%' and item_attribute_value like '%" + strColor + "%' order by Item_price "+ order_by; 
             
             //document.getElementById("Template5Search1_show_items").value = "select distinct H.NumberDays,isnull(IC.[order],'99') as Priority,Item.Item_ID, Item.Item_name,Item.Item_Price, Item.Template_ID, Item.Item_Image from Item  left outer join Item_attribute ia on Item.Item_id=ia.Item_id left outer join Hitsview as H on H.Item_id=Item.Item_id LEFT OUTER JOIN ItemOrderbycatg as IC ON Item.Item_id = IC.Item_Id and IC.Cat_ID = "+ CatID +" where Item.isActive = 'T' and Item.Item_ID in (select Item_ID from Item_ParentCategory  where Cat_ID = "+ CatID +")and (Item.Item_Price >= " + from + " and Item.Item_Price <= " + to + ") and item_attribute_value like '%" + strGemstone + "%' and item_attribute_value like '%" + strColor + "%' order by Item.Item_Price "+ order_by;
             //document.getElementById("Template5Search1_show_items").value = "select distinct Item.Item_ID, Item.Item_name,Item.Item_Price, Item.Template_ID, Item.Item_Image from Item  left outer join Item_attribute ia on Item.Item_id=ia.Item_id left outer join Hitsview as H on H.Item_id=Item.Item_id LEFT OUTER JOIN ItemOrderbycatg as IC ON Item.Item_id = IC.Item_Id and IC.Cat_ID = "+ CatID +" where Item.isActive = 'T' and Item.Item_ID in (select Item_ParentCategory.Item_ID from Item_ParentCategory  where Cat_ID = "+ CatID +") and (Item.Item_Price >= " + from + " and Item.Item_Price <= " + to + ") and item.item_id in (select item_attribute.item_id from item_attribute where item_attribute_value like '%"+strGemstone+"%' and attribute_id = '111') and item.item_id in (select item_attribute.item_id from item_attribute where (item_attribute_value like '%"+strColor+"%' or item_attribute_value is null) and attribute_id = '120') order by Item.Item_Price "+ order_by;
             
             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+"')", 1);
            }
        }

function GetSearchCriteria()
{
    
        strQurey = document.getElementById("Template5Search1_show_items").value;
        Templates_uc_SearchResult.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_Template5Search.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_Template5Search.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_Template5Search.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_SearchResult.GetPaging(RecordNumber,strQurey,SetPagging);
        document.getElementById("DisplayLoading").style.visibility="hidden";
        document.getElementById("DisplayLoading").style.display="none";
        
    }
    
    

 

    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_Template5Search.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_Template5Search.getitemset(Searchval1,Cat_ID1,PriceRange,MetalSelected,prodsel,matsal,SearchClickgetitemset) //calling ajax function getitemset.
        //return false;
    }

 




    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_Template5Search.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;
                    }
                }
    } 
    
    
    //#####################  JavaScript from Templates /Uc/Search.ascx
    
    
    function CollectCompareIds(from,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("hdnfrom");
    var frm = document.forms["form1"];
//    if(frm)
//    {
        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;

        }

}
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_SearchResult.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("hdnDiaCmprIds");
    var hdnfrom = document.getElementById("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_SearchResult.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
    {
    //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 getdatadisplayItem(rec)
{    
    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";
    Templates_uc_SearchResult.displayItem(RecordNumber,strQurey,getPagging);    
    GetSearchCriteria();
}
function setfocus()
{document.getElementById("SearchResult").focus();
}

function getdatadisplayItemnotFound(rec)
{       
    RecordNumber =  rec;
    strQurey=document.getElementById("Template5Search1_show_items").value;
    document.getElementById("DisplayLoading").style.visibility="visible";
    document.getElementById("DisplayLoading").style.display="block";
    Templates_uc_SearchResult.displayItem(RecordNumber,strQurey,getPaggingNotFound);    
    GetSearchCriteria();
}
function getPaggingNotFound(res)
{
   document.getElementById("Searchres").innerHTML = res.value;
    getSession();
    strQurey=document.getElementById("Template5Search1_show_items").value;
    Templates_uc_SearchResult.GetPaging(RecordNumber,strQurey,SetPagging);
    document.getElementById("DisplayLoading").style.visibility="hidden";
    document.getElementById("DisplayLoading").style.display="none";
}

function getPagging(res)
{    
    var ress = res.value;
    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;
        if(strGemstone == "select")
        {
            strGemstone = "";
        }
        document.getElementById("Template5Search1_drpgemstone").selectedIndex = 0;
        
        var Index2 = document.getElementById("Template5Search1_drpcolor").selectedIndex;
        var strColor = document.getElementById("Template5Search1_drpcolor").options[Index2].value;
        if(strColor == "select")
        {
            strColor = "";
        }
        document.getElementById("Template5Search1_drpcolor").selectedIndex = 0;
        
        var Index3 = document.getElementById("Template5Search1_drpsort").selectedIndex;
        var strSort = document.getElementById("Template5Search1_drpsort").options[Index3].value;
        if(strSort == "select")
        {
            strSort = "";
        }
        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>";
        
       
        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, 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, 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, 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, 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";
        }
        
        //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 (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;
    Templates_uc_SearchResult.GetPaging(RecordNumber,strQurey,SetPagging);
    document.getElementById("DisplayLoading").style.visibility="hidden";
    document.getElementById("DisplayLoading").style.display="none";
    
}
        function record_resp_price(resp_price)
        {     
                
            //document.getElementById("LblDefaultPrice").style.visibility = 'visible';
            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)
{    
    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";
       
    }    
   
}


