
$(document).ready(function() {
    $(".search_t").click(function(){
        chk_ajax(document.getElementById("searchtype").value);
    });
    $("#firsttrade").mouseover();
});
function chk_ajax(type)
{

	$.post("/search/index/getHotsearch", { type: type  },
	function(data){
		$('#hotsearch').html(data);
	});

}


function showInfo(f)
{
	document.getElementById("brandlist0").style.display = "none";
	document.getElementById("brandlist1").style.display = "none";
	document.getElementById("brandlist2").style.display = "none";
	document.getElementById("tradelist0").className = "";
	document.getElementById("tradelist1").className = "";
	document.getElementById("tradelist2").className = "";
	document.getElementById("brandlist"+f).style.display = "block";
	document.getElementById("tradelist"+f).className = "cur";
}

function setSearch(f, sort)
{
	var i;
	for (i = 0; i<7; i++)
	{
		document.getElementById("searchitem"+i).className = "";
	}
	document.getElementById("searchitem"+f).className = "cur";
	document.getElementById("searchtype").value = sort;
}

function searchText(obj, n)
{
	if (n == 0)
	{
		if (obj.value == '例如：输入“唯品”') {
			obj.value = '';
			obj.style.color = '#000000';
		}
	} else if (n == 1) {
		if (obj.value == '') {
			obj.value = '例如：输入“唯品”';
			obj.style.color = '#ccc';
		}
	}
}

// 搜索： 资讯 品牌 产品 活动/促销 商家 论坛 博客
function checkHomeSubmit(obj)
{
	with(obj)
	{
		if (obj.k.value == '例如：输入“唯品”' || obj.k.value == '') {
			alert('请输入搜索内容，例如：输入“唯品”');
			obj.k.focus();
			return false;
		}
		return true;
	}
}

function checkICP()
{
    if ($.trim($("#homeicp").val()) == '') {
        alert('请输入备案号');
        $("#homeicp").focus();
        return false;
    }
    if ($.trim($("#homecode").val()) == '') {
        alert('请输入和图片上一致的验证码');
        $("#homecode").focus();
        return false;
    }
    return true;
}

function icpVerifyPic()
{
    $("#vcode").attr("src", "/getcode/index/homepage?r="+(new Date().getTime()));
    return false;
}

// 查询icp
jQuery(function ($) {
	$("#homesearchicp").click(function () {
	    if(checkICP()==true) {
	        $("#searchicpform").submit();
	    }
	});
	$("#homeapplyicp").click(function () {
	    if(checkICP()==true) {
        	$.post("/member/company/ajaxicp.html", { code:$("#homecode").val(), icp:$("#homeicp").val() },
        	function(data){
        		if(data == null || data == '') {
        		    alert('参数错误');
        		} else if (data == -1) {
            	    $("#searchicpform").attr('action', '/member/company/icp.html');
            	    $("#searchicpform").submit();
        		} else {
        		    alert(data);
        		}
        		return false;
        	});
	    }
	});
});

function showTradeBrand(id) {
    if (isNaN(id) == false && id > 0) {
        $.post("/index/index/ajax_shownavbrand.html", { tid: id },
        function(data){
            if (data.match('<a') || data == '') {
                $("#tradebrand").html(data);
            }
        });
    }
}