﻿$(document).ready(function() {
    $("#showDj").hover(function() {
        $('<div id="tooltip"  class="tooltip" style="z-index:5"><span class="t_top"></span><p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;当地接待是指您在同程网上预订了地接线路，当到达该线路目的地后由提供该线路的当地旅行社为您提供接待服务。</p><span class="t_bottom"></span></div>').insertAfter(this);
        $(this).mouseover(function(e) {
            var iptOffSet = $(this).offset();
            var iptLeft = iptOffSet.left + 40;
            var iptTop = iptOffSet.top - 40;
            $("#tooltip").css({
                "left": e.pageX,
                "top": e.pageY + 5,
                "display": "block"
            });
        });
    },
    function() {
        $("#tooltip").remove();
    })
});
function GetVisit(self, lineId, categoryId) {
    var viId = 'Visit_' + lineId + "_" + categoryId;
    var caId = 'Calendar_' + lineId + "_" + categoryId;
    var dpId = 'dp_' + lineId + '_' + categoryId;
    var tqId = 'tq_' + lineId + '_' + categoryId;
    if (document.getElementById(viId).innerHTML != '') {
        document.getElementById(viId).innerHTML = '';
        document.getElementById(dpId).innerHTML = "点评▼";
        return;
    }
    var postData = 'lineId=' + lineId + "&categoryId=" + categoryId + "&Type=GetVisit" + "&s=" + Math.random();
    $.ajax({
        type: 'Post',
        url: globeAjaxAdrr,
        data: postData,
        complete: function(data) {
            var msg = data.responseText;
            if (msg != '0') {
                if (document.getElementById(caId).innerHTML != '') {
                    document.getElementById(caId).innerHTML = '';
                }
                document.getElementById(viId).innerHTML = msg;
                document.getElementById(dpId).innerHTML = "点评▲";
            }
        }
    });
}
function GetTeamVisit(self, lineId, categoryId) {
    var viId = 'Visit_' + lineId + "_" + categoryId + "_Team";
    var caId = 'Calendar_' + lineId + "_" + categoryId + "_Team";
    var dpId = 'dp_' + lineId + '_' + categoryId + "_Team";
    var tqId = 'tq_' + lineId + '_' + categoryId + "_Team";
    if (document.getElementById(viId).innerHTML != '') {
        document.getElementById(viId).innerHTML = '';
        document.getElementById(dpId).innerHTML = "点评▼";
        return;
    }
    var postData = 'lineId=' + lineId + "&categoryId=" + categoryId + "&Type=GetVisit" + "&s=" + Math.random();
    $.ajax({
        type: 'Post',
        url: globeAjaxAdrr,
        data: postData,
        complete: function(data) {
            var msg = data.responseText;
            if (msg != '0') {
                if (document.getElementById(caId).innerHTML != '') {
                    document.getElementById(caId).innerHTML = '';
                }
                document.getElementById(viId).innerHTML = msg;
                document.getElementById(dpId).innerHTML = "点评▲";
            }
        }
    });
}
function GetCalendar(self, lineId, categoryId, curMonth, curYear) {
    var viId = 'Visit_' + lineId + "_" + categoryId;
    var caId = 'Calendar_' + lineId + '_' + categoryId;
    var tqId = 'tq_' + lineId + '_' + categoryId;
    var dpId = 'dp_' + lineId + '_' + categoryId;
    if (document.getElementById(caId).innerHTML != '') {
        document.getElementById(caId).innerHTML = '';
        document.getElementById(tqId).innerHTML = "团期▼";
        return;
    }
    var postData = 'lineId=' + lineId + '&categoryId=' + categoryId +
    "&curMonth=" + curMonth +
    "&curYear=" + curYear +
     "&Type=GetCalendar" + "&s=" + Math.random();
    $.ajax({
        type: 'Post',
        url: globeAjaxAdrr,
        data: postData,
        complete: function(data) {
            var msg = data.responseText;
            if (msg != '0') {
                if (document.getElementById(viId).innerHTML != '') {
                    document.getElementById(viId).innerHTML = '';
                }
                document.getElementById(caId).innerHTML = msg;
                document.getElementById(tqId).innerHTML = "团期▲";
            }
        }
    });
}

