var MerchantSAmount=0;
var FZAjax=new Ajax();
//加载指定地区的街道
function LoadStreet(URL,I,ID){
	if(I=='')return;
	StreetID=ID;
	FZAjax.open(URL.replace(ext,I+ext),ReStreet);
	FZAjax.send();
}
var StreetID;
function ReStreet(reAjax,status){
	 if(status == 200){
		 if(reAjax.responseText.split(':')[0]!='ok' || reAjax.responseText.split(':').length!=2)return;
		 var obj=$(StreetID);
		 var TList=reAjax.responseText.split(':')[1].split(';');
		 obj.options.length=1;
		 for(var i=0;i<TList.length;i++){
			 obj.options[obj.options.length]=new Option(TList[i].split(',')[1],TList[i].split(',')[0]);
		 }
	 }
}

//加载指定街道的小区,写字楼
function LoadCommunity(URL,I,ID){
	if(I=='')return;
	CommunityID=ID;
	FZAjax.open(URL.replace(ext,I+ext),ReCommunity);
	FZAjax.send();
}
var CommunityID;
function ReCommunity(reAjax,status){
	 if(status == 200){
		 if(reAjax.responseText.split(':')[0]!='ok' || reAjax.responseText.split(':').length!=2)return;
		 var obj=$(CommunityID);
		 var TList=reAjax.responseText.split(':')[1].split(';');
		 obj.options.length=1;
		 for(var i=0;i<TList.length;i++){
			 obj.options[obj.options.length]=new Option(TList[i].split(',')[1],TList[i].split(',')[0]);
		 }
	 }
}

function loginForm(obj){
	try{
		if(cookie.is('SaveLogin'))cookie.delCookie('SaveLogin');
		if(cookie.is('UserName'))cookie.delCookie('UserName');
		if(cookie.is('UserPassword'))cookie.delCookie('UserPassword');
		if(obj.SaveLogin.checked){
			cookie.setCookie('SaveLogin',1,obj.SaveLoginTime.value,'/');
			cookie.setCookie('UserName',$('UserName').value,obj.SaveLoginTime.value,'/');
			cookie.setCookie('UserPassword',$('UserPassword').value,obj.SaveLoginTime.value,'/');
		}
	} catch (e) {}
	return true;
}
function loginFormHome(obj){
	if($('UserName').value==''||$('UserPassword').value=='')
	  {alert('用户名、密码不能空');
	   return false;
	  }
	  if($('mtype').value==''||$('mtype').value==0){
		alert('请选择类型');
		return false;
	  }
	try{
		if(cookie.is('SaveLogin'))cookie.delCookie('SaveLogin');
		if(cookie.is('UserName'))cookie.delCookie('UserName');
		if(cookie.is('UserPassword'))cookie.delCookie('UserPassword');
		if(obj.SaveLogin.checked){
			cookie.setCookie('SaveLogin',1,obj.SaveLoginTime.value,'/');
			cookie.setCookie('UserName',$('UserName').value,obj.SaveLoginTime.value,'/');
			cookie.setCookie('UserPassword',$('UserPassword').value,obj.SaveLoginTime.value,'/');
		}
	} catch (e) {}
	return true;
}
window.onload=function(){
	try{
		if(!window.onbeforeunload && MerchantSAmount!=0) window.onbeforeunload = ConfirmClose;
	}catch(e){}
	try{
		if(cookie.is('SaveLogin')){
			if(cookie.getCookie('SaveLogin')=='1'){
				$('SaveLogin').checked=true;
				if(cookie.is('UserName')){
					$('UserName').value=cookie.getCookie('UserName');
				}
				else return;
				if(cookie.is('UserPassword')){
					$('UserPassword').value=cookie.getCookie('UserPassword');
				}
				else return;
				if(cookie.is('UserName') && cookie.is('UserPassword')){
					BbsAjaxLogin(cookie.getCookie('UserName'),cookie.getCookie('UserPassword'));
				}
			}
		}
	} 
	catch (e) {}
	SetCart();
}
var BbsUserName,BbsUserPassword,mtype;
function BbsAjaxLogin(user,pass){
		BbsUserName=user;
		BbsUserPassword=pass;
		FZAjax.open("/bbs/member_enter.php",ReBbsAjaxLogin);
		FZAjax.send("username="+BbsUserName+"&password="+BbsUserPassword+"&imcode=&login_mode=&session_term=604800&location=index.php&action=login");
}
function ReBbsAjaxLogin(reAjax,status){
	 if(status == 200){
		try{			
			if(reAjax.responseText=="ok"){
				FZAjax.open(LoginUrl,AjaxLogin);    //LoginUrl="index.php?Act=Hybk&Cmd=Ajaxlogin&do";
				FZAjax.send("login[UserName]="+BbsUserName+"&login[UserPassword]="+BbsUserPassword+"&mtype="+mtype);
			}
			else alert(reAjax.responseText);
		}
		catch (e) {
			FZAjax.open(LoginUrl,AjaxLogin);
			FZAjax.send("login[UserName]="+BbsUserName+"&login[UserPassword]="+BbsUserPassword);
		}
	 }
}
function WebLogin(){
	if(loginForm($('login_form'))){
	 BbsAjaxLogin($('UserName').value,$('UserPassword').value);
	}
	//return false;
}
function WebLoginHome(){
	mtype=$('mtype').value;
	 if(loginFormHome($('login_form'))){
	 if(mtype=='user')
	     BbsAjaxLogin($('UserName').value,$('UserPassword').value);
	 else{
		  document.forms['login_form'].submit();
		 }	  
	}
	//return false;
}


