$(function () {
	var basePath = $($("body")[0]).attr("base");
    var O_ChangeDate=$("#O_ChangeDate");
    var O_IndateDetails=$("#O_IndateDetails");
    var O_OutdateDetails=$("#O_OutdateDetails");
    //修改日期
    O_ChangeDate.click(function(){
        var v_indate=O_IndateDetails.val();
        var v_outdate=O_OutdateDetails.val();
        //判断入住日期
        if(v_indate.length==0){ alert("请选择入住日期!");O_IndateDetails.focus();WdatePicker({minDate:'%y-%M-#{%d}',el:'O_IndateDetails'});return; }
        //判断离店日期
        if(v_outdate.length==0){ alert("请选择离店日期!");O_OutdateDetails.focus();WdatePicker({minDate:'%y-%M-#{%d}',el:'O_OutdateDetails'});return; }
        //比较日期
        var ary1=v_indate.split("-");
        var ary2=v_outdate.split("-");
        //alert(Number(ary1[0])+Number(ary1[1])+Number(ary1[2]));
        if((Number(ary1[0])+Number(ary1[1])+Number(ary1[2])) - (Number(ary2[0])+Number(ary2[1])+Number(ary2[2]))>=0) {
            alert("入住日期"+v_indate+"晚于离店日期"+v_outdate);O_OutdateDetails.focus();WdatePicker({minDate:'%y-%M-#{%d}',el:'O_OutdateDetails'});return;
        }
        $.post(basePath + "?m=hotel.setHotelBookDate",{ indate:v_indate,outdate:v_outdate },function(data) {
            if(data[0] == "success") { window.location.reload(); }
        }, "json");
    });
    //入住日期
    O_IndateDetails.click(function(){
        WdatePicker({minDate:'%y-%M-#{%d}',el:'O_IndateDetails'})
    });
    //离厂日期
    O_OutdateDetails.click(function(){
        WdatePicker({minDate:'%y-%M-#{%d}',el:'O_OutdateDetails'})
    });
});
//添加酒店点评
function hotelCommentAdd(){
	var basePath = $($("body")[0]).attr("base");
	$.post(basePath + "?m=login.checkLogin",{},function(data){//alert(data);
		if(data[0] == "null") {
			showWinLogin(); //弹出窗口登录
		} else {
			window.location.href = basePath + 'member/order-checkin.html';
		}
	}, "json");
}
//搜索酒店问答
function searchAsk(){
	var basePath = $($("body")[0]).attr("base");
	var O_AskLoading = $("#O_AskLoading");
	O_AskLoading.show();
    var O_CategoryName = $("#O_AskCategoryName");
	var O_CategoryRelId = $("#O_AskCategoryRelId");
	var O_Key = $("#O_AskKey");
	var O_HotelAskList = $("#O_HotelAskList");
	
	$.post(basePath + "?m=hotel.getListByQuestion", { categoryName:O_CategoryName.val(), categoryRelId:O_CategoryRelId.val(), keywords:O_Key.val() }, function(data) {//alert(data);
		O_HotelAskList.html(data);
		O_AskLoading.hide();
	});
}
//窗口登录
function showWinLogin(){
	//启动浏览模式
	var range = getRange();
	var obj_doing = document.getElementById("doing");
	if(range != null && obj_doing != null) {
		obj_doing.style.width = range.width + "px";
		obj_doing.style.height = (range.height+100)+ "px";
		obj_doing.style.display = "block";
	}
	var divLogin = document.getElementById("divLogin");
	if(divLogin != null) { divLogin.style.display = ""; }
	var divLoginF = document.getElementById("divLoginF");
	if(divLoginF != null) { divLoginF.style.display = ""; }
}