﻿var number = Math.random();

function hello(obj) {
    alert(obj);
}

/// <summary>
/// 创建 XmlHttpRequest 对象
/// </summary>
function GetHttpObject() {
    if (typeof XMLHttpRequest != 'undefined') return new XMLHttpRequest();

    try {
        return new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch(e) {
        try {
            return new ActiveXObject("Microsoft.XMLHTTP");
        }
        catch(e) {}
    }

    return false;
}

/// <summary> 
///Creates a client callback back to the requesting page
/// and calls the callback method with the response as parameter.
/// </summary>
function CreateCallback(url, callback, calling) {
    var http = GetHttpObject();
    http.open("GET", url, true);

    http.onreadystatechange = function () {
        if (http.readyState != 4) {
            calling();
        }
        if (http.readyState == 4) {
            if (http.responseText.length > 0 && callback != null) callback(http.responseText);
        }
    };
    http.send(null);
}

/// <summary> 
///Creates a client callback back to the requesting page
/// and calls the callback method with the response as parameter.
/// </summary>
function CreateProductCallback(url, callback, calling, startcity) {
    var http = GetHttpObject();
    http.open("GET", url, true);

    http.onreadystatechange = function () {
        if (http.readyState != 4) {
            calling(startcity);
        }
        if (http.readyState == 4) {
            if (http.responseText.length > 0 && callback != null) callback(http.responseText, startcity);
        }
    };
    http.send(null);
}

// 上面
//id 目的地 ，type 类别
function treecall(id, type) {
    number++;
    // alert(type);
    CreateCallback("/tree.axd?id=" + id + "&type=" + type + "&ron=" + number, treeback, calling);
}

function treeback(response) {
    //alert(response);
    $("#divcontent").html(response);
}

function calling() {
    //  $("#divcontent").html("<img src='picImages/loadinfoBlue.gif'></img>");
}
/**
//线路
*/
//id 目的地,type 排序类别，startcity 出发城市，mtype 类别，pageid 页吗
function pcall(id, type, startcity, mtype, pageid, searchtype) {
    number++;
    CreateProductCallback("product.axd?id=" + id + "&type=" + type + "&startcity=" + startcity + "&mtype=" + mtype + "&pageid=" + pageid + "&ron=" + number + "&searchtype=" + searchtype, pback, pcalling, startcity);
}
//线路
function pcalling(obj) {
    $("#show" + obj).html("<img src='/picImages/loadinfoBlue.gif'></img>");
}
function pback(response, obj) {
    $("#show" + obj).html(response);

}
/**
//线路
*/
//id 目的地,type 排序类别，startcity 出发城市，mtype 类别，pageid 页吗
function sort(id, type, startcity, mtype, pageid, searchtype) {
    pcall(id, type, startcity, mtype, pageid, searchtype);
}
// shen fenye
function shencallback(response, obj) {
    $("#router" + obj).html(response);
    // document.getElementById("shendiv").innerHTML=response;
}
//id 景点id startcity 出发城市 type 排序类别 searchtype 查询类别 ischina 是否为中国
function shencall(id, startcity, type, searchtype, ischina) {
    number++;
    CreateProductCallback("/product.axd?shenid=" + id + "&startcity=" + startcity + "&ron=" + number + "&searchtype=" + searchtype + "&type=" + type + "&ischina=" + ischina, shencallback, shencalling, startcity);
}

function shencalling(obj) {
    $("#router" + obj).html("<img src='/picImages/loadinfoBlue.gif'></img>");
}

/*自由行**/
function tripcall(type, startcity, pageid) {
    number++;
    CreateCallback("/trip.axd?type=" + type + "&startcity=" + startcity + "&pageid=" + pageid + "&ron=" + number, tripback, tripcalling);

}
function tripback(response) {
    // alert(response);
    $("#tripdiv").html(response);
}
function tripcalling() {

}
function tripsort(type, startcity, pageid) {
    number++;
    // alert(type); alert(startcity); alert(pageid);
    tripcall(type, startcity, pageid);
}
function jingdiancall(treeid, type) {
    number++;
    //alert(treeid);
    //alert(type);
    CreateCallback("/jingdian.axd?type=" + type + "&treeid=" + treeid + "&ron=" + number, jingdiancback, jingdiancalling);
}
function jingdiancalling() {

}
function jingdiancback(response) {
    //   alert(response);
    $("#jingdiandiv").html(response);
}
function jingdiansort(treeid, type) {
    // alert(treeid);  alert(type);
    jingdiancall(treeid, type);
}

/*自由行**/
function tripcall(type, startcity, pageid) {
    number++;
    CreateCallback("/trip.axd?type=" + type + "&startcity=" + startcity + "&pageid=" + pageid + "&ron=" + number, tripback, tripcalling);

}
function tripback(response) {
    //alert(response);
    $("#tripdiv").html(response);
}
function tripcalling() {

}
function tripsort(type, startcity, pageid) {
    number++;
    //alert(type); alert(startcity); alert(pageid);
    tripcall(type, startcity, pageid);
}

//visa lulisheng
function visacall(treeid) {
    number++;
    //  alert(treeid);
    CreateCallback("/visaHandler.axd?tid=" + treeid + "&ron=" + number, visacallback, visacalling);
}
function visacalling() {}
function visacallback(response) {
    //alert(response);
    $("#visatype").remove();
    $("#divvisatype").html(response);
}

function treetripcall(pageid, treeid, startcity, column, searchtype) {
    // alert(pageid);  alert(treeid);alert(startcity);  alert(column);
    //  CreateCallback("trip.axd?pageid="+pageid+"&treeid="+treeid+"&startcity="+startcity+"&type="+column+"&ron="+number+"&searchtype=1", treetripback,treetripcalling);
    CreateProductCallback("trip.axd?pageid=" + pageid + "&treeid=" + treeid + "&startcity=" + startcity + "&type=" + column + "&ron=" + number + "&searchtype=" + searchtype, treetripback, treetripcalling, startcity);

}
function treetripcalling(obj) {
    $("#show" + obj).html("<img src='/picImages/loadinfoBlue.gif'></img>");
}
function treetripback(response, obj) {
    $("#show" + obj).html(response);
}
function weathercall(treename) {
    // alert(treename);
    number++;
    CreateCallback("/weather.aspx?treename=" + escape(treename) + "&ron=" + number, weathercback, weathercalling);
}
function weathercback(response) {
    //alert(response);
    document.getElementById("weatherul").innerHTML = response;
}
function weathercalling() {}
function regioncall(treeid, type, t) {
    number++;
    CreateCallback("/go/TravelHandler.ashx?type=" + type + "&treeid=" + treeid + "&t=" + t + "&ron=" + number, regioncback, regioncalling);
}
function regioncalling() {

}
function regioncback(response) {
    //alert(response);
    document.getElementById("jingdiandiv").innerHTML = response;
}
function regionsort(treeid, type, t) {
    regioncall(treeid, type, t);
}

function searchchat(pageid, type, size) {
    number++;
    CreateCallback("../../Manager/M_content/AjaxSearchChat.aspx?pageid=" + pageid + "&type=" + type + "&size=" + size + "&ron=" + number, searchchatcallback, searchcalling);
}
function searchchatcallback(response) {
    $("#chatdiv").html(response);
    chatleft();
}
function searchcalling() {

}
function deleteassesstype(obj) {
    CreateCallback("../../Manager/M_company/UpdateAssessType.aspx?assessTypeID=" + obj + "&action=del", deleteassesstyped, deleteassesstypeing);
}
function deleteassesstypeing() {

}
function deleteassesstyped(response) {
    alert(response);
}
//得到个人图表
function getpersonChat(obj, year, month, type) {
    number++;
    CreateCallback("../../Manager/M_company/AssessChat.aspx?adminid=" + obj + "&year=" + year + "&month=" + month + "&type=" + type + "&num=" + number, getpersonChatBack, getpersonChatCalling);
}
function getpersonChatBack(response) {
    $("#personChat").html(response);
}
function getpersonChatCalling() {
    $("#personChat").html("<img src='/picImages/loadinfoBlue.gif'></img>");
}
//得到个人图表详细信息
function getpersonChatInfo(obj, year, month, type) {
    number++;
    CreateCallback("../../Manager/M_company/AssessChat.aspx?adminid=" + obj + "&year=" + year + "&month=" + month + "&type=" + type + "&num=" + number, getpersonChatInfoBack, getpersonChatInfoCalling);
}
function getpersonChatInfoBack(response) {
    $("#AssessInfo").html(response);
}
function getpersonChatInfoCalling() {}

//得到所有人图表
function getallchat(year, month, type) {
    number++;
    CreateCallback("../../Manager/M_company/AssessChat.aspx?year=" + year + "&month=" + month + "&type=" + type + "&num=" + number, getallChatBack, getallChatCalling);
}
function getallChatBack(response) {
    $("#allchat").html(response);
}
function getallChatCalling() {}
function getallChatCalling() { }
function searchkeycall() {
    number++;
    CreateCallback("../search/ajaxsearchkey.aspx?ron="+ number, searchkeycback, searchkeycalling);
}
function searchkeycback(response) {
    $("#search_link").html(response);
}
function searchkeycalling() { }