<?php
/*******************************************************************************
 *
 * LEIDEN OPEN VARIATION DATABASE (LOVD)
 *
 * Created     : 2009-11-13
 * Modified    : 2010-01-06
 * For LOVD    : 2.0-24
 *
 * Access      : Public.
 * Purpose     : Provide JavaScript for AJAX calls.
 *
 * Copyright   : 2004-2010 Leiden University Medical Center; http://www.LUMC.nl/
 * Programmer  : Ing. Ivo F.A.C. Fokkema <I.F.A.C.Fokkema@LUMC.nl>
 * Last edited : Ing. Ivo F.A.C. Fokkema <I.F.A.C.Fokkema@LUMC.nl>
 *
 *
 * This file is part of LOVD.
 *
 * LOVD is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * LOVD is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with LOVD; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 *************/

// 2010-01-06; 2.0-24; Needed a proper check whether or not to include the header, it got included too often.
if (substr(basename($_SERVER['SCRIPT_NAME']), 0, 7) == 'inc-js-') {
    header('Content-type: text/javascript; charset=ISO-8859-1');
}
?>

function lovd_HTTPRequest (sURL) {
    // Create HTTP request object.
    var objHTTP;
    try {
        // W3C standard.
        objHTTP = new XMLHttpRequest();
    } catch (e) {
        // Internet Explorer?
        try {
            objHTTP = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
                objHTTP = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {
                // Ok, last try!
                try {
                    objHTTP = window.createRequest();
                } catch (e) {
                    // Never mind.
                    objHTTP = false;
                }
            }
        }
    }

    if (objHTTP) {
        objHTTP.open("GET", sURL, false);
        objHTTP.send(null);
        return objHTTP;

    } else {
        return false;
    }
}


