/* Џгбв п дг­ЄжЁп, зв®Ўл Ўл«® */
function none() { }


/* Џ®Є §лў Ґ¬ ®Є­® «®ЈЁ­  */
function ShowLogin(e)
{
 if(!e) e=window.event;
 var curleft=curtop=0;
 var x=y=0;
 var popup=document.getElementById('popup');

 if(e.pageX || e.pageY)
 { x=e.pageX; y=e.pageY; }
 else if (e.clientX || e.clientY)
 {
  x=e.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft) - document.documentElement.clientLeft;
  y=e.clientY + (document.documentElement.scrollTop || document.body.scrollTop) - document.documentElement.clientTop;
 }

 popup.style.top='-1000px';
 popup.style.left='-1000px';
 popup.style.display='block';
 popup.className='over';
 var posx=x+3;
 var posy=y+3;
 var popupwidth=popup.offsetWidth;
 var popupheight=popup.offsetHeight;
 if(ClientWidth()>popupwidth && posx+popupwidth+10>ScrollLeft()+ClientWidth()) posx=x-popupwidth+3;
 if(ClientHeight()>popupheight && posy+popupheight+10>ScrollTop()+ClientHeight()) posy=y-popupheight+3;
 popup.style.top=posy+'px';
 popup.style.left=posx+'px';
 popup.className='';
}



function DocHeight()
{
 return (document.body.scrollHeight>document.body.offsetHeight)?document.body.scrollHeight:document.body.offsetHeight;
}

function DocWidth()
{
 return (document.body.scrollWidth>document.body.offsetWidth)?document.body.scrollWidth:document.body.offsetWidth;
}

function ClientHeight()
{
 return !window.opera?document.documentElement.clientHeight:document.body.clientHeight;
}

function ClientWidth()
{
 return !window.opera?document.documentElement.clientWidth:document.body.clientWidth;
}

function ScrollTop()
{
 return self.pageYOffset || (document.documentElement && document.documentElement.scrollTop) || (document.body && document.body.scrollTop);
}

function ScrollLeft()
{
 return self.pageXOffset || (document.documentElement && document.documentElement.scrollLeft) || (document.body && document.body.scrollLeft);
}


function showInstruments()
{
 var obj=document.getElementById('instruments');
 var objlnk=document.getElementById('instrlink');
 if(obj.style.display!='block')
 {
  obj.style.display='block';
  objlnk.className='instrlinktop';
 }
 else
 {
  obj.style.display='none';
  objlnk.className='instrlinkbottom';
 }

}


var m = document.uniqueID
&& document.compatMode
&& !window.XMLHttpRequest
&& document.execCommand;
var _gaq = _gaq || [];
var mydom = window.location.hostname.replace(/^(www\.)?(([a-z0-9]+)\.)?gorod.*$/, "$3");
if(mydom=='') mydom = 'gorodovoy';


if( document.cookie.match ( '(^|;) ?cook=([^;]*)(;|$)' )) {
_gaq.push(['_setCustomVar', 1, 'Registered_user', 'Yes', 2 ]);
}

try{
     if(!!m)
      {
         m("BackgroundImageCache", false, true);
      }
   }
catch(oh){};

function alignPic(){
	var pics = document.getElementsByTagName('img');
	if (/MSIE/.test(navigator.userAgent)) {
		for (var i=0;i<pics.length;i++){
			if (pics[i].align == 'right'){
				pics[i].style.cssFloat = 'right';
			}
		}
	}
}
function superOnload(fnName) {
	var ol = window.onload;
	if (typeof ol == "function") {
		window.onload = function() {
			ol();
			fnName();
		}
	}
	else {
		window.onload = fnName;
	}
}
superOnload(alignPic);





function registrationFormF()
{
	var marginTop = -170+getBodyScrollTop();
	if (document.getElementById('registration_form'))
	{
		document.getElementById('registration_form').style.margin=marginTop+'px 0px 0px -308px';
	}
	else
	{
		var iframe=document.createElement('IFRAME');
		iframe.id='registration_form';
		iframe.allowTransparency='yes';
		iframe.scrolling="no";
		iframe.frameBorder='0';
		iframe.src="/html/registration_form.html";
		iframe.style.position='absolute';
		iframe.style.backgroundColor='transparent';
		iframe.style.zIndex='9999';
		iframe.style.left='50%';
		iframe.style.top='50%';
		iframe.style.width='616px';
		iframe.style.height='341px';
		iframe.style.margin=marginTop+'px 0px 0px -308px';
		document.body.appendChild(iframe);
	}
	hiddenSelectF();
}

