﻿var currentSelected="", strSelectedCriteria = "", IDDynamic = "SearchGrid1_", ImagePath = "./images/user_Images/",selectedShape, selectedShapeName, selectedShapeImage, selectedCriteriaD="", shapemastername, selectedCriteria="", selectedColorName, selectedColorImage, selectedColorMasterName, selectedCriteriaC="", selectedCutName, selectedCutImage, strCutName,strtempTop="",strtempLeft="",isshowTopControl=false;
var PassShape="";var Sequence = "";
var Cat_ID = 77;
function MM_preloadImages(arg,arg1) 
{ 
    var d=document; 
    if(d.images) 
    { 
        if(!d.MM_p) d.MM_p=new Array(); 
        if(!d.MM_p1) d.MM_p1=new Array(); 
        var i,j=d.MM_p.length; 
        a=arg.split(","); 
        b=arg.split(","); 
        for(i=0; i<a.length; i++) 
        { 
            if (a[i].indexOf("#")!=0) 
            { 
                d.MM_p1[j]=new Image; 
                d.MM_p1[j++].src=b[i]; 
                d.MM_p[j]=new Image; 
                d.MM_p[j++].src=a[i]; 
            } 
        } 
    } 
} 
function MM_findObj(n, d) 
{ 
    var p,i,x; 
    if(!d) d=document; 
    if((p=n.indexOf("?"))>0&&parent.frames.length) 
    {
        d=parent.frames[n.substring(p+1)].document; 
        n=n.substring(0,p);
    } 
    if(!(x=d[n])&&d.all) x=d.all[n]; 
    for (i=0;!x&&i<d.forms.length;i++) 
    x=d.forms[i][n]; 
    for(i=0;!x&&d.layers&&i<d.layers.length;i++) 
    x=MM_findObj(n,d.layers[i].document); 
    if(!x && d.getElementById) 
    x=d.getElementById(n); 
    return x; 
} 
function MM_findObj1(n, d) 
{ 
    var p,i,x; 
    if(!d) d=document; 
    if((p=n.indexOf("?"))>0&&parent.frames.length) 
    {
        d=parent.frames[n.substring(p+1)].document; 
        n=n.substring(0,p);
    } 
    if(!(x=d[n])&&d.all) x=d.all[n]; 
    for (i=0;!x&&i<d.forms.length;i++) 
    x=d.forms[i][n]; 
    for(i=0;!x&&d.layers&&i<d.layers.length;i++) 
    x=MM_findObj1(n,d.layers[i].document); 
    if(!x && d.getElementById) 
    x=d.getElementById(n); 
    return x; 
} 
function ShowHideSearchPanal(status) 
{ 
    try 
    { 
        if(GetClassName("tblSearchPanal")=="VISIBLE" || GetClassName("tblSearchPanal")=="VISIBLEFIREFOX") 
        { 
            SetSrc("imgControlShape","./images/showArrow.gif");
            SCursor("imgTopControl","default"); 
            document.getElementById("imgTopControl").title="";
            SetHide("tblSearchPanal"); 
            SetHide("tblCut"); 
            SetHide("tblColor"); 
            SetHide("tblSize"); 
            SetHide("IDDiamondDetail"); 
            SetHide("topControlPanal"); 
            CloseShowOptionTop(); 
        } 
        else 
        { 
            SetSrc("imgControlShape","./images/closeArrow.gif");
            SetVisible("tblSearchPanal"); 
            SCursor("imgTopControl","pointer");
            document.getElementById("imgTopControl").title="Click Here";
            SetHide("extrabar"); 
            SetHide("IDDiamondDetail");
        } 
        SLeftP("optionbyname",(findPosX(document.getElementById("tblDataGrid"))+"px")); 
        STopP("optionbyname",(findPosY(document.getElementById("img21"))-55+"px")); 
    } 
    catch(e){} 
} 
function IsNumeric(strString) 
{ 
    var strValidChars = "0123456789.", strChar, blnResult = true; 
    if (strString.length == 0) 
    return false; 
    for (i = 0; i < strString.length && blnResult == true; i++) 
    { 
        strChar = strString.charAt(i); 
        if (strValidChars.indexOf(strChar) == -1) 
        { 
            blnResult = false; 
        } 
    } 
    return blnResult; 
} 
document.onkeydown = KeyCheck; 
function KeyCheck(e) 
{ 
    try 
    { 
        var keyId = nn6?e.keyCode:event.keyCode; 
        if(keyId==13) 
        { 
            if(document.getElementById("tblSearchPanal").className=="VISIBLE") 
            { 
                getSearchResult('1','',''); 
            } 
        } 
    } 
    catch(evt){} 
} 
function changeClass() 
{ 
    try 
    { 
        var keyId = nn6?e.keyCode:event.keyCode; 
        if(keyId >= 46 && keyId <=57) 
        { 
            SetClassName("txtPriceFrom","bluetext"); 
        } 
        else 
        { 
            SetClassName("txtPriceFrom","errorMesage"); 
        } 
    } 
    catch(evt){} 
} 
function setPriceFrom(value) 
{ 
    SetCValue("hdnFrom_Price",GetCValue("txtPriceFrom")); 
    if(GetCValue("hdnFrom_Price")!="") 
    { } 
    else { } 
    eraseCookie("MsolSearch_PriceFrom"); 
    createCookie("MsolSearch_PriceFrom",GetCValue("hdnFrom_Price"),30);
} 
function setPriceTo(value) 
{ 
    SetCValue("hdnTo_Price",GetCValue("txtPriceTo")); 
    if(GetCValue("hdnTo_Price")!="") 
    { } 
    else 
    { } 
    eraseCookie("MsolSearch_PriceTo"); 
    createCookie("MsolSearch_PriceTo",GetCValue("hdnTo_Price"),30); 
} 
function setSizeFrom(value) 
{ 
    SetCValue("hdnFrom_Size",GetCValue("txtSizeFrom")); 
    if(GetCValue("hdnFrom_Size")!="") 
    { } 
    else 
    { } 
    eraseCookie("MsolSearch_SizeFrom"); 
    createCookie("MsolSearch_SizeFrom",GetCValue("hdnFrom_Size"),30); 
} 
function setSizeTo(value) 
{ 
    SetCValue("hdnTo_Size",GetCValue("txtSizeTo")); 
    if(GetCValue("hdnTo_Size")!="") 
    { } 
    else { } 
    eraseCookie("MsolSearch_SizeTo"); 
    createCookie("MsolSearch_SizeTo",GetCValue("hdnTo_Size"),30); 
} 
  
