function jfbis(){
	if ($("jfbdiv").style.display == "none"){
		$("jfbdiv").style.display = ""
		$("isjfb").checked = true;
	}else{
		$("jfbdiv").style.display = "none"
		$("isjfb").checked = false;
	}
}
function jfbsubmit(){
	var uid = $("uid").value
	var pwd = $("pwd").value
	if (uid == "" || pwd==""){
		$("msgs").style.display = ""
		$("msgs").innerHTML = "<img src='/skin/main/images/error.gif' width='13' height='13' align='absmiddle'>请输入您在(http://www.jianfeiba.com)上注册的用户名与密码！"
	}else{
		check_jianfeiba_user(uid,pwd);
	}
}

function check_jianfeiba_user(uid,pwd){
	$("msgs").style.display = ""
	$("msgs").innerHTML = "验证中..."
	var pars="&u="+uid+"&p="+pwd;
	var url="/check_jfbuser.php";
	var myAjax = new Ajax.Request(
		url, 
		{
			method: 'get', 
			parameters: pars, 
			onSuccess: checkValid_OK,
			onFailure: ajax_failure
		});
}

function checkValid_OK(o){
	var returnText = o.responseText;
	if (returnText.indexOf("error1")!=-1){
		$("msgs").innerHTML = "<img src='/skin/main/images/error.gif' width='13' height='13' align='absmiddle'>不存在这个用户！"
	}else if(returnText.indexOf("error2")!=-1){
		$("msgs").innerHTML = "<img src='/skin/main/images/error.gif' width='13' height='13' align='absmiddle'>抱歉，密码不正确！"
	}else{
		$("msgs").innerHTML = "<img src='/skin/main/images/right.gif' width='13' height='13' align='absmiddle'>验证完成，获取成功！"
		alllist = returnText.split("|||")
		$("names").value = alllist[0]
		$("address").value = alllist[1]
		$("postcode").value = alllist[2]
		$("tel").value = alllist[3]
		$("mtel").value = alllist[4]
		$("names").focus();
	}
	return false;
}

function bank(s){
	if (s!=0){
		$("cityquery").style.display = "none";
	}else{
		$("cityquery").style.display = "";
	}
	if (s==2){
		$("banklist").style.display = "";
	}else{
		$("banklist").style.display = "none";
	}
}
function pubcity(){
	getzjs(orderform.province.value,orderform.city.value);
	bank(0);
}
function getzjs(x,b){
	//orderform.city.value = orderform.city.value.replace("市","").replace("区","").replace("县","")
	b = b.replace("市","")
	b = b.replace("区","")
	b = b.replace("县","")
	if (x!=0&&b!=""){
		$("pubal").style.display = ""
		$("pubal").innerHTML = "验证中..."
		var pars="&id="+x+"&c="+encodeURIComponent(b);
		var url="/check_city.php";
		var myAjax = new Ajax.Request(
			url, 
			{
				method: 'get', 
				parameters: pars, 
				onSuccess: getAreaState,
				onFailure: ajax_failure
			});

	}else if (b==""){
		orderform.fs[0].checked=true;
		orderform.fs[1].checked=false;
		$("pubal").innerHTML = "(注：请在选择省份后填写县或地区，系统会自动检索是否支持货到付款)"
	}
}

function getAreaState(o) {
  var p = orderform.province.options[orderform.province.selectedIndex].text;
  var statethis = o.responseText;
  if (statethis.indexOf("yes")==-1){//不支持支付
	orderform.fs[0].checked=false;
	orderform.fs[1].checked=true;
	$("pubal").innerHTML = "<img src='http://www.shoushow.com/skin/main/images/error.gif' width='13' height='13' align='absmiddle'><font color=red> "+p+"-"+orderform.city.value+" 不支持货到付款。</font>";
  }else{
	orderform.fs[0].checked=true;
	orderform.fs[1].checked=false;
	$("pubal").innerHTML = "<img src='http://www.shoushow.com/skin/main/images/right.gif' width='13' height='13' align='absmiddle'><font color=red> 恭喜，<b>"+p+"-"+orderform.city.value+"</b> 支持货到付款。</font>";
  }
}
var shoulimei_prod_list=new Array();
shoulimei_prod_list[4]=new Array(6280,3899,2381);
shoulimei_prod_list[3]=new Array(4710,3140,1570);
shoulimei_prod_list[2]=new Array(3140,2500,640);
shoulimei_prod_list[1]=new Array(1570,1570,0);
comecoo_prod_list=new Array();
comecoo_prod_list[0]=0;
comecoo_prod_list[1]=380;
comecoo_prod_list[2]=680;

function show_order_info(){
	var choose_slm=choose_kmk=0;
	var choose_slm = get_check(orderform.prod_id);
	if(choose_slm){
		var choose_kmk 	= get_check(orderform.kmk);
		var kmk_price 	= comecoo_prod_list[choose_kmk];

		var cuxiaojia	= shoulimei_prod_list[choose_slm][1];
		var all_price 	= shoulimei_prod_list[choose_slm][1]+kmk_price;//取促销价
		var pay_price 	= Math.round(all_price*0.95);
		var jieshen 	=  Math.round(all_price*0.05);

		var t='瘦立美'+choose_slm+'套：促销价'+cuxiaojia+'元；';
		if(choose_kmk){
			t=t+' '+choose_kmk+'个疗程康美柯：'+kmk_price+'元';
		}
		t=t+'<br />总计金额：<b style="color:#f00; ">'+all_price+'</b>元    先行付款节省：<b style="color:#f00; ">'+jieshen+'</b>元    实际支付金额：<b style="color:#f00; ">'+pay_price+'.00</b>元';
	}else{
	 var t="请先选择您要订购的产品";	
	}
	order_info.innerHTML=t;
}

function get_check(obj){
	checked=0;
	for(i=0;i<obj.length;i++){
		if(obj[i].checked){checked=obj[i].value;break;}
	}
	return checked;
}

function check(){
	var names = orderform.names
	var address =orderform.address
	var postcode =orderform.postcode
	var tel = orderform.tel
	var mtel = orderform.mtel
	var other1 = orderform.other1
	var other2 = orderform.other2
	var content = orderform.content
	var choose_prod = get_check(orderform.prod_id);
	var fsID = get_check(orderform.fs);

	if(choose_prod<1){
		alert("[提示]请选择您要订购的产品！");
		return false;
	}
	if (names.value.length < 2 || names.value.lenght > 20){
		alert("[提示]请认真填写收货人姓名！")
		names.focus();
		return false;
	}
	if (address.value.length < 3){
		alert("[提示]请认真填写收货地址，以确保货物能准确送达！")
		address.focus();
		return false;
	}
	if (postcode.value!=""&&(postcode.value.length != 6||isNaN(postcode.value))){
		alert("[提示]邮政编辑格式错误！")
		postcode.focus();
		return false;
	}
	if (tel.value == ""&&mtel.value==""){
		alert("[提示]联系电话和手机至少填写一项！")
		tel.focus();
		return false;
	}
	if (other1.value!=""&&isNaN(other1.value)){
		alert("[提示]身高不正确！")
		other1.focus();
		return false;
	}
	if (other2.value!=""&&isNaN(other2.value)){
		alert("[提示]体重不正确！")
		other2.focus();
		return false;
	}
	if (content.value.length > 200){
		alert("[提示]备注说明请控制在200字以内！")
		content.focus();
		return false;
	}
	if(fsID<1){
		alert("[提示]请选择支付方式！");
		return false;
	}
}