function pageLoad(vl){
    el = document.getElementById('link_' + vl);
    el.style.backgroundColor = '#e9e9e9';
    el.style.borderBottom = '1px solid #e9e9e9';
    el.style.color = '#000';
    sendRequest('getBoardInfo.php?id=' + vl, handleResponse, false);
}

// this function should be called by the pages that are to display
// the pdf brochures
function sendRequest(url, callback, bl) {
    var xmlHttp = GetXmlHttpObject();
    if(xmlHttp == null) {
        alert('Browser does not support HTTP Request');
        return false;
    }

    xmlHttp.open("GET", url, true);
    xmlHttp.onreadystatechange = function() {
        if(xmlHttp.readyState != 4) {
            /*if(bl == true) {
                document.getElementById('ajaxLoader').style.display = 'block';
            }*/
            return;
        } /*else {
            if(bl == true) {
                document.getElementById('ajaxLoader').style.display = 'none';
            }
        }   */

        if(xmlHttp.status != 200 && req.status != 304) {
            alert('HTTP error ' + req.status);
            return;
        }
        callback(xmlHttp);
    }
    xmlHttp.send(null);
}

function handleResponse(req) {
    document.getElementById('tabContent').innerHTML = req.responseText;
}

function handleArchiveResponse(req) {
    document.getElementById('ajaxReply').innerHTML = req.responseText;
}

function GetXmlHttpObject() {
    var objXMLHttp = null;
    if(window.XMLHttpRequest) {
        objXMLHttp = new XMLHttpRequest();
    } else if (window.ActiveXObject) {
        objXMLHttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    return objXMLHttp;
}

function showMemberInfo(i, el) {
    changeBackgroundColor();
    el.style.backgroundColor = '#e9e9e9';
    el.style.color = '#000';
    el.style.borderBottom = '1px solid #e9e9e9';
    sendRequest('getBoardInfo.php?id=' + i, handleResponse, false);
    return false;
}

function showMeetingArchive() {
    var mt = document.getElementById('slt_meetingTitle').value;
    var my = document.getElementById('slt_meetingYear').value;
    var mm = document.getElementById('slt_meetingMonth').value;
    document.getElementById('ajaxReply').style.display = 'block';
    sendRequest('getArchive.php?mt=' + mt + '&my=' + my + '&mm=' + mm, handleArchiveResponse, true);
    return false;
}

function changeBackgroundColor() {
    for( var j = 1, el; el = document.getElementById('link_'+j); j++ ) {
        el.style.backgroundColor = '#9f082b';
        el.style.color = '#fff';
        el.style.borderBottomColor = '#9f082b';
    }
}

function turnOnColor(el) {  //alert(el.style.backgroundColor.value);
    if(el.style.backgroundColor != 'rgb(233, 233, 233)' && el.style.backgroundColor != '#e9e9e9') {
        el.style.backgroundColor = '#8b9c3d';
        el.style.borderBottomColor = '#8b9c3d';
    }
}

function turnOffColor(el) {
    if(el.style.backgroundColor != 'rgb(233, 233, 233)' && el.style.backgroundColor != '#e9e9e9') {
        el.style.backgroundColor = '#9f082b';
        el.style.borderBottomColor = '#9f082b';
    }
}
