﻿function GetXmlHttpObject() {
    if (window.XMLHttpRequest) {
        // code for IE7+, Firefox, Chrome, Opera, Safari
        return new XMLHttpRequest();
    }
    if (window.ActiveXObject) {
        // code for IE6, IE5
        return new ActiveXObject("Microsoft.XMLHTTP");
    }
    return null;
}

var xmlhttp;
function fillddlFSP(param) {
    window.document.getElementById("ddlFSP").innerHTML = "Loading...";
    xmlhttp = GetXmlHttpObject();
    if (xmlhttp == null) {
        alert("Your browser does not support AJAX!");
        return;
    }

    var url = "Ajax/AjaxFSP.aspx";

    url = url + "?FP=" + escape(param);
    url = url + "&CompanyID=0";
    xmlhttp.onreadystatechange = stateChangedfillddlFSP;
    xmlhttp.open("GET", url, true);
    xmlhttp.send(null);
    //window.document.forms[0].submit();
}

function stateChangedfillddlFSP() {
    if (xmlhttp.readyState == 4) {
        window.document.getElementById("ddlFSP").innerHTML = xmlhttp.responseText;
    }
}

var xmlhttp2;
function fillddlTP(param, param2) {
    window.document.getElementById("ddlTP").innerHTML = "Loading...";
    xmlhttp2 = GetXmlHttpObject();
    if (xmlhttp2 == null) {
        alert("Your browser does not support AJAX!");
        return;
    }

    var url = "Ajax/AjaxTP.aspx";

    url = url + "?FP=" + escape(param);
    url = url + "&FSP=" + escape(param2);
    url = url + "&CompanyID=0";
    xmlhttp2.onreadystatechange = stateChangedfillddlTP;
    xmlhttp2.open("GET", url, true);
    xmlhttp2.send(null);
    //window.document.forms[0].submit();
}

function stateChangedfillddlTP() {
    if (xmlhttp2.readyState == 4) {
        window.document.getElementById("ddlTP").innerHTML = xmlhttp2.responseText;
    }
}

var htmlhttp3;
function fillddlTSP(param, param2, param3) {
    window.document.getElementById("ddlTSP").innerHTML = "Loading...";
    xmlhttp3 = GetXmlHttpObject();
    if (xmlhttp3 == null) {
        alert("Your browser does not support AJAX!");
        return;
    }
    var url = "Ajax/AjaxTSP.aspx?FP=" + escape(param) + "&FSP=" + escape(param2)
                    + "&TP=" + escape(param3) + "&CompanyID=0";

    xmlhttp3.onreadystatechange = stateChangedfillddlTSP;
    xmlhttp3.open("GET", url, true);
    xmlhttp3.send(null);
}

function stateChangedfillddlTSP() {
    if (xmlhttp3.readyState == 4) {
        window.document.getElementById("ddlTSP").innerHTML = xmlhttp3.responseText;
    }
}



var sequentialFP = '-1';
var sequentialFSP = '-1';
var sequentialTP = '-1';
var sequentialTSP = '-1';

var htmlhttp6;
function fillddlFSPSequential() {
    xmlhttp6 = GetXmlHttpObject();
    if (xmlhttp6 == null) {
        alert("Your browser does not support AJAX!");
        return;
    }

    var url = "Ajax/AjaxFSP.aspx";

    url = url + "?FP=" + escape(sequentialFP);
    url = url + "&CompanyID=0";
    xmlhttp6.onreadystatechange = stateChangedfillddlFSPSequential;
    xmlhttp6.open("GET", url, true);
    xmlhttp6.send(null);
}

function stateChangedfillddlFSPSequential() {
    if (xmlhttp6.readyState == 4) {
        window.document.getElementById("ddlFSP").innerHTML = xmlhttp6.responseText;
        fillddlTPSequential();
    }
}

var htmlhttp7;
function fillddlTPSequential() {
    xmlhttp7 = GetXmlHttpObject();
    if (xmlhttp7 == null) {
        alert("Your browser does not support AJAX!");
        return;
    }

    var url = "Ajax/AjaxTP.aspx";

    url = url + "?FP=" + escape(sequentialFP);
    url = url + "&FSP=" + escape(sequentialFSP);
    url = url + "&CompanyID=0";
    xmlhttp7.onreadystatechange = stateChangedfillddlTPSequential;
    xmlhttp7.open("GET", url, true);
    xmlhttp7.send(null);
}

