var vclose=0;

//----------Flash
var plugin;
var version = 5;
var flash = 0;
var cur_version = 0;

if (navigator.plugins) {
    if (navigator.plugins["Shockwave Flash"]) {
        plugin = navigator.plugins["Shockwave Flash"].description;
        cur_version = parseInt(plugin.charAt(plugin.indexOf('.') - 1));        
        flash = cur_version >= version;
    } else {
        if ((navigator.userAgent.indexOf('MSIE') != -1) && (navigator.userAgent.indexOf('Win') != -1))
        {
            try {
                eval('var test = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.'+version+'");')
                var flash_version = test.getVariable('$version');
                cur_version = parseInt(flash_version.charAt(flash_version.indexOf(',') - 1));
            }
            catch(e){
            }
            flash = cur_version >= version;
        }
    }
}
//----------Flash

if(!flash)
for(i=0;i<=20;i++)
{
if(document.getElementById("fl_"+i))
document.getElementById("fl_"+i).innerHTML='<p align="right"><a href="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" target="_blank">Установить flash-player</a></p><br /><br /><p align="center">FLASH Player<br />не установлен.</p>';
}

function ShowDivMenu(stroka)	
{
//	alert(stroka);
window.setTimeout("NoDivMenu()",15000);
if(document.getElementById(stroka).style.display=='')
document.getElementById(stroka).style.display='none';
else
document.getElementById(stroka).style.display='';
}

function ShowDivKalNO(stroka)	
{
document.getElementById(stroka).style.display='none';
}

function NoDivMenu()	
{
if(vclose==0)
document.getElementById('menu_blin').style.display='none';
else
window.setTimeout("NoDivMenu()",3200);
vclose=0;
}


function ShowDivKal(stroka,s2,nch)	
{

for(i=nch;i<=nch+7; i++)
if("ID"+s2+i!=stroka) document.getElementById("ID"+s2+i).style.display='none';

if(document.getElementById(stroka).style.display=='')
document.getElementById(stroka).style.display='none';
else
document.getElementById(stroka).style.display='';
}


function OW(url,avelname,avelval)	
{
	if(avelval==""&&avelname!="") avelval=document.getElementById(avelname).value;
	document.getElementById(avelname).value="";
	if(avelname=="s.ID_STREET") avelname="ID_STREET";
	if(avelname=="b.ID_BUILDING") avelname="ID_BUILDING";

	if(avelname!="")
	url=url+"&"+avelname+"="+avelval;
	window.open(url,'wedit','width=500,height=600');
}

function OWin(url,w,h)	
{

	window.open(url,'wedit',',resizable,scrollbars,width='+w+',height='+h+'');
	//,resizable
}


function ml_func(sss)	
{
	location.href="mailto:"+ replace_string(sss,'___','@');
}

function OPW(nnn,w,h)	
{
	w+=100;
	h+=100;
	pp=window.open('','wedit','width='+w+',height='+h+'');
	pp.document.write(document.getElementById(nnn).innerHTML);
//	pp.print();
}

function OPWN(nnn)	
{
	pp=window.open('');
	pp.document.write('<link rel="Stylesheet" href="text.css" type="text/css" media="all">');
	pp.document.write(document.getElementById(nnn).innerHTML);
	pp.document.close();
//	pp.print();
}


function OPWin(nnn,w,h)	
{
	w+=100;
	h+=100;
	pp=window.open(nnn,'wedit','width='+w+',height='+h+',scrollbars,resizable');
}

function escSel(str)
{		
		mas='0123456789ABCDEF';
		ss="";
		for(i=0;i<str.length; i++)
		{
		v=str.charCodeAt(i);
		if(v>256) 
			{v=v-848;
			a=Math.floor(v/16);
			b=v-a*16;
			ss=ss+"%"+mas.charAt(a)+mas.charAt(b);
			}
		else ss=ss+str.charAt(i);
		}
		return ss;
}

function replace_string(txt,cut_str,paste_str){
var f=0;
var ht='';
ht = ht + txt;
f=ht.indexOf(cut_str);
while (f!=-1){
//цикл для вырезания всех имеющихся подстрок
f=ht.indexOf(cut_str);
if (f>0){
ht = ht.substr(0,f) + paste_str + ht.substr(f+cut_str.length);
};
};
return ht
};

function code_to(str,code)
{
	rs='';
	ii=0;
	vp=73;
	for(i=0;i<code.length;i++)
	{
	if(ii==str.length) ii=0;
	vol=code.charCodeAt(i)-48+str.charCodeAt(ii);
	if(vol>222) {vol=vp;vp++;}
	rs=rs+vol;
	ii++;
	}
	return rs;
}

function hh(q){var old=0;q.onkeyup=function(ev){if(ev) ee=ev.target;else ee=event.srcElement;if(Math.abs(ee.value*1+1)>0);else  ee.value=old;old=ee.value;}}

