﻿
    var sliderVGrid = null;
    var sliderVGridEvent = false;
    var GlobalLoadedCarat = 0;
    var GlobalLoadedColor=0;
    var GlobalLoadedPrice=0;
    var GlobalLoadedCalrity=0;
    var GlobalLoadedRange=0;
    var selectedVal = "";
    var selectedValSecondSlider = "";
    var isIE = false;  
    var divGFirstSlider = null;
    var divGSecondSlider =  null;    
    var divGFirstSliderCarat = null;
    var divGSecondSliderCarat =  null;  
    var divGFirstSliderClarity = null;
    var divGSecondSliderClarity =  null;  
    var divGFirstSliderColor = null;
    var divGSecondSliderColor =  null;  
    var varIEVersion = navigator.appVersion;
    if(navigator.appName=="Microsoft Internet Explorer")
    {        
          isIE = true;
    }
 //Zapatec.Grid.prototype.
 getMyColumnRange=function(txtValueRange){
	
	var aKeys = [];
	
	var elementColors = document.getElementById(txtValueRange).value;
	var arrColor = elementColors.split(',');
	//alert(arrColor);
	for (var iCol = 0; iCol < arrColor.length; iCol++)
		 {
		    aKeys.push({
					v: arrColor[iCol],
					c: arrColor[iCol],
					o: arrColor[iCol]
				});
		 }
	// Return range of column values
	var iLastKey = aKeys.length - 1;
	return {
		min: aKeys[0].c,
		minValue: aKeys[0].v,
		minOrig: aKeys[0].o,
		max: aKeys[iLastKey].c,
		maxValue: aKeys[iLastKey].v,
		maxOrig: aKeys[iLastKey].o,
		values: aKeys
	};
};

 
function onCellRightClick(oGrid, oCell) {
	alert('Right mouse button\nRow id is ' + oGrid.getCellRowId(oCell) +
	 '\nCell id is ' + oGrid.getCellId(oCell) +
	 '\nItem number is ' + oGrid.getCellValueString(oGrid.getCellByRow(
	 oGrid.getRowByCell(oCell), 0)));
}

/**
 * Passed to grid through callbackRowOnClick config option and called when grid
 * row is clicked.
 * @private
 */
function onRowClick(oGrid, oRow) {
	alert('Left mouse button\nRow id is ' + oGrid.getRowId(oRow) +
	 '\nItem number is ' + oGrid.getCellValueString(oGrid.getCellByRow(oRow, 0)));
};

/**
 * Passed to grid through callbackRowOnRightClick config option and called when
 * grid row is right clicked.
 * @private
 */
function onRowRightClick(oGrid, oRow) {
	alert('Right mouse button\nRow id is ' + oGrid.getRowId(oRow) +
	 '\nItem number is ' + oGrid.getCellValueString(oGrid.getCellByRow(oRow, 0)));
};

/**
 * Converts number of milliseconds since January 1, 1970, 00:00:00.000 into
 * a date string.
 * @private
 */


/**
 * Holds ids of the fields used for sliders. Gives ability to change them
 * dynamically.
 * @private
 */
var oSliderFields = {
	//rangeOfDates: 1,
	//rangeOfMinutes: 5,
	rangeOfCarat: 1,
	rangeOfClarity: 2,
	rangeOfColor: 3,
	rangeOfPrice: 4
};

var oColorRange=null;
var oClarityRange=null;
var oCaratRange=null;
var oPriceRange=null;


function onRangeOfCaratChange(iMinValue, iMaxValue) 
{   
    document.getElementById("hiddenIsPriceRangeChanged").value = "NO";  

    iMinValue = Math.round(iMinValue);
	iMaxValue = Math.round(iMaxValue);
	document.getElementById('txtCaratMin').value=oCaratRange.values[iMinValue].v;
    document.getElementById('txtCaratMax').value=oCaratRange.values[iMaxValue].v;
	 if(GlobalLoadedCarat != 0)
	 {
       //#__doPostBack('btnHidden','');
       //document.getElementById('btnHidden').click();
      }
    else
        GlobalLoadedCarat = 1; 
        
//    if((divGFirstSliderCarat == null) || (divGSecondSliderCarat==null)) //This is for one time initialization.
//    {
       var divRange = document.getElementById("rangeOfCaratScale");
      
       var divContainer =  divRange.getElementsByTagName('div');
       var varCounter = 0;
       for(varCounter = 0;varCounter<divContainer.length;varCounter++)
       {
            if((divContainer[varCounter].id.indexOf("FirstSlider") != -1 ) && (divContainer[varCounter].id.indexOf("zp") != -1 ))
            {               
                divGFirstSliderCarat = document.getElementById(divContainer[varCounter].id);  
            }
            if((divContainer[varCounter].id.indexOf("SecondSlider") != -1 ) && (divContainer[varCounter].id.indexOf("zp") != -1 ))
            {               
                divGSecondSliderCarat =  document.getElementById(divContainer[varCounter].id);
            }           
       }       
//    } 
    
    showSelectedArea("divSACarat",divGFirstSliderCarat,divGSecondSliderCarat); 
}

