$.postJSON = function(url,data,callback){
	$.post(url,data,callback,'json');
}
//加载地区
function getarea(parentID,childID)
{
	$('#'+childID).empty();//清除下拉框
	var pid = $('#'+parentID).val();
	if(pid == 0)
	{
		option = "<option value='0' >地级市</option>";
		$(option).appendTo('#'+childID);
		return false;
	}
	var option;
	$.getJSON(sitepath+'ajax/area.php',{act:'list',pid:pid,ajax:1},function(data){
			if(data == false)
			{
				$('#'+childID).hide();
			}
			else
			{
				$('#'+childID).show();
				$.each(data,function(i,n){
						option = "<option value='"+n.id+"' >"+n.name+"</option>";
						$(option).appendTo('#'+childID);
								 });
			}
			$('#otherarea').show();
			$('#otherareaTip').show();
	});
}
//加载地区
function getsearcharea(parentID,childID,defaultcity)
{
	$('#'+childID).empty();//清除下拉框
	var pid = $('#'+parentID).val();

	option = "<option value='0' >"+defaultcity+"</option>";
	$(option).appendTo('#'+childID);
	var option;
	$.getJSON(sitepath+'ajax/area.php',{act:'list',pid:pid,ajax:1},function(data){
			if(data != false)
			{
				$.each(data,function(i,n){
						option = "<option value='"+n.id+"' >"+n.name+"</option>";
						$(option).appendTo('#'+childID);
								 });
			}
	});
}

