﻿var strMain = "";
var strBug = "|";
var strUni = "|";
var strReg = "|";
var strFix = "|";
var strRom = "|";
var strRef = "|";
var strDat = "|";
var strInv = "|";
var strMainR = "";
var strBugR = "|";
var strRegR = "|";
var strFixR = "|";
var strRomR = "|";
var strRefR = "|";
var strDatR = "|";
var BuyRent = "Buy";
var SearchMainType = "";
var SearchMainTypeR = "";
var DTDis = "300";
var DTDisR = "300";


function SetMain(v)
{
    strMain = "QY|" + v;
    strBug = "|";
    strUni = "|";
    strReg = "|";
    strFix = "|";
    strRom = "|";
    strRef = "|";
    strDat = "|";
    strInv = "|";
    BuyRent = "Buy";
    
    jQuery('#ctl00_CPH_content_imgBtnQS').click();
}

function SetBug(v)
{
    strMain = "";
    strBug = "|" + v;
    strUni = "|";
    strReg = "|";
    strFix = "|";
    strRom = "|";
    strRef = "|";
    strDat = "|";
    strInv = "|";
    BuyRent = "Buy";
       
    jQuery('#ctl00_CPH_content_imgBtnQS').click();
}

function SetRom(v)
{
    strMain = "";
    strBug = "|";
    strUni = "|";
    strReg = "|";
    strFix = "|";
    strRom = "|" + v;
    strRef = "|";
    strDat = "|";
    strInv = "|";
    BuyRent = "Buy";
    
    jQuery('#ctl00_CPH_content_imgBtnQS').click();
}

function SetCon()
{
    jQuery('#ConMain').attr('value', strMain);
    if (strBug == '|'){
        strBug = '';
    }
    else if (strBug.substr(0, 1) == '|'){
        strBug = strBug.substr(1, strBug.length - 1);
    }
    jQuery('#ConBug').attr('value', strBug);
    if (strUni == '|'){
        strUni = '';
    }
    else if (strUni.substr(0, 1) == '|'){
        strUni = strUni.substr(1, strUni.length - 1);
    }    
    jQuery('#ConUni').attr('value', strUni);
    if (strReg == '|'){
        strReg = '';
    }
    else if (strReg.substr(0, 1) == '|'){
        strReg = strReg.substr(1, strReg.length - 1);
    }    
    jQuery('#ConReg').attr('value', strReg);
    if (strFix == '|'){
        strFix = '';
    }
    else if (strFix.substr(0, 1) == '|'){
        strFix = strFix.substr(1, strFix.length - 1);
    }    
    jQuery('#ConFix').attr('value', strFix);
    if (strRom == '|'){
        strRom = '';
    } 
    else if (strRom.substr(0, 1) == '|'){
        strRom = strRom.substr(1, strRom.length - 1);
    }   
    jQuery('#ConRom').attr('value', strRom);
    if (strRef == '|'){
        strRef = '';
    }
    else if (strRef.substr(0, 1) == '|'){
        strRef = strRef.substr(1, strRef.length - 1);
    }    
    jQuery('#ConRef').attr('value', strRef);
    if (strDat == '|'){
        strDat = '';
    }
    else if (strDat.substr(0, 1) == '|'){
        strDat = strDat.substr(1, strDat.length - 1);
    }    
    jQuery('#ConDat').attr('value', strDat);
    if (strInv == '|'){
        strInv = '';
    }
    else if (strInv.substr(0, 1) == '|'){
        strInv = strInv.substr(1, strInv.length - 1);
    }    
    jQuery('#ConInv').attr('value', strInv);
    
    if(jQuery('#keywordS').val() == "请输入小区或路名")
    {
       jQuery('#ConNam').attr('value', '');
    }
    else
    {
        jQuery('#ConNam').attr('value', jQuery('#keywordS').val());
    }
}

