
/**
 * Generic ajax call function
 * @param string url - url to call including GET args
 * @param string callback - callback function without parathensis
 * @return void - calls callback at end
 */
function ajaxCall( url, callback ) {

    if (window.XMLHttpRequest) { // Mozilla, Safari, ...
        http_request = new XMLHttpRequest();
        if (http_request.overrideMimeType) {
            http_request.overrideMimeType('text/xml');
            // See note below about this line
        }
    } else if (window.ActiveXObject) { // IE
        try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
                http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
        }
    }

    if (!http_request) {
        alert('Giving up :( Cannot create an XMLHTTP instance');
        return false;
    }
    
    // Build the function call
    var f_call = callback + '(http_request)';

    http_request.onreadystatechange = function() { eval(f_call);  };
    http_request.open('GET', url, true);
    http_request.send(null);
}

function handleLightBox(http_request){
//	alert(http_request.responseText);
}

function addtolbox(id, checked) {
	var checked = ( checked ) ? 'true' : 'false';
	var url = "http://www.realandwildlight.com/gallery/aj/addtolightbox.php?id="+id+"&checked="+checked;

	ajaxCall( url, 'handleLightBox' );
}