function onRangeOfCaratDrag(iMinValue, iMaxValue)
{   
    //sliderVGrid.gotoFirst();
	 document.getElementById("hiddenIsPriceRangeChanged").value = "NO";  

    iMinValue = Math.round(iMinValue);
	iMaxValue = Math.round(iMaxValue);
	document.getElementById('txtCaratMin').value=oCaratRange.values[iMinValue].v;
    document.getElementById('txtCaratMax').value=oCaratRange.values[iMaxValue].v;
  
    //  alert(document.getElementById('txtCaratMin').value);
    //  alert(document.getElementById('txtCaratMax').value);
    if(GlobalLoadedCarat != 0)
     {
      __doPostBack('btnHidden','');     
     }
    else
        GlobalLoadedCarat = 1; 
        
     sliderVGrid.gotoFirst(); //Reset Grid Slider Position
}

function onRangeOfClarityChange(iMinValue, iMaxValue) 
{
    document.getElementById("hiddenIsPriceRangeChanged").value = "NO";  

	iMinValue = Math.round(iMinValue);
	iMaxValue = Math.round(iMaxValue);
	
	 document.getElementById('txtClarityMin').value=oClarityRange.values[iMinValue].v;
     document.getElementById('txtClarityMax').value=oClarityRange.values[iMaxValue].v;
	 if(GlobalLoadedCalrity != 0)
	 {
      // __doPostBack('btnHidden','');
      //document.getElementById('btnHidden').click();
      }
    else
        GlobalLoadedCalrity = 1;	
        
//  if((divGFirstSliderClarity == null) || (divGSecondSliderClarity==null)) //This is for one time initialization.
//    {
       var divRange = document.getElementById("rangeOfClarityScale");
      
       var divContainer =  divRange.getElementsByTagName('div');
       var varCounter = 0;
       for(varCounter = 0;varCounter<divContainer.length;varCounter++)
       {
            if((divContainer[varCounter].id.indexOf("FirstSlider") != -1 ) && (divContainer[varCounter].id.indexOf("zp") != -1 ))
            {               
                divGFirstSliderClarity = document.getElementById(divContainer[varCounter].id);  
            }
            if((divContainer[varCounter].id.indexOf("SecondSlider") != -1 ) && (divContainer[varCounter].id.indexOf("zp") != -1 ))
            {               
                divGSecondSliderClarity =  document.getElementById(divContainer[varCounter].id);
            }           
       }       
//    } 
    showSelectedArea("divSAClarity",divGFirstSliderClarity,divGSecondSliderClarity);  
}

function onRangeOfClarityDrag(iMinValue, iMaxValue)
 {
   // sliderVGrid.gotoFirst();
	//onRangeOfClarityChange(iMinValue, iMaxValue);
    document.getElementById("hiddenIsPriceRangeChanged").value = "NO";  
	
	iMinValue = Math.round(iMinValue);
	iMaxValue = Math.round(iMaxValue);
	
	 document.getElementById('txtClarityMin').value=oClarityRange.values[iMinValue].v;
     document.getElementById('txtClarityMax').value=oClarityRange.values[iMaxValue].v;
	 if(GlobalLoadedCalrity != 0)
	 {
       __doPostBack('btnHidden','');
      //document.getElementById('btnHidden').click();
     }
    else
        GlobalLoadedCalrity = 1;
        
        
     sliderVGrid.gotoFirst(); //Reset Grid Slider Position
 }


function onRangeOfPriceChange(iMinValue, iMaxValue) 
{
	document.getElementById("hiddenIsPriceRangeChanged").value = "YES";  
	iMinValue = Math.round(iMinValue);
	iMaxValue = Math.round(iMaxValue);
	
	//document.getElementById('rangeOfPrice').innerHTML ='$'+
	//oPriceRange.values[iMinValue].v + '- $' + oPriceRange.values[iMaxValue].v;	
	 
	 document.getElementById('txtPriceMin').value=oPriceRange.values[iMinValue].v;
     document.getElementById('txtPriceMax').value=oPriceRange.values[iMaxValue].v;
	 if(GlobalLoadedPrice != 0)
	 {
       //  __doPostBack('btnHidden','');
       //document.getElementById('btnHidden').click();
       // varIsPricesliderChanging  = true;     
     }
    else
        GlobalLoadedPrice = 1;	
       
    selectedVal = document.getElementById('txtPriceMin').value;
    selectedValSecondSlider = document.getElementById('txtPriceMax').value;
  
//    if((divGFirstSlider == null) || (divGSecondSlider==null)) //This is for one time initialization.
//    {
       var divRange = document.getElementById("rangeOfPriceScale");
      
       var divContainer =  divRange.getElementsByTagName('div');
       var varCounter = 0;
       for(varCounter = 0;varCounter<divContainer.length;varCounter++)
       {
            if((divContainer[varCounter].id.indexOf("FirstSlider") != -1 ) && (divContainer[varCounter].id.indexOf("zp") != -1 ))
            {               
                divGFirstSlider = document.getElementById(divContainer[varCounter].id);  
            }
            if((divContainer[varCounter].id.indexOf("SecondSlider") != -1 ) && (divContainer[varCounter].id.indexOf("zp") != -1 ))
            {               
                divGSecondSlider =  document.getElementById(divContainer[varCounter].id);
            }           
       }       
//    } 
    ShowSlidingPrice(selectedVal,selectedValSecondSlider);
   // showSelectedArea("divSAPrice",divGFirstSlider,divGSecondSlider); 
}

