﻿var XmlHttp;
var XmlHttp2;
function CreateXmlHttp() {
    //Creating object of XMLHTTP in IE
    try {
        XmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch (e) {
        try {
            XmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
        catch (oc) {
            XmlHttp = null;
        }
    }
    //Creating object of XMLHTTP in Mozilla and Safari 
    if (!XmlHttp && typeof XMLHttpRequest != "undefined") {
        XmlHttp = new XMLHttpRequest();
    }
}


function CreateXmlHttp2() {
    //Creating object of XMLHTTP in IE
    try {
        XmlHttp2 = new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch (e) {
        try {
            XmlHttp2 = new ActiveXObject("Microsoft.XMLHTTP");
        }
        catch (oc) {
            XmlHttp2 = null;
        }
    }
    //Creating object of XMLHTTP in Mozilla and Safari 
    if (!XmlHttp2 && typeof XMLHttpRequest != "undefined") {
        XmlHttp2 = new XMLHttpRequest();
    }
}

function HandleResponseDropDown(TheDiv) {
    // To make sure receiving response data from server is completed
    if (XmlHttp.readyState == 4) {
        // To make sure valid response is received from the server, 200 means response received is OK
        if (XmlHttp.status == 200) {
            HandleRDDRetV(XmlHttp.responseXML.documentElement);
        }
        else {
            alert("There was a problem retrieving data from the server.\n\nRefress the page");
        }
    }
}
function HandleResponseDropDown2(TheDiv) {
    // To make sure receiving response data from server is completed
    if (XmlHttp2.readyState == 4) {
        // To make sure valid response is received from the server, 200 means response received is OK
        if (XmlHttp2.status == 200) {
            HandleDepGuides(XmlHttp2.responseXML.documentElement);
        }
        else {
            alert("There was a problem retrieving data from the server.\n\nRefress the page");
        }
    }
}
function HandleResponse3(TheDiv) {
    // To make sure receiving response data from server is completed
    if (XmlHttp.readyState == 4) {
        // To make sure valid response is received from the server, 200 means response received is OK
        if (XmlHttp.status == 200) {
            //HandleDepPrice(XmlHttp.responseXML.documentElement);
            HandleDepPrice(XmlHttp.responseText);
        }
        else {
            alert("There was a problem retrieving data from the server.\n\nRefress the page");
        }
    }
}
//var HandleResponseAction = 0;
function HandleResponseDiv() {

    if (XmlHttp.readyState == 4) {
        if (XmlHttp.status == 200) {
            if (HandleResponseAction == 0)
                generateGridReturnVal(XmlHttp.responseText);
            else if (HandleResponseAction == 1)
                generateGridReturnVal2(XmlHttp.responseText);
        }
        else {
            alert("There was a problem retrieving data from the server.\n\nRefress the page");
        }
    }
}
function generateGrid(TheUrl, Action) {
    CreateXmlHttp();
    if (XmlHttp) {
        HandleResponseAction = Action
        XmlHttp.onreadystatechange = HandleResponseDiv;
        XmlHttp.open("GET", TheUrl, true);
        XmlHttp.send(null);
    }
    return false;
}








function ModalShow() {
    var Modaldiv = document.getElementById('ModalPageLayer');
    Modaldiv.className = 'modalBackground';
    Modaldiv.style.display = '';

    // var arrayPageSize = getPageSize();
    //var arrayPageScroll = getPageScroll();

    //Modaldiv.style.height = (arrayPageSize[1] + 'px');
}

function ModalHidde() {
    var Modaldiv = document.getElementById('ModalPageLayer');
    Modaldiv.className = 'modalBackgroundHidden';
    Modaldiv.style.display = 'none';
}

function getPageScroll() {

    var yScroll;

    if (self.pageYOffset) {
        yScroll = self.pageYOffset;
    } else if (document.documentElement && document.documentElement.scrollTop) {	 // Explorer 6 Strict
        yScroll = document.documentElement.scrollTop;
    } else if (document.body) {// all other Explorers
        yScroll = document.body.scrollTop;
    }

    arrayPageScroll = new Array('', yScroll)
    return arrayPageScroll;
}

function getPageSize() {

    var xScroll, yScroll;

    if (window.innerHeight && window.scrollMaxY) {
        xScroll = document.body.scrollWidth;
        yScroll = window.innerHeight + window.scrollMaxY;
    } else if (document.body.scrollHeight > document.body.offsetHeight) { // all but Explorer Mac
        xScroll = document.body.scrollWidth;
        yScroll = document.body.scrollHeight;
    } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
        xScroll = document.body.offsetWidth;
        yScroll = document.body.offsetHeight;
    }

    var windowWidth, windowHeight;
    if (self.innerHeight) {	// all except Explorer
        windowWidth = self.innerWidth;
        windowHeight = self.innerHeight;
    } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
        windowWidth = document.documentElement.clientWidth;
        windowHeight = document.documentElement.clientHeight;
    } else if (document.body) { // other Explorers
        windowWidth = document.body.clientWidth;
        windowHeight = document.body.clientHeight;
    }

    // for small pages with total height less then height of the viewport
    if (yScroll < windowHeight) {
        pageHeight = windowHeight;
    } else {
        pageHeight = yScroll;
    }

    // for small pages with total width less then width of the viewport
    if (xScroll < windowWidth) {
        pageWidth = windowWidth;
    } else {
        pageWidth = xScroll;
    }


    arrayPageSize = new Array(pageWidth, pageHeight, windowWidth, windowHeight)
    return arrayPageSize;
}

function DivPopUpShow(LayerID, height, witdh, css) {
    //    var divLayer = document.getElementById(LayerID);


}

function DivPopUpHide(LayerID, height, witdh, css) {
    //    var divLayer = document.getElementById(LayerID);
}
function ShowSmallLoading(theObject) {
    document.getElementById(theObject).innerHTML = "<div align='center' valign='middle' style='width: 50px; height: 100px; background-color:#FFFFFF;'><img alt='Loading Data' src='../images/loading.gif' /></div>";
}
function ShowLoading(theObject) {
    document.getElementById(theObject).innerHTML = "<div align='center' valign='middle' style='width: 50px; height: 100px; background-color:#FFFFFF;'><img alt='Loading Data' src='../images/loading_medium.gif' /></div>";
}
function ShowBigLoading(theObject) {
    document.getElementById(theObject).innerHTML = "<div align='center' valign='middle' style='width: 480px; height: 100px; background-color:#FFFFFF;'><img alt='Loading Data' src='../images/loadingBig.gif' /></div>";
}