function onloadfun()
{
    try
    {
        FillScroller_html();
        if(strXslDetail==null || strXslDetail.trim()=="")
        {
            GetDetailXsl();
        }
        var flagload = false, strreadShape = readCookie("MsolSearch_ShapeId");
        if(strreadShape != null && strreadShape.trim()!="")
        {
            flagload = true;
            strreadShape = strreadShape.split(',');
            for(var i=0;i<strreadShape.length;i++)
            {
                SetSearch(strreadShape[i],'hdnFrom_ShapeId','SearchGrid1_lblShape','ShapeId','jpg','imgShape'); 
            } 
        } 
        var strreadCut = readCookie("MsolSearch_CutId"); 
        if(strreadCut != null && strreadCut.trim()!="") 
        { 
            flagload = true; strreadCut = strreadCut.split(','); 
            for(var i=0;i<strreadCut.length;i++) 
            { 
                SetSearch(strreadCut[i],'hdnFrom_Cut','SearchGrid1_lblCut','CutId','jpg','imgCut'); 
            } 
        } 
        var strreadColor = readCookie("MsolSearch_CutId"); 
        if(strreadColor != null && strreadColor.trim()!="") 
        { 
            flagload = true; strreadColor = strreadColor.split(','); 
            for(var i=0;i<strreadColor.length;i++) 
            { 
                SetSearch(strreadColor[i],'hdnFrom_Color','SearchGrid1_lblColor','ColorId','jpg','imgColor'); 
            } 
        } 
        if(readCookie("MsolSearch_SizeFrom")!=null) 
        { 
            flagload = true; 
            SetCValue("txtSizeFrom",readCookie("MsolSearch_SizeFrom")); 
            setSizeFrom(""); 
        } 
        if(readCookie("MsolSearch_SizeTo")!=null) 
        { 
            flagload = true; 
            SetCValue("txtSizeTo",readCookie("MsolSearch_SizeTo")); 
            setSizeTo(""); 
        } 
        if(readCookie("MsolSearch_PriceTo")!=null) 
        { 
            flagload = true; 
            SetCValue("txtPriceTo",readCookie("MsolSearch_PriceTo")); setPriceTo(""); 
        } 
        if(readCookie("MsolSearch_PriceFrom")!=null) 
        { 
            flagload = true; 
            SetCValue("txtPriceFrom",readCookie("MsolSearch_PriceFrom")); setPriceFrom(""); 
        } 
        var strreadClarity = readCookie("MsolSearch_ClarityId"); 
        if(strreadClarity != null && strreadClarity.trim()!="") 
        { 
            flagload = true; strreadClarity = strreadClarity.split(','); 
            for(var i=0;i<strreadClarity.length;i++) 
            { 
                SetSearch(strreadClarity[i],'hdn_Clarity','SearchGrid1_lblClarityText','ClarityId','gif','imgClarity'); 
            } 
        } 
        if(flagload == true) 
        { 
            strshapeId = GetCValue("hdnFrom_ShapeId"); 
            strcut = GetCValue("hdnFrom_Cut"); 
            strpriceFrom = GetCValue("hdnFrom_Price"); 
            strpriceTo = GetCValue("hdnTo_Price"); 
            strsizeFrom = GetCValue("hdnFrom_Size"); 
            strsizeTo = GetCValue("hdnTo_Size"); 
            strcolor = GetCValue("hdnFrom_Color"); 
            strclarity = GetCValue("hdn_Clarity"); 
            strpolish = GetCValue("hdnPolish"); 
            strsymmetry = GetCValue("hdnSymmetry"); 
            strdepth = GetCValue("hdnDepth"); strtable = 
            GetCValue("hdnTable"); 
            strfluorescence = GetCValue("hdnFluorescence"); 
            strPageNumber = (readCookie("Page_Number")!=null)?readCookie("Page_Number"):"1"; 
            strsearchtype = (readCookie("MsolSearchType")!=null)?readCookie("MsolSearchType"):""; 
            strGlobalSort = (readCookie("MsolSortCriteria")!=null)?readCookie("MsolSortCriteria"):""; 
            strGlobalAscDesc = (readCookie("MsolGlobalAscDesc")!=null)?readCookie("MsolGlobalAscDesc"):""; 
            uc_SearchResultGrid.GetSearchResult(strshapeId,strcut,strpriceFrom,strpriceTo,strsizeFrom,strsizeTo,strcolor,strclarity,strpolish,strsymmetry,strdepth,strtable,strfluorescence,strPageNumber,strGloabalPagging,strsearchtype,strGlobalSort,strGlobalAscDesc,callback_loadScroller); 
        } 
    }catch(e){alert("onloadfun"+e.message+"\n"+e.source);} 
} 
function callback_loadScroller(res) 
{ 
    var arr="", strtemp=null; 
    arr = res.value; 
    if(typeof(arr)=="object" && arr.length>0) 
    { 
        strXml = arr[0]; 
        if(strXml.trim()!="") 
        { 
            strScrollerPriceFrom = (parseFloat(arr[3])).toFixed(2); 
            strScrollerPriceTo = (parseFloat(arr[4])).toFixed(2); 
            arrPrice[0] = (parseFloat(arr[3])).toFixed(2); 
            arrPrice[1] = (parseFloat(arr[4])).toFixed(2); 
            strScrollerShape = arr[8];
            strScrollerSizeFrom = (parseFloat(arr[5])).toFixed(2); 
            strScrollerSizeTo = (parseFloat(arr[6])).toFixed(2); 
            SetScroller(); 
            var pagging = arr[2], j=pagging.indexOf("="), build_type = getURLParameters(); 
            SetVisible("tbl"); 
            SetVisible("tblDataGrid"); 
            SetVisible("tblInnerDataGrid"); 
            SetHide("tblSearchPanal"); 
            SetSrc("imgControlShape","./images/showArrow.gif"); 
            SetSrc("img3","./images/closeArrow.gif");
            if(readCookie("MsolScrollerPos")!=null) 
            { 
                var arrScrollerPos1 = readCookie("MsolScrollerPos").split(','); 
                arrScrollerPos[0][0] = arrScrollerPos1[0]; 
                arrScrollerPos[0][1] = arrScrollerPos1[1]; 
                arrScrollerPos[1][0] = arrScrollerPos1[2]; 
                arrScrollerPos[1][1] = arrScrollerPos1[3]; 
                arrScrollerPos[2][0] = arrScrollerPos1[4]; 
                arrScrollerPos[2][1] = arrScrollerPos1[5]; 
                arrScrollerPos[3][0] = arrScrollerPos1[6]; 
                arrScrollerPos[3][1] = arrScrollerPos1[7]; 
                arrScrollerPos[4][0] = arrScrollerPos1[8]; 
                arrScrollerPos[4][1] = arrScrollerPos1[9]; 
                arrScrollerPos[5][0] = arrScrollerPos1[10]; 
                arrScrollerPos[5][1] = arrScrollerPos1[11]; 
                if(arrScrollerPos[0][0].trim()!="") 
                { 
                    SHeightP("ImgScroller1TT",((arrScrollerPos[0][0]-8)+2 +"px")); 
                    STopP("ImgScroller1T",(((arrScrollerPos[0][0]*1)-16)+2 + "px")); 
                } 
                if(arrScrollerPos[0][1].trim()!="") 
                { 
                    SHeightP("ImgScroller1BB",((BPosition-arrScrollerPos[0][1]+ 8) +"px")); 
                    STopP("ImgScroller1BB",((arrScrollerPos[0][1]) + "px")); 
                } 
                if(arrScrollerPos[1][0].trim()!="") 
                { 
                    SHeightP("ImgScroller2TT",((arrScrollerPos[1][0]-8)+2 +"px")); 
                    STopP("ImgScroller2T",(((arrScrollerPos[1][0]*1)-16)+2 + "px")); 
                } 
                if(arrScrollerPos[1][1].trim()!="") 
                { 
                    SHeightP("ImgScroller2BB",((BPosition-arrScrollerPos[1][1]+ 8) +"px")); 
                    STopP("ImgScroller2BB",((arrScrollerPos[1][1]) + "px")); 
                } 
                if(arrScrollerPos[2][0].trim()!="") 
                { 
                    SHeightP("ImgScroller3TT",((arrScrollerPos[2][0]-8)+2 +"px")); 
                    STopP("ImgScroller3T",(((arrScrollerPos[2][0]*1)-16)+2 + "px")); 
                } 
                if(arrScrollerPos[2][1].trim()!="") 
                { 
                    SHeightP("ImgScroller3BB",((BPosition-arrScrollerPos[2][1]+ 8) +"px")); 
                    STopP("ImgScroller3BB",((arrScrollerPos[2][1]) + "px")); 
                } 
                if(arrScrollerPos[3][0].trim()!="") 
                { 
                    SHeightP("ImgScroller4TT",((arrScrollerPos[3][0]-8)+4 +"px")); 
                    STopP("ImgScroller4T",(((arrScrollerPos[3][0]*1)-16)+4 + "px")); 
                } 
                if(arrScrollerPos[3][1].trim()!="") 
                { 
                    SHeightP("ImgScroller4BB",((BPosition-arrScrollerPos[3][1]+ 8) +"px")); 
                    STopP("ImgScroller4BB",((arrScrollerPos[3][1]) + "px")); 
                } 
                if(arrScrollerPos[4][0].trim()!="") 
                { 
                    SHeightP("ImgScroller5TT",((arrScrollerPos[4][0]-8)+2 +"px")); 
                    STopP("ImgScroller5T",(((arrScrollerPos[4][0]*1)-16)+2 + "px")); 
                } 
                if(arrScrollerPos[4][1].trim()!="") 
                { 
                    SHeightP("ImgScroller5BB",((BPosition-arrScrollerPos[4][1]+ 8) +"px")); 
                    STopP("ImgScroller5BB",((arrScrollerPos[4][1]) + "px")); 
                } 
                if(arrScrollerPos[5][0].trim()!="") 
                { 
                    SHeightP("ImgScroller6TT",((arrScrollerPos[5][0]-8)+2 +"px")); 
                    STopP("ImgScroller6T",(((arrScrollerPos[5][0]*1)-16)+2 + "px")); 
                } 
                if(arrScrollerPos[5][1].trim()!="") 
                { 
                    SHeightP("ImgScroller6BB",((BPosition-arrScrollerPos[5][1]+ 8) +"px")); 
                    STopP("ImgScroller6BB",((arrScrollerPos[5][1]) + "px")); 
                } 
            } 
            SetCValue("VScrollerShapeId",((readCookie("MSOLC_Shape")!=null?readCookie("MSOLC_Shape"):strshapeId))); 
            SetCValue("VScrollerCut",((readCookie("MSOLC_Cut")!=null?readCookie("MSOLC_Cut"):strcut))); 
            SetCValue("VScrollerPriceFrom",((readCookie("MSOLC_PriceFrom")!=null?readCookie("MSOLC_PriceFrom"):strpriceFrom))); 
            SetCValue("VScrollerPriceTo",((readCookie("MSOLC_PriceTo")!=null?readCookie("MSOLC_PriceTo"):strpriceTo))); 
            SetCValue("VScrollerSizeFrom",((readCookie("MSOLC_SizeFrom")!=null?readCookie("MSOLC_SizeFrom"):strsizeFrom))); 
            SetCValue("VScrollerSizeTo",((readCookie("MSOLC_SizeTo")!=null?readCookie("MSOLC_SizeTo"):strsizeTo))); 
            SetCValue("VScrollerColor",((readCookie("MSOLC_Color")!=null?readCookie("MSOLC_Color"):strcolor))); 
            SetCValue("VScrollerClarity",((readCookie("MSOLC_Clarity")!=null?readCookie("MSOLC_Clarity"):strclarity))); 
            if(GetCValue("VScrollerPriceFrom")!="") 
            { 
                SetInnerHtml("spanPriceStartValue",("$"+GetCValue("VScrollerPriceFrom"))); 
            } 
            if(GetCValue("VScrollerPriceTo")!="") 
            { 
                SetInnerHtml("spanPriceFinalValue",("$"+GetCValue("VScrollerPriceTo"))); 
            } 
            if(GetCValue("VScrollerSizeFrom")!="") 
            { 
                SetInnerHtml("spanSizeStartValue",(GetCValue("VScrollerSizeFrom"))); 
            } 
            if(GetCValue("VScrollerSizeTo")!="") 
            { 
                SetInnerHtml("spanSizeFinalValue",(GetCValue("VScrollerSizeTo"))); 
            } 
            GetSearchResultScroller(strPageNumber,""); 
        } 
    } 
} 
function ShowOptionColumnTop(rowId,controlId) 
{ 
    if(GetChecked(controlId)==true) 
    { 
        SetVisible(rowId); 
    } 
    else 
    { 
        SetHide(rowId); 
    } 
} 

