
function ShowDiv(div)
{
if(document.getElementById(div)!=null)
document.getElementById(div).style.display='block';
}
function HideDiv(div)
{
if(document.getElementById(div)!=null)
document.getElementById(div).style.display='none';
}
function ShowHall(id,oid,p)
{
	document.getElementById('href'+oid).className='noactivvariant';
	document.getElementById('href'+id).className='activvariant';
	$("#contenthall").css("background-position","0 "+p+"");
}
function ShowHall1(id,oid,oid1,p)
{
	document.getElementById('href'+oid1).className='noactivvariant';
	document.getElementById('href'+oid).className='noactivvariant';
	document.getElementById('href'+id).className='activvariant';
	$("#contenthall").css("background-position","0 "+p+"");
}
function ShowMenu(id)
{
	if(document.getElementById('mm1')!=null)
	{
	HideDiv('menu1');
	HideDiv('menu2');
	HideDiv('menu3');
	ShowDiv('menu'+id);
	for (i=1;i<20;i++)
	{
		if(document.getElementById('mm'+i)!=null)document.getElementById('mm'+i).className="nosel";
		else i=20;
	}
	document.getElementById('mm'+id).className="sel";
	}
	resize();
}
function Set(id,text)
{
	document.getElementById(id).innerHTML=text;
}
function resize()
{
document.getElementById("left").style.height=1+"px";
document.getElementById("right").style.height=1+"px";
var height=document.body.scrollHeight-240;
var width=document.body.scrollWidth;
if(width>1360) {document.getElementById('allbody').width=1360;width=1360;}
document.getElementById("left").style.height=height+"px";
document.getElementById("right").style.height=height+"px";
document.getElementById("top").style.width=width-38+"px";
document.getElementById("bottom").style.width=width-38+"px";
document.getElementById("left").style.visibility="visible";
document.getElementById("right").style.visibility="visible";
document.getElementById("top").style.visibility="visible";
document.getElementById("bottom").style.visibility="visible";
}
function setborders()
{
var height=document.body.scrollHeight-270;
var width=document.body.scrollWidth;
if(width>1360)  {document.getElementById('allbody').width=1360;width=1360;}
document.getElementById("left").style.height=height+"px";
document.getElementById("right").style.height=height+"px";
document.getElementById("top").style.width=width-38+"px";
document.getElementById("bottom").style.width=width-38+"px";
document.getElementById("left").style.visibility="visible";
document.getElementById("right").style.visibility="visible";
document.getElementById("top").style.visibility="visible";
document.getElementById("bottom").style.visibility="visible";
}
function ShowDivHide(div)
{
if(document.getElementById(div).style.display=='none')
document.getElementById(div).style.display='block';
else document.getElementById(div).style.display='none';
}
function ShowMovie(name)
{
	var arrayPageSize = getPageSize();
	var arrayPageScroll = getPageScroll();
	var lightboxTop = arrayPageScroll[1] + ((arrayPageSize[3] - 35) / 2);
	var lightboxLeft = ((arrayPageSize[0] - 20) / 2);
	var height=430;
	var width=600;
	document.getElementById('flashblock').style.top=lightboxTop;
	document.getElementById('flashblock').style.left=lightboxLeft;	
	document.getElementById('flashblock').style.width=0;
	document.getElementById('flashblock').style.height=0;
$('#flashblock').animate(
	{
		top: lightboxTop-height/2-20,
		left:lightboxLeft-width/2,
		width:width,
		height:height,
		opacity: 1,
		background:'transparent'
	},
	500
);
	setTimeout("AC_FL_RunContent("+
			"'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0',"+
			"'width', '600',"+
			"'height', '400',"+
			"'src', 'tour/"+name+"',"+
			"'quality', 'high',"+
			"'pluginspage', 'http://www.macromedia.com/go/getflashplayer',"+
			"'align', 'middle',"+
			"'play', 'true',"+
			"'loop', 'true',"+
			"'scale', 'showall',"+
			"'wmode', 'window',"+
			"'devicefont', 'false',"+
			"'id', 'tour/"+name+"',"+
			"'bgcolor', '#ffffff',"+
			"'name', 'tour/"+name+"',"+
			"'menu', 'true',"+
			"'allowFullScreen', 'false',"+
			"'allowScriptAccess','sameDomain',"+
			"'movie', 'tour/"+name+"',"+
			"'salign', ''"+
			"); ",600)
}
function CloseMovie()
{
	document.getElementById("flashblock").style.display="none";
	document.getElementById("flashmovie").innerHTML="";
}

