﻿function index_return(obj){
    var $listStr = '';
    for(var o in obj[0]){
        if(!/^fun/.test(obj[0][o])){
            $listStr += '\
            <li>\
            <h3><a href="/'+obj[0][o].url+'jiudian/'+obj[0][o].id+'.html" target="_blank">'+obj[0][o].name+'</a> <img src="/images/alpha.gif" border="0" align="absmiddle" class="icon pa a23 a23a'+obj[0][o].star[0]+'" /></h3>\
            <div class="matter">\
            <dl>\
            <dt>\
            <div class="picture"><a href="/'+obj[0][o].url+'jiudian/'+obj[0][o].id+'-picture/" target="_blank" title="'+obj[0][o].name+'酒店图片"><img src="http://picture.99sleep.com/'+obj[0][o].picture+'" width="80" height="70" class="picture" />酒店图片</a></div>\
            <div class="vote">\
            人气：'+obj[0][o].popular+' \
            </div>\
            </dt>\
            <dd>\
            <div class="info">\
            <p>'+obj[0][o].information+'</p>\
            </div>\
            <div class="room">\
            <table borderColor="#C5DDF6" cellSpacing="0" cellPadding="0" width="100%" border="1">\
                <tbody>\
                <tr>\
                    <th width="27%" class="curtate">房型</th>\
                    <th width="8%">门市价</th>\
                    <th width="20%">首日价/详细</th>\
                    <th width="7%">早餐</th>\
                    <th width="8%">床型</th>\
                    <th width="10%">宽带</th>\
                    <th width="10%"></th>\
                </tr>';
            var book = '6';
            for(var r in obj[0][o].room){
                if(!/^fun/.test(obj[0][o].room[r])){
                    $listStr += '<tr>\
                        <td class="curtate">'+obj[0][o].room[r].name+'</td>\
                        <td class="shop">&yen;'+obj[0][o].room[r]["price-shop"]+'</td>\
                        <td class="price">'+(obj[0][o].room[r]["price-select"][0].split(':')[0]?'<strong>&yen;'+obj[0][o].room[r]["price-select"][0].split(':')[0]+'</strong>':'满房')+' <a href="javascript:;" onMouseOver="document.getElementById(\'_r'+obj[0][o].room[r].id+'\').style.display = \'\';" onMouseOut="document.getElementById(\'_r'+obj[0][o].room[r].id+'\').style.display = \'none\';">详细价格\
                    </a><div id="_r'+obj[0][o].room[r].id+'" class="price" style="display:none">\
                    <ul>\
                    <li class="w">周日</li><li class="w">周一</li><li class="w">周二</li><li class="w">周三</li><li class="w">周四</li><li class="w">周五</li><li class="w">周六</li>';
                    book = '6';
                    var dary = (new Date(document.getElementById("txtCheckIn").value.replace('-','/')).getDay());
                    if(dary==7)
                        dary = 0;
                    for(var day=0;day < dary;day++)
                        $listStr += '<li></li>';
                    for(var i=0;i<obj[0][o].num_day;i++){
                        if('_'+obj[0][o].room[r]["price-select"][i]=='_undefined')
                            obj[0][o].room[r]["price-select"].push('');
                    }
                    for(var i in obj[0][o].room[r]["price-select"]){
                        if(!/^fun/.test(obj[0][o].room[r]["price-select"][i])){
                            if(obj[0][o].room[r]["price-select"][i])
                                $listStr += '<li>'+obj[0][o].room[r]["price-select"][i].split(':')[0]+'<br />'+breakfast(obj[0][o].room[r]["price-select"][i].split(':')[1])+'</li>';
                            else{
                                $listStr += '<li class="x">满房</li>';
                                if(book!='7')
                                    book = '7';
                            }
                        }
                    }
                    $listStr += '</ul></div>\
                    </td>\
                        <td'+((r==0)?' class="first"':'')+'>'+breakfast(obj[0][o].room[r]["price-select"][0].split(':')[1])+'</td>\
                        <td'+((r==0)?' class="first"':'')+'>'+obj[0][o].room[r]["bed-type"]+'</td>\
                    <td'+((r==0)?' class="first"':'')+'>'+obj[0][o].room[r].internet+'</td>\
                    <td'+((r==0)?' class="first"':'')+'><form name="book_form'+obj[0][o].room[r].id+'" action="/room.php" method="get">\
                    <input type="hidden" name="id" value="'+obj[0][o].room[r].id+'" />\
                    <input type="hidden" name="check-in" value="'+document.getElementById("txtCheckIn").value+'" />\
                    <input type="hidden" name="check-out" value="'+document.getElementById("txtCheckOut").value+'" />\
                    <input type="submit" value="免费预订" />\
                    </form>\
                    </td>\
                    </tr>';
                    
                }
            }
            $listStr += '\
            </tbody>\
            </table>\
            </div>\
            </dd>\
            </dl>\
            </div>\
            </li>';
        }
    }
    document.getElementById("list").innerHTML = $listStr;
    document.getElementById("data-count").innerHTML = obj[1][0];
    document.getElementById("current").innerHTML = obj[1][2];
    document.getElementById("count").innerHTML = obj[1][1];
    
    if(obj[1][2]==0){
        document.getElementById("page_previous").className = 'icon pc c9';
        document.getElementById("page_previous").disabled = true;
    }else{
        document.getElementById("page_previous").className = 'icon pc c8';
        document.getElementById("page_previous").disabled = false;
    }
    if(obj[1][2]==(obj[1][1]-1)){
        document.getElementById("page_next").className = 'icon pc c9';
        document.getElementById("page_next").disabled = true;
    }else{
        document.getElementById("page_next").className = 'icon pc c8';
        document.getElementById("page_next").disabled = false;
    }
    unpop();
}