function getBodyScrollTop()
{
  return self.pageYOffset || (document.documentElement && document.documentElement.scrollTop) || (document.body && document.body.scrollTop);
}

function hiddenSelectF()
{
  var isIE6  = (navigator.appVersion.indexOf("MSIE 6") != -1) ? true : false;
  if (isIE6)
  {
  	var allSelect=document.getElementsByTagName('SELECT');
	for (var i=0; i<allSelect.length; i++)
  	{
	  	allSelect[i].style.visibility='hidden';
  	}
  }
}
//Календарь, родительская функция
//Сам календарь берется из разметки (div.calendarDates)
//У наследуемой функции нужно обязательно указать
//1.this.linker - элемент на котором произошел клик
//2.this.afterChoose(date) - функция, срабатывает при выборе даты, передается выбранная дата
//пример функции - afishaPopup.js
function CalendarPopup(){
	this.initCP=function(){
		this.calendarInner = as.$$('div.calendarDates').innerHTML;
			this.popup = document.createElement('div');
			this.popup.className = 'afisha-calendar-wrapper';
			this.popup.innerHTML = '<div class="bottom-pipka"></div>'+
					'<div class="afisha-calendar-container">'+
						'<div class="shadow"></div>'+
						'<div class="afisha-calendar">'+
							'<img class="bottom-pipka" alt="" src="/i/relax-calendar-str-bg.gif">'+
							'<a class="closer" href="#">закрыть</a>'+
							'<h4>Дата</h4>'+ this.calendarInner +
						'</div>'+
					'</div>';
			document.body.appendChild(this.popup);

			this.popupCalendar = as.$$('div.afisha-calendar-wrapper');
			this.closer = as.$$('div.afisha-calendar-wrapper a.closer');
			this.dateClickers = as.$('div.afisha-calendar ul li a');
			this.showClosePopup();
	}
	this.showClosePopup=function(){
		var self = this;
		this.linker.onclick = function(e){
			self.stopEvent(e);
			self.popupCalendar.style.display == 'block' ? self.popupCalendar.style.display = 'none' : self.popupCalendar.style.display = 'block';
			self.popupCalendar.style.left = as.getElementPosition(this).left - self.popupCalendar.offsetWidth/2 + 10 + 'px';
			self.popupCalendar.style.top = as.getElementPosition(this).top - self.popupCalendar.offsetHeight + 'px';
			document.body.onclick = function(e){
				var event = e || window.event,target = event.target || event.srcElement, checkTarget = false;
				while (target.parentNode){
					if ((target == self.popupCalendar) || (target == self.linker) || (target == self.popupCalendar.childNode)){checkTarget = true; break;}
					else {
						checkTarget = false;
					}
					target = target.parentNode;
				}
				if (!checkTarget){
					self.popupCalendar.style.display = 'none';
				}
			}
		}
		this.closer.onclick =  function(e){
			self.stopEvent(e);
			self.popupCalendar.style.display = 'none';
		}
		this.chooseDate();
	}
	this.chooseDate=function(){
		var self = this;
		if(this.dateClickers[0]) {
			this.dateClickers[0].parentNode.className += ' active';
		}
		for (var i=0;i<this.dateClickers.length;i++){
			self.dateClickers[i].onclick = function(e){
				self.stopEvent(e);
				for (var j=0;j<self.dateClickers.length;j++){
					self.dateClickers[j].parentNode.className = self.dateClickers[j].parentNode.className.replace(/\bactive\b/,'');
				}
				this.parentNode.className += ' active';
				self.afterChoose.call(self, this); //Функция запускается после выбора даты, прописывается в наследуемом объекте
				self.popupCalendar.style.display = 'none';
			}
		}
	}
	this.stopEvent=function(e){
		var event = e || window.event;
		event.preventDefault ? event.preventDefault() : event.returnValue = false;
	}
}