function showTopControl(sender) 
{
    try
    {
        if(isshowTopControl==false)
        {
            strtempTop = findPosY(sender)-40 +"px";
            strtempLeft = findPosX(sender)-263 +"px";
            uc_NavigatePanel.GetShowHideSearchPanel(callback_showTopControl);
        }
        else
        {
            if(GetClassName("tblSearchPanal") == "VISIBLE" || GetClassName("tblSearchPanal") == "VISIBLEFIREFOX") 
            { 
                if(GetClassName("topControlPanal") == "HIDE" || GetClassName("topControlPanal") == "HIDEFIREFOX") 
                { 
                    SLeftP("topControlPanal",(findPosX(sender)-263 +"px")); 
                    STopP("topControlPanal",(findPosY(sender)-40 +"px")); 
                    SetVisible("topControlPanal");
                }
                else{SetHide("topControlPanal");} 
            } 
            SetHide("tblCut"); 
            SetHide("tblColor");
            SetHide("tblSize");
        }
    }catch(e){AError("showTopControl:"+"\n"+e.message+"\n"+e.stack+"\n"+e.source);}
} 

function callback_showTopControl(res)
{
    try
    {
        if(res.value != null && res.value != "")
        {   
            SetInnerHtml("div_topControlPanal",res.value);
            isshowTopControl = true;
            if(GetClassName("tblSearchPanal") == "VISIBLE" || GetClassName("tblSearchPanal") == "VISIBLEFIREFOX") 
            { 
                if(GetClassName("topControlPanal") == "HIDE" || GetClassName("topControlPanal") == "HIDEFIREFOX") 
                { 
                    SLeftP("topControlPanal",strtempLeft); strtempLeft="";
                    STopP("topControlPanal",strtempTop); strtempTop = "";
                    SetVisible("topControlPanal");
                }
                else{SetHide("topControlPanal");} 
            } 
            SetHide("tblCut"); 
            SetHide("tblColor");
            SetHide("tblSize");
        }

    }catch(e){AError("callback_showTopControl:"+id+"\n"+e.message);}
}
function changeImage(status) 
{ 
    if(document.getElementById("topControlPanal").className=="HIDE") 
    { 
        if(status=="on") 
        { 
            SetSrc("imgTopControl","./images/chosse-basic-search.gif"); 
        } 
        else 
        { 
             SetSrc("imgTopControl","./images/chosse-basic-search.gif"); 
        } 
    } 
} 
function CloseShowOptionTop() { SetHide("topControlPanal"); } 
function showSearchData() 
{ 
    var shapeIdFrom=GetCValue("hdnFrom_ShapeId"); 
    var cutFrom=GetCValue("hdnFrom_Cut"); 
    var priceFrom=GetCValue("txtPriceFrom"); 
    var sizeFrom=GetCValue("txtSizeFrom"); 
    var colorFrom=GetCValue("hdnFrom_Color"); 
    var clarityFrom=GetCValue("hdnFrom_Clarity"); 
} 
function MM_swapImgRestore() 
{ 
    var i,x,a=document.MM_sr; 
    for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) 
    x.src=x.oSrc; 
} 
function MM_findObj(n, d) 
{ 
    var p,i,x; if(!d) d=document; 
    if((p=n.indexOf("?"))>0&&parent.frames.length) 
    {
        d=parent.frames[n.substring(p+1)].document;n=n.substring(0,p);
    } 
    if(!(x=d[n])&&d.all) x=d.all[n]; 
    for (i=0;!x&&i<d.forms.length;i++) 
    x=d.forms[i][n]; 
    for(i=0;!x&&d.layers&&i<d.layers.length;i++) 
    x=MM_findObj(n,d.layers[i].document); 
    if(!x && d.getElementById) 
        x=d.getElementById(n); 
    return x; 
} 
function MM_swapImage() 
{ 
    var i,j=0,x,a=MM_swapImage.arguments; 
    document.MM_sr=new Array; 
    for(i=0;i<(a.length-2);i+=3) 
    { 
        if ((x=MM_findObj(a[i]))!=null) 
        { 
            document.MM_sr[j++]=x; 
            if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2]; 
        } 
    } 
} 
var domainName="";
function GetImageSrc(imgSRC) 
{ 
    var temp = "", ImageID = ""; 
    temp = imgSRC.split("/"); 
    return temp[temp.length-1]; 
} 
function GetSelectImage(imgID,imgType,imgExt) 
{ 
    return imgID.substring(3,imgID.length)+imgType+imgExt; 
} 
function SetSearch(imgID,hiddenID,labelID,strCookieImageID,imgExt,DistnictID) 
{
    var SelectImageSrc="", DisplayValue = "", HiddenValue = "", arrImageID="", CurImage = GetImageSrc(document.getElementById(imgID).src), SelectImage = "", originalImageName = GetSelectImage(imgID,"_MouseOut.",imgExt), IDs = ""; 
    if(strSelectedCriteria=="") 
    { 
        strSelectedCriteria = imgID; 
        d = document.getElementById(imgID).attributes; 
        d.getNamedItem("alt").value ="Click Here to Deselect"; 
        d.getNamedItem("title").value ="Click Here to Deselect";
    } 
    else if(strSelectedCriteria.indexOf(imgID)==-1) 
    { 
        strSelectedCriteria += "," + imgID; 
        d = document.getElementById(imgID).attributes; 
        d.getNamedItem("alt").value ="Click Here to Deselect"; 
        d.getNamedItem("title").value ="Click Here to Deselect";
    } 
    else 
    { 
        arrImageID = strSelectedCriteria.split(","); 
        strSelectedCriteria=""; 
        var flag=true; 
        for(var i=0;i<arrImageID.length;i++) 
        { 
            if(arrImageID[i]!= imgID) 
            { 
                if(flag==true) 
                { 
                    strSelectedCriteria = arrImageID[i]; 
                } 
                else 
                { 
                    strSelectedCriteria += "," + arrImageID[i]; 
                } 
                flag=false; 
            } 
        } 
        d = document.getElementById(imgID).attributes; 
        d.getNamedItem("alt").value ="Click Here to Select"; 
        d.getNamedItem("title").value ="Click Here to Select"; 
    } 
    arrImageID = strSelectedCriteria.split(","); 
    var flag=true; 
    for(var i=0;i<arrImageID.length;i++) 
    { 
        if(arrImageID[i].indexOf(DistnictID)!=-1) 
        { 
            d = document.getElementById(arrImageID[i]).attributes; 
            if(flag==true) 
            { 
                DisplayValue = d.getNamedItem("displayvalue").value; 
                HiddenValue = d.getNamedItem("hiddenvalue").value; 
                IDs = arrImageID[i]; 
            } 
            else 
            { 
                DisplayValue += ", " + d.getNamedItem("displayvalue").value; 
                HiddenValue += "," + d.getNamedItem("hiddenvalue").value; 
                IDs += ","+arrImageID[i]; 
            } 
            flag=false; 
        } 
    } 
    SelectImage = GetSelectImage(imgID,"_Select.",imgExt); 
    var c = document.getElementById(imgID).style.borderColor;
   
    c = c.split(" ");
    if(typeof(c)=='array'|| typeof(c)=='object')
    {
        c = c[0];
    }
    if(c=="black")
    { 
        
        document.getElementById(imgID).style.borderColor="#FFFFFF";
    } 
    else 
    { 
        
        document.getElementById(imgID).style.borderColor="black";
    }
    
    document.getElementById(hiddenID).value = HiddenValue; 
    strCookieImageID = "MsolSearch_"+strCookieImageID; 
    eraseCookie(strCookieImageID); 
    createCookie(strCookieImageID,IDs,30); 
} 
function SetMouseOut(imageControlId,outImage,overImage,selectImage)
{
    var c = document.getElementById(imageControlId).style.borderColor;
   
    c = c.split(" ");
    if(typeof(c)=='array'|| typeof(c)=='object')
    {
        c = c[0];
    }
    
    if(c!="black")
    {
        document.getElementById(imageControlId).style.borderColor="#FFFFFF";
    }
}
function SetMouseOver(imageControlId,outImage,overImage,selectImage)
{   
    var c = document.getElementById(imageControlId).style.borderColor;
    c = c.split(" ");
    if(typeof(c)=='array'|| typeof(c)=='object')
    {
        c = c[0];
    }
    
    if(c!="black")
    {
        document.getElementById(imageControlId).style.borderColor="#999999";
    }
}