function onRangeOfPriceDrag(iMinValue, iMaxValue)
 {
  //  GetAllDivs();
 
   // sliderVGrid.gotoFirst();
   //onRangeOfPriceChange(iMinValue, iMaxValue);
	document.getElementById("hiddenIsPriceRangeChanged").value = "YES";  
	iMinValue = Math.round(iMinValue);
	iMaxValue = Math.round(iMaxValue);
	
//	document.getElementById('rangeOfPrice').innerHTML ='$'+
//	oPriceRange.values[oPriceRange.min].v + '<font color=white>.........................................................................................................</font>' + "$"+oPriceRange.values[oPriceRange.max].v; 
//	
	 showPrice(iMinValue, iMaxValue);
	 
	 document.getElementById('txtPriceMin').value=oPriceRange.values[iMinValue].v;
     document.getElementById('txtPriceMax').value=oPriceRange.values[iMaxValue].v;
	 if(GlobalLoadedPrice != 0)
	 {
        __doPostBack('btnHidden','');        
     }
    else
        GlobalLoadedPrice = 1;
        
     //  alert(iMinValue + "--" + iMaxValue);
      // alert(oPriceRange.getPos());
      // alert(oPriceRange.getPos());
      
     sliderVGrid.gotoFirst(); //Reset Grid Slider Position
    // GeneratePopupDiv(oPriceRange.values[iMinValue].v);
}

function showPrice(iMinValue, iMaxValue)
{
//    var varSelectedPrice =  "($"+oPriceRange.values[iMinValue].v + " - $" + oPriceRange.values[iMaxValue].v+")";
//    var varPriceLine = "";
//    varPriceLine = '$' + oPriceRange.values[oPriceRange.min].v + "<font color=white>...........................................................................................................</font>"+ "$"+oPriceRange.values[oPriceRange.max].v;
//    document.getElementById('rangeOfPrice').innerHTML = varPriceLine;	
}

function onRangeOfColorChange(iMinValue, iMaxValue)
 {
	 document.getElementById("hiddenIsPriceRangeChanged").value = "NO"; 
	 document.getElementById('txtColorMin').value=oColorRange.values[iMinValue].v;
     document.getElementById('txtColorMax').value=oColorRange.values[iMaxValue].v;
	 if(GlobalLoadedColor != 0)
	 {
       //__doPostBack('btnHidden','');
      //document.getElementById('btnHidden').click();
      }
    else
        GlobalLoadedColor = 1;
        
// if((divGFirstSliderColor == null) || (divGSecondSliderColor==null)) //This is for one time initialization.
//    {
       var divRange = document.getElementById("rangeOfColorScale");
      
       var divContainer =  divRange.getElementsByTagName('div');
       var varCounter = 0;
       for(varCounter = 0;varCounter<divContainer.length;varCounter++)
       {
            if((divContainer[varCounter].id.indexOf("FirstSlider") != -1 ) && (divContainer[varCounter].id.indexOf("zp") != -1 ))
            {               
                divGFirstSliderColor = document.getElementById(divContainer[varCounter].id);  
            }
            if((divContainer[varCounter].id.indexOf("SecondSlider") != -1 ) && (divContainer[varCounter].id.indexOf("zp") != -1 ))
            {               
                divGSecondSliderColor =  document.getElementById(divContainer[varCounter].id);
            }           
       }       
//    } 
    showSelectedArea("divSAColor",divGFirstSliderColor,divGSecondSliderColor); 
}

function onRangeOfColorDrag(iMinValue, iMaxValue)
 {   
	 document.getElementById("hiddenIsPriceRangeChanged").value = "NO"; 
	 document.getElementById('txtColorMin').value=oColorRange.values[iMinValue].v;
     document.getElementById('txtColorMax').value=oColorRange.values[iMaxValue].v;
	 if(GlobalLoadedColor != 0)
	 {
       __doPostBack('btnHidden','');      
      }
    else
        GlobalLoadedColor = 1;	        
   
   sliderVGrid.gotoFirst(); //Reset Grid Slider Position
 }

var oCaratSlider;
var oClaritySlider;
var oColorSlider;
var oPriceSlider;
/**
 * Passed to the grid through eventListeners config option as 'gridInitialized'
 * event listener and called when grid is initialized. Grid object can be
 * accessed through "this" because function is called in scope of grid object.
 * @private
 */
