function load()
{
    for(var i = 0;i<10;i++)
    {
        $ge("divUp"+i).style.left = $ge("imgUp"+i).offsetLeft;
        $ge("divDown"+i).style.left = $ge("imgDown"+i).offsetLeft;
    }

    for(var i = 6;i<10;i++)
    {
        $ge("divVisible"+i).style.left = $ge("imgUp"+i).offsetLeft;
    }
    $ge("divVisible0").style.left = $ge("imgUp0").offsetLeft;
    
    
    
    if(document.getElementById(globals.controlIdentities.chfConPrice).value != "")
    {
   
        commonSearchInit("price",document.getElementById(globals.controlIdentities.chfConPrice).value);
    }
    else if(document.getElementById(globals.controlIdentities.chfConWeight).value != "")
    {
        commonSearchInit("weight",document.getElementById(globals.controlIdentities.chfConWeight).value);
    }
}

function ReSearch(){



}


function $ge(obj){ 
return document.getElementById(obj); 
} 

var sPosition;

document.onmousedown=dragLayer;
document.onmouseup=new Function("dragMe=false");


//?色??
var Color= new Array();
Color[0] = "D";
Color[1] = "E";
Color[2] = "F";
Color[3] = "G";
Color[4] = "H";
Color[5] = "I";
Color[6] = "J";

//?度??

var Clarity = new Array();
Clarity[0] = "FL";
Clarity[1] = "IF";
Clarity[2] = "VVS1";
Clarity[3] = "VVS2";
Clarity[4] = "VS1";
Clarity[5] = "VS2";
Clarity[6] = "SI1";
Clarity[7] = "SI2";

//切工??
var Cut = new Array();
Cut[0] = "EX";
Cut[1] = "VG";
Cut[2] = "G";
Cut[3] = "F";

//?光度??

var Fluorescence = new Array();
Fluorescence[0] = "N";
Fluorescence[1] = "F";
Fluorescence[2] = "MB";
Fluorescence[3] = "SB";
Fluorescence[4] = "VSB";

//回?事件
//根据?入?值判?按?位置

