﻿														
    var refPrice = new Array(1);
	
	refPrice[0] = new Array(13);	
	refPrice[0][0] = new Array(2);	// Price Difference Range
	refPrice[0][0][0] = 0;
	refPrice[0][0][1] = 100000;
	refPrice[0][1] = new Array(2);	// 1 To 8 is for Price Percentage range
	refPrice[0][1][0] = 0.0;
	refPrice[0][1][1] = 0.595;
	refPrice[0][2] = new Array(2);
	refPrice[0][2][0] = 0.595;
	refPrice[0][2][1] = 1.19;
	refPrice[0][3] = new Array(2);
	refPrice[0][3][0] = 1.19;
	refPrice[0][3][1] = 1.675;
	refPrice[0][4] = new Array(2);
	refPrice[0][4][0] = 1.675;
	refPrice[0][4][1] = 2.216;
	refPrice[0][5] = new Array(2);
	refPrice[0][5][0] = 2.216;
	refPrice[0][5][1] = 2.724;
	refPrice[0][6] = new Array(2);
	refPrice[0][6][0] = 2.724;
	refPrice[0][6][1] = 7.10;
	refPrice[0][7] = new Array(2);
	refPrice[0][7][0] = 7.10;
	refPrice[0][7][1] = 7.766;
	refPrice[0][8] = new Array(2);
	refPrice[0][8][0] = 7.766;
	refPrice[0][8][1] = 11.755;

    refPrice[0][9] = new Array(2);
	refPrice[0][9][0] = 11.755;
	refPrice[0][9][1] = 29.183;
	refPrice[0][10] = new Array(2);
	refPrice[0][10][0] = 29.183;
	refPrice[0][10][1] = 53.965;
	refPrice[0][11] = new Array(2);
	refPrice[0][11][0] = 53.965;
	refPrice[0][11][1] = 76.829;
	refPrice[0][12] = new Array(2);
	refPrice[0][12][0] = 76.829;
	refPrice[0][12][1] = 100;
			//PriceArray Documentation
			/*
			PriceArray[i][0] = Minimum Price
			PriceArray[i][1] = Maximum Price
			PriceArray[i][2] = Minimum Percentage
			PriceArray[i][3] = Maximum Percentage
														*/
			var PriceArray = new Array(1);
			PriceArray[0] = new Array(4);
			PriceArray[0][0] = 0;
			PriceArray[0][1] = 100000;  //Updated by Hatim
			PriceArray[0][2] = 0;
			PriceArray[0][3] = 100;
			//Price Array
			
			//Table Documentation
			/*
			TableArray[i][0] = Minimum Table
			TableArray[i][1] = Maximum Table
			TableArray[i][2] = Minimum Percentage
			TableArray[i][3] = Maximum Percentage
														*/
			var TableArray = new Array(1);
			TableArray[0] = new Array(4);
			TableArray[0][0] = 0;
			TableArray[0][1] = 100;  //Updated by Hatim
			TableArray[0][2] = 0;
			TableArray[0][3] = 100;
			//Table Array
			
			//Depth Documentation
			/*
			DepthArray[i][0] = Minimum Depth
			DepthArray[i][1] = Maximum Depth
			DepthArray[i][2] = Minimum Percentage
			DepthArray[i][3] = Maximum Percentage
														*/
			var DepthArray = new Array(1);
			DepthArray[0] = new Array(4);
			DepthArray[0][0] = 0;
			DepthArray[0][1] = 100;  //Updated by Hatim
			DepthArray[0][2] = 0;
			DepthArray[0][3] = 100;
			//Depth Array
			
			//---------------------- Slider Global Variables--------------//
			var SliderBarLeftRightDiff = 5;
			
			var SliderWidth = 16;
			var SliderDiff = 3;
			
			var flgSliderMovementLeft = true;
			//---------------------- Slider Global Variables--------------//
			
			//Extra Variables
			var DealerID="";
			var flgShareSorted = false;
			var flgSizeSorted = false;
            var flgClaritySorted = false;
            var flgColorSorted = false;
            var flgCutGradeSorted = false;
            var flgCertSorted = false;
            var flgPriceSorted = false;
			
			
			var dvDiamonds;	//Diamond DataView
			var flgRecordFecth=true;
			var flgZipcode=true;
			var OrderBy="fltPrice";
			var OrderType="Asc";
			var Shape="";
			//Hatim
			var Clarity="";
			var Color="";
			var ColorMin=71;
			var ColorMax=72;
			var CutGradeMin=1;
			var CutGradeMax=4;
			var ClarityMin=5;
			var ClarityMax=6;
			var InitialCaratMin=0.10;
			var InitialCaratMax=15.0;  //Updated line by Hatim
			var CaratMin=1.5;
			var CaratMax=2;
			var PriceMin=22100;
			var PriceMax=100000; 
			var InitialPriceMin = 0;	
			var InitialPriceMax = 100000;
			
			var Certificate="";
			var CutGrade="All"
			var DepthMin=0;
			var DepthMax=100;
			var TableMin=0;
			var TableMax=100;
			
			var MouseLeft=0;
			var MouseRight=0;
			//Common variables
			var sldMouseLeft=0;
			var sldMouseTop=0;
			//Color Slider's left Arrow variables
			var dosldColorLeftDrag = false;
			var sldColorLeftMinLeft=0;
			var sldColorLeftMaxLeft=0;			
			//Color slider's right Arrow variables
			var dosldColorRightDrag = false;
			var sldColorRightMinLeft=0;
			var sldColorRightMaxLeft=0;
			
			//CutGrade Slider's left Arrow variables
			var dosldCutGradeLeftDrag = false;
			var sldCutGradeLeftMinLeft=0;
			var sldCutGradeLeftMaxLeft=0;			
			//CutGrade slider's right Arrow variables
			var dosldCutGradeRightDrag = false;
			var sldCutGradeRightMinLeft=0;
			var sldCutGradeRightMaxLeft=0;
			
			//Clarity Slider's left Arrow variables
			var dosldClarityLeftDrag = false;
			var sldClarityLeftMinLeft=0;
			var sldClarityLeftMaxLeft=0;
			//Clarity slider's right Arrow variables
			var dosldClarityRightDrag = false;
			var sldClarityRightMinLeft=0;
			var sldClarityRightMaxLeft=0;
			//Carat Slider's left Arrow variables
			var dosldCaratLeftDrag = false;
			var sldCaratLeftMinLeft=0;
			var sldCaratLeftMaxLeft=0;
			//Carat slider's right Arrow variables
			var dosldCaratRightDrag = false;
			var sldCaratRightMinLeft=0;
			var sldCaratRightMaxLeft=0;
			//Price Slider's left Arrow variables
			var dosldPriceLeftDrag = false;
			var sldPriceLeftMinLeft=0;
			var sldPriceLeftMaxLeft=0;
			//Price slider's right Arrow variables
			var dosldPriceRightDrag = false;
			var sldPriceRightMinLeft=0;
			var sldPriceRightMaxLeft=0;
			
			//Table Slider's left Arrow variables
			var dosldTableLeftDrag = false;
			var sldTableLeftMinLeft=0;
			var sldTableLeftMaxLeft=0;
			//Table slider's right Arrow variables
			var dosldTableRightDrag = false;
			var sldTableRightMinLeft=0;
			var sldTableRightMaxLeft=0;
			
			//Depth Slider's left Arrow variables
			var dosldDepthLeftDrag = false;
			var sldDepthLeftMinLeft=0;
			var sldDepthLeftMaxLeft=0;
			//Depth slider's right Arrow variables
			var dosldDepthRightDrag = false;
			var sldDepthRightMinLeft=0;
			var sldDepthRightMaxLeft=0;
			
			//Scroll slider
			var dosldScrollDrag = false;
			var sldScrollMinTop = 0;
			var sldScrollMaxTop = 0;
			var sldScrollMiddleHeight = 0;
			var sldMinSliderHeight = 15;
			var sldMaxSliderHeight = 460;
			var TimeOutId;
			var TimeOptimizeId;
			var TimeOptimizeScrollId;
			var TimeOutflg = false;
			var TimeOutControlflg = false;
			
			//Diamond Records variable
			var intCurrentRecordIndex = 0;	//Current Start Record No.
			var MaxRecords = 15;	//Display no. of Records
			var increamentflag = true;
			var intCurrentArrayIndex = 0;
			var intArraySize = 30;
			var intTotalRecords = 0;
			
			//Diamond Pairing Variable
			var PairCode = 1;
			
			//Paging Variables
			var currentPageIndex = 1;
			var DisplayNoOfPages = 5;
			
			var intOptimize = 0;
			var flgRowBack = false;
			var objDivWait;
			var lblPrice;
			
			function MM_openBrWindow(theURL,winName,features) 
			{ 
				window.open(theURL,winName,features);
			}

			function fnLoad()	//Initialize variables
			{				
			
				
				//****** Price Slider ******
				//Slider Price Left Arrow Variables				
				lblPrice = document.getElementById("divPriceLabel");
				
				o=document.getElementById("sldPriceLeft");
				o1=document.getElementById("tblPriceSlider");
				sldPriceLeftMinLeft = getAbsLeft(o1) + SliderBarLeftRightDiff-7;
				sldPriceLeftMaxLeft = getAbsLeft(o1) + o1.offsetWidth;
				sldPriceTop = getAbsTop(o1)+ 14;
				setTop(o,sldPriceTop);
				setPosition(o,sldPriceLeftMinLeft, sldPriceTop);
				//fnPriceLeftCheck(sldPriceLeftMinLeft);
				//Slider Price Right Arrow Variables
				o=document.getElementById("sldPriceRight");
				sldPriceRightMinLeft = sldPriceLeftMinLeft;
				sldPriceRightMaxLeft = getAbsLeft(o1) + o1.offsetWidth - SliderWidth - SliderBarLeftRightDiff - 5;
				setTop(o,sldPriceTop);
				setPosition(o,sldPriceRightMaxLeft, sldPriceTop);
				o=document.getElementById("sldPriceMiddle");
				
				o.style.top = sldPriceTop + 'px';
				o.style.left = sldPriceLeftMinLeft  + 'px';
				o.style.width = (sldPriceRightMaxLeft - sldPriceLeftMinLeft)  + 'px';
				
				
				//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
				//price
				
				//tdMinPrice1=document.getElementById("tdMinPrice");
				//tdMaxPrice1=document.getElementById("tdMaxPrice");
				if(PriceMax>100000) PriceMax=100000  //Added line by Hatim
				if(PriceMin > PriceMax)  PriceMin= PriceMax-5000;  //Added line by Hatim
				//tdMinPrice1.innerHTML = PriceMin;
				//tdMaxPrice1.innerHTML = PriceMax;

                //PriceMin = 0;
                
				//tdMaxPrice1.innerHTML = "$" + parseMoney(PriceMax);
				//tdMinPrice1.innerHTML = "$" + parseMoney(PriceMin);
				
				
				
				document.getElementById("hdnPriceMin").value = 1500;
				document.getElementById("hdnPriceMax").value = 100000;

				setLeftPriceSlider();
				setRightPriceSlider();	
				fnBuildPriceArray(InitialPriceMin,InitialPriceMax);
				PriceMin = 1500;
                PriceMax = 100000;
                
                // Add By Trishul 
				document.getElementById("txtTo").value = "$" + parseMoney(PriceMax);
				document.getElementById("txtFrom").value = "$" + parseMoney(PriceMin);
				
			}
			function getAbsLeft(o) {
				oLeft = o.offsetLeft
				while(o.offsetParent!=null) {
					oParent = o.offsetParent
					oLeft += oParent.offsetLeft
					o = oParent
				}
				return oLeft
			}
			function getAbsTop(o) {
				oTop = o.offsetTop
				while(o.offsetParent!=null) {
					oParent = o.offsetParent
					oTop += oParent.offsetTop
					o = oParent
				}
				return oTop
			}
			function setLeft(o,oLeft) 
			{
				o.style.left = oLeft + 'px';
			}
			function setTop(o,oTop) 
			{
				o.style.top = oTop + "px";
			}
			function setPosition(o,oLeft,oTop) 
			{
				setLeft(o,oLeft);
			}
			
			function sldMouseMove(e)	// Generic mouse move handler
			{
				if (!e) {e = window.event}				
				MouseLeft = e.clientX;
				MouseRight = e.clientY;				
					if (dosldPriceLeftDrag)	// If drag action is on going
					{
					    //debugger
						o=document.getElementById("sldPriceLeft");
						var newPos = e.clientX-sldMouseLeft;	// Get slider's head new position
						if(newPos<=sldPriceLeftMinLeft){newPos=sldPriceLeftMinLeft};	// Check slider's container boundaries
						if(newPos>=sldPriceLeftMaxLeft){newPos=sldPriceLeftMaxLeft - 7}; ////23-Oct-2009 - Added +7
						
						sldPriceRightMinLeft = newPos;
						
						setPosition(o,newPos,sldPriceTop);	// Set slider's head new position
						
						fnPriceLeftCheck(newPos);
						
						//23-Oct-2009
						setPosition(lblPrice,newPos-20,sldPriceTop);
						setTop(lblPrice,sldPriceTop-18);
						lblPrice.style.display='block';
						
						if(sldPriceLeftMaxLeft - sldPriceRightMinLeft <= 7)
						    PriceMin=PriceMax;
						lblPrice.innerHTML = "$" + parseMoney(PriceMin.toFixed(0));
						
						// add by Trishul
						document.getElementById("txtFrom").value = "$" + parseMoney(PriceMin.toFixed(0));
						
						
						////////////
						o=document.getElementById("sldPriceMiddle");
						o.style.left = newPos  + 'px';
						o.style.width = (sldPriceLeftMaxLeft + SliderWidth - newPos - 5)  + 'px';
						
						
						return false;
					}
					else if(dosldPriceRightDrag)
					{		
					    		
						o=document.getElementById("sldPriceRight");
						var newPos = e.clientX-sldMouseLeft;	// Get slider's head new position
						if(newPos<=sldPriceRightMinLeft){newPos=sldPriceRightMinLeft + 11};	// Check slider's container boundaries
						if(newPos>=sldPriceRightMaxLeft){newPos=sldPriceRightMaxLeft};
						sldPriceLeftMaxLeft = newPos - SliderBarLeftRightDiff;
						setPosition(o,newPos,sldPriceTop);	// Set slider's head new position
						
						fnPriceRightCheck(newPos);
						
						//23-Oct-2009
						setPosition(lblPrice,newPos-20,sldPriceTop);
						setTop(lblPrice,sldPriceTop-18);
						lblPrice.style.display='block';
						
						if(sldPriceLeftMaxLeft - sldPriceRightMinLeft <= 7)
						    PriceMax=PriceMin;
						    
						lblPrice.innerHTML = "$" + parseMoney(PriceMax.toFixed(0));
						
						// add by Trishul
						document.getElementById("txtTo").value = "$" + parseMoney(PriceMax.toFixed(0));
						
						////////////
						
						o=document.getElementById("sldPriceMiddle");
						o.style.width = (newPos - sldPriceRightMinLeft + SliderWidth - 15)  + 'px';
						return false;
					}
					else if(dosldScrollDrag)
					{
						o=document.getElementById("sldScrollMiddle");
						var newPos = e.clientY - sldMouseTop;	// Get slider's head new position
						if(newPos<=sldScrollMinTop){newPos=sldScrollMinTop};	// Check slider's container boundaries
						if(newPos>=sldScrollMaxTop){newPos=sldScrollMaxTop};
						setTop(o, newPos + 3);
				
						o=document.getElementById("sldScrollTop");
						setTop(o, newPos);
						
						o=document.getElementById("sldScrollBottom");
						setTop(o, newPos + sldScrollMiddleHeight + 3);
						fnScrollCheck(newPos);
						return false;
					}
			}
			
			function sldPriceLeftMouseDown(e)
			{
				if (!e) {e = window.event}
				dosldPriceLeftDrag=true;
				o1=document.getElementById("sldPriceLeft");
				sldMouseLeft=e.clientX - o1.offsetLeft;
			}
			function sldPriceRightMouseDown(e)
			{
				if (!e) {e = window.event}
				dosldPriceRightDrag=true;
				o1=document.getElementById("sldPriceRight");
				sldMouseLeft=e.clientX - o1.offsetLeft;
			}
			
			function sldMouseUp(e)
			{
			    lblPrice = document.getElementById("divPriceLabel");
				dosldPriceLeftDrag = false;
				dosldPriceRightDrag = false;
				dosldScrollDrag = false;
				TimeOutflg = false;
				TimeOutControlflg = false;
				window.clearInterval(TimeOutId);	//Clear Time Interval
				lblPrice.style.display='none';
				return true;
			}
						
			function fnPriceLeftCheck(Pos)	//Change Price Range
			{
			//tdSearchPrice1=document.getElementById("tdSearchPrice");
			//tdMinPrice1=document.getElementById("tdMinPrice");
				var Old_PriceMin = PriceMin;
				var percentage = Math.round((Pos - sldPriceLeftMinLeft) * 100/(sldPriceRightMaxLeft - sldPriceLeftMinLeft));
				var NewPrice;
				
				for(var i = 0; i < PriceArray.length; i++)
				{
				    if(PriceArray[i][3] >= 99)
				        PriceArray[i][3] = 100;
					if(percentage >= PriceArray[i][2] && percentage <= PriceArray[i][3])
					{
						percentage = Math.round((percentage - PriceArray[i][2]) * 100/(PriceArray[i][3] - PriceArray[i][2]));						
						NewPrice = (((PriceArray[i][1] - PriceArray[i][0]) * (percentage)) / 100) + PriceArray[i][0];
						break;
					}
				}
				if(PriceMax < NewPrice)
				{NewPrice = PriceMax;}
				//tdMinPrice1.innerHTML = "$" + parseMoney(NewPrice);
				
				PriceMin = NewPrice;
				document.getElementById("hdnPriceMin").value = PriceMin;
				//tdSearchPrice1.innerHTML = "$" + parseMoney(PriceMin) + " - $" + parseMoney(PriceMax);
				if(!flgRecordFecth && Old_PriceMin != PriceMin){fnFetchRecord(false);}
				//document.getElementById("txtPriceMin").value = PriceMin;
			}
			function fnPriceRightCheck(Pos)	//Change Price Range
			{
			//debugger
			//tdSearchPrice1=document.getElementById("tdSearchPrice");
			//tdMaxPrice1=document.getElementById("tdMaxPrice");
				var Old_PriceMax = PriceMax;
				var percentage = Math.round((Pos - sldPriceLeftMinLeft) * 100/(sldPriceRightMaxLeft - sldPriceLeftMinLeft));
				var NewPrice;
				for(var i = 0; i < PriceArray.length; i++)
				{
				    if(PriceArray[i][3] >= 99)
				        PriceArray[i][3] = 100;
					if(percentage >= PriceArray[i][2] && percentage <= PriceArray[i][3])
					{
						percentage = Math.round((percentage - PriceArray[i][2]) * 100/(PriceArray[i][3] - PriceArray[i][2]));
						NewPrice = (((PriceArray[i][1] - PriceArray[i][0]) * (percentage)) / 100) + PriceArray[i][0];
						break;
					}
				}
				if(PriceMin > NewPrice)
				{NewPrice = PriceMin;}
				//tdMaxPrice1.innerHTML = "$" + parseMoney(NewPrice);
				PriceMax = NewPrice;
				
				document.getElementById("hdnPriceMax").value = PriceMax;
				//tdSearchPrice1.innerHTML = "$" + parseMoney(PriceMin) + " - $" + parseMoney(PriceMax);
				if(!flgRecordFecth && Old_PriceMax != PriceMax){fnFetchRecord(false);}
				//document.getElementById("txtPriceMax").value = PriceMax;
			}
			
			function parseMoney(parseString)
			{
				if(parseInt(parseString/1000)>=1)
				{
					var modString = parseInt(parseString%1000);
					if(modString<100)
					{
						if(modString<10)
							modString = "00" + modString;
						else
							modString = "0" + modString;
					}
					parseString = parseMoney(parseInt(parseString/1000)) + "," + modString;
					return parseString;
				}
				else
					return parseString;
			}
			
			
			// Set Price: For Leftside UP Arrow 
			function arwPriceLeftUp()
			{
				 PriceArray[0][0]= PriceArray[0][0] + 500;
				if( PriceArray[0][0] > 5000)
					 PriceArray[0][0]=5000;
			
				if(PriceArray[0][0] == PriceMax || PriceArray[0][0] > PriceMax)
				{	
					alert("Invalid price Interval.");
					PriceArray[0][0]=PriceArray[0][0] - 500
					if(PriceArray[0][0] > PriceMin)
						PriceMin=PriceArray[0][0];
				}
				else
				{
					if(PriceArray[0][0] > PriceMin)
					{
						PriceMin=PriceArray[0][0];
						//tdMinPrice1.innerHTML = "$" + parseMoney(PriceMin);
						tdSearchPrice1.innerHTML = "$" + PriceMin + " - $" + PriceMax;
						if(!flgRecordFecth){fnFetchRecord(false);}
						//document.getElementById("txtPriceMin").value = PriceMin;
					}
				}
				    
				    
				setLeftPriceSlider();
				setRightPriceSlider();
			}
			
			// Set Price: For Leftside UP Arrow 
			function arwPriceLeftDown()
			{
				 PriceArray[0][0]= PriceArray[0][0] - 500;
				if( PriceArray[0][0] < 0)
					 PriceArray[0][0]=0;
				setLeftPriceSlider();
				setRightPriceSlider();
			}
			
			// Set Price: For Rightsside UP Arrow 
			function arwPriceRightUp()
			{
				PriceArray[0][1]= PriceArray[0][1] + 10000;
				if( PriceArray[0][1] > 100000)
					 PriceArray[0][1]=100000;
					 
				setLeftPriceSlider();
				setRightPriceSlider();	 
			}
			
			// Set Price: For Rightside Down Arrow 
			function arwPriceRightDown()
			{
				PriceArray[0][1]= PriceArray[0][1] - 10000;
				if( PriceArray[0][1] < 10000)
					 PriceArray[0][1]=10000;
				   
				if(PriceArray[0][1] == PriceMin || PriceArray[0][1] < PriceMin)
					{
						alert("Invalid price interval.");
						PriceArray[0][1]=PriceArray[0][1] + 10000;
						if(PriceArray[0][1] < PriceMax)
							PriceMax=PriceArray[0][1];
					}
				else
					{
						if(PriceArray[0][1] < PriceMax)
						{
							PriceMax=PriceArray[0][1];
							//tdMaxPrice1.innerHTML = "$" + parseMoney(PriceMax);
							tdSearchPrice1.innerHTML = "$" + PriceMin + " - $" + PriceMax;
							if(!flgRecordFecth){fnFetchRecord(false);}
							//document.getElementById("txtPriceMax").value = PriceMax;
						}
					}
				setLeftPriceSlider();
				setRightPriceSlider();
			}
			
			//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
			
			function setLeftPriceSlider()
			{
				//Set Left Diamond
				osldPriceLeft = document.getElementById("sldPriceLeft");
				
				var percentage = (PriceMin - PriceArray[0][0]) * 100/(PriceArray[0][1] - PriceArray[0][0]);
				var newPos = Math.round(((percentage * (sldPriceRightMaxLeft - sldPriceLeftMinLeft)) / 100) + sldPriceLeftMinLeft);
				
				//if(PriceMin == PriceMax)
				//	newPos=newPos-3;
				sldPriceRightMinLeft = newPos;
				setPosition(osldPriceLeft,newPos,sldPriceTop);
				
				o=document.getElementById("sldPriceMiddle");
				o.style.left = newPos + 'px';
				if(PriceMin == PriceMax)
					o.style.width=0  + 'px';
				else
					o.style.width = sldPriceLeftMaxLeft + SliderWidth - newPos  + 'px';
				return false;
			}
			
			function setRightPriceSlider()
			{
				//Set Right Diamond
				osldPriceRight = document.getElementById("sldPriceRight");
				
				var percentage = (PriceMax - PriceArray[0][0]) * 100/(PriceArray[0][1] - PriceArray[0][0]);
				var newPos = Math.round(((percentage * (sldPriceRightMaxLeft - sldPriceLeftMinLeft)) / 100) + sldPriceLeftMinLeft);
			         
				sldPriceLeftMaxLeft = newPos-5;
				setPosition(osldPriceRight,newPos,sldPriceTop);
				
				o=document.getElementById("sldPriceMiddle");
				if(PriceMax==PriceMin)
					o.style.width=0  + 'px';
				else
					o.style.width = newPos - sldPriceRightMinLeft + SliderWidth - 15  + 'px';
                
			         
				return false;
			}
					
			
            //Function to search on click of search button for binding grid
            function onPairChange()
            {            
				//Pair Code
				PairCode = parseInt(document.getElementById("cmbIncludePairs").value);
				fnFetchRecord(true);
				return false;
			}
			
			function setPagesize(pagesize)
			{
			    MaxRecords= pagesize;
			    intArraySize= pagesize * 2;
			    fnFetchRecord(true);
			    return false;
			}
			
			function checkAll(objCheckAll)
            {
                if(objCheckAll.checked)
                {                                                                                                   
                   document.getElementById("Shape1").checked=true;
                   document.getElementById("Shape2").checked=true;
                   document.getElementById("Shape3").checked=true;
                   document.getElementById("Shape4").checked=true;
                   document.getElementById("Shape5").checked=true;
                   document.getElementById("Shape6").checked=true;
                   document.getElementById("Shape7").checked=true;
                   document.getElementById("Shape8").checked=true;
                   document.getElementById("Shape9").checked=true;
                   document.getElementById("Shape10").checked=true; 
                   document.getElementById("Shape11").checked=true; 
                }
                else
                {
                   document.getElementById("Shape1").checked=false;
                   document.getElementById("Shape2").checked=false;
                   document.getElementById("Shape3").checked=false;
                   document.getElementById("Shape4").checked=false;
                   document.getElementById("Shape5").checked=false;
                   document.getElementById("Shape6").checked=false;
                   document.getElementById("Shape7").checked=false;
                   document.getElementById("Shape8").checked=false;
                   document.getElementById("Shape9").checked=false;
                   document.getElementById("Shape10").checked=false; 
                   document.getElementById("Shape11").checked=false; 
                }
                fnFetchRecord(true);
            }
            
            
            function CurrencyFormatted(nStr)
            {
	            nStr += '';
	            x = nStr.split('.');
	            x1 = x[0];
	            x2 = x.length > 1 ? '.' + x[1] : '';
	            var rgx = /(\d+)(\d{3})/;
	            while (rgx.test(x1)) {
		            x1 = x1.replace(rgx, '$1' + ',' + '$2');
	            }
	            return x1 + x2;
            }

            function SortOnHeaderClick(objType)
            {
                if(objType.id == 'tdShape' )
                {
                    if (flgShareSorted == false)
                    {
                        fnSort('txtShape','Asc','img_txtShape_Asc');
                        flgShareSorted = true;
                    }
                    else
                    {
                        fnSort('txtShape','Desc','img_txtShape_Desc');
                        flgShareSorted = false;
                    }
                }
                else if(objType.id == 'tdSize' )
                {
                    if (flgSizeSorted == false)
                    {
                        fnSort('fltCarat','Asc','img_fltCarat_Asc');
                        flgSizeSorted = true;
                    }
                    else
                    {
                        fnSort('fltCarat','Desc','img_fltCarat_Desc');
                        flgSizeSorted = false;
                    }
                }
                else if(objType.id == 'tdClarity' )
                {
                    if (flgClaritySorted == false)
                    {
                        fnSort('intClarityPriority','Asc','img_intClarityPriority_Asc');
                        flgClaritySorted = true;
                    }
                    else
                    {
                        fnSort('intClarityPriority','Desc','img_intClarityPriority_Desc');
                        flgClaritySorted = false;
                    }
                }
                else if(objType.id == 'tdColor' )
                {
                    if (flgColorSorted == false)
                    {
                        fnSort('intColorPriority','Asc','img_intColorPriority_Asc');
                        flgColorSorted = true;
                    }
                    else
                    {
                        fnSort('intColorPriority','Desc','img_intColorPriority_Desc');
                        flgColorSorted = false;
                    }
                }
                else if(objType.id == 'tdCutGrade' )
                {
                    if (flgCutGradeSorted == false)
                    {
                        fnSort('strCutGrade','Asc','img_strCutGrade_Asc');
                        flgCutGradeSorted = true;
                    }
                    else
                    {
                        fnSort('strCutGrade','Desc','img_strCutGrade_Desc');
                        flgCutGradeSorted = false;
                    }
                }
                else if(objType.id == 'tdCertificate' )
                {
                    if (flgCertSorted == false)
                    {
                        fnSort('txtCertificate','Asc','img_txtCertificate_Asc');
                        flgCertSorted = true;
                    }
                    else
                    {
                        fnSort('txtCertificate','Desc','img_txtCertificate_Desc');
                        flgCertSorted = false;
                    }
                }
                else if(objType.id == 'tdPrice' )
                {
                    if (flgPriceSorted == false)
                    {
                        fnSort('fltPrice','Asc','img_fltPrice_Asc');
                        flgPriceSorted = true;
                    }
                    else
                    {
                        fnSort('fltPrice','Desc','img_fltPrice_Desc');
                        flgPriceSorted = false;
                    }
                }
                
            }
            
            
           //Function to load array for sensitivity
			function fnBuildPriceArray(InitialMin,InitialMax)
			{			    
				var flgprice = false;
				var priceDiff = InitialMax - InitialMin;
				
				for(i = 0; i < refPrice.length; i++)
				{
					if(priceDiff >= refPrice[i][0][0] && priceDiff <= refPrice[i][0][1])
					{
						var Per = 0;
						PriceArray = new Array(12);
						for(j = 0; j < PriceArray.length; j++)
						{
							PriceArray[j] = new Array(4);
							PriceArray[j][0] = parseFloat(((((InitialMax - InitialMin) * refPrice[i][j+1][0]) / 100) + parseFloat(InitialMin)).toFixed(2));
							PriceArray[j][1] = parseFloat(((((InitialMax - InitialMin) * refPrice[i][j+1][1]) / 100) + parseFloat(InitialMin)).toFixed(2));
							PriceArray[j][2] = Per;
							PriceArray[j][3] = Per + 8.33;
							Per = Per + 8.33;
						}
						flgprice = true;
					}
					else
						continue;
				}
				if(!flgprice || InitialMin == InitialMax)
				{
					PriceArray = new Array(1);
					PriceArray[0] = new Array(4);
					PriceArray[0][0]=InitialMin;
					PriceArray[0][1]=InitialMax;
					PriceArray[0][2]=0;
					PriceArray[0][3]=100;
				}
			}
			function fnDiamondShape(CurShape)	//Change Shape
			{
			
		        if(CurShape.checked)
		        {
		            if(Shape!='') 
		                Shape = Shape + "," + CurShape.className;
		            else
		            {
		                Shape = Shape + CurShape.className;		                
		            }
		            //CurShape.checked = true;   
		        }
		       else
		       {
		            if(Shape.indexOf(CurShape.className + ",")>=0)
		                Shape = Shape.replace(CurShape.className + ",",'');
		            else if(Shape.indexOf("," + CurShape.className)>=0)
		                Shape = Shape.replace("," + CurShape.className,'');
		            else
		                Shape = Shape.replace(CurShape.className,'');
		            //document.getElementById('Shape12').checked = false;
		            
		            if(CurShape.className.indexOf("AllCuts")>=0)
		            {
		                Shape="";	
		                for(var i=1;i<=11;i++)
				        {
				            objShape = document.getElementById('Shape'+i);
				            objShape.checked = false;
				        }	                
		            }
		       } 
		       
		       if(Shape.indexOf("AllCuts")>=0)
				{
				    Shape="";
				    for(var i=1;i<=11;i++)
				    {
				        objShape = document.getElementById('Shape'+i);	
				        if(i==1)	        
				            Shape = objShape.className;
				        else
				            Shape = Shape + "," + objShape.className;    
				        objShape.checked = true;
				        
				    }
				}
				else
				{
				    for(var i=1;i<=11;i++)
				    {
				        objShape = document.getElementById('Shape'+i);	
				        if(!objShape.checked)
				        {
				            document.getElementById('Shape12').checked = false;
				            break;
				        }
				        else
				            document.getElementById('Shape12').checked = true;   
				    }
				}
		       document.getElementById('hdnShape').value = Shape;
		       //setShapeImages();			   	
				if(!flgRecordFecth){fnFetchRecord(true);}
			}
			
			
			
			// add by trishul
			function fnChanged()
			{
			    
			        var from = document.getElementById("txtFrom").value.replace('$','').replace(',','');
			        var to = document.getElementById("txtTo").value.replace('$','').replace(',','');
			        
			        if(parseInt(from)<=0 || parseInt(from)>=100000 || parseInt(to)<=0 || parseInt(to)>=100000)
			        {
			            alert("Please enter price value between 0-100000.");
			            return false;
			        }
			        
			       
			        document.getElementById("hdnPriceMin").value = from;
				    document.getElementById("hdnPriceMax").value = to;

                    
                    
				    setLeftPriceSlider();
				    setRightPriceSlider();
				    
				    
				    	
				    //fnBuildPriceArray(InitialPriceMin,InitialPriceMax);
				    PriceMin = from;
                    PriceMax = to;
                    
                    // Add By Trishul 
				    document.getElementById("txtTo").value = "$" + parseMoney(PriceMax);
				    document.getElementById("txtFrom").value = "$" + parseMoney(PriceMin);
				    
				    return false;
				
			}
			
			function checkValues()
			{
			    
			    var from = document.getElementById("txtFrom").value.replace('$','').replace(',','');
		        var to = document.getElementById("txtTo").value.replace('$','').replace(',','');
		        
		        if(!IsNumeric(from) || !IsNumeric(to))
		        {
		             alert("Please enter price value between 0-100000.");
		            return false;
		        }
		        if(parseInt(from)>parseInt(to))
		        {
		            alert("Please enter proper value.");
		            return false;
		        }
		        if(parseInt(from)<0 || parseInt(from)>100000 || parseInt(to)<0 || parseInt(to)>100000)
		        {
		            alert("Please enter price value between 0-100000.");
		            return false;
		        }
		        
		        document.getElementById("hdnPriceMin").value = from;
				document.getElementById("hdnPriceMax").value = to;
		        
		        return true;
			}
			
	           function IsNumeric(strString)
               //  check for valid numeric strings	
               {
               var strValidChars = "0123456789.";
               var strChar;
               var blnResult = true;

               if (strString.length == 0) return false;

               //  test strString consists of valid characters listed above
               for (i = 0; i < strString.length && blnResult == true; i++)
                  {
                  strChar = strString.charAt(i);
                  if (strValidChars.indexOf(strChar) == -1)
                     {
                     blnResult = false;
                     }
                  }
               return blnResult;
                 }
 