function ShowImage(i)
{
	var id,width,height,comment;
	width=document.getElementById('wd'+i).value-2;
	height=document.getElementById('hd'+i).value;
	var arrayPageSize = getPageSize();
	var arrayPageScroll = getPageScroll();
	var lightboxTop = arrayPageScroll[1] + ((arrayPageSize[3] - 35) / 2)+30;
	var lightboxLeft = ((arrayPageSize[0] - 40) / 2);
	document.getElementById('backimagebox').style.height=arrayPageSize[1]+'px';
	document.getElementById('backimagebox').style.width=arrayPageSize[0]+'px';
	document.getElementById('backimagebox').style.display='block';
	document.getElementById('numimage').value=i;
	document.getElementById('imagebox').style.top=lightboxTop-height/2-20;
	document.getElementById('imagebox').style.left=lightboxLeft-width/2;	
	document.getElementById('imagebox').style.width=0;	
	document.getElementById('imagebox').style.height=0;	
$('#imagebox').animate(
	{
		top: lightboxTop-height/2-20,
		left:lightboxLeft-width/2,
		width:width,
		height:height,
		opacity: 1,
		backgroundColor:'#faf8e0'
	},
	500
);
	document.getElementById('imagecontent').style.width=width
	document.getElementById('imagecontent').style.height=height;
	document.getElementById('imagecontent').style.display='block';
	document.getElementById('closebutton').style.top=lightboxTop-height/2-10;
	document.getElementById('closebutton').style.left=lightboxLeft+width/2-30;		
	setTimeout("document.getElementById('closebutton').style.display='block';",1000)		
	lightboxLeft++;	
	document.getElementById('imageleft').style.width=width/2;
	document.getElementById('imageleft').style.height=height-80;	
	document.getElementById('imageleft').style.left=lightboxLeft-width/2-2;	
	document.getElementById('imageleft').style.top=lightboxTop-(height/2-40);
	setTimeout("document.getElementById('imageleft').style.display='block';",500);
	document.getElementById('imageright').style.width=width/2;	
	document.getElementById('imageright').style.height=height-80;
	document.getElementById('imageright').style.top=lightboxTop-(height/2-40);
	document.getElementById('imageright').style.left=lightboxLeft;	
	setTimeout("document.getElementById('imageright').style.display='block';",500);
	document.getElementById('imagecontent').innerHTML="<img id=image src='/admin/photos/"+document.getElementById('photoname'+i).value+"' style='opacity:0.01;filter:alpha(opacity=0.01);' onload=Display()>";	
	document.getElementById('imagecontent').style.backgroundImage="url(/img/loading.gif)";
}
function Display()
{
	document.getElementById('imagecontent').style.backgroundImage="none";
	$('#image').animate(
	{
		opacity: 1,
		background:"#faf8e0"
	},
	500
	);	
}
function animatehide()
{
	$('#image').animate(
	{
		opacity: 0,
		backgroundColor:"#faf8e0"
	},
	500
	);
	
}
function animateshow(lightboxTop,lightboxLeft,width,height,id)
{
	document.getElementById('imagecontent').innerHTML="<img id=image src='/admin/photos/"+document.getElementById('photoname'+id).value+"' style='opacity:0.01;filter:alpha(opacity=0.01);' onload=Display() width="+width+"px height="+height+"px>";	
	//document.getElementById('imagecontent').style.backgroundColor='#000000';
	document.getElementById('imagecontent').style.backgroundImage="url(/img/loading.gif)";
	//alert(100);
	$('#imagebox').animate(
	{
		top: lightboxTop-height/2-20,
		left:lightboxLeft-width/2,
		width:width,
		height:height,
		backgroundColor: '#faf8e0'
	},
	500
	);		
	$('#imagecontent').animate(
	{
		width:width,
		height:height
	},
	500
	);	
}
function ShowNext()
{
	var arrayPageSize = getPageSize();
	var arrayPageScroll = getPageScroll();
	var lightboxTop = arrayPageScroll[1] + ((arrayPageSize[3] - 35) / 2)+30;
	var lightboxLeft = ((arrayPageSize[0] - 40) / 2);
	var id,width,height,i,comment;
	i=document.getElementById('numimage').value;
	if(i!=document.getElementById('max_image').value){i++;}
	else i=1;
	width=document.getElementById('wd'+i).value;
	height=document.getElementById('hd'+i).value;	
	document.getElementById('imageright').style.display='none';
	document.getElementById('imageleft').style.display='none';
	animatehide();
	setTimeout('animateshow('+lightboxTop+','+lightboxLeft+','+width+','+height+','+i+')',500)
	lightboxLeft++;	
	document.getElementById('imageleft').style.width=width/2;
	document.getElementById('imageleft').style.height=height-80;	
	document.getElementById('imageleft').style.left=lightboxLeft-width/2-2;	
	document.getElementById('imageleft').style.top=lightboxTop-(height/2-40);
	setTimeout("document.getElementById('imageleft').style.display='block';",1500);
	document.getElementById('imageright').style.width=width/2;	
	document.getElementById('imageright').style.height=height-80;
	document.getElementById('imageright').style.top=lightboxTop-(height/2-40);
	document.getElementById('imageright').style.left=lightboxLeft;	
	setTimeout("document.getElementById('imageright').style.display='block';",1500);
	document.getElementById('closebutton').style.display='none'
	document.getElementById('closebutton').style.top=lightboxTop-height/2-10;
	document.getElementById('closebutton').style.left=lightboxLeft+width/2-30;		
setTimeout("document.getElementById('closebutton').style.display='block';",1500)	
	document.getElementById('numimage').value=i;

}
function ShowPrev()
{
	var arrayPageSize = getPageSize();
	var arrayPageScroll = getPageScroll();
	var lightboxTop = arrayPageScroll[1] + ((arrayPageSize[3] - 35) / 2)+30;
	var lightboxLeft = ((arrayPageSize[0] - 40) / 2);
	var id,width,height,i,comment;
	i=document.getElementById('numimage').value;
	if(i>1)	{i--;}
	else i=document.getElementById('max_image').value;
	width=document.getElementById('wd'+i).value;
	height=document.getElementById('hd'+i).value;
	document.getElementById('imageright').style.display='none';
	document.getElementById('imageleft').style.display='none';
	animatehide();
	setTimeout('animateshow('+lightboxTop+','+lightboxLeft+','+width+','+height+','+i+')',500)
	document.getElementById('imageleft').style.width=width/2-2;
	document.getElementById('imageleft').style.height=height-80;	
	lightboxLeft++;	
	document.getElementById('imageleft').style.left=lightboxLeft-width/2;	
	document.getElementById('imageleft').style.top=lightboxTop-(height/2-40);
	setTimeout("document.getElementById('imageleft').style.display='block';",1500);	
	document.getElementById('imageright').style.width=width/2;	
	document.getElementById('imageright').style.height=height-80;
	document.getElementById('imageright').style.top=lightboxTop-(height/2-40);
	document.getElementById('imageright').style.left=lightboxLeft;		
	setTimeout("document.getElementById('imageright').style.display='block';",1500);
document.getElementById('closebutton').style.display='none'
	document.getElementById('closebutton').style.top=lightboxTop-height/2-10;
	document.getElementById('closebutton').style.left=lightboxLeft+width/2-30;			
setTimeout("document.getElementById('closebutton').style.display='block';",1500)	
	document.getElementById('numimage').value=i;
}
function Activdiv(div)
{
	document.getElementById(div).style.backgroundImage='url(/img/close1.png)';
}
function unActivdiv(div)
{
	document.getElementById(div).style.backgroundImage='url(/img/close.png)';
}
function StopSlide()
{
document.getElementById('imagebox').style.display='none';
document.getElementById('imageleft').style.display='none';
document.getElementById('imageright').style.display='none';
document.getElementById('closebutton').style.display='none';
document.getElementById('backimagebox').style.display='none';
}

