﻿var MsgLib = {
    InnameLenFail: "请输入入住人姓名！",
    khNameLenFail: "请输入联系人姓名！",
    khTellenFail: "请输入正确的手机号码！",
    noBeginDate: "请选择入住日期！",
    noEndDate: "请选择离店日期！",
    CityRequired: "请输入入住城市！",
    tbGNameReq: "请输入提问者姓名！",
    tbGMailReq: "请输入联系方式！",
    tbGNoteReq: "请输入提问内容！",
    GetOrderReq: "请输入入住人姓名或手机查询订单！",
    totalPayReq: "无价格房型不能预定！",
    pNameReq: "持卡人姓名不能为空！",
    pIDTypeReq: "持卡人证件类型不能为空！",
    pIDNumReq: "持卡人证件号码不能为空！",
    pTelReq: "持卡人电话不能为空！",
    UserNameReq: "请输入用户名！",
    UserPasswordReq: "请输入密码！",
    CommentContent: "请输入评论内容",
    suggestList: "<div id='suggestList' class='suggestList'>",
    doingDiv: "<div id='doing' class='openwindiv'><iframe src='' style=\"position:absolute;visibility:inherit; top:0px; left:0px; width:100%; height:100%;z-index:-1;filter='progid;DXImageTransform.Microsoft.Alpha(style=0,opacity=0)';\"></iframe></div>"
}

function ShowObj(ID)
{ 
   document.getElementById(ID).style.display="block";
}

function HideObj(ID)
{
   document.getElementById(ID).style.display="none";
}

function SHjs(ID1,ID2){
  var obj = document.getElementById(ID1)
  var obj = document.getElementById(ID2)
    document.getElementById(ID1).style.display="none";	
    document.getElementById(ID2).style.display="block";	
}
var PubFunction = {
    //城市自动搜索
    InitCityBox: function(CityBox,Area,DefaultCity){
        //CityBox:城市文本框名称，Area:区域控件名称，DefaultCity:默认城市
        var $CityBox;
        $("body").append(MsgLib.suggestList);
        $("body").append(MsgLib.doingDiv);
        if(CityBox != null && CityBox !="" && $("#" + CityBox).length > 0)
        {
            $CityBox = $("#" + CityBox);
        }
        else
        {
            $CityBox = $("#txtHotelCity");
        }
        
        $CityBox
        .keyup(function(){
            getKeyword($(this));
        })
        .focus(function(){
            getKeyword($(this));
        })
        .blur(function(){
            if(document.activeElement.id == "suggestList"){
                $("div.suggestList li").each(function(){
                    //添加li的click事件
                    $(this).click(function(){
                        $CityBox.val($(this).attr('cityname'));
                        $('#suggestList').hide();
                        $('#doing').hide();
                        UpdateArea();
                    });
                })
                $("#suggestList").show();
            }
            else{
                //默认选择第一个li的cityname
                //alert($("div.suggestList li:first").attr("cityname"));
                $CityBox.val($("div.suggestList li:first").attr("cityname"));
                $("#suggestList").hide();
                $('#doing').hide();
                UpdateArea();
                //
            }
        });
        
        function UpdateArea(){
            //城市变动，更新区域
            if(Area != null && Area !="" && $("#" + Area).length > 0)
            {
                var $Area = $("#" + Area);
                if($Area.attr("type") == "select-one"){
                    $.get("/Hotel/HotelAjax.aspx",{
                        "Action":"Area",
                        "Type":"select-one",
                        "CityName":$CityBox.val()},function(data){
                        $Area.empty();
                        if(data != null && data != ""){
                            //alert(data);
                            var ArrListItem = data.split("|");
                            var strOptions;
                            for(var i = 0; i < ArrListItem.length; i++){
                                if(ArrListItem[i] != null && ArrListItem[i] != ""){
                                    strOptions += "<option value='" + ArrListItem[i].split(",")[0] + "'>" + ArrListItem[i].split(",")[1] + "</option>";
                                }
                            }
                            $Area.append(strOptions);
                        }
                        
                    });
                }
                //
                //alert($Area.attr("tagName"));
                if($Area.attr("tagName").toLowerCase() == "span"){
                    //Hotel_HotelSearch.getHotelArea($CityBox.val());
                    //alert($CityBox.val());
                    $("#btnSearchArea").click();
                }
                //
            }
        };
        
        function getKeyword(obj){
            var _Obj = document.getElementById(obj.attr("id"));
            var $doing = document.getElementById("doing");
            var top = 21;
            var left = 0;
            while(_Obj){
                //此循环得到文件域对象在页面中的绝对位置
                top += _Obj["offsetTop"];
                left += _Obj["offsetLeft"];
                _Obj = _Obj.offsetParent;
            }
            //$doing = $doing.offsetParent;
            //alert($doing);
            $.get("/Hotel/HotelAjax.aspx",{
                "Action":"HotelCity",
                "DefaultCity":DefaultCity,
                "Keywords":obj.val()},function(data){
                var $suggestList = $("#suggestList");
                var ListWidth = $CityBox.attr("scrollWidth");   //自适应宽度
                if(ListWidth < 164){
                    //设定最小宽度
                    ListWidth = 164;
                }
                $suggestList.html(data).attr({style:"left:" + left +"px;top:" + top + "px;width:" + ListWidth + "px;"});
                if(data != null && data != ""){
                    //alert($CityBox.attr("scrollWidth"));
                    //$suggestList.attr("width",$CityBox.attr("scrollWidth"));
                    //alert($suggestList.attr("scrollWidth"));
                    $suggestList.show();
                    //兼容IE6 遮罩层遮住下拉列表
                    var width = $suggestList.attr("scrollWidth");
                    var height = $suggestList.attr("scrollHeight");
                    $("#doing").attr({style:"left:" + left +"px;top:" + top + "px;width:" + width + "px;height:" + height +"px;"}).show();
                }
                else{
                    $("#doing").hide();
                    $suggestList.hide();
                }                
            });
        };
    },
    
    HotelchkOnclick: function(chkName){
        //绑定 不限 onclick事件
        $("input[name^='" + chkName + "']:checkbox:first").bind("click",function() {
	        if($("input[name^='" + chkName + "']:checkbox:first").attr("checked")){
	            $("input[name^='" + chkName + "']:checkbox:not(input[name^='" + chkName + "']:checkbox:first)").each(function(){
	                $(this).attr("checked", false);
	            })
	        }
	    });
	    //绑定 其它选项 onclick事件
        $("input[name^='" + chkName + "']:checkbox:not(input[name^='" + chkName + "']:checkbox:first)").bind("click",function() {
	        var flag = 0;
	        $("input[name^='" + chkName + "']:checkbox:first").attr("checked", false);
	        $("input[name^='" + chkName + "']:checkbox:not(input[name^='" + chkName + "']:checkbox:first)").each(function(){
	            if($(this).attr("checked")){
	                flag ++;
	            }
	        });
	        if(flag == 0 || flag == $("input[name^='" + chkName + "']:checkbox").length - 1){
	            $("input[name^='" + chkName + "']:checkbox:first").attr("checked", true);
	        }
	    });
    },
    
    VisitAll: function(){
        $("#hplVisitAll").click(function(){
            $.get("/PubAjax.ashx",{
                "Action":"VisitAll",
                "t":+ new Date()},function(data){
                    window.location.href = "http://www.ljvip.cn";
            });
        })
    }
    //,
}

