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=LoadEvents.length-1;i>-1;i--)
   for(var i=0;i<LoadEvents.length;i++)
   {
           //alert(LoadEvents[i]);
           LoadEvents[i]();
   }
}
addEvent(window,'load',LoadEventsStart,false);
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_tmp2=setTimeout('ig_WaitToStart()',ig_SlideShowDelay);
	//init items
	
	
	
	//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_Items[ig_CurItem].title,ig_Items[ig_CurItem].desc,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_Items[ig_CurItem].title,ig_Items[ig_CurItem].desc,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_Items[ig_CurItem].title,ig_Items[ig_CurItem].desc,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)
		{
			//$('lenta').scrollLeft=newL;//-$('lenta').offsetWidth;
			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,pTitle,pDesc) //v2.0 A.D.A 13.07.2006
	{
		ig_WaitToStart();
		var po=MM_findObj('photo_out');
		po.src=iURL;
		var x=document.getElementById('photo_text');
         var y=document.getElementById('photo_out');
		
         if (pTitle != '')
         {
             x.innerHTML='<div class="t1">'+pTitle+'</div><div id="t2">'+pDesc+'</div>';
			 x.className='photo_text1';
             //y.style.float='left';
             y.className='photo_out2';
         }
         else
         {
             x.innerHTML='';
			 x.className='photo_text2';
			 y.className='photo_out1';

         }
		
	}
function ig_showPic2 (whichpic,pTitle,pDesc,imgID)
{
	//alert(ig_Items.length);
	for(var i=0;i<ig_Items.length;i++)
	{
		//alert(ig_Items[i].imgID+' '+imgID);
		if(ig_Items[i].imgID==imgID)
		{
			ig_CurItem=i;
			//ig_OldItem='ig_item_'+imgID;
			break;
		}
	}
	ig_IsSlideShow=false;
	ig_CheckSlideShowState();
	var ret=ig_showPic (whichpic,unescape(pTitle),unescape(pDesc),imgID);
	//alert(ret);
	return ret;
}
function ig_showPic (whichpic,pTitle,pDesc,imgID) {  //v2.0 A.D.A 13.07.2006
	//alert(whichpic.href);
	
	//alert(ig_CurItem);
	if (document.getElementById)
	{
		var po=document.getElementById('photo_out');
		po.src = whichpic.href;
		var pr=document.getElementById('ig_item_'+imgID);

		if(ig_OldItem) $(ig_OldItem).className="item";
		//if($(ig_OldItem)) alert($(ig_OldItem).innerHTML);
		pr.className="item_active";

		ig_OldItem=pr.id;
		var x=document.getElementById('photo_text');
         var y=document.getElementById('photo_out');
	
         if (pTitle != '')
         {
             x.innerHTML='<div class="t1">'+pTitle+'</div><div id="t2">'+pDesc+'</div>';
			 x.className='photo_text1';
             y.className='photo_out2';
         }
         else
         {
             x.innerHTML='';
			 x.className='photo_text2';
			 y.className='photo_out1';

         }
		return false;
	} else {
		return true;
	}
}
function ig_AddImage(imgID,pTitle,pDesc) //v2.0 A.D.A 13.07.2006
{
		var id=imgID.split('.')[0];
		//alert(id);
		var cls=ig_Items.length?'item':'item_active';
         var wr='<td><div class="'+cls+'" id="ig_item_'+id+'"><a OnClick="return ig_showPic2(this,\''+escape(pTitle)+"','"+escape(pDesc)+"',"+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);
		 var c=ig_Items.length;
		
		 var z=new Object();
		 z.href='/dyn_images/big'+imgID;
		 z.title=pTitle;
		 z.desc=pDesc;
		 z.imgID=id;
		 ig_Items[c]=new Object();
		 ig_Items[c]=z;
		 //alert(z.href);
		 ig_CurItem=0;
		 if(ig_Items.length>1) ig_CurItem=1;
}
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;
}