window.onerror=function(){return true;}

//================ Menu function ==================================
function dropit(e,oIEorNN6s,sOneNN,xMenu){
	if(ie4){
		oneIE = oIEorNN6s;
		if (window.themenu&&themenu.id!=oneIE.id)
			themenu.style.visibility="hidden";
		themenu=oneIE;
		themenu.style.left=document.body.scrollLeft+event.clientX-event.offsetX;
		themenu.style.top=document.body.scrollTop+event.clientY-event.offsetY+15;
		lX=themenu.style.posLeft-document.body.scrollLeft;
		rX=lX+themenu.offsetWidth;
		tY=themenu.style.posTop-document.body.scrollTop-25;
		bY=themenu.offsetHeight+tY+25;
		//updateIt(oneIE);
		if (themenu.style.visibility=="hidden"){
			themenu.style.visibility="visible";
			themenu.style.zIndex=zi++;
		}
	}
	if(nn4){
		if (window.themenu&&themenu.id!=eval(sOneNN).id)
			themenu.visibility="hide";
		themenu=eval(sOneNN);
		if (themenu.visibility=="hide")
			themenu.visibility="show";
		themenu.zIndex++;
		themenu.left=e.pageX-e.layerX;
		themenu.top=e.pageY-e.layerY+14;
		lX=themenu.left;
		rX=lX+themenu.clip.width;
		tY=themenu.top-25;
		bY=themenu.top+themenu.clip.height;
		return false;
	}
	if(nn6){
		oneNN = document.getElementById(oIEorNN6s); //eval(sOneNN);
		if (window.themenu&&themenu.id!=oneNN.id)
			themenu.style.visibility="hidden";
		themenu=oneNN;
		themenu.style.left=xMenu;
		themenu.style.top=146;
		lX=parseInt(themenu.style.left);
		rX=lX+themenu.offsetWidth;
		tY=parseInt(themenu.style.top);
		bY=themenu.offsetHeight+tY+25;
		//updateIt(oneNN);
		if (themenu.style.visibility=="hidden"){
			themenu.style.visibility="visible";
			themenu.style.zIndex=zi++;
			
		}
	}
}

function dropita(e,oIEorNN6s,sOneNN,xMenu){
	if(ie4){
		oneIE = oIEorNN6s;
		if (window.themenu&&themenu.id!=oneIE.id)
			themenu.style.visibility="hidden";
		themenu=oneIE;
		themenu.style.left=document.body.scrollLeft+event.clientX-event.offsetX;
		themenu.style.top=document.body.scrollTop+event.clientY-event.offsetY-63;
		lX=themenu.style.posLeft-document.body.scrollLeft;
		rX=lX+themenu.offsetWidth;
		tY=themenu.style.posTop-document.body.scrollTop-25;
		bY=themenu.offsetHeight+tY+25;
		//updateIt(oneIE);
		if (themenu.style.visibility=="hidden"){
			themenu.style.visibility="visible";
			themenu.style.zIndex=zi++;
		}
	}
	if(nn4){
		if (window.themenu&&themenu.id!=eval(sOneNN).id)
			themenu.visibility="hide";
		themenu=eval(sOneNN);
		if (themenu.visibility=="hide")
			themenu.visibility="show";
		themenu.zIndex++;
		themenu.left=e.pageX-e.layerX;
		themenu.top=e.pageY-e.layerY+14;
		lX=themenu.left;
		rX=lX+themenu.clip.width;
		tY=themenu.top-25;
		bY=themenu.top+themenu.clip.height;
		return false;
	}
	if(nn6){
		oneNN = document.getElementById(oIEorNN6s); //eval(sOneNN);
		if (window.themenu&&themenu.id!=oneNN.id)
			themenu.style.visibility="hidden";
		themenu=oneNN;
		themenu.style.left=xMenu;
		themenu.style.top=146;
		lX=parseInt(themenu.style.left);
		rX=lX+themenu.offsetWidth;
		tY=parseInt(themenu.style.top);
		bY=themenu.offsetHeight+tY+25;
		//updateIt(oneNN);
		if (themenu.style.visibility=="hidden"){
			themenu.style.visibility="visible";
			themenu.style.zIndex=zi++;
			
		}
	}
}