function detail_return(obj){
    var $listStr = '<table borderColor="#C5DDF6" cellSpacing="0" cellPadding="0" width="100%" border="1">\
                <tbody>\
                <tr>\
                    <th width="27%" class="curtate">房型</th>\
                    <th width="8%">门市价</th>\
                    <th width="20%">首日价/详细</th>\
                    <th width="7%">早餐</th>\
                    <th width="8%">床型</th>\
                    <th width="10%">宽带</th>\
                    <th width="10%"></th>\
                </tr>';
            
            
            var book = '6';
            for(var r in obj[0]){
                if(!/^fun/.test(obj[0][r])){
                    $listStr += '<tr>\
                        <td class="curtate">'+obj[0][r].name+'</td>\
                        <td class="shop">&yen;'+obj[0][r]["price-shop"]+'</td>\
                        <td class="price">'+(obj[0][r]["price-select"][0].split(':')[0]?'<strong>&yen;'+obj[0][r]["price-select"][0].split(':')[0]+'</strong>':'满房')+' <a href="javascript:;" onMouseOver="document.getElementById(\'_r'+obj[0][r].id+'\').style.display = \'\';" onMouseOut="document.getElementById(\'_r'+obj[0][r].id+'\').style.display = \'none\';">详细价格\
                    </a><div id="_r'+obj[0][r].id+'" class="price" style="display:none">\
                    <ul>\
                    <li class="w">周日</li><li class="w">周一</li><li class="w">周二</li><li class="w">周三</li><li class="w">周四</li><li class="w">周五</li><li class="w">周六</li>';
                    book = '6';
                    var dary = (new Date(document.getElementById("txtCheckIn2").value.replace('-','/')).getDay());
                    if(dary==7)
                        dary = 0;
                    for(var day=0;day < dary;day++)
                        $listStr += '<li></li>';
                    for(var i=0;i<obj[2][2];i++){
                        if('_'+obj[0][r]["price-select"][i]=='_undefined')
                            obj[0][r]["price-select"].push('');
                    }
                    for(var i in obj[0][r]["price-select"]){
                        if(!/^fun/.test(obj[0][r]["price-select"][i])){
                            if(obj[0][r]["price-select"][i])
                                $listStr += '<li>'+obj[0][r]["price-select"][i].split(':')[0]+'<br />'+breakfast(obj[0][r]["price-select"][i].split(':')[1])+'</li>';
                            else{
                                $listStr += '<li class="x">满房</li>';
                                if(book!='7')
                                    book = '7';
                            }
                        }
                    }
                    $listStr += '</ul></div>\
                    </td>\
                        <td'+((r==0)?' class="first"':'')+'>'+breakfast(obj[0][r]["price-select"][0].split(':')[1])+'</td>\
                        <td'+((r==0)?' class="first"':'')+'>'+obj[0][r]["bed-type"]+'</td>\
                    <td'+((r==0)?' class="first"':'')+'>'+obj[0][r].internet+'</td>\
                    <td'+((r==0)?' class="first"':'')+'><form name="book_form'+obj[0][r].id+'" action="/hotel-book.php" method="get">\
                    <input type="hidden" name="id" value="'+obj[0][r].id+'" />\
                    <input type="hidden" name="check-in" value="'+obj[2][0]+'" />\
                    <input type="hidden" name="check-out" value="'+obj[2][1]+'" />\
                    <input type="submit" value="预订" class="book" />\
                    </form></td>\
                    </tr>';
                    
                    
                    
                    
                    
                }
            }
            $listStr += '\
            </tbody>\
            </table>';
            document.getElementById("Rp").innerHTML = $listStr;
            document.getElementById("txtCheckIn").value = obj[2][0];
            document.getElementById("txtCheckOut").value = obj[2][1];
}



