function index_return(obj){
    var $listStr = '';
    for(var o in obj[0]){
        if(!/^fun/.test(obj[0][o])){
            $listStr += '\
            <li>\
            <div class="matter">\
            <dl>\
            <dt>\
            <div class="picture"><a href="cn/'+obj[0][o].id+'.htm" 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">\
            <h3><a href="cn/'+obj[0][o].id+'.htm" 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>\
            <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"':'')+'><a href="/hotel/item1/'+obj[0][o].id+'/'+obj[0][o].room[r].id+'.html" class="icon pc c'+book+'" target="_blank">'+((book=='7')?'查看':'预订')+'</a></td>\
                    </tr>';
                    
                    
                }
            }
            $listStr += '\
            </tbody>\
            </table>\
            </div>\
            <div class="more"><a href="/hotel/cn/'+obj[0][o].id+'.htm" target="_blank">显示全部房型</a></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];
    document.getElementById("data-count2").innerHTML = document.getElementById("data-count").innerHTML;
    document.getElementById("current2").innerHTML = document.getElementById("current").innerHTML;
    document.getElementById("count2").innerHTML = document.getElementById("count").innerHTML;
    
    if(obj[1][2]==0){
        document.getElementById("page_previous").className = 'icon pc c9';
        document.getElementById("page_previous2").className = 'icon pc c9';
        document.getElementById("page_previous").disabled = true;
        document.getElementById("page_previous2").disabled = true;
    }else{
        document.getElementById("page_previous").className = 'icon pc c8';
        document.getElementById("page_previous2").className = 'icon pc c8';
        document.getElementById("page_previous").disabled = false;
        document.getElementById("page_previous2").disabled = false;
    }
    if(obj[1][2]==(obj[1][1]-1)){
        document.getElementById("page_next").className = 'icon pc c9';
        document.getElementById("page_next2").className = 'icon pc c9';
        document.getElementById("page_next").disabled = true;
        document.getElementById("page_next2").disabled = true;
    }else{
        document.getElementById("page_next").className = 'icon pc c8';
        document.getElementById("page_next2").className = 'icon pc c8';
        document.getElementById("page_next").disabled = false;
        document.getElementById("page_next2").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="detailform_'+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="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 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;
                }
        //alert(_parm);
            var tsa = tsAjax;
            tsa.response = function(_){index_return(_);};
            tsa.send(_uri,_mode,_parm);
            pop();
        } catch (e) {
            alert(e.message);
            _return = true;
        }
        return _return;
}

function detail_tsAjax(objFrom){
    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 class="load"><img src="/images/min_loading.gif" width="16" height="16" align="absmiddle" /> 酒店实时价格载入中。。。</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"><img src="/images/min_loading.gif" width="16" height="16" align="absmiddle" /> 酒店实时价格载入中。。。</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 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';
                    document.getElementById("page_next2").className = 'icon pc c8';
                }else{
                    document.getElementById("page_next").className = 'icon pc c9';
                    document.getElementById("page_next2").className = 'icon pc c9';
                    document.getElementById("page_next").disabled = false;
                    document.getElementById("page_next2").disabled = false;
                }
            }else if(str=='-'){
                if(current>0){
                    current--;
                    document.getElementById("page_previous").className = 'icon pc c8';
                    document.getElementById("page_previous2").className = 'icon pc c8';
                }else{
                    document.getElementById("page_previous").className = 'icon pc c9';
                    document.getElementById("page_previous2").className = 'icon pc c9';
                    document.getElementById("page_previous").disabled = false;
                    document.getElementById("page_previous2").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){
    var _return = true;
    var nowDate = document.getElementById('txtNowDate').value;
    var checkIn = document.getElementById('txtCheckIn').value;
    var checkOut = document.getElementById('txtCheckOut').value;
    var _checkIn = new Date(checkIn.replace('-','/'));
    var _checkOut = new Date(checkOut.replace('-','/'));
    var _nowDate = new Date(nowDate.replace('-','/'));
    if(_return && '_'+_checkIn=='_NaN'){
        alert('请正确填写您的入住日期！');
        document.getElementById('txtCheckIn').focus();
        _return = false;
    }
    if(_return && '_'+_checkOut=='_NaN'){
        alert('请正确填写您的离店日期！');
        document.getElementById('txtCheckOut').focus();
        _return = false;
    }
    if(_return && _checkOut<=_checkIn){
        document.getElementById('txtCheckOut').focus();
        alert('离店日期不得小于或等于入住日期！');
        _return = false;
    }
    if(_return && _nowDate>_checkIn){
        alert('入住日期不得小于今天！');
        document.getElementById('txtCheckIn').focus();
        _return = false;
    }
    if(_return){
        document.getElementById('txtCheckOut').disabled = true;
        document.getElementById('txtCheckIn').disabled = true;
        document.getElementById("room").innerHTML = '房型实时价格载入中。。。';
        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>\
        <th width="18%">日期</th>\
        <th width="25%">房价</th>\
        <th width="15%">早餐</th>\
        <th width="17%">预订间数</th>\
        <th width="25%">小计</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()+'-'+(Number(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('check-number').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;
    }