Cargador = function(){

    this.width = 200;
    this.heigth = 100;
    this.lineas = new Array();
    
};

Cargador.prototype.init = function(){
    this.finish();
    var ldng = document.createElement("div");
    ldng.id = "AKtransitionLayer";
    ldng.style.backgroundColor = "#000";
    ldng.style.position = "absolute";
    var dimensiones = this.getPageSizeWithScroll();
    ldng.style.width = dimensiones[0] + "px";
    ldng.style.height = dimensiones[1] + "px";
    ldng.style.left = "0px";
    ldng.style.top = "0px";
    ldng.style.zIndex = "9999";
    ldng.style.opacity = 0.8;
    ldng.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=70)';
    ldng.onclick = this.finish;
    document.body.appendChild(ldng);
    this.crearcargando();
    document.body.style.overflow = "hidden";
    
}

Cargador.prototype.crearcargando = function(){
    var ldng = document.createElement("div");
    ldng.id = "Akloaderinfo";
    ldng.style.color = "black";
    ldng.style.backgroundColor = "#e8e4cb";
    ldng.style.position = "absolute";
    ldng.style.width = this.width + "px";
    ldng.style.left = ((f_clientWidth() / 2) + f_scrollLeft()) - (this.width / 2) + "px";
    ldng.style.top = ((f_clientHeight() / 2) + f_scrollTop()) - (this.heigth / 2) + "px";
    ldng.style.zIndex = "10000";
    ldng.style.padding = "10px";
    ldng.style.border = "solid 1px #000000";
	ldng.innerHTML += "<div id='chargerinitialphrase'>" + this.frasecargando +"</div>";
    for (var i = 0; i < this.lineas.length; i++) {
        ldng.innerHTML += "<div id='" + this.lineas[i][3] + "'>" + this.lineas[i][0] + "</div>";
    }
    document.body.appendChild(ldng);
    
}

Cargador.prototype.frasecargando=null;

Cargador.prototype.addLine = function(enespera, enproceso, finalizado, id){
    if (browserName != "Microsoft Internet Explorer") {
        var insarray = new Array(enespera, enproceso, finalizado, id)
        this.lineas.push(insarray);
    }
}

Cargador.prototype.updateLine = function(idlinea, estado){
    if (browserName != "Microsoft Internet Explorer") {
        var ldng = document.getElementById("Akloaderinfo");
        if (ldng) {
            for (var i = 0; i < this.lineas.length; i++) {
                if (this.lineas[i][3] == idlinea) {
                    if (document.getElementById(idlinea)) {
                        document.getElementById(idlinea).innerHTML = this.lineas[i][estado];
                        break;
                    }
                }
            }
        }
    }
}

Cargador.prototype.finish = function(){
    var ldng = document.getElementById("Akloaderinfo");
    if (ldng) {
        document.body.removeChild(ldng);
    }
    var ldng = document.getElementById("AKtransitionLayer");
    if (ldng) {
        //fadeOut("AKtransitionLayer");
        document.body.removeChild(ldng);
    }
}

Cargador.prototype.getPageSizeWithScroll = function(){
    if (window.innerHeight && window.scrollMaxY) {// Firefox
        yWithScroll = window.innerHeight + window.scrollMaxY;
        xWithScroll = window.innerWidth + window.scrollMaxX;
    }
    else 
        if (document.body.scrollHeight > document.body.offsetHeight) { // all but Explorer Mac
            yWithScroll = document.body.scrollHeight;
            xWithScroll = document.body.scrollWidth;
        }
        else { // works in Explorer 6 Strict, Mozilla (not FF) and Safari
            yWithScroll = document.body.offsetHeight;
            xWithScroll = document.body.offsetWidth;
        }
    arrayPageSizeWithScroll = new Array(xWithScroll, yWithScroll);
    return arrayPageSizeWithScroll;
}