//function FilltxtPrice(ShapeName)
//{
//    var flagin = false;
//    var frm = document.forms["aspnetForm"];
//    var arrShapeName = new Array();     
//    var shape = "";
//    var check = ""; 
//    var uncheckedShapes = "";   
//    if(frm)
//    {
//        chkCollection = frm.elements["chk"];        
//        if(chkCollection)
//        {
//           for (var i=0; i < chkCollection.length; i++)
//           {
//               if (chkCollection[i].checked==true)
//               {
//                    flagin = true;
//                    arrShapeName[i] = chkCollection[i].value;
//               } //endif        
//               
//               if(chkCollection[i]!=null)
//               {
//                  if(i==chkCollection.length-1)
//                  {
//                    arrChkID = chkCollection[i].value.split(",")
//                    uncheckedShapes = uncheckedShapes + "'" + arrChkID[0] + "'";;
//                  }
//                  else
//                  {
//                    arrChkID = chkCollection[i].value.split(",")
//                    uncheckedShapes = uncheckedShapes + "'" + arrChkID[0] + "',";
//                  }
//               }
//           } //end for
//           
//           PassShape = "";
//           shape = "";
//           for(var j=0;j<arrShapeName.length;j++)
//           {
//                if(j==arrShapeName.length-1)
//                {   
//                    if(arrShapeName[j]!=null)
//                    {
//                        arrChkID = arrShapeName[j].split(",");
//                        shape = shape + "'" + arrChkID[0] + "'";                        
//                        PassShape += arrChkID[1];
//                    }
//                }
//                else
//                {   
//                    if(arrShapeName[j]!=null)
//                    {
//                        arrChkID1 = arrShapeName[j].split(",");
//                        shape = shape + "'" + arrChkID1[0] + "',";                        
//                        PassShape += arrChkID1[1] + ",";
//                    }
//                }
//           } //endfor
//           
//           if(flagin==false)
//           {
////                var PFrom = document.getElementById("txtPriceFrom");
////                var PTo = document.getElementById("txtPriceTo");
////                if(PFrom != null)
////                    PFrom.value = "";
////                if(PTo != null)
////                    PTo.value = "";
//                Search2.GetMinMaxPriceShape(uncheckedShapes,callbackFillPFT);
//           } //end if
//           
//           if(flagin==true)
//           {               
//                document.getElementById("hdnFrom_ShapeId").value = PassShape;
//                var trPriceLoading = document.getElementById("trPriceLoading");
//                if(trPriceLoading!=null)
//                {
//                    trPriceLoading.style.visibility = "visible";
//                    trPriceLoading.style.display = '';
//                }
//                Search2.GetMinMaxPriceShape(shape,callbackFillPFT);
//           }//end if
//        }//end if checkcollection
//    }//end if frm
//}//end function