function onGridInit() 
{
    //appendError("Started OnGridInit Successfullay : ");
    createGridNewVGSlider();
	oCaratRange = getMyColumnRange('txtCaratrange');//this.getMyColumnRange('txtCaratrange');
	oCaratRange.min = 0;
	oCaratRange.max = oCaratRange.values.length-1;
	if(oCaratRange)
	{
	 document.getElementById('rangeOfCarat').innerHTML = "0.5<font color=white>....................</font>1<font color=white>....................</font>1.5<font color=white>....................</font>2<font color=white>....................</font>2.5<font color=white>....................</font>3"
      
      		 oCaratSlider = new Zapatec.Slider({
				div: 'rangeOfCaratScale', 
				length: 350,
				dual: true, 
				orientation: 'H',
				step: 1,
				theme:'theme4',
				range : [oCaratRange.min, oCaratRange.max],
				eventListeners: {
					'onChange': onRangeOfCaratChange,
					'newPosition': onRangeOfCaratDrag
				}
			});
	 }
	 //appendError(" oCaratRange.min :" + oCaratRange.min + "..." +oCaratRange.max);
//	}
	
	
	 oPriceRange = getMyColumnRange('txtPriceRange');//this.getMyColumnRange('txtPriceRange');
	 oPriceRange.min = 0;
	 oPriceRange.max = oPriceRange.values.length-1;
	if(oPriceRange)
	{	
		 oPriceSlider = new Zapatec.Slider({
				div: 'rangeOfPriceScale', 
				length: 350,
				dual: true, 
				orientation: 'H',
				step: 1,
				theme:'theme4',
				range : [oPriceRange.min, oPriceRange.max],
				eventListeners: {
					'onChange': onRangeOfPriceChange,
					'newPosition': onRangeOfPriceDrag
				}
			});
		  }
 //appendError(" oPriceRange.min :" + oPriceRange.min + "..." +oPriceRange.max);
	
	 oColorRange = getMyColumnRange('txtColorRange');//{column: oSliderFields.rangeOfColor});
	 oColorRange.min = 0;
	 oColorRange.max = oColorRange.values.length-1;
	 
	if(oColorRange)
	{
	    document.getElementById('rangeOfColor').innerHTML =
	    "D<font color=white>.................</font>E<font color=white>.................</font>F<font color=white>...................</font>G<font color=white>...................</font>H<font color=white>..................</font>I<font color=white>................</font>J";
	
		 oColorSlider = new Zapatec.Slider({
				div: 'rangeOfColorScale', 
				length: 350,
				dual: true, 
				orientation: 'H',
				step: 1,
				theme:'theme4',
				range : [oColorRange.min, oColorRange.max],
				eventListeners: {
					'onChange': onRangeOfColorChange,
					'newPosition': onRangeOfColorDrag
				}
			});
	 }
	 
// appendError(" oColorSlider.min :" + oColorSlider.min + "..." +oColorSlider.max);


oClarityRange = getMyColumnRange('txtClarityRange');//this.getMyColumnRange('txtClarityRange');

oClarityRange.min = 0;
oClarityRange.max = oClarityRange.values.length-1;
	if(oClarityRange)
	{
	    document.getElementById('rangeOfClarity').innerHTML ="IF<font color=white>.............</font>VVS1<font color=white>.......</font>VVS2<font color=white>........</font>VS1<font color=white>........</font>VS2<font color=white>.........</font>SI1<font color=white>.........</font>SI2<font color=white>.........</font>I1<font color=white>.........</font>I2"
      
		 oClaritySlider = new Zapatec.Slider({
				div: 'rangeOfClarityScale', 
				length: 350,
				dual: true, 
				orientation: 'H',
				step: 1,
				theme:'theme4',
				range : [oClarityRange.min, oClarityRange.max],
				eventListeners: {
					'onChange': onRangeOfClarityChange,
					'newPosition': onRangeOfClarityDrag
				}
			});
	}
 //appendError(" oClaritySlider.min :" + oClaritySlider.min + "..." +oClaritySlider.max);

}



function onGridMovedColumn(oMove) {
	// Fix sliders using special static method of the grid
	
	oSliderFields.rangeOfCarat = Zapatec.Grid.getNewColumnNumber({
		fieldId: oSliderFields.rangeOfCarat,
		move: oMove
	});
	oSliderFields.rangeOfClarity = Zapatec.Grid.getNewColumnNumber({
		fieldId: oSliderFields.rangeOfClarity,
		move: oMove
	});
	oSliderFields.rangeOfColor = Zapatec.Grid.getNewColumnNumber({
		fieldId: oSliderFields.rangeOfColor,
		move: oMove
	});
	oSliderFields.rangeOfPrice = Zapatec.Grid.getNewColumnNumber({
		fieldId: oSliderFields.rangeOfPrice,
		move: oMove
	});
}