//酒店版块
var Hotel = {
    //网站首页    
    HomePage: function(){
        $("#imgBtSearch").click(function() {
            var $HotelCity = $("#txtHotelCity"),
	            $BeginDate = $("#txtBeginDate"),
	            $EndDate = $("#txtEndDate");
	        if($HotelCity.val() == ""){
	            alert(MsgLib.CityRequired);
	            return false;
	        }
	        if($BeginDate.val() == ""){
	            alert(MsgLib.noBeginDate);
	            return false;
	        }
	        if($EndDate.val() == ""){
	            alert(MsgLib.noEndDate);
	            return false;
	        }
	        window.location.href = "/Hotel/HotelSearch.aspx?" 
	            + "HotelCity=" + encodeURI($HotelCity.val()) 
	            + "&BeginDate=" + $BeginDate.val() 
	            + "&EndDate=" + $EndDate.val() 
	            + "&HotelPrice=" + $("#ddlHotelPrice").val() 
	            + "&HotelStars=" + $("#ddlHotelStars").val() 
	            + "&HotelKeywords=" + encodeURI($("#txtHotelKeywords").val().replace("输入酒店关键字，如：喜来登",""));
	        return false;
        });
        
//        $("#btnMyOrderSubmit").click(function(){
//            if($("#txtGetOrder").val().replace("输入入住人姓名或手机查询订单","") == ""){
//                alert(MsgLib.GetOrderReq);
//                return false;
//            }
//            window.location.href = "/UserCenter/MyHotelOrder.aspx?GetOrder=" + encodeURI($("#txtGetOrder").val().replace("输入入住人姓名或手机查询订单",""));
//            return false;
//        });
        
        function document.onkeydown(){ 
            var e = event.srcElement; 
            if(event.keyCode == 13) 
            { 
	            //回车不进行任何处理
	            return false;
            } 
        };
    },
    
    //酒店默认页初始化
    DefaultInit: function(){
        $("#imgBtSearch").click(function() {
	        var $HotelCity = $("#txtHotelCity"),
	            $BeginDate = $("#txtBeginDate"),
	            $EndDate = $("#txtEndDate");
	        if($HotelCity.val() == ""){
	            alert(MsgLib.CityRequired);
	            return false;
	        }
	        if($BeginDate.val() == ""){
	            alert(MsgLib.noBeginDate);
	            return false;
	        }
	        if($EndDate.val() == ""){
	            alert(MsgLib.noEndDate);
	            return false;
	        }
	        window.location.href = "/Hotel/HotelSearch.aspx?" 
	            + "HotelCity=" + encodeURI($HotelCity.val()) 
	            + "&HotelArea=" + $("#ddlHotelArea").val() 
	            + "&BeginDate=" + $BeginDate.val() 
	            + "&EndDate=" + $EndDate.val() 
	            + "&HotelPrice=" + $("#ddlHotelPrice").val() 
	            + "&HotelStars=" + $("#ddlHotelStars").val() 
	            + "&HotelKeywords=" + encodeURI($("#txtHotelKeywords").val().replace("输入酒店关键字，如：喜来登",""));
	        return false;
	    });
	    
    },
    
    //酒店搜索页初始化
    SearchInit: function(){
        //价格
        PubFunction.HotelchkOnclick("chkHotelPrice");
	    //星级
	    PubFunction.HotelchkOnclick("chkHotelStars");
    },
    
    //详细信息页选项卡初始化
    InittagMenu: function(){
        $("#tagMenu li a").click(function(){
            var $this = $(this);
            
            $("#tagMenu li a").each(function() { 
                $(this).removeClass("infoactive");
                $("#tagContent_" + $(this).attr("id").substring(8,9)).hide();
            });
            
            $this.attr({className:"infoactive"});
            var tagIndex = $this.attr("id").substring(8,9);
            var $tagContent = $("#tagContent_" + tagIndex);
            $tagContent.show();
            
            if(tagIndex == 1 && $("#hotelimg").html() == ""){
                $.ajax({
			        type:"get",
			        url:"/Hotel/HotelAjax.aspx",
			        data:{Action:"HotelPictures",HotelId:$("#hdHotelId").val()},
			        beforeSend: function(){
			            $("#hotelimg").html("<div style='text-align:center;'><img src='/images/loading.gif' /></div>")
			        },
			        error:function(){
				        $("#hotelimg").html("<div>数据加载出错...</div>");
			        },
			        success:function(data){
				        $("#hotelimg").html(data);
				        $('#hotelimg a').lightBox();
				        //alert(data);
			        }
		        });
            }
            
            if(tagIndex == 2 && $("#map").html() == ""){
                var GooglePosition = $("#hdGooglePosition").val().split(",");
                GoogleMapShow($("#lbHotelName").html(), eval(GooglePosition[0]), eval(GooglePosition[1]));
            }
            
            //alert($this.attr("id").substring(8,9));
        });
    },
    
    //详细信息页初始化
    HotelDetailInit: function() {
	    $("#imgBtSearch").click(function() {
            $.ajax({
			    type:"get",
			    url:"/Hotel/HotelAjax.aspx",
			    data:{Action:"BindRoomList",BeginDate:$("#txtBeginDate").val(),EndDate:$("#txtEndDate").val(),HotelId:$("#hdHotelId").val()},
			    beforeSend: function(){
			        $("#spnhotelprice").html("<div style='text-align:center;'><img src='/images/loading.gif' /></div>")
			    },
			    error:function(){
				    $("#spnhotelprice").html("<div>数据加载出错...</div>");
			    },
			    success:function(data){
				    $("#spnhotelprice").html(data);
				    //alert(data);
			    }
		    });
		    return false;
	    });
	    //
	    $("#imgBtHotelSearch").click(function() {
	        var $HotelCity = $("#txtHotelCity"),
	            $BeginDate = $("#txtBeginDateRight"),
	            $EndDate = $("#txtEndDateRight");
	        if($HotelCity.val() == ""){
	            alert(MsgLib.CityRequired);
	            return false;
	        }
	        if($BeginDate.val() == ""){
	            alert(MsgLib.noBeginDate);
	            return false;
	        }
	        if($EndDate.val() == ""){
	            alert(MsgLib.noEndDate);
	            return false;
	        }
	        window.location.href = "/Hotel/HotelSearch.aspx?" 
	            + "HotelCity=" + encodeURI($HotelCity.val()) 
	            + "&BeginDate=" + $BeginDate.val() 
	            + "&EndDate=" + $EndDate.val() 
	            + "&HotelPrice=" + $("#ddlHotelPrice").val() 
	            + "&HotelStars=" + $("#ddlHotelStars").val() 
	            + "&HotelKeywords=" + encodeURI($("#txtHotelKeywords").val().replace("输入酒店关键字",""));
	        return false;
	    });
	    
	    $("#btGuestQA").click(function() {
	        var $tbGName = $("#tbGName"),
	            $tbGMail = $("#tbGMail"),
	            $tbGNote = $("#tbGNote");
	        if($tbGName.val() == ""){
	            alert(MsgLib.tbGNameReq);
	            return false;
	        }
	        if($tbGMail.val() == ""){
	            alert(MsgLib.tbGMailReq);
	            return false;
	        }
	        if($tbGNote.val() == ""){
	            alert(MsgLib.tbGNoteReq);
	            return false;
	        }
	    });
	    
	    $("#btnSubmitComment").click(function() {
	        var $txtNote = $("#txtNote"),
	            $lblUserName = $("#lblUserName"),
	            $txtUserName = $("#txtUserName"),
	            $txtPassword = $("#txtPassword");
	        if($txtNote.val() == ""){
	            alert(MsgLib.CommentContent);
	            return false;
	        }
	        if($lblUserName.length <= 0){
	            if($txtUserName.val() == ""){
	                alert(MsgLib.UserNameReq);
	                return false;
	            }
	            if($txtPassword.val() == ""){
	                alert(MsgLib.UserPasswordReq);
	                return false;
	            }
	            
	            $.get("HotelOrderAjax.aspx",{
                    "Action":"chkLogin",
                    "UserName":$("#txtUserName").val(),
                    "Password":$("#txtPassword").val()},function(data){
                    if(data!="true"){
                        alert(data);
                    }
                });
	        }
	    });
	    
     },
     
    //预定窗口初始化
    bkwInit: function (){
        $("#imgBtSearchForBook").click(function() {                
            $.get("HotelOrderAjax.aspx",{
                "Action":"bkwSearchPrice",
                "BedForBook":$("#ddlBedForBook").val(),
                "PayType":$("#ddlPayType").val(),
                "jsForBook":$("#ddljsForBook").val(),
                "InNameForBook":$("#txtInNameForBook").val(),
                "BeginDate":$("#txtBeginDateForBook").val(),
                "EndDate":$("#txtEndDateForBook").val(),
                "HotelId":$("#hdHotelIdForBook").val(),
                "RoomsId":$("#hdRoomsIdForBook").val()},function(data){
                $("#divbkwPrice").html(data);
            });
            return false;
        });
        $("#btSubmitBook").click(function() {            
            if($("#spnTotalMoneyForBook").html() == "0"){
                //价格零不允许预定
                alert(MsgLib.totalPayReq);
                return false;
            }
            var $InName = $("#txtInNameForBook"),
                $khName = $("#txtkhNameForBook"),
                $khTel = $("#txtkhTelForBook"),
                $BeginDate = $("#txtBeginDateForBook"),
                $EndDate = $("#txtEndDateForBook"),
                $Bed = $("#ddlBedForBook"),
                $PayType = $("#ddlPayType"),
                $js = $("#ddljsForBook"),
                $OrderNote = $("#txtOrderNoteForBook");
            
            var InName = $InName.val(),
                khName = $khName.val(),
                khTel = $khTel.val(),
                BeginDate = $BeginDate.val(),
                EndDate = $EndDate.val();
                Bed = $Bed.val(),
                PayType = $PayType.val(),
                js = $js.val(),
                OrderNote = $OrderNote.val();
             
            if(InName.length == 0){
                alert(MsgLib.InnameLenFail);
                $InName.focus();
                return false;
            }
            if(khName.length == 0){
                alert(MsgLib.khNameLenFail);
                $khName.focus();
                return false;
            }
            if(isMobile(khTel) == false){
                alert(MsgLib.khTellenFail);
                $khTel.focus();
                return false;
            }
            $("#btSubmitBook").attr("disabled","true"); //防止重复提交
            $.get("HotelOrderAjax.aspx",{
                "Action":"bkwSubmitBook", 
                "HotelId":$("#hdHotelIdForBook").val(),
                "RoomsId":$("#hdRoomsIdForBook").val(), 
                "UserName":khName, 
                "UserMobile":khTel, 
                "InName":InName, 
                "BeginDate":BeginDate, 
                "EndDate":EndDate, 
                "Bed":Bed, 
                "PayType":PayType, 
                "js":js, 
                "OrderNote":OrderNote},function(data){
                if(data == "Success"){                    
                    $("#windown-close").click();
                    //alert("Success!");
                    tipsWindown("预定成功","url:get?/Hotel/HotelBookSuccess.html","300","150","true","","true","text");
                }
                else{
                    alert(data);
                    //$OrderNote.html(data);
                };
            });
            return false;
        });
    },
    
    //酒店快捷支付页面
    MyHotelOrderInit: function(){
        $("#hplBatchPay").click(function(){
            $hdtoPayOrderNoBatch = $("#hdtoPayOrderNoBatch");
            if($hdtoPayOrderNoBatch.val() == ""){
                alert("请选择要支付的订单！");
            }
            else{
                tipsWindown('丽江时光旅行网—酒店订单批量支付','url:get?99BillSendHotel.aspx?Action=HotelBatchPay&OrderNo=' + $hdtoPayOrderNoBatch.val(),'680','230','true','','true','',Hotel.HotelBatchPay);
            }
        });
    },
    
    HotelSinglePay: function(){
        Hotel.InitPayBt('imgBtPaySubmit','HotelSinglePaySubmit');
    },
    
    HotelBatchPay: function(){
        Hotel.InitPayBt('imgBtPaySubmit','HotelBatchPaySubmit');
    },
    
    InitPayBt: function(btName,Action){
        $("#" + btName).click(function(){
            var PayAmount = $("#txtPayMoney").val(),
                MaxNotPay = $("#hdMaxNotPay").val(),
                PayNote = $("#txtPayNote").val().replace(/\n/g,"").replace(/\r/g,"");
            if(PayAmount == "" || PayAmount == 0){
                alert("支付金额不能为零！");
                return false;
            }
            else if(parseFloat(PayAmount) > parseFloat(MaxNotPay)){
                alert("支付金额不能超过 " + MaxNotPay + "元！");
                return false;
            }
            if(PayNote.length > 100){
                alert("付款说明长度不能超过100个字符！");
                return false;
            }
                    
            //alert($("input[name='rbtnPayType']:checked").val());
            var rbtnPayType = $("input[name='rbtnPayType']:checked").val();
            if(rbtnPayType == "0"){
                //支付宝支付
                $("#" + btName).attr("disabled","true"); //防止重复提交
                $.post("HotelOrderAjax.aspx",{
                    "Action": Action,
                    "GetOrder": $("#hdGetOrder").val(),
                    "OrderNo": $("#spnPayOrderNo").html(),
                    "PayAmount": PayAmount,
                    "PayNote": PayNote},function(data){
                    //alert(data);
                    eval(data);
                });
            }
            else if(rbtnPayType == "1"){
                //alert(rbtnPayType);
                //$("#form1").attr({action:"PaybyIps.aspx",target:"_blank"}).submit();
                var pName = $("#pName").val(),
                    pIDType = $("#pIDType").val(),
                    pIDNum = $("#pIDNum").val(),
                    pTel = $("#pTel").val();
                
                if(pName == ""){
                    alert(MsgLib.pNameReq);
                    return false;
                }
                if(pIDType == ""){
                    alert(MsgLib.pIDTypeReq);
                    return false;
                }
                if(pIDNum == ""){
                    alert(MsgLib.pIDNumReq);
                    return false;
                }
                if(pTel == ""){
                    alert(MsgLib.pTelReq);
                    return false;
                }
                
                $("#" + btName).attr("disabled","true"); //防止重复提交
                $.post("HotelOrderAjax.aspx",{
                    "Action": "HotelSingleIpsCATPaySubmit",
                    "GetOrder": $("#hdGetOrder").val(),
                    "OrderNo": $("#spnPayOrderNo").html(),
                    "pName": pName,
                    "pIDType": pIDType,
                    "pIDNum": pIDNum,
                    "pTel": pTel,
                    "PayAmount": PayAmount,
                    "PayNote": PayNote},function(data){
                    $("body").append("<div id=\"divPay\"></div>");
                    $("#divPay").html(data).remove();
                    //alert(data);
                    tipsWindown('酒店订单支付','iframe:PayResult.htm','600','350','true','','true');
                });
            }
            
            return false;
        });
        
        
    }
}

