function divPop(name)
{
    this.addPopImg = function( imgSrc, link )
    {
        this._addPop( imgSrc, link, 'img' );
    }
    this.addPopFlash = function( imgSrc, link )
    {
        this._addPop( imgSrc, link, 'flash' );
    }
    this.addPopFrame = function( imgSrc, link )
    {
        this._addPop( imgSrc, link, 'iframe' );
    }
    this._addPop = function( imgSrc, link, type )
    {
        var div = document.createElement( 'DIV' );
        div.className = 'divpop';
        div.id = name + '' + ( this.cnt++ );
        div.style.zIndex = '99999';
        
        if ( type == 'img' )
        {
            var an = document.createElement( 'A' );
            an.style.border = 'none';
            an.href = link;
            div.appendChild( an );

            var img = document.createElement( 'IMG' );
            an.appendChild( img );
            img.style.border = 'none';
            //img.onload = function() { div.style.width = img.width+'px'; div.style.height = img.height + 'px'; };
            img.src = imgSrc;
        }
        else if ( type == 'flash' )
        {
        }
        else if ( type == 'iframe' )
        {
            var an = document.createElement( 'IFRAME' );
            an.style.border = 'none';
            an.src = link;
            div.appendChild( an );
        }
        else
            return false;

        var divClose = document.createElement( 'DIV');
        divClose.style.fontSize = '8pt';
        divClose.innerHTML = 'fechar';
        divClose.style.cursor = 'pointer';
        divClose.style.color = '#BBBBBB';
        divClose.style.backgroundColor = '#000000';
        divClose.style.position = 'absolute';
        divClose.style.top = '0px';
        divClose.style.left = '0px';
        div.appendChild( divClose );
        
        var self = this;
        divClose.onclick = function() {
            this.parentNode.style.display = 'none';
        }

        div.style.position = 'absolute';
        div.style.top = (this.marg + parseInt(this.yc)) + 'px';
        div.style.left = (this.marg + parseInt(this.xc)) + 'px';
        div.style.width = parseInt(this.divw) + 'px';
        div.style.height = parseInt(this.divh) + 'px';
        div.style.background = '#333333';
        div.style.borderColor = '#DDDDDD';
        div.style.borderStyle = 'solid';
        div.style.borderWidth = '3px';
        div.style.overflow = 'hidden';
        this.divs[this.divs.length] = div;
        if ( ++this.plc < this.perline )
        {
            this.xc += this.marg + parseInt(this.divw);
        }
        else
        {
            this.yc += this.marg + parseInt(this.divh);
            this.xc = 0;
            this.plc = 0;
        }
    }
    this.init = function()
    {
        this.divpad = 16;
        this.xc = 0;
        this.yc = 10;
        this.marg = 20;
        this.perline = 5;
        this.plc = 0;
        this.divw = 100;
        this.divh = 100;
        this.divs = Array();
        var closeAll = document.createElement('DIV');
        closeAll.innerHTML = 'fechar tudo';
        closeAll.style.cursor = 'pointer';
        closeAll.style.float = 'right';
        closeAll.style.color = '#BBBBBB';
        closeAll.style.backgroundColor = '#000000';
        closeAll.style.fontSize = '10pt';
        closeAll.style.position = 'absolute';
        closeAll.style.left = '0px';
        closeAll.style.top = '0px';
        closeAll.style.zIndex = '999999';
        var self = this;
        closeAll.onclick = function() {
            for(var i=0;i<self.divs.length;i++)
                self.divs[i].style.display = 'none';
            this.style.display = 'none';
        }
        this.closeAllDiv = closeAll;
    }
    this.show = function()
    {
        for(var i=0;i<this.divs.length;i++)
            document.body.appendChild( this.divs[i] );
        document.body.appendChild( this.closeAllDiv );
        window.scroll(0,0);
    }
    this.init();
}
