



function vmpopup(image,nWidth,nHeight,sTilte,nColor,nMargin)
{
	if (nColor=="") 
	{
		nColor="#FFFFFF";
	}
	var adj=10;
	var w = screen.width;
	var h = screen.height;
    var agent=navigator.userAgent.toLowerCase();

    if(agent.indexOf("opera") != -1)
    {
    w = document.body.clientWidth;
    h = document.body.clientHeight;
    }
    
    var byFactor=1;
	
	if(w<740)
	{
		var lift=0.90;
	}
	
	if(w>=740 & w<835)
	{
	var lift=0.91;
	}
	
    if(w>=835)
    {
    var lift=0.93;
    }
    
    if (nWidth>w)
    {	
    byFactor = w / nWidth;
    nWidth = w;
    nHeight = nHeight * byFactor;
    }
    
    if (nHeight>h-adj)
    {
    byFactor = h / nHeight;
    nWidth = (nWidth * byFactor);
    nHeight = h; 
    }

    var scrWidth = w-adj;
    var scrHeight = (h*lift)-adj;
     
    if (nHeight>scrHeight)
    {
    nHeight=nHeight*lift;
    nWidth=nWidth*lift;
    }
    
    var posLeft=0;
    var posTop=0;
    
    if (nMargin < 0)
    {nMargin=0}
    
    nMargin*=2;
    var nTemp = parseInt(nHeight) + nMargin;
    
    if (nTemp < scrHeight) 
    {
    scrHeight = nTemp;
    } 
    
    nTemp = parseInt(nWidth) + nMargin;
    
    if (nTemp < scrWidth) 
    {
    scrWidth = nTemp;
    }
    
    if (scrHeight<100)
    {scrHeight=100;}
    
    if (scrWidth<100)
    {scrWidth=100;}
    
    posTop =  ((h-(scrHeight/lift)-adj)/2);
    posLeft = ((w-(scrWidth)-adj)/2);
    
    if (nHeight > (h*lift)-adj || nWidth > w-adj)
    {
    nHeight=nHeight-adj;
    nWidth=nWidth-adj;
    }
    
    posTop = parseInt(posTop);
    posLeft = parseInt(posLeft);		
    scrWidth = parseInt(scrWidth); 
    scrHeight = parseInt(scrHeight);
    newWindow = window.open("","","width="+scrWidth+",height="+scrHeight+",left="+posLeft+",top="+posTop);
    
    if(newWindow!=null)
    {
	    newWindow.document.open();
	    newWindow.document.write('<html><title>'+sTilte+'</title>'); 
	    newWindow.document.write('<meta http-equiv="imagetoolbar" content="false">');
	    newWindow.document.write('<body leftmargin="0" topmargin="0" marginheight="0" marginwidth="0" bgcolor='+nColor+' onBlur="self.close()" onClick="self.close()">'); 
	    newWindow.document.write('<table width='+nWidth+' border="0" cellspacing="0" cellpadding="0" align="center" height='+scrHeight+' ><tr><td>');
	    newWindow.document.write('<img src="'+image+'" width='+nWidth+' height='+nHeight+' alt="Click to close window" >');
	    newWindow.document.write('</td></tr></table></body></html>');
	    newWindow.document.close();
	    newWindow.focus();
    }
    
    return false;
}