presentNow=slide2wNow=0;
function onMOver(Obj,mode,cLip)
{
	if('top'==mode)
	{
		Obj.removeClassName('mOver').removeClassName('mCenter').setStyle({backgroundPosition:'top'});hd();
	}
	else if('bottom'==mode)
	{
		Obj.addClassName('mOver').setStyle({backgroundPosition:'bottom'});
		slideIt(Obj.rev);
	}
	else if('center'==mode)Obj.addClassName('mCenter').setStyle({'backgroundPosition':'center'});
}
document.observe("dom:loaded", function() 
{
	$$('[rel=MO]').each(function(Obj){
		Obj.observe('mouseover',function(event){onMOver(Obj,'bottom',1)});
		Obj.observe('mouseout', function(event){onMOver(Obj,'top',1)});
	});
	setTimeout(function(){Present.go()},5*1000);
	$('dLogo').observe('mouseover',function(event){slideIt('general')});
	$('dLogo').observe('mouseout', function(event){slide2w('ds_general',0)});
	$('dCompanyName').observe('mouseover',function(event){slideIt('general')});
	$('dCompanyName').observe('mouseout', function(event){slide2w('ds_general',0)});	
	$('kiev').autoHeight = $('sevastopol').autoHeight = false;
	if(window.R&&'KY'==R)$('dRight').insertBefore($('sevastopol'),$('kiev'));
	$('dRight').down('form').observe('submit', function(event){fsearch(event)});
	$('dRight').down('div.dSearchSubmit').observe('click', function(event){fsearch(event);$('dRight').down('form').submit()});
	if($('feedback')){Obj=$('feedback').down().next().down('a');Obj.observe('click',function(event) {fsendqst(Obj)})}
});

function in_array(a,b,c){var d=false,key,c=!!c;for(key in b){if((c&&b[key]===a)||(!c&&b[key]==a)){d=true;break}}return d}

function slideIt(name){
	if (!slide2wNow && name) 
	{
		$('d0ver1ay').update($('ds_'+ name).innerHTML);
		slide2w('d0ver1ay',1,300);
	}
}
function hd(){if (!slide2wNow)$('d0ver1ay').setStyle({height:'0px',overflow:'hidden'})}

Present = {
	ar:[],
	cur:0,
	pa:false,
	go:function()
	{
		presentNow=1;
		if (!this.ar.size()) 
		{
			$$('#dLeft a.leftButtns[rel=MO]').each(function(Obj,j){Present.ar[j] = Obj.id});
			Present.cur = Present.ar.first();
		}
		this.pa = new PeriodicalExecuter(function(pa){Present.show()},5);
	},
	show:function()
	{
		if(!presentNow){Present.pa.stop();return false}
		pulsate(Present.cur);
		slideIt($(Present.cur).rev);
		setTimeout(function(){hd()},4*1000);
		Present.cur = Present.ar[Present.ar.indexOf(Present.cur)+1];
		if (!Present.cur) Present.cur = Present.ar.first();
	},
	stop:function(event)
	{
		if(!presentNow)return false;
		Event.extend(event); var Obj = event.element();
		presentNow=0;
		hd();		
	}
}

function pulsate(oId,param1,param2)
{
	var Obj = $(oId); if(typeof(Obj)=='undefined')return;
	if (undefined == param1) { param1 = 6; param2 = 1; }
	param1--; param2 = (param2)?0:1;
	var Ca11 = 'pulsate("'+oId+'",'+param1+','+param2+')';
	if (param1>0) setTimeout(Ca11,600);
	if (param2) Obj.setStyle({backgroundPosition:'top'});
	else if(null!=Obj)Obj.setStyle({backgroundPosition:'bottom'});
}

function clipText2() 
{
	var step=4;var timt=5;var maxh=600;
	var curh = text2.getHeight(); 
	if (maxh < curh) {
		text2.style.height = maxh+'px'; 
		var scrollbar = new Control.ScrollBar('scrollbar_content','scrollbar_track'); 
		if('function'==typeof window.afterClipping)afterClipping();
		return;
	}
	else {text2.style.height = (curh+step-40)+'px';setTimeout(function(){clipText2()},timt)}
}
function error(txt,alert)
{
	var div = (alert)?'<div style="color:red">':'<div>'; 
	$('dRight').insert({top:div+txt+'</div>'});
}
function finger(a){b=decode64(a+'==');return '<a href="mailto:'+b+'" class="my10">'+b+'</a>';}
function splash(Obj,off)
{
	div = Obj.up().next();
	if (div.busy && !off)return false;
	if (!off){div.busy = true; onMOver(div,'bottom'); setTimeout(function(){splash(Obj,1)},100)}
	else{delete div.busy;onMOver(div,'top')}
}

function slide2w(id,out,upto,timt,delta) 
{
	if (!slide2wNow) slide2wNow = true;
	var obj = $(id);
	if(undefined==out){out=true;obj.closed = false;obj.origY=obj.getHeight()} else obj.closed = !out; 
	if(undefined==timt) {var timt=3}
	if(undefined==delta){var delta=20}
	if(window.ass)delta *= 2;
	var curh = obj.getHeight();
	var progress = (out)?curh/upto:upto/curh;
	if (out)
	{
		var newh = delta + curh;
		obj.style.height = newh+'px';
		if(newh<upto) setTimeout(function(){slide2w(id,1,upto,timt,delta)},timt);
		else {
			slide2wNow = false;
			if(undefined==obj.autoHeight) obj.setStyle({overflow:'visible',height:'auto'}); 
		}
	} else {
		var newh = -delta + curh; if(newh<0)newh=0;
		obj.setStyle({overflow:'hidden',height:newh+'px'});
		if(newh>obj.origY) setTimeout(function(){slide2w(id,0,upto,timt,delta)},timt);
		else { slide2wNow = false; hd()}
	}
}
function decode64(a){var a=a;var b="";var c,chr2,chr3;var d,enc2,enc3,enc4;var i=0;var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";a=a.replace(/[^A-Za-z0-9\+\/\=]/g,"");while(i<a.length){d=e.indexOf(a.charAt(i++));enc2=e.indexOf(a.charAt(i++));enc3=e.indexOf(a.charAt(i++));enc4=e.indexOf(a.charAt(i++));c=(d<<2)|(enc2>>4);chr2=((enc2&15)<<4)|(enc3>>2);chr3=((enc3&3)<<6)|enc4;b=b+String.fromCharCode(c);if(enc3!=64){b=b+String.fromCharCode(chr2)}if(enc4!=64){b=b+String.fromCharCode(chr3)}}return b}
function fsearch(evnt){$('dSearch').down('input').name = 'p01sk';$('dRight').down('form').method='post';$('dRight').down('form').action='/ryf375dc';return true;}
function fsendqst(butObj){var txt=['Ваши координаты','Ваш вопрос'];eml = butObj.previous('input').value; bdy = butObj.previous('textarea').value;
if(5>eml.length || eml==txt[0]){alert('укажите, куда нам отправить ответ'); return false}
if(5>bdy.length || bdy==txt[1]){alert('вы забыли написать текст'); return false}
new Ajax.Request('/oyf375dc',{method:'post', parameters:{eml:eml,bdy:bdy},evalScripts:false,onSuccess:function f(transport) {
if (butObj.up('div').id=='d0ver1ay') $('d0ver1ay').update('').hide();
else {butObj.previous('input').value = txt[0]; butObj.previous('textarea').value = txt[1]; slide2w('feedback',false,275,10,3)}
fCover(false);$('dVoproz').hide()}});
}