document.onkeydown=Enter;
function Enter(e)
{
    var code = (window.event) ? event.keyCode : e.which;
    if (code==13) 
    {
        if($ge("hfStartCarat").value == "true")
        {
            var max = $ge("ctl00_cphContent_hfCaratMax").value;
            var min = $ge("ctl00_cphContent_hfCaratMin").value;
            var avg = (max-min)/162;
            var value = $ge("ctl00_cphContent_tbStartCarat").value;
            if(!IsPlusNumeric(value))
            {
                alert("你?入的不正确！");
                return;
            }
            var point = Math.pow((max - value) / (max - min), 4) * 162;
            if(point<0)
            {
                point = 0;
            }
            if(point>162)
            {
                point = 162;
            }
            
            var top = $ge("imgDown1").style.pixelTop;
            if(point>top)
            {
                point = top;
            }
            $ge("imgUp1").style.pixelTop = point;
            sPosition = point;
            SetUpDiv("divUp1","imgUp1");
        }
        else if($ge("hfEndCarat").value == "true")
        {
            var max = $ge("ctl00_cphContent_hfCaratMax").value;
            var min = $ge("ctl00_cphContent_hfCaratMin").value;
            var avg = (max-min)/162;
            var value = $ge("ctl00_cphContent_tbEndCarat").value;
            if(!IsPlusNumeric(value))
            {
                alert("你?入的不正确！");
                return;
            }
            var point = Math.pow((max - value) / (max - min), 4) * 162;
            if(point<0)
            {
                point = 0;
            }
            if(point>162)
            {
                point = 162;
            }
            
            var top = $ge("imgUp1").style.pixelTop;
            if(point<top)
            {
                point = top;
            }
            $ge("imgDown1").style.pixelTop = point;
            sPosition = point;
            SetDownDiv("divDown1","imgDown1");
        }
        else if($ge("hfStartPrice").value == "true")
        {
        
            var max = document.getElementById(globals.controlIdentities.chfPriceMax).value;
            var min = document.getElementById(globals.controlIdentities.chfPriceMin).value;
            var avg = (max-min)/162;
            var value = document.getElementById(globals.controlIdentities.ctbStartPrice).value;
            if(value.substring(0,1) == "¥")
            {
                value = value.substring(1,value.length);
                //alert(value);
            }
            if(!IsPlusNumeric(value))
            {
                alert("你?入的不正确！");
                return;
            }

            //var point = parseInt((max - value)/avg);
            
            var point = Math.pow((max - value) / (max - min), 20) * 162;
            
            if(point<0)
            {
                point = 0;
            }
            if(point>162)
            {
                point = 162;
            }
            
            var top = $ge("imgDown2").style.pixelTop;
            if(point>top)
            {
                point = top;
            }
            $ge("imgUp2").style.pixelTop = point;
            sPosition = point;
            SetUpDiv("divUp2","imgUp2");
        }
        else if($ge("hfEndPrice").value == "true")
        {
			
            var max = document.getElementById(globals.controlIdentities.chfPriceMax).value;
            var min = document.getElementById(globals.controlIdentities.chfPriceMin).value;
            
            var avg = (max-min)/162;
            var value = getElementById(globals.controlIdentities.ctbEndPrice).value;
            if(value.substring(0,1) == "¥")
            {
                value = value.substring(1,value.length);
                //alert(value);
            }
            if(!IsPlusNumeric(value))
            {
                alert("你?入的不正确！");
                return;
            }
            var point = Math.pow((max - value) / (max - min), 20) * 162;
            if(point<0)
            {
                point = 0;
            }
            if(point>162)
            {
                point = 162;
            }
            
            var top = $ge("imgUp2").style.pixelTop;
            if(point<top)
            {
                point = top;
            }
            $ge("imgDown2").style.pixelTop = point;
            sPosition = point;
            SetDownDiv("divDown2","imgDown2");
        }
        else if($ge("hfStartDepth").value == "true")
        {
        
            var max = document.getElementById(globals.controlIdentities.chfDepthMax).value;
            var min = document.getElementById(globals.controlIdentities.chfDepthMin).value;
            var avg = (max-min)/162;
            var value = $ge("tbStartDepth").value;
            if(!IsPlusNumeric(value))
            {
                alert("你?入的不正确！");
                return;
            }
            var point = parseInt((max - value)/avg);
            if(point<0)
            {
                point = 0;
            }
            if(point>162)
            {
                point = 162;
            }
            
            var top = $ge("imgDown8").style.pixelTop;
            if(point>top)
            {
                point = top;
            }
            $ge("imgUp8").style.pixelTop = point;
            sPosition = point;
            SetUpDiv("divUp8","imgUp8");
        }
        else if($ge("hfEndDepth").value == "true")
        {
        
            var max = document.getElementById(globals.controlIdentities.chfDepthMax).value;
            var min = document.getElementById(globals.controlIdentities.chfDepthMin).value;
            var avg = (max-min)/162;
            var value = $ge("tbEndDepth").value;
            if(!IsPlusNumeric(value))
            {
                alert("你?入的不正确！");
                return;
            }
            var point = parseInt((max - value)/avg);
            if(point<0)
            {
                point = 0;
            }
            if(point>162)
            {
                point = 162;
            }
            
            var top = $ge("imgUp8").style.pixelTop;
            if(point<top)
            {
                point = top;
            }
            $ge("imgDown8").style.pixelTop = point;
            sPosition = point;
            SetDownDiv("divDown8","imgDown8");
        }
        else if($ge("hfStartTable").value == "true")
        {
        
            var max = document.getElementById(globals.controlIdentities.chfTableMa).value;
            var min = document.getElementById(globals.controlIdentities.chfTableMin).value;
            var avg = (max-min)/162;
            var value = $ge("tbStartTable").value;
            if(!IsPlusNumeric(value))
            {
                alert("你?入的不正确！");
                return;
            }
            var point = parseInt((max - value)/avg);
            if(point<0)
            {
                point = 0;
            }
            if(point>162)
            {
                point = 162;
            }
            
            var top = $ge("imgDown9").style.pixelTop;
            if(point>top)
            {
                point = top;
            }
            $ge("imgUp9").style.pixelTop = point;
            sPosition = point;
            SetUpDiv("divUp9","imgUp9");
        }
        else if($ge("hfEndTable").value == "true")
        {
        
            var max = document.getElementById(globals.controlIdentities.chfTableMax).value;
            var min = document.getElementById(globals.controlIdentities.chfTableMin).value;
            var avg = (max-min)/162;
            var value = $ge("tbEndTable").value;
            
            if(!IsPlusNumeric(value))
            {
                alert("你?入的不正确！");
                return;
            }
            var point = parseInt((max - value)/avg);
            if(point<0)
            {
                point = 0;
            }
            if(point>162)
            {
                point = 162;
            }
            
            var top = $ge("imgUp9").style.pixelTop;
            if(point<top)
            {
                point = top;
            }
            $ge("imgDown9").style.pixelTop = point;
            sPosition = point;
            SetDownDiv("divDown9","imgDown9");
        }
        
     }
}

//根据刻度?置克拉
function SetStartCarat()
{

    var max = document.getElementById(globals.controlIdentities.chfCaratMax).value;
    var min = document.getElementById(globals.controlIdentities.chfCaratMin).value;
    var avg = (max-min)/162;
    
    var price = max - Math.pow(sPosition/162, 1/4)*(max-min);
   
    if(price<min)
    {
        price = min-0;
    }
  
	document.getElementById(globals.controlIdentities.ctbStartCarat).value = price.toFixed(2);
}
function SetEndCarat()
{

    var max = document.getElementById(globals.controlIdentities.chfCaratMax).value;
    var min = document.getElementById(globals.controlIdentities.chfCaratMin).value;
    var avg = (max-min)/162;
   
    var price = max - Math.pow(sPosition/162, 1/4)*(max-min);
   
    if(price<min)
    {
        price = min-0;
    }

	 document.getElementById(globals.controlIdentities.ctbEndCarat).value = price.toFixed(2);
}


function SetEndCarat2(intmin, intmax, flat)
{

    var max = document.getElementById(globals.controlIdentities.chfCaratMax).value;
    var min = intmin;
    var avg = (max-min)/162;
	
    var price = max - Math.pow(intmin, 1/4)*(max-min);

    if(price<min)
    {
        price = min-0;
    }
		
    document.getElementById('imgDown1').style.pixelTop = ((max-min)/max)*162;
	document.getElementById(globals.controlIdentities.ctbEndCarat).value = intmin;
	

	
	
	
}


