var pop = null;

function Pop(width, height, content)
{
	this.width = width;
	this.height = height;
	this.content = content;
	
	this.elScreen = document.createElement( "DIV" );
	this.elContent = document.createElement( "DIV" );
	this.elClose = document.createElement( "DIV" );
	
    this.elScreen.style.position = "absolute";
    this.elScreen.style.display = "block";
    this.elScreen.style.background = "#000000";
    this.elScreen.style.opacity = 0.7;
    this.elScreen.style.filter = "alpha(opacity=70)";
    if( this.elScreen.style.setAttribute )
        this.elScreen.style.setAttribute( "-moz-opacity", "0.7" );
    this.elScreen.style.width = "1px";
    this.elScreen.style.height = "1px";
    this.elScreen.style.zIndex = 100;
    document.body.appendChild( this.elScreen );

    this.elContent.style.display = "block";
    this.elContent.style.position = "absolute";
    this.elContent.style.width = this.width + "px";
    this.elContent.style.height = this.height + "px";
    this.elContent.style.border = "none";
    this.elContent.style.zIndex = 101;
    this.elContent.style.background = "#ffffff";
    this.elContent.innerHTML = content;
    document.body.appendChild( this.elContent );    
    
    this.elClose.style.display = "block";
    this.elClose.style.position = "absolute";
    this.elClose.style.width = this.width + "px";
    this.elClose.style.height = "11px";
    this.elClose.style.padding = "4px 0px 4px 0px";
    this.elClose.style.background = "#cfcfcf";
    this.elClose.style.borderLeft = "#ffffff";
    this.elClose.style.borderRight = "#ffffff";
    this.elClose.style.borderBottom = "#ffffff";
    this.elClose.style.zIndex = 101;
    this.elClose.style.textAlign = "center";
    this.elClose.innerHTML = "<A style=\"color: #526c93; font-weight: normal; font-size: 10px; text-transform: uppercase;\" href=\"javascript:vopen_close();\">Chiudi</A>";
    document.body.appendChild( this.elClose );
    
   if( document.documentElement !== undefined ) {
        document.documentElement.style.overflow = "hidden";
        document.body.style.overflow = "hidden";
    } else {
        document.body.style.overflow = "hidden";
    }

    this.positionElements();
}

Pop.prototype.close = function()
{
	document.body.removeChild( this.elContent );
	document.body.removeChild( this.elClose );
	document.body.removeChild( this.elScreen );
	this.elContent = null;
	this.elClose = null;
	this.elScreen = null;

    if( document.documentElement !== undefined ) {
        document.documentElement.style.overflow = "";
        document.body.style.overflow = "";
    } else {
        document.body.style.overflow = "";
    }
}

Pop.prototype.positionElements = function()
{
    var mtx = getDocMetrics();

    this.elScreen.style.left = mtx.offX + "px";
    this.elScreen.style.top = mtx.offY + "px";
    this.elScreen.style.width = mtx.width + "px";
    this.elScreen.style.height = mtx.height + "px";
    this.elContent.style.left = (mtx.offX + ((mtx.width - this.width)/2)) + "px";
    this.elContent.style.top = (mtx.offY + ((mtx.height - this.height)/2)) + "px";
    this.elClose.style.left = (mtx.offX + ((mtx.width - this.width)/2)) + "px";
    this.elClose.style.top = ((mtx.offY + ((mtx.height - this.height)/2)) + this.height) + "px";
}


function vopen_ext(link)
{
	if( pop != null )
		return;
		
	var mx = getDocMetrics();
	var width = Math.round(mx.width * 0.75);
	var height = Math.round(mx.height * 0.75);
		
	pop	= new Pop( width, 
				   height,
				   "<IFRAME style=\"border: none; padding: none; width: " + width + "; height: " + height + ";\" frameborder=\"0\" align=\"center\" src=\"" + link + "\" width=\"" + width + "\" height=\"" + height + "\"></IFRAME>" );
}

function vopen_you(emc)
{
	if( pop != null )
		return;
		
	var width = 425;
	var height = 344;

	pop	= new Pop( width, 
				   height,
				   "<object width=\"425\" height=\"344\"><param name=\"movie\" value=\"" + emc + "&hl=it&fs=1\"></param><param name=\"allowFullScreen\" value=\"true\"></param><param name=\"allowscriptaccess\" value=\"always\"></param><embed src=\"" + emc + "&hl=it&fs=1\" type=\"application/x-shockwave-flash\" allowscriptaccess=\"always\" allowfullscreen=\"true\" width=\"425\" height=\"344\"></embed></object>" );
}

function vopen_close()
{
	if( pop == null ) return;
	pop.close();
	pop = null;
}