function SetConR()
{
    jQuery('#ConMain').attr('value', strMainR);
    if (strBugR == '|'){
        strBugR = '';
    }
    else if (strBugR.substr(0, 1) == '|'){
        strBugR = strBugR.substr(1, strBugR.length - 1);
    }
    jQuery('#ConBug').attr('value', strBugR);
    jQuery('#ConUni').attr('value', '');
    if (strRegR == '|'){
        strRegR = '';
    }    
    else if (strRegR.substr(0, 1) == '|'){
        strRegR = strRegR.substr(1, strRegR.length - 1);
    }
    jQuery('#ConReg').attr('value', strRegR);
    if (strFixR == '|'){
        strFixR = '';
    } 
    else if (strFixR.substr(0, 1) == '|'){
        strFixR = strFixR.substr(1, strFixR.length - 1);
    }   
    jQuery('#ConFix').attr('value', strFixR);
    if (strRomR == '|'){
        strRomR = '';
    }
    else if (strRomR.substr(0, 1) == '|'){
        strRomR = strRomR.substr(1, strRomR.length - 1);
    }    
    jQuery('#ConRom').attr('value', strRomR);
    if (strRefR == '|'){
        strRefR = '';
    }
    else if (strRefR.substr(0, 1) == '|'){
        strRefR = strRefR.substr(1, strRefR.length - 1);
    }    
    jQuery('#ConRef').attr('value', strRefR);
    if (strDatR == '|'){
        strDatR = '';
    }   
    else if (strDatR.substr(0, 1) == '|'){
        strDatR = strDatR.substr(1, strDatR.length - 1);
    } 
    jQuery('#ConDat').attr('value', strDatR);
    jQuery('#ConInv').attr('value', '');
    
    if(jQuery('#keywordR').val() == "请输入小区或路名")
    {
       jQuery('#ConNam').attr('value', '');
    }
    else
    {
        jQuery('#ConNam').attr('value', jQuery('#keywordR').val());
    }
}

function ClearDefault(o)
{
    if(o.value == "请输入小区或路名")
    {
        o.value = "";
    }
}
    