function change_return(obj){
    var $listStr = '<table borderColor="#C5DDF6" cellSpacing="0" cellPadding="0" width="100%" border="1">\
                <tbody>\
                <tr>\
                    <th width="27%" class="curtate">房型</th>\
                    <th width="8%">门市价</th>\
                    <th width="20%">首日价/详细</th>\
                    <th width="7%">早餐</th>\
                    <th width="8%">床型</th>\
                    <th width="10%">宽带</th>\
                    <th width="10%"></th>\
                </tr>';
            
            
            var book = '6';
            for(var r in obj[0]){
                if(!/^fun/.test(obj[0][r])){
                    $listStr += '<tr>\
                        <td class="curtate">'+obj[0][r].name+'</td>\
                        <td class="shop">&yen;'+obj[0][r]["price-shop"]+'</td>\
                        <td class="price">'+(obj[0][r]["price-select"][0].split(':')[0]?'<strong>&yen;'+obj[0][r]["price-select"][0].split(':')[0]+'</strong>':'满房')+' <a href="javascript:;" onMouseOver="document.getElementById(\'_r'+obj[0][r].id+'\').style.display = \'\';" onMouseOut="document.getElementById(\'_r'+obj[0][r].id+'\').style.display = \'none\';">详细价格\
                    </a><div id="_r'+obj[0][r].id+'" class="price" style="display:none">\
                    <ul>\
                    <li class="w">周日</li><li class="w">周一</li><li class="w">周二</li><li class="w">周三</li><li class="w">周四</li><li class="w">周五</li><li class="w">周六</li>';
                    book = '6';
                    var dary = (new Date(document.getElementById("txtCheckIn").value.replace('-','/')).getDay());
                    if(dary==7)
                        dary = 0;
                    for(var day=0;day < dary;day++)
                        $listStr += '<li></li>';
                    for(var i=0;i<obj[2][2];i++){
                        if('_'+obj[0][r]["price-select"][i]=='_undefined')
                            obj[0][r]["price-select"].push('');
                    }
                    for(var i in obj[0][r]["price-select"]){
                        if(!/^fun/.test(obj[0][r]["price-select"][i])){
                            if(obj[0][r]["price-select"][i])
                                $listStr += '<li>'+obj[0][r]["price-select"][i].split(':')[0]+'<br />'+breakfast(obj[0][r]["price-select"][i].split(':')[1])+'</li>';
                            else{
                                $listStr += '<li class="x">满房</li>';
                                if(book!='7')
                                    book = '7';
                            }
                        }
                    }
                    $listStr += '</ul></div>\
                    </td>\
                        <td'+((r==0)?' class="first"':'')+'>'+breakfast(obj[0][r]["price-select"][0].split(':')[1])+'</td>\
                        <td'+((r==0)?' class="first"':'')+'>'+obj[0][r]["bed-type"]+'</td>\
                    <td'+((r==0)?' class="first"':'')+'>'+obj[0][r].internet+'</td>\
                    <td'+((r==0)?' class="first"':'')+'><form name="changeform_'+obj[0][r].id+'" action="/hotel/item1/'+obj[1]+'/'+obj[0][r].id+'.html" method="post">\
                    <input type="hidden" name="check-in" value="'+obj[2][0]+'" />\
                    <input type="hidden" name="check-out" value="'+obj[2][1]+'" />\
                    <input type="hidden" name="id-order" value="'+obj[3]+'" />\
                    <input type="submit" value="'+((book=='7')?'查看':'预订')+'" class="icon pc c'+book+'" /></form></td>\
                    </tr>';
                    
                }
            }
            $listStr += '\
            </tbody>\
            </table>';
            document.getElementById("Rp").innerHTML = $listStr;
            document.getElementById("txtCheckIn").value = obj[2][0];
            document.getElementById("txtCheckOut").value = obj[2][1];
}