function AjaxLogin(reAjax,status){
	 if(status == 200){
		if(reAjax.responseText=="ok"){
			window.location.reload(true);
		}
		else  alert(reAjax.responseText);
	 }
}
function ReBbsAjaxRegExit(reAjax,status){}
function ReBbsAjaxReg(reAjax,status){
	 if(status == 200){
		if(reAjax.responseText=="ok"){
			//FZAjax.open("/bbs/member_enter.php?action=logout",ReBbsAjaxRegExit);
			//FZAjax.send();
			$("memberReg").submit();
		}
		else{
			alert(reAjax.responseText);
			FZAjax.open("/bbs/member_enter.php?action=logout",ReBbsAjaxRegExit);
			FZAjax.send();
			
		}
	 }
}
function WebReg(){
	if(checkMemberReg()){		
		var PostValue="username="+$("RegUserName").value;
		PostValue+="&password="+$("UserPassword[0]").value;
		PostValue+="&password_again="+$("UserPassword[0]").value;
		if($("Email[0]").value=="")$("Email[0]").value="temp";
		if($("Email[1]").value=="")$("Email[1]").value="temp.te";
		PostValue+="&email="+$("Email[0]").value+"@"+$("Email[1]").value;
		PostValue+="&password="+$("UserPassword[0]").value;
		PostValue+="&password="+$("UserPassword[0]").value;
		try{
			if($("RegGender").checked){
				PostValue+="&sex=先生";
			}
			else PostValue+="&sex=女士";
		}
		catch (e) {}
		FZAjax.open("/bbs/member_enter.php",ReBbsAjaxReg);
		FZAjax.send(PostValue+"&email_set=secret&get_web_email=no&imcode=&session_term=604800&action=register");
	}
}
function ReBbsAjaxExitLogin(reAjax,status){
	 if(status == 200){
		try{
			if(reAjax.responseText=="ok"){
				UserExitLogin();
			}
			else alert(reAjax.responseText);
		}
		catch (e) {
			UserExitLogin();
		}
	 }
} 

function ExitLogin(){
		//FZAjax.open("/bbs/member_enter.php?action=logout",ReBbsAjaxExitLogin);
		//FZAjax.send();
		UserExitLogin();
}

//  1 点餐
function Ordering(obj){
//	if(obj.getAttribute('UID')=="0"){
//		alert("请登录后再"+MerchantType+"！");
//		window.location="/";
//		return;
//	}
	 FZAjax.open(OrderingUrl,ReOrdering);
	 FZAjax.send("Mid="+obj.getAttribute('MID'));	 
}
//  1 re 点餐
function ReOrdering(reAjax,status){
	 if(status == 200){
		 var bodyHtml;
		FZmoves.setclose("关闭","关闭");
		FZmoves.setbar(MerchantType);
		FZmoves.settitle(MerchantType);
		FZmoves.setAlpha(60);
		 FZmoves.show();
		FZmoves.setbody(reAjax.responseText);			
	 }
}