jQuery(function(){
    jQuery('.SearchMm :radio').each(function(){
        jQuery(this).click(function(){
            if(jQuery(this).attr("checked")==true){
                if (BuyRent == "Buy")
                {
                    strMain = strMain.replace("DT|" + DTDis + "|", "DT|" + jQuery(this).attr("value") + "|"); 
                    DTDis = jQuery(this).attr("value");                
                }
                else
                {
                    strMainR = strMainR.replace("DT|" + DTDisR + "|", "DT|" + jQuery(this).attr("value") + "|"); 
                    DTDisR = jQuery(this).attr("value");
                }
            }
        })
    })
    
    jQuery('.SearchMain :radio').each(function(){
        jQuery(this).click(function(){
            if(jQuery(this).attr("checked")==true){
                if (jQuery(this).attr("value") != ""){
                    switch(jQuery(this).attr("name")){
                    case "chkDat":
                            strDat = "|" + jQuery(this).attr("value") + "|";
                            break;
                    case "chkDatR":
                            strDatR = "|" + jQuery(this).attr("value") + "|";
                            break;
                    }
                }
                else{
                    switch(jQuery(this).attr("name")){
                    case "chkDat":
                            strDat = "|";
                            break;
                    case "chkDatR":
                            strDatR = "|";
                            break;                               
                    }
                }
            }
            else{
                if (jQuery(this).attr("value") != ""){
                    switch(jQuery(this).attr("name")){
                    case "chkDat":
                            strDat = strDat.replace("|" + jQuery(this).attr("value") + "|", "|");
                            break;
                    case "chkDatR":
                            strDatR = strDatR.replace("|" + jQuery(this).attr("value") + "|", "|");
                            break;                            
                    }
                }
            }
        })
    })
    
    jQuery('.SearchMain :checkbox').each(function(){
        jQuery(this).click(function(){
  
            if(jQuery(this).attr("checked")==true){
                if (jQuery(this).attr("value") != ""){
                                        
                    jQuery('.SearchMain input[name="' + jQuery(this).attr("name") + '"]:checkbox').each(function(){
                        if (jQuery(this).attr("value") == ""){
                            jQuery(this).attr("checked",false);
                        }
                    })
                    
                    switch(jQuery(this).attr("name")){
                    case "chkInv":
                            strInv += jQuery(this).attr("value") + "|";
                            break;
                    case "chkRef":
                            strRef += jQuery(this).attr("value") + "|";
                            break;
                    case "chkRefR":
                            strRefR += jQuery(this).attr("value") + "|";
                            break;                            
                    case "chkRom":
                            strRom += jQuery(this).attr("value") + "|";
                            break;
                    case "chkRomR":
                            strRomR += jQuery(this).attr("value") + "|";
                            break;                            
                    case "chkFix":
                            strFix += jQuery(this).attr("value") + "|";
                            break;
                    case "chkFixR":
                            strFixR += jQuery(this).attr("value") + "|";
                            break;                            
                    case "chkReg":
                            if (strReg.substring(0,1) == "|"){
                                strReg += jQuery(this).attr("value") + "|";
                            }
                            else{
                                strReg = "|" + jQuery(this).attr("value") + "|";
                            }
                            break;
                    case "chkRegR":
                            if (strRegR.substring(0,1) == "|"){
                                strRegR += jQuery(this).attr("value") + "|";
                            }
                            else{
                                strRegR = "|" + jQuery(this).attr("value") + "|";
                            }
                            break;                            
                    case "chkUni":
                            strUni += jQuery(this).attr("value") + "|";
                            break;
                    case "chkBug":
                            if (strBug.substring(0,1) == "|"){
                                strBug += jQuery(this).attr("value") + "|";
                            }
                            else{
                                strBug = "|" + jQuery(this).attr("value") + "|";
                            }
                            break;   
                    case "chkBugR":
                            if (strBugR.substring(0,1) == "|"){
                                strBugR += jQuery(this).attr("value") + "|";
                            }
                            else{
                                strBugR = "|" + jQuery(this).attr("value") + "|";
                            }
                            break;                              
                    }
                }
                else{
                    jQuery('.SearchMain input[name="' + jQuery(this).attr("name") + '"]:checkbox').each(function(){
                        if (jQuery(this).attr("value") != ""){
                            jQuery(this).attr("checked",false);
                        }
                    })
                    
                    switch(jQuery(this).attr("name")){
                    case "chkInv":
                            strInv = "|";
                            break;
                    case "chkRef":
                            strRef = "|";
                            break;
                    case "chkRefR":
                            strRefR = "|";
                            break;                            
                    case "chkRom":
                            strRom = "|";
                            break;
                    case "chkRomR":
                            strRomR = "|";
                            break;                            
                    case "chkFix":
                            strFix = "|";
                            break; 
                    case "chkFixR":
                            strFixR = "|";
                            break;                            
                    case "chkReg":
                            strReg = "|";
                            break;
                    case "chkRegR":
                            strRegR = "|";
                            break;                            
                    case "chkUni":
                            strUni = "|";
                            break;
                    case "chkBug":
                            strBug = "|";
                            break;  
                    case "chkBugR":
                            strBugR = "|";
                            break;                                                                                   
                    }
                }               
            }
            else{
                if (jQuery(this).attr("value") != ""){
                    switch(jQuery(this).attr("name")){
                    case "chkInv":
                            strInv = strInv.replace("|" + jQuery(this).attr("value") + "|", "|");
                            break;                           
                    case "chkRef":
                            strRef = strRef.replace("|" + jQuery(this).attr("value") + "|", "|");
                            break;
                    case "chkRefR":
                            strRefR = strRefR.replace("|" + jQuery(this).attr("value") + "|", "|");
                            break;                            
                    case "chkRom":
                            strRom = strRom.replace("|" + jQuery(this).attr("value") + "|", "|");
                            break;
                    case "chkRomR":
                            strRomR = strRomR.replace("|" + jQuery(this).attr("value") + "|", "|");
                            break;                            
                    case "chkFix":
                            strFix = strFix.replace("|" + jQuery(this).attr("value") + "|", "|");
                            break; 
                    case "chkFixR":
                            strFixR = strFixR.replace("|" + jQuery(this).attr("value") + "|", "|");
                            break;                             
                    case "chkReg":
                            strReg = strReg.replace("|" + jQuery(this).attr("value") + "|", "|");
                            break;
                    case "chkRegR":
                            strRegR = strRegR.replace("|" + jQuery(this).attr("value") + "|", "|");
                            break;                            
                    case "chkUni":
                            strUni = strUni.replace("|" + jQuery(this).attr("value") + "|", "|");
                            break;
                    case "chkBug":
                            strBug = strBug.replace("|" + jQuery(this).attr("value") + "|", "|");
                            break;     
                    case "chkBugR":
                            strBugR = strBugR.replace("|" + jQuery(this).attr("value") + "|", "|");
                            break;                                                                                
                    }
                }
            }
        })
    })
})