function hidemenu (whichone){
	if(ie4) hidemenu1 (whichone);
	if(nn6) hidemenu3();
	if(nn4) hidemenu2();
}

function hidemenu1(whichone){
	if(window.themenu)
		themenu.style.visibility="hidden";
	hidemenu2();
}

function hidemenu2(){
	if(typeof(themenu)!="undefined")
		themenu.visibility="hide";
}

function hidemenu3(){
	if (themenu.style.visibility=="visible")
		themenu.style.visibility="hidden";
}

function updateIt(oneIE){
	var x,y
	if(ie4){
		x=window.event.clientX;
		y=window.event.clientY;
		if(x>rX || x<lX) hidemenu(oneIE);
		else if(y>bY+1 || y<tY) hidemenu1(oneIE);
	}
	if(nn6){
		x=oneIE.clientX;
		y=oneIE.clientY;
		if(x>rX || x<lX) hidemenu3();
		else if(y>bY+1 || y<tY-30) hidemenu3();
	}
	if(nn4){
		x=oneIE.pageX;
		y=oneIE.pageY;
		if(x>rX || x<=lX-1) hidemenu2();
		else if(y>bY || y<tY) hidemenu2();
	}
}

//================ Picture Function
function pshow(ImageName,Ext,Wid,Hei,Tit) {
       newWindow=window.open("",""+ImageName+"","toolbar=no,location=no,directories=no,status=no,menubar=no,fullscreen=no,scrollbars=no,resizable=no,width="+Wid+",height="+Hei+"");
       var newContent = "<html><head>\n"
       newContent += "<title>" + Tit + "&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </title></head>\n"
       newContent += "<script language=\"JavaScript\">\n"
       newContent += "var r=-1\n"
       newContent += "function Init() {\n"
       newContent += "if (navigator.appName==\"Netscape\") r=0;\n"
       newContent += "self.focus(); window.setTimeout(\"r = 0\",1000)\n}\n"
       newContent += "</script>\n"
       newContent += "<body bgcolor=\"#ffffff\" onLoad=\"Init()\" marginheight=\"0\" marginwidth=\"0\" topmargin=\"0\" leftmargin=\"0\">\n"
       newContent += "<a href=\"javascript: if (r == 0) self.close()\"><img border=0 src=\"images/" + ImageName + "." + Ext +"\"" + " width=\"" + Wid + "\" height=\"" + Hei + "\"></a>\n"
       newWindow.document.writeln(newContent)
       newWindow.document.writeln("</body></html>")
       newWindow.document.close()
}

function WrImg(ImgImg, Ext, ImgURL,ImgText){
	document.write("<table border=0 cellpadding=0 cellspacing=0 width=214>");
	document.write("<tr>");
	document.write("<td width=200><a href="+ImgURL+"><img class=a src=images/"+ImgImg+"_SM"+Ext+" width=200 height=120 border=0 id=img></a></td>");
	document.write("<td width=14><img src=images/SHADOW.GIF width=14 height=120 border=0></td>");
	document.write("</tr><tr>");
	document.write("<td bgcolor=#E0E4E6><div class=c>");
	if (ImgText!="") {
		document.write(ImgText+"</div></td>");
	} else {
		document.write("&nbsp;</div></td>");
	}	
	document.write("</tr>");
	document.write("</table>");
}