function index_send(current){
        var _return = false;
        try{
            var _uri = 'index.php';
            var _mode = 'post';
            var _parm = 'mode=text/ajax&hotel_city='+encodeURI(document.getElementById("txtCity").value)+'&check-in='+encodeURI(document.getElementById("txtCheckIn").value)+'&check-out='+encodeURI(document.getElementById("txtCheckOut").value)+'&hotel_location='+encodeURI(document.getElementById("txtLocation").value)+'&hotel_name='+encodeURI(document.getElementById("txtHotelName").value)+'&hotel_price='+encodeURI(document.getElementById("txtPrice").value);
                if(current)
                    _parm += '&page='+current;
                for(var v = 0;v < document.getElementById("av").getElementsByTagName("input").length;v++){
                    if(document.getElementById("av").getElementsByTagName("input")[v].checked)
                        _parm += document.getElementById("av").getElementsByTagName("input")[v].value;
                }
            var tsa = tsAjax;
            tsa.response = function(_){index_return(_);};
            tsa.send(_uri,_mode,_parm);
            pop();
        } catch (e) {
            alert(e.message);
            _return = true;
        }
        return _return;
}
function number_format(num, i)
{
    num = num.toFixed(i);
    if(!/^(\+|-)?(\d+)(\.\d+)?$/.test(num))
        return num;
    var a = RegExp.$1, b = RegExp.$2, c = RegExp.$3, d;
    var re = new RegExp().compile("(\\d)(\\d{3})(,|$)");
    while(re.test(b))
        b = b.replace(re, "$1,$2$3");
    return a + "" + b + "" + c;
}