//点餐
function Ordering2(obj){
	if(obj.getAttribute('UID')=="0"){
		alert("请登录后再"+MerchantType+"！");
		window.location="/";
		return;
	}
	var bodyHtml;
	FZmoves.setclose("关闭","关闭");
	FZmoves.setbar(MerchantType);
	FZmoves.settitle(MerchantType);
	FZmoves.setAlpha(60);
	bodyHtml='<div class="listx"><ul><li class="t1"><span>商品名称：</span><INPUT TYPE="hidden" id="MsUnit" value="'+obj.getAttribute('MsUnit')+'"><INPUT TYPE="hidden" id="MID" value="'+obj.getAttribute('MID')+'"><INPUT TYPE="hidden" id="MsName" value="'+obj.getAttribute('MsName')+'"><INPUT TYPE="hidden" id="MsPrice" value="'+obj.getAttribute('MsPrice')+'"><strong>'+obj.getAttribute('MsName')+'</strong>&nbsp;&nbsp;'+obj.getAttribute('MsPrice')+'元/1'+obj.getAttribute('MsUnit')+'</li><li class="t1"><span>选择数量：</span><SELECT NAME="MsCopies" id="MsCopies" class="select1">';
	for(var i=1;i<=obj.getAttribute('MsCopies');i++){
		bodyHtml+='<option value="'+i+'">'+i+'</option>';
	}
	bodyHtml+='</SELECT>&nbsp;'+obj.getAttribute('MsUnit')+'</li><li class="c2"><INPUT TYPE="image" src="images/tj.jpg" onclick="javascript:AddCart();" class="button"></li></ul></div>';
	FZmoves.show();
	FZmoves.setbody(bodyHtml);			
}

// 2. Cart() 写入cookie   见di2.jpg
function AddCart(){
	var TCart=escape($('MsName').value)+','+$('MsPrice').value+','+$('MsCopies').value+","+$('MID').value+","+escape($('MsUnit').value)+","+$('MerchantID').value+","+$('specs').value; //","+$('specs').value+
	if(cookie.is('Cart')){
		if(cookie.getCookie('Cart')!="")TCart+=";";
		TCart+=cookie.getCookie('Cart');
	}
	cookie.setCookie('Cart',TCart,ShoppingCartTime,'/');
	FZmoves.hidden();
	SetCart();
}
function DeleteCart(index){
	var TCartValue="";
	var TCart=cookie.getCookie('Cart').split(";");
	for(var i=0;i<TCart.length;i++){
		if(i!=index){
			if(TCartValue!="")TCartValue+=";";
			TCartValue+=TCart[i];
		};
	}
	cookie.setCookie('Cart',TCartValue,ShoppingCartTime,'/');
	SetCart();
}