var Trip = {
     //快捷支付页面
    MyTripOrderInit: function(){
        $("#hplBatchPay").click(function(){
            $hdtoPayOrderNoBatch = $("#hdtoPayOrderNoBatch");
            if($hdtoPayOrderNoBatch.val() == ""){
                alert("请选择要支付的订单！");
            }
            else{
                tipsWindown('丽江时光旅行网—度假订单批量支付','url:get?99BillSendTrip.aspx?Action=BatchPay&OrderNo=' + $hdtoPayOrderNoBatch.val(),'780','360','true','','true','',Trip.BatchPay);
            }
        });
    },
    
     //订单支付
     SinglePay: function(){
        //alert('aid');
        Trip.InitPayBt('imgBtPaySubmit','SinglePaySubmit');
    },
    BatchPay: function(){
        Trip.InitPayBt('imgBtPaySubmit','BatchPaySubmit');
    },
    
    InitPayBt: function(btName,Action){
        $("#" + btName).click(function(){
            var PayAmount = $("#txtPayMoney").val(),
                MaxNotPay = $("#hdMaxNotPay").val();
            if(PayAmount == "" || PayAmount == 0){
                alert("支付金额不能为零！");
                return false;
            }
            else if(PayAmount > MaxNotPay){
                alert("支付金额不能超过 " + MaxNotPay + "元！");
                return false;
            }
            $.get("/UserCenter/TripPayAjax.aspx",{
                "Action": Action,
                "OrderNo": $("#spnPayOrderNo").html(),
                "PayAmount": PayAmount,
                "PayNote": $("#txtPayNote").val()},function(data){
                //alert(data);
                eval(data);
            });
            return false;
        });
    },
    
    //预定窗口初始化
    bkwInit: function (){
        //alert("123");
        $("#btSubmitBook").click(function() {      
              
            var $khName = $("#txtkhNameForBook"),
                $khTel = $("#txtkhTelForBook"),
                $BeginDate = $("#TripDate"),
                $Num1 = $("#TripNum1"),
                $Num2 = $("#TripNum2"),
                $OrderNote = $("#txtOrderNoteForBook");               
            
            var khName = $khName.val().trim(),
                khTel = $khTel.val().trim(),
                BeginDate = $BeginDate.val().trim(),
                Num1 = $Num1.val().trim(),
                Num2 = $Num2.val().trim(),
                OrderNote = $OrderNote.val().trim();
             
            if(khName.length == 0){
                alert(MsgLib.khNameLenFail);
                $khName.focus();
                return false;
            }
            if(isMobile(khTel) == false){
                alert(MsgLib.khTellenFail);
                $khTel.focus();
                return false;
            }
            
            $.get("/TripAjax.aspx",{
                "Action":"bkwSubmitBook", 
                "Id":$("#hdIdForBook").val(),
                "UserName":khName, 
                "UserMobile":khTel, 
                "DateSale":BeginDate, 
                "Num1":Num1, 
                "Num2":Num2, 
                "OrderNote":OrderNote},function(data){
                if(data == "Success"){
                    $("#windown-close").click();
                    tipsWindown("预定成功","url:get?/BookSuccess.html","300","150","true","","true","text");
                }
                else{
                    alert(data);
                    //$OrderNote.html(data);
                };
            });
            return false;
        });
    }
}