function resetControls(oForm) {
	if (typeof oGrid == 'undefined') {
		oGrid = objGrid;
	}
	// Reset form
	oForm.textFilter.value = '';
	// Reset all sliders
	var aWidgets = Zapatec.Widget.all;
	var iWidgets = aWidgets.length;
	var oWidget;
	for (var iWidget = 0; iWidget < iWidgets; iWidget++) {
		oWidget = aWidgets[iWidget];
		if (oWidget.constructor == Zapatec.Slider) {
			oWidget.setPos(oWidget.config.range[0], oWidget.config.range[1]);
		}
	}
	// Reset filters
	if (oGrid) {
		oGrid.resetFilters();
	}
}


function CheckShapes()
{
    sliderVGridEvent = false;
    var allSahpes;
    allSahpes = "";
    //alert('dfdf');
 if(document.getElementById('chkRound') != null)
 {
    if(document.getElementById('chkRound').checked )
        allSahpes = "'BR',";
 }
 
if(document.getElementById('chkOval') != null)
{
    if(document.getElementById('chkOval').checked )
        allSahpes += "'OV',";
}

if(document.getElementById('chkPrincess') != null)
{
    if(document.getElementById('chkPrincess').checked )
         allSahpes += "'PRN',"; 
 }

if(document.getElementById('chkPear') != null)
{
    if(document.getElementById('chkPear').checked )
        allSahpes += "'PS',";
}

if(document.getElementById('chkMarquise') != null)
{
    if(document.getElementById('chkMarquise').checked )
        allSahpes += "'MQ',";
}

if(document.getElementById('chkHeart') != null)
{
    if(document.getElementById('chkHeart').checked )
        allSahpes += "'HS',";
}
if(document.getElementById('chkRadiant') != null)
{
    if(document.getElementById('chkRadiant').checked )
        allSahpes += "'RAD',";
}
if(document.getElementById('chkCushion') != null)
{
     if(document.getElementById('chkCushion').checked )
        allSahpes += "'CUS',";
 }
 if(document.getElementById('chkAsscher') !=null)
 {
    if(document.getElementById('chkAsscher').checked )
        allSahpes += "'AS',";
 }
  if(document.getElementById('chkEmerald') != null)
  {
     if(document.getElementById('chkEmerald').checked )
        allSahpes += "'EM',";
  }
 
 alert(allSahpes);
 document.getElementById('txtAllshapes').value =  allSahpes;

  if(GlobalLoadedPrice != 0)
  {
       sliderVGrid.gotoFirst(); //Reset Grid Slider Position
       __doPostBack('btnHidden','');
   }
   else
   {
       GlobalLoadedPrice = 1;
   }     
}

function onRangeOfVGridSliderChange(a)
{
    sliderVGridEvent = true;
    document.getElementById("txtTotalrecord").value = ParseInt(a);
     if(GlobalLoadedRange != 0)
	 {
      __doPostBack('btnHidden','');
     }
    else
        GlobalLoadedRange = 1;   
}

function ReInitializePriceBar(varNewPriceRange)
{
   if(document.getElementById("hiddenIsPriceRangeChanged").value == "NO") // Need not to reconfigure if price slider changes
    { 
        document.getElementById("txtPriceRange").value = varNewPriceRange;     
        reconfig_PriceSlider();
    }             
   document.getElementById("hiddenIsPriceRangeChanged").value = "NO"         
} 

function reconfig_PriceSlider()
{       
     oPriceRange = getMyColumnRange('txtPriceRange');//this.getMyColumnRange('txtPriceRange');
	 oPriceRange.min = 0;
	 oPriceRange.max = oPriceRange.values.length-1;
	if(oPriceRange)
	{       
		 if(oPriceSlider)
		 {
		    // appendError("Reset Started..");
		     oPriceSlider.reset(oPriceRange.min, oPriceRange.max);
		 }			 	
	}
}

function ResetAllSliders()
{ 
    document.getElementById('chkRound').checked  = true;
    oCaratRange = getMyColumnRange('txtCaratrange');//this.getMyColumnRange('txtCaratrange');
	oCaratRange.min = 0;
	oCaratRange.max = oCaratRange.values.length-1;
	if(oCaratSlider)
    {
      oCaratSlider.reset(oCaratRange.min, oCaratRange.max);
    }
    
    oPriceRange = getMyColumnRange('txtPriceRange');//this.getMyColumnRange('txtPriceRange');
	oPriceRange.min = 0;
	oPriceRange.max = oPriceRange.values.length-1;
	
	if(oPriceSlider)
	{
	   oPriceSlider.reset(oPriceRange.min, oPriceRange.max);
	}
	//alert(oPriceRange.min + '---"' + oPriceRange.max);
	//document.getElementById('rangeOfPrice').innerHTML = '$'+
	//oPriceRange.values[oPriceRange.min].v + '<font color=white>...........................................................................................................</font>' + '$' + oPriceRange.values[oPriceRange.max].v; 
   
	 oColorRange = getMyColumnRange('txtColorRange');//{column: oSliderFields.rangeOfColor});
	 oColorRange.min = 0;
	 oColorRange.max = oColorRange.values.length-1;
	 
	if(oColorSlider)
    {
      oColorSlider.reset(oColorRange.min, oColorRange.max);
    }
	
	oClarityRange = getMyColumnRange('txtClarityRange');
    oClarityRange.min = 0;
    oClarityRange.max = oClarityRange.values.length-1;	

	 if(oClaritySlider)
	 {
	  oClaritySlider.reset(oClarityRange.min, oClarityRange.max);
	 }
	 
     sliderVGrid.gotoFirst(); //Reset Grid Slider Position
}