var CartListNum=0;
var CartMaxPriceNum=0;
// 3  见di2.jpg
function SetCart(){
	CartListNum=0;
	CartMaxPriceNum=0;
	try{
		var TDHtml="";
		var XTDHtml="";
		if(cookie.is('Cart')){
			XTDHtml='<table border="0" align="center" cellpadding="1" width="100%" cellspacing="1" bgcolor="#dbdbdb" class="t3">';
			var TCart=cookie.getCookie('Cart').split(";");
			for(var i=0;i<TCart.length;i++){
				if(TCart[i].split(",").length==7){
					XTDHtml+='<tr bgcolor="#f4f8f0">';
					XTDHtml+='<td width="250" class="t4">'+unescape(TCart[i].split(",")[0])+'</td>';
					XTDHtml+='<td width="45">'+TCart[i].split(",")[1]+'</td>';
					XTDHtml+='<td width="45">'+TCart[i].split(",")[2]+unescape(TCart[i].split(",")[4])+'</td>';
					XTDHtml+='<td width="45">'+(TCart[i].split(",")[1]*TCart[i].split(",")[2])+'元</td>';
					XTDHtml+='<td><span style="cursor:pointer;" onclick="javascript:DeleteCart('+i+');">删除</span></td>';
					XTDHtml+='</tr>';
					//CartMaxPriceNum+=(TCart[i].split(",")[1]*TCart[i].split(",")[2]);
					CartMaxPriceNum=floatAdd(CartMaxPriceNum,TCart[i].split(",")[1]*TCart[i].split(",")[2]);
					CartListNum+=(TCart[i].split(",")[2]*1);
				}
			}
			XTDHtml+='</table>';
			//CartListNum=cookie.getCookie('Cart')=="" ? 0 : TCart.length;
		}
		$('CartList').innerHTML=XTDHtml;
		$('CartListNum').innerHTML=CartListNum;
		$('MaxPriceNum').innerHTML=CartMaxPriceNum;
		if(CartListNum>0){
			if(MerchantSAmount<=CartMaxPriceNum){
				$('OkOrderingButton').disabled=false;
				$('OkOrderingButton').src="/images/dc_sub2.gif";
			}else{
				$('OkOrderingButton').disabled=true;
				$('OkOrderingButton').src="/images/dc_sub2x.gif";
				}  
			//set1234567890();
		}
		else $('OkOrderingButton').disabled=true;	
		
		$("CartList2").innerHTML=XTDHtml;
		$('CartListNum2').innerHTML=CartListNum;
		$('MaxPriceNum2').innerHTML=CartMaxPriceNum;
		if(CartListNum>0){
			if(MerchantSAmount<=CartMaxPriceNum){
				$('OkOrderingButton2').disabled=false;
				$('OkOrderingButton2').src="/images/dc_sub2.gif";
			}else{
				$('OkOrderingButton2').disabled=true;
				$('OkOrderingButton2').src="/images/dc_sub2x.gif";
			} 
		}
		dcmenuh=window.setInterval("heartBeat()",20); 
		if(CartListNum>0){
			$("dcmenu").style.visibility="visible";
		}
		else $("dcmenu").style.visibility="hidden";

	} catch (e) {}
}
//  4  见di3.jpg index.php?Act=Ajax&Cmd=cart&do 生成订餐信息
function OkOrdering(){
	FZAjax.open(CartUrl,ReOkOrdering);
	FZAjax.send();
}
//4  re index.php?Act=Ajax&Cmd=cart&do 生成订餐信息
function ReOkOrdering(reAjax,status){  
	 if(status == 200){
		Orderingmoves.setclose("关闭","关闭");
		if(reAjax.responseText.split("体验订餐结束").length>1){
			Orderingmoves.setbar("体验订餐结束");
			Orderingmoves.settitle("体验订餐结束");
		}
		else{
			Orderingmoves.setbar("生成"+MerchantType+"信息");
			Orderingmoves.settitle("生成"+MerchantType+"信息");
		}
		Orderingmoves.setAlpha(60);
		if(reAjax.responseText.split(":::::=====:::::").length==2){
			cookie.setCookie('Cart',reAjax.responseText.split(":::::=====:::::")[0],ShoppingCartTime,'/');
			Orderingmoves.setbody(reAjax.responseText.split(":::::=====:::::")[1]);	
			SetCart();
		}
		else Orderingmoves.setbody(reAjax.responseText);			
		Orderingmoves.show();
		//SetCart();
	 }
}
// 5 见di4.jpg 确认/显示订餐信息
function DIVOkOrdering(){    // 5. DIVOkOrdering()     见di4.jpg index.php?Act=Ajax&Cmd=showordering&do    显示订餐信息
	if($("FZAddres").value=="" || $("FZAddres").value=="不在配送范围!"){
		alert("请选择配送地址！");
		return;
	}
	if($("FZT").value.split(':').length!=2){
		alert("送到时间格式错误,时和分之间用:分割.");
		return;
	}
	var d=new Date();
	var dd=new Date(d.getFullYear(),d.getMonth(),d.getDate(),$("FZT").value.split(':')[0],$("FZT").value.split(':')[1],d.getSeconds());
	if(dd.getTime()<(d.getTime()+1000*60*30)){
		alert('送到时间允许往后半小时的修改，不能修改成半小时内的！');
		return;
	}
	FZAjax.open(ShoworderingUrl,ReShowordering);
	//FZAjax.open(OkorderingUrl,ReOkOrdering);
	FZAjax.send("M="+$("FZMsg").value+"&Addres="+$("FZAddres").value+"&T="+$("FZT").value);	
	Orderingmoves.hidden();
}


function Showordering(M,A,T){
	//FZAjax.open(ShoworderingUrl,ReShowordering);
	FZAjax.open(OkorderingUrl,ReOkOrdering);
	FZAjax.send("M="+M+"&Addres="+A+"&T="+T);	
}

// 5 re  确认订单信息 
function ReShowordering(reAjax,status){  //5 di4.jpg  确认订单信息 
	 if(status == 200){
		Orderingmoves.setclose("关闭","关闭");
		Orderingmoves.setbar("确认"+MerchantType+"信息");
		Orderingmoves.settitle("确认"+MerchantType+"信息");
		Orderingmoves.setAlpha(60);
		Orderingmoves.setbody(reAjax.responseText);	
		Orderingmoves.show();
		 $("dcmenu").style.visibility="hidden";
	 }
}