function FilltxtPrice(ShapeName)
{
    var flagin = false;
    var frm = document.forms["aspnetForm"];
    var arrShapeName = new Array();     
    var shape = "";
    var check = ""; 
    var uncheckedShapes = "";   
    if(frm)
    {
        var chkCollection = frm.elements["chk"];        
        if(chkCollection)
        {
           var len = chkCollection.length;
           if(len != null)
           {    
               for (var i=0; i < len; i++)
               {
                   if (chkCollection[i].checked==true)
                   {
                        flagin = true;
                        arrShapeName[i] = chkCollection[i].value;
                   } //endif        
                   
                   if(chkCollection[i]!=null)
                   {
                      if(i==len-1)
                      {
                        arrChkID = chkCollection[i].value.split(",")
                        uncheckedShapes = uncheckedShapes + "'" + arrChkID[0] + "'";;
                      }
                      else
                      {
                        arrChkID = chkCollection[i].value.split(",")
                        uncheckedShapes = uncheckedShapes + "'" + arrChkID[0] + "',";
                      }
                   }
               } //end for
           }
           else
           {
               if (chkCollection.checked==true)
               {
                    flagin = true;
                    arrShapeName[0] = chkCollection.value;
               } //endif        
               
               if(chkCollection!=null)
               {  
                    arrChkID = chkCollection.value.split(",")
                    uncheckedShapes = uncheckedShapes + "'" + arrChkID[0] + "'";
               }
           }
           
           PassShape = "";
           shape = "";
           var shapelength = arrShapeName.length;
           if(shapelength != null && shapelength > 0)
           {
               for(var j=0;j<shapelength;j++)
               {
                    if(j==shapelength-1)
                    {   
                        if(arrShapeName[j]!=null)
                        {
                            arrChkID = arrShapeName[j].split(",");
                            shape = shape + "'" + arrChkID[0] + "'";                        
                            PassShape += arrChkID[1];
                        }
                    }
                    else
                    {   
                        if(arrShapeName[j]!=null)
                        {
                            arrChkID1 = arrShapeName[j].split(",");
                            shape = shape + "'" + arrChkID1[0] + "',";                        
                            PassShape += arrChkID1[1] + ",";
                        }
                    }
               } //endfor
           }
//           else
//           {    
//                if(arrShapeName[0]!=null)
//                {
//                    arrChkID = arrShapeName[0].split(",");
//                    shape = shape + "'" + arrChkID[0] + "'";                        
//                    PassShape += arrChkID[1];
//                }
//           }
           
           if(flagin==false)
           {
//                var PFrom = document.getElementById("txtPriceFrom");
//                var PTo = document.getElementById("txtPriceTo");
//                if(PFrom != null)
//                    PFrom.value = "";
//                if(PTo != null)
//                    PTo.value = "";
                Search2.GetMinMaxPriceShape(uncheckedShapes,callbackFillPFT);
           } //end if
           
           if(flagin==true)
           {               
                document.getElementById("hdnFrom_ShapeId").value = PassShape;
                var trPriceLoading = document.getElementById("trPriceLoading");
                if(trPriceLoading!=null)
                {
                    trPriceLoading.style.visibility = "visible";
                    trPriceLoading.style.display = '';
                }
                Search2.GetMinMaxPriceShape(shape,callbackFillPFT);
           }//end if
        }//end if checkcollection
    }//end if frm
}//end function