function detail_tsAjax(objFrom){
    $("#Rp").html("<div class=\"load\">酒店实时价格载入中。。。</div>");
    var hotelid = $("#hotelid").val();
    var checkin = $("#txtCheckIn2").val();
    var checkout = $("#txtCheckOut2").val();
    $.getJSON("/hotel/price?hotelid=" + hotelid + "&checkin=" + checkin + "&checkout=" + checkout, function(json){
        var hotel = json[hotelid];
        var rooms = hotel["rooms"];
        /*var content = "<div class=\"price-list\"><ul>";
        var sumPrice = 0;
        for(var dpb in room["prices"]){
            content += "<li><span class=\"date\">" + dpb + "</span> <span class=\"price\">&yen;" + number_format(room["prices"][dpb]["price"], 2) + "</span></li>";
            sumPrice += Number(room["prices"][dpb]["price"]);
        }
        content += "</ul></div>";
        $("#sumprice").val(sumPrice);
        var total = (number * sumPrice);
        content += "<p>总天数：<strong>" + json["checkdays"] + "</strong>　　间数：<strong id=\"roomnumber\">"  + number + "</strong>　　总房价：<strong id=\"total\">&yen;" + number_format(total, 2) + "</strong>（无需提前付款，请到酒店前台支付）</p>";
        content += "<p>返　利：<strong id=\"bonus\">&yen;" + number_format(total * bonusratio, 2) + "</strong></p>";*/
        var content = '<table borderColor="#C5DDF6" cellSpacing="0" cellPadding="0" width="100%" border="1">\
            <tbody>\
            <tr>\
                <th width="27%" class="curtate">房型</th>\
                <th width="8%">门市价</th>\
                <th width="20%">首日价/详细</th>\
                <th width="7%">早餐</th>\
                <th width="8%">床型</th>\
                <th width="10%">宽带</th>\
                <th width="10%">返利</th>\
                <th width="10%"></th>\
            </tr>';
        for(var roomid in rooms)
        {
        /*
        
        <td class="price">'+(obj[0][r]["price-select"][0].split(':')[0]?'<strong>&yen;'+obj[0][r]["price-select"][0].split(':')[0]+'</strong>':'满房')+' <a href="javascript:;" onMouseOver="document.getElementById(\'_r'+obj[0][r].id+'\').style.display = \'\';" onMouseOut="document.getElementById(\'_r'+obj[0][r].id+'\').style.display = \'none\';">详细价格\
                    </a><div id="_r'+obj[0][r].id+'" class="price" style="display:none">\
                    <ul>\
                    <li class="w">周日</li><li class="w">周一</li><li class="w">周二</li><li class="w">周三</li><li class="w">周四</li><li class="w">周五</li><li class="w">周六</li>';
                    book = '6';
                    var dary = (new Date(document.getElementById("txtCheckIn").value.replace('-','/')).getDay());
                    if(dary==7)
                        dary = 0;
                    for(var day=0;day < dary;day++)
                        $listStr += '<li></li>';
                    for(var i=0;i<obj[2][2];i++){
                        if('_'+obj[0][r]["price-select"][i]=='_undefined')
                            obj[0][r]["price-select"].push('');
                    }
                    for(var i in obj[0][r]["price-select"]){
                        if(!/^fun/.test(obj[0][r]["price-select"][i])){
                            if(obj[0][r]["price-select"][i])
                                $listStr += '<li>'+obj[0][r]["price-select"][i].split(':')[0]+'<br />'+breakfast(obj[0][r]["price-select"][i].split(':')[1])+'</li>';
                            else{
                                $listStr += '<li class="x">满房</li>';
                                if(book!='7')
                                    book = '7';
                            }
                        }
                    }
                    $listStr += '</ul></div>\
                    </td>
        */
            //bonusratio
            var room = rooms[roomid];
            var price = '满房';
            if(room["status"] == 1)
            {
                price = '<strong>&yen;' + room["average"] + '</strong> <a href="javascript:;" onMouseOver="document.getElementById(\'_r'+roomid+'\').style.display = \'\';" onMouseOut="document.getElementById(\'_r'+roomid+'\').style.display = \'none\';">详细价格</a><div id="_r'+roomid+'" class="price" style="display:none"><ul>\
                    <li class="w">周日</li><li class="w">周一</li><li class="w">周二</li><li class="w">周三</li><li class="w">周四</li><li class="w">周五</li><li class="w">周六</li>';
                var dary = (new Date(checkin.replace('-','/')).getDay());
                if(dary==7)
                    dary = 0;
                for(var day=0;day < dary;day++)
                    price += '<li></li>';
                for(var i in room["prices"])
                {
                    var _price = room["prices"][i];
                    if(_price["status"] == 1)
                    {
                        price += '<li>' + _price["price"] + '<br />' + _price["breakfast"] + '</li>';
                    }
                    else
                    {
                        price += '<li class="x">满房</li>';
                    }
                }
                price += '</ul></div>';
                
            }
            content += '<tr>\
                    <td class="curtate">' + room["name"] + '</td>\
                    <td class="shop">&yen;' + room["marketprice"] + '</td>\
                    <td class="price">' + price + '</td>\
                    <td>' + room["breakfast"] + '</td>\
                    <td>' + room["bedtype"] + '</td>\
                    <td>' + room["internet"] + '</td>\
                    <td class="bonus"><strong>&yen;' + room["bonus"] + '</strong></td>\
                    <td><form name="book_form'+roomid+'" action="/hotel/book" method="get">\
                    <input type="hidden" name="hotelid" value="'+hotelid+'" />\
                    <input type="hidden" name="roomid" value="'+roomid+'" />\
                    <input type="hidden" name="checkin" value="'+json["checkin"]+'" />\
                    <input type="hidden" name="checkout" value="'+json["checkout"]+'" />\
                    <input type="submit" value="预订" class="book" />\
                    </form></td>\
                </tr>';
        }
        $("#Rp").html(content);
        return false;
    }, "json");
    return false;
    
    
    /*var _return = true;
    var nowDate = objFrom.txtNowDate2.value;
    var checkIn = objFrom.txtCheckIn2.value;
    var checkOut = objFrom.txtCheckOut2.value;
    var _checkIn = new Date(checkIn.replace('-','/'));
    var _checkOut = new Date(checkOut.replace('-','/'));
    var _nowDate = new Date(nowDate.replace('-','/'));
    if(_return && '_'+_checkIn=='_NaN'){
        alert('请正确填写您的入住日期！');
        objFrom.txtCheckIn2.focus();
        _return = false;
    }
    if(_return && '_'+_checkOut=='_NaN'){
        alert('请正确填写您的离店日期！');
        objFrom.txtCheckOut2.focus();
        _return = false;
    }
    if(_return && _checkOut<=_checkIn){
        objFrom.txtCheckOut2.focus();
        alert('离店日期不得小于或等于入住日期！');
        _return = false;
    }
    if(_return && _nowDate>_checkIn){
        alert('入住日期不得小于今天！');
        objFrom.txtCheckIn2.focus();
        _return = false;
    }
    if(_return){
        document.getElementById("Rp").innerHTML = '酒店实时价格载入中。。。</div>';
        var _return = false;
        try{
            var _uri = objFrom.action;
            var _mode = objFrom.method;
            var _parmArray = Array('mode=text/ajax');
            for(var f = 0;f<objFrom.getElementsByTagName('input').length;f++){
                if(objFrom.getElementsByTagName('input')[f].type=='text' || objFrom.getElementsByTagName('input')[f].type=='hidden')
                    _parmArray.push(objFrom.getElementsByTagName('input')[f].name+'='+objFrom.getElementsByTagName('input')[f].value);
            }
            var tsa = tsAjax;
            tsa.response = function(_){detail_return(_);};
            tsa.send(_uri,_mode,_parmArray.join('&'));
        } catch (e) {
            alert(e.message);
            _return = true;
        }
    }
    return _return;*/
}

