/**
 * Controller functions for news article and press release page ajax requests
 * 
 * @author Garrette A. Hall <ghall@positroniks.com>
 * @copyright 2006, licensed for unrestricted use to The Vandiver Group, Inc.
 */

/**
 * Sends ajax request for a list of article or release links and inserts output into the document
 *
 * @param string release 'true' to select press releases, 'false' for articles
 */
function requestNewsList(release) {
    var xhr = getXHR();
    var url = '../../script/backend.php';
    var action = '?ajax=1&request=newslist&release=' + release;
    xhr.open('get', url + action, true);
    xhr.onreadystatechange = function() {
        if(xhr.readyState == 4) {
            if(xhr.status == 200) {
                result = xhr.responseText;
                document.getElementById('sidebar').innerHTML = result;
            }
        }
    }
    xhr.send(null);
}

/**
 * Sends ajax request for formatted copy of an article or release
 *
 * @param int nid article or release id
 */
function requestNewsCopy(nid) {
    var xhr = getXHR();
    var url = '../../script/backend.php';
    var action = '?ajax=1&request=news&nid=' + nid;
    xhr.open('get', url + action, true);
    xhr.onreadystatechange = function() {
        if(xhr.readyState == 4) {
            if(xhr.status == 200) {
                result = xhr.responseText;
                document.getElementById('copy').innerHTML = result;
            }
        }
    }
    xhr.send(null);
}
