function switchImage(a)
{
	img = document.getElementById("mainimage");
	img.src = a;
}

function writePages (n_pages) 
{
	if(document.location.href.indexOf("action=viewImage") > -1) return false;
	document.write('<p><b>* Пожалуйста дождитесь загрузки всех изображений.<br>При клике на превью открываются фото большего размера.</b></p>');
	var n_links = 10;
	var pattern = /^(.*)([\d]+)$/;
	
	var path = window.location + "?resultPage=";
	var n = 1;
	if (pattern.exec(window.location))
	{
		path = RegExp.$1;
		n = parseInt(RegExp.$2);
	}

	document.write('<table cellpadding="3" cellspacing="5" border="0" class="pag-nav"><tr>');	
	if (n != 1)
		document.write('<td><a href="' + path + (n - 1) + '"><< Предыдущая</a>&nbsp;</td>');

	if (n_links) {
		if (n_links > n_pages)
			n_links = n_pages;
		document.write('<td>');
		var n_sideLinks = Math.floor((n_links - 1) / 2),
			n_firstLink, n_lastLink;
		
		if (n + n_sideLinks >= n_pages) {
			n_firstLink = n_pages - n_links + 1;
			n_lastLink = n_pages;
		}
		else if (n - n_sideLinks <= 0) {
			n_firstLink = 1;
			n_lastLink = n_links;
		}
		else {
			n_firstLink = n - n_sideLinks;
			n_lastLink = n_firstLink + n_links - 1;
		}
		for (var i = n_firstLink; i <= n_lastLink; i++)
			document.write(i == n ? i + ' ' : '<a href="' + path + i + '" title="">' + i + '</a> ');
		document.write('</td>');
	}
	
	if (n != n_pages)
		document.write('<td>&nbsp;<a href="' + path + (n + 1) + '">Следующая >></a></td>');
	document.write('</tr></table>');
}