$(document).ready(function() {
    $("#perNative").click(function(event) {
        $("#addr").insertAfter(this);
        var iptOffSet = $(this).offset();
        var iptLeft = iptOffSet.left - 50;
        var iptTop = iptOffSet.top + 20;
        $("#addr").css({ left: iptLeft + "px", top: iptTop + "px" });
        $("#addr").css({ "display": "block" });
    });
    $("#gb").click(function(event) {
        $("#addr").css({ "display": "none" });
    });
});

function GetNextNewCalendar(self, lineId, categoryId, curMonth, curYear) {
    var divCaId = 'div_Calendar_' + lineId + '_' + categoryId;
    var postData = 'lineId=' + lineId + '&categoryId=' + categoryId +
    "&curMonth=" + curMonth +
    "&curYear=" + curYear +
     "&Type=GetTagNewCalendar" + "&s=" + Math.random();
    $.ajax({
        type: 'Post',
        url: globeAjaxAdrr,
        data: postData,
        complete: function(data) {
            var msg = data.responseText;
            if (msg != '0') {
                document.getElementById(divCaId).innerHTML = msg;
            }
        }
    });
}
function GetNewCalendar(self, lineId, categoryId, curMonth, curYear) {
    var trviId = 'tr_Visit_' + lineId + "_" + categoryId;
    var trcaId = 'tr_Calendar_' + lineId + '_' + categoryId;
    var tdviId = 'td_Visit_' + lineId + "_" + categoryId;
    var tdcaId = 'td_Calendar_' + lineId + '_' + categoryId;
    var divCaId = 'div_Calendar_' + lineId + '_' + categoryId;
    var sptqId = 'tq_' + lineId + '_' + categoryId;
    var spdpId = 'dp_' + lineId + '_' + categoryId;
    if (document.getElementById(spdpId) != null)
        document.getElementById(spdpId).className = "dp01";
    if (document.getElementById(divCaId).innerHTML != '') {
        document.getElementById(divCaId).innerHTML = '';
        document.getElementById(trcaId).style.display = "none";
        document.getElementById(tdcaId).style.display = "none";
        document.getElementById(sptqId).className = "dp01";
        return;
    }
    document.getElementById(trcaId).style.display = "";
    document.getElementById(tdcaId).style.display = "";
    var postData = 'lineId=' + lineId + '&categoryId=' + categoryId +
    "&curMonth=" + curMonth +
    "&curYear=" + curYear +
     "&Type=GetTagNewCalendar" + "&s=" + Math.random();
    $.ajax({
        type: 'Post',
        url: globeAjaxAdrr,
        data: postData,
        complete: function(data) {
            var msg = data.responseText;
            if (msg != '0') {
                if (document.getElementById(tdviId).innerHTML != '') {
                    document.getElementById(tdviId).innerHTML = '';
                    document.getElementById(tdviId).style.display = "none";
                    document.getElementById(trviId).style.display = "none";
                }
                if (document.getElementById(divCaId) != null)
                    document.getElementById(divCaId).innerHTML = msg;
                document.getElementById(sptqId).className = "dp02";
            }
        }
    });
}
function GetCalendarNext(self, lineId, categoryId, curMonth, curYear) {
    var caId = 'Calendar_' + lineId + '_' + categoryId;
    var postData = 'lineId=' + lineId + '&categoryId=' + categoryId +
    "&curMonth=" + curMonth +
    "&curYear=" + curYear +
     "&Type=GetCalendar" + "&s=" + Math.random();
    $.ajax({
        type: 'Post',
        url: globeAjaxAdrr,
        data: postData,
        complete: function(data) {
            var msg = data.responseText;
            if (msg != '0') {
                document.getElementById(caId).innerHTML = '';
                document.getElementById(caId).innerHTML = msg;
            }
        }
    });
}
$(document).ready(function() {
    var postData = "Type=GetQuestionHelp" + "&s=" + Math.random();
    $.ajax({
        type: 'Post',
        url: globeAjaxAdrr,
        data: postData,
        complete: function(data) {
            var msg = data.responseText;
            document.getElementById("questionHelp").innerHTML = msg;
        }
    });
});
function SearchLineInfo() {
    var departureCity = $("#txtDepartureCity").val();
    var destinationCity = $("#txtDestinationCity").val();
    window.location.href = globeUrl + "LineQuery.aspx?DepartureCity=" + encodeURIComponent(departureCity) +
    "&DestinationCity=" + encodeURIComponent(destinationCity) + "&page=1";
}