function WrImg1(ImgImg, Ext, ImgURL,ImgText){
	document.write("<table border=0 cellpadding=0 cellspacing=0 width=214>");
	document.write("<tr>");
	document.write("<td width=200><a href="+ImgURL+"><img class=a src=images/"+ImgImg+"_SM"+Ext+" width=200 height=240 border=0 id=img></a></td>");
	document.write("<td width=14><img src=images/SHADOW1.GIF width=14 height=240 border=0></td>");
	document.write("</tr><tr>");
	document.write("<td bgcolor=#E0E4E6><div class=c>");
	if (ImgText!="") {
		document.write(ImgText+"</div></td>");
	} else {
		document.write("&nbsp;</div></td>");
	}	
	document.write("</tr>");
	document.write("</table>");
}

function WrImg2(ImgImg, Ext){
	document.write("<table border=0 cellpadding=0 cellspacing=0 width=214>");
	document.write("<tr>");
	document.write("<td width=200><img class=a src=images/"+ImgImg+"_SM"+Ext+" width=200 height=120 border=0 id=img></td>");
	document.write("<td width=14><img src=images/SHADOW.GIF width=14 height=120 border=0></td>");
	document.write("</tr>");
	document.write("</table>");
}

function WrImg3(ImgImg, Ext, ImgURL){
	document.write("<table border=0 cellpadding=0 cellspacing=0 width=386>");
	document.write("<tr>");
	document.write("<td width=200><a href="+ImgURL+"><img class=a src=images/"+ImgImg+"_SM"+Ext+" width=372 height=233 border=0 id=img></a></td>");
	document.write("<td width=14><img src=images/SHADOW.GIF width=14 height=233 border=0></td>");
	document.write("</tr>");
	document.write("</table>");
}

function WrImg4(ImgImg, Ext, ImgURL,ImgText){
	document.write("<table border=0 cellpadding=0 cellspacing=0 width=214>");
	document.write("<tr>");
	document.write("<td width=200><a href="+ImgURL+"><img class=a src=images/"+ImgImg+"_SM"+Ext+" width=200 height=240 border=0 id=img></a></td>");
	document.write("<td width=14><img src=images/SHADOW1.GIF width=14 height=240 border=0></td>");
	document.write("</tr>");
	document.write("</table>");
}

function WrImg5(ImgImg, Ext, ImgURL,ImgText){
	document.write("<table border=0 cellpadding=0 cellspacing=0 width=214>");
	document.write("<tr>");
	document.write("<td width=200><a href="+ImgURL+"><img class=a src=images/"+ImgImg+"_SM"+Ext+" width=290 height=240 border=0 id=img></a></td>");
	document.write("<td width=14><img src=images/SHADOW1.GIF width=14 height=240 border=0></td>");
	document.write("</tr>");
	document.write("</table>");
}



// ===================


var plugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;
if(plugin){
 plugin=(parseInt(plugin.description.substring(plugin.description.indexOf(".")-1))>=4);
}
else if((navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0)&&((navigator.userAgent.indexOf("Windows 95")>=0)||(navigator.userAgent.indexOf("Windows 98")>=0)||(navigator.userAgent.indexOf("Windows NT")>=0))){
 document.write('<'+'SCRIPT LANGUAGE=VBScript'+'>\n');
 document.write('on error resume next\n');
 document.write('plugin=( IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.5")))\n');
 document.write('</'+'SCRIPT'+'>');
}

function ua(){
	var n=window.navigator,an=n.appName.toLowerCase(),ag=n.userAgent.toLowerCase(),k=0;
	uWin=(ag.indexOf("win")>=0)
	uOpera=uNav=uIE=0;
	if((k=ag.indexOf("opera"))>=0) uOpera=parseFloat(ag.substring(k+6));
		else if((k=ag.indexOf("msie"))>=0) uIE=parseFloat(ag.substring(k+5));
			else if(an.indexOf("netscape")>=0) uNav=parseFloat(n.appVersion);
	uNav4=(uNav>=4.08 && uNav<5 && uWin);
	uMoz=(uNav>=5 && uWin);
	uIE4=(uIE>=4 && uWin);
}