function FormatFloat(_obj)
{
	_obj.value=_obj.value.replace(/[^\d.]/g,'');
}


//***首页搜索点击激活	    
function SearCk(id,cnt)
{
    var varCk=document.getElementById("SearCk").getElementsByTagName("li");
    for(i=0;i<cnt;i++)
    {
        i==id?varCk[id].className="select":varCk[i].className="";
        i==id?document.getElementById("idSear"+i).style.display="block":document.getElementById("idSear"+i).style.display="none";
    }
}

//***推荐酒店选项卡
function SetTab(tab,id,cnt){
    var menus=document.getElementById(tab).getElementsByTagName("a");            
    for(i=0;i<cnt;i++){	       
        i==id?menus[i].className="shallow_blue_box_switch_selected":(menus[i].className!=""?menus[i].className="shallow_blue_box_switch":menus[i].className="");
        i==id?document.getElementById(tab+"-content"+i).style.display="block":document.getElementById(tab+"-content"+i).style.display="none";
    }
}
function SetTabLI(tab,id,cnt){
    var menus=document.getElementById(tab).getElementsByTagName("li");            
    for(i=0;i<cnt;i++){	       
        i==id?menus[i].className="select":menus[i].className="";
        i==id?document.getElementById(tab+"-content"+i).style.display="block":document.getElementById(tab+"-content"+i).style.display="none";
    }
}