//清除select下拉框
function selectempty(childID)
{
	$('#'+childID).empty();//清除下拉框	
}
function selecthide(childID)
{
	$('#'+childID).hide();//清除下拉框	
}
//加载行业类别
function gettype(parentID,childID)
{
	$('#'+childID).empty();//清除下拉框
	var pid = $('#'+parentID).val();
	var option;
	$.getJSON(sitepath+'ajax/type.php',{act:'list',pid:pid,ajax:1},function(data){
			if(data == false)
			{
				
			}
			else
			{
				$('#'+childID).show();
				$.each(data,function(i,n){
						option = "<option value='"+n.id+"' >"+n.name+"</option>";
						$(option).appendTo('#'+childID);
								 });
			}
	});
}
//加载地区等有限可选分类
function getChild(type,parentID,childID,str)
{
	$('#'+childID).empty();//清除下拉框
	var pid = $('#'+parentID).val();
	if(pid == 0)
	{
		option = "<option value='0' >"+str+"</option>";
		$(option).appendTo('#'+childID);
		return false;
	}
	var option;
	$.getJSON(sitepath+'ajax/'+type+'.php',{act:'list',pid:pid,ajax:1},function(data){
			if(data == 0)
			{
				$('#'+childID).hide();
			}
			else
			{
				$('#'+childID).show();
				option = "<option value='0' >"+str+"</option>";
				$(option).appendTo('#'+childID);
				
				$.each(data,function(i,n){
									 if(type == 'area')
									 {
										option = "<option value='"+n.id+"' >"+n.subname+"</option>";
									 }
									 else
									 {
										 option = "<option value='"+n.id+"' >"+n.name+"</option>";
									 }
										$(option).appendTo('#'+childID);
								 });
				
			}
	});
}
function getAutoChild(type,num,obj)
{
	var boxid = type+num+'box';
	$('#'+boxid).html('');
	var pid = $('#'+type+num).val();
	$('#'+obj).val(pid);
	if(pid == 0) return false;
	var htmlstr;
	$.getJSON(sitepath+'ajax/'+type+'.php',{act:'list',pid:pid,ajax:1},function(data){
		if(data != 0)
		{
			num = num + 1;
			htmlstr = "<select id='"+type+num+"' onchange=\"getAutoChild('"+type+"',"+num+",'"+obj+"')\" >";
			$.each(data,function(i,n){
				 htmlstr += "<option value='"+n.id+"' >"+n.name+"</option>";
			});
			htmlstr += "</select><span id='"+type+num+"box'></span>";
			$(htmlstr).appendTo('#'+boxid);
			getAutoChild(type,num,obj);
		}
	});
}
//加载行业类别
function gettypetitle(parentID,childID)
{
	$('#'+childID).empty();//清除下拉框
	var pid = $('#'+parentID).val();
	var option;
	$.getJSON(sitepath+'ajax/type.php',{act:'list',pid:pid,ajax:1},function(data){
			if(data == false)
			{
				var selectedtext = $('#'+parentID).find("option:selected").text();
				$('#title').val('提供'+selectedtext);
				$('#keyword').val(selectedtext);
			}
			else
			{
				$('#'+childID).show();
				$.each(data,function(i,n){
						option = "<option value='"+n.id+"' >"+n.name+"</option>";
						$(option).appendTo('#'+childID);
								 });
			}
	});
}
function gettitle(ID)
{
	var selectedtext = $('#'+ID).find("option:selected").text();
	$('#title').val('提供'+selectedtext);
	$('#keyword').val(selectedtext);
}
//会员中心删除附件
function delattact(field,hash,nopic)
{
	var file = $('#'+field+'_input').val();
	if(file != '')
	{
		$.getJSON('attactment.php',{act:'del',file:file,hash:hash,ajax:1},function(data){
			if(data == 0)
			{
				alert('删除失败');	
				return false;
			}
			$('#'+field+'_input').val('');
			if(nopic != '')
			{
				$('#'+field+'_preview').attr('src', nopic);
				$('#'+field+'_editform').hide();
				$('#'+field+'_upform').show();
			}
		});
	}
}
//ajax提交评论留言
function commentpost(m,infoid)
{
	var _uid = $('#_uid').val();
	var uname = '';
	var upass = '';
	if(_uid == 0 && commentall == '0') 
	{
		uname = $('#comment_username').val();
		upass = $('#comment_password').val();
		if(uname == '')
		{
			alert('您还没有登录,请输入用户名');
			return false;
		}
		if(upass == '')
		{
			alert('请输入密码');
			return false;	
		}
	}
	var str = $('#comment_content').val();
	if(str.length < 5 )
	{
		alert('请多写点吧');
		return false;
	}
	if(str.length > 500)
	{
		alert('写的太多了');
		return false;	
	}
	
	var captcha = $('#comment_captcha').val();
	if(captcha == '')
	{
		alert('请输入验证码');
		return false;		
	}	
	var uid = $('#shopid').val();
 
	$.postJSON(sitepath+'ajax/comment.php',{act:'post',uname:uname,upass:upass,m:m,uid:uid,id:infoid,content:str,captcha:captcha,ajax:1},function(data){
		if(data.error == 1)
		{//发生错误
			alert(data.message);
			
			return false;
		}
		else
		{//发布成功,提示并执行其他操作
			IniComment(data._uid);
			alert(data.message);
			if(data.list)
			{
				commentlist(m,infoid);
			}
			return false;
		}
																					
	});
}
function commentlist(m,infoid,page)
{
	$('#commentbox').html('内容加载中...');
	
	$.getJSON(sitepath+'ajax/comment.php',{act:'list',m:m,infoid:infoid,page:page,ajax:1},function(data){
		$('.commentcount').text(data.count);
		$('#commentbox').html(data.content);
	});
}
function answerpost(askid)
{
	var _uid = $('#_uid').val();
	var uname = '';
	var upass = '';
	if(_uid == 0) 
	{
		uname = $('#answer_username').val();
		upass = $('#answer_password').val();
		if(uname == '')
		{
			alert('您还没有登录,请输入用户名');
			return false;
		}
		if(upass == '')
		{
			alert('请输入密码');
			return false;	
		}
	}
	var str = $('#answer_content').val();
	if(str.length < 1 )
	{
		alert('您的回答不能为空');
		return false;
	}

	var captcha = $('#comment_captcha').val();
	if(captcha == '')
	{
		alert('请输入验证码');
		return false;		
	}
	$.postJSON(sitepath+'ask/answer.php',{act:'post',uname:uname,upass:upass,askid:askid,content:str,captcha:captcha,ajax:1},function(data){
		if(data.error == 1)
		{//发生错误
			alert(data.message);
			return false;
		}
		else
		{
			alert(data.message);
			window.location.reload();
		}
																					
	});	
}
function feedbackpost()
{
	var str = $('#content').val();
	if(str.length < 10 || str.length > 500 )
	{
		alert('内容至少为10个字符且不超过500个');
		$('#content').focus();
		return false;
	}
	var email = $('#email').val();
	var myreg = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
	if(!myreg.test(email))
	{
		alert('请输入正确的邮箱地址');
		$('#email').focus();
		return false;
	}
	var captcha = $('#comment_captcha').val();
	if(captcha == '')
	{
		alert('请输入验证码');
		$('#comment_captcha').focus();
		return false;		
	}
	$.postJSON('feedback.php',{act:'post',email:email,content:str,captcha:captcha,ajax:1},function(data){
		if(data.error == 1)
		{//发生错误
			alert(data.message);
			return false;
		}
		else
		{
			alert(data.message);
			window.location.reload();
		}
																					
	});	
}
function askpost()
{
	var _uid = $('#_uid').val();
	var uname = '';
	var upass = '';
	if(_uid == 0) 
	{
		uname = $('#ask_username').val();
		upass = $('#ask_password').val();
		if(uname == '')
		{
			alert('您还没有登录,请输入用户名');
			return false;
		}
		if(upass == '')
		{
			alert('请输入密码');
			return false;	
		}
	}
	var title = $('#title').val();
	if(title.length < 5 || title.length > 50 )
	{
		alert('标题至少为5个字符且不超过50个');
		$('#title').focus();
		return false;
	}
	var str = $('#content').val();
	var captcha = $('#comment_captcha').val();
	if(captcha == '')
	{
		alert('请输入验证码');
		$('#comment_captcha').focus();
		return false;		
	}
	$.postJSON('post.php',{act:'post',uname:uname,upass:upass,title:title,content:str,captcha:captcha,ajax:1},function(data){
		if(data.error == 1)
		{//发生错误
			alert(data.message);
			return false;
		}
		else
		{
			alert(data.message);
			window.open('read.php?id='+data.id, '_self');
		}
																					
	});	
}
var _refurl = '';
function regbox()
{
	$('#poptitle').text('快速注册');
	$('#popcontent').text('内容加载中...');
	$.getJSON(sitepath+'ajax/reg.php',{act:'box'},function(data){
		$('#popcontent').html(data.content);
		$('#r_username').focus();
		$('#_refurl').val(_refurl);
	});
}
function loginbox()
{
	$('#poptitle').text('快速登录');
	$('#popcontent').text('内容加载中...');
	$.getJSON(sitepath+'ajax/login.php',{act:'box'},function(data){
		$('#popcontent').html(data.content);
		$('#a_username').focus();
		$('#_refurl').val(_refurl);
	});
	openUI();
}
function messagebox(uid)
{
	$('#poptitle').text('发送站内信');
	$('#popcontent').text('内容加载中...');
	$.getJSON(sitepath+'ajax/message.php',{act:'box'},function(data){
		$('#popcontent').html(data.content);
		$('#a_uid').val(uid);
		$('#_refurl').val(_refurl);
	});
	openUI();
}
function loginpost()
{
	var username = $('#a_username').val();
	var password = $('#a_password').val();
	var code = $('#a_code').val();
	var savelogin = $('#a_savelogin').val();
	if(username == '') {
		showtip('err','用户名不能为空');
		$('#a_username').focus();
		return false;
	}
	else{
		showtip('','');	
	}
	if(password == '') {
		showtip('err','密码不能为空');
		$('#a_password').focus();
		return false;
	}
	else{
		showtip('','');	
	}
	if(code == '') {
		showtip('err','验证码不能为空');
		$('#a_code').focus();
		return false;
	}
	else{
		showtip('','');	
	}
	$.postJSON(sitepath+'ajax/login.php',{act:'login',username:username,password:password,code:code,savelogin:savelogin,ajax:1},function(data){
		if(data.error > 0 )
		{
			showtip('err',data.message);
			return false;
		}
		else
		{
			closeUI();
			IniLogin(data.uid,data.uname);
			EvalStr();
		}
	});
	return false;
	
}
function EvalStr()
{
	var refurl = $('#_refurl').val();
	if(refurl == '') return false;
	var query = refurl.split('||');
	var strs = query[0]+"(";
	for(var i=1;i<query.length;i++)
	{
		if(i > 1)
		{
			strs += ",";
		}
		strs += "'"+query[i]+"'";
	}
	strs += ")";
	eval(strs);
	$('#_refurl').val('');
}
function regpost()
{
	var username = $('#r_username').val();
	var password = $('#r_password').val();
	var rpassword = $('#rs_password').val();
	var code = $('#r_code').val();
	var email = $('#r_email').val();

	var patrn=/^(\w){5,12}$/;  
	if(!patrn.exec(username))
	{
		showtip('err','用户名是5~12个字母、数字、下划线的组合');
		$('#r_username').focus();
		return false;
	}
 	else{
		showtip('','');	
	}
	if(password.length > 20 || password.length < 6) {
		showtip('err','密码长度介于6~20位之间');
		$('#r_password').focus();
		return false;
	}
	else{
		showtip('','');	
	}
	if( rpassword != password)
	{
		showtip('err','重复密码与密码不一致');
		$('#rs_password').focus();
		return false;
	}
	else{
		showtip('','');	
	}
	var myreg = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
	if(!myreg.test(email))
	{
		showtip('err','请输入正确的邮箱地址');
		$('#r_email').focus();
		return false;
	}
	else
	{
		showtip('','');	
	}
	if(code == '') {
		showtip('err','验证码不能为空');
		$('#r_code').focus();
		return false;
	}
	else{
		showtip('','');	
	}
	
	$.postJSON(sitepath+'ajax/reg.php',{act:'save',username:username,password:password,rpassword:rpassword,code:code,email:email,ajax:1},function(data){
		if(data.error > 0 )
		{
			showtip('err',data.message);
			return false;
		}
		else
		{
			closeUI();
			IniLogin(data.uid,data.uname);
			EvalStr();
		}
	});
	return false;
	
}
function showtip(type,val)
{
	if(type == ''){
		$('#msgtip').removeClass();
		$('#msgtip').addClass('msgtip');
		$('#msgtip').text(val);
	}
	else{
		$('#msgtip').removeClass();
		$('#msgtip').addClass(type+'tip');
		$('#msgtip').text(val);
	}
}
function messagepost(uid,content)
{
	
	uid = isNaN(uid) ? 0 : uid;
	if(uid == 0)
	{
		uid = $('#a_uid').val();
		content = $('#a_content').val();	
	}
	if(uid == 0)
	{
		showtip('err','收件人不能为空');
		return false;
	}
 
	if(content.length < 5 || content.length > 500)
	{
		showtip('err','消息内容至少5字符且不超过500字符');
		return false;
	}
	
	var _uid = $('#_uid').val();
	if(_uid == 0)
	{
		_refurl = 'messagepost||'+uid+'||'+content;
		loginbox();
		return false;
	}
	$.getJSON(sitepath+'ajax/message.php',{'act':'post','uid':uid,'content':content,ajax:1},function(data){
		if(data.errorcode == 1)
		{
			IniLogin(0,'');
			messagepost(uid,content);
		}
		else
		{
			$('#a_content').val('');
			closeUI();
			alert(data.message);
		}
	});
	
}
function baoming(shopid)
{
	var realname = $('#bm_realname').val();
	if(realname == '')
	{
		alert('请输入您的姓名!');
		$('#bm_realname').focus();
		return false;	
	}
	var sex = $('input[type=radio][name=bm_sex][checked]').val();
	var tel = $('#bm_tel').val();
	if(tel == '')
	{
		alert('请输入您的联系电话或手机!');
		$('#bm_tel').focus();
		return false;	
	}
	var lesson = $('#bm_lesson').val();
	if(lesson == '')
	{
		alert('请输入您预报的课程!');
		$('#bm_lesson').focus();
		return false;	
	}
	var content = $('#bm_content').val();
	$.getJSON(sitepath+'ajax/baoming.php',{'act':'post','shopid':shopid,'realname':realname,'sex':sex,'tel':tel,'lesson':lesson,'content':content,ajax:1},function(data){
		alert(data.message);
		window.location.reload();
	});
}
function fanyiorder(shopid)
{
	var yuyan = $('#fy_yuyan').val();
	if(yuyan == '')
	{
		alert('请输入您的预翻译的语言!');
		$('#fy_yuyan').focus();
		return false;	
	}
	var hangye = $('#fy_hangye').val();
	if(hangye == '')
	{
		alert('请输入您的所在的行业!');
		$('#fy_hangye').focus();
		return false;	
	}
	var info = $('#fy_info').val();
	if(info == '')
	{
		alert('请输入订单详情');
		$('#fy_info').focus();
		return false;	
	}
	var name = $('#fy_name').val();
	if(name == '')
	{
		alert('请输入您的姓名!');
		$('#fy_name').focus();
		return false;	
	}
	var tel = $('#fy_tel').val();
	if(tel == '')
	{
		alert('请输入您的联系电话或手机!');
		$('#fy_tel').focus();
		return false;	
	}
	var title = $('#fy_title').val();
	var type = $('#fy_type').val();
	$.getJSON(sitepath+'ajax/fanyiorder.php',{'act':'post','shopid':shopid,'name':name,'yuyan':yuyan,'hangye':hangye,'tel':tel,'title':title,'info':info,'type':type,ajax:1},function(data){
		alert(data.message);
		window.location.reload();
	});
}
function favorites(m,url,title)
{
	var _uid = $('#_uid').val();
	if(_uid == 0)
	{
		_refurl = 'favorites||'+m+'||'+url+'||'+title;
		loginbox();
		return false;
	}
	$.getJSON(sitepath+'ajax/favorites.php',{'act':'add','m':m,'url':url,'title':title,ajax:1},function(data){
		if(data.errorcode == 1)
		{
			IniLogin(0,'');
			favorites(m,url,title);
		}
		else
		{
			alert(data.message);
		}
	});
	
}
function openUI()
{
	$.blockUI({message:$('#popbox')[0],css:{width:'500px',left: ($(window).width() - 500) /2 + 'px'}});
}
function closeUI()
{
	$.unblockUI({message:$('#popbox')[0]});
}