function IsRegCode(obj,IsRegCodeUrl){
	if(obj.value.length==6){
		FZAjax.open(IsRegCodeUrl,ReIsRegCode);
		FZAjax.send("RegCode="+obj.value);	
	}
}
function ReIsRegCode(reAjax,status){
	if(status == 200){alert(reAjax.responseText);}
}


//催餐
function myUrge(){
  	 FZAjax.open(urgUrl,ReMyUrge);
	 FZAjax.send();	 
}
function ReMyUrge(reAjax,status){
	 if(status == 200){
		 var bodyHtml;
		FZmoves.setclose("关闭","关闭");
		FZmoves.setbar('催餐');
		FZmoves.settitle('催餐');
		FZmoves.setAlpha(60);
		 FZmoves.show();
		FZmoves.setbody(reAjax.responseText);			
	 }	
}

function checkUserPassword(){
	if($('UserPassword[1]').value=="" || $('UserPassword[0]').value!=$('UserPassword[1]').value){
		if($('UserPassword[1]').value==""){
			alert('请输入确认密码!');
		}
		else{
			alert('两次输入密码不一致!');
		}
		$('UserPassword[1]').focus();
		return true;
	}
	return false;
}
//验证用户注册输入的信息
function checkMemberReg(){
	if($('RegUserName').value==""){
		alert('请输入用户名!');
		$('RegUserName').focus();
		return false;
	}
	if($('RegUserName').value.length<2 || $('RegUserName').value.length>20){
		alert('请输入用户名,长度范围为4-20字符!');
		$('RegUserName').focus();
		return false;
	}
	if($('Nickname').value==""){
		alert('请输入会员称呼!');
		$('Nickname').focus();
		return false;
	}
	if($('Birthday[0]').value==""){
		alert('请选择会员生日!');
		$('Birthday[0]').focus();
		return false;
	}
	if($('Birthday[1]').value==""){
		alert('请选择会员生日!');
		$('Birthday[1]').focus();
		return false;
	}
	if($('UserPassword[0]').value==""){
		alert('请输入密码!');
		$('UserPassword[0]').focus();
		return false;
	}
	if(checkUserPassword()){
		return false;
	}
	if($('UserPassword[0]').value.length<4 || $('UserPassword[0]').value.length>20){
		alert('提交被拒绝！密码长度不在允许范围（4-20字符）！');
		$('UserPassword[0]').focus();
		return false;
	}
	if($("CommunityID[0]").value==""){
		alert('请选择送餐地址!');
		$('CommunityID[0]').focus();
		return false;
	}
	if($("StreetID[1]").value!=""&&$("CommunityID[1]").value==""){
		 alert('第二个地址选择不完整，无法保存第二个地址!');
		 $('CommunityID[1]').focus();
		 return false;
	}
	if($('PhoneNumber').value=="" || ($('PhoneNumber').value.length!=11 && $('PhoneNumber').value.length!=12)){
		alert('请输入手机号码!');
		$('PhoneNumber').focus();
		return false;
	}
	if($('RegCode').value==""){
		alert('请输入您接收到的随机验证码!');
		$('RegCode').focus();
		return false;
	}
	if(!$('checkbox').checked){
		alert('请认真查看注册协议!');
		$('checkbox').focus();
		return false;
	}
	if(isChinese($('RegUserName').value)){
		$('RegUserName').focus();
		return false;
	}
	return true;
}
function isChinese(string)
{
	var compare="`-=[]\;',./ !@#$%^&*()_+{}|:\"<>?｀－＝［］＼；＇，．／　～！＠＃＄％＾＆＊（）＿＋｛｝｜：＂＜＞？";
	for (var i=0;i<string.length;i++){
		if (compare.indexOf(string.charAt(i))!=-1){
			alert('用户名请不要用:'+compare+'等字符.')
			return true;
		}
	}
	return false;
} 
function IsUserNameReg(URL){
	FZAjax.open(URL,ReIsUserNameReg);
	FZAjax.send("UserName="+$("RegUserName").value);
}
function ReIsUserNameReg(reAjax,status){
	 if(status == 200){
		 $("showUserTSinfo").innerHTML=reAjax.responseText;
	 }
}
function chkpassword(){  
 if( $('UserPassword[0]').value.length<6 || $('UserPassword[0]').value.length>16){
		 //$('UserPassword[0]').focus();
		  $("showUserPassword").innerHTML='<font color=red>请输入正确的密码长度！6-16个字符。</font>';
	}
	else
	  $("showUserPassword").innerHTML='<img src="/images/check_right.gif"/>';
	
}
function chkrepassword(){  
 if($('UserPassword[0]').value!=$('UserPassword[1]').value){
	 	  $("showReUserPassword").innerHTML='<font color=red>你输入的密码不一致！</font>';
	}else
	  $("showReUserPassword").innerHTML='<img src="/images/check_right.gif"/>';

}

