var toPage=1;//当前页码
var pageSize=9;
var pageCount=0;
var weekDay=['星期天','星期一','星期二','星期三','星期四','星期五','星期六'];
var nYear=toDay.split('-')[0];
var nMonth=toDay.split('-')[1];
var nDate=toDay.split('-')[2];
var dCalDate=new Date(nYear, nMonth-1, nDate);
var thisDayInWeek=dCalDate.getDay();
var thisWeekDay=weekDay[thisDayInWeek];
var gMenuInfo=null;
function getMenuInfoList(toPage,pageSize,dataTime){
	var url='ajax.php?action=getMenuInfo&toPage='+toPage+"&pageSize="+pageSize+"&dateTime="+toDay+"&companyLevel="+userSession.companyLevel;
	var ajax=new BHPAjax();
	ajax.Request(url,{'method':'get','asyn':true,'callback':innerMenuInfoList});
}
function innerMenuInfoList(menuInfoData){
	var imgSrc="uploads/menuImg/";
	var oMenuInfoList=$('menuInfoList');
	var arrJson=menuInfoData.parseJSON();
	var menuInfoJson=arrJson.menuInfo;
	if(menuInfoJson){
		gMenuInfo=menuInfoJson;
		oMenuInfoList.innerHTML='';
		for(var i=0;i<menuInfoJson.length;i++){
			var newMenu=document.createElement('li');
			newMenu.id='menu_'+menuInfoJson[i].menuId;
			newMenu.className='container_img';
			var sHtml=	'<div class="biti">'+
							'<div style="width:165px; margin-top:8px;text-align:center" id="menuName_'+menuInfoJson[i].menuId+'">'+menuInfoJson[i].menuName+
								'(<span style="font-size=12px" id="menuPrice_'+menuInfoJson[i].menuId+'">'+menuInfoJson[i].menuPrice+'/份)</span></div>'+
							'</div>'+
							'<div class="container_img_top">'+
								'<img src="'+((menuInfoJson[i].menuPic!="")? (imgSrc+menuInfoJson[i].menuPic) : "/system/images/0001.gif")+'" width="132" height="87" style="padding-left:15px;" onmouseover="showFoodDetail(0,'+i+')" onmouseout="showFoodDetail(1,'+i+')"/>'+
							'</div>'+
							'<div class="container_img_bottom">'+
								'<div style="width:165px; text-align:center ;height:30px;margin-top:2px;">'+
									'<ul style="height:30px;width:165px;" id="foodList_'+menuInfoJson[i].menuId+'">'+
									'</ul>'+
								'</div>'+
							'</div>'+
							'<div class="botton">';
							if(userSession.userType=='company_admin'){		
								sHtml+=	'<img src="images/shoucang.gif" width="57" height="22" style="margin-left:10px; cursor:pointer;" onclick="addToFavourites('+menuInfoJson[i].menuId+')"/>';
							}
							sHtml+=	'<img src="images/xuangou.gif" width="57" height="22" style="margin-left:20px; cursor:pointer;" onclick="manageShopCar('+menuInfoJson[i].menuId+',1)" /></div>';
				sHtml+='<DIV id="foodDetail_'+menuInfoJson[i].menuId+'" style="DISPLAY: none; WIDTH: 132px; POSITION: relative; LEFT: 40px; top:-150px; BACKGROUND-COLOR: #fff">'+
							'<DIV style="BORDER-RIGHT: #e4692e 2px solid; BORDER-TOP: #e4692e 2px solid; Z-INDEX: 999; LEFT: 96px; BORDER-LEFT: #e4692e 2px solid; WIDTH: 132px; BORDER-BOTTOM: #e4692e 2px solid; POSITION: absolute; TOP: 0px; HEIGHT: 100px; BACKGROUND-COLOR: #fff">'+
								'<img src="images/img.gif" width="132" height="87" id="foodImg_'+menuInfoJson[i].menuId+'" />'+
								'<span  style="display:block;text-align:center; font-size:14px; color:#009999" id="foodName_'+menuInfoJson[i].menuId+'">菜品1</span>'+
							'</DIV>'+
                  			'<DIV style="Z-INDEX: 998; LEFT: 96px;  WIDTH: 132px; POSITION: absolute; TOP: 5px; HEIGHT: 100px; BACKGROUND-COLOR: #ccc"></DIV>'+
                  		'</DIV>';
				newMenu.innerHTML=sHtml;
			oMenuInfoList.appendChild(newMenu);
			var oFoodList=$('foodList_'+menuInfoJson[i].menuId);
			if(menuInfoJson[i].foodInfo){
				var foodInfoJson=menuInfoJson[i].foodInfo;
				for(var j=0;j<foodInfoJson.length;j++){
					var oNewFood=document.createElement('li');
					oNewFood.id='food_'+menuInfoJson[i].menuId+'_'+foodInfoJson[j].foodId;
					if(j%2==0){
						oNewFood.style.cssText='width:80px;height:15px;float:left;text-align:right; margin-left:0px';
					}else{
						oNewFood.style.cssText='width:80px;height:15px;float:left;text-align:left; margin-left:3px';
					}
					oNewFood.innerHTML=foodInfoJson[j].foodName;
					oFoodList.appendChild(oNewFood);
				}
			}else{
				oFoodList.innerHTML=menuInfoJson[i].menuSpec;
			}
		}
	}else{
		oMenuInfoList.innerHTML="<li>没有任何套餐......</li>";
	}
	innerPageCount(arrJson.pageCount);
}
var inlShowFood=0;
var foodDetailIndex=0;
var foodDetailLength=0;
var gFoodInfo=null;
function showFoodDetail(showType,menuIndex){
	var iMenuId=gMenuInfo[menuIndex].menuId;
	gFoodInfo=gMenuInfo[menuIndex].foodInfo;
	var oShowFoodDetail=$("foodDetail_"+iMenuId);
	if(showType==0 && gFoodInfo){
		foodDetailLength=gFoodInfo.length;
		var oImg=$("foodImg_"+iMenuId);
		var oFoodName=$("foodName_"+iMenuId);
		var imgSrc="uploads/foodImg/";
		oImg.src=(gFoodInfo[0].foodPic!="") ? (imgSrc+gFoodInfo[0].foodPic) : "/system/images/0001.gif";
		oFoodName.innerHTML=gFoodInfo[0].foodName;
		if(foodDetailLength>1){
			inlShowFood=window.setInterval("showFoodInfo("+iMenuId+")",2000);
		}
		oShowFoodDetail.style.display="block";
	}else if((showType==1 && gFoodInfo)){
		oShowFoodDetail.style.display="none";
		window.clearInterval(inlShowFood);
		foodDetailIndex=0;
	}
}
function showFoodInfo(menuId){
	window.clearInterval(inlShowFood);
	foodDetailIndex = (foodDetailIndex==foodDetailLength-1) ? 0 : foodDetailIndex-0+1;
	var oImg=$("foodImg_"+menuId);
	var oFoodName=$("foodName_"+menuId);
	var imgSrc="uploads/foodImg/";
	oImg.src=(gFoodInfo[foodDetailIndex].foodPic!="") ? (imgSrc+gFoodInfo[foodDetailIndex].foodPic) : "/system/images/0001.gif";
	oFoodName.innerHTML=gFoodInfo[foodDetailIndex].foodName;
	if (oImg.complete) { // 如果图片已经存在于浏览器缓存，直接调用回调函数
        inlShowFood=window.setInterval("showFoodInfo("+menuId+")",2000);
        return;// 直接返回，不用再处理onload事件
    }
    oImg.onload = function () { //图片下载完毕时异步调用callback函数。
        inlShowFood=window.setInterval("showFoodInfo("+menuId+")",2000);
    };
}
function innerPageCount(iPageCount){
	var pageList=$('pageList');
	pageList.innerHTML='';
	pageCount=iPageCount;
	for(var i=1;i<Number(pageCount)+1;i++){
		var oNewOption=document.createElement('option');
		oNewOption.innerHTML=i;
		if(i==toPage){
			oNewOption.selected=true;
		}
		oNewOption.setAttribute('value',i);
		pageList.appendChild(oNewOption);
	}
}
//分页部分代码
function goPage(num){
	goToPage=toPage+num;
	if(goToPage<1){
		goToPage=1;
	}else if(goToPage>pageCount){
		goToPage=pageCount;
	}
	if(goToPage==toPage){
		return;
	}else{
		toPage=goToPage;
		getMenuInfoList(toPage,pageSize,toDay);
	}
}
function goto(iToPage){
	toPage=iToPage;
	getMenuInfoList(toPage,pageSize,toDay);
}
function addToFavourites(menuId){
	var postData={
		'action':'ManageMenuFavourites',
		'userId':userSession.userId,
		'manageType':1,
		'menuId':menuId,
		'companyId':userSession.companyId
	};
	url='ajax.php';
	var ajax=new BHPAjax();
	ajax.Request(url,{'method':'post','sdata':postData.toJSONString(),'asyn':true,'callback':afterAddFavourites});
}
function afterAddFavourites(result){
	if(result==0){
		alert('该套餐已存在公司收藏夹中...');
	}else if(result==1){
		alert('收藏成功...');
	}
}
function manageShopCar(menuId,manageType){
	if(shopDiningType==2){
		alert('今天订餐时间已过..');
		return false;
	}
	var postData={
		'action':'ManageShopCar',
		'manageType':manageType,
		'menuId':menuId
	};
	url='ajax.php';
	var ajax=new BHPAjax();
	ajax.Request(url,{'method':'post','sdata':postData.toJSONString(),'asyn':true,'callback':afterManageShopCar});
}
function afterManageShopCar(result){
	if(result==0){
		alert('购物车中已存在改套餐...');
		return;
	}else{
		getShopCar();
	}
}
function getShopCar(){
	url='ajax.php?action=getShopCar';
	var ajax=new BHPAjax();
	ajax.Request(url,{'method':'get','asyn':true,'callback':innerShopCarList});
}
function innerShopCarList(result){
	var oShopCarList=$('shopCarList');
	if(result==0){
		oShopCarList.innerHTML=	'<li>欢迎您的光临!!</li>'+
								'<li>您订购的套餐将来到这里.</li>'+
								'<li>您可以在这里选择订几份.</li>'+
								'<li>也可以在这里修改.</li>';				
	}else{
		var shopCarJson=result.parseJSON();
		oShopCarList.innerHTML='';
		if(shopCarJson && shopCarJson.length>0){
			for(var i=0;i<shopCarJson.length;i++){
				var oNewMenu=document.createElement('li');
				oNewMenu.innerHTML='<div style="float:left;width:60px;padding-top:5px;" id="shopMenu_'+shopCarJson[i].menuId+'">'+shopCarJson[i].menuName+'</div>'+
									'<div style="float:left;margin-left:4px;"><input type="hidden"  value="'+shopCarJson[i].menuPrice+'" id="txtMenuPrice_'+shopCarJson[i].menuId+'"/><input type="text" size="1" maxlength="3"  value="'+shopCarJson[i].menuCount+'" id="txtOrderCount_'+shopCarJson[i].menuId+'" onchange="check(this);"  /></div>'+
									'<div style="float:left;margin-left:4px;padding-top:5px;">份</div>'+
									'<div style="float:left;margin-left:20px;padding-top:5px;"><img src="images/del.gif" style="cursor:pointer;"  width="16" height="16" border="0" onclick="manageShopCar('+shopCarJson[i].menuId+',2)" /></div>';
				oNewMenu.id='shopCar_'+shopCarJson[i].menuId;
				oShopCarList.appendChild(oNewMenu);
			}
		}
	}
	updateCountInfo();
}
function updateCountInfo(){
	var shopCarList=$('shopCarList').getElementsByTagName('li');
	var totalAmount=0;
	var totalOrders=0; 
	if(shopCarList){
		for(var i=0;i<shopCarList.length;i++){
			if(shopCarList[i].id){
				menuId=shopCarList[i].id.split('_')[1];
				totalOrders+=Number($('txtOrderCount_'+menuId).value);
				totalAmount+=Number($('txtOrderCount_'+menuId).value)*(Number($('txtMenuPrice_'+menuId).value));
			}else{
				break;
			}
		}
	}
	$('totalOrders').innerHTML=totalOrders;
	$('totalAmount').innerHTML=totalAmount;
} 
function check(obj){
	var menuId=obj.id.split("_")[1];
	if(!(/^\d+$/.test(obj.value)) || (obj.value-0)<=0){
		obj.value=1;
	}
	updateCountInfo();
	updateMenuNum(menuId,4,obj.value);
}
function updateMenuNum(menuId,manageType,menuNum){
	var postData={
		'action':'ManageShopCar',
		'manageType':manageType,
		'menuId':menuId,
		'menuNum':menuNum
	};
	url='ajax.php';
	var ajax=new BHPAjax();
	ajax.Request(url,{'method':'post','sdata':postData.toJSONString(),'asyn':true,'callback':afterUpdateMenuNum});
}
function afterUpdateMenuNum(result){
	return;
}
/***弹出窗口代码开始***/
var smW;
function shW(sWidth,sHeight,sHTML){
    smW=new sW(sWidth,sHeight,sHTML,1,"#333","#fff");
    smW.bgn="bgDiv";
    smW.cn="cnDiv";
    smW.crDiv();
}
function closeW(){
    smW.clDiv();
    window.location.reload();
}
function gBS(){
    BSW=document.body.clientWidth;
    BSH=document.body.clientHeight;
    BSHs=document.body.scrollHeight;
    BSHt=getScrollTop();
}
function getScrollTop(){
	var scrollPos;
	if (typeof window.pageYOffset != 'undefined') { 
		scrollPos = window.pageYOffset; 
	} else if (typeof document.compatMode != 'undefined' && 
		document.compatMode != 'BackCompat') { 
		scrollPos = document.documentElement.scrollTop; 
	} else if (typeof document.body != 'undefined') { 
		scrollPos = document.body.scrollTop; 
	} 
	return scrollPos;
}
function sW(width,height,html,isshadow,wbg,wnbg){
    this.winW=width;        //窗口宽度
    this.winH=height;        //窗口高度
    this.winHtml=html;        //窗口内容
    this.winS=isshadow;        //是否有遮罩层
    this.winBg=wbg;      //遮罩层背景
    this.winBn=wnbg;      //内容层背景
    this.bgn=null;            //遮罩层ID
	this.bgObj=null;
    this.cn=null;            //内容层ID
	this.cnObj=null;
    this.clDiv=function clDiv(){ //关闭窗口方法
		//showSelect();//显示所有下拉框 
        if(this.winS==1){
            $(this.bgn).style.display="none"; //隐藏遮罩
        }
        $(this.cn).style.display="none";//隐藏窗口
    };
    this.crDiv=function crDiv(){
		gBS();
        var doc=document;
        var docB=doc.body;
        if( $(this.cn)){
            if(this.winS==1){
                $(this.bgn).style.display="block";
            }
       		var objLeft = parseInt(docB.scrollLeft+(BSW - this.winW)/2)+"px"; //
			var objTop = parseInt(BSHt)+parseInt(this.winW/2)+"px";
    		$(this.cn).style.left=objLeft;
    		$(this.cn).style.top=objTop;
            $(this.cn).style.display="block";
            return;
        }
        if(this.winS==1){
            var gD=doc.createElement("div");
            gD.setAttribute("id",this.bgn);
            gD.style.zIndex="98";
            gD.style.top = "0";
            gD.style.left = "0";
            gD.style.width = BSW+"px";
            gD.style.height = BSHs+"px";
            gD.style.position = "absolute";
            gD.style.background = this.winBg;
            gD.style.filter="alpha(opacity=60)";
            gD.style.opacity="0.4";
            docB.appendChild(gD); 
        }
       	var objLeft = parseInt(docB.scrollLeft+(BSW - this.winW)/2)+"px";
		var objTop = parseInt(BSHt)+parseInt(this.winW/2)+"px";
        var nD=doc.createElement("div");
        nD.setAttribute("id",this.cn);
        nD.style.top = objTop;
        nD.style.left = objLeft;
        nD.style.position = "absolute";
        nD.style.width= this.winW+"px";
        nD.style.height= this.winH+"px";
        //nD.style.height="100%";
        nD.style.zIndex="99";
        nD.style.background = this.winBn;
        nD.innerHTML =this.winHtml;
        docB.appendChild(nD);
		this.cnObj=nD;
    };
}
/***弹出窗口代码结束***/
var orderSubmitType=0;
function orderSubmit(){
	if($('totalOrders').innerHTML=='0'){
		alert('你没有选择任何套餐...');
		return;
	}
	if(userSession.userId==0){
		openLogionWin();
	}else{
		if(userSession.userState==4){
			alert('系统故障，请直接与客服电话联系！');
			return false;
		}else if(userSession.userState==2){
			if(userSession.userType=="waiting_user"){
				alert('审核中，请等待或直接和客服联系！');
				return false;
			}else{
				if(shopSheduleId==0){
					if(userSession.companyId==0){
						orderSubmitType=0;
						//alert("newCompany");
						openOrderDetail(0);//新建单位订餐
					}else {
						if(userSession.userType=='common_employee'){
							orderSubmitType=1;
							openOrderDetail(1);//普通员工内部订餐
						}else{
							if(shopDepartmentId!=0){
								openChooseOrderType();//选择类型
							}else{
								if(userSession.userType=='department_admin'){
									orderSubmitType=2;
									openOrderDetail(2);//部门管理员订餐
								}else if(userSession.userType=='company_admin'){
									orderSubmitType=3;
									openOrderDetail(3);//单位管理员订餐
								}
							}
						}
					}
				}else{
					if(userSession.userType=='department_admin'){
						orderSubmitType=2;
						openOrderDetail(2);//部门管理员订餐
					}else if(userSession.userType=='company_admin'){
						orderSubmitType=3;
						openOrderDetail(3);//单位管理员订餐
					}
				}
			}
		}
	}
}
function openLogionWin(){
	var loginString=	'<div class="pop_center" style="width:212px; height:150px">'+
							'<div class="pop_center_middle" style="width:212px; height:126px">'+
								'<div class="pop_biankuang_bg" style="width:212px;" >'+
									'<div class="close" onclick="closeW()"></div>'+
									'<span>您尚未登陆,请登陆!</span>'+
								'</div>'+
								'<img src="images/login_top.gif" width="212" height="69" />'+
								'<div class="pop_biankuang" style="width:212px; padding-top:0px; margin-top:0px">'+
									'<table width="100%" border="0" cellspacing="0" cellpadding="0">'+
										'<tr>'+
											'<td align="center">'+
												'<form action="./panel/noRandom.index.php" method="post">'+
												'<div class="pop_login">'+
													'<ul>'+
														'<li>用户名<input name="userName" type="text" class="pop_login_k_01" size="8" />'+
														'<input name="Input2" type="image" class="pop_button" src="images/pop_login.gif" /></li>'+
														'<li>密&nbsp;&nbsp;码<input name="userPwd" type="password" class="pop_login_k_01" size="8" />'+
															'<img onclick="window.location=\'./panel/register.php\'" class="pop_button" style="cursor:pointer;" border="0" src="images/pop_register.gif" />'+
															'<input name="c" value="fCustomerLogin" type="hidden"  />'+
	   														'<input name="action" value="noRandom"  type="hidden" />'+
	   														'<input type="hidden" name="refer" value="index" />'+
														'</li>'+
													'</ul>'+
												'</div>'+
												'</form>'+
											'</td>'+
										'</tr>'+
									'</table>'+
								'</div>'+
							'</div>'+
						'</div>';
	if($('cnDiv')){
		$('cnDiv').style.width="212px";
		$('cnDiv').style.height="150px";
		$('cnDiv').innerHTML=loginString;
		shW(212,150,'');
	}else{
		shW(212,150,loginString);
	}
		
}
function openChooseOrderType(){
	var chooseOrderTypeString=	'<div class="pop_center" style="height:100px; background-color:#FFFFFF">'+	
									'<div class="pop_center_middle" style="height:100px">'+
										'<div class="pop_biankuang_bg"><div class="close" onclick="closeW()"></div><span>订餐类型</span></div>'+
										'<div class="pop_biankuang">'+
											'<table width="100%" height="44" border="0" cellpadding="0" cellspacing="0">'+
												'<tr>'+
													'<td width="8%" align="center">&nbsp;</td>'+
													'<td width="50%" align="left"><input type="radio" name="orderType" id="insideOrder" value="0" checked="true" />单位个人订餐</td>'+
													'<td width="42%" rowspan="2" align="center" >'+
														'<div style="background-color:#80CEDB; width:60px;height:21px; margin-top:6px;border:1px solid #8E7CB3;cursor:pointer;" onclick="chooseSumbit();">确认选择</div>'+
													'</td>'+
												'</tr>'+
												'<tr>'+
													'<td align="center">&nbsp;</td>'+
													'<td width="23%" align="left">'+
														'<input type="radio" name="orderType" id="partOrder" value="1"/>单位部门订餐'+
													'</td>'+
												'</tr>'+
											'</table>'+
											'<table width="100%" border="0" cellspacing="0" cellpadding="0">'+
												'<tr>'+
													'<td align="center">&nbsp;</td>'+
												'</tr>'+
											'</table>'+
										'</div>'+
									'</div>'+
								'</div>';
	if($('cnDiv')){
		$('cnDiv').innerHTML=chooseOrderTypeString;
		$('cnDiv').style.width="210px";
		$('cnDiv').style.height="100px";
		shW(210,100,'');
	}else{
		shW(210,100,chooseOrderTypeString);
	}
}
function chooseSumbit(){
	if($('insideOrder').checked){
		orderSubmitType=1;
		//openOrderDetail(1);
	}else if($('partOrder').checked){
		if(userSession.userType=='department_admin'){
			orderSubmitType=2;
			//openOrderDetail(2);//部门管理员订餐
		}else if(userSession.userType=='company_admin'){
			orderSubmitType=3;
			//openOrderDetail(3);//单位管理员订餐
		}
	}
	openOrderDetail(orderSubmitType);
}