function createGridNewVGSlider()
{    
    totalRecord = parseInt(document.getElementById('txtTotalrecord').value); 
   
        sliderVGrid = new Zapatec.Slider({
        div : "VGridSlider", 
        length : 310, 
        range : [0,1000],    
        start : 1,        
        orientation : "V",
        step : 1,
        onChange : function(a)
        {
            document.getElementById("hiddenIsGridSliderChanged").value = "YES";
            document.getElementById("txtVGSliderMinPixel").value = a;
            document.getElementById("txtTotalrecord").value = a;
                if(GlobalLoadedRange != 0)
                {
                   // __doPostBack('btnHidden','');
                }
                else
                {
                GlobalLoadedRange = 1; 
                }  
             },
        newPosition : function (a)
        {
            document.getElementById("hiddenIsGridSliderChanged").value = "YES";
            document.getElementById("txtTotalrecord").value = a;
            document.getElementById("txtVGSliderMinPixel").value = a;            
            __doPostBack('btnHidden','');                                                       
        }
        });
    
}

//Code For Selection Area Highlighting
function showSelectedArea(varDivSA,objDivFirstSlider,objDivSecondSlider)
{
    //appendError("showSelectedArea : " + varDivSA);
    if(document.getElementById(varDivSA) != null)
    {
        var objSelDiv =  document.getElementById(varDivSA);
        objSelDiv.style.left =  parseInt(parseInt(objDivFirstSlider.style.left) + parseInt(10)) + "px";	        

        if((parseInt(objDivSecondSlider.style.left) - parseInt(objDivFirstSlider.style.left)) > 9)
        {
            objSelDiv.style.width = parseInt(parseInt(objDivSecondSlider.style.left) - parseInt(objDivFirstSlider.style.left) - parseInt(9)) + "px";		   
        }
        else
        {
            objSelDiv.style.width = parseInt(parseInt(objDivSecondSlider.style.left) - parseInt(objDivFirstSlider.style.left)) + "px";		   
        }
    }
    else
    {  
        var varcontSA = objDivFirstSlider.parentNode;
        var objSelDiv = document.createElement('div');			
        objSelDiv.setAttribute('id', varDivSA);		       		
        objSelDiv.style.top  = (parseInt(objDivFirstSlider.style.top) + parseInt(10))+ "px";

        if(isIE)
        {		        
            var objImage111 = document.createElement("img");
            objImage111.style.height = "3"
            objSelDiv.style.height=objImage111.height+'px';            
            objSelDiv.style.fontSize='0px';
        }
        else //Mozilla
        {
            objSelDiv.style.height=  "2px";
        }
        //IE 7
         //For IE 7
        if(varIEVersion.indexOf("7") != -1)
        {
            objSelDiv.style.height= "2px";
            objSelDiv.style.top  = (parseInt(objDivFirstSlider.style.top) + parseInt(10))+ "px";
        }
        
        //appendError("Left " + varDivSA + " Second :" + objDivSecondSlider.style.left + "<br/> First : " + objDivFirstSlider.style.left);
        // objSelDiv.style.width = parseInt(parseInt(objDivSecondSlider.style.left) - parseInt(objDivFirstSlider.style.left) - parseInt(9)) + "px";		
        objSelDiv.style.width =  "355px";		
        objSelDiv.style.left = parseInt(10) + "px";				       			
        varcontSA.appendChild(objSelDiv);	      
    }	  
 }

//Code for Sliding price

