﻿
//选择省
$(function() {
    ////////select 选中时触发事件
    $('#SB_ProvinceDropDownList').change(
            function() {
                $('option:selected', this).each(function() { //印出選到多個值
                    //取得一个HTML页面的最新版本。
                    $.ajax({
                        url: '/Ajax/CityOpration.aspx?id=' + this.value,
                        cache: false,
                        success: function(htmlStr) {
                            $('#CityDropDownList').html(htmlStr);
                        }
                    });
                });
            });
});


//function SearchInputClick(va) {
//    if (va.value == '请输入展会名称') {
//        va.value = '';
//    }
//}

//function SearchInputBlur(va) {
//    if (va.value == '') {
//        va.value = '请输入展会名称';
//    }
//}

function SearchSubmit() {
    var va = $('#myInput').val();
    //s 搜索关键字
    var s = trim(va.replace(/[\-\/&]/g, ' '));
    if (s != '') {
        if (s.length < 2 || s.length > 20) {
            alert('关键词长度不能小于2个字符并且大于20个字符！');
            $('#myInput').focus();
            return false;
        }
        s = encodeURIComponent(s);
    }
    else {
        s = 'snull';
    }

    //行业分类
    var c = $('#SB_ClassDropDownList').val();
    if (c != 'default') {
        c = 'c' + c + '-';
    }
    else {
        c = '';
    }

    //日期条件
    var date = '';
    //开展日期    
    var start = $('#startDate').val();
    //结束日期
    var end = $('#endDate').val();
    if (start != '' && end != '') {
        date = 'd' + start + '_' + end + '-';
    }

    //省份
    var ap = '';
    //市区
    var ac = '';

    if ($('#SB_ProvinceDropDownList').val() != 'default') {
        ap = 'ap' + $('#SB_ProvinceDropDownList').val() + '-';
    }

    if ($('#CityDropDownList').val() != 'default') {
        ac = 'ac' + $('#CityDropDownList').val() + '-';
    }

    if (c == '' && date == '' && ap == '' && ac == '' && s == 'snull') {
        alert('请选择搜索条件！');
        return false;
    }

    //提交的URL
    var url = '/ZhanHui/s/' + c + date + ap + ac + s;

    window.location.href = url;
}