//根据刻度?置价?
function SetStartPrice()
{

    var max = document.getElementById(globals.controlIdentities.chfPriceMax).value;
    var min = document.getElementById(globals.controlIdentities.chfPriceMin).value;
    var avg = (max-min)/162;
    
    //var price = max - sPosition * avg;
    
    var price = max - Math.pow(sPosition/162, 1/20)*(max-min);


    if(price<min)
    {
        price = min-0;
    }
  
	document.getElementById(globals.controlIdentities.ctbStartPrice).value = Math.ceil(price);
}
function SetEndPrice()
{

    var max = document.getElementById(globals.controlIdentities.chfPriceMax).value;
    var min = document.getElementById(globals.controlIdentities.chfPriceMin).value;
    var avg = (max-min)/162;
    
    var price = max - Math.pow(sPosition/162, 1/20)*(max-min);
   
    if(price<min)
    {
        price = min-0;
    }
 
	 document.getElementById(globals.controlIdentities.ctbEndPrice).value = Math.ceil(price);
}
//根据刻度?置?度

function SetStartClarity() {
    var i = (sPosition-9)/20;
    i = parseInt(i);
    if(i-1>=7)
    {
        i = 7;
    }
    
	$ge("tbStartClarity").value = Clarity[i];
}

function SetEndClarity() {
    var i = (sPosition+9)/20;
    i = parseInt(i);
    if(i-1>=7)
    {
        i = 7;
    }
    
	$ge("tbEndClarity").value = Clarity[i];
}

//根据刻度?置?色
function SetStartColor() {
    var i = (sPosition-10)/23;
    i = parseInt(i);
    if(i-1>=6)
    {
        i = 6;
    }
    
	$ge("tbStartColor").value = Color[i];
}

function SetEndColor() {
    var i = (sPosition+10)/23;
    i = parseInt(i);
    if(i-1>=6)
    {
        i = 6;
    }
    
	$ge("tbEndColor").value = Color[i];
}
//根据刻度?置Cut
function SetStartCut() {
    var i = (sPosition-10)/40;
    i = parseInt(i);
    if(i-1>=3)
    {
        i = 3;
    }
    
	$ge("tbStartCut").value = Cut[i];
}

function SetEndCut() {
    var i = (sPosition+15)/40;
    i = parseInt(i);
    if(i-1>=3)
    {
        i = 3;
    }
    
	$ge("tbEndCut").value = Cut[i];
}

//根据刻度?置Polish
function SetStartPolish()
{
    var i = (sPosition-10)/40;
    i = parseInt(i);
    if(i-1>=3)
    {
        i = 3;
    }
    
	$ge("tbStartPolish").value = Cut[i];
}
function SetEndPolish()
{
    var i = (sPosition+15)/40;
    i = parseInt(i);
    if(i-1>=3)
    {
        i = 3;
    }
    
	$ge("tbEndPolish").value = Cut[i];
}

//根据刻度?置Symmetry
function SetStartSymmetry()
{
    var i = (sPosition-10)/40;
    i = parseInt(i);
    if(i-1>=3)
    {
        i = 3;
    }
    
	$ge("tbStartSymmetry").value = Cut[i];
}

function SetEndSymmetry()
{
    var i = (sPosition+15)/40;
    i = parseInt(i);
    if(i-1>=3)
    {
        i = 3;
    }
    
	$ge("tbEndSymmetry").value = Cut[i];
}

//根据刻度?置Depth
function SetStartDepth()
{
  
    var max = document.getElementById(globals.controlIdentities.chfDepthMax).value;
    var min = document.getElementById(globals.controlIdentities.chfDepthMin).value;
    var avg = (max-min)/162;
    
    var price = max - sPosition*avg;
    //alert(max);
    if(price<min)
    {
        price = min-0;
    }
  
	$ge("tbStartDepth").value = price.toFixed(1);
}

function SetEndDepth()
{

    var max = document.getElementById(globals.controlIdentities.chfDepthMax).value;
    var min = document.getElementById(globals.controlIdentities.chfDepthMin).value;
    var avg = (max-min)/162;
    var price = max - sPosition*avg;
    if(price<min)
    {
        price = min-0;
    }
  
	$ge("tbEndDepth").value = price.toFixed(1);
}

//根据刻度?置Table
function SetStartTable()
{

    var max = document.getElementById(globals.controlIdentities.chfTableMax).value;
    var min = document.getElementById(globals.controlIdentities.chfTableMin).value;
    var avg = (max-min)/162;
    var price = max - sPosition*avg;
    if(price<min)
    {
        price = min-0;
    }
  
	$ge("tbStartTable").value = price.toFixed(1);
}

function SetEndTable()
{
    var max = document.getElementById(globals.controlIdentities.chfTableMax).value;
    var min = document.getElementById(globals.controlIdentities.chfTableMin).value;
    var avg = (max-min)/162;
    var price = max - sPosition*avg;
    if(price<min)
    {
        price = min-0;
    }
  
	$ge("tbEndTable").value = price.toFixed(1);
}

//根据刻度?置Fluorescence
function SetStartFluorescence()
{
    var i = (sPosition-10)/32;
    i = parseInt(i);
    if(i-1>=4)
    {
        i = 4;
    }
    
	$ge("tbStartFluorescence").value = Fluorescence[i];
}

function SetEndFluorescence()
{
    var i = (sPosition+15)/32;
    i = parseInt(i);
    if(i-1>=4)
    {
        i = 4;
    }
    
	$ge("tbEndFluorescence").value = Fluorescence[i];
}