function showdivcenter(div)
{
	var arrayPageSize = getPageSize();
	var arrayPageScroll = getPageScroll();
	var obj=document.getElementById(div);
	if (obj) {
		obj.style.top = (arrayPageScroll[1] + ((arrayPageSize[3] - 600) / 2) + 'px');
		obj.style.left = (((arrayPageSize[0] - 20 - 300) / 2) + 'px');
		obj.style.display = 'block';		
	}
	else alert('no');
}
function isNotMax(e){
	e = e || window.event;
	var target = e.target || e.srcElement;
	var code=e.keyCode?e.keyCode:(e.which?e.which:e.charCode)
	if(target.value.length > target.getAttribute('maxlength')) target.value=target.value.substr(0,target.getAttribute('maxlength'))
	return target.value.length <= target.getAttribute('maxlength');
}
function clean()
{
		document.getElementById("errormessagecomment").innerHTML="";
		document.getElementById('codcomment').value="";
		document.getElementById("textreviewcomment").value="";
		document.getElementById("name_guestcomment").value="";	
		newcod=(Math.round(Math.random()*7+2)*10 + Math.round(Math.random()*1+1));
		document.getElementById('codbuttoncomment').src="cod/cod_"+newcod+".jpg";
		document.getElementById('comment').style.display='none';
		document.getElementById('lostletterscomment').innerHTML='0';
}