function change_tsAjax(objForm){
        document.getElementById("Rp").innerHTML = '<div class="load">酒店实时价格载入中。。。</div>';
        var _return = false;
        try{
            var _uri = objForm.action;
            var _mode = objForm.method;
            var _parmArray = Array('mode=text/ajax');
            for(var f = 0;f<objForm.getElementsByTagName('input').length;f++){
                if(objForm.getElementsByTagName('input')[f].type=='text' || objForm.getElementsByTagName('input')[f].type=='hidden')
                    _parmArray.push(objForm.getElementsByTagName('input')[f].name+'='+objForm.getElementsByTagName('input')[f].value);
            }
            var tsa = tsAjax;
            tsa.response = function(_){change_return(_);};
            tsa.send(_uri,_mode,_parmArray.join('&'));
        } catch (e) {
            alert(e.message);
            _return = true;
        }
        return _return;
}

function breakfast($Inteval){
        $breakfast_array = Array();
        $breakfast_array[0] = '无';
        $breakfast_array[1] = '单早';
        $breakfast_array[2] = '双早';
        $breakfast_array[3] = '三早';
        $breakfast_array[4] = '四早';
        $breakfast_array[5] = '五早';
        $breakfast_array[6] = '六早';
        $breakfast_array[7] = '七早';
        $breakfast_array[8] = '八早';
        $breakfast_array[9] = '九早';
        $breakfast_array['*1'] = '每人一份';
        $breakfast_array['*2'] = '每人两份';
        $breakfast_array['*3'] = '每人三份';
        if($Inteval){
            $return_value = $breakfast_array[$Inteval];
        }else{
            $return_value = $breakfast_array[0];
        }
        return $return_value;
    }



function page(str){
        var count = Number(document.getElementById("count").innerHTML);
        var current = Number(document.getElementById("current").innerHTML);
        if(count!=0){
            if(str=='+'){
                if(current<count){
                    current++;
                    document.getElementById("page_next").className = 'icon pc c8';
                }else{
                    document.getElementById("page_next").className = 'icon pc c9';
                    document.getElementById("page_next").disabled = false;
                }
            }else if(str=='-'){
                if(current>0){
                    current--;
                    document.getElementById("page_previous").className = 'icon pc c8';
                }else{
                    document.getElementById("page_previous").className = 'icon pc c9';
                    document.getElementById("page_previous").disabled = false;
                }
            }
            index_send(current);
        }
    }


