//网站直达
jQuery(function(){
	jQuery('#site_direct').click(function(){
		
		jQuery('#direct').val('1');
		
		jQuery('#search_form').submit();
		jQuery('#direct').val('0');
		
	});
});

jQuery(function(){
    jQuery("#search_text").focus();
    
    jQuery("#search_form").submit(function(){
        var kw = jQuery("#search_text").val();
        var kw = jQuery.trim(kw);
        if('' == kw){
            alert('请输入您要检索的企业名称或品牌名称！');
            jQuery("#search_text").val('');
            jQuery("#search_text").focus();
            return false;
        }
    });
});

/*
jQuery(function(){
	jQuery('#search_btn').click(function(){
		
		jQuery('#search_form').attr('action',(jQuery('#wap').attr('checked') ? 'http://yp.wap.cn/search.php' : 'http://yp.knet.cn/search.php'));
		
		jQuery('#search_form').submit();
	
		
	});
});
*/
window.$=window.jQuery;
$(document).ready(function() {
	var searchForm = $(".search_ form:first");
	var defaultActionUrl = searchForm.attr("action");
	var searchBox = $(".searchfield input");
	searchForm.find(":radio").click(function(){
		var type = $(this).val();
		if(type == "knetsearch"){
			searchForm.attr("action","http://yp.knet.cn/search.php");
			searchBox.attr("name","kw");
		}else if(type == "wapsearch"){
			searchForm.attr("action","http://yp.wap.cn/search.php");
			searchBox.attr("name","kw");
		}else{
			searchForm.attr("action",defaultActionUrl);
			searchBox.attr("name","content");
		}
	})
	
	$("#search_btn2").click(function(){
		location.href = "http://name.knet.cn/cn.dll?charset=utf8&name="+encodeURIComponent(searchBox.val());
	})
});


var open_roll;
$(function (){
	//首页向上滚动名片
	if($('#roll_cards').length > 0) {
		$('div.trade p:first').hide();
		//向上滚动
		openRoll();
		$('#roll_cards').mouseover(function (){
			clearInterval(open_roll);
		}).mouseout(function (){
			openRoll();
		});
	}
	//列表页调整搜索区与列表区的源代码顺序
	$('div.card-list').before($('div.trade-search'));
});
function openRoll()
{
	open_roll = setInterval(function (){
		$('#roll_cards').animate({
			scrollTop: 18
		}, 1000, function (){
			$('#roll_cards li:last').after($('#roll_cards li:first'));
			$('#roll_cards')[0].scrollTop = 0;
		})
	}, 6000);
}