//?置拖拉按?后的div灰?
function SetDownDiv(id,ref_id)
{
    $ge(id).style.left = $ge(ref_id).offsetLeft;
    $ge(id).style.height = 162-sPosition+10 + 'px';      
	$ge(id).style.pixelTop = 274-(162-sPosition);
	
	if (!window.event) { $ge(id).style.top = 274 - (162-sPosition) + 'px'; $ge(ref_id).style.top = (sPosition) +'px'; }
}

function SetUpDiv(id,ref_id)
{

    $ge(id).style.left = $ge(ref_id).offsetLeft;
    $ge(id).style.height = sPosition+7 +'px';
    
    if (!window.event) { $ge(ref_id).style.top = sPosition +'px'; }
}
var dragMe=false, kObj, yPos,kObj1;

//?鼠?拖??触?事件
function moveLayer(e) {
  var code = (window.event) ? event.keyCode : e.which;
  var ex = (window.event) ? event : e;
  if (!temp2) { 
    if (kObj.id.indexOf('Down') > -1) {
      temp2 = 162;
    }
    else {
      temp2 = 0;
    }
  }
  
if ((code==1 || event.button == 1) && dragMe) {
    kObj.style.pixelTop=temp2+ex.clientY-yPos; 
    if(kObj.id.length == 8)
    {
        if (!kObj1.style.pixelTop) kObj1.style.pixelTop = 0;
	    if(kObj.style.pixelTop < kObj1.style.pixelTop)
	    {
	        kObj.style.pixelTop = kObj1.style.pixelTop;
	    }
	    if(kObj.style.pixelTop > 162)
	    {
	        kObj.style.pixelTop = 162;
	    }
	    sPosition=kObj.style.pixelTop; 
	    
	    switch(kObj.id)
	    {
	        case "imgDown1" :
	        //alert($ge("divDown1").style.left);
            SetDownDiv("divDown1","imgDown1");
	        SetEndCarat();
	        break;
	        case "imgDown2" :
	        SetDownDiv("divDown2","imgDown2");
	        SetEndPrice();
	        break;
	        case "imgDown3" :
	        SetDownDiv("divDown3","imgDown3");
	        SetEndClarity();
	        break;
	        case "imgDown4" :
	        SetDownDiv("divDown4","imgDown4");
	        SetEndColor();
	        break;
	        case "imgDown5" :
	        SetDownDiv("divDown5","imgDown5");
	        SetEndCut();
	        break;
	        case "imgDown6" :
	        SetDownDiv("divDown6","imgDown6");
	        SetEndPolish();
	        break;
	        case "imgDown7" :
	        SetDownDiv("divDown7","imgDown7");
	        SetEndSymmetry();
	        break;
	        case "imgDown8" :
	        SetDownDiv("divDown8","imgDown8");
	        SetEndDepth();
	        break;
	        case "imgDown9" :
	        SetDownDiv("divDown9","imgDown9");
	        SetEndTable();
	        break;
	        case "imgDown0" :
	        SetDownDiv("divDown0","imgDown0");
	        SetEndFluorescence();
	        break;
	    }
	}
	else if (kObj.id.length == 6)
	{
	    if (!kObj1.style.pixelTop) kObj1.style.pixelTop = 162;
	    if(kObj.style.pixelTop > kObj1.style.pixelTop)
	    {
	        kObj.style.pixelTop = kObj1.style.pixelTop;
	    }
	    if(kObj.style.pixelTop < 0)
	    {
	        kObj.style.pixelTop = 0;
	    }
	    sPosition= parseInt(kObj.style.pixelTop); 
	    switch(kObj.id)
	    {
	        case "imgUp1" :
	        SetUpDiv("divUp1","imgUp1");
	        SetStartCarat();
	        break;
	        case "imgUp2" :
	        SetUpDiv("divUp2","imgUp2");
	        SetStartPrice();
	        break;
	        case "imgUp3" :
	        SetUpDiv("divUp3","imgUp3");
	        SetStartClarity();
	        break;
	        case "imgUp4" :
	        SetUpDiv("divUp4","imgUp4");
	        SetStartColor();
	        break;
	        case "imgUp5" :
	        SetUpDiv("divUp5","imgUp5");
	        SetStartCut();
	        break;
	        case "imgUp6" :
	        SetUpDiv("divUp6","imgUp6");
	        SetStartPolish();
	        break;
	        case "imgUp7" :
	        SetUpDiv("divUp7","imgUp7");
	        SetStartSymmetry();
	        break;
	        case "imgUp8" :
	        SetUpDiv("divUp8","imgUp8");
	        SetStartDepth();
	        break;
	        case "imgUp9" :
	        SetUpDiv("divUp9","imgUp9");
	        SetStartTable();
	        break;
	        case "imgUp0" :
	        SetUpDiv("divUp0","imgUp0");
	        SetStartFluorescence();
	        break;
	    }
	}
	return false; }
}