function SetTabLIClassOnly(tab,id,cnt){
    var menus=document.getElementById(tab).getElementsByTagName("li");            
    for(i=0;i<cnt;i++){	       
        i==id?menus[i].className="select":menus[i].className="";       
    }
}

//***酒店详细介绍选项卡
function SetTabliForHotelDetail(tab,id,cnt){
    var menus=document.getElementById(tab).getElementsByTagName("li");            
    for(i=0;i<cnt;i++){	       
        i==id?menus[i].className="Navigation_switch_s":menus[i].className="";
        i==id?document.getElementById(tab+"-content"+i).style.display="block":document.getElementById(tab+"-content"+i).style.display="none";
    }
}

function SetTabLIForLineIntro(tab,id,cnt){
    var menus=document.getElementById(tab).getElementsByTagName("li");            
    for(i=0;i<cnt;i++){	       
        i==id?menus[i].className="Navigation_switch_s":menus[i].className="";
        i==id?document.getElementById(tab+"-content"+i).style.display="block":document.getElementById(tab+"-content"+i).style.display="none";
    }
}

//***推荐酒店选项卡
function SetTabByID(tab,id,cnt){
    var menus=document.getElementById(tab).getElementsByTagName("a");            
    for(i=0;i<cnt;i++){	       
        i==id?menus[i].className="shallow_blue_box_switch_selected":menus[i].className="shallow_blue_box_switch";
        i==id?document.getElementById(tab+"-content"+i).style.display="block":document.getElementById(tab+"-content"+i).style.display="none";
    }
}

//***推荐游记攻略选项卡
function SetTab2(tab,id,cnt){
    var menus=document.getElementById(tab).getElementsByTagName("span");            
    for(i=0;i<cnt;i++){	       
        i==id?menus[i].className="big_switch_selected":(menus[i].className!=""?menus[i].className="big_switch":menus[i].className="");
        i==id?document.getElementById(tab+"-content"+i).style.display="block":document.getElementById(tab+"-content"+i).style.display="none";
    }
}


//***推荐租车选项卡
function SetTab3(tab,id,cnt){
    var menus=document.getElementById(tab).getElementsByTagName("span");            
    for(i=0;i<cnt;i++){	       
        i==id?menus[i].className="car_c_sl":menus[i].className="car_c";
        i==id?document.getElementById(tab+"-content"+i).style.display="block":document.getElementById(tab+"-content"+i).style.display="none";
    }
}

//酒店价格显示
/*begin*/
function getObject(s) {
    return document.getElementById(s);
}

function PopPrice(tdId, strPrice, Type, xLeft, xTop) {
    var obj = document.all[tdId]; //获取文本域对象
    //if(obj.value==""){
    //        return;
    //    }
    var top = 0;
    var left = 0;

    while (obj) {//此循环得到文件域对象在页面中的绝对位置
        top += obj.offsetTop;
        left += obj.offsetLeft;
        obj = obj.offsetParent;
    }
    if (Type == "1") {
        document.getElementById("Popdiv").innerHTML = CreatePriceList(strPrice); //把数据填充到提示层
    }
    else if(Type == "2") {
        document.getElementById("Popdiv").innerHTML = ShowHotelOrderRoomList(strPrice); //把数据填充到提示层
    }
    if (xLeft != "" && xLeft != null) {
        getObject("Popdiv").style.left = (left - xLeft) + "px"; //设置提示层的位置,左
    }
    else {
        getObject("Popdiv").style.left = (left - 200) + "px"; //设置提示层的位置,左
    }
    if (xTop != "" && xTop != null) {
        getObject("Popdiv").style.top = (top + xTop) + "px"; //设置提示层的位置,上
    }
    else {
        getObject("Popdiv").style.top = (top + 20) + "px"; //设置提示层的位置,上
    }
    getObject("Popdiv").style.display = "block"; //设置提示层可见
}