ua()

//--------------------------------------------------------------------------------------------------------------------

var pWnd=0;

function wopen(url){
	if(pWnd && !pWnd.closed)pWnd.close();
	pWnd=window.open(url,'salon_window','width=20,height=20,top=0,left=0,resizable=1,fullscreen=0,scrollbars=1');
}
	
function zoom(pname,id,format){
	wopen('zoom.xgi?PIC='+pname+'&DOCUMENT_ID='+id+'&FORMAT='+format);
}

function cover(id){
	wopen('cover.xgi?ID='+id);
}

function plan(id) {
	wopen('plan.xgi?ID='+id+'&DIV=1&INIT=1');
}

//--------------------------------------------------------------------------------------------------------------------

function openDiv(){
	if(uNav4)document.write("<layer name='tbar' top=0 left=0 width=100%>");
		else document.write("<div id='tbar' style='position:absolute;top:0px;left:0px;width:100%;overflow:hidden;z-index:0'>");
} 
function closeDiv(){
	if(uNav4)document.layers.tbar.document.write("</layer>");
		else document.write("</div>");
}


//--------------------------------------------------------------------------------------------------------------------

function getPos(obj){
	if(!obj)
		return 0;
	if(uNav4)
		return [obj.x,obj.y];
	else if(uIE4||uMoz||(uOpera>=5)){
		for(var x=0,y=0;obj;obj=obj.offsetParent){
			x+=obj.offsetLeft;
			y+=obj.offsetTop;
		}
		return [x,y];
	} else return 0;
}

function resizeWnd(x,y){
	var pos=getPos(document.images?(document.images.LP):0);
	if(!pos||!pos[0])
		pos=[x||600,y||400];
	window.resizeTo(pos[0]+(uNav4?10:35),pos[1]+(uNav4?20:55));
	window.focus();
}

//--------------------------------------------------------------------------------------------------------------------

function movObj(id,cx,cy,hide){
	if(uIE4) with (document.all(id).style) {
		pixelLeft=cx;pixelTop=cy+0;visibility=hide?"hidden":"visible";
	} else if(uNav4) {
		document.layers[id].moveTo(cx,cy+0);
		document.layers[id].visibility=hide?"hide":"show";
	} else if(uMoz) with (document.getElementById(id).style) {
		left=cx;top=cy+0;visibility=hide?"hidden":"visible";
	}
}

var mbOld=0,mbTimer=0;

function getScroll(){
	if(uIE4) return [_ht.scrollLeft,_ht.scrollTop];
	if(uMoz) return [_ht.scrollX,_ht.scrollY];
	if(uNav4)return [_ht.pageXOffset,_ht.pageYOffset];
}

function getWSize(){
	if(uIE4) return [_ht.clientWidth,_ht.clientHeight];
		else return [_ht.innerWidth-16,_ht.innerHeight-16];
}

function movBar(){
	var mbNew=getScroll()[0];
	if(mbNew!=mbOld){
		movObj("tbar",mbNew,0);
		mbOld=mbNew;
		mbTimer=0;
	}
}

//--------------------------------------------------------------------------------------------------------------------

function handWrite(){
	var img="<img src='images/POINTER.GIF' width='24' height='16' border='0'>";
	if(uIE4||uMoz)document.write("<div id='HAND' style='position:absolute;top:0px;left:0px;width:16px;height:16px;visibility:hidden;z-index:100'>"+img+"</div>");
		else if(uNav4) document.write("<layer name='HAND' top=0 left=0 width=0 height=0 visibility=hide z-index=100>"+img+"</layer>");
}

function isA(el){
	var a=["A","INPUT","SELECT"];
	while(el){
		var v=el.tagName;
		for(var ii=0;v&&ii<a.length;ii++) if(a[ii]==v)return true;
		el=el[uIE4?"parentElement":"parentNode"];
	}
	return false;
}