function ShowSlidingPrice(selectedVal1,selectedVal2)
{    
   var divSlidingPrice1 = document.getElementById("divPopupFirstSlider");	
   	
	if(divSlidingPrice1 != null)
	{	  		
		divSlidingPrice1.style.left = divGFirstSlider.style.left;  
		divSlidingPrice1.style.position = divGFirstSlider.style.position;  
		divSlidingPrice1.innerHTML = "$"+ formatCurrency(selectedVal1);
		
		var divSlidingPrice2 = document.getElementById("divPopupSecondSlider");
		if(divSlidingPrice2 != null)
	    {	       
		    divSlidingPrice2.style.left = divGSecondSlider.style.left; 
		    divSlidingPrice2.style.position = divGSecondSlider.style.position; 
		    divSlidingPrice2.innerHTML = "$"+formatCurrency(selectedVal2);
		}				  
		   var varSecondSliderPos = parseInt(divGSecondSlider.style.left);
		   var varFirstSliderPos =parseInt(divGFirstSlider.style.left);
		   var varDifference = (parseInt(varSecondSliderPos) - parseInt(varFirstSliderPos));
		   
		   if(varSecondSliderPos > 330) //Extreme At Slider 2
	       {
	            divSlidingPrice2.style.left =313 + "px";
	            if(parseInt(varDifference) < parseInt(93))
		        {
		             divSlidingPrice1.style.left = 250 +"px";
		        }
	       }
	       else if(varFirstSliderPos < 30)
	       {
	         if(parseInt(varDifference) < parseInt(40))
	            {
	                 divSlidingPrice2.style.left = 55 +"px";
	                if(varFirstSliderPos > 6)
	                {
	                 divSlidingPrice1.style.left = 4 +"px";
	                }
	            }	           
	       }
	       else if(parseInt(varDifference) < parseInt(50))
	       {	    
	           divSlidingPrice1.style.left = parseInt(parseInt(varFirstSliderPos) - parseInt("35")) + "px";	      	             
               divSlidingPrice2.style.left = parseInt(parseInt(varSecondSliderPos) + parseInt("20")) + "px";               		     	      
	       }
	       
//	       //divPopupSelectedArea
	       if(document.getElementById("divSAPrice") != null)
	       {
	            var objSelDiv =  document.getElementById("divSAPrice");
	            objSelDiv.style.left =  parseInt(parseInt(divGFirstSlider.style.left) + parseInt(10)) + "px";	        
	            
	            if((parseInt(divGSecondSlider.style.left) - parseInt(divGFirstSlider.style.left)) > 9)
	            {
	                objSelDiv.style.width = parseInt(parseInt(divGSecondSlider.style.left) - parseInt(divGFirstSlider.style.left) - parseInt(9)) + "px";		   
	            }
	            else
	            {
	                objSelDiv.style.width = parseInt(parseInt(divGSecondSlider.style.left) - parseInt(divGFirstSlider.style.left)) + "px";		   
	            }
	       }
	       else
	       {  
	            var varcontSA = divGFirstSlider.parentNode;
	            var objSelDiv = document.createElement('div');			
		        objSelDiv.setAttribute('id', 'divSAPrice');		       		
		        objSelDiv.style.top  = (parseInt(divGFirstSlider.style.top) + parseInt(10))+ "px";
		        
		        if(isIE)
		        {		        
		            var objImage111 = document.createElement("img");
		            objImage111.style.height = "3"
		            objSelDiv.style.height=objImage111.height+'px';
                    objSelDiv.style.fontSize='0px';
                }
                else //Mozilla
                {
                     objSelDiv.style.height=  "2px";
                }       
                
                 //For IE 7
                if(varIEVersion.indexOf("7") != -1)
                {
                    objSelDiv.style.height= "2px";
                    objSelDiv.style.top  = (parseInt(divGFirstSlider.style.top) + parseInt(10))+ "px";
                }        
               
	            objSelDiv.style.width = parseInt(parseInt(divGSecondSlider.style.left) - parseInt(divGFirstSlider.style.left) - parseInt(9)) + "px";		
		        objSelDiv.style.left = parseInt(parseInt(divGFirstSlider.style.left) + parseInt(10)) + "px";				       			
		        varcontSA.appendChild(objSelDiv);	      
	       }	  
	}
	else
	{	   
		var varcont = divGFirstSlider.parentNode;
		var newdiv = document.createElement('div');			
		newdiv.setAttribute('id', 'divPopupFirstSlider');	
		newdiv.style.top  = parseInt(divGFirstSlider.style.top) + parseInt("25");	
		if(!isIE)
		    newdiv.style.top = "25px";				
		newdiv.style.left = divGFirstSlider.style.left;		
		newdiv.innerHTML = "$" +formatCurrency(selectedVal1);			
		varcont.appendChild(newdiv);
		
		//Second Slider		
		var newdiv2 = document.createElement('div');			
		newdiv2.setAttribute('id', 'divPopupSecondSlider');			
		newdiv2.innerHTML = "$"+formatCurrency(selectedVal2);			
		newdiv2.style.top  = parseInt(divGSecondSlider.style.top) + parseInt("25");	
		if(!isIE)
		    newdiv2.style.top = "25px";			
		newdiv2.style.left = divGSecondSlider.style.left;			
		varcont.appendChild(newdiv2);			
	}		
	
	//showSelectedArea();	 
}



function appendError(varErrorInfo)
{
    var varErrorDiv = document.getElementById('divPopupErrInfo');
    if(!(varErrorDiv != null))
    {
        var newdiv12 = document.createElement('div');			
	    newdiv12.setAttribute('id', 'divPopupErrInfo');	
	    document.body.appendChild(newdiv12);
	    varErrorDiv = document.getElementById('divPopupErrInfo');		
	}
	varErrorDiv.innerHTML += "<br>" + varErrorInfo;			
}

