function ampliaImagen() {
    return this;
}

ampliaImagen.prototype.d = document;


ampliaImagen.prototype.show = function(imgSrc) {
    this.createMask();
    this.createCanvas(imgSrc);
    this.getScreenSize();
    //return false;
}

ampliaImagen.prototype.createCanvas = function(imgSrc) {
    this.canvas = this.d.createElement("div");
    this.canvas.className = "canvas";
    this.img = this.d.createElement("img");
    this.btnClose = this.d.createElement("a");
    this.btnClose.parent = this;
    this.btnClose.href = "#";
    this.btnClose.className = "btnClose";
    this.btnClose.innerHTML = "Fechar";
    this.btnClose.onclick = this.close;
    this.img.src = imgSrc;
    this.d.body.appendChild(this.canvas);
    //this.canvas.appendChild(this.img);
    this.img.parent = this;
    //alert(this.canvas.offsetLeft);
    this.canvas.style.left = this.canvas.offsetLeft - (this.canvas.offsetWidth/2)+"px";
    this.img.onload = function() {
        //alert("teste "+this.parent.d);
        this.parent.canvas.appendChild(this);
        this.parent.canvas.style.width = this.offsetWidth;
        this.parent.canvas.style.height = this.offsetHeight;
        this.parent.canvas.style.left = (this.parent.screen.x/2) - (this.parent.canvas.offsetWidth/2)+"px";
        this.parent.canvas.appendChild(this.parent.btnClose);
        //alert(this.parent.getScreenSize());
    }
}
ampliaImagen.prototype.createMask = function(imgSrc) {
    this.mask = this.d.createElement("div");
    this.mask.className = "mask";
    this.d.body.appendChild(this.mask);
}
ampliaImagen.prototype.close = function() {
    this.parent.d.body.removeChild(this.parent.mask);
    this.parent.d.body.removeChild(this.parent.canvas);
    return false;
}


ampliaImagen.prototype.getScreenSize = function() {
    this.screen = new Object();
    if(document.all) {
        screenX = document.body.offsetWidth;
        screenY = document.body.offsetHeight;
    } else {
        screenX = window.innerWidth;
        screenY = window.innerHeight;
    }

    this.screen.y = screenY;
    this.screen.x = screenX;
}





var ampImg = new ampliaImagen();