function changeState(layerRef, state)
{ 
	var blockElement = document.getElementById(layerRef).style;
	blockElement.display = state;
}

function NextImg (button)
{
	var LastImage = FirstImage+8;
	var blockFirst, blockLast, blockNext, blockBack;
	blockNext = document.getElementById('next').style;
	blockBack = document.getElementById('back').style;
	
	if (button=='next')
	{
		blockFirst = document.getElementById('model_'+FirstImage).style;
		LastImage++;
		blockLast = document.getElementById('model_'+LastImage).style;
		blockFirst.display = 'none';
		blockLast.display = 'block';
		blockBack.display = 'block';
		if (LastImage == SizeMenu) blockNext.display = 'none';
		FirstImage++;		
	}
	else {	
		FirstImage--;
		blockFirst = document.getElementById('model_'+FirstImage).style;
		blockLast = document.getElementById('model_'+LastImage).style;
		blockFirst.display = 'block';
		blockLast.display = 'none';
		blockNext.display = 'block';
		if (FirstImage == 1) blockBack.display = 'none';
		
	}
}


// Wopen 3.1 
var toolX=10;
var toolY=37;
if (navigator.userAgent.indexOf("Opera")>-1) {toolY+=0;toolY+=13;}
if (navigator.userAgent.indexOf("Firefox")>-1) {toolX-=3;toolY-=4;}
function wopen3(imgName) {
	var wo = window.open("", "picture", "width=150px, height=100px, scrollbars=0, status=0" );
	wo.document.open();
	wo.document.writeln("<html><head>");
	wo.document.writeln("<style>body{margin:0;}img{display:block;border:0;cursor:pointer;}</style>");
	wo.document.writeln("<script>");
	wo.document.writeln("function resize(x,y){ self.window.resizeTo(x+"+toolX+",y+"+toolY+");");
	wo.document.writeln("document.getElementById('loading').style.display='none';}");
	wo.document.writeln("function error(){ document.getElementById('loading').innerHTML='Картинка не найдена<br>"+imgName+"'; }");
	wo.document.writeln("</script>");
	wo.document.writeln("</head><body>");
	wo.document.writeln("<div id='loading' style='padding:37px 5px 0 5px; height: 100px; width:150px; text-align:center; font-size:15px;'>Идёт загрузка</div>");
	wo.document.writeln("<div onclick='self.window.close();'><img onload='resize(this.width,this.height);' onerror='error()' src='"+imgName+"' alt=''></div>");
	wo.document.writeln("</body></html>");
	wo.window.focus();
	wo.document.close();
}

