// Call of remote data via xmlHttpRequest

function mediaalbumDataServent()
{};

mediaalbumDataServent.prototype.initialize = function()
{
    try {
        // Mozilla / Safari
        this._xh = new XMLHttpRequest();
    } catch (e) {
        // Explorer
        var _ieModel = new Array(
        'MSXML2.XMLHTTP.5.0',
        'MSXML2.XMLHTTP.4.0',
        'MSXML2.XMLHTTP.3.0',
        'MSXML2.XMLHTTP',
        'Microsoft.XMLHTTP'
        );
        var success = false;
        for (var i=0;i < _ieModel.length && !success; i++)
        {
            try {
                this._xh = new ActiveXObject(_ieModel[i]);
                success = true;
            } catch (e) {
                // Manage the exceptions
            }
        }
        if ( !success )
        {
            // Manage the exceptions, while alert
            return false;
        }
        return true;
    }
}

mediaalbumDataServent.prototype.occupy = function()
{
    beenActual = this._xh.readyState;
    return (beenActual && (beenActual < 4));
}

mediaalbumDataServent.prototype.process = function()
{
    if (this._xh.readyState == 4 && this._xh.status == 200)
    {
        this.processdo = true;
    }
}

mediaalbumDataServent.prototype.sending = function(urlget,data)
{
    if (!this._xh)
    {
        this.initialize();
    }
    if (!this.occupy())
    {
        this._xh.open("GET",urlget,false);
        this._xh.send(data);
        if (this._xh.readyState == 4 && this._xh.status == 200)
        {
            return this._xh.responseText;
        }
    }
    return false;
}

// Rapid access for making changes
function mediaalbum_gr(reqseccion,divcont)
{
    remote = new mediaalbumDataServent;
    nt = remote.sending(reqseccion,"");
    document.getElementById(divcont).innerHTML = nt;
}

// Call the ajax-rating.php out of Admin Menu to execute rating
function mediaalbumRateMedia(rating,mediaalbum_id,message)
{
        remote = new mediaalbumDataServent;
        nt = remote.sending('ajax-rating.php?rating='+rating+'&mediaalbum_id='+mediaalbum_id);
        rating = rating * 25;
        document.getElementById('current-rating').style.width = rating+'px';
        document.getElementById('ratelinks').style.display = 'none';
        document.getElementById('ratingtext').innerHTML = message;
}

// Call the ajax-rating.php in Admin Menu to execute rating
function mediaalbumRateAdminMedia(rating,mediaalbum_id,message)
{
        remote = new mediaalbumDataServent;
        nt = remote.sending('mediaalbum/ajax-rating.php?rating='+rating+'&mediaalbum_id='+mediaalbum_id);
        rating = rating * 25;
        document.getElementById('current-rating').style.width = rating+'px';
        document.getElementById('ratelinks').style.display = 'none';
        document.getElementById('ratingtext').innerHTML = message;
}
function mediaalbumRateAdminMedia1(rating,mediaalbum_id,message,count)
{
        remote = new mediaalbumDataServent;
        nt = remote.sending('mediaalbum/ajax-rating.php?rating='+rating+'&mediaalbum_id='+mediaalbum_id);
        rating = rating * 25;
        document.getElementById('current-rating' + count).style.width = rating+'px';
        document.getElementById('ratelinks' + count).style.display = 'none';
        //document.getElementById('ratingtext' + count).innerHTML = message;
}

