﻿var div_search_index = "";
var search_path = "Ajax/SearchAction.ashx";
var div_show = "div_search_show";
var div_show_ = "div_show_";
var div_open_ = "div_open_";
var div_close_ = "div_close_";
var div_order = "order";

function setNil() {
    document.getElementById(div_show).innerHTML = "<br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>";
}
function doShow() {
    if (isSussecc()) {
        removeSearch();
        document.getElementById("div_copy").style.display = "none";
        document.getElementById(div_show).innerHTML = getAjaxText();
    }
}
function doLook() {
    if (isSussecc()) {
        showOrder();
        document.getElementById(div_order).innerHTML = getAjaxText();
    }
}
function doOpen_1() {
    if (isSussecc()) {
        document.getElementById(div_show_ + div_search_index).innerHTML = getAjaxText();
        document.getElementById(div_show_ + div_search_index).style.display = "block";
        document.getElementById(div_open_ + div_search_index).style.display = "none";
        document.getElementById(div_close_ + div_search_index).style.display = "block";
    }
}
function doOpen_2(i) {
    document.getElementById(div_show_ + i).style.display = "block";
    document.getElementById(div_open_ + i).style.display = "none";
    document.getElementById(div_close_ + i).style.display = "block";
}
function open(i) {
    if (document.getElementById(div_show_ + i).innerHTML == "") {
        div_search_index = i;
        doAjaxQuick("doOpen_1", search_path, "operator", "open", "i", i);
    }
    else {
        doOpen_2(i);
    }
}
function open_double(i) {
    if (document.getElementById(div_show_ + i).innerHTML == "") {
        div_search_index = i;
        doAjaxQuick("doOpen_1", search_path, "operator", "opendouble", "i", i);
    }
    else {
        doOpen_2(i);
    }
}
function open_back(i) {
    if (document.getElementById(div_show_ + i).innerHTML == "") {
        div_search_index = i;
        doAjaxQuick("doOpen_1", search_path, "operator", "openback", "i", i);
    }
    else {
        doOpen_2(i);
    }
}
function close(i) {
    document.getElementById(div_show_ + i).style.display = "none";
    document.getElementById(div_open_ + i).style.display = "block";
    document.getElementById(div_close_ + i).style.display = "none";
}
function show() {
    var return_date = document.getElementById("return_date").value;
    if (return_date == '') {
        doAjaxQuick("doShow", search_path, "operator", "searchsolo", "fromCity", getCity("txtCity"), "toCity", getCity("txtCity0"), "airDate", document.getElementById("depart_date").value, "airCo", document.getElementById("airCo").value, "airTime", document.getElementById("airTime").value);
    } else {
        document.getElementById("hdn_return_date").value = return_date;
        doAjaxQuick("doShow", search_path, "operator", "searchdouble", "fromCity", getCity("txtCity"), "toCity", getCity("txtCity0"), "airDate", document.getElementById("depart_date").value, "airCo", document.getElementById("airCo").value, "airTime", document.getElementById("airTime").value);
    }
    showSearch();
}
function show_back(i, j) {
    doAjaxQuick('doShow', search_path, "operator", "searchback", "i", i, "j", j, "airDate", document.getElementById("hdn_return_date").value);
    showSearch();
}
function doSort() {
    var rdo;
    if (document.getElementById("rdoAmt").checked) {
        rdo = document.getElementById("rdoAmt").value;
    } else if (document.getElementById("rdoTime").checked) {
        rdo = document.getElementById("rdoTime").value;
    } else {
        rdo = document.getElementById("rdoCo").value;
    }
    var ckb;
    if (document.getElementById("ckbTrue").checked) {
        ckb = "true";
    } else {
        ckb = "false";
    }
    doAjaxQuick('doShow', search_path, 'operator', 'sortsolo', 'fromCity', document.getElementById('hdnFromCity').value, 'toCity', document.getElementById('hdnToCity').value, 'airDate', document.getElementById('hdnAirTime').value, 'airTime', document.getElementById('hdnAirTime').value, 'airCo', document.getElementById('hdnAirCo').value, 'orderby', rdo, 'asc', ckb);
    showSearch();
}
function doSort_double() {
    var rdo;
    if (document.getElementById("rdoAmt").checked) {
        rdo = document.getElementById("rdoAmt").value;
    } else if (document.getElementById("rdoTime").checked) {
        rdo = document.getElementById("rdoTime").value;
    } else {
        rdo = document.getElementById("rdoCo").value;
    }
    var ckb;
    if (document.getElementById("ckbTrue").checked) {
        ckb = "true";
    } else {
        ckb = "false";
    }
    doAjaxQuick('doShow', search_path, 'operator', 'sortdouble', 'fromCity', document.getElementById('hdnFromCity').value, 'toCity', document.getElementById('hdnToCity').value, 'airDate', document.getElementById('hdnAirTime').value, 'airTime', document.getElementById('hdnAirTime').value, 'airCo', document.getElementById('hdnAirCo').value, 'orderby', rdo, 'asc', ckb);
    showSearch();
}
function doSort_back() {
    var rdo;
    if (document.getElementById("rdoAmt").checked) {
        rdo = document.getElementById("rdoAmt").value;
    } else if (document.getElementById("rdoTime").checked) {
        rdo = document.getElementById("rdoTime").value;
    } else {
        rdo = document.getElementById("rdoCo").value;
    }
    var ckb;
    if (document.getElementById("ckbTrue").checked) {
        ckb = "true";
    } else {
        ckb = "false";
    }
    doAjaxQuick('doShow', search_path, 'operator', 'sortback', 'fromCity', document.getElementById('hdnFromCity').value, 'toCity', document.getElementById('hdnToCity').value, 'airDate', document.getElementById('hdnAirTime').value, 'airTime', document.getElementById('hdnAirTime').value, 'airCo', document.getElementById('hdnAirCo').value, 'orderby', rdo, 'asc', ckb);
    showSearch();
}
function asSort(rdoSort) {
    var ckb;
    if (document.getElementById("ckbTrue").checked) {
        ckb = "true";
    } else {
        ckb = "false";
    }
    doAjaxQuick('doShow', search_path, 'operator', 'sortsolo', 'fromCity', document.getElementById('hdnFromCity').value, 'toCity', document.getElementById('hdnToCity').value, 'airDate', document.getElementById('hdnAirTime').value, 'airTime', document.getElementById('hdnAirTime').value, 'airCo', document.getElementById('hdnAirCo').value, 'orderby', rdoSort, 'asc', ckb);
    showSearch();
}
function asSort_double(rdoSort) {
    var ckb;
    if (document.getElementById("ckbTrue").checked) {
        ckb = "true";
    } else {
        ckb = "false";
    }
    doAjaxQuick('doShow', search_path, 'operator', 'sortdouble', 'fromCity', document.getElementById('hdnFromCity').value, 'toCity', document.getElementById('hdnToCity').value, 'airDate', document.getElementById('hdnAirTime').value, 'airTime', document.getElementById('hdnAirTime').value, 'airCo', document.getElementById('hdnAirCo').value, 'orderby', rdoSort, 'asc', ckb);
    showSearch();
}
function asSort_back(rdoSort) {
    var ckb;
    if (document.getElementById("ckbTrue").checked) {
        ckb = "true";
    } else {
        ckb = "false";
    }
    doAjaxQuick('doShow', search_path, 'operator', 'sortback', 'fromCity', document.getElementById('hdnFromCity').value, 'toCity', document.getElementById('hdnToCity').value, 'airDate', document.getElementById('hdnAirTime').value, 'airTime', document.getElementById('hdnAirTime').value, 'airCo', document.getElementById('hdnAirCo').value, 'orderby', rdoSort, 'asc', ckb);
    showSearch();
}
function PAGE_LOAD() {
    if (Request("operator") == "search") {
        var fromCity = Request("fromCity");
        var fromCityChs = Request("fromCityChs");
        var toCity = Request("toCity");
        var toCityChs = Request("toCityChs");
        document.getElementById("txtCity").value = fromCityChs + "(" + fromCity + ")";
        document.getElementById("txtCity0").value = toCityChs + "(" + toCity + ")";
        doAjaxQuick("doShow", search_path, "operator", "searchsolo", "fromCity", fromCity, "toCity", toCity, "airDate", getNextDate(), "airCo", "", "airTime", "");
        showSearch();
    }
}
function show_date(date) {
    doAjaxQuick("doShow", search_path, "operator", "searchsolo", "fromCity", document.getElementById("hdnFromCity").value, "toCity", document.getElementById("hdnToCity").value, "airDate", date, "airCo", document.getElementById("hdnAirCo").value, "airTime", document.getElementById("hdnAirTime").value);
    showSearch();
}
function show_date_double(date) {
    doAjaxQuick("doShow", search_path, "operator", "searchdouble", "fromCity", document.getElementById("hdnFromCity").value, "toCity", document.getElementById("hdnToCity").value, "airDate", date, "airCo", document.getElementById("hdnAirCo").value, "airTime", document.getElementById("hdnAirTime").value);
    showSearch();
}
function show_date_back(date) {
    doAjaxQuick("doShow", search_path, "operator", "searchbacknext", "airDate", date);
    showSearch();
}
function look(i, j) {
    doAjaxQuick("doLook", search_path, "operator", "look", "i", i, "j", j);
}
function next(i, j) {
    doAjaxQuick("doLook", search_path, "operator", "next", "i", i, "j", j);
}
function getCity(city) {
    return document.getElementById(city).value.substring(document.getElementById(city).value.length - 4, document.getElementById(city).value.length - 1);
}
function getCity_in(city) {
    return city.substring(city.length - 4, city.length - 1);
}
function DivAlert(messageDiv) {
    this.messageDiV = messageDiv;
    this.bottomDIV = document.createElement("div");
    var x = document.body.clientWidth;
    var y = document.body.clientHeight;
    this.bottomDIV.style.opacity = "0.50";
    this.bottomDIV.style.filter = "Alpha(opacity=0);";
    this.bottomDIV.style.backgroundColor = "#FFFFFF";
    this.bottomDIV.style.width = x;
    this.bottomDIV.style.height = y;
    this.bottomDIV.style.marginTop = "0px";
    this.bottomDIV.style.marginLeft = "0px";
    this.bottomDIV.style.position = "absolute";
    this.bottomDIV.style.top = "0px";
    this.bottomDIV.style.left = "0px";
    this.bottomDIV.style.zIndex = 100;
    //显示提示框
    this.show = function() {
        document.body.appendChild(this.bottomDIV);
        this.messageDiV.style.display = "inline";
        this.messageDiV.style.position = "absolute";
        this.messageDiV.style.top = "300px";
        this.messageDiV.style.left = x / 2 - 230 + "px";
        this.messageDiV.style.zIndex = 101;
    }
    //移除提示框
    this.remove = function() {
        document.body.removeChild(this.bottomDIV);
        this.messageDiV.style.display = "none";
    }
}
function DivAlert_2(messageDiv) {
    this.messageDiV = messageDiv;
    this.bottomDIV = document.createElement("div");
    var x = document.body.clientWidth;
    var y = document.body.clientHeight;
    this.bottomDIV.style.opacity = "0.50";
    this.bottomDIV.style.filter = "Alpha(opacity=0);";
    this.bottomDIV.style.backgroundColor = "#FFFFFF";
    this.bottomDIV.style.width = x;
    this.bottomDIV.style.height = y;
    this.bottomDIV.style.marginTop = "0px";
    this.bottomDIV.style.marginLeft = "0px";
    this.bottomDIV.style.position = "absolute";
    this.bottomDIV.style.top = "0px";
    this.bottomDIV.style.left = "0px";
    this.bottomDIV.style.zIndex = 100;
    //显示提示框
    this.show = function() {
        document.body.appendChild(this.bottomDIV);
        this.messageDiV.style.display = "inline";
        this.messageDiV.style.position = "absolute";
        this.messageDiV.style.top = y / 2 + 300 + "px";
        this.messageDiV.style.left = x / 2 + 300 + "px";
        this.messageDiV.style.zIndex = 101;
    }
    //移除提示框
    this.remove = function() {
        document.body.removeChild(this.bottomDIV);
        this.messageDiV.style.display = "none";
    }
}
var dc;
function showOrder() {
    var d = document.getElementById(div_order);
    dc = new DivAlert(d);
    dc.show();
}
function removeOrder() {
    dc.remove();
}
var dc_2;
function showSearch() {
    setNil();
    var d = document.getElementById("jiazai");
    dc_2 = new DivAlert(d);
    dc_2.show();
}
function removeSearch() {
    dc_2.remove();
}
function createOrder() {
    var passenger = '';
    var code = '';
    var ps = document.getElementsByTagName("input");
    for (var i = 0; i - ps.length; i++) {
        var v = ps.item(i);
        if (v.name == "name") {
            passenger += "^" + v.value;
        } else if (v.name == "code") {
            code += "^" + v.value;
        }
    }
    passenger = passenger.substring(1, passenger.length);
    code = code.substring(1, code.length);
    doAjaxQuick("doCreate", search_path, "operator", "create", "linkMan", document.getElementById("linkMan").value, "mobile", document.getElementById("mobile").value, "phone", document.getElementById("phone").value, "email", document.getElementById("email").value, "passenger", passenger, "code", code);
}
function doCreate() {
    if (isSussecc()) {
        document.getElementById(div_order).innerHTML = getAjaxText();
    }
}