function callbackFillPFT(res)
{   
    if(res!=null)
    {
        var result = res.value;
        if(result!="")
        {
            var arrPriceFT;
            arrPriceFT = result.split(",");
            var PFrom = document.getElementById("txtPriceFrom")
            var PTo = document.getElementById("txtPriceTo")
            if(PFrom!=null)
            {
                PFrom.value = arrPriceFT[0];
                document.getElementById("hdnFrom_Price").value = arrPriceFT[0];
            }
            if(PTo != null)
            {
                PTo.value = arrPriceFT[1];
                document.getElementById("hdnTo_Price").value = arrPriceFT[1];
            }
            var trPriceLoading = document.getElementById("trPriceLoading");
            if(trPriceLoading!=null)
            {
                trPriceLoading.style.visibility = "hidden";
                trPriceLoading.style.display = "none";
            }
        }
    }
}
function SetSequenceParameters()
{
    Sequence = "S";
    setTimeout("window.location='SelectSetting.aspx?seq=" + Sequence + "&Cat_ID=" + Cat_ID + "'");
}
function SendSearchParameters(DefaultSearchIds)
{
        SetInnerHtml("priceError","");
        
        if (isNaN(GetCValue("txtPriceFrom"))==true) 
		{ 
			SetVisible("priceErrorRow"); 
			SetInnerHtml("priceError","Please Enter Valid Price or Leave Price fields blank"); 
			SetCValue("hdnFrom_Price",""); 
			SetClassName("txtPriceFrom","errorMesage"); 
			eraseCookie("MsolSearch_PriceFrom"); 
			createCookie("MsolSearch_PriceFrom",GetCValue("hdnFrom_Price"),30); 
			SetFocus("txtPriceFrom"); 
			return false; 
		} 
		else if ((GetCValue("txtPriceFrom"))< 0) 
		{ 
			SetVisible("priceErrorRow"); 
			SetInnerHtml("priceError","Please Enter Valid Price or Leave Price field blank"); 
			SetCValue("hdnFrom_Price",""); 
			SetClassName("txtPriceFrom","errorMesage"); 
			eraseCookie("MsolSearch_PriceFrom"); 
			createCookie("MsolSearch_PriceFrom",GetCValue("hdnFrom_Price"),30); 
			SetFocus("txtPriceFrom"); 
			return false; 
		} 
		else if (isNaN(GetCValue("txtPriceTo"))==true) 
		{ 
			SetVisible("priceErrorRow"); 
			SetInnerHtml("priceError","Please Enter Valid Price or Leave Price field blank"); 
			SetCValue("hdnTo_Price",""); 
			SetClassName("txtPriceTo","errorMesage"); 
			eraseCookie("MsolSearch_PriceTo"); 
			createCookie("MsolSearch_PriceTo",GetCValue("hdnTo_Price"),30); 
			SetFocus("txtPriceTo"); 
			return false; 
		} 
		else if ((GetCValue("txtPriceTo"))< 0) 
		{ 
			SetVisible("priceErrorRow"); 
			SetInnerHtml("priceError","Please Enter Valid Price or Leave Price fields blank"); 
			SetCValue("hdnTo_Price",""); 
			SetClassName("txtPriceTo","errorMesage"); 
			eraseCookie("MsolSearch_PriceTo"); 
			createCookie("MsolSearch_PriceTo",GetCValue("hdnTo_Price"),30); 
			SetFocus("txtPriceTo"); 
			return false; 
		}
		else
		{}
		
		if (GetCValue("txtPriceTo")!="") 
		{ 
			if(parseFloat(GetCValue("txtPriceTo"))< parseFloat(GetCValue("txtPriceFrom"))) 
			{ 
				SetVisible("priceErrorRow"); 
				SetInnerHtml("priceError","Please enter smaller value in first box and larger value in second box"); 
				SetCValue("hdnTo_Price",""); 
				SetClassName("txtPriceTo","errorMesage"); 
				eraseCookie("MsolSearch_PriceTo"); 
				createCookie("MsolSearch_PriceTo",GetCValue("hdnTo_Price"),30); 
				SetFocus("txtPriceTo"); 
				return false; 
			} 
		} 
        
    //  Code here for getting and sending the values
        var varShapes = document.getElementById("hdnFrom_ShapeId").value;
        if(varShapes=="")
            varShapes = DefaultSearchIds;
        var PFrom = document.getElementById("txtPriceFrom");
        var PTo = document.getElementById("txtPriceTo");
    //  The URL between the quotation marks needs to be changed.
        var destination = "SelectDiamond.aspx";
        
        var QueryString = null;
           try
           {    
                QueryString = location.href.substring ( location.href.indexOf ( "?" ) ); // get the QueryString from the URL
                QueryString = QueryString.split ( "&" );  // creates an array of Strings, e.g. "p=1"
                var i;
                for ( i = 0; i < QueryString.length; i++ ) 
                {
                    QueryString [ i ] = QueryString [ i ].split ( "=" ); // creates a name and value element for each parameter in the QueryString
                }
           }
           catch(e)
           {
                alert(e.message);
           }
           if(QueryString!=null)
           {
            //  Pause can be changed by specifying a different number of milliseconds.
                if(QueryString[0][1]!=null)
                    setTimeout("window.location='"+destination+ "?Seq=" + QueryString[0][1] + "&PF=" + PFrom.value + "&Cat_ID=" + Cat_ID + "&PT=" + PTo.value + "&Shape=" + varShapes  + "'",0);
                else
                {
                    setTimeout("window.location='"+destination+ "?Seq=D&PF=" + PFrom.value + "&Cat_ID=" + Cat_ID + "&PT=" + PTo.value + "&Shape=" + varShapes  + "'",0);
                }    
           }
           else
                setTimeout("window.location='"+destination+ "?Seq=D&PF=" + PFrom.value + "&Cat_ID=" + Cat_ID + "&PT=" + PTo.value + "&Shape=" + varShapes  + "'",0);
        return true;
}

