var n = 0;
var m = 0;   
function winOpen(loc)
{
    n++;
	var width = 600;
	var height = 550;
	x = (640 - width)/2, y = (480 - height)/2;
	if (screen) {
		var y = (screen.availHeight - height)/2;
		var x = (screen.availWidth - width)/2;
	}
		if (screen.availWidth > 1800) {
		var x = ((screen.availWidth/2) - width)/2;
	}
	var win = window.open(loc, n, 'width='+width+',height='+height+',screenX='+x+',screenY='+y+',top='+y+',left='+x+',titlebar=1,resizable=yes,scrollbars=1');
}
function GalOpen(pic, width, height, title,i,all,p,mod)
{
	m++;
    winh=600;
    winw=800;
    a=b=murl=next=prew='';
    if(all!=1)
    {
        if(mod!=5) murl= '&m='+mod;
        winh+=+22;
        if(width<200)width=200;
        if(i < all)
        {
            z = parseInt(i) + 1;
            a ='<a title="Следущая" href="/include/modules/gallery_pic.php?p='+p+murl+'&i='+z+'&lang=rus">';
            b ='</a>';
            next =' <a href="/include/modules/gallery_pic.php?p='+p+murl+'&i='+z+'&lang=rus">Следующая &rarr;</a>';
        }
    }
	x = (640 - width)/2, y = (580 - winh)/2;
	if (screen) {
		var y = (screen.availHeight - winh)/2;
		var x = (screen.availWidth - winw)/2;
	}
		if (screen.availWidth > 1800) {
		var x = ((screen.availWidth/2) - winw)/2;
	}
	//alert(x+','+y);
	var win = window.open("", m, 'width='+winw+',height='+winh+',screenX='+x+',screenY='+y+',top='+y+',left='+x+',titlebar=no,resizable=no,scrollbars=no');
	win.document.open();
	str = '<html>'+
			'<head><meta http-equiv="Content-Type" content="text/html; charset=windows-1251"><title>'+title+'</title>'+
			'<link rel="stylesheet" type="text/css" href="/css/global.css">'+
			'</head>'+
			'<body style="margin:0; padding: 15px 0">'+
			'<table width="100%" cellpadding="0" cellspacing="0" border="0" height="100%">'+
				'<tr>'+
					'<td colspan="3" align="center" height="100%" >';
 	str += a;
	str += '<img class="galary" src="/'+pic+'" width="'+width+'" height="'+height+'" border="0" alt="'+title+'">'+b+'</td></tr>';
	win.document.writeln(str);
	if(all!=1)
    {
        if(i > 1)
        {
            z=parseInt(i)-1;
            prew ='<a href="/include/modules/gallery_pic.php?p='+p+murl+'&i='+z+'&lang=rus">&larr; Предыдущая</a> ';
			if(i < Number(all))
			{
				z=parseInt(i) + 1;
	            next='<a href="/include/modules/gallery_pic.php?p='+p+murl+'&i='+z+'&lang=rus">Следующая &rarr;</a> ';
			}
		}
	    win.document.writeln('<tr align="center" valign="middle"><td width="35%">'+prew+'</td><td width="30%" height="20">'+i+'/'+all+'</td><td width="35%">'+next+'</td></tr>');
    }
    win.document.writeln('</table></body></html>');
	win.document.close();
}
