var _st="";
var _win=null;


function showpop_gallery(image, width, height, image_count)
{
	var x = Math.round((screen.availWidth - width) / 2);
	var y = Math.round((screen.availHeight - height) / 3);
	height += 20;
	window.open("../popup.php?image=./gallery/" + image + "&image_count=" + image_count,"_blank","width=" + width + ",height=" + height + ",left=" + x + ",top=" + y + ",toolbar=no,menubar=no,resizable=no,scrollbars=no,status=no,location=no");
	return false;
}


function showpop(image, width, height, image_count)
{
var x = Math.round((screen.availWidth - width) / 2);
var y = Math.round((screen.availHeight - height) / 3);
var regexp = /([\d+])[\.]jpg/ig;
var index = regexp.exec(image);
var image_number = 1;
var image_number_next = 1;
var image_number_previous = 1;
var image_prev = new String(image);
var image_next = new String(image);

if (index.length > 0)
{
	image_number = eval(index[0].replace(regexp, "$1"));
        image_number_next = (image_number == image_count) ? 1 : image_number + 1;
	image_number_previous = (image_number == 1) ? image_count :  image_number - 1;
	image_prev = image_prev.replace(regexp, image_number_previous + ".jpg");
        image_next = image_next.replace(regexp, image_number_next + ".jpg");
        //alert(image_number_next + "===" + image_number_previous);
        //alert(image_next+"==="+image_prev);

}
_st="";
_st+="<html><head><META http-equiv=Content-Type content='text/html; charset=windows-1251'>";
_st+="<title>Галерея объектов группы компаний NeоDеcor</title></head><body marginwidth=0 marginheight=0 leftmargin=0 topmargin=0 bgcolor=#EBEBEB><table width='100%' height='100%' border='0' cellpadding='' cellspacing='0'><tr><td height='40' align='right' bgcolor='#721E1E'><img src='/images/logo_small.gif' width='127' height='18' alt=''><img src='/images/1x1.gif' width='15' height='1' alt=''></td></tr><tr><td bgcolor=#FFD285><img src='/images/1x1.gif' width='15' height='2' alt=''></td></tr><tr><td height='100%' background='/images/loading.gif'  style='background-repeat: no-repeat; background-position: center'>";
_st+="<img src=" + image + " border=0 alt=\"Кликните по картинке для закрытия окна\" onclick=\"window.close()\">";
_st+='</td></tr><tr><td height="15"><table border="0" width="100%" cellpadding="0" cellspacing="0"><tr>';
_st+='<td><a href=\"#\" onClick=\"showpop(\'' + image_prev + '\', '+width+','+height+', '+image_count+')\" target=\"_self\">&laquo;назад</a></td>';
_st+='<tD align="right"><a href="#">вперед&raquo;</a></td></td></tr></tr></table></td></tr>';
_st+="</td></tr></table></body>";

//height += 20;
//alert(height);
_win=window.open("","","width=" + width + ",height=" + height + ",left=" + x + ",top=" + y + ",toolbar=no,menubar=no,resizable=no,scrollbars=no,status=no,location=no");
_win.document.open();
_win.document.write(_st);
_win.document.close();
return false;
}

function showpopsimple(image, width, height)
{
var x = Math.round((screen.availWidth - width) / 2);
var y = Math.round((screen.availHeight - height) / 3);

_st="";
_st+="<html><head><META http-equiv=Content-Type content='text/html; charset=windows-1251'>";
_st+="<title>Галерея объектов группы компаний NeоDecor</title></head><body marginwidth=0 marginheight=0 leftmargin=0 topmargin=0 bgcolor=#EBEBEB><table width='100%' height='100%' border='0' cellpadding='' cellspacing='0'><tr><td height='40' align='right' bgcolor='#721E1E'><img src='/images/logo_small.gif' width='127' height='18' alt=''><img src='/images/1x1.gif' width='15' height='1' alt=''></td></tr><tr><td bgcolor=#FFD285><img src='/images/1x1.gif' width='15' height='2' alt=''></td></tr><tr><td height='100%' background='/images/loading.gif'  style='background-repeat: no-repeat; background-position: center'>";
_st+="<img src=" + image + " border=0 alt=\"Кликните по картинке для закрытия окна\" onclick=\"window.close()\">";
_st+="</td></tr></table></body>";

//height += 20;
//alert(height);
_win=window.open("","","width=" + width + ",height=" + height + ",left=" + x + ",top=" + y + ",toolbar=no,menubar=no,resizable=no,scrollbars=no,status=no,location=no");
_win.document.open();
_win.document.write(_st);
_win.document.close();
return false;
}