//注册会员订餐html
function getNewCompanyOrderString(){
	var newCompanyOrderString='<table width="100%" height="100%" border="0" cellspacing="0" cellpadding="0">'+
									'<tr>'+
										'<td width="60" align="right">接受人:</td>'+
										'<td><input name="orderAccepter" id="orderAccepter" type="text" value="'+userSession.userName+'" size="15" /></td>'+
									'</tr>'+
									'<tr>'+
										'<td align="right">单位名称: </td>'+
										'<td><input name="companyName" id="companyName" type="text" size="15" /></td>'+
									'</tr>'+
									'<tr>'+
										'<td align="right">用餐时间:</td>'+
										'<td><span id="departmentDiningType">中餐</span> <select name="hour" id="hour">';
	if(shopDiningType==0){									
			newCompanyOrderString+=				'<option value="11">11</option>'+
												'<option value="12">12</option>';
	}else{	
			newCompanyOrderString+=				'<option value="17">17</option>'+
												'<option value="18">18</option>';
	}
			newCompanyOrderString+=			'</select> : '+
											'<select name="time" id="time">'+
												'<option value="00">00</option>'+
												'<option value="15">15</option>'+
												'<option value="30">30</option>'+
												'<option value="45">45</option>'+
											'</select>'+
										'</td>'+
									'</tr>'+
									'<tr>'+
										'<td align="right">配送地址:</td>'+
										'<td><input name="accepterAddress" id="accepterAddress" type="text" value="'+userSession.companyAddress+'" size="20" /></td>'+
									'</tr>'+
									'<tr>'+
										'<td align="right">要求备注:</td>'+
										'<td><input name="orderComment" id="orderComment" type="text" value="" size="20" /><span style="font-size:12px"> 限制20个字符</span></td>'+
									'</tr>'+
									'<tr>'+
										'<td align="right">支付方式:</td>'+
										'<td><input type="radio" name="radiobutton" id="netPay" value="1" checked="true"/>网支'+
										'</td>'+
									'</tr>'+
								'</table>';
	return newCompanyOrderString;
}
//单位内部员工html代码
function getInsideOrderString(){
	var insideOrderString='<table width="100%" border="0" cellspacing="0" cellpadding="0" id="orderUserInfo">'+
								'<tr>'+
									'<td width="60" align="right">接受人:</td>'+
									'<td>'+userSession.userName+'</td>'+
								'</tr>'+
								'<tr>'+
									'<td ><p>&nbsp;单位名称: </td>'+
									'<td>'+userSession.companyName+' | '+userSession.departmentName+'</td>'+
								'</tr>'+
								'<tr>'+
									'<td>&nbsp;用餐时间:</td>'+
									'<td>'+((shopDiningType==0)? '中餐' : '晚餐')+'</td>'+
								'</tr>'+
								'<tr>'+
									'<td>&nbsp;要求备注:</td>'+
									'<td>'+
										'<input class="inputcolor" name="orderComment" id="orderComment" type="text" value="" size="20" />'+
										'<span style="font-size:11px"> 限制20个字符</span>'+
									'</td>'+
								'</tr>'+ 
							'</table>';
	return insideOrderString;	
}