function SendSearchParametersEarrings(DefaultSearchIds)
{
        SetInnerHtml("priceError","");
        
        if (isNaN(GetCValue("txtPriceFrom"))==true) 
		{ 
			SetVisible("priceErrorRow"); 
			SetInnerHtml("priceError","Please Enter Valid Price or Leave Price fields blank"); 
			SetCValue("hdnFrom_Price",""); 
			SetClassName("txtPriceFrom","errorMesage"); 
			eraseCookie("MsolSearch_PriceFrom"); 
			createCookie("MsolSearch_PriceFrom",GetCValue("hdnFrom_Price"),30); 
			SetFocus("txtPriceFrom"); 
			return false; 
		} 
		else if ((GetCValue("txtPriceFrom"))< 0) 
		{ 
			SetVisible("priceErrorRow"); 
			SetInnerHtml("priceError","Please Enter Valid Price or Leave Price field blank"); 
			SetCValue("hdnFrom_Price",""); 
			SetClassName("txtPriceFrom","errorMesage"); 
			eraseCookie("MsolSearch_PriceFrom"); 
			createCookie("MsolSearch_PriceFrom",GetCValue("hdnFrom_Price"),30); 
			SetFocus("txtPriceFrom"); 
			return false; 
		} 
		else if (isNaN(GetCValue("txtPriceTo"))==true) 
		{ 
			SetVisible("priceErrorRow"); 
			SetInnerHtml("priceError","Please Enter Valid Price or Leave Price field blank"); 
			SetCValue("hdnTo_Price",""); 
			SetClassName("txtPriceTo","errorMesage"); 
			eraseCookie("MsolSearch_PriceTo"); 
			createCookie("MsolSearch_PriceTo",GetCValue("hdnTo_Price"),30); 
			SetFocus("txtPriceTo"); 
			return false; 
		} 
		else if ((GetCValue("txtPriceTo"))< 0) 
		{ 
			SetVisible("priceErrorRow"); 
			SetInnerHtml("priceError","Please Enter Valid Price or Leave Price fields blank"); 
			SetCValue("hdnTo_Price",""); 
			SetClassName("txtPriceTo","errorMesage"); 
			eraseCookie("MsolSearch_PriceTo"); 
			createCookie("MsolSearch_PriceTo",GetCValue("hdnTo_Price"),30); 
			SetFocus("txtPriceTo"); 
			return false; 
		}
		else
		{}
		
		if (GetCValue("txtPriceTo")!="") 
		{ 
			if(parseFloat(GetCValue("txtPriceTo"))< parseFloat(GetCValue("txtPriceFrom"))) 
			{ 
				SetVisible("priceErrorRow"); 
				SetInnerHtml("priceError","Please enter smaller value in first box and larger value in second box"); 
				SetCValue("hdnTo_Price",""); 
				SetClassName("txtPriceTo","errorMesage"); 
				eraseCookie("MsolSearch_PriceTo"); 
				createCookie("MsolSearch_PriceTo",GetCValue("hdnTo_Price"),30); 
				SetFocus("txtPriceTo"); 
				return false; 
			} 
		} 
        
    //  Code here for getting and sending the values
        var varShapes = document.getElementById("hdnFrom_ShapeId").value;
        if(varShapes=="")
            varShapes = DefaultSearchIds;
        var PFrom = document.getElementById("txtPriceFrom");
        var PTo = document.getElementById("txtPriceTo");
    //  The URL between the quotation marks needs to be changed.
        var destination = "SelectDiamondEarrings.aspx";
        
        var QueryString = null;
           try
           {    
                QueryString = location.href.substring ( location.href.indexOf ( "?" ) ); // get the QueryString from the URL
                QueryString = QueryString.split ( "&" );  // creates an array of Strings, e.g. "p=1"
                var i;
                for ( i = 0; i < QueryString.length; i++ ) 
                {
                    QueryString [ i ] = QueryString [ i ].split ( "=" ); // creates a name and value element for each parameter in the QueryString
                }
           }
           catch(e)
           {
                alert(e.message);
           }
           if(QueryString!=null)
           {
            //  Pause can be changed by specifying a different number of milliseconds.
                if(QueryString[0][1]!=null)
                    setTimeout("window.location='"+destination+ "?Seq=" + QueryString[0][1] + "&PF=" + PFrom.value + "&Cat_ID=" + Cat_ID + "&PT=" + PTo.value + "&Shape=" + varShapes  + "'",0);
                else
                {
                    setTimeout("window.location='"+destination+ "?Seq=D&PF=" + PFrom.value + "&Cat_ID=" + Cat_ID + "&PT=" + PTo.value + "&Shape=" + varShapes  + "'",0);
                }    
           }
           else
                setTimeout("window.location='"+destination+ "?Seq=D&PF=" + PFrom.value + "&Cat_ID=" + Cat_ID + "&PT=" + PTo.value + "&Shape=" + varShapes  + "'",0);
        return true;
}