//POPUPы
function openWindow1(aOb,width,height) {
	var url_image = aOb.getAttribute('href');
	var width = width?width:500;
	var height = height?height:500;
	var left = parseInt((screen.width - width)/2);
	var top = parseInt((screen.height - height)/2);
	var dsdWindow = window.open("","",'left='+left+',top='+top+',width='+width+',height='+height+',toolbar=no,status=no,menubar=no,scrollbars=no,resizable=no');
	dsdWindow.document.write("<center><img src=" + url_image + "></center>");
	dsdWindow.document.write("<br><h2>Круглый модуль</h2><ul><li>&Oslash; 50,60</li><li>H от 4 до 14 см</li>");
	dsdWindow.document.write("<li><b>Цена</b> <ul><li>&Oslash; – 50, H – 14</li><li>&Oslash; – 50, H – 4</li></ul></li></ul>");
	return false;
}
function openWindow2(aOb,width,height) {
	var url_image = aOb.getAttribute('href');
	var width = width?width:500;
	var height = height?height:500;
	var left = parseInt((screen.width - width)/2);
	var top = parseInt((screen.height - height)/2);
	var dsdWindow = window.open("","",'left='+left+',top='+top+',width='+width+',height='+height+',toolbar=no,status=no,menubar=no,scrollbars=no,resizable=no');
	dsdWindow.document.write("<center><img src=" + url_image + "></center>");
	dsdWindow.document.write("<br><h2>Кубический модуль</h2>");	
	dsdWindow.document.write("<ul><li>50х50х50</li><li>40х40х40</li></ul>");
	return false;
}
function openWindow3(aOb,width,height) {
	var url_image = aOb.getAttribute('href');
	var width = width?width:500;
	var height = height?height:500;
	var left = parseInt((screen.width - width)/2);
	var top = parseInt((screen.height - height)/2);
	var dsdWindow = window.open("","",'left='+left+',top='+top+',width='+width+',height='+height+',toolbar=no,status=no,menubar=no,scrollbars=no,resizable=no');
	dsdWindow.document.write("<center><img src=" + url_image + "></center>");
	dsdWindow.document.write("<br><h2>Плоский модуль 1, 2</h2><ul><li>60х100х8</li><li>60х100х5</li><li>100х100х5</li><li>100х100х8</li><li>100х200х5</li><li>100х200х8</li></ul>");
	return false;
}
function openWindow4(aOb,width,height) {
	var url_image = aOb.getAttribute('href');
	var width = width?width:500;
	var height = height?height:500;
	var left = parseInt((screen.width - width)/2);
	var top = parseInt((screen.height - height)/2);
	var dsdWindow = window.open("","",'left='+left+',top='+top+',width='+width+',height='+height+',toolbar=no,status=no,menubar=no,scrollbars=no,resizable=no');
	dsdWindow.document.write("<center><img src=" + url_image + "></center>");
	dsdWindow.document.write("<br><h2>Полуцилиндрический модуль</h2><ul><li>60хR15</li></ul>");
	return false;
}
function openWindow5(aOb,width,height) {
	var url_image = aOb.getAttribute('href');
	var width = width?width:500;
	var height = height?height:500;
	var left = parseInt((screen.width - width)/2);
	var top = parseInt((screen.height - height)/2);
	var dsdWindow = window.open("","",'left='+left+',top='+top+',width='+width+',height='+height+',toolbar=no,status=no,menubar=no,scrollbars=no,resizable=no');
	dsdWindow.document.write("<center><img src=" + url_image + "></center>");
	dsdWindow.document.write("<br><h2>Прямоугольный модуль 1, 2, 3, 4</h2>");
	dsdWindow.document.write("<ul><li>60х30х30</li><li>60х40х40</li><li>80х20х20</li><li>100х25х25</li><li>200х30х30</li><li>120х30х30</li><li>120х30х30</li></ul>");
	return false;
}
function openWindow6(aOb,width,height) {
	var url_image = aOb.getAttribute('href');
	var width = width?width:500;
	var height = height?height:500;
	var left = parseInt((screen.width - width)/2);
	var top = parseInt((screen.height - height)/2);
	var dsdWindow = window.open("","",'left='+left+',top='+top+',width='+width+',height='+height+',toolbar=no,status=no,menubar=no,scrollbars=no,resizable=no');
	dsdWindow.document.write("<center><img src=" + url_image + "></center>");
	dsdWindow.document.write("<br><h2>Секторный модуль</h2>");
	dsdWindow.document.write("<ul><li>R 25 </li><li>H от 4 до 14 см</li><li><b>Цена</b> R 25 H 14</li></ul>");
	return false;
}
function openWindow7(aOb,width,height) {
	var url_image = aOb.getAttribute('href');
	var width = width?width:500;
	var height = height?height:500;
	var left = parseInt((screen.width - width)/2);
	var top = parseInt((screen.height - height)/2);
	var dsdWindow = window.open("","",'left='+left+',top='+top+',width='+width+',height='+height+',toolbar=no,status=no,menubar=no,scrollbars=no,resizable=no');
	dsdWindow.document.write("<center><img src=" + url_image + "></center>");
	dsdWindow.document.write("<br><h2>Треугольный модуль 1, 2, 3</h2>");
	dsdWindow.document.write("<ul><li>основание 50 высота 50 толщина 50</li><li>основание 40 высота 40 толщина 40</li><li>основание 50 высота 25 толщина 50</li><li>основание 40 высота 20 толщина 40</li><li>основание 50 высота 43 толщина 40</li></ul>");
	return false;
}
function openWindow8(aOb,width,height) {
	var url_image = aOb.getAttribute('href');
	var width = width?width:500;
	var height = height?height:500;
	var left = parseInt((screen.width - width)/2);
	var top = parseInt((screen.height - height)/2);
	var dsdWindow = window.open("","",'left='+left+',top='+top+',width='+width+',height='+height+',toolbar=no,status=no,menubar=no,scrollbars=no,resizable=no');
	dsdWindow.document.write("<center><img src=" + url_image + "></center>");
	dsdWindow.document.write("<br><h2>Угловой модуль 1 (ступенька)</h2>");
	dsdWindow.document.write("<ul><li>40х40х20</li><li>50х50х25</li></ul>");
	return false;
}
function openWindow9(aOb,width,height) {
	var url_image = aOb.getAttribute('href');
	var width = width?width:500;
	var height = height?height:500;
	var left = parseInt((screen.width - width)/2);
	var top = parseInt((screen.height - height)/2);
	var dsdWindow = window.open("","",'left='+left+',top='+top+',width='+width+',height='+height+',toolbar=no,status=no,menubar=no,scrollbars=no,resizable=no');
	dsdWindow.document.write("<center><img src=" + url_image + "></center>");
	dsdWindow.document.write("<br><h2>Угловой модуль 2 (горка)</h2>");
	dsdWindow.document.write("<ul><li>50х50х80(10)</li><li>40х40х60(10)</li></ul>");
	return false;
}
function openWindow10(aOb,width,height) {
	var url_image = aOb.getAttribute('href');
	var width = width?width:500;
	var height = height?height:500;
	var left = parseInt((screen.width - width)/2);
	var top = parseInt((screen.height - height)/2);
	var dsdWindow = window.open("","",'left='+left+',top='+top+',width='+width+',height='+height+',toolbar=no,status=no,menubar=no,scrollbars=no,resizable=no');
	dsdWindow.document.write("<center><img src=" + url_image + "></center>");
	dsdWindow.document.write("<br><h2>Цилиндрический модуль</h2>");
	dsdWindow.document.write("<ul><li>D 50 H 48</li><li>D 30 H 90</li><li>D 20 H 80</li><li>D 20 H 60");
	dsdWindow.document.write("</li></ul>");
	return false;
}