function sendreviewcomment(id_item)
{
	var name=document.getElementById("name_guestcomment").value;
	var text=document.getElementById("textreviewcomment").value;
	var id_message=document.getElementById("nummessage").value;
	var newcod;
	var cod=document.getElementById("codbuttoncomment").src;
	var len=cod.length;
	var ras=cod.substr(len-6,6);
	ras=ras.substr(0,2);
	ras=parseInt(ras);
	ras=ras*56-15;
	if(text=="" || document.getElementById("codcomment").value=="")
	{
		document.getElementById("errormessagecomment").innerHTML="Вы не заполнили все необходимые поля";
		document.getElementById('codcomment').value="";
		newcod=(Math.round(Math.random()*7+2)*10 + Math.round(Math.random()*1+1));
		document.getElementById('codbuttoncomment').src="cod/cod_"+newcod+".jpg";
		document.getElementById('codbuttoncomment').value=newcod;
	}
	else 
	if(document.getElementById("codcomment").value==ras)
	{
		ServerMessage1(id_item+'|'+name+'|'+text+'|'+id_message,'savemessagecomment','listmessages');
		document.getElementById("errormessagecomment").innerHTML="";
		document.getElementById('codcomment').value="";
		document.getElementById("textreviewcomment").value="";
		document.getElementById("name_guestcomment").value="";	
		newcod=(Math.round(Math.random()*7+2)*10 + Math.round(Math.random()*1+1));
		document.getElementById('codbuttoncomment').src="cod/cod_"+newcod+".jpg";
		document.getElementById('comment').style.display='none';
	}
	else 
	{
		document.getElementById("errormessagecomment").innerHTML="Неверный код";
		document.getElementById('codcomment').value="";
		newcod=(Math.round(Math.random()*7+2)*10 + Math.round(Math.random()*1+1));
		document.getElementById('codbuttoncomment').src="cod/cod_"+newcod+".jpg";
		document.getElementById('codbuttoncomment').value=newcod;
	}
}
function sendcomment()
{
	var feedback=true;
	var re2=/^[0-9a-zA-Z\-_]+@[0-9a-zA-Z\-_\.]+\.[a-zA-Z]{2,3}$/;	
	var fiotext=document.getElementById("namecomment").value;
	var mailtext=document.getElementById("mailcomment").value;
	var texttext=document.getElementById("textcomment").value;
	if(texttext==="") {feedback=false;pole="textcomment";}
	if(mailtext==="" || !re2.test(mailtext)) {feedback=false;pole="mailcomment";}
	if(fiotext==="") {feedback=false;pole="namecomment";}
	if(feedback==true)
	{
		document.getElementById("namecomment").value="";
		document.getElementById("mailcomment").value="";
		document.getElementById("textcomment").value="";
		ServerMessage1(fiotext+'|'+mailtext+'|'+texttext,"ifsend","ifsend");
		setTimeout('HideLetter()',2500);		
	}
	else
	{
		$("#"+pole).highlightFade({color:'#b7162c',speed:1000,iterator:'sinusoidal'});
	}
}
function HideLetter()
{
document.getElementById("ifsend").innerHTML="";
HideDiv("ifsend");
}
function setvalue(div,value)
{
	document.getElementById(div).value=value;
}