function showInfo(event1, clickDate, lineid) {
    var msgDiv = document.getElementById('divMsg');
    var s = "<div style=\"text-align:center;border-collapse:collapse;\" id=\"loadMessage\"><img src=\"http://img.17u.cn/ly/cn/img/loading_16x16.gif\" alt=\"正在加载数据请您稍候...\" />正在加载数据...</div>";
    msgDiv.innerHTML = s;
    var e = event1;
    var clinetX = e.clientX;
    var clientY = e.clientY;

    //获取浏览器类型
    var Sys = {};
    var ua = navigator.userAgent.toLowerCase();
    var s;
    (s = ua.match(/msie ([\d.]+)/)) ? Sys.ie = s[1] :
            (s = ua.match(/firefox\/([\d.]+)/)) ? Sys.firefox = s[1] :
            (s = ua.match(/chrome\/([\d.]+)/)) ? Sys.chrome = s[1] :
            (s = ua.match(/opera.([\d.]+)/)) ? Sys.opera = s[1] :
            (s = ua.match(/version\/([\d.]+).*safari/)) ? Sys.safari = s[1] : 0;

    var top = clientY + document.documentElement.scrollTop + (e.offsetY == undefined ? 0 : e.offsetY) - 10;
    var left = clinetX + document.documentElement.scrollLeft - (e.offsetX == undefined ? 0 : e.offsetX) - 5;
    if (Sys.ie) {
        top = document.documentElement.scrollTop + e.clientY;
        left = document.documentElement.scrollLeft + e.clientX;
    }
    msgDiv.style.left = left + "px";
    msgDiv.style.top = top + "px";
    msgDiv.style.display = "";

    $.ajax({
        type: 'Post',
        url: globeUrl + "AjaxCall.aspx",
        data: "Type=GetTagPricesByClickDate&clickDate=" + clickDate + "&lineSerialId=" + lineid + "&s=" + Math.random(),
        complete: function(data) {
            var dataInfo = data.responseText;
            document.getElementById('divMsg').innerHTML = dataInfo;
        }
    });
}
//隐藏价格体系层
function hidPricesInfo() {
    document.getElementById('divMsg').style.display = 'none';
}
//日历里面的预定
function calendarBook(date, lineId) {
    var adultCount = 0;
    var childCount = 0;
    if (document.getElementById("txtShowAdult") != null) {
        if (isNumber($("#txtShowAdult").val()))
            adultCount = document.getElementById("txtShowAdult").value;
        else {
            alert("请输入正确的数字!");
            return;
        }
    }
    if (document.getElementById("txtShowChild") != null) {
        if (isNumber($("#txtShowChild").val()))
            childCount = document.getElementById("txtShowChild").value;
        else {
            alert("请输入正确的数字!");
            return;
        }

    }
    newTourBook(date, adultCount, childCount, lineId);
}
function newTourBook(bookDate, adult, child, lineId) {
    if (bookDate != null && bookDate != "" && bookDate != "undefined") {
        var urldata = "?adult=" + adult + "&child=" + child + "&bookdate=" + bookDate + "&id=" + lineId;
        window.location.href = globeUrl + 'linebook1.aspx' + urldata;
    }
    else {
        alert('对不起，预定日期没有获取到，无法进入到预定页面，请重试！');
    }
}