function Getcode(URL){
	if((/^13\d{9}$/g.test($("PhoneNumber").value))||(/^15[0-35-9]\d{8}$/g.test($("PhoneNumber").value))||(/^18[05-9]\d{8}$/g.test($("PhoneNumber").value))){
		FZAjax.open(URL.replace(ext,$("PhoneNumber").value+ext),ReGetcode);
		FZAjax.send();
	}
	else alert('非法的手机号！');
}
function ReGetcode(reAjax,status){
	 if(status == 200){
		 alert(reAjax.responseText);
	 }
}
//找回密码
function GetPassword(){
	var bodyHtml;
	FZmoves.setclose("关闭","关闭");
	FZmoves.setbar("找回密码");
	FZmoves.settitle("找回密码");
	FZmoves.setAlpha(60);
	bodyHtml='<BR>&nbsp;&nbsp;手机号：<INPUT TYPE="text" id="GetMobile" name="GetMobile">&nbsp;<BR><BR><INPUT type="image" src="/images/zhmm.jpg" onclick="javascript:OkGetPassword();" class="button">';
	FZmoves.show();
	FZmoves.setbody(bodyHtml);			
}
function OkGetPassword(){
	if($("GetMobile").value!=""){
		FZAjax.open(GetPasswordUrl+"="+new Date().getTime(),ReOkGetPassword);
		FZAjax.send("GetMobile="+$("GetMobile").value);
		FZmoves.hidden();
	}
}
function ReOkGetPassword(reAjax,status){
	 if(status == 200){
		 alert(reAjax.responseText);
	 }
}



var upx=5;
function SetUpx(i){
	var THtml="";
	if(i<1)i=1;
	if(i>5)i=5;
	upx=i;
	for(var j=1;j<=i;j++){
		THtml+='<span onclick="javascript:SetUpx('+j+');" style="color:red;cursor:pointer;">★</span>';
	}
	for(var k=j;k<=5;k++){
		THtml+='<span onclick="javascript:SetUpx('+k+');" style="color:#CCCCCC;cursor:pointer;">★</span>';
	}
	$("numEvaluation").innerHTML=THtml;
}
function OrderEvaluation(OID){
	var bodyHtml;
	upx=5;
	FZmoves.setclose("关闭","关闭");
	FZmoves.setbar("订单确认和评价");
	FZmoves.settitle("订单确认和评价");
	FZmoves.setAlpha(60);
	bodyHtml='<INPUT TYPE="hidden" value="'+OID+'" id="upOID" name="upOID">&nbsp;&nbsp;&nbsp;评价：<span id="numEvaluation"><span onclick="javascript:SetUpx(1);" style="color:red;cursor:pointer;">★</span><span onclick="javascript:SetUpx(2);" style="color:red;cursor:pointer;">★</span><span onclick="javascript:SetUpx(3);" style="color:red;cursor:pointer;">★</span><span onclick="javascript:SetUpx(4);" style="color:red;cursor:pointer;">★</span><span onclick="javascript:SetUpx(5);" style="color:red;cursor:pointer;">★</span></span><BR>&nbsp;&nbsp;&nbsp;<TEXTAREA id="upEvaluation" NAME="upEvaluation" ROWS="2" COLS="30" style="width:240px;height:50px;"></TEXTAREA>&nbsp;&nbsp;<BR><BR><span style="   padding-top:10px;"><INPUT type="image" src="images/dccg.jpg" onclick="javascript:OkOrderEvaluation();" class="button" style="margin-left:20px">&nbsp;&nbsp;<INPUT type="image" style="margin-left:40px" src="images/dcsb.jpg" onclick="javascript:ErrorOrderEvaluation();" class="button2"></span>';
	FZmoves.show();
	FZmoves.setbody(bodyHtml);
}
function OkOrderEvaluation(){
	if($("upEvaluation").value=="")$("upEvaluation").value="订单成功！";
	if($("upEvaluation").value!=""){
		UpdateAjax.open(UpdateUrl,ReOkOrderEvaluation);
		UpdateAjax.send("uptype=Evaluation&upvalue="+$("upEvaluation").value+"&OID="+$("upOID").value+"&upx="+upx);
		FZmoves.hidden();
	}
}
function ErrorOrderEvaluation(){
	if($("upEvaluation").value!=""){
		UpdateAjax.open(UpdateUrl,ReErrorOrderEvaluation);
		UpdateAjax.send("uptype=EvaluationError&upvalue=订餐失败,"+$("upEvaluation").value+"&OID="+$("upOID").value+"&upx="+upx);
		FZmoves.hidden();
	}
	else alert("请填写订餐失败原因！");
}
function ReErrorOrderEvaluation(reAjax,status){
	if(status == 200){
		window.location.reload(true);
	}
}
function ReOkOrderEvaluation(reAjax,status){
	if(status == 200){
		if(reAjax.responseText!="error"){
			alert("评价成功！");
			window.location.reload(true);
		}
	}
}