function GetAllDivs()
{
		var allDivs = document.getElementsByTagName('div');	
		var varStr = "";
		var str = "";
		for(counter1=0;counter1<allDivs.length;counter1++)
		{
			if(allDivs[counter1] != null)
				varStr += "  ---  " + allDivs[counter1].id;

			try
			{
				str += 	"( "+allDivs[counter1].id + "="+ document.getElementById(allDivs[counter1].id).style.top + "--" +document.getElementById(allDivs[counter1].id).style.left + "--" +document.getElementById(allDivs[counter1].id).style.position + ")";
			}
			catch (e)
			{
			}
			
		}		
}
	
function ScanMyDiv(varDivId)
{
    var objDiv =  document.getElementById(varDivId);
    var varDivInfo = "";
    if(objDiv != null)
    {
       varDivInfo = "<br/>This is Div : " + varDivId +"<br/>";
       varDivInfo +="Number Of Divs inside : " + objDiv.getElementsByTagName('div').length + "<br/>"; 
       
       varDivInfo +="Child Divs : "
       var objChilds = objDiv.getElementsByTagName('div');
       var varCounter = 0;
       for(varCounter = 0; varCounter < objChilds.length;varCounter++)
       {
         varDivInfo += objChilds[varCounter].id;
         ScanMyDiv(objChilds[varCounter].id);
       }
    }
    appendError(varDivInfo);
}

//Currency formatting
  function addCommas(number)
   {
      return ((number.length > 3) ? (addCommas(number.substring(0, number.length - 3)) + "," + number.substring(number.length - 3, number.length)) : 
         String(number));
   }
 
   function moneyToNumber(money)
   {
      var number = money.replace("$", "");
      while (number.indexOf(",") > -1)
      {
         number = number.replace(",", "");
      }
	  if ((number.length)<1) return 0; else return number;
   }

   function formatCurrency(varValueToConvert)
   { 
        //return varValueToConvert;
        if(varValueToConvert != "")
        {    
              var number     = moneyToNumber(varValueToConvert);
              var negative   = (number.substr(0, 1) == "-");
              number         = number.replace("-", "");
              var floatArray = number.split(".");
              floatArray[0]  = "" + parseFloat(floatArray[0]);
              var newValue   = addCommas(floatArray[0]);
              if (floatArray[1] != undefined)
              {
                // newValue += "." + floatArray[1].substr(0, 2);
              }
              if (negative)
              {
                 newValue = "-" + newValue;
              }     
              return newValue;
        }
   }
  
function creatPreviewToolBar(varErrorInfo)
{
    var varErrorDiv = document.getElementById('divPopupErrInfo');
    if(!(varErrorDiv != null))
    {
        var newdiv12 = document.createElement('div');			
	    newdiv12.setAttribute('id', 'divPopupErrInfo');
	    	
	    document.body.appendChild(newdiv12);
	    varErrorDiv = document.getElementById('divPopupErrInfo');		
	}
	varErrorDiv.innerHTML += "<br>" + varErrorInfo;			
}


function previewShapes(varImgURL,varZooomURL)
{
    if(varImgURL != "NotFound")
    {
        document.getElementById("imgMainImage").style.display = "block";
        document.getElementById("hypZoom").style.display = "block";
        document.getElementById("imgMainImage").src = varImgURL;    
        document.getElementById("hypZoom").href="javascript:void(window.open('"+ varZooomURL +"','zoomimage','width=550,height=460,scrollbars=no,resizable=no'));"
    }
    else
    {
        document.getElementById("imgMainImage").style.display = "none";
        document.getElementById("hypZoom").style.display = "none";
        //document.getElementById("imgMainImage").style.visible = false;    
       // document.getElementById("hypZoom").href="javascript:void(window.open('"+ varZooomURL +"','zoomimage','width=550,height=460,scrollbars=no,resizable=no'));"

    }
}

function previewClicked(varPreviewImage)
{
    document.getElementById("hidPreviewImage").value = varPreviewImage;
    __doPostBack('btnHiddenPreview','');         
}

function funcDiamondSelected(objChk,varSelectedDiaCode)
{
    if(objChk.checked)
    {      
       document.getElementById('hiddenNumOfDiaSelected').value = parseInt(document.getElementById('hiddenNumOfDiaSelected').value) + parseInt(1);
    }
    else
    {
        document.getElementById('hiddenNumOfDiaSelected').value = parseInt(document.getElementById('hiddenNumOfDiaSelected').value) - parseInt(1);                
    }
    
    if((parseInt(document.getElementById('hiddenNumOfDiaSelected').value)  == 1) && objChk.checked)
    {
        document.getElementById('hidDiamondCode').value = varSelectedDiaCode;        
        document.getElementById('hiddenDiamondSelected').value = "YES";
        __doPostBack('btnHiddenForDiamond','');   
    }
}