/* jLightBox (using jQuery library).
*--------------------------------------------*
*  @author : ukhome ( ukhome@gmail.com | ntkhoa_friends@yahoo.com )
*--------------------------------------------*
*  @released : 24-Mar-2009 : version 1.0
*--------------------------------------------*
*  @revision history : ( latest version : 1.0 )
*--------------------------------------------*
*      + 24-Mar-2009 : version 1.0
*          - released
*--------------------------------------------*
*/

/* package $lightbox.Ajax
*/

/*
* parent = $lightbox object
*/

$lightbox.Ajax = function (parent, url, callback) {
    var xmlHttp;
    try {
        // Firefox, Opera 8.0+, Safari
        xmlHttp = new XMLHttpRequest();
    }
    catch (e) {
        // Internet Explorer
        try {
            xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e) {
            try {
                xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch (e) {
                //alert("Your browser does not support AJAX!");
                new $lightbox.ErrorHandler(parent, "Your browser does not support AJAX !");
                return false;
            }
        }
    }

    xmlHttp.onreadystatechange = function() {
        if ( xmlHttp.readyState == 4 ) {
            if ( xmlHttp.status == 200 ) {
                callback(xmlHttp.responseText);
            }
            else if ( xmlHttp.status == 404 ) {
                new $lightbox.ErrorHandler(parent, "Can not find URL !");
                return false;
            }
        }
    }

    xmlHttp.open("GET", url, true);
    xmlHttp.send(null);

}