function hidPrice() {
    getObject("Popdiv").style.display = "none"; //设置提示层隐藏
}

function PopPlanIntroduction(PlanCode, chinesename, englishname, discriptions, zuoweishu, pictureurl,Type, xLeft, xTop) {
    var obj = document.all[PlanCode]; //获取文本域对象
      var top = 0;
    var left = 0;

    while (obj) {//此循环得到文件域对象在页面中的绝对位置
        top += obj.offsetTop;
        left += obj.offsetLeft;
        obj = obj.offsetParent;
    }
    if (Type == "1") {
        document.getElementById("Popdiv").innerHTML = CreatePlanIntroTable(chinesename,englishname,discriptions,zuoweishu,pictureurl); //把数据填充到提示层
    }
    else if (Type == "2") {
    document.getElementById("Popdiv").innerHTML = CreatePlanIntroTable(chinesename, englishname, discriptions, zuoweishu, pictureurl); //把数据填充到提示层
    }
    if (xLeft != "" && xLeft != null) {
        getObject("Popdiv").style.left = (left - xLeft) + "px"; //设置提示层的位置,左
    }
    else {
        getObject("Popdiv").style.left = (left - xLeft) + "px"; //设置提示层的位置,左
    }
    if (xTop != "" && xTop != null) {
        getObject("Popdiv").style.top = (top + xTop) + "px"; //设置提示层的位置,上
    }
    else {
        getObject("Popdiv").style.top = (top + 20) + "px"; //设置提示层的位置,上
    }
    getObject("Popdiv").style.display = "block"; //设置提示层可见
}

function hidPrice() {
    getObject("Popdiv").style.display = "none"; //设置提示层隐藏
}

function PopTicketRule(PlanCode,CancelRule,ChangeRule,TransferRule,RuleString,Type, xLeft, xTop) {
    var obj = document.all[PlanCode]; //获取文本域对象
    var top = 0;
    var left = 0;

    while (obj) {//此循环得到文件域对象在页面中的绝对位置
        top += obj.offsetTop;
        left += obj.offsetLeft;
        obj = obj.offsetParent;
    }
    if (Type == "1") {
        document.getElementById("Popdiv").innerHTML = CreateTicketRuleTable(CancelRule, ChangeRule, TransferRule,RuleString); //把数据填充到提示层
    }
    else if (Type == "2") {
    document.getElementById("Popdiv").innerHTML = CreateTicketRuleTable(CancelRule, ChangeRule, TransferRule,RuleString); //把数据填充到提示层
    }
    if (xLeft != "" && xLeft != null) {
        getObject("Popdiv").style.left = (left - xLeft) + "px"; //设置提示层的位置,左
    }
    else {
        getObject("Popdiv").style.left = (left - 200) + "px"; //设置提示层的位置,左
    }
    if (xTop != "" && xTop != null) {
        getObject("Popdiv").style.top = (top + xTop) + "px"; //设置提示层的位置,上
    }
    else {
        getObject("Popdiv").style.top = (top + 20) + "px"; //设置提示层的位置,上
    }
    getObject("Popdiv").style.display = "block"; //设置提示层可见
}

//生成机型介绍表(table)
function CreatePlanIntroTable(chinesename,englishname,discriptions,zuoweishu,pictureurl) {
    var str = "<table bgcolor='#E2F0FF' style='width:390px; font-weight: normal;border-color:#6FB8E5;' border='1' cellspacing='3' cellpadding='3'>";
    str = str + "<tr><td nowrap='nowrap' colspan='2'>机型参数</td></tr>";   
    if(chinesename!="")
    {
        str = str + "<tr><td nowrap='nowrap'>中文名称:</td><td>" + chinesename + "</td></tr>";   
    }
    if(discriptions!="")
    {
        str = str + "<tr><td nowrap='nowrap'>机型描述:</td><td>" + discriptions + "</td></tr>";
    }
    if(zuoweishu!="")
    {
        str = str + "<tr><td nowrap='nowrap'>座位个数:</td><td>" + zuoweishu + "</td></tr>";
    }    
    if (pictureurl != "") {
        str = str + "<tr><td colspan='2'><img width='390px' alt='外形' src='" + pictureurl + "' /></td></tr>";
    }    
    str = str + "</table>";
    return str;
}

//生成机票退改签(table)
function CreateTicketRuleTable(CancelRule, ChangeRule,TransferRule,RuleString) {
    var str = "<table bgcolor='#E2F0FF' style='width:390px; font-weight: normal;border-color:#6FB8E5;' border='1' cellspacing='3' cellpadding='3'>";
    str = str +"<tr><td nowrap='nowrap' colspan='2'>退改签规则</td></tr>";
    if(CancelRule!="")
    {
        str = str + "<tr><td nowrap='nowrap'>退票规定:</td><td>" + CancelRule + "</td></tr>";
    }
    if(ChangeRule!="")
    {
        str = str + "<tr><td nowrap='nowrap'>改签规定:</td><td>" + ChangeRule + "</td></tr>";
    }
    if(TransferRule!="")
    {
        str = str + "<tr><td nowrap='nowrap'>签转规定:</td><td>" + TransferRule + "</td></tr>";  
    }    
    str = str + "</table>";
    return str;
}