//部门订餐html代码
function getDepartmentOrderString(){
	var departmentOrderString='<table width="100%" border="0" cellspacing="0" cellpadding="0">'+
									'<tr>'+
										'<td width="60" align="right">接受人:</td>'+
										'<td>'+userSession.userName+'</td>'+
									'</tr>'+
									'<tr>'+
										'<td align="right">单位名称: </td>'+
										'<td>'+userSession.companyName+'</td>'+
									'</tr>'+
									'<tr>'+
										'<td align="right">用餐时间:</td>'+
										'<td><span id="departmentDiningType">中餐</span><span id="orderDiningTime">'+((shopDiningType==0) ? userSession.companyLunchTime : userSession.companySupperTime)+'</span>'+
										'</td>'+
									'</tr>'+
									'<tr>'+
										'<td align="right">配送地址:</td>'+
										'<td>'+userSession.companyAddress+'</td>'+
									'</tr>'+
									'<tr>'+
										'<td align="right">要求备注:</td>'+
										'<td><input name="orderComment" id="orderComment" type="text" value="" size="20" /><span style="font-size:12px"> 限制20个字符</span></td>'+
									'</tr>'+
									'<tr>'+
										'<td align="right">支付方式:</td>'+
										'<td>';
										
					if(userSession.companyBillType>0){
						departmentOrderString+='<input type="radio" name="radiobutton" id="netPay" value="1" '+((userSession.companyBillType==1) ? "checked" : "")+'/>网支';
						if(userSession.companyBillType>1){
							departmentOrderString+='<input type="radio" name="radiobutton" id="cashPay" value="2" '+((userSession.companyBillType==2) ? "checked" : "")+'/>现金';
							if(userSession.companyBillType>2){
								departmentOrderString+='<input type="radio" name="radiobutton" id="signedPay" value="3" '+((userSession.companyBillType==3) ? "checked" : "")+'/>签单';
							}
						}
					}
					
				departmentOrderString+=	'</td>'+
									'</tr>'+
								'</table>';
				return departmentOrderString;
}