//?鼠?按下?触?事件
function dragLayer(e) {
    var code = (window.event) ? event.keyCode : e.which;

    //if (!document.all) return;
    var srcObj;
    try {
      srcObj = (window.event) ? event.srcElement : e.target;
    }
    catch(e) {
      srcObj = event.srcElement;
    }
    
    if(srcObj.className == "search_box" ||srcObj.className == "hd_wd") { }
    //alert(event.clientY)
    if (srcObj.className=="up"||srcObj.className=="down")	
    {
    
        dragMe=true; 
        kObj=srcObj; 
        switch(kObj.id)
        {
            case "imgUp1":
            kObj1 = $ge("imgDown1");
            break;
            case "imgDown1":
            kObj1 = $ge("imgUp1");
            break; 
            
            case "imgUp2" :
            kObj1 = $ge("imgDown2");
            break;
            case "imgDown2" :
            kObj1 = $ge("imgUp2");
            break; 
            
            
            case "imgUp3" :
            kObj1 = $ge("imgDown3");
            break;
            case "imgDown3" :
            kObj1 = $ge("imgUp3");
            break;
            
            case "imgUp4" :
            kObj1 = $ge("imgDown4");
            break;
            case "imgDown4" :
            kObj1 = $ge("imgUp4");
            break;
            
            case "imgUp5" :
            kObj1 = $ge("imgDown5");
            break;
            case "imgDown5" :
            kObj1 = $ge("imgUp5");
            break; 
            
            case "imgUp6" :
            kObj1 = $ge("imgDown6");
            break;
            case "imgDown6" :
            kObj1 = $ge("imgUp6");
            break; 
            
            case "imgUp7" :
            kObj1 = $ge("imgDown7");
            break;
            case "imgDown7" :
            kObj1 = $ge("imgUp7");
            break; 
            
            case "imgUp8" :
            kObj1 = $ge("imgDown8");
            break;
            case "imgDown8" :
            kObj1 = $ge("imgUp8");
            break; 
            
            case "imgUp9" :
            kObj1 = $ge("imgDown9");
            break;
            case "imgDown9" :
            kObj1 = $ge("imgUp9");
            break; 
            
            case "imgUp0" :
            kObj1 = $ge("imgDown0");
            break;
            case "imgDown0" :
            kObj1 = $ge("imgUp0");
            break; 
        }
        temp2=kObj.style.pixelTop; 
        yPos= (window.event) ? event.clientY : e.clientY;
        document.onmousemove=moveLayer; 
        //alert(temp2);
        //alert(yPos);
    }
}

function showDiv(checkBox,div)
{
    if($ge(checkBox).checked == true)
    {
        $ge(div).style.display = "none";
    }
    else
    {
        $ge(div).style.display = "block";
    }
}

function change(id)
{
    //alert(id);
    var tagName = document.getElementsByName('hd');
    //alert(tagName.length)
    for(var i = 0;i<tagName.length;i++)
    {
        if(tagName[i].id == id)
        {
            tagName[i].value = "true";
        }
        else
        {
            tagName[i].value = "false";
        }
    }
}

//判?是否??字（正?或小?）
function IsPlusNumeric(fData)
{
    if ((isNaN(fData)) || (fData.indexOf("-")!=-1))
        return false; 
    if(fData.indexOf(".") == fData.length-1)
        return false;
    return true;    
} 

var orderBy = "";
function SearchDiamond()
{

    $ge('hfPageIndex').value = 1;

    //$ge("hfChoose").value = "";
    popDiv();
    orderBy = "";    
    Search();
	
}