//生成酒店房型价格
function CreatePriceList(strPrice) {
    var str = "<table border='0' cellspacing='0' cellpadding='0'>";
    str = str + "<tr><td class='hotel_win_1'></td></tr>";
    str = str + "<tr><td class='hotel_win_2'>";
    str = str + "<table border='0' cellspacing='1' cellpadding='0' class='hotel_win_3'><tr height='30'>";
    var arrPrice = strPrice.split('$');
    var arrWeek = arrPrice[0].split(',');
    var i;
    for (i = 0; i < arrWeek.length; i++) {
        str = str + "<td class='hotel_win_date'>" + arrWeek[i] + "</td>";
    }
    str = str + "</tr>";
    //alert("ok");
    for (i = 1; i < arrPrice.length; i++) {
        var arrWeekPrice = arrPrice[i].split('|');
        str = str + "<tr>";
        var j = 0;
        for (j = 0; j < arrWeekPrice.length; j++) {
            var arrDayPrice = arrWeekPrice[j].split(',');
            str = str + "<td class='hotel_win_c'>" + arrDayPrice[0] + "<br /><span class='price_red_12'>" + arrDayPrice[1] + "</span><br />" + arrDayPrice[2] + "</td>"
        }
        for (var k = 0; k < 7 - j; k++) {
            str = str + "<td class='hotel_win_c'>&nbsp;</td>"
        }
        str = str + "</tr>"
    }
    str = str + "</table>"
    str = str + "</td></tr>";
    str = str + "</table>";
    return str;
}
//生成酒店订单房型价格
function ShowHotelOrderRoomList(strPrice) {
    var str = "<table border='0' cellspacing='0' cellpadding='0'>";
    str = str + "<tr><td class='hotel_win_1'></td></tr>";
    str = str + "<tr><td class='hotel_win_2'>";
    str = str + "<table border='0' cellspacing='1' cellpadding='0' class='hotel_win_3'><tr height='30'>";
    var arrPrice = strPrice.split('$');
    var arrTitle = arrPrice[0].split(',');
    var i;
    for (i = 0; i < arrTitle.length; i++) {
        str = str + "<td class='hotel_win_date'>" + arrTitle[i] + "</td>";
    }
    str = str + "</tr>";
    //alert("ok");
    for (i = 1; i < arrPrice.length; i++) {
        if (arrPrice[i] != "") {
            var arrDeatils = arrPrice[i].split(',');
            str = str + "<tr>";
            for (var j = 0; j < arrDeatils.length; j++) {
                str = str + "<td class='hotel_win_c'>&nbsp;" + arrDeatils[j] + "&nbsp;</td>";
            }
            str = str + "</tr>";
        }
    }
    str = str + "</table>"
    str = str + "</td></tr>";
    str = str + "</table>";
    return str;
}
/*end*/


//酒店房型 显示/隐藏
function ShowAllRoomType(hotelId,ShowNum) 
{
    var tb=document.getElementById("hotel"+hotelId);
	if(tb){
	    if(tb.showAll==null)
	    {
		    tb.showAll="false";
	    }
	    else
	    {
		    if(tb.showAll=="false")
			    tb.showAll="true";
		    else
			    tb.showAll="false";
	    }
	    var trs=tb.firstChild.childNodes;
	    var roomTypeCount=0;
	    var roomType="";
	    for(var i=0;i<trs.length;i++)
	    {
		    if(trs[i].hotelId!=null)
		    {
			    if(tb.showAll=="true")
			    {
				    trs[i].style.display="block";
			    }
			    else
			    {
				    if(trs[i].roomtype!=roomType)
				    {
					    roomType=trs[i].roomtype;
					    roomTypeCount++;
				    }
				    if( roomTypeCount > ShowNum )
				    {
					    trs[i].style.display="none";
				    }
				    else
				    {
					    trs[i].style.display="block";
				    }
			    }
		    }
	    }
    	
	    var imgRoomsMore=document.getElementById("imgRoomsMore_"+hotelId);
	    if(imgRoomsMore){
	        if(tb.showAll=="true"){
	            imgRoomsMore.src="/images/hotel_list_up.gif";
	        }
	        else{
	            imgRoomsMore.src="/images/hotel_list_dn.gif";
	        }
	        //alert(imgRoomsMore.src);
	    }
	}
	
}


//床型、付款方式选择
function ChangePrice(TotalPrice, BedType, PayType) {
    $("#tdPriceForBook span").each(function(index){
        $(this).attr("style","display:none");
        //alert($(this).html());
    })
    $("#spnPriceForBook_" + BedType + "_" + PayType).attr("style","display:");
    //alert(TotalPrice[BedType][PayType]);
    $("#spnTotalMoneyForBook").html(TotalPrice[BedType][PayType] * $("#ddljsForBook").val());
}

//价格合计
function ChangeRoomNum(TotalPrice, BedType, PayType, RoomNum) {
    $("#spnTotalMoneyForBook").html(TotalPrice[BedType][PayType] * RoomNum);
}

//手机号码验证，验证13系列和150-159(154除外)、180、185、186、187、188、189几种号码，长度11位
function isMobile(value) {   
    if((/^13\d{9}$/g.test(value)) || (/^15[0-35-9]\d{8}$/g.test(value)) || (/^18[05-9]\d{8}$/g.test(value)))
    {
        return true;
    }
    else
    {
        return false;
    }   
}

