function ChangePro()
{
	pr = document.getElementById('prod'+CurPro);
	pr.style.display = 'none';
	ps = document.getElementById('ProSel');
	CurPro = ps.value;
	pr = document.getElementById('prod'+CurPro);
	pr.style.display = 'block';
	
}

function getScrollTop()
{
    return document.documentElement.scrollTop || document.body.scrollTop;
}


function ShowPhoto(path,width,height)
{
	scTop = getScrollTop();
	
	for (i=1; i<=fnames.length; i++)
	{
		if (fnames[i]==path) curI=i;
	}
	
	tl = document.getElementById('ToLeft');
	tr = document.getElementById('ToRight');
	tli = document.getElementById('ToLeftImg');
	tri = document.getElementById('ToRightImg');
	
	if ((curI-1)!=0)
	{	
	tli.innerHTML = '<img src="/img/.gif" width="17" height="33"  onclick=ShowPhoto("'+fnames[(curI-1)]+'",'+fwidths[(curI-1)]+','+fheights[(curI-1)]+')>';
	tl.style.display = 'block';
	tl.style.marginTop = -44 + scTop + 'px';
	tli.style.display = 'block';
	tli.style.marginTop = -44 + scTop + 'px';
	} else
		{
			tl.style.display = 'none';
			tli.style.display = 'none';
		}
	
	if ((curI+1)<fnames.length)
	{
	tri.innerHTML = '<img src="/img/.gif" width="17" height="33" onclick=ShowPhoto("'+fnames[(curI+1)]+'",'+fwidths[(curI+1)]+','+fheights[(curI+1)]+')>';
	tr.style.display = 'block';
	tr.style.marginTop = -16 + scTop + 'px';
	tri.style.display = 'block';
	tri.style.marginTop = -16 + scTop + 'px';
	} else
		{
			tr.style.display = 'none';
			tri.style.display = 'none';
		}
	
				
	int = document.getElementById('interlaced');
	int.style.height = document.documentElement.scrollHeight + 'px';
	int.style.visibility = 'visible';
	view = document.getElementById('ViewPhoto');
	vd = document.getElementById('Vdiv');
	foto = document.getElementById('Fotka');
	foto.innerHTML = '<img src="'+path+'" onclick="HidePhoto();">';

	if (GalType==1) document.getElementById('moreinfo').innerHTML = '<a href="'+folink[curI]+'">Подробнее об этой лестнице</a> &rarr;'; else document.getElementById('moreinfo').innerHTML = '';
	
	view.style.width = width + 'px';
	vd.style.width = width + 'px';
	view.style.height = height + 30 + 'px';
	view.style.marginLeft = -Math.round(width/2) + 'px';
	view.style.marginTop = -Math.round(height/2) - 35 + scTop + 'px';
	view.style.display = 'block';
}

function ShowPhotoX(path,width,height)
{
	scTop = getScrollTop();
	view = document.getElementById('ViewPhoto');
	vd = document.getElementById('Vdiv');
	foto = document.getElementById('Fotka');
	foto.innerHTML = '<img src="'+path+'" onclick="HidePhoto();">';
	view.style.width = width + 'px';
	vd.style.width = width + 'px';
	view.style.height = height + 30 + 'px';
	view.style.marginLeft = -Math.round(width/2) + 'px';
	view.style.marginTop = -Math.round(height/2) - 35 + scTop + 'px';
	view.style.display = 'block';
	

	int = document.getElementById('interlaced');
	int.style.height = document.documentElement.scrollHeight + 'px';
	int.style.visibility = 'visible';


}

function HidePhoto()
{
	tl = document.getElementById('ToLeft');
	tr = document.getElementById('ToRight');
	tr.style.display = 'none';
	tl.style.display = 'none';
	tli = document.getElementById('ToLeftImg');
	tri = document.getElementById('ToRightImg');
	tri.style.display = 'none';
	tli.style.display = 'none';
	view = document.getElementById('ViewPhoto');
	view.style.display = 'none';
	int = document.getElementById('interlaced');
	int.style.height = '100px';
	int.style.visibility = 'hidden';
	

}


var curPhoto = 1;
	
function GoRight()
{
	curPhoto = curPhoto + 1;
	document.getElementById('cpic').innerHTML = '<img src="/photos/'+fnames[curPhoto]+'">';
	if (!fnames[curPhoto+1]) document.getElementById('rarr').style.display = 'none';
	if (fnames[curPhoto-1]) document.getElementById('larr').style.display = 'block';
	document.getElementById('tx1').innerHTML = falts[curPhoto];
	document.getElementById('tx2').innerHTML = falts[curPhoto];
}

function GoLeft()
{
	curPhoto = curPhoto - 1;
	document.getElementById('cpic').innerHTML = '<img src="/photos/'+fnames[curPhoto]+'">';
	if (fnames[curPhoto+1]) document.getElementById('rarr').style.display = 'block';
	if (!fnames[curPhoto-1]) document.getElementById('larr').style.display = 'none';
	document.getElementById('tx1').innerHTML = falts[curPhoto];
	document.getElementById('tx2').innerHTML = falts[curPhoto];
}

function SubmitMessage()
{
	sm=true;
	if (!checkEmpty(document.MessageForm.name.value)) 
		{
	alert('Введите имя!');
	sm=false;	
		}
	if (!checkEmpty(document.MessageForm.email.value)) 
		{
	alert('Введите e-mail!');
	sm=false;	
		}
	if (!checkEmpty(document.MessageForm.content.value)) 
		{
	alert('Введите ваше сообщение!');
	sm=false;	
		}
	if (sm==true) {document.MessageForm.submit();}		
}

function SubmitMessage1()
{
	sm=true;
	if (!checkEmpty(document.MessageForm.name.value)) 
		{
	alert('Введите имя!');
	sm=false;	
		}
	if (!checkEmpty(document.MessageForm.email.value)) 
		{
	alert('Введите e-mail!');
	sm=false;	
		}
	if (sm==true) {document.MessageForm.submit();}		
}

function checkEmpty (val){
	if (val=="" || val.search(/[^\s]+/)==-1) {
		return false;
	}
	return true;
}