function priceSelect($int){
        var oTable = document.getElementById('room').getElementsByTagName('table')[0];
        if($int<=0){
            document.getElementById('PNum').style.display = 'none';
            for(var i = 1;i<oTable.getElementsByTagName('tr').length;i++){
                oTable.getElementsByTagName('tr').item(i).childNodes[3].innerHTML = '';
                oTable.getElementsByTagName('tr').item(i).childNodes[4].innerHTML = '';
            }
        }else{
            var PNumi = 0;
            for(var i = 1;i<oTable.getElementsByTagName('tr').length;i++){
                var $price = oTable.getElementsByTagName('tr')[i].children[1].innerHTML.replace('¥','').replace(/<[^><]+>/g,'');
                oTable.getElementsByTagName('tr')[i].children[3].innerHTML = $int+'间';
                oTable.getElementsByTagName('tr')[i].children[4].innerHTML = '&yen;'+($price*$int);
                PNumi += ($price*$int);
            }
            document.getElementById('price-sum').innerHTML = '&yen;'+PNumi;
            document.getElementById('PNum').style.display = '';
        }
        
    }

function room_tsAjax(objFormAction){
        document.getElementById('txtCheckIn').disabled = true;
        document.getElementById('txtCheckOut').disabled = true;
        document.getElementById("room").innerHTML = '房型实时价格载入中。。。';
        var _return = false;
        try{
            var _uri = objFormAction;
            var _mode = 'post';
            var _parmArray = Array('mode=text/ajax');
            _parmArray.push('check-in='+document.getElementById('txtCheckIn').value);
            _parmArray.push('check-out='+document.getElementById('txtCheckOut').value);
            var tsa = tsAjax;
            tsa.response = function(_){room_tsReturn(_);};
            tsa.send(_uri,_mode,_parmArray.join('&'));
        } catch (e) {
            alert(e.message);
            _return = true;
        }
        return _return;
}

    
function room_tsReturn($obj){
        var $obj_explode = $obj[0].split(',');
        var _return = '';
        _return += '<table borderColor="#C5DDF6" cellSpacing="0" cellPadding="0" width="480" border="1">\
<tbody>\
        <tr bgcolor="#F4F6FA">\
        <th width="18%" align="center">日期</th>\
        <th width="25%" align="center">房价</th>\
        <th width="15%" align="center">早餐</th>\
        <th width="17%" align="center">预订间数</th>\
        <th width="25%" align="center">小计</th>\
      </tr>';
        var day = 0;
        var priceSum = 0;
        
        for(var i=0;i<$obj[1][2];i++){
            if('_'+$obj_explode[i]=='_undefined')
            $obj_explode.push('');
        }
        
        for(var i in $obj_explode){
            if(!/^fun/.test($obj_explode[i])){
                var dateS = new Date($obj[1][0].replace("-","/"));
                dateS.setDate(dateS.getDate()+day);
                $obj_explode[i] = $obj_explode[i].split(':');
                _return += '<tr><td>'+dateS.getFullYear()+'-'+(dateS.getMonth()+1)+'-'+dateS.getDate()+'</td>\
                <td><strong>&yen;'+$obj_explode[i][0]+'</strong></td>\
                <td>'+breakfast($obj_explode[i][1])+'</td>';
                
                _return += '<td'+((day==0)?' class="first"':'')+'>';
                if(document.getElementById('txtCheckNumber').value!='0')
                    _return += document.getElementById('txtCheckNumber').value+'间';
                _return += '</td><td'+((day==0)?' class="first"':'')+' style="color:#ff9900">';
                if(document.getElementById('txtCheckNumber').value!='0')
                    _return += '&yen;'+($obj_explode[i][0]*document.getElementById('txtCheckNumber').value);
                _return += '</td></tr>';
                
                if(document.getElementById('txtCheckNumber').value!='0')
                priceSum += Number($obj_explode[i][0]*document.getElementById('txtCheckNumber').value)
                else
                priceSum += Number($obj_explode[i][0]);
                day++;
            }
        }
        _return += '</table>';
        document.getElementById('room').innerHTML = _return;
        if(document.getElementById('txtCheckNumber').value!='0'){
            document.getElementById('price-sum').innerHTML = '&yen;'+priceSum;
        }
        document.getElementById('txtCheckIn').value = $obj[1][0];
        document.getElementById('txtCheckOut').value = $obj[1][1];
        document.getElementById('txtCheckIn').disabled = false;
        document.getElementById('txtCheckOut').disabled = false;
    }