//Google地图
function ChooseGoogleAPIKey() {
    //已注册好的密钥
    var keyMapping = {
    'ljvip.cn': 'ABQIAAAAAjCY4XqgYMkw18NM8Gc1mRTKw087bRjKmrqmZRbg3Nu4P0o3UhQ0-iRC-ThoeXiX18eRPx5nn1JT4A',
    'www.ljvip.cn': 'ABQIAAAAAjCY4XqgYMkw18NM8Gc1mRTAyXbnwSaudz3EaZOWu4nYrGPQkhSDydLAT3lmUXrK8b7pB0wqrVtL-A'
     };
    //实际请求页面的域名
    var requestHost = window.location.hostname;
    //找到需要的密钥
    var key = keyMapping[requestHost];
    //构造加载API的script url
    var apiUrl = "http://maps.google.com/maps?file=api&v=2&key=" + key;
    //使用script动态加载的方法加载地图API
    document.write('<script type="text/javascript" charset="utf-8" src="' + apiUrl + '"><' + '/script>');
}
//获得坐标方法：
//登录：http://map.google.com 搜索地址，在地图上右键点击所要获取的地址的具体位置（未提高精确度，请尽量放大地图），点击“在此居中放置地图”
//然后在地址栏输入：javascript:void(prompt('',gApplication.getMap().getCenter())); 按回车，弹出的数据即为该地址坐标，如：18.22788391799234, 109.6329116821289
function GoogleMapShow(GMakerTitle,GooglePosition_Y, GooglePosition_X) {
    // 检查浏览器是否可以正确执行
    if (GBrowserIsCompatible()) {
        if (GooglePosition_Y == null || GooglePosition_Y == "" || GooglePosition_X == null || GooglePosition_X == "") {
            //document.getElementById("InsteadMap").style.display = "block";
            document.getElementById("map").innerHTML = "<iframe width='100%' height='100%' frameborder='0' scrolling='no' marginheight='0' marginwidth='0' src='http://maps.google.com/maps?f=q&amp;source=s_q&amp;hl=zh-CN&amp;geocode=&amp;q=" + GMakerTitle + "&amp;ie=UTF8&amp;output=embed'></iframe>";
        }
        else {
            //document.getElementById("InsteadMap").style.display = "none";
            // 指定GMap使用的图层
            var map = new GMap2(document.getElementById("map"));

            // 地图控制列
            map.addControl(new GSmallMapControl()); // 左侧控制列
            //map.addControl(new GMapTypeControl()); // 右上控制列
            map.enableScrollWheelZoom();    //鼠标滚轮控制放大与缩小


            // 坐标
            var point = new GLatLng(GooglePosition_Y, GooglePosition_X);
            // 坐标Y/X于API v1/v2的摆放位置是相反的
            map.setCenter(point, 12); // 放大倍率

            // 自订图标
            var TruckIcon = new GIcon(G_DEFAULT_ICON);
            TruckIcon.image = "http://www.ljvip.net/Images/Target.png";
            // 自订图标大小
            TruckIcon.iconSize = new GSize(20, 34);
            markerOptions = { icon: TruckIcon, title: GMakerTitle };

            // 设定坐标点使用自订图标
            var marker = new GMarker(point, markerOptions);
            map.addOverlay(marker);
            
            //新建弹出窗口
            var opts = {
                text: GMakerTitle
                };
            marker = new PopupMarker(point, opts);
            map.addOverlay(marker);
            
            //监听点击图标事件
            GEvent.addListener(marker, "click", function() {
                //marker.openInfoWindow(GMakerTitle);
                marker.hidePopup();
            });

            // 讯息
            //map.openInfoWindow(map.getCenter(), document.createTextNode("显示于地图中央的讯息"));
        }
        
    } else {
        alert("您的浏览器不支持Google Maps！！");
    }
}



/*酒店订单 选择,取消*/
function getObject(id) {
    return (document.getElementById) ? document.getElementById(id) : document.all[id];
}
function CheckedAll(myform) {
    var OrderNo = "";       //订单号
    var TotalPrice = 0;     //合计价格
    for (var i = 0; i < getObject(myform).elements.length; i++) {
        var e = getObject(myform).elements[i];
        if (e.type == 'checkbox' && e.name == 'CheckObject' && e.disabled == false) {
            e.checked = true;
            OrderNo = OrderNo + e.value + ",";
            TotalPrice = TotalPrice + parseFloat(getObject("td_totalprice_" + e.value).innerHTML);
        }
    }
    getObject('hdtoPayOrderNoBatch').value = OrderNo;
    getObject("tdTotalPrice").innerHTML = TotalPrice.toFixed(2);
    getObject("myselect").innerHTML = "[<a href=\"javascript:CancelAll('" + myform + "')\">取消</a>]";
}
function CancelAll(myform) {
    for (var i = 0; i < getObject(myform).elements.length; i++) {
        var e = getObject(myform).elements[i];
        if (e.type == 'checkbox' && e.name == 'CheckObject' && e.disabled == false) {
            e.checked = false;
        }
    }
    getObject('hdtoPayOrderNoBatch').value = "";
    getObject("tdTotalPrice").innerHTML = "0";
    getObject("myselect").innerHTML = "[<a href=\"javascript:CheckedAll('" + myform + "')\">全选</a>]";
}

function ChangePaySelect(myform) {
    var OrderNo = "";       //订单号
    var TotalPrice = 0;     //合计价格
    for (var i = 0; i < getObject(myform).elements.length; i++) {
        var e = getObject(myform).elements[i];
        if (e.type == 'checkbox' && e.name == 'CheckObject' && e.disabled == false && e.checked == true) {
            OrderNo = OrderNo + e.value + ",";
            TotalPrice = TotalPrice + parseFloat(getObject("td_totalprice_" + e.value).innerHTML);
        }
    }
    getObject('hdtoPayOrderNoBatch').value = OrderNo;
    getObject("tdTotalPrice").innerHTML = TotalPrice.toFixed(2);
}

function ChangePayType(chkValue){
    if(chkValue == "1"){
        //alert();
        $("tr[id*='Ips_']").attr("style","display:block;");
        $("#tdIps_2").html("").html("<select name=\"pIDType\" id=\"pIDType\"><option value=\"1\" selected=\"selected\">身份证</option><option value=\"2\">护照</option><option value=\"3\">军官证</option><option value=\"4\">回乡证</option><option value=\"5\">台胞证</option><option value=\"6\">港澳通行证</option><option value=\"7\">国际海员证</option><option value=\"8\">外国人永久居住证</option><option value=\"9\">其他</option></select>");
        $("#windown-content").height($("#windown-content").attr("scrollHeight"));
    }
    else{
        $("tr[id*='Ips_']").attr("style","display:none;");
        $("#tdIps_2").html("");
        $("#windown-content").height($("#windown-content").attr("scrollHeight"));
    }
}

function toSupport(Type,Id,_Obj){
    _Obj.onclick = null;
    _Obj.innerHTML = "请稍候";
    $("#Snum_"+Id).html(parseInt($("#Snum_"+Id).html())+1);
    $.get("HotelOrderAjax.aspx",{
        "Action":"toSupport",
        "Type":Type,
        "CommentId":Id},function(data){
        _Obj.innerHTML="已　顶";
    });
}

  function ClientItemSelected(source, e)
    {
      var node;
      var value = e.get_value();
      
      if (value) node = e.get_item();
      else
      {
        value = e.get_item().parentNode._value;
        node = e.get_item().parentNode;
      }
      
      var text = (node.innerText) ? node.innerText : (node.textContent) ? node.textContent : node.innerHtml;
      source.get_element().value = text.substring(text.lastIndexOf(' ')+1);      
    }