function Search()
{

    var startCarat = document.getElementById(globals.controlIdentities.ctbStartCarat).value;
    var endCarat = document.getElementById(globals.controlIdentities.ctbEndCarat).value;
    
    var startPrice = document.getElementById(globals.controlIdentities.ctbStartPrice).value;
    var endPrice = document.getElementById(globals.controlIdentities.ctbEndPrice).value;	
    var startClarity = $ge("tbStartClarity").value;
    var endClarity = $ge("tbEndClarity").value;
    var startColor = $ge("tbStartColor").value;
    var endColor = $ge("tbEndColor").value;
    
    var startCut = $ge("tbStartCut").value;
    var endCut = $ge("tbEndCut").value;
    
  


    var sizeFrom =  document.getElementById(globals.controlIdentities.chfSizeFrom).value;
   
    var sizeTo =  document.getElementById(globals.controlIdentities.chfSizeTo).value;

    var startPolish = "";
    var endPolish = "";
    var startSymmetry = "";
    var endSymmetry = "";
    var startDepth = "";
    var endDepth = "";
    var startTable = "";
    var endTable = "";
    var startFluorescence = "";
    var endFluorescence = "";
    var shape = "";

    if($ge("cbPolish").checked == true)
    {
        startPolish = $ge("tbStartPolish").value;
        endPolish = $ge("tbEndPolish").value;
    }

    if($ge("cbSymmetry").checked == true)
    {
        startSymmetry = $ge("tbStartSymmetry").value;
        endSymmetry = $ge("tbEndSymmetry").value;
    }
    
    if($ge("cbDepth").checked == true)
    {
        startDepth = $ge("tbStartDepth").value;
        endDepth = $ge("tbEndDepth").value;
        //判?用??入的depth
        if(!IsPlusNumeric(startDepth))
        {
            alert("你?入的Depth不正确！");
            return;
        }
        
        if(!IsPlusNumeric(endDepth))
        {
            alert("你?入的Depth不正确！");
            return;
        }
    }
    
    if($ge("cbTable").checked == true)
    {
        startTable = $ge("tbStartTable").value;
        endTable = $ge("tbEndTable").value;
        
        //判?用??入的Table
        if(!IsPlusNumeric(startTable))
        {
            alert("你?入的Table不正确！");
            return;
        }
        
        if(!IsPlusNumeric(endTable))
        {
            alert("你?入的Table不正确！");
            return;
        }
    }
    
    if($ge("cbFluorescence").checked == true)
    {
        startFluorescence = $ge("tbStartFluorescence").value;
        endFluorescence = $ge("tbEndFluorescence").value;
    }
    
    if($ge("cbRD").checked == true)
    {
        shape = "RD";
    }
    
    //判??入克拉是否正确
    if(!IsPlusNumeric(startCarat))
    {
        alert("你?入的克拉?不正确！");
        return;
    }
    if(!IsPlusNumeric(endCarat))
    {
        alert("你?入的克拉?不正确！");
        return;
    }
    //判?用??入价?是否正确
    if(startPrice.substring(0,1) == "¥")
    {
        //alert(startPrice.substring(0,1));
        
        startPrice = startPrice.substring(1,startPrice.length);
        //alert(startPrice);
    }
    if(!IsPlusNumeric(startPrice))
    {
        alert("你?入的价?不正确！");
        return;
    }
    
     if(endPrice.substring(0,1) == "¥")
    {
        endPrice = endPrice.substring(1,endPrice.length);
        //alert(value);
    }
    if(!IsPlusNumeric(endPrice))
    {
        alert("你?入的价?不正确！");
        return;
    }

    $ge("lbHtml").innerHTML = "";
    $ge("divLoading").style.display = "block";
//    if(event.srcElement.className == "DiamondSearch")
//    popDiv();

    var index = $ge("hfPageIndex").value;
    var sUrl;
    var sPara;

    sUrl = "diy-jewelry.aspx?id=diy-ring";

	sPara = "oper=search&startCarat="+startCarat+"&endCarat="+endCarat+"&startPrice="+startPrice+"&endPrice="+endPrice+"&startClarity="+startClarity+"&endClarity="+endClarity;
	sPara += "&startColor="+startColor+"&endColor="+endColor+"&startCut="+startCut+"&endCut="+endCut+"&startPolish="+startPolish+"&endPolish="+endPolish;
	sPara += "&startSymmetry="+startSymmetry+"&endSymmetry="+endSymmetry+"&startDepth="+startDepth+"&endDepth="+endDepth+"&startTable="+startTable;
	sPara += "&endTable="+endTable+"&startFluorescence="+startFluorescence+"&endFluorescence="+endFluorescence+"&shape="+shape+"&orderBy="+orderBy+"&sizeFrom="+sizeFrom+"&sizeTo="+sizeTo+"&index="+index;


    //ajaxDownloadUrlAsString(sUrl, sPara);
    $.post(sUrl, sPara.paramsToJson(), ajaxOut);
    
    
    

    
    //var request = new XMLHttpRequest();
	//request.open("POST", sUrl, true);
	  //  alert(1);
//Send the proper header information along with the request

    //alert(2);
//request.onreadystatechange = function() {//Call a function when the state changes.
	//if(request.readyState == 4 && request.status == 200) {
	//	alert(http.responseText);
	//}

    //alert(3);
//request.send(sPara);

    
    
}

function commonSearchInit(condition,value)
{
    $ge('hfPageIndex').value = 1;
    //popDiv();
    orderBy = "";
     
    commonSearch(condition,value);
}
function commonSearch(condition,value)
{
   Search();
    
   
}

function popDiv(){
	
	
    $ge('popDiv').style.display='block';
    
    //$ge('bg').style.display='block';
    
    //alert($ge("divInfo").style.left)
    $ge("divSearch").style.display = "block";
    
    $ge("divCompare").style.display = "none";
}

function closeDiv(){
    $ge('popDiv').style.display='none';
    $ge('bg').style.display='none';
    $ge("lbHtml").innerHTML = "";
    $ge("lbCompareHtml").innerHTML = "";
    //$ge("hfChoose").value = "";
    $ge("lbCount").innerHTML = "";
    $ge("lbCompareCount").innerHTML = "";
    
    document.getElementById(globals.controlIdentities.chfConPrice).value = "";
    document.getElementById(globals.controlIdentities.chfConWeight).value = "";
}

function BackMainDiv(){
    $ge('popDiv').style.display='none';
    $ge('bg').style.display='none';
    $ge("lbHtml").innerHTML = "";
    $ge("lbCompareHtml").innerHTML = "";
    //$ge("hfChoose").value = "";
    $ge("lbCount").innerHTML = ""; 
    $ge("lbCompareCount").innerHTML = "";
    
    document.getElementById(globals.controlIdentities.chfConPrice).value = "";
    document.getElementById(globals.controlIdentities.chfConWeight).value = "";
    document.getElementById('mainbox').style.display = 'block';
	document.getElementById('mbox').style.display = 'none';
}


//?鼠?移入行?示??信息
function ShowInfo(event, id,shape,carat,color,clarity,cut,symmetry,price,depth,table,polish,ying,lab,certNo,point)
{

    if (!cut || cut.trim() == '') {
      cut = '&nbsp; &nbsp;'; 
    }
    
    if (window.event) y= event.clientY-100-(event.clientY-20)/2;
    else y = 100-100-(0-20)/2;
    //var a = pageX(document.getElementById("divSearch")) - pageX(document.body)
    var show = $ge("divInfo");
    show.style.display = "block";
    show.style.top = y+"px";
    show.style.left = $ge("divSearch").offsetLeft-166;
    show.style.position="absolute";

    $ge("lbId").innerHTML = id;
    $ge("lbShape").innerHTML = shape;
    $ge("lbCarat").innerHTML = carat;
    $ge("lbClarity").innerHTML = clarity;
    $ge("lbCut").innerHTML = cut;
    $ge("lbSymmetry").innerHTML = symmetry;
    $ge("lbPrice").innerHTML = price;
    $ge("lbDepth").innerHTML = depth;
    $ge("lbTable").innerHTML = table;
    $ge("lbPolish").innerHTML = polish;
    $ge("lbYing").innerHTML = ying;
    $ge("lbLab").innerHTML = lab;
    $ge("lbCertNo").innerHTML = certNo;
    $ge("lbColor").innerHTML = color;  
}