function ServerMessage1(keyword,table,name_div)
{
	var req;
	var sss;
	if (window.XMLHttpRequest)
	{
		req=new XMLHttpRequest();
	}
	else if (window.ActiveXObject)
	{
		try	{req=new ActiveXObject('MSXML2.XMLHTTP.3.0');}
		catch(e){}
	}
	if(req)
	{
		req.open("post","/ajax.php",true);
		req.setRequestHeader("Content-Type"," application/x-www-form-urlencoded;");
		req.onreadystatechange=function()
		{
	   	 if (req.readyState==4 && req.status==200)
	    	{
	    		sss=req.responseText;
	    		document.getElementById(name_div).innerHTML=sss;
				setborders();
	    	}
		}
		req.send('keyword='+table+'|'+encodeURIComponent(keyword));
	}
}
function ShowBigImage(name,div1,div2)
{
	if(document.getElementById('allowimage')!=null)
	{
	var arrayPageSize = getPageSize();
	var arrayPageScroll = getPageScroll();
	var lightboxTop = arrayPageScroll[1] + ((arrayPageSize[3] - 35) / 2);
	var lightboxLeft = ((arrayPageSize[0] - 20) / 2);
	document.getElementById(div2).style.top=lightboxTop-(document.getElementById(div1+'h').value/2);
	document.getElementById(div2).style.left=lightboxLeft-(document.getElementById(div1+'w').value/2);
	document.getElementById(div1).innerHTML="<img src='/admin/img/"+name+".jpg' id="+name+" style='opacity:0.01;filter:alpha(opacity=0.01);' onload=Display1('"+div2+"','"+name+"')>";	
	document.getElementById(div2).style.background="url(/img/loading.gif) no-repeat center center #faf8e0";	
	//document.getElementById(div1).innerHTML="<img src='/admin/img/"+name+".jpg'>";
	ShowDiv(div2);
	}
}
function Display1(div,name)
{
	document.getElementById(div).style.backgroundImage="none";
	$('#'+name).animate(
	{
		opacity: 1,
		background:"#faf8e0"
	},
	500
	);	
}
function ShowNew(id)
{
	if(document.getElementById('text'+id).style.display=='none')
	{
		for (i=1;i<=5;i++)
		{
		HideDiv('text'+i);ShowDiv('preview'+i);
		}
		HideDiv('preview'+id);
		ShowDiv('text'+id);
	}
	else
	{
		HideDiv('text'+id);
		ShowDiv('preview'+id);
	}
	resize();
}
function ShowTour(id)
{
	if(document.getElementById('tour'+id).className!="play")
	{
	var file=document.getElementById('nametour'+id).value;
	AC_FL_RunContent(	
	'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0',
			'width', '680',
			'height', '440',
			'src', file,
			'quality', 'high',
			'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
			'align', 'middle',
			'play', 'true',
			'loop', 'true',
			'scale', 'showall',
			'wmode', 'window',
			'devicefont', 'false',
			'id', file,
			'bgcolor', '#faf8e0',
			'name', file,
			'menu', 'true',
			'allowFullScreen', 'false',
			'allowScriptAccess','sameDomain',
			'movie', file,
			'salign', '');
	for(i=1;i<=13;i++)
	{
		if(document.getElementById('tour'+i)!=null)
		document.getElementById('tour'+i).className="";
		if(document.getElementById('btn'+i)!=null)
		document.getElementById('btn'+i).style.visibility="hidden";
	}
	document.getElementById('tour'+id).className="play";
	document.getElementById('btn'+id).style.visibility="visible";
	}
}
function ActivTour(id)
{
	if(document.getElementById('tour'+id).className!="play")
	document.getElementById('tour'+id).className="activtour";
}
function desActivTour(id)
{
	if(document.getElementById('tour'+id).className!="play")
	document.getElementById('tour'+id).className="";
	//alert(document.getElementById('tour'+id).className)
}