﻿// JScript File

var dragapproved = false;

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_Template5SearchLPGS.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_Template5SearchLPGSWA.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/Template5SearchLpgSWF
function RetainCompareChecks(from1)
{

    var from = "";
    var arrDiaID = new Array();
    var hdnDiaCmprIds = "";
    var hdnDiaCmprIdsobj = document.getElementById("ctl00_ContentPlaceHolder1_Template5Search1_hdnDiaCmprIds");
    var hdnfrom = document.getElementById("ctl00_ContentPlaceHolder1_Template5Search1_hdnfrom");
    var frm = document.forms["aspnetForm"];
    if(hdnfrom!=null)
    from = hdnfrom.value;  
        
    from = from1;      
    if(frm)
    {
        try
        {
            if(from=='REC')        
                chkcollection = frm.elements["chk"];        
            if(from=='NUP')        
                chkcollection = frm.elements["chkNUP"];
            if(chkcollection)
            {
                hdnDiaCmprIds = hdnDiaCmprIdsobj.value;
                arrDiaID = hdnDiaCmprIds.split(",");
                for(var j=0;j<arrDiaID.length;j++)
                {
                    for(var i=0; i < chkcollection.length; i++)
                    {
                        if(arrDiaID[j] == chkcollection[i].value)
                        {
                            chkcollection[i].checked = true;
                        }
                    }
                }
            }
        }
        catch(e)
        {
        alert(e.value);
        }
    }
}
function updatecookiepgIds(rep)
{
    var hdnDiaCmprIdsobj = document.getElementById("ctl00_ContentPlaceHolder1_Template5Search1_hdnDiaCmprIds");
    hdnDiaCmprIdsobj.value =rep;
     RetainCompareChecks('NUP');
    //alert(rep);
}
function retainremovedIDs(id)
{
    var hdnDiaCmprIdsobj = document.getElementById("ctl00_ContentPlaceHolder1_Template5Search1_hdnDiaCmprIds");
    var hdnfrom = document.getElementById("ctl00_ContentPlaceHolder1_Template5Search1_hdnfrom");
    var frm = document.forms["aspnetForm"];
    var from='NUP';       
    var arrhdnDiaCmprIdsobj=hdnDiaCmprIdsobj.value.split(',');
    //alert(arrhdnDiaCmprIdsobj.length);
    if(arrhdnDiaCmprIdsobj.length>1)
    {
            var dialids;
            dialids="";
            if(from=='NUP')        
                chkcollection = frm.elements["chkNUP"];
            if(chkcollection)
            {
                hdnDiaCmprIds = hdnDiaCmprIdsobj.value;
                arrDiaID = hdnDiaCmprIds.split(",");
                for(var i=0; i < chkcollection.length; i++)
                {
                   if(id == chkcollection[i].value)
                   {
                       chkcollection[i].checked = false;                 
                   }                   
                }                
                for(var j=0;j< arrhdnDiaCmprIdsobj.length;j++)
                {   
                    if(id== arrhdnDiaCmprIdsobj[j])
                    {                    }
                    else
                    { dialids+= arrhdnDiaCmprIdsobj[j]+",";   }
                }   
                dialids=dialids.substring(0,dialids.length-1);
                hdnDiaCmprIdsobj.value =dialids;   
                createCookie(hdnDiaCmprIdsobj.value);          
            }                   
     }
}

