var ret;
if(!Array.prototype.push){Array.prototype.push=function(obj){for(var i=0;i<arguments.length;i++){this[this.length]=arguments[i];}
return this.length;}}
if(!Array.prototype.shift){Array.prototype.shift=function(){var result=this[0];for(var i=0;i<this.length-1;i++){this[i]=this[i+1];}
this.length--;return result;}}
if(!Array.prototype.unshift){Array.prototype.unshift=function(){this.reverse();for(var i=arguments.length-1;i>=0;i--){this[this.length]=arguments[i]}
this.reverse();return this.length;}}
if(!Array.prototype.pop){Array.prototype.pop=function(){lastElement=this[this.length-1];this.length=Math.max(this.length-1,0);return lastElement;}}
Object.extend=function(destination,source){for(property in source){destination[property]=source[property];}
return destination;}
function $(){var elements=new Array();for(var i=0;i<arguments.length;i++){var element=arguments[i];if(typeof element=='string')
element=document.getElementById(element);if(arguments.length==1)
return element;elements.push(element);}
return elements;}
function getElementsByClassName(strClass,strTag,objContElm)
{
	strTag=strTag||"*";
	objContElm=objContElm||document;
	var objColl=(strTag=='*'&&document.all)?document.all:objContElm.getElementsByTagName(strTag);
	var arr=new Array();
	var delim=strClass.indexOf('|')!=-1?'|':' ';
	var arrClass=strClass.split(delim);
	if(objColl.length)
	{
	for(i=0,j=objColl.length;i<j;i++)
	{
                if(objColl[i].className)
                {	
		var arrObjClass=objColl[i].className.split(' ');
		if(delim==' '&&arrClass.length>arrObjClass.length)continue;
		var c=0;
		comparisonLoop:for(k=0,l=arrObjClass.length;k<l;k++)
		{
			for(m=0,n=arrClass.length;m<n;m++)
			{
				if(arrClass[m]==arrObjClass[k])c++;
				if((delim=='|'&&c==1)||(delim==' '&&c==arrClass.length))
				{
					arr.push(objColl[i]);
					break comparisonLoop;
				}
			}
		}
		}
	}
	}
	return arr;
}
function addLoadEvent(func){var oldonload=window.onload;if(typeof window.onload!='function'){window.onload=func;}else{window.onload=function(){oldonload();func();}}}
function addEvent(elm,evType,fn,useCapture){if(elm.addEventListener){elm.addEventListener(evType,fn,useCapture);return true;}
else if(elm.attachEvent){var r=elm.attachEvent('on'+evType,fn);EventCache.add(elm,evType,fn);return r;}
else{elm['on'+evType]=fn;}}
var EventCache=function(){var listEvents=[];return{listEvents:listEvents,add:function(node,sEventName,fHandler,bCapture){listEvents.push(arguments);},flush:function(){var i,item;for(i=listEvents.length-1;i>=0;i=i-1){item=listEvents[i];if(item[0].removeEventListener){item[0].removeEventListener(item[1],item[2],item[3]);};if(item[1].substring(0,2)!="on"){item[1]="on"+item[1];};if(item[0].detachEvent){item[0].detachEvent(item[1],item[2]);};item[0][item[1]]=null;};}};}();addEvent(window,'unload',EventCache.flush,false);

var LoadEvents=new Array();
function pushLoadEvent(func)
{
    LoadEvents.push(func);
}
function LoadEventsStart()
{
   for(var i=0;i<LoadEvents.length;i++)
   {
           LoadEvents[i]();
   }
}
addEvent(window,'load',LoadEventsStart,false);