function stateChangedfillddlTPSequential() {
    if (xmlhttp7.readyState == 4) {
        window.document.getElementById("ddlTP").innerHTML = xmlhttp7.responseText;
        fillddlTSPSequential();
    }
}

var xmlhttp8
function fillddlTSPSequential() {
    xmlhttp8 = GetXmlHttpObject();
    if (xmlhttp8 == null) {
        alert("Your browser does not support AJAX!");
        return;
    }
    var url = "Ajax/AjaxTSP.aspx?FP=" + escape(sequentialFP) + "&FSP=" + escape(sequentialFSP)
                    + "&TP=" + escape(sequentialTP) + "&CompanyID=0";

    xmlhttp8.onreadystatechange = stateChangedfillddlTSPSequential;
    xmlhttp8.open("GET", url, true);
    xmlhttp8.send(null);
}

function stateChangedfillddlTSPSequential() {
    if (xmlhttp8.readyState == 4) {
        window.document.getElementById("ddlTSP").innerHTML = xmlhttp8.responseText;
        document.getElementById("selectFSP").value = sequentialFSP;
        document.getElementById("selectTP").value = sequentialTP;
        document.getElementById("selectTSP").value = sequentialTSP;
    }
}

var xmlhttp9;
function fillAllPlaces() {
    xmlhttp9 = GetXmlHttpObject();
    if (xmlhttp9 == null) {
        alert("Your browser does not support AJAX!");
        return;
    }
    var url = "Ajax/DepartArrive.aspx";

    xmlhttp9.onreadystatechange = stateChangedfillAllPlaces;
    xmlhttp9.open("GET", url, true);
    xmlhttp9.send(null);
}

function stateChangedfillAllPlaces() {
    if (xmlhttp9.readyState == 4) {
        window.document.getElementById("allPlaces").innerHTML = xmlhttp9.responseText;
        
    }
}

var htmlhttp5;
function fillScroller() {
    xmlhttp5 = GetXmlHttpObject();
    if (xmlhttp5 == null) {
        alert("Your browser does not support AJAX!");
        return;
    }
    var url = "scroller2/slider.html";

    xmlhttp5.onreadystatechange = stateChangedfillScroller;
    xmlhttp5.open("GET", url, true);
    xmlhttp5.send(null);
}

function stateChangedfillScroller() {
    if (xmlhttp5.readyState == 4) {
        window.document.getElementById("scrollerspan").innerHTML = xmlhttp5.responseText;
        marqueeInit({
            uniqueid: 'mycrawler',
            style: {
                'margin': '0 auto',
                'width': '1000px',
                'height': '165px'
            },
            inc: 2, //speed - pixel increment for each iteration of this marquee's movement
            mouse: 'pause', //mouseover behavior ('pause' 'cursor driven' or false)
            moveatleast: 2,
            neutral: 150,
            savedirection: true,
            random: true
        });
    }  
}

var xmlhttp10;
function queryKTBTrip() {
    xmlhttp10 = GetXmlHttpObject();
    if (xmlhttp10 == null) {
        alert("Your browser does not support AJAX!");
        return;
    }

    var url = "../Ajax/QueryKTBTrip.aspx";

    xmlhttp10.onreadystatechange = stateChangedqueryKTBTrip;
    xmlhttp10.open("GET", url, true);
    xmlhttp10.send(null);
}

function stateChangedqueryKTBTrip() {
    if (xmlhttp10.readyState == 4) {
        var responseText = xmlhttp10.responseText;
        if (responseText.length > 0) {

            var separate = responseText.split('|||');

            if (separate.length > 0) {
                window.document.getElementById("divKTBDepart").innerHTML = separate[0];
            }
            if (separate.length > 1) {
                window.document.getElementById("divKTBReturn").innerHTML = separate[1];
            }
            initLytebox();
            parent.calcHeight();
        }
    }
}