//?鼠?移出行?藏?示的??信息

function Remove()
{
    $ge("divInfo").style.display = "none";
    
}

//比??石

function Compare()
{

    $ge("divSearch").style.display = "none";
    $ge("divCompare").style.display = "block";
    $ge('lbCompareHtml').innerHTML = "";
    $ge('lbCompareCount').innerHTML = "";
    var id = $ge("hfChoose").value;
    var sUrl;
    var sPara;
    sUrl = "diy-jewelry.aspx?id=diy-ring&cid="+id;
    //sUrl = "DiamondSearch.aspx";
  
    sPara = "oper=compare&cid="+id;
    //ajaxDownloadUrlAsString(sUrl, sPara);
    
    $.post(sUrl, sPara.paramsToJson(), ajaxOut);
}

//查??果排序
function OrderBy(field)
{
    $ge("lbHtml").innerHTML = "";
    var order = $ge("hf"+field);
    if(order.value == "")
    {
        orderBy = field + " asc";
        order.value = "asc";
        $ge("img"+field).src = "../../Images/DiyRing/pic_ar_02.gif";
    }
    else if(order.value == "asc")
    {
        orderBy = field + " desc";
        order.value = "desc";
        $ge("img"+field).src = "../../Images/DiyRing/pic_ar_01.gif";
    }
    else
    {
        orderBy = field + " asc";
        order.value = "asc";
        $ge("img"+field).src = "../../Images/DiyRing/pic_ar_02.gif";
    }
   
    if(document.getElementById(globals.controlIdentities.chfConPrice).value != "")
    {
        commonSearch("price",document.getElementById(globals.controlIdentities.chfConPrice).value);
    }
    else if( document.getElementById(globals.controlIdentities.chfConWeight).value != "")
    {
        commonSearch("weight",document.getElementById(globals.controlIdentities.chfConWeight).value.value);
    }   
    else
    {
        Search();
    }
}

//比????CheckBox事件
function Choose(id,seq,code,row)
{
   var ckb = $ge("Checkbox"+row).checked;
   var hfChoose = $ge("hfChoose");
   var str = "";
   if(ckb)
   {
        var list = hfChoose.value.split("#");
        if(list.length > 10)
        {
            alert("您??了?多的?石?行比?,??可能??您??的性能下降!");
            $ge("Checkbox"+row).checked = false;
            return;
        }
        hfChoose.value += "#"+id+"-"+seq+"-"+code;
   }
   else
   {
        //死机原因修改
        if(hfChoose.value.indexOf("#"+id+"-"+seq+"-"+code)!=-1)
        {
           var s1 = hfChoose.value.substring(0,hfChoose.value.indexOf("#"+id+"-"+seq+"-"+code));
           //alert(s1);
           s2 =hfChoose.value.substring(hfChoose.value.indexOf("#"+id+"-"+seq+"-"+code)+20,hfChoose.value.length);
           //alert(s2);
           str = s1+s2;
        }
        if(str != "")
        {
            hfChoose.value = str; 
        }
        else
        {
            hfChoose.value = "#";
        }
   }
}

//?除比?的?石

function deleteCompare(index)
{  
	//$ge("divPop").style.display = "block";
    //$ge('bg1').style.display='block';
    var sUrl;
    var sPara;
    var id = $ge("hfChoose").value;
    sUrl = "diy-jewelry.aspx?id=diy-ring&cid="+id;
    //sUrl = "DiamondSearch.aspx";
    sPara = "oper=delete&index="+index+"&id="+id;
    //ajaxDownloadUrlAsString(sUrl, sPara);
    
    $.post(sUrl, sPara.paramsToJson(), ajaxOut);
}


window.onload = load;
window.onresize = load;