function CollectCompareIds(from,ID)
{   
    var diaidlist="";
    var arrDiaID = new Array();
    var arrDiaID1 = new Array();
    var flag = false;
    var hdnDiaCmprIdsobj = document.getElementById("ctl00_ContentPlaceHolder1_Template5Search1_hdnDiaCmprIds");
    var hdnDiaCmprIds = hdnDiaCmprIdsobj.value;
        
    var hdnfrom = document.getElementById("ctl00_Bottomnav_include1_hdnfrom");
    var frm = document.forms["aspnetForm"];
        if(from=='REC')        
            chkcollection = frm.elements["chk"];        
        if(from=='NUP')        
            chkcollection = frm.elements["chkNUP"];
        if(hdnfrom!=null)
                hdnfrom.value = from;
        if(chkcollection)
        {
              //Changes for comparison across pages
              hdnDiaCmprIds = hdnDiaCmprIdsobj.value;
              var remstr1 = "";
              var remstr2 = "";
              var remstr3 = "";
              var remstr4 = "";  
              var repl = "";
              var tworepl = "";
              
              for (var i=0; i < chkcollection.length; i++)
              {   
                  if (chkcollection[i].checked)
                  {     
                        if(i==chkcollection.length)
                        {
                            if(hdnDiaCmprIds.indexOf(chkcollection[i].value)==-1)
                                hdnDiaCmprIds += chkcollection[i].value + ",";
                        }
                        else
                        {   
                            var ndx = hdnDiaCmprIds.search(/,/);
                            if(ndx==-1)
                            {
                                if(hdnDiaCmprIds.indexOf(chkcollection[i].value)==-1)
                                    hdnDiaCmprIds += "," + chkcollection[i].value + ",";                            
                            }
                            else
                            {
                                if(hdnDiaCmprIds.indexOf(chkcollection[i].value)==-1)
                                    hdnDiaCmprIds += "," + chkcollection[i].value + ",";
                            }
                        }
                        flag = true;
                  }
                  if(chkcollection[i].checked==false)
                  { 
                    remstr4 = chkcollection[i].value;
                    if(hdnDiaCmprIds!="")
                    {
                        hdnDiaCmprIds = hdnDiaCmprIds.replaceAll(remstr4,',');
                    }
                  }
              }
              arrDiaID = hdnDiaCmprIds.split(",");              
              for(var k=0;k<arrDiaID.length;k++)
              {
                if(arrDiaID[k]!=null && arrDiaID[k]!="")
                    arrDiaID1[k] = arrDiaID[k];
              }
              arrDiaID = null;
              arrDiaID = arrDiaID1;
              for(var j=0;j<arrDiaID.length;j++)
              {
                if(j==arrDiaID.length-1)
                {
                    if(arrDiaID[j]!=null && arrDiaID[j]!="")
                        diaidlist += arrDiaID[j];
                }
                else
                {
                    if(arrDiaID[j]!=null)
                    {
                        if(arrDiaID[j]!="")
                            diaidlist += arrDiaID[j] + ",";
                    }
                }
              }
                hdnDiaCmprIdsobj.value =  diaidlist;
createCookie(hdnDiaCmprIdsobj.value);
        }
}
String.prototype.replaceAll=function(s1, s2) {return this.split(s1).join(s2)}
function SetCompareParameter(from)
{      
    var diaidlist="";
    var arrDiaID = new Array();
    var flag = false;
    var hdnDiaCmprIds = "";
    var hdnDiaCmprIdsobj = document.getElementById("ctl00_ContentPlaceHolder1_Template5Search1_hdnDiaCmprIds");

                if(hdnDiaCmprIdsobj.value!="")
                {
                    diaidlist = hdnDiaCmprIdsobj.value;
                    Templates_uc_Template5SearchLPGSWA.setCompareDiaIds(diaidlist);
                    flag = true;
                }

              if(flag==false || diaidlist=="")
              {
                alert("Please select diamonds to compare.");
                return;
              }
              
          include_bottomnavintpg.GetDiamondComparisonDatac(from,callbackremovecompare);
}
var Index1;
var strSize="";
    function SethdnP(page)
    {
        document.getElementById("ctl00_ContentPlaceHolder1_Template5Search1_hdnpageno").value = page;
        sortfilter();
    }
    function SethdnS(shapeval)
    {    
        document.getElementById("ctl00_ContentPlaceHolder1_Template5Search1_hdnshape").value = shapeval;
        sortfilter();
    }
    function funccertified()
    {
        //document.getElementById("Template5Search1_hdnsort").value = sortval;
        if(document.getElementById("ctl00_ContentPlaceHolder1_Template5Search1_chkcertified").checked == true)
        {
            document.getElementById("ctl00_ContentPlaceHolder1_Template5Search1_spancerti").innerHTML = "Certified";
        }   
        else    
        {
            document.getElementById("ctl00_ContentPlaceHolder1_Template5Search1_spancerti").innerHTML = "Un-certified";
        }    
        sortfilter();
    }

    function hdnShape(shapeval)
    {
        document.getElementById("ctl00_ContentPlaceHolder1_Template5Search1_hdnshape").value = shapeval;
        
        document.getElementById("Round").style.display = 'none';
        document.getElementById("Princess").style.display = 'none';
        document.getElementById("Emerald").style.display = 'none';
        document.getElementById("Oval").style.display = 'none';
        document.getElementById("Heart").style.display = 'none';
        document.getElementById("Pear").style.display = 'none';
        document.getElementById("Cushion").style.display = 'none';
        
        document.getElementById("ctl00_ContentPlaceHolder1_Template5Search1_shape1").innerHTML="<div class='text'>Round</div>";
        document.getElementById("ctl00_ContentPlaceHolder1_Template5Search1_shape2").innerHTML="<div class='text'>Princess</div>";
        document.getElementById("ctl00_ContentPlaceHolder1_Template5Search1_shape3").innerHTML="<div class='text'>Emerald</div>";
        document.getElementById("ctl00_ContentPlaceHolder1_Template5Search1_shape4").innerHTML="<div class='text'>Oval</div>";
        document.getElementById("ctl00_ContentPlaceHolder1_Template5Search1_shape5").innerHTML="<div class='text'>Heart</div>";
        document.getElementById("ctl00_ContentPlaceHolder1_Template5Search1_shape6").innerHTML="<div class='text'>Pear</div>";
        document.getElementById("ctl00_ContentPlaceHolder1_Template5Search1_shape7").innerHTML="<div class='text'>Cushion</div>";
        
        document.getElementById ("ctl00_ContentPlaceHolder1_Template5Search1_shape11").innerHTML="<img src="+ Strpath +"'images/ShapesLarge/round.gif' alt='Round'/>";
        document.getElementById ("ctl00_ContentPlaceHolder1_Template5Search1_shape22").innerHTML="<img src="+ Strpath +"'images/ShapesLarge/princess.gif' alt='Princess'/>";
        document.getElementById ("ctl00_ContentPlaceHolder1_Template5Search1_shape33").innerHTML="<img src="+ Strpath +"'images/ShapesLarge/emerald.gif' alt='Emerald'/>";
        document.getElementById ("ctl00_ContentPlaceHolder1_Template5Search1_shape44").innerHTML="<img src="+ Strpath +"'images/ShapesLarge/oval.gif' alt='Oval'/>";
        document.getElementById ("ctl00_ContentPlaceHolder1_Template5Search1_shape55").innerHTML="<img src="+ Strpath +"'images/ShapesLarge/heart.gif' alt='Heart'/>";
        document.getElementById ("ctl00_ContentPlaceHolder1_Template5Search1_shape66").innerHTML="<img src="+ Strpath +"'images/ShapesLarge/pear.gif' alt='Pear'/>";
        document.getElementById ("ctl00_ContentPlaceHolder1_Template5Search1_shape77").innerHTML="<img src="+ Strpath +"'images/ShapesLarge/cushion.gif' alt='Cushion'/>";
        
        if(shapeval == "Round")
        {            
            document.getElementById("ctl00_ContentPlaceHolder1_Template5Search1_Round").style.display = 'inline';    
            document.getElementById("ctl00_ContentPlaceHolder1_Template5Search1_shape1").innerHTML="<div style='width:118px; height:auto; text-align:center; float:left; font-weight:bold; font-family:Arial; color:#587f17'>Round</div>";         
            document.getElementById ("ctl00_ContentPlaceHolder1_Template5Search1_shape11").innerHTML="<img src="+ Strpath +"'images/ShapesLarge/round.gif' alt='Round' style='border:1px solid #587f17'/>";
        }
        if(shapeval == "Princess")
        {
            document.getElementById("ctl00_ContentPlaceHolder1_Template5Search1_Princess").style.display = 'inline';   
            document.getElementById("ctl00_ContentPlaceHolder1_Template5Search1_shape2").innerHTML="<div style='width:118px; height:auto; text-align:center; float:left; font-weight:bold; font-family:Arial; color:#587f17'>Princess</div>";                     
            document.getElementById ("ctl00_ContentPlaceHolder1_Template5Search1_shape22").innerHTML="<img src="+ Strpath +"'images/ShapesLarge/princess.gif' alt='Princess' style='border:1px solid #587f17'/>";
        }
        if(shapeval == "Emerald")
        {            
            document.getElementById("ctl00_ContentPlaceHolder1_Template5Search1_Emerald").style.display = 'inline'; 
            document.getElementById("ctl00_ContentPlaceHolder1_Template5Search1_shape3").innerHTML="<div style='width:118px; height:auto; text-align:center; float:left; font-weight:bold; font-family:Arial; color:#587f17'>Emerald</div>";
            document.getElementById ("ctl00_ContentPlaceHolder1_Template5Search1_shape33").innerHTML="<img src="+ Strpath +"'images/ShapesLarge/emerald.gif' alt='Emerald' style='border:1px solid #587f17'/>";
        }
        if(shapeval == "Oval")
        {
            document.getElementById("ctl00_ContentPlaceHolder1_Template5Search1_Oval").style.display = 'inline';                        
            document.getElementById("ctl00_ContentPlaceHolder1_Template5Search1_shape4").innerHTML="<div style='width:118px; height:auto; text-align:center; float:left; font-weight:bold; font-family:Arial; color:#587f17'>Oval</div>";
            document.getElementById ("ctl00_ContentPlaceHolder1_Template5Search1_shape44").innerHTML="<img src="+ Strpath +"'images/ShapesLarge/oval.gif' alt='Oval' style='border:1px solid #587f17'/>";
        }
        if(shapeval == "Heart")
        {            
            document.getElementById("ctl00_ContentPlaceHolder1_Template5Search1_Heart").style.display = 'inline'; 
            document.getElementById("ctl00_ContentPlaceHolder1_Template5Search1_shape5").innerHTML="<div style='width:118px; height:auto; text-align:center; float:left; font-weight:bold; font-family:Arial; color:#587f17'>Heart</div>";
            document.getElementById ("ctl00_ContentPlaceHolder1_Template5Search1_shape55").innerHTML="<img src="+ Strpath +"'images/ShapesLarge/heart.gif' alt='Heart' style='border:1px solid #587f17'/>";
        }
        if(shapeval == "Pear")
        {
            document.getElementById("ctl00_ContentPlaceHolder1_Template5Search1_Pear").style.display = 'inline';  
            document.getElementById("ctl00_ContentPlaceHolder1_Template5Search1_shape6").innerHTML="<div style='width:118px; height:auto; text-align:center; float:left; font-weight:bold; font-family:Arial; color:#587f17'>Pear</div>";                      
            document.getElementById ("ctl00_ContentPlaceHolder1_Template5Search1_shape66").innerHTML="<img src="+ Strpath +"'images/ShapesLarge/pear.gif' alt='Pear' style='border:1px solid #587f17'/>";
        }
        if(shapeval == "Cushion")
        {            
            document.getElementById("ctl00_ContentPlaceHolder1_Template5Search1_Cushion").style.display = 'inline'; 
            document.getElementById("ctl00_ContentPlaceHolder1_Template5Search1_shape7").innerHTML="<div style='width:118px; height:auto; text-align:center; float:left; font-weight:bold; font-family:Arial; color:#587f17'>Cushion</div>";
            document.getElementById ("ctl00_ContentPlaceHolder1_Template5Search1_shape77").innerHTML="<img src="+ Strpath +"'images/ShapesLarge/cushion.gif' alt='Cushion' style='border:1px solid #587f17'/>";
        }
        sortfilter();
    }
    function hdnSort()
    {
        //document.getElementById("Template5Search1_hdnsort").value = sortval;
        sortfilter();
    }
    function hdnCarat()
    {
        //document.getElementById("Template5Search1_hdncarat").value = caratval;
        sortfilter();
    }
    function hdnSize()
    {        
        var sshape=document.getElementById("ctl00_ContentPlaceHolder1_Template5Search1_hdnshape").value;
        if(sshape=="Round")
        {
            Index1 = document.getElementById("ctl00_ContentPlaceHolder1_Template5Search1_drpSize1").selectedIndex;
            strSize = document.getElementById("ctl00_ContentPlaceHolder1_Template5Search1_drpSize1").options[Index1].value;        
        }
        else if(sshape=="Princess")
        {
            Index1 = document.getElementById("ctl00_ContentPlaceHolder1_Template5Search1_drpSize2").selectedIndex;
            strSize = document.getElementById("ctl00_ContentPlaceHolder1_Template5Search1_drpSize2").options[Index1].value;        
        }
        else if(sshape=="Emerald")
        {
            Index1 = document.getElementById("ctl00_ContentPlaceHolder1_Template5Search1_drpSize3").selectedIndex;
            strSize = document.getElementById("ctl00_ContentPlaceHolder1_Template5Search1_drpSize3").options[Index1].value;        
        }
        else if(sshape=="Oval")
        {
            Index1 = document.getElementById("ctl00_ContentPlaceHolder1_Template5Search1_drpSize4").selectedIndex;
            strSize = document.getElementById("ctl00_ContentPlaceHolder1_Template5Search1_drpSize4").options[Index1].value;        
        }
        else if(sshape=="Heart")
        {
            Index1 = document.getElementById("ctl00_ContentPlaceHolder1_Template5Search1_drpSize5").selectedIndex;
            strSize = document.getElementById("ctl00_ContentPlaceHolder1_Template5Search1_drpSize5").options[Index1].value;        
        }
        else if(sshape=="Pear")
        {
            Index1 = document.getElementById("ctl00_ContentPlaceHolder1_Template5Search1_drpSize6").selectedIndex;
            strSize = document.getElementById("ctl00_ContentPlaceHolder1_Template5Search1_drpSize6").options[Index1].value;        
        }
        else if(sshape=="Cushion")
        {
            Index1 = document.getElementById("ctl00_ContentPlaceHolder1_Template5Search1_drpSize7").selectedIndex;
            strSize = document.getElementById("ctl00_ContentPlaceHolder1_Template5Search1_drpSize7").options[Index1].value;        
        }
        //document.getElementById("Template5Search1_hdnsize").value = sizeval;
        sortfilter();
    }
 function sortfilter()
    {   
        
        var shapeval = document.getElementById("ctl00_ContentPlaceHolder1_Template5Search1_hdnshape").value;           
        var catid=CatID;
        var pagesel = document.getElementById("ctl00_ContentPlaceHolder1_Template5Search1_hdnpageno").value;
        if(pagesel=="")
        {
            pagesel="1";
        }
        var Index1 = document.getElementById("ctl00_ContentPlaceHolder1_Template5Search1_drpSize1").selectedIndex;
        var strSize = document.getElementById("ctl00_ContentPlaceHolder1_Template5Search1_drpSize1").options[Index1].value;
        //var strSize=document.getElementById("ctl00_ContentPlaceHolder1_Template5Search1_hdnsize").value;
        if(strSize == "select")
        {
            strSize = "0";
        }
        if(strSize=="")
        {
            strSize = "0";
        }	
        //var strSize=document.getElementById("ctl00_ContentPlaceHolder1_Template5Search1_hdnsizel").value;
        if(strSize == "select")
        {
            strSize = "0";
        }
        if(strSize=="")
        {
            strSize = "0";
        }
	//alert(strSize);
        var Index2 = document.getElementById("ctl00_ContentPlaceHolder1_Template5Search1_drpCarat").selectedIndex;
        var strCarat = document.getElementById("ctl00_ContentPlaceHolder1_Template5Search1_drpCarat").options[Index2].value;
        if(strCarat == "select" || strCarat == "")
        {
            strCarat = "0";
        }

        var Index3 = document.getElementById("ctl00_ContentPlaceHolder1_Template5Search1_drpsort").selectedIndex;
        var strSort = document.getElementById("ctl00_ContentPlaceHolder1_Template5Search1_drpsort").options[Index3].value;   
        
        var strCert="true";
        if(document.getElementById("ctl00_ContentPlaceHolder1_Template5Search1_chkcertified").checked== false)
        {
            strCert="false";
        }
        var urlpath = window.location.href;         
 //       var path=urlpath.split("/");        
//        var urlpath="<%=strPath%>"+path[3]+"/";
//        window.location=urlpath+catid+"/"+shapeval+"/"+strSort+"/"+strCert+"/"+strSize+"/"+strCarat+"/"+pagesel;
        
        //var urlpath2=urlpath.split("?");
        //var path=urlpath2[1].split("&");
        //window.location=urlpath2[0]+"?"+path[0]+"&"+path[1]+"&Shape="+shapeval+"&Sort="+strSort+"&Cert="+strCert+"&Size="+strSize+"&Carat="+strCarat+"&Page="+pagesel;
	var urlpath = window.location.href;         
        var path=urlpath.split("/");        
        var urlpath=Strpath+path[3]+"/";
        window.location=urlpath+catid+"/"+shapeval+"/"+strSort+"/"+strCert+"/"+strSize+"/"+strCarat+"/"+pagesel;   
 }
        
        function callbackquery(resquery)
        {        
            var pagesel = document.getElementById("hdnpagesel").value;
            document.getElementById("Template5Search1_show_items").value = resquery.value;
            setTimeout("getdatadisplayItem('"+pagesel+"')", 2000);
        }
        
        function SearchMetal1(metal,from,to)
        {
                                   
            var pagesel = document.getElementById("hdnpagesel").value;            
            var Index1 = document.getElementById("Template5Search1_drpgemstone").selectedIndex;
            var strGemstone = document.getElementById("Template5Search1_drpgemstone").options[Index1].value;
            if(strGemstone == "select")
            {
                strGemstone = "";
            }
            
            var Index2 = document.getElementById("Template5Search1_drpcolor").selectedIndex;
            var strColor = document.getElementById("Template5Search1_drpcolor").options[Index2].value;
            if(strColor == "select")
            {
                strColor = "";
            }
            
            var Index3 = document.getElementById("Template5Search1_drpsort").selectedIndex;
            var strSort = document.getElementById("Template5Search1_drpsort").options[Index3].value;
            var order_by = "asc"; 
            if(strSort == "select")
            {
              order_by = "asc";
            }
            else if(strSort == "LTH")
            {
                order_by = "asc";
            }
            else if(strSort == "HTL")
            {
                order_by = "desc";
            }
            else if(strSort == "PP")
            {
              order_by = "";
            }                
             
            if(from == "" && to == "")
            {
                document.getElementById("Template5Search1_show_items").value = "select distinct H.Item_ID, H.Item_name,H.Item_Price, H.Template_ID, H.Item_Image, isnull(IC.[order],'99') as Priority, H.IsRecommended, H.Item_Seo_link, H.NumberDays from Hitsview as H left outer join ItemAttribute_Gem_View as iagv on H.Item_id=iagv.Item_id left outer join ItemAttribute_Color_View as iacv on H.Item_id=iacv.Item_id LEFT OUTER JOIN ItemOrderbycatg as IC ON H.Item_id = IC.Item_Id and IC.Cat_ID = "+ CatID +" where H.Cat_id = "+ CatID +" and H.Item_Price >= 0 and (iacv.item_id is null or iacv.Item_Attribute_Value like '%" + strColor + "%')and (iagv.item_id is null or iagv.Item_Attribute_Value like '%" + strGemstone + "%')order by H.Item_Price "+ order_by;
                
                setTimeout("getdatadisplayItem('"+pagesel+"')", 2000);
            }
            else if(from != "" && to == "")
            {
             document.getElementById("Template5Search1_show_items").value = "select distinct H.Item_ID, H.Item_name,H.Item_Price, H.Template_ID, H.Item_Image, isnull(IC.[order],'99') as Priority, H.IsRecommended, H.Item_Seo_link, H.NumberDays from Hitsview as H left outer join ItemAttribute_Gem_View as iagv on H.Item_id=iagv.Item_id left outer join ItemAttribute_Color_View as iacv on H.Item_id=iacv.Item_id LEFT OUTER JOIN ItemOrderbycatg as IC ON H.Item_id = IC.Item_Id and IC.Cat_ID = "+ CatID +" where H.Cat_id = "+ CatID +" and H.Item_Price >= " + from + " and (iacv.item_id is null or iacv.Item_Attribute_Value like '%" + strColor + "%')and (iagv.item_id is null or iagv.Item_Attribute_Value like '%" + strGemstone + "%')order by H.Item_Price "+ order_by;
             setTimeout("getdatadisplayItem('"+pagesel+"')", 2000);                
            }
            else
            {
             document.getElementById("Template5Search1_show_items").value = "select distinct H.Item_ID, H.Item_name,H.Item_Price, H.Template_ID, H.Item_Image, isnull(IC.[order],'99') as Priority, H.IsRecommended, H.Item_Seo_link, H.NumberDays from Hitsview as H left outer join ItemAttribute_Gem_View as iagv on H.Item_id=iagv.Item_id left outer join ItemAttribute_Color_View as iacv on H.Item_id=iacv.Item_id LEFT OUTER JOIN ItemOrderbycatg as IC ON H.Item_id = IC.Item_Id and IC.Cat_ID = "+ CatID +" where H.Cat_id = "+ CatID +" and (H.Item_Price >= " + from + " and H.Item_Price <= " + to + ") and (iacv.item_id is null or iacv.Item_Attribute_Value like '%" + strColor + "%')and (iagv.item_id is null or iagv.Item_Attribute_Value like '%" + strGemstone + "%')order by H.Item_Price "+ order_by;
             setTimeout("getdatadisplayItem('"+pagesel+"')", 2000);
            }
        }