function SendSearchParametersEarringsBD(DefaultSearchIds)
{
        SetInnerHtml("priceError","");
        
        if (isNaN(GetCValue("txtPriceFrom"))==true) 
		{ 
			SetVisible("priceErrorRow"); 
			SetInnerHtml("priceError","Please Enter Valid Price or Leave Price fields blank"); 
			SetCValue("hdnFrom_Price",""); 
			SetClassName("txtPriceFrom","errorMesage"); 
			eraseCookie("MsolSearch_PriceFrom"); 
			createCookie("MsolSearch_PriceFrom",GetCValue("hdnFrom_Price"),30); 
			SetFocus("txtPriceFrom"); 
			return false; 
		} 
		else if ((GetCValue("txtPriceFrom"))< 0) 
		{ 
			SetVisible("priceErrorRow"); 
			SetInnerHtml("priceError","Please Enter Valid Price or Leave Price field blank"); 
			SetCValue("hdnFrom_Price",""); 
			SetClassName("txtPriceFrom","errorMesage"); 
			eraseCookie("MsolSearch_PriceFrom"); 
			createCookie("MsolSearch_PriceFrom",GetCValue("hdnFrom_Price"),30); 
			SetFocus("txtPriceFrom"); 
			return false; 
		} 
		else if (isNaN(GetCValue("txtPriceTo"))==true) 
		{ 
			SetVisible("priceErrorRow"); 
			SetInnerHtml("priceError","Please Enter Valid Price or Leave Price field blank"); 
			SetCValue("hdnTo_Price",""); 
			SetClassName("txtPriceTo","errorMesage"); 
			eraseCookie("MsolSearch_PriceTo"); 
			createCookie("MsolSearch_PriceTo",GetCValue("hdnTo_Price"),30); 
			SetFocus("txtPriceTo"); 
			return false; 
		} 
		else if ((GetCValue("txtPriceTo"))< 0) 
		{ 
			SetVisible("priceErrorRow"); 
			SetInnerHtml("priceError","Please Enter Valid Price or Leave Price fields blank"); 
			SetCValue("hdnTo_Price",""); 
			SetClassName("txtPriceTo","errorMesage"); 
			eraseCookie("MsolSearch_PriceTo"); 
			createCookie("MsolSearch_PriceTo",GetCValue("hdnTo_Price"),30); 
			SetFocus("txtPriceTo"); 
			return false; 
		}
		else
		{}
		
		if (GetCValue("txtPriceTo")!="") 
		{ 
			if(parseFloat(GetCValue("txtPriceTo"))< parseFloat(GetCValue("txtPriceFrom"))) 
			{ 
				SetVisible("priceErrorRow"); 
				SetInnerHtml("priceError","Please enter smaller value in first box and larger value in second box"); 
				SetCValue("hdnTo_Price",""); 
				SetClassName("txtPriceTo","errorMesage"); 
				eraseCookie("MsolSearch_PriceTo"); 
				createCookie("MsolSearch_PriceTo",GetCValue("hdnTo_Price"),30); 
				SetFocus("txtPriceTo"); 
				return false; 
			} 
		} 
        
    //  Code here for getting and sending the values
        var varShapes = document.getElementById("hdnFrom_ShapeId").value;
        if(varShapes=="")
            varShapes = DefaultSearchIds;
        var PFrom = document.getElementById("txtPriceFrom");
        var PTo = document.getElementById("txtPriceTo");
    //  The URL between the quotation marks needs to be changed.
        var destination = "SelectDiamondEarringsBD.aspx";
        
        var QueryString = null;
           try
           {    
                QueryString = location.href.substring ( location.href.indexOf ( "?" ) ); // get the QueryString from the URL
                QueryString = QueryString.split ( "&" );  // creates an array of Strings, e.g. "p=1"
                var i;
                for ( i = 0; i < QueryString.length; i++ ) 
                {
                    QueryString [ i ] = QueryString [ i ].split ( "=" ); // creates a name and value element for each parameter in the QueryString
                }
           }
           catch(e)
           {
                alert(e.message);
           }
           if(QueryString!=null)
           {
            //  Pause can be changed by specifying a different number of milliseconds.
                if(QueryString[0][1]!=null)
                    setTimeout("window.location='"+destination+ "?Seq=" + QueryString[0][1] + "&PF=" + PFrom.value + "&Cat_ID=" + Cat_ID + "&PT=" + PTo.value + "&Shape=" + varShapes  + "'",0);
                else
                {
                    setTimeout("window.location='"+destination+ "?Seq=D&PF=" + PFrom.value + "&Cat_ID=" + Cat_ID + "&PT=" + PTo.value + "&Shape=" + varShapes  + "'",0);
                }    
           }
           else
                setTimeout("window.location='"+destination+ "?Seq=D&PF=" + PFrom.value + "&Cat_ID=" + Cat_ID + "&PT=" + PTo.value + "&Shape=" + varShapes  + "'",0);
        return true;
}


//MM_preloadImages(imageString,'');