function handDown(e){
	var e=window.event||e;
	window.defaultStatus=" ";
	if((e[uIE4?"button":"which"]!=1)||e.modifiers||e.altKey||e.shiftKey||e.ctrlKey)
		return;
	var el=e[uIE4?"srcElement":"target"],ws=getWSize();
	if(uIE4||uMoz) {
		if(e.clientX>ws[0]||e.clientY>ws[1]||isA(el))return;
	} else if(uNav4&&el&&el.href)return;
	_hd=getScroll();
	_hd[0]+=e.screenX;_hd[1]+=e.screenY;
	_ha=1;
	handDrag(e);
	return false;
}

function handDrag(e){
	if(!_ha)return;
	var e=window.event||e;
	if(e[uIE4?"button":"which"]){
		window.scrollTo(_hd[0]-e.screenX,_hd[1]-e.screenY);
		movObj("HAND",
			(uIE4?(e.clientX+_ht.scrollLeft):(e.pageX))-10,
			(uIE4?(e.clientY+_ht.scrollTop):(e.pageY))-10);
		return false;
	} else handUp();
}

function handUp(){
	movObj("HAND",0,0,1);
	window.defaultStatus=_hs;
	_ha=0;
}

//--------------------------------------------------------------------------------------------------------------------

function evtKeydown(e){
	var e=window.event||e;
	if(e.keyCode==36) window.scrollTo(0,0);
	if(e.keyCode==35) window.scrollTo(document.body.scrollWidth,0);
	if(e.keyCode==33) window.scrollBy(-(getWSize()[0]),0);
	if(e.keyCode==34) window.scrollBy((getWSize()[0]),0);
}

function evtScroll() {
	if(mbTimer)
		clearTimeout(mbTimer);
	mbTimer=setTimeout("movBar()",100);
}

var _ws=[window.innerWidth,window.innerHeight];

function evtResize() {
	if(uIE4)
		movBar();
	else if(uNav4 && (window.innerWidth!=_ws[0]||window.innerHeight!=_ws[1]))
		location.reload();
}






function evtLoad(){
	if(uNav4||uMoz||uIE4){
		window._hd=[];
		window._ha=0;
		window._ht=uIE4?document.body:window;
		window._hs=(uIE4?
			"Нажмите левую кнопку мыши и перемещайте мышь для прокрутки страницы":
			"Click and drag to move the view, hold Alt and drag to select text");
		window.defaultStatus=_hs;
		if(uNav4) 
			window.captureEvents(Event.MOUSEDOWN | Event.MOUSEMOVE | Event.MOUSEUP);
		if(uIE4)
			_ht.onkeydown=evtKeydown;
		_ht.onmousedown=handDown;
		_ht.onmouseout=updateIt;
		_ht.onmousemove=handDrag;
		_ht.onmouseup=handUp;
		_ht.onresize=evtResize;
		if(uIE>=5)
			_ht.onscroll=evtScroll;
		else 
		window.setInterval("movBar()",1000);
	}
}


function zoomLink(file,w,h) {
 var p=window.open(file,'preview_window',"width="+w+",height="+h+",top=0,left=0,location=0,toolbar=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1,fullscreen=0");
 if(p)p.focus();
 return false;
}

function gScrollToObj(name)
{
var obj;
if(document.all) obj= document.all[name]; else obj=document.getElementById(name); 
var pos=getPos(obj);
window.scrollTo(pos[0]-15,0);
}


var ie4, nn4, nn6;
var rX, lX, tY, bY;
var zi=100;
ie4 = nn4 = nn6 = 0;
if(document.all)
	{ie4=1; document.body.onmousemove=updateIt;}
if(document.layers)
	{nn4=1; window.captureEvents(Event.MOUSEMOVE); window.onmousemove=updateIt;}
if(document.getElementById&&!ie4)
	{nn6=1; document.body.onmousemove=updateIt;}