function ShowNews(theURL,winName)
{ //v1.0
	var now = new Date();
	window.open(theURL,winName+now.getTime(),'scrollbars=1,width=800,height=600,');
}
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,'scrollbars=0,width=920,height=700,');
}
function MM_openBrWindowEx(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

/*
	Image Galery Functions
*/
var ig_Items=new Array();
var ig_CurItem=-1;
var ig_IsSlideShow=true;
var ig_SlideShowDelay=1000;
var old_w=0;
var ig_tmp1,ig_tmp2;
var ig_OldItem;
var ig_IsFirst=true;
var ig_ToScrollLeft;
var ig_ToScrollLeftT;
function ig_WaitToStart()
{
	if(ig_tmp1) clearTimeout(ig_tmp1);
	if(!ig_IsSlideShow) return;
	if(ig_CurItem != -1)
	{
		ig_tmp1=setTimeout(ig_WaitToStart,1000);
		return;
	}
	ig_CurItem=0;
	//start silde show
	var pl=$('control_play');
	pl.onclick=ig_StartStop;
	pl.className="control_play";
	
	pl=$('control_left');
	pl.onclick=ig_MoveLeft;
	
	pl=$('control_right');
	pl.onclick=ig_MoveRight;
	
	$('lenta').scrollLeft=1;
	ig_SlideShow();
	$('lenta').scrollLeft=1;
}
function ig_MoveLeft()
{
	if(ig_IsSlideShow) {ig_IsSlideShow=false;ig_CheckSlideShowState();ig_CurItem--;}
	ig_CheckSlideShowState();
	if(ig_Items[ig_CurItem])
	{
		ig_CurItem--;
		if(ig_CurItem<0) ig_CurItem=ig_Items.length-1;
		ig_showPic (ig_Items[ig_CurItem],ig_CurItem,ig_Items[ig_CurItem].imgID);
		ig_CheckScrollPosition();
	}
}
function ig_MoveRight()
{
	if(ig_IsSlideShow) {ig_IsSlideShow=false;ig_CheckSlideShowState();ig_CurItem--;}
	if(ig_Items[ig_CurItem])
	{
		ig_CurItem++;
		if(ig_CurItem>=ig_Items.length) ig_CurItem=0;
		ig_showPic (ig_Items[ig_CurItem],ig_CurItem,ig_Items[ig_CurItem].imgID);
		ig_CheckScrollPosition();
	}
}
function ig_StartStop()
{
	if(ig_IsSlideShow) ig_IsSlideShow=false;else ig_IsSlideShow=true;
	ig_CheckSlideShowState();
	ig_CurItem++;
	if(ig_CurItem>=ig_Items.length) ig_CurItem=0;
}
function ig_CheckSlideShowState()
{
	if(ig_IsSlideShow)
	{
		$('control_play').className="control_play";
	}
	else
	{
		$('control_play').className="control_stop";
	}
}
function ig_SlideShow()
{
	
	if(ig_tmp2) clearTimeout(ig_tmp2);
	if(ig_IsSlideShow)
	{
		if(ig_Items[ig_CurItem])
		{
		ig_showPic (ig_Items[ig_CurItem],ig_CurItem,ig_Items[ig_CurItem].imgID);
		ig_CheckScrollPosition();
		ig_CurItem++;
		
			if(ig_CurItem==ig_Items.length)
			{
				ig_CurItem=0;
				old_w=0;
			}
		}
	}
	ig_tmp2=setTimeout(ig_SlideShow,ig_SlideShowDelay);
}
function ig_CheckScrollPosition()
{
	var pr2=$(ig_OldItem).parentElement?$(ig_OldItem).parentElement:$(ig_OldItem).parentNode;
		var newW=pr2.offsetWidth;
		var newL=pr2.offsetLeft;
		
		var Flag;
		
		if(newL+newW-$('lenta').scrollLeft>=$('lenta').offsetWidth || $('lenta').scrollLeft>newL) Flag=true; else Flag=false;
		if(Flag)
		{
			ig_ToScrollLeft=newL;
			if(newL>$('lenta').scrollLeft) ig_AnimScroll(); else ig_AnimScrollM();
		}
}
function ig_AnimScroll()
{
	if(ig_ToScrollLeftT) clearTimeout(ig_ToScrollLeftT);
	var sl=$('lenta').scrollLeft;
	var d=ig_ToScrollLeft-sl;
	var dl=40;
	if(d>0)
	{
		d=sl+dl;
		if(d>ig_ToScrollLeft) d=ig_ToScrollLeft;
		$('lenta').scrollLeft=d;
		ig_ToScrollLeftT=setTimeout('ig_AnimScroll()',70);
	}
}
function ig_AnimScrollM()
{
	if(ig_ToScrollLeftT) clearTimeout(ig_ToScrollLeftT);
	var sl=$('lenta').scrollLeft;
	var d=-ig_ToScrollLeft+sl;
	var dl=100;
	if(d>0)
	{
		d=sl-dl;
		if(d<ig_ToScrollLeft) d=ig_ToScrollLeft;
		$('lenta').scrollLeft=d;
		ig_ToScrollLeftT=setTimeout('ig_AnimScrollM()',50);
	}
}

function ig_SetImage(iURL,data,id) //v2.1 A.D.A 13.07.2007(!!! OLD_DATE=13.07.2006 ONE YEAR)
	{
		ig_WaitToStart();
		return;
		var po=MM_findObj('photo_out');
		po.src=iURL;
		var out;
		for(var p in data)
		{
			out=$("photo_"+p);
			if(out) out.innerHTML=data[p];
		}
	}
function ig_showPic2 (whichpic,C,imgID)
{
	
	ig_IsSlideShow=false;
	ig_CheckSlideShowState();
	var ret=ig_showPic (whichpic,C,imgID);
	return ret;
}
function ig_showPic (whichpic,C,imgID) {  //v2.0 A.D.A 13.07.2006
	if (document.getElementById)
	{
		var po=document.getElementById('photo_out');
		po.src = whichpic.href;
		var pr=document.getElementById('ig_item_'+imgID);
		var data=ig_Items[C].data;
		if(ig_OldItem) $(ig_OldItem).className="item";
		pr.className="item_active";

		ig_OldItem=pr.id;
		var out;
		for(var p in data)
		{
			out=$("photo_"+p);
			if(out) out.innerHTML=data[p];
		}
		return false;
	} else {
		return true;
	}
}
function ig_AddImage(imgID,data,id) //v2.1 A.D.A 13.07.2007
{
		var id=imgID.split('.')[0];
		var cls=ig_Items.length?'item':'item_active';

		 var c=ig_Items.length;
		 var z=new Object();
		 z.href='/dyn_images/big'+imgID;
		 z.data=data;
		 z.imgID=id;
		 ig_Items[c]=z;
		 var wr='<td><div class="'+cls+'" id="ig_item_'+id+'"><a OnClick="return ig_showPic2(this,'+c+','+id+');" href="/dyn_images/big'+imgID+'" ><img src="/dyn_images/img'+imgID+'"/></a></div></td>';
		 if(!ig_Items.length)ig_OldItem='ig_item_'+id;
         document.write(wr);
}
function ig_ShowBigImg(iSCR) { //v1.0 A.D.A 17.07.2006

  now = new Date();
  newWindow=window.open('',now.getTime(),'scrollbars=1,width=1280,height=1024');
  newWindow.document.writeln('<html><head>');
  newWindow.document.writeln('<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">');
  newWindow.document.writeln('</head>');
  newWindow.document.writeln('<body align=center bgcolor="#5c1212" leftmargin="20" topmargin="20" marginwidth="20" marginheight="20">');
  newWindow.document.writeln('<center><a href="javascript:;" OnClick="javascript:window.close();"><img style="border:0px;" src=\''+iSCR+'\' alt="???????"/></a>');
  newWindow.document.writeln('<BR/><br/><a style="font-size:16px;color:white;" href="javascript:;" OnClick="javascript:window.close();">???????</a></center>');
  newWindow.document.writeln('</body></html>');
}
function ShowBI(hlink) //v1.0 A.D.A 17.07.2006
{
	if (hlink.href=='#') return false;
	ShowBigImg(hlink.href);
	return false;
}