function GetSearchCriteria()
{
    
        strQurey = document.getElementById("Template5Search1_show_items").value;
        Templates_uc_SearchResultLPGS.GetTotalRecords(strQurey,GetSearchCallBack);
        setfocus();
}

function GetSearchCallBack(response)
{ var Ser_Price,Ser_Material,Ser_Prod,Ser_Metal;
    try
    {
         var w = document.getElementById("Template5Search1_DDProduct").selectedIndex;
         Ser_Prod = document.getElementById("Template5Search1_DDProduct").options[w].text;

    }catch(err){Ser_Prod="";}
    try
    {
        var w = document.getElementById("Template5Search1_DDMaterial").selectedIndex;
         Ser_Material = document.getElementById("Template5Search1_DDMaterial").options[w].text;

    }catch(err){Ser_Material=""; }
    try
    {
        var w = document.getElementById("Template5Search1_DDMetal").selectedIndex;
         Ser_Metal = document.getElementById("Template5Search1_DDMetal").options[w].text;

    }catch(err){ Ser_Metal=""; }
    try
    {
        var w = document.getElementById("Template5Search1_DDPrice").selectedIndex;
         Ser_Price = document.getElementById("Template5Search1_DDPrice").options[w].text;

    }catch(err){ Ser_Price=""; }    
    try
    {
    //document.getElementById("TotalSearchRecords").innerHTML="There Are Total "+response.value + " " + Ser_Prod + Ser_Material + Ser_Metal +" Items Matching "+Ser_Price +" Your Search Criteria." ;
    }catch(err){}
    
}
    function color_change(colorvalue)
    {
        if(colorvalue == "select")
        {
            
        }
        else
        {
            document.getElementById("Template5Search1_show_items").value = "select ia.item_attribute_value,Item.Item_ID, Item.Item_name,Item.Item_Desc, Item.Item_Price, Item.Template_ID, Item.Item_Image from Item Item left outer join Item_attribute ia on Item.Item_id=ia.Item_id where Item.isActive = 'T' and Item.Item_ID in (select Item_ID from Item_ParentCategory  where Cat_ID = "+ CatID +") and item_attribute_value like '%"+colorvalue+"%'";
            setTimeout("getdatadisplayItem('1')", 2000);
        }
    }
    function gemstone_change(gemstonevalue)
    {   
        if(gemstonevalue == "select")
        {
            
        }
        else
        {
            document.getElementById("Template5Search1_show_items").value = "select ia.item_attribute_value,Item.Item_ID, Item.Item_name,Item.Item_Desc, Item.Item_Price, Item.Template_ID, Item.Item_Image from Item Item left outer join Item_attribute ia on Item.Item_id=ia.Item_id where Item.isActive = 'T' and Item.Item_ID in (select Item_ID from Item_ParentCategory  where Cat_ID = "+ CatID +") and item_attribute_value like '%"+gemstonevalue+"%'";
            setTimeout("getdatadisplayItem('1')", 2000);
        }
    }

    function pricerange_change(value)        
    {       
          if(value == 'select')
          {
          
          }  
          if(value=='LTH')
          {
          document.getElementById("Template5Search1_show_items").value = "select Item.Item_ID, Item.Item_name,Item.Item_Desc, Item.Item_Price, Item.Template_ID, Item.Item_Image from Item where Item.isActive = 'T' and Item_ID in (select Item_ID from Item_ParentCategory  where Cat_ID ="+ CatID +") order by Item_Price asc";
          setTimeout("getdatadisplayItem('1')", 2000);
          Templates_uc_SearchResultLPGS.DefaultedPrice(CatID,resp_price);
          }
          else if(value=='HTL')
          {
          document.getElementById("Template5Search1_show_items").value = "select Item.Item_ID, Item.Item_name,Item.Item_Desc, Item.Item_Price, Item.Template_ID, Item.Item_Image from Item where Item.isActive = 'T' and Item_ID in (select Item_ID from Item_ParentCategory  where Cat_ID ="+ CatID +") order by Item_Price desc";
          setTimeout("getdatadisplayItem('1')", 2000);
          Templates_uc_SearchResultLPGS.DefaultedPrice( CatID,resp_price);
          }
          else if(value == 'PP')
          {
          document.getElementById("Template5Search1_show_items").value = "select distinct H.Item_ID,H.Item_Desc, H.Item_name, H.Item_Price, H.Template_ID, H.Item_Image, isnull(IC.[order],'99') as Priority, H.IsRecommended, H.Item_Seo_link, H.NumberDays from Hitsview as H LEFT OUTER JOIN ItemOrderbycatg as IC ON H.Item_id = IC.Item_Id and IC.Cat_ID = 107 where H.Cat_id =107 order by H.NumberDays desc,priority asc";
          setTimeout("getdatadisplayItem('1')", 2000);
          Templates_uc_SearchResultLPGS.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 setajaxres()
    {
    
    //alert('hello');
    var frm=document.form1; 
    var Cat_ID=frm.Template5Search1_HCat_ID.value;
        
//alert("Searchval="+Searchval+"cat_id="+Cat_ID+"prrange="+PriceRange+"mat="+Mat+"MCat_ID="+MCat_ID+"Metal="+Metal+"materialselected="+MaterialSelected+"productselet="+ProductSelected+"metalselected="+MetalSelected+"prodsel"+prodsel+"matsal"+matsal);
Templates_uc_Template5SearchLPGSWA.getitemset('notset',Cat_ID,'notset','notset',Cat_ID,'',callgetitemset) //calling ajax function getitemset.
    }
    
    function OnSearchClick()
    { 
       
    var frm1=document.form1;  
    var Searchval1=frm1.Template5Search1_HSearchval.value;
    var Cat_ID1=frm1.Template5Search1_HCat_ID.value;
    var PriceRange=frm1.Template5Search1_HPrice.value;
    var PriceRangequery=frm1.Template5Search1_HPrice.value;
    var Mat=frm1.Template5Search1_HMat.value;
    var Metal=frm1.Template5Search1_HMetal.value;
    var MCat_ID1=frm1.Template5Search1_HMCat_ID.value;
    var prodsel="0";
    var matsal="";
   document.getElementById("DisplayLoading").style.visibility="visible";
    if(Searchval1=="notset")
        {
            var PriceRange="notset";          
        }
    else
        {
            var PriceRange=frm1.Template5Search1_DDPrice.options[frm1.Template5Search1_DDPrice.selectedIndex].value;
        }
    if(Searchval1=="M")
       {
            var MaterialSelected=frm1.Template5Search1_DDMaterial.options[frm1.Template5Search1_DDMaterial.selectedIndex].value;
       }
    else
       {
           var MaterialSelected="notset";
       }
    if(Searchval1=="P")
        {
            var ProductSelected=frm1.Template5Search1_DDProduct.options[frm1.Template5Search1_DDProduct.selectedIndex].value;
        }
       else 
        {
            var ProductSelected="notset";
        }
   //if(Metal=="notset")
   //     {
             var MetalSelected="notset";
   //     }
        //else
        //{
        //     var MetalSelected=frm1.Template5Search1_DDMetal.options[frm1.Template5Search1_DDMetal.selectedIndex].value;
        //}
    if(Cat_ID1 != "notset")
        {
            if (ProductSelected == "notset")
            {
                prodsel = Cat_ID1;
            }
            else
            {
                prodsel = ProductSelected;
            }
        }
        else
        {
            if (ProductSelected != "notset")
            {
                prodsel = ProductSelected;
            }            
        }
   
   if (Mat != "notset") //searchvalue==M
        {
       // alert("MaterialSelected="+MaterialSelected);
       //     matsal = Mat;
      //      alert("matsal="+matsal);
            if (MaterialSelected != "notset")
            {
                matsal = MaterialSelected;
            }
        } 
    else
      {
        // alert("else --MaterialSelected="+MaterialSelected);
            if (MaterialSelected != "notset")
                {
                    matsal = MaterialSelected;
                }
      }      
//alert("Searchval1="+Searchval1+"Cat_ID1="+Cat_ID1+"prrange="+PriceRange+"mat="+Mat+"MCat_ID1="+MCat_ID1+"Metal="+Metal+"materialselected="+MaterialSelected+"productselet="+ProductSelected+"metalselected="+MetalSelected+"prodsel"+prodsel+"matsal"+matsal);
Templates_uc_Template5SearchLPGSWA.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_Template5SearchLPGSWA.getitemset(Searchval1,Cat_ID1,PriceRange,MetalSelected,prodsel,matsal,SearchClickgetitemset) //calling ajax function getitemset.
        //return false;
    }
  


function callgetitemset(response) //getting response from ajax function call
    {//alert(response.value);
          document.getElementById("Template5Search1_show_items").value=response.value;
          setTimeout("getdatadisplayItem('1')", 10000);
    }
    function SearchClickgetitemset(response) //getting response from ajax function call
    {
           //alert(response.value);
          document.getElementById("Template5Search1_show_items").value=response.value;
          //getdatadisplayItem('1');
          setTimeout("getdatadisplayItem('1')", 2000);
    }
   function pricefill() //this function called in cs file.
    {
        var prdid=document.getElementById("Template5Search1_DDProduct").value;
        //alert("--prdid="+prdid+"--");
        Templates_uc_Template5SearchLPGSWA.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.
    {   
        try
        {
        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;
                    }
                }
     }
     catch(err){}
    }  