//单位订餐html代码
function getCompanyOrderString(){
	var companyOrderString='<table width="100%" border="0" cellspacing="0" cellpadding="0">'+
									'<tr>'+
										'<td width="60" align="right">接受人:</td>'+
										'<td><input name="orderAccepter" id="orderAccepter" type="text" value="'+userSession.userName+'" size="15" /></td>'+
									'</tr>'+
									'<tr>'+
										'<td align="right">单位名称: </td>'+
										'<td>'+userSession.companyName+'</td>'+
									'</tr>'+
									'<tr>'+
										'<td align="right">部门: </td>'+
										'<td><select id="selectDepartment"><option value="0">未指定</option></select></td>'+
									'</tr>'+
									'<tr>'+
										'<td align="right">用餐时间:</td>'+
										'<td><span id="departmentDiningType">中餐</span> <select name="hour" id="hour">';
	if(shopDiningType==0){
		var orderDiningTime=userSession.companyLunchTime;
	}else{
		var orderDiningTime=userSession.companySupperTime;
	}
	var sH=orderDiningTime.split(":")[0];
	var sM=orderDiningTime.split(":")[1];
	if(shopDiningType==0){
			companyOrderString+=				'<option value="11" '+((sH==11) ? "selected" :"")+'>11</option>'+
												'<option value="12" '+((sH==12) ? "selected" :"")+'>12</option>';
	}else{	
			companyOrderString+=				'<option value="17" '+((sH==17) ? "selected" :"")+'>17</option>'+
												'<option value="18" '+((sH==18) ? "selected" :"")+'>18</option>';
	}
			companyOrderString+=			'</select> : '+
											'<select name="time" id="time">'+
												'<option value="00" '+((sM=='00') ? "selected" :"")+'>00</option>'+
												'<option value="15" '+((sM=='15') ? "selected" :"")+'>15</option>'+
												'<option value="30" '+((sM=='30') ? "selected" :"")+'>30</option>'+
												'<option value="45" '+((sM=='45') ? "selected" :"")+'>45</option>'+
											'</select>'+
										'</td>'+
									'</tr>'+
									'<tr>'+
										'<td align="right">配送地址:</td>'+
										'<td><input name="accepterAddress" id="accepterAddress" type="text" value="'+userSession.companyAddress+'" size="20" /></td>'+
									'</tr>'+
									'<tr>'+
										'<td align="right">要求备注:</td>'+
										'<td><input name="orderComment" id="orderComment" type="text" value="" size="20" /><span style="font-size:12px"> 限制20个字符</span></td>'+
									'</tr>'+
									'<tr>'+
										'<td align="right">支付方式:</td>'+
										'<td>';
					if(userSession.companyBillType>0){
						companyOrderString+='<input type="radio" name="radiobutton" id="netPay" value="1" '+((userSession.companyBillType==1) ? "checked" : "")+'/>网支';
						if(userSession.companyBillType>1){
							companyOrderString+='<input type="radio" name="radiobutton" id="cashPay" value="2" '+((userSession.companyBillType==2) ? "checked" : "")+'/>现金';
							if(userSession.companyBillType>2){
								companyOrderString+='<input type="radio" name="radiobutton" id="signedPay" value="3" '+((userSession.companyBillType==3) ? "checked" : "")+'/>签单';
							}
						}
					}
				companyOrderString+=	'</td>'+
									'</tr>'+
								'</table>';
			return companyOrderString;
}
function getDepartmentInfo(){
	var url='ajax.php?action=getDepartment&companyId='+userSession.companyId;
	var ajax=new BHPAjax();
	ajax.Request(url,{'method':'get','asyn':true,'callback':afterGetDepartmentInfo});
}
function afterGetDepartmentInfo(result){
	if(result){
		var departmentJson=result.parseJSON();
		if(departmentJson){
			$("selectDepartment").innerHTML="";
			var newOption=document.createElement("option");
			newOption.value=0;
			newOption.innerHTML="未指定";
			$("selectDepartment").appendChild(newOption);
			for(var i=0,j=departmentJson.length;i<j;i++){
				var newOption=document.createElement("option");
				newOption.value=departmentJson[i].departmentId;
				newOption.innerHTML=departmentJson[i].departmentName;
				if(shopDepartmentId==departmentJson[i].departmentId){
					newOption.selected=true;
				}
				$("selectDepartment").appendChild(newOption);
			}
		}
	}
}
function openOrderDetail(typeId){
	//alert(typeId);
	var orderHtmlString="";
	switch(typeId-0){
		case 0:
			orderHtmlString=getNewCompanyOrderString();
			break;
		case 1:
			orderHtmlString=getInsideOrderString();
			break;
		case 2:
			orderHtmlString=getDepartmentOrderString();
			break;
		case 3:
			orderHtmlString=getCompanyOrderString();
			break;
		default:
			break;
	}
	var innerString='<div  class="pop_center" style="width:300px; height:393px">'+	
						'<div class="pop_center_middle" style="width:300px;">'+
							'<div class="pop_biankuang_bg"><div class="close" onclick="closeW()"></div><span>'+((typeId==1) ? '单位个人订餐' : '单位部门订餐')+'</span></div>'+
							'<div class="pop_biankuang" style="width:300px;">';
	innerString+=orderHtmlString;
	innerString+='<table width="100%" height="100%" border="0" cellspacing="0" cellpadding="0">'+
					'<tr bgcolor="#9BA0C0">'+
						'<td width="44%" align="center" style="border-right:solid; border-right-color:#A4BACB; border-right-width:1px">&nbsp;套餐类型</td>'+
						'<td width="23%" align="center" style="border-right:solid; border-right-color:#A4BACB; border-right-width:1px">数量</td>'+
						'<td width="33%" align="center" >金额</td>'+
					'</tr>'+
				'</table>'+
				'<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0" id="orderMenuList"></table>'+
				'<table width="100%" border="0" cellspacing="0" cellpadding="0" id="orderTotal">'+
					'<tr bgcolor="#28C9C3">'+
						'<td width="44%" align="center">&nbsp;合计</td>'+
						'<td width="23%" align="center">4份</td>'+
						'<td width="33%" align="center" >28元</td>'+
					'</tr>'+
				'</table>'+
				'<table width="100%" border="0" cellspacing="0" cellpadding="0">'+
					'<tr>'+
						'<td align="center"><div style="background-color:#FBCC62; width:104px;height:21px; margin-top:12px;border:1px solid #DAC88A;cursor:pointer;" id="sendOrder">确认下单</div></td>'+
					'</tr>'+
				'</table>'+
			'</div>'+
		'</div>'+
	'</div>';
	if($('cnDiv')){
		shW(300,100,innerString);
		$('cnDiv').innerHTML=innerString;
		$('cnDiv').style.width="300px";
		$('cnDiv').style.height="100px";
	}else{
		shW(300,100,innerString);
	}
	switch(typeId-0){
		case 0:
			$('sendOrder').onclick=function(){sendNewCompanyOrder()};
			$('departmentDiningType').innerHTML=((shopDiningType==0) ? '中餐' : '晚餐');
			break;
		case 1:
			$('sendOrder').onclick=function(){sendInsideOrder()};
			break;
		case 2:
			$('sendOrder').onclick=function(){sendDepartmentOrder()};
			$('departmentDiningType').innerHTML=((shopDiningType==0) ? '中餐' : '晚餐');
			break;
		case 3:
			$('sendOrder').onclick=function(){sendCompanyOrder()};
			$('departmentDiningType').innerHTML=((shopDiningType==0) ? '中餐' : '晚餐');
			getDepartmentInfo();
			break;
		default:
			$('sendOrder').onclick=function(){return false};
			break;
	}
	/*
	if(typeId==0){
		$('sendOrder').onclick=function(){sendInsideOrder()};
	}else if(typeId==1){
		$('sendOrder').onclick=function(){sendDepartmentOrder()};
		$('departmentDiningType').innerHTML=((shopDiningType==0) ? '中餐' : '晚餐');
	}*/
	var oOrderMenuList=$('orderMenuList');
	var oShopCarList=$('shopCarList');
	for(var i=0;i<oShopCarList.childNodes.length;i++){
		var shopCarId=(oShopCarList.childNodes[i].id).split('_')[1];
		var oNewRow=oOrderMenuList.insertRow();
		var oNewCell1=oNewRow.insertCell();
		oNewRow.id="insideOrder_"+shopCarId;
		oNewCell1.innerHTML=$('shopMenu_'+shopCarId).innerHTML+"("+$('txtMenuPrice_'+shopCarId).value+"元/份)";
		oNewCell1.setAttribute('width',"44%");
		oNewCell1.setAttribute('align',"center");
		var oNewCell2=oNewRow.insertCell();
		oNewCell2.innerHTML=$('txtOrderCount_'+shopCarId).value+"份";
		oNewCell2.setAttribute('width',"23%");
		oNewCell2.setAttribute('align',"center");
		var oNewCell3=oNewRow.insertCell();
		oNewCell3.innerHTML=Number($('txtMenuPrice_'+shopCarId).value)*Number($('txtOrderCount_'+shopCarId).value)+"元";
		oNewCell3.setAttribute('width',"33%");
		oNewCell3.setAttribute('align',"center");
		$('orderTotal').rows[0].cells[1].innerHTML=$('totalOrders').innerHTML+"份";
		$('orderTotal').rows[0].cells[2].innerHTML=$('totalAmount').innerHTML+"元";
	}
}
function cancelSendButton(){
	$('sendOrder').onclick=function(){return false;};
}
function bindSendButton(){
	switch(orderSubmitType-0){
		case 0:
			$('sendOrder').onclick=function(){sendNewCompanyOrder()};
			break;
		case 1:
			$('sendOrder').onclick=function(){sendInsideOrder()};
			break;
		case 2:
			$('sendOrder').onclick=function(){sendDepartmentOrder()};
			break;
		case 3:
			$('sendOrder').onclick=function(){sendCompanyOrder()};
			break;
		default:
			$('sendOrder').onclick=function(){return false};
			break;
	}
}