function getEvent() //同时兼容ie和ff的写法， 这个方法是网上copy的 
    {
        if(document.all)   return window.event;
        func=getEvent.caller;
        while(func!=null){
            var arg0=func.arguments[0];
            if(arg0)
            {
                if((arg0.constructor==Event || arg0.constructor ==MouseEvent) || (typeof(arg0)=="object" && arg0.preventDefault && arg0.stopPropagation))
                {
                    return arg0;
                }
            }
            func=func.caller;
        }
        return null;
    }

function ConfirmClose() {
		if(CartListNum<=0)return;
        if(window.event){
            window.event.returnValue = "你确信要关闭本页面吗？离开该商家页面,你未完成的点餐会失效.";
		}
        else{
			getEvent().returnValue = "你确信要关闭本页面吗？离开该商家页面,你未完成的点餐会失效.";
            getEvent().preventDefault();//for firefox
		}
}

function searchAddress(TURL,I){
	if(I==''){
		alert("没有输入！");
		return;
	}
	FZAjax.open(TURL.replace(ext,encodeURI(I)+ext)+new Date().getTime(),ResearchAddress);
	FZAjax.send();
}

function ResearchAddress(reAjax,status){
	 if(status == 200){
		 if(reAjax.responseText==""){
			 if(confirm('没有找到相关信息，你现在可以先随便填写一个附近的地址，过两天管理员加上后在登录上来修改！给管理员留言，说明你的地址不在范围内吗？'))window.open("/index.php?Act=Lyb&do"); 
		 }
		 else alert(reAjax.responseText);
	 }
}
function GetMsHTMLText(id,mshtmlUrl){
	//FZAjax.open(ShoworderingUrl,ReShowordering);
	FZAjax.open(mshtmlUrl,ReGetMsHTML);
	FZAjax.send("ID="+id);	
}
function ReGetMsHTML(reAjax,status){
	 if(status == 200){
	   document.getElementById('imageList').innerHTML=reAjax.responseText;
	 }
}
function isEntry2( ){ 
       if (event.keyCode == 13) { 
		var button = document.getElementById("bsubmit"); //bsubmit 为botton按钮的id 
		button.click(); 
		return false; 
		} 
     } 
function LoginWeb(){
 	var bodyHtml;
	FZmoves.setclose("关闭","关闭");
	FZmoves.setbar("用户登录");
	FZmoves.settitle("用户登录");
	FZmoves.setAlpha(60);
	bodyHtml='<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;用户名：<INPUT TYPE="text" id="UserName" NAME="login[UserName]" value=""  onkeydown="javascript:isEntry2();">&nbsp; 还没注册? <a href="/index.php?Act=Hybk&Cmd=reg&do"  style=" text-decoration:underline">注册</a><BR><BR> 密码： <input type="password" name="login[UserPassword]" id="UserPassword" onkeydown="javascript:isEntry2();" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br><br><INPUT TYPE="image" src="/images/dl.gif" id="bsubmit" onclick="javascript:WebLogin();">';
	FZmoves.show();
	FZmoves.setbody(bodyHtml);	
 
}