//以上为最新的
document.writeln('<div class="popbox" id="popbox" style="display:none;">');
document.writeln('<div class="title"><span id="poptitle"></span><span class="thisclose" onclick="closeUI()">[关闭]</span></div>');
document.writeln('<div class="popcontent" id="popcontent"></div>');
document.writeln('</div>');

function getareachild(autochild)
{
	var areaid;
	$('#areaid_0_box').html('');
	if(!autochild)
	{	
		areaid = $('#areaid_0').val();
		$('#areaid').val(areaid);
	}
	else
	{
		areaid = $('#areaid').val();
	}
	$.getJSON("ajax.php",{type:'areachild',areaid:areaid,autochild:autochild,ajax:1},function(data){
						if(data == false) return false;
						if(autochild) $('#areaid_0').attr('value',data.parentid);
						var str = "<select id=\"areaid_"+areaid+"\" class=\"itext3\" onchange=\"getarea('"+areaid+"')\"><option value='0' >市/地区</option>";
						var selected;
						$.each(data,function(i,n){
							if(autochild){
								if(areaid == i)
									selected = " selected ";
								else
									selected = "";
							}
							if(i>0) str += "<option value=\""+i+"\" "+selected+" >"+n+"</option>";
						});
						str += "</select>";
						$('#areaid_0_box').html(str);
						
		});
}
var productatt = 0;
function getindustry(iid)
{
	var industryid = $("#industryid_"+iid).val();
	$('#industryid').val(industryid);
	getbrand(false);
	if(productatt == 1) getattrbute();
}
function getindustrychild(autochild)
{
	var industryid;
	$('#industryid_0_box').html('');
	if(!autochild)
	{	
		industryid = $('#industryid_0').val();
		$('#industryid').val(industryid);
	}
	else
	{
		industryid = $('#industryid').val();
	}
	$.getJSON("ajax.php",{type:"industrychild",industryid:industryid,autochild:autochild,ajax:1},function(data){
						if(data == false) return false;
						if(autochild) $('#industryid_0').attr('value',data.parentid);
						var str = "<select id=\"industryid_"+industryid+"\" class=\"itext\" onchange=\"getindustry('"+industryid+"')\">";
						var selected;
						var j=0;
						$.each(data,function(i,n){
							if(autochild){
								if(industryid == n.id)
									selected = " selected ";
								else
									selected = "";
							}
							else
							{
								if(j==0)
								{
									selected = " selected ";
									$('#industryid').val(n.id);
								}
								else
									selected = "";
							}
							if(n.id>0) str += "<option value=\""+n.id+"\" "+selected+" >"+n.name+"</option>";
							j++;
						});
						str += "</select>";
						$('#industryid_0_box').html(str);
						if(!autochild) getbrand(false);
						if(productatt == 1 && !autochild) getattrbute();
						
	});
}
function getbrand(auto)
{
	var industryid = $('#industryid').val();
	if(!auto)
	{
		$("#brandid").val('0');
	}
	if(industryid == 0 || industryid == '' || industryid == null || industryid == 'undefined')
	{
		return false;
	}
	
	$.getJSON("ajax.php",{type:"brandlist",industryid:industryid},function(data){
					
					$("#brandid_0").empty();
					var str = "<option value='0'>选择品牌</option>";
					if(data != false)
					{
						var selected;
						var brandid = $("#brandid").val();
						$.each(data,function(i,n){
							if(auto){
								if(brandid == i)
									selected = " selected ";
								else
									selected = "";
							}
							str += "<option value=\""+i+"\" "+selected+" >"+n.first+"=>"+n.name+"</option>";
						});
					}
					$("#brandid_0").append(str);	
		});
}
function getbrand_s(str)
{
	var industryid = $('#industryid').val();
	if(industryid == 0 || industryid == '') 
	{
		return false;
	}
	$.getJSON("ajax.php",{type:"brandlist",industryid:industryid},function(data){
					
					$("#brandid").empty();											   
					str = "<option value='0'>"+str+"</option>";
					if(data)
					{	
						$.each(data,function(i,n){
							str += "<option value=\""+i+"\">"+n.first+" "+n.name+"</option>";
						});
					}
					$("#brandid").append(str);	
		});
}
function getbrand_()
{
	var industryid = $('#industryid').val();
	if(industryid == 0 || industryid == '' || industryid == null || industryid == 'undefined') return false;
	$.getJSON("ajax.php",{type:"brandlist",industryid:industryid},function(data){
					$("#brandlist").html('加载中...');											   
					var str = "";											   
					if(data != false)
					{
						$.each(data,function(i,n){
							str += "<span id='brand_"+i+"_id'>"+n.name+" <a href='javascript:void(0);'  onclick=\"addbrand('"+i+"');\">添加</a></span><br />";
						});
					}
					$("#brandlist").html(str);	
		});
}
function getindustry_s()
{
	var industryid = $("#industryid_1").val();
	$('#industryid').val(industryid);
}
function getindustry_()
{
	var industryid = $("#industryid_1").val();
	$('#industryid').val(industryid);
	getbrand_();
}
function getindustrychild_s(str)
{
	var industryid = $('#industryid_0').val();
	$('#industryid').val(industryid);
	$.getJSON("ajax.php",{type:"industrychild",industryid:industryid},function(data){
						str = "<option value=\"0\" >"+str+"</option>";
						if(data)
						{
							$.each(data,function(i,n){
								str += "<option value=\""+n.id+"\">"+n.name+"</option>";
							});
						}
						$("#industryid_1").empty();
						$("#industryid_1").append(str);
						
	});
}
function getindustrychild_()
{
	var industryid = $('#industryid_0').val();
	$('#industryid').val(industryid);
	$.getJSON("ajax.php",{type:"industrychild",industryid:industryid},function(data){
						if(data == false)
						{
							getbrand_();
							return false;
						}						
						var str = "";
						var selected;
						var j=0;
						$.each(data,function(i,n){
							if(j==0)
							{
								selected = " selected ";
								$('#industryid').val(n.id);
							}
							else
								selected = "";
							str += "<option value=\""+n.id+"\" "+selected+" >"+n.name+"</option>";
							j++;
						});
						$("#industryid_1").empty();
						$("#industryid_1").append(str);
						getbrand_();
						
	});
}
function setbrand()
{
	var brandid = $('#brandid_0').val();
	$('#brandid').val(brandid);
	if(productatt == 1) getattrbute();
}
function getproduct(auto)
{
	var industryid = $('#industryid').val();
	if(auto)
	{
		var brandid = $('#brandid').val();
	}
	else
	{
		var brandid = $('#brandid_0').val();
		$('#brandid').val(brandid);
	}
	
	if(industryid == 0 || industryid == '' || industryid == null || industryid == 'undefined') 
	{
		return false;
	}
	if(brandid == 0 || brandid == '' || brandid == null || brandid == 'undefined') 
	{
		return false;
	}
	$.getJSON("ajax.php",{type:"productlist",industryid:industryid,brandid:brandid},function(data){
					
					$("#productid_0").empty();																 
					var str = "<option value='0'>选择商品</option>";	
					if(data != false)
					{
						var selected;	
						var productid = $('#productid').val();
						$.each(data,function(i,n){
							if(auto){
								if(productid == i)
									selected = " selected ";
								else
									selected = "";
							}
							str += "<option value=\""+i+"\" "+selected+" >"+n+"</option>";
						});
					}
					$("#productid_0").append(str);	
		});
}
function getproduct_s(auto)
{
	var industryid = $('#industryid').val();
	var brandid = $('#brandid').val();
	if(industryid == 0 || industryid == '' || industryid == null || industryid == 'undefined') 
	{
		return false;
	}
	if(brandid == 0 || brandid == '' || brandid == null || brandid == 'undefined') 
	{
		return false;
	}
	$.getJSON("ajax.php",{type:"productlist",industryid:industryid,brandid:brandid},function(data){
								
					$("#productid").empty();																 
					var str = "<option value='0'>所有商品</option>";
					if(data != false)
					{
						var selected;
						$.each(data,function(i,n){
							if(auto){
								if(productid == i)
									selected = " selected ";
								else
									selected = "";
							}
							str += "<option value=\""+i+"\" "+selected+" >"+n+"</option>";
						});
					}
					$("#productid").append(str);	
		});
}
function getattrbute()
{
	var industryid = $('#industryid').val();
	var brandid = $('#brandid').val();
	var productid = $('#id').val();
	var str = "";
	if(industryid == 0 || industryid == '' || industryid == null || industryid == 'undefined') 
	{
		$("#tab3").html(str);
		return false;
	}
	$.getJSON("ajax.php",{type:"attributelist",industryid:industryid,brandid:brandid,productid:productid},function(data){
					
					$.each(data,function(i,n){
							str += " <tr> <td align='right' class='leftt'>"+n.name+"</td> <td align='left' class='rightc'>"+n.template+"</td>  </tr>";
						});
					$("#tab3").html(str);	
		});
}
