var closing = true;

function closeFunction(checkinUrl)
{
    // This is purposely commented out, since there is something that is closing the book prematurely on the 
    // GetImage servlet.
    // if (getCloseState())
    // {
    //     setCloseState(false);
    //     processClose(checkinUrl);
    // }
}

function processClose(checkinUrl)
{
    var locstring = document.domain;
//    alert("Closing Event: " + document.URL.slice(document.URL.search(locstring)+locstring.length,document.URL.length));
    var i = document.createElement('img');
    i.onload = function ( ) { /* server is happy */ };
    i.onerror = function ( ) { /* server is not happy */ };
    i.src = checkinUrl;//'../AutoCheckin/test.gif' + params;
    // the following causes a call to the servlet to load this image, resulting in the checkout.
    document.test_image = i;
    setCloseState(false);
}

function getCloseState()
{
    if ((window.parent != null) && (window.parent.getParentCloseState != null))
    {
        return window.parent.getParentCloseState();
    }
    return closing;
}

function setCloseState(state)
{
    if ((window.parent != null) && (window.parent.setParentCloseState != null))
    {
        window.parent.setParentCloseState(state);
        return;
    }
    closing = state;
    return true;
}



