

var dx, dy, newWindow;

function winOpen(imgPath){
	dx=(screen.width-400)/2;
	dy=(screen.height-400)/2;
  
	newWindow = open("","myWin","toolbar=no,location=no,directories=no,"+
	"status=no,scrollbars=no,resizable=no,width=500,height=310"+
	"copyhistory=no,top="+dy+",left="+dx);
	
	newWindow.focus();
	
	newWindow.document.open();
	
	newWindow.document.write ("<html><head><title>Рузский район</title></head>"+
	"<body leftmargin=0 topmargin=0 marginwidth=0 marginheight=0>"+
	"<table width=500 height=310 border=0 cellpadding=0 cellspacing=0><td align=center bgcolor=#D4D4D4><img src="+imgPath+"></td></table></body></html>");

	newWindow.document.close();
}

NumTotal = 70; // размер область чисел для выборки
SelectSize = 2; // размер выборки чисел

ArrayNum = new Array(SelectSize); // здесь будем хранить выборку

function RandomSelect() { // функция произвольной выборки
	 return Math.round(Math.random()*(NumTotal-1)+1);
}

function CheckNoRepeat(ArrayForCheck,CheckNumber) {  //функция, нет ли такого числа в массиве
	for (k = 0; k < ArrayForCheck.length; k++){
		if (ArrayForCheck[k] == CheckNumber) { 
			return true;
		}
	}
} 

for (i = 0; i < SelectSize; i++) {
	do {
		CurrentRandom = RandomSelect();	             //берем случайное число,  
	} while (CheckNoRepeat(ArrayNum,CurrentRandom)); //пока не окажется, что его нет в массиве

	ArrayNum[i] = CurrentRandom;                     //и это случайное уникальное число добавляем  в массив
}

for (l=0; l < SelectSize; l++) {

	document.write("<a href=\"javascript:void(0);\" onClick=\"winOpen(\'");
	document.write("fotos/"+ArrayNum[l]);
	document.write(".jpg\');\"><img src=fotos");
	document.write("/sm"+ArrayNum[l]);
	document.write(".jpg border=0 vspace=7></a> <br>");
}


