
function showAjax(furl,id)
{
	runAjax1(furl+'&n='+Math.random(),document.getElementById(id),showText);
}

function showProducts(value)
{
	var furl = '/member/extra/showPinfo.cgi?f=showProducts&pid='+value;
	showAjax(furl,'products')
}

function showPmart(value,mid)
{
	var furl = '/member/extra/showPinfo.cgi?f=showPmart&sid='+value+'&mid='+mid;
	showAjax(furl,'pro_mart')
}

function showPunit(value)
{
	var furl = '/member/extra/showPinfo.cgi?f=showPunit&pid='+value;
	showAjax(furl,'pro_unit')
}

function showPspec(value)
{
	var furl = '/member/extra/showPinfo.cgi?f=showPspec&pid='+value;
	showAjax(furl,'pro_spec')
	showPmart('','');
}

function showPname(value)
{
	var furl = '/member/extra/showPinfo.cgi?f=showPname&c1='+value;
	showAjax(furl,'pro_name')
	showPunit('');
	showPspec('');
	showPmart('','');
}

function showPcate1(value)
{
	var furl = '/member/extra/showPinfo.cgi?f=showPcate1&c='+value;
	showAjax(furl,'cate1')
	showPname('');
	showPspec('');
	showPmart('','');
}

function deletePinfo(did,pid)
{
	var furl = '/member/extra/showPinfo.cgi?f=deletePinfo&did='+did+'&pid='+pid;
	showAjax(furl,'products');
}

function insertPinfo()
{
	var pro_id = document.getElementById('pro_id');
	var spec_id = document.getElementById('spec_id');
	var mart_id = document.getElementById('mart_id');
	var unit_id = document.getElementById('unit_id');
	var pro_date = document.getElementById('pro_date');
	var price = document.getElementsByName('price');
	var company = document.getElementsByName('company');
	var pvalue = ",";
	var cvalue = ",";
	for(var i=0;i<price.length;i++){
		pvalue += price[i].value+",";
	}	
	for(var i=0;i<company.length;i++){
		cvalue += company[i].value+",";
	}
	
	var furl = '/member/extra/showPinfo.cgi?f=insertPinfo';
	furl += '&pro_id='+pro_id.value;
	furl += '&spec_id='+spec_id.value;
	furl += '&mart_id='+mart_id.value;
	furl += '&unit_id='+unit_id.value;
	furl += '&pro_date='+pro_date.value;
	furl += '&price='+pvalue;
	furl += '&company='+cvalue;
	showAjax(furl,'products');
}

function cloneLine(id,id_to)
{
	var obj = document.getElementById(id);
	var obj_to = document.getElementById(id_to);
	
  var newline = obj.cloneNode(true); 					//克隆一行    
  obj_to.appendChild(newline); 								//添加刚才克隆的一行    
}

function deleteLine(id)
{   
	var obj = document.getElementById(id);   
  var lines = obj.childNodes.length;   
  if (lines > 0) {  
  	obj.removeChild(obj.lastChild); 
  }
} 
  
function checkInput()
{   
	var pro_cate = document.getElementById('pro_cate');  
	var pro_cate1 = document.getElementById('pro_cate1'); 
	var pro_id = document.getElementById('pro_id'); 
	if(pro_cate.value=='' || pro_cate1.value=='' || pro_id.value==''){
		alert('数据不完整！');
		return false;
	}
	return true;
}  


function showPinitmart(value,mid)
{
	var furl = '/member/extra/showPinfo.cgi?f=showPinitmart&sid='+value+'&mid='+mid;
	showAjax(furl,'pro_mart')
}

function showPinitspec(value,init_spec_id)
{
	var furl = '/member/extra/showPinfo.cgi?f=showPinitspec&name='+value+'&sid='+init_spec_id;
	showAjax(furl,'pro_spec')
	showPinitmart('','');
}