//注册会员订餐
function sendNewCompanyOrder(){
	cancelSendButton();
	var orderMenu=[];
	var oOrderMenuList=$('orderMenuList');
	for(var i=0;i<oOrderMenuList.rows.length;i++){
		var menuId=(oOrderMenuList.rows[i].id).split('_')[1];
		var menuCount=$('txtOrderCount_'+menuId).value;
		var sOrderMenu='{"menuId":'+menuId+',"menuCount":'+menuCount+'}';
		orderMenu.push(sOrderMenu);
	}
	var totalOrders=$('totalOrders').innerHTML;
	var totalAmount=$('totalAmount').innerHTML;
	var orderAccepter=$('orderAccepter').value;
	if(orderAccepter.trim()==""){
		alert("请填写接受人...");
		bindSendButton();
		return false;
	}
	var companyName=$('companyName').value;
	if(companyName.trim()==""){
		alert("请填写公司名称...");
		bindSendButton();
		return false;
	}
	var accepterAddress=$("accepterAddress").value;
	if(accepterAddress.trim()==""){
		alert("请填写配送地址...");
		bindSendButton();
		return false;
	}
	var orderDiningTime=$("hour").options[$("hour").selectedIndex].value+":"+$("time").options[$("time").selectedIndex].value;
	var createTime=toDay;
	var orderComment=$('orderComment').value;
	var billType=1;
	var postData={
		'action':'addNewCompanyOrder',
		'orderMenu':orderMenu,
		'userId':userSession.userId,
		'userTel':userSession.userTel,
		'companyName':companyName,
		'orderAccepter':orderAccepter,
		'accepterAddress':accepterAddress,
		'orderComment':orderComment,
		'diningType':shopDiningType,
		'orderDiningTime':orderDiningTime,
		'billType':billType,
		'createTime':toDay,
		'orderMenuCount':totalOrders,
		'orderAmountCount':totalAmount
	};
	var url='ajax.php';
	var ajax=new BHPAjax();
	ajax.Request(url,{'method':'post','sdata':postData.toJSONString(),'asyn':true,'callback':afterSendOrder});
}
//普通员工订餐
function sendInsideOrder(){
	cancelSendButton();
	var orderMenu=[];
	var oOrderMenuList=$('orderMenuList');
	for(var i=0;i<oOrderMenuList.rows.length;i++){
		var menuId=(oOrderMenuList.rows[i].id).split('_')[1];
		var menuCount=$('txtOrderCount_'+menuId).value;
		var sOrderMenu='{"menuId":'+menuId+',"menuCount":'+menuCount+'}';
		orderMenu.push(sOrderMenu);
	}
	var createTime=toDay;
	var orderComment=$('orderComment').value;
	var postData={
		'action':'ManageShedule',
		'orderMenu':orderMenu,
		'userId':userSession.userId,
		'companyId':userSession.companyId,
		'departmentId':userSession.departmentId,
		'orderComment':orderComment,
		'diningType':shopDiningType,
		'createTime':toDay
	};
	var url='ajax.php';
	var ajax=new BHPAjax();
	ajax.Request(url,{'method':'post','sdata':postData.toJSONString(),'asyn':true,'callback':afterSendOrder});
}
//部门订餐
function sendDepartmentOrder(){
	cancelSendButton();
	var orderMenu=[];
	var oOrderMenuList=$('orderMenuList');
	for(var i=0;i<oOrderMenuList.rows.length;i++){
		var menuId=(oOrderMenuList.rows[i].id).split('_')[1];
		var menuCount=$('txtOrderCount_'+menuId).value;
		var sOrderMenu='{"menuId":'+menuId+',"menuCount":'+menuCount+'}';
		orderMenu.push(sOrderMenu);
	}
	var billType=1;
	if($('netPay')){
		if($('netPay').checked){billType=1};
	}
	if($('cashPay')){
		if($('cashPay').checked){billType=2};
	}
	if($('signedPay')){
		if($('signedPay').checked){billType=3};
	}
	var companyId=userSession.companyId;//单位ID
	var userId=userSession.userId;//用户ID
	//var companyOrderAdmin=userSession.userId;
	var orderDiningType=shopDiningType;//餐别
	var orderDepartmentId=shopDepartmentId;//部门ID
	var orderAccepterAddress=userSession.companyAddress;//接受地址
	var orderDiningDate=toDay;//用餐日期
	var orderMenuCount=$('totalOrders').innerHTML;//订单总套餐数
	var orderAmountCount=$('totalAmount').innerHTML;//订单总金额
	var orderAccepter=userSession.userName;//订单接受人
	var orderComment=$('orderComment').value.trim();//订单备注
	var orderDiningTime=$("orderDiningTime").innerHTML;//用餐时间
	var postData={
		'action':'ManageOrder',
		'userId':userId,
		'manageType':1,
		'orderId':0,
		'billType':billType,
		'companyId':companyId,
		'orderDiningType':orderDiningType,
		'orderDepartmentId':orderDepartmentId,
		'orderAccepterAddress':orderAccepterAddress,
		'orderAccepter':orderAccepter,
		'orderDiningDate':orderDiningDate,
		'orderMenu':orderMenu,
		'orderMenuCount':orderMenuCount,
		'orderAmountCount':orderAmountCount,
		'orderComment':orderComment,
		'orderDiningTime':orderDiningTime,
		'orderStatus':1,
		'sheduleId':shopSheduleId
	};
	var ajax=new BHPAjax();
	var url='ajax.php';
	ajax.Request(url,{'method':'post','sdata':postData.toJSONString(),'asyn':true,'callback':afterSendOrder});
}
//单位订餐
function sendCompanyOrder(){
	cancelSendButton();
	var orderMenu=[];
	var oOrderMenuList=$('orderMenuList');
	for(var i=0;i<oOrderMenuList.rows.length;i++){
		var menuId=(oOrderMenuList.rows[i].id).split('_')[1];
		var menuCount=$('txtOrderCount_'+menuId).value;
		var sOrderMenu='{"menuId":'+menuId+',"menuCount":'+menuCount+'}';
		orderMenu.push(sOrderMenu);
	}
	var billType=1;
	if($('netPay')){
		if($('netPay').checked){billType=1};
	}
	if($('cashPay')){
		if($('cashPay').checked){billType=2};
	}
	if($('signedPay')){
		if($('signedPay').checked){billType=3};
	}
	var companyId=userSession.companyId;
	var companyOrderAdmin=userSession.userId;
	var orderDiningType=shopDiningType;
	var orderDepartmentId=shopDepartmentId;
	var orderAccepter=$('orderAccepter').value.trim();
	if(orderAccepter==""){
		alert("请填写接受人...");
		bindSendButton();
		return false;
	}
	var orderAccepterAddress=$("accepterAddress").value.trim();
	if(orderAccepterAddress==""){
		alert("请填写配送地址...");
		bindSendButton();
		return false;
	}
	var orderDiningDate=toDay;
	var orderMenuCount=$('totalOrders').innerHTML;
	var orderAmountCount=$('totalAmount').innerHTML;
	var orderComment=$('orderComment').value.trim();
	var orderDiningTime=$("hour").options[$("hour").selectedIndex].value+":"+$("time").options[$("time").selectedIndex].value;
	var postData={
		'action':'ManageOrder',
		'userId':userSession.userId,
		'manageType':1,
		'orderId':0,
		'billType':billType,
		'companyId':companyId,
		'companyOrderAdmin':companyOrderAdmin,
		'orderDiningType':orderDiningType,
		'orderDepartmentId':$("selectDepartment").options[$("selectDepartment").selectedIndex].value,
		'orderAccepterAddress':orderAccepterAddress,
		'orderAccepter':orderAccepter,
		'orderDiningDate':orderDiningDate,
		'orderMenu':orderMenu,
		'orderMenuCount':orderMenuCount,
		'orderAmountCount':orderAmountCount,
		'orderComment':orderComment,
		'orderDiningTime':orderDiningTime,
		'orderStatus':3,
		'sheduleId':shopSheduleId
	};
	var ajax=new BHPAjax();
	var url='ajax.php';
	ajax.Request(url,{'method':'post','sdata':postData.toJSONString(),'asyn':true,'callback':afterSendOrder});
}
function afterSendOrder(result){
	if(result==1){
		clearSession();
		var messageString=	'<div class="pop_center" style="height:100px; background-color:#FFFFFF">'+	
								'<div class="pop_center_middle" style="height:100px">'+
									'<div class="pop_biankuang_bg"><div class="close" onclick="closeW()"></div><span>提示</span></div>'+
									'<div class="pop_biankuang">'+
										'<table width="100%" height="44" border="0" cellpadding="0" cellspacing="0">'+
											'<tr>'+
												'<td width="8%" align="center">&nbsp;</td>'+
												'<td align="left">您的订单已成功递交,请耐心等待,</td>'+
											'</tr>'+
											'<tr>'+
												'<td align="center">&nbsp;</td>'+
												'<td align="left">如有变动,请与管理员联系!</td>'+
											'</tr>'+
										'</table>'+
										'<table width="100%" border="0" cellspacing="0" cellpadding="0">'+
											'<tr>'+
												'<td align="center"><div style="background-color:#80CEDB; width:60px;height:21px; margin-top:2px;border:1px solid #8E7CB3;cursor:pointer;" onclick="closeW()">确认选择</div></td>'+
											'</tr>'+
										'</table>'+
									'</div>'+
								'</div>'+
							'</div>';
		$('cnDiv').style.width="100px";
		$('cnDiv').innerHTML=messageString;
	}else if(result==2008){
		alert('帐户余额不足,请先充值...');
		bindSendButton();
		return false;
	}else if(result==2007){
		alert('单位名称已经存在,请与管理员联系...');
		bindSendButton();
		return false;
	}else if(result==2006){
		alert('该时段您已经订餐,请与管理员联系...');
		bindSendButton();
		return false;
	}else if(result==2009){
		alert('该时段部门订餐已经提交,请与管理员联系...');
		bindSendButton();
		return false;
	}else{
		alert(result);
		bindSendButton();
		return false;
	}
}
function clearSession(){
	var postData={
		'action':'ManageShopCar',
		'manageType':3,
		'menuId':0
	};
	url='ajax.php';
	var ajax=new BHPAjax();
	ajax.Request(url,{'method':'post','sdata':postData.toJSONString(),'asyn':true,'callback':aftercClearSession});
}
function aftercClearSession(result){
	if(result==0){
		innerShopCarList(result);
		shopSheduleId=0;
		shopDepartmentId=userSession.companyId;
		shopDiningType=userSession.diningType;
	}else{
		clearSession();
	}
}
function starCaTran(year,month,date){
	var sMonth,sDate;
	with(new Date(year,month-1,date)){
		if(getMonth()+1<10){
			sMonth="0"+Number(getMonth()+1);
		}else{
			sMonth=Number(getMonth())+1;
		}
		if(getDate()<10){
			sDate="0"+getDate();
		}else{
			sDate=getDate();
		}
		return getFullYear() + "-" +sMonth + "-" + sDate;
	}
}
function getHotMenu(){
	var dCalDate=new Date(nYear, nMonth-1, nDate);
	var thisDayInWeek=dCalDate.getDay();	//选中的天是星期几
	if(thisDayInWeek==0){
		var prevWeekFirstDate=nDate-thisDayInWeek-14;
	}else{
		var prevWeekFirstDate=nDate-thisDayInWeek-7;
	}
	var prevWeekFirstDateTime=starCaTran(nYear,nMonth,prevWeekFirstDate-0+1);
	var prevWeekLastDateTime=starCaTran(nYear,nMonth,prevWeekFirstDate-0+7);
	url='ajax.php?action=getHotMenu&fDateTime='+prevWeekFirstDateTime+'&lDateTime='+prevWeekLastDateTime;
	var ajax=new BHPAjax();
	ajax.Request(url,{'method':'get','asyn':true,'callback':afterGetHotMenu});
}
function afterGetHotMenu(result){
	var oHotMenuDiv=$('hotMenuList');
	oHotMenuDiv.innerHTML="";
	var hotMenuJson=result.parseJSON();
	if(hotMenuJson){
		for(var i=0;i<hotMenuJson.length;i++){
			var newHotMenu=document.createElement('li');
			newHotMenu.id="hotMenu_"+i;
			var sHtml='<div style="float:left">'+(i-0+1)+'.</div>';
			sHtml+='<div style="float:left;margin-left:30px;width:120px;" title="'+hotMenuJson[i].menuPrice+'元/份';
			sHtml+='&#13;'+hotMenuJson[i].menuSpec;
			sHtml+='">'+hotMenuJson[i].menuName+'</div>';
			sHtml+='<div style="float:left;margin-left:5px;">'+hotMenuJson[i].orderCount+'套</div>';
			newHotMenu.innerHTML=sHtml;
			oHotMenuDiv.appendChild(newHotMenu);
		}
	}else{
		var newHotMenu=document.createElement('li');
		newHotMenu.innerHTML='统计中...';
		oHotMenuDiv.appendChild(newHotMenu);
	}
}
function showHotMenuDetail(event,obj,type){
	if(type==0){
		var sLeft=Event.pointerX(event);
		var sTop=Event.pointerY(event);
		var menuIndex=parseInt(obj.id.split('_')[1]);
		$('hotDetailDiv').style.left=sLeft-0-10+"px";
		$('hotDetailDiv').style.top=sTop-0+20+"px";
		$('hotDetail').innerHTML='';
		var foodStyle='margin-top:6px;float:left;width:65px;padding-left:10px;display:inline';
		var newfoodPrice=document.createElement('li');
		newfoodPrice.style.cssText=foodStyle;
		newfoodPrice.innerHTML=hotMenuJson[menuIndex].menuPrice+"元/份";
		$('hotDetail').appendChild(newfoodPrice);
		
		if(typeof(hotMenuJson[menuIndex].menuInfo)!='undefined'){
			for(var i=0;i<hotMenuJson[menuIndex].menuInfo.length;i++){
				var newfoodInfo=document.createElement('li');
				newfoodInfo.style.cssText=foodStyle;
				newfoodInfo.innerHTML=hotMenuJson[menuIndex].menuInfo[i].foodName;
				$('hotDetail').appendChild(newfoodInfo);
			}
		}else{
			var newfoodInfo=document.createElement('li');
			newfoodInfo.style.cssText=foodStyle;
			newfoodInfo.innerHTML=hotMenuJson[menuIndex].menuSpec;
			$('hotDetail').appendChild(newfoodInfo);
		}
		$('hotDetailDiv').style.display="block";
	}else if(type==1){
		$('hotDetailDiv').style.display="none";
	}
}
function getFoodNews(){
	url='ajax.php?action=getFoodNews';
	var ajax=new BHPAjax();
	ajax.Request(url,{'method':'get','asyn':true,'callback':afterGetFoodNews});
}
function afterGetFoodNews(result){
	var oNewsList=$('newsList');
	oNewsList.innerHTML='';
	if(result){
		foodNewsJson=result.parseJSON();
		if(foodNewsJson){
			if(foodNewsJson.length>7){
				for(var i=0;i<foodNewsJson.length-1;i++){
					var newNews=document.createElement('li');
					newNews.innerHTML='<div style="float:left;margin-left:5px;width:140px;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;"><a href="newsDetail.php?newsId='+foodNewsJson[i].newsId+'" title="'+foodNewsJson[i].newsTitle+'" target="_blank">'+foodNewsJson[i].newsTitle+'</a></div><div style="float:left;width:60px;">'+foodNewsJson[i].newsCreateTime+'</div>';
					oNewsList.appendChild(newNews);
				}
				var newNews=document.createElement('li');
				newNews.innerHTML='<div style="margin-left:5px;"><a href="./newsList.php" target="_blank">[查看更多饮食文化]</a></div>';
				oNewsList.appendChild(newNews);
			}else{
				for(var i=0;i<foodNewsJson.length;i++){
					var newNews=document.createElement('li');
					newNews.innerHTML='<div style="float:left;margin-left:5px;width:140px;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;"><a href="newsDetail.php?newsId='+foodNewsJson[i].newsId+'" title="'+foodNewsJson[i].newsTitle+'" target="_blank">'+foodNewsJson[i].newsTitle+'</a></div><div style="float:left;width:60px;">'+foodNewsJson[i].newsCreateTime+'</div>';
					oNewsList.appendChild(newNews);
				}
			}
		}else{
			var newNews=document.createElement('li');
			newNews.innerHTML='暂无记录...';
			oNewsList.appendChild(newNews);
		}
	}else{
		var newNews=document.createElement('li');
		newNews.innerHTML='暂无记录...';
		oNewsList.appendChild(newNews);
	}
}

