﻿/*jQuery(document).keydown(function () {
if (event.keyCode == 13) {
jQuery("input[name='btnSearch']").click();
}
});*/
jQuery(function () {
    //    jQuery("#autoTabs").tabs();
    //首页TAB导航开始
    var tabTitle = jQuery(".tabs");
    var tabContent = jQuery(".dhlist");
    tabTitle.mousemove(function () {
        var index = tabTitle.index(jQuery(this));
        jQuery(tabContent.get(index)).show().siblings('.dhlist').hide();
        return false;
    });
    //首页TAB导航结束
    //新闻搜索
    var txbKey = jQuery("#txbKeyword");
    txbKey.focus(function () { if (txbKey.val() == "请输入关键字") { txbKey.val(""); } }).blur(function () {
        if (txbKey.val().length == 0 || txbKey.val() == "请输入关键字") {
            txbKey.val("请输入关键字");
        }
    });
    var btnSearch = jQuery("#btnSearch").click(function () {
        if (txbKey.val().length == 0 || txbKey.val() == "请输入关键字") {
            //window.location.href = "/search.aspx";
            window.open("/search.aspx");
        }
        else {
            //window.location.href = "/search.aspx?keyword=" + jQuery.trim(txbKey.val());
            window.open("/search.aspx?keyword=" + encodeURI(jQuery.trim(txbKey.val())));
        }
    });
    //底部新闻
    var txbkw = jQuery("#txbkw");
    txbkw.focus(function () { if (txbkw.val() == "请输入关键字") { txbkw.val(""); } }).blur(function () {
        if (txbkw.val().length == 0 || txbkw.val() == "请输入关键字") {
            txbkw.val("请输入关键字");
        }
    });
    var btns = jQuery("#btns").click(function () {
        if (txbkw.val().length == 0 || txbkw.val() == "请输入关键字") {
            //window.location.href = "/search.aspx";
            window.open("/search.aspx");
        }
        else {
            //window.location.href = "/search.aspx?keyword=" + jQuery.trim(txbKey.val());
            window.open("/search.aspx?keyword=" + encodeURI(jQuery.trim(txbkw.val())));
        }
    });
    //4S店搜索
    var txb4SSearch = jQuery("#txb4SSearch");
    txb4SSearch.focus(function () { if (txb4SSearch.val() == "网上4S店") { txb4SSearch.val(""); } }).blur(function () {
        if (txb4SSearch.val().length == 0 || txbKey.val() == "网上4S店") {
            txb4SSearch.val("网上4S店");
        }
    });
    var btn4SSearch = jQuery("#btn4SSearch").click(function () {
        if (txb4SSearch.val().length == 0 || txb4SSearch.val() == "网上4S店") {
            //window.location.href = "/search.aspx";
            window.open("/4s_list.aspx");
        }
        else {
            //window.location.href = "/search.aspx?keyword=" + jQuery.trim(txbKey.val());
            //window.open("/4s_list.aspx?query=" + encodeURI(jQuery.trim(txb4SSearch.val())));
            getAES(jQuery.trim(txb4SSearch.val()),"/4s_list.aspx");
        }
    });

    //二手搜索
    var txb2SSearch = jQuery("#txb2SSearch");
    txb2SSearch.focus(function () { if (txb2SSearch.val() == "二手车") { txb2SSearch.val(""); } }).blur(function () {
        if (txb2SSearch.val().length == 0 || txbKey.val() == "二手车") {
            txb2SSearch.val("二手车");
        }
    });
    var btn2SSearch = jQuery("#btn2SSearch").click(function () {
        if (txb2SSearch.val().length == 0 || txb2SSearch.val() == "二手车") {
            //window.location.href = "/search.aspx";
            window.open("/sec_list.aspx");
        }
        else {
            //window.location.href = "/search.aspx?keyword=" + jQuery.trim(txbKey.val());
            window.open("/sec_list.aspx?keyword=" + encodeURI(jQuery.trim(txb2SSearch.val())));
        }
    });

    //汽车美容搜索
    var txbMRSearch = jQuery("#txbMRSearch");
    txbMRSearch.focus(function () { if (txbMRSearch.val() == "汽车美容") { txbMRSearch.val(""); } }).blur(function () {
        if (txbMRSearch.val().length == 0 || txbKey.val() == "汽车美容") {
            txbMRSearch.val("汽车美容");
        }
    });
    var btnMRSearch = jQuery("#btnMRSearch").click(function () {
        if (txbMRSearch.val().length == 0 || txbMRSearch.val() == "汽车美容") {
            //window.location.href = "/search.aspx";
            window.open("/mr_list.aspx");
        }
        else {
            //window.location.href = "/search.aspx?keyword=" + jQuery.trim(txbKey.val());
            window.open("/mr_list.aspx?query=" + encodeURI(jQuery.trim(txbMRSearch.val())));
        }
    });
    //查询加密
    function getAES(q,r) {
        jQuery.get("Query.aspx", { query:q},
        function (data) {
            window.location.href=r+"?query=" + data;
        }); 
    }

});