function ajaxOut(sContent)
{
	
    if(sContent.length > 5)
    {
        //返回添加?果
        if( getTagValue(sContent, "status") == "success")
        {
            var sMsg = getTagValue(sContent, "desc");
            if(sMsg != "")
            {
                $ge("lbHtml").innerHTML = "";
                $ge('lbHtml').innerHTML = sMsg;
                $ge("divLoading").style.display = "none";
            }
            else
            {
                alert("操作失?（服?器?有返回），?重?!");
                $ge("divLoading").style.display = "none";
            }
            
            var sMsg1 = getTagValue(sContent, "count");
            if(sMsg1 != "")
            {
                $ge('lbCount').innerHTML = sMsg1;
            }
           
             var sMsg2 = getTagValue(sContent, "pageCount");
            if(sMsg2 != "")
            {
                $ge('lbIndex').innerHTML = $ge("hfPageIndex").value+"/"+sMsg2;
            }
           
            
            var index = $ge('hfPageIndex').value;
//            if(index == "1")
//            {
//                $ge("prePage").style.display = "none";
//                $ge("prePage").style.display
//               
//            } 
//            else
//            {
//                $ge("prePage").style.display = "block";
//                $ge("firstPage").style.display = "block";
//                $ge("lastPage").style.display = "block";
//            }
//            if(index == sMsg2)
//            {
//            alert("a");
//                $ge("nextPage").style.display = "none";
//            }
//            else
//            {
//                $ge("nextPage").style.display = "block";
//                $ge("firstPage").style.display = "block";
//                $ge("lastPage").style.display = "block";
//            }
             if(sMsg2 == "0")
             {
//                $ge("prePage").style.display = "none";
//                $ge("nextPage").style.display = "none";
//                $ge("firstPage").style.display = "none";
//                $ge("lastPage").style.display = "none";
//               // $ge("goPage").style.display = "none";
//               // $ge("tbIndex").style.display = "none";
                 $ge("lbIndex").innerHTML = "0/0";
             }
          
        }
        else if(getTagValue(sContent, "status") == "compare")
        {
            var sMsg = getTagValue(sContent, "desc");
            if(sMsg != "")
            {
                $ge('lbCompareHtml').innerHTML = sMsg;
            }
            else
            {
                alert("操作失?（服?器?有返回），?重?!");
            }
            var sMsg1 = getTagValue(sContent, "count");
            if(sMsg1 != "")
            {
                $ge('lbCompareCount').innerHTML = sMsg1;
            }
            else
            {
                alert("操作失?（服?器?有返回），?重?!");
            }
            var sMsg2 = getTagValue(sContent, "id");
            if(sMsg2 != "")
            {
                $ge('hfChoose').value = sMsg2;
            }
            $ge("divPop").style.display = "none";
            $ge('bg1').style.display='none';
        }
        else
        {
             alert("操作失?（服?器?有返回），?重?!");
             $ge("divLoading").style.display = "none";
        }
    }
    else
    {
        alert("操作失?（服?器?有返回），?重?。");
        $ge("divLoading").style.display = "none";
    }
}



//向前翻?
function previous()
{

    var index = $ge("hfPageIndex").value;
    if(index == 1)
    {        
        return;
    }
    if (index > 1)
    {
        --index;
        //alert(index);
        $ge("hfPageIndex").value = index;
    }
    if(document.getElementById(globals.controlIdentities.chfConPrice).value != "")
    {
        commonSearch("price",document.getElementById(globals.controlIdentities.chfConPrice).value);
    }
    else if(document.getElementById(globals.controlIdentities.chfConWeight).value != "")
    {
        commonSearch("weight",document.getElementById(globals.controlIdentities.chfConWeight).value);
    }   
    else
    {
        Search();
    }
}

//向后翻?
function next()
{
	
    var index = $ge("hfPageIndex").value;
    if(index == $("#lbIndex").text().split('/')[1] || $("#lbIndex").text().split('/')[1] == 0)
    {        
        return;
    }
    ++index;
    $ge("hfPageIndex").value = index;
    if(document.getElementById(globals.controlIdentities.chfConPrice).value != "")
    {
        commonSearch("price",document.getElementById(globals.controlIdentities.chfConPrice).value);
    }
    else if(document.getElementById(globals.controlIdentities.chfConWeight).value != "")
    {
        commonSearch("weight",document.getElementById(globals.controlIdentities.chfConWeight).value);
    }   
    else
    {
        Search();
    }
}

//首?
function firstPage()
{
    if($("#lbIndex").text().split('/')[1] == 0)
    {
       
        return;
    }
    $ge("hfPageIndex").value = 1;
     if(document.getElementById(globals.controlIdentities.chfConPrice).value != "")
    {
        commonSearch("price",document.getElementById(globals.controlIdentities.chfConPrice).value);
    }
    else if(document.getElementById(globals.controlIdentities.chfConWeight).value != "")
    {
        commonSearch("weight",document.getElementById(globals.controlIdentities.chfConWeight).value);
    }   
    else
    {
        Search();
    }
}

//未?
function lastPage()
{
    if($("#lbIndex").text().split('/')[1] == 0)
    {
        alert("已?是最后一?了!");
        return;
    }
    var index = $("#lbIndex").text();
    //alert(index.split('/')[1]);
    $ge("hfPageIndex").value = index.split('/')[1];
     if(document.getElementById(globals.controlIdentities.chfConPrice).value != "")
    {
        commonSearch("price",document.getElementById(globals.controlIdentities.chfConPrice).value);
    }
    else if(document.getElementById(globals.controlIdentities.chfConWeight).value != "")
    {
        commonSearch("weight",document.getElementById(globals.controlIdentities.chfConWeight).value);
    }   
    else
    {
        Search();
    }
}

//?入??翻?
function goPage()
{
    var index = $ge("tbIndex").value;
    var maxIndex = $("#lbIndex").text();
    if(index >0  &&  index==parseInt(index) && parseInt(index) <= parseInt(maxIndex.split('/')[1]))
    {
        $ge("hfPageIndex").value = index;
         if(document.getElementById(globals.controlIdentities.chfConPrice).value != "")
        {
            commonSearch("price",document.getElementById(globals.controlIdentities.chfConPrice).value);
        }
        else if(document.getElementById(globals.controlIdentities.chfConWeight).value != "")
        {
            commonSearch("weight",document.getElementById(globals.controlIdentities.chfConWeight).value);
        }   
        else
        {
            Search();
        }
    }
    else
    {
        alert("您?入的??不合法!");
    }
}
