$(function() {

	$('#csForm').validate({onkeyup: false,onfocusout:false,onclick:false,focusInvalid:false});
	$('#psForm').validate({onkeyup: false,onfocusout:false,onclick:false,focusInvalid:false});
	
	$('#searchbar input:text').addClass('disabled').attr('disabled','disabled');
	$('#searchbar input:radio:checked').closest('tr').find('input:text').removeClass('disabled').removeAttr('disabled');
	$('#searchbar input:radio').click(function(){
		$(this).closest('tr').siblings('tr').find('input:text').val('').addClass('disabled').attr('disabled','disabled');
		$(this).closest('tr').siblings('tr').find('em').remove();
		$(this).closest('tr').find('input:text').removeClass('disabled').removeAttr('disabled');
	});
});

// 企业查询function
function csSearch(){
	// 企业查询radio类型
	var csSearchType = $('input[name=csSearchType]:checked').val();
	var csSearchValue = '';
	if(csSearchType == '0') {
	// 企业代码
		csSearchValue = $('#corpCode').val();
	} else if (csSearchType == '1'){
	// 组织机构代码
		csSearchValue = $('#orgCode').val();
	} else if (csSearchType == '2'){
	// 进出口代码
		csSearchValue = $('#inOutCode').val();
	} else if (csSearchType == '3'){
	// 工商注册号
		csSearchValue = $('#regCode').val();
	} else if (csSearchType == '4'){
	// 关键字
		csSearchValue = $('#csKeyword').val();
	}
	if(csSearchType){
		$('#csForm').submit();
	}
}

// 产品查询function
function psSearch(){
	// 产品查询radio类型
	var psSearchType = $('input[name=psSearchType]:checked').val();
	var psSearchValue = '';
	if (psSearchType == '0') {
	// 商务产品编码
		psSearchValue = $('#cpccode').val();
	} else if (psSearchType == '1') {
	// HS号
		psSearchValue = $('#hscode').val();
	} else if (psSearchType == '2') {
	// 关键字
		psSearchValue = $('#psKeyword').val();
	}
	if(psSearchType){
		$('#psForm').submit();
	}
}

// 获取近期注册企业信息
function getRegiCorpInfo(rowNum){
	$.getJSON("member/getRegiCorpInfo.htm",{rowNum:rowNum},function(data){
		$("#regiCorpInfoTable").append(data.resData);
		$("#regiCorpInfoTable td").each(function(i){
			var $this = $(this);
			var tdLink = $this.find('a');
			var tdText = $this.text();
			if(tdText.length>16){
				tdNewText = tdText.substring(0,15)+'...';
				if(tdLink&&tdLink.length>0){
					tdLink.attr('title',tdText).text(tdNewText);
				}else{
					$this.empty().append('<a class="nolink" title="' + tdText + '">' + tdNewText + '</a>');
				}
			}
		});
	});
	
}

function getCorpProdInfo(rowNum){
	$.getJSON("member/getProdInfoForIndex.htm",{rowNum:rowNum},function(data){
			$("#regProdInfo").append(data.resData);
	});
}
