try{document.execCommand("BackgroundImageCache", false, true);}catch(err){}

var _$=new Array();
var ie=(document.all&&!window.opera);
var tmr;
var URL_loader=0;
var URL_short='';
var loadFast;


function $(id)
{
	 _$[id]=document.getElementById(id);
	return _$[id];
}

function $_ (id){
	if(!_$[id]){
		_$[id]=document.getElementById(id);
	}
	return _$[id];
}

function SetOpacity(obj,op){
	if (ie){
		obj.style.filter="progid:DXImageTransform.Microsoft.Alpha(opacity="+op+")";
	}
	else{
		obj.style.opacity=op/100;
	}
	
}

var arr_days=new Array();
var sm_items=new Array();

function waitResize(){
	for (i=0;i<arr_days.length;i++){
		($('mn'+arr_days[i])).style.display='';
		($('mn'+arr_days[i])).style.height=($('day'+arr_days[i])).offsetHeight;
	}
}


function docResize(){
	var i,sum;
	sum=0;
	for (i=0;i<arr_days.length;i++){
		oldH=$('tbl'+arr_days[i]).offsetHeight;
		if (mov_opened[arr_days[i]]){
			CheckHeight(arr_days[i],act_div[arr_days[i]],false);
		}
		else{
			if ($('tbl'+arr_days[i]).offsetHeight<180)
				$('div'+arr_days[i]).style.height=180;
			else
				$('div'+arr_days[i]).style.height=$('tbl'+arr_days[i]).offsetHeight;
			sum+=$('tbl'+arr_days[i]).offsetHeight;
			if ($('mn'+arr_days[i])){

				var h=$('tbl'+arr_days[i]).offsetHeight-33;
				if (h<255) h=255	;
				($('mn'+arr_days[i])).style.height=h;
				if ($('tbl'+arr_days[i]).offsetHeight<h+40){
					$('div'+arr_days[i]).style.height=h+40;
				}
			}
		}
	}
}

function docLoad(loadLater){
	var arr=new Array();
	var reg=/[^#]*#([0-9]*)-([0-9]{2,})\.([0-9]{2,})\.([0-9]{2,})-(.*)/;
	arr=reg.exec(document.location.href);
	if (arr){
		var dt=new Date(arr[4],arr[3]-1,arr[2],0,0,0);
		var date=dt.getTime()/1000;
		$_('loader2').style.display='';
		loadFast=true;
	}
	for (i=0;i<arr_days.length;i++){
		for (j=0;j<sm_items[arr_days[i]].length;j++){
			if ($('hd'+sm_items[arr_days[i]][j].id)){
				sm_items[arr_days[i]][j].h=$('hd'+sm_items[arr_days[i]][j].id).offsetHeight;
				sm_items[arr_days[i]][j].cont=$_('sm'+sm_items[arr_days[i]][j].id).innerHTML;
			}
			else{
				sm_items[arr_days[i]][j].h=-1;
			}
		}
	}
	if (URL_loader>0){
		for (j=0;j<sm_items[URL_loader].length;j++){
			if (sm_items[URL_loader][j].id!=act_div[URL_loader]){
				sm_items[URL_loader][j].h=$('hd'+sm_items[URL_loader][j].id).offsetHeight;
				sm_items[URL_loader][j].cont=$_('sm'+sm_items[URL_loader][j].id).innerHTML;
				$('sm'+sm_items[URL_loader][j].id).style.height=sm_items[URL_loader][j].h+26;
			}
			else{
				sm_items[URL_loader][j].cont=URL_short;
				sm_items[URL_loader][j].h=-1;
			}
		}
		for (i=1;i<sm_items[URL_loader].length;i++){
			if (sm_items[URL_loader][i].id==act_div[URL_loader]){
				if (i!=(sm_items[URL_loader].length-1))
				{
					bounds=getBounds($_('sm'+sm_items[URL_loader][i+1].id));
					i_top=bounds.top;
				}
				else{
					bounds=getBounds($_('sm'+sm_items[URL_loader][i-1].id));
					i_top=bounds.top+bounds.height+20;
				}
				break;
			}
		}
		$_('sm'+act_div[URL_loader]).style.height='auto';
		$_('sm'+act_div[URL_loader]).style.top=i_top-20-getBounds($_('day'+URL_loader)).top;
		CheckHeight(URL_loader,act_div[URL_loader],false);
		moveScroll(document.body.scrollTop,i_top);
		URL_loader=0;
	}
	if (!loadLater){
		if (!arr)
		{
			$('loader2').style.display='none';
			return;
		}
		else{
			GetNews(date,arr[1],arr[5]);
		}
	}
	else{
		loadFast=true;
	}

}

var tmp1=0;
function makeScroll(from,to,action){
	if (Math.abs(tmp1)>5){
		step=Math.log(tmp1)*Math.log(tmp1);
		if (Math.abs(step)<3) step=3;
		tmp1-=step;
		document.body.scrollTop=to+(from<to?-1:1)*tmp1;
		if (loadFast){
			setTimeout('makeScroll('+from+','+to+',\''+action+'\')',5);
		}
		else{
			setTimeout('makeScroll('+from+','+to+',\''+action+'\')',20);
		}
	}
	else{
		document.body.scrollTop=to;
		if (action) eval(action);
	}
}
function moveScroll(from,to,action){
	tmp1=Math.abs(from-to);
	makeScroll(from,to,action);
}
function makeResize(from,to,id,action){
	if (Math.abs(tmp1)>5){
		step=Math.log(tmp1)*Math.log(tmp1)*0.7;
		if (Math.abs(step)<5) step=5;
		tmp1-=step;
		$_(id).style.height=to+(from<to?-1:1)*tmp1;
		if (loadFast)
		{
			setTimeout('makeResize('+from+','+to+',\''+id+'\',\''+action+'\')',5);
		}
		else{
			setTimeout('makeResize('+from+','+to+',\''+id+'\',\''+action+'\')',20);
		}
		
	}
	else{
		$_(id).style.height=to;
		if (action) eval(action);
	}
}


function moveResize(to,id,action){
	from=$_(id).offsetHeight;
	tmp1=Math.abs(from-to);
	makeResize(from,to,id,action);
}


function makeSize(step,n,id){
	$(id).style.height=$(id).offsetHeight-step;
	n--;
	if (n>0){
		if (loadFast){
			setTimeout('makeSize('+step+','+n+',\''+id+'\')',5);
		}
		else{
			setTimeout('makeSize('+step+','+n+',\''+id+'\')',20);
		}
		
	}
	else{

	}
}

function moveSize(dt){
	var step=0;
	var to=$('div'+dt).offsetHeight;
	var from=$('tbl'+dt).offsetHeight;
	var id='div'+dt;
	step=(to-from)/20;
	makeSize(step,20,id);
}

function getBounds(element)
{
  var left = element.offsetLeft;
  var top = element.offsetTop;
  for (var parent = element.offsetParent; parent; parent = parent.offsetParent)
  {
    left += parent.offsetLeft;
    top += parent.offsetTop;
  }
  return {left: left, top: top, width:element.offsetWidth, height:element.offsetHeight};
}

var mov_step1=new Array();
var count_step1=10;
var tmr1=0;
var mov_step2=new Array();
var count_step2=10;
var tmr2=0;
var mov_step3=new Array();
var count_step3=10;
var tmr3=0;
var mov_step4=0;
var count_step4=10;
var tmr4=0;
var mov_step5=0;
var count_step5=10;
var tmr5=0;
var mov_step6=0;
var count_step6=10;
var tmr6=0;
var mov_step7=0;
var count_step7=10;
var tmr7=0;
var mov_step8=0;
var count_step8=10;
var tmr8=0;
var mov_step9=0;
var count_step9=10;
var tmr9=0;
var mov_step10=0;
var count_step10=10;
var tmr10=0;
var mov_step11=0;
var count_step11=10;
var tmr11=0;
var mov_step12=0;
var count_step12=10;
var tmr12=0;
var mov_step13=0;
var count_step13=10;
var tmr13=0;
var inc;
var arr_b;
var ajax_reslt='';
var mov_opened=new Array();
var act_div=new Array();
var i_top;

var is_animating=false;


function GetNews(day_id,news_id,zag,element){
	if (element){
		element.href='javascript:void(0);';
	}
	if (is_animating) return;
	var dt=new Date();
	dt.setTime(day_id*1000);
	var day=dt.getDate();
	if (day<10) {
		day='0'+day;
	}
	var month=dt.getMonth()+1;
	if (month<10) {
		month='0'+month;
	}
	var year=dt.getYear();
	if (year<1900) {
		year=1900+year;
	}
	MoveStep1(day_id,news_id,zag);
	if (element){
		element.href='#'+news_id+'-'+day+'.'+month+'.'+year+'-'+zag;
	}
}

function AnimateStep1a(news_id,s_left){
	if (s_left==0){
		return;
	}
	else{
		$_('sm'+news_id).style.left=parseInt($_('sm'+news_id).style.left)+29;
	}
	if (loadFast){
		setTimeout('AnimateStep1a('+news_id+','+(s_left-1)+')',25);
	}else{
		setTimeout('AnimateStep1a('+news_id+','+(s_left-1)+')',5);
	}
}


function AnimateStep1(day_id,news_id,s_left){
	if (s_left==0){
		MoveStep2(day_id,news_id);
		
		return;
	}
	for (i=0;i<sm_items[day_id].length;i++){
		if (sm_items[day_id][i].id!=news_id)
			$_('sm'+sm_items[day_id][i].id).style.height=$_('sm'+sm_items[day_id][i].id).offsetHeight+mov_step1[i];
	}
	clearTimeout(tmr1);
	if (loadFast){
		tmr1=setTimeout('AnimateStep1('+day_id+','+news_id+','+(s_left-1)+')',25);
	}
	else{
		tmr1=setTimeout('AnimateStep1('+day_id+','+news_id+','+(s_left-1)+')',5);
	}
	
}



function MoveStep1(day_id,news_id,zag){
	if (is_animating) return;
	$('loader').style.display='';
	is_animating=true;
	arr_b=new Array();
	$('mn'+day_id).style.height=$('mn'+day_id).offsetHeight;
	var req = new JsHttpRequest();
	$('loader').style.top=document.body.scrollTop;
	$('loader').style.display='';
	ajax_reslt='';
	req.onreadystatechange = function() {
		if (req.readyState == 4) {
			var oldheight=$('day'+day_id).offsetHeight;
			ajax_reslt=req.responseJS.a;
			
		}
	}
	if ($('limg'+day_id)) $('limg'+day_id).style['display']='none';

	req.open(null, '/modules/getnews.php?ajax=1&short=1&date='+day_id+'&zag='+zag, true);
	req.send({});
	if (!mov_opened[day_id]){
		
		act_div[day_id]=news_id;
		mov_opened[day_id]=true;
		for (i=0;i<sm_items[day_id].length;i++){
		var bounds=getBounds($_('sm'+sm_items[day_id][i].id));
			arr_b[i]=bounds;
		}
		h=getBounds($_('day'+day_id)).top;
		if (!ie) h=0;
		for (i=0;i<sm_items[day_id].length;i++){
			
			$_('sm'+sm_items[day_id][i].id).style.position='absolute';
			$_('sm'+sm_items[day_id][i].id).style.zIndex=10;
			if (i!=0){
				$_('sm'+sm_items[day_id][i].id).style.left=arr_b[i].left;
				if (ie)
				{
					$_('sm'+sm_items[day_id][i].id).style.top=arr_b[i].top-h;
				}
				else{
					$_('sm'+sm_items[day_id][i].id).style.top=arr_b[i].top;
				}
				
			}
			else{
				$_('sm'+sm_items[day_id][i].id).style.left=25;
				$_('sm'+sm_items[day_id][i].id).style.top=20;
			}
			$_('sm'+sm_items[day_id][i].id).style.float='none';
			mov_step1[i]=(sm_items[day_id][i].h+22-$_('sm'+sm_items[day_id][i].id).offsetHeight)/count_step1;
		}
		$('tbl'+day_id).style.height=parseInt($('tbl'+day_id).offsetHeight)+($_('sm'+act_div[day_id]).offsetHeight+20);
		clearTimeout(tmr1);
		if (loadFast){
			tmr1=setTimeout('AnimateStep1('+day_id+','+news_id+','+count_step1+')',5);
		}
		else{
			tmr1=setTimeout('AnimateStep1('+day_id+','+news_id+','+count_step1+')',25);
		}
	}
	else{
		MoveStep6(day_id,news_id);
	}
}

function AnimateStep2a(day_id,s_left,step,mx){
	if (s_left==1)
	{
		$_('div'+day_id).style.height=mx+40;
		$_('mn'+day_id).style.height=mx+40;
		$_('tbl'+day_id).style.height=mx+40;
		return;
	}
	else{
		$_('mn'+day_id).style.height=parseInt($_('mn'+day_id).style.height)+step;
		$_('div'+day_id).style.height=parseInt($_('div'+day_id).style.height)+step;
	}
	if (loadFast){
		setTimeout('AnimateStep2a('+day_id+','+(s_left-1)+','+step+','+mx+')',5);
	}
	else{
		setTimeout('AnimateStep2a('+day_id+','+(s_left-1)+','+step+','+mx+')',25);
	}
	
}

function AnimateStep2(day_id,news_id,s_left){
	if (s_left==0){
		for (i=0;i<sm_items[day_id].length;i++){
			if (sm_items[day_id][i].id!=news_id)
			{
				if (i!=0){
					$_('par'+day_id).removeChild($_('sm'+sm_items[day_id][i].id));
				}
				else{
					$_('sm'+sm_items[day_id][i].id).style.top=getBounds($_('day'+day_id)).top+20;
					$_('lef'+day_id).removeChild($_('sm'+sm_items[day_id][i].id));
				}
				document.body.appendChild($_('sm'+sm_items[day_id][i].id));
				$_('sm'+sm_items[day_id][i].id).style.position='absolute';
				$_('sm'+sm_items[day_id][i].id).style.left=179;
			}
		}
		MoveStep3(day_id,news_id);
		return;
	}
	
	for (i=1;i<sm_items[day_id].length;i++){
		if (sm_items[day_id][i].id!=news_id)
		{
			$_('sm'+sm_items[day_id][i].id).style.top=parseInt($_('sm'+sm_items[day_id][i].id).style.top)+mov_step2[i].y;
			$_('sm'+sm_items[day_id][i].id).style.left=parseInt($_('sm'+sm_items[day_id][i].id).style.left)+mov_step2[i].x;
		}
	}
	clearTimeout(tmr2);
	if (loadFast){
		tmr2=setTimeout('AnimateStep2('+day_id+','+news_id+','+(s_left-1)+')',5);
	}
	else{
		tmr2=setTimeout('AnimateStep2('+day_id+','+news_id+','+(s_left-1)+')',25);
	}
}

function MoveStep2(day_id,news_id){
	var sum=arr_b[0].top;
	var sum2=sm_items[day_id][0].h;
	for (i=0;i<sm_items[day_id].length;i++){ 
		if (sm_items[day_id][i].id!=news_id)
		{
			mov_step2[i]={x:(178-parseInt($_('sm'+sm_items[day_id][i].id).style.left))/count_step2,y:(sum-parseInt($_('sm'+sm_items[day_id][i].id).style.top))/count_step2};
			sum+=parseInt($_('sm'+sm_items[day_id][i].id).style.height)+20;
			sum2+=parseInt($_('sm'+sm_items[day_id][i].id).style.height)+20;
		}
	}
	if (sm_items[day_id][0].id==news_id){
		obj=$_('sm'+news_id);
		bounds=getBounds(obj);
		$_('lef'+day_id).removeChild(obj);
		$_('par'+day_id).appendChild(obj);
		if (ie)
		{
			obj.style.top=bounds.top-getBounds($('day'+day_id)).top;
		}
		else{
			obj.style.top=bounds.top;
		}
		obj.style.left=bounds.left;
		setTimeout('AnimateStep1a('+news_id+',10)',50);
	}
	tmp=getBounds($_('sm'+act_div[day_id])).top+($_('sm'+act_div[day_id]).offsetHeight+20) - getBounds($('day'+day_id)).top-$('day'+day_id).offsetHeight;
	if (tmp>0) {
		$('day'+day_id).style.height=parseInt($('day'+day_id).style.height)+tmp;
	}
	
	CheckHeight(day_id,news_id);
	if (loadFast){
		setTimeout('AnimateStep2('+day_id+','+news_id+','+count_step2+')',5);
	}
	else{
		setTimeout('AnimateStep2('+day_id+','+news_id+','+count_step2+')',200);
	}
	
}

function AnimateStep3(day_id,news_id,s_left){
	$_('sm'+news_id).style.top=parseInt($_('sm'+news_id).style.top)+mov_step3[s_left].y;
	$_('sm'+news_id).style.left=parseInt($_('sm'+news_id).style.left)+mov_step3[s_left].x;
	if (s_left==0){
		MoveStep4(day_id,news_id);
		return;
	}
	clearTimeout(tmr3);
	if (loadFast){
		tmr3=setTimeout('AnimateStep3('+day_id+','+news_id+','+(s_left-1)+')',5);
	}
	else{
		tmr3=setTimeout('AnimateStep3('+day_id+','+news_id+','+(s_left-1)+')',10);
	}
}

function MoveStep3(day_id,news_id){
	var i_top=0;
	var sum=0;
	mov_step3=new Array();
	
	for (i=0;i<sm_items[day_id].length;i++){
		if (sm_items[day_id][i].id==news_id){
			var bounds;
			if (i!=(sm_items[day_id].length-1))
			{
				bounds=getBounds($_('sm'+sm_items[day_id][i+1].id));
				i_top=bounds.top;
			}
			else{
				if (i!=0){
					bounds=getBounds($_('sm'+sm_items[day_id][i-1].id));
					i_top=bounds.top+bounds.height+20;
				}
				else{
					bounds=getBounds($_('sm'+sm_items[day_id][i].id));
					i_top=bounds.top;
				}
			}
			bounds=getBounds($_('sm'+sm_items[day_id][i].id));
			for (j=0;j<=count_step3;j++){
				sum+=j;
			}
			for (j=0;j<=count_step3;j++){
				
				mov_step3[count_step3-j]={x:(470-bounds.left)*j/sum,y:(i_top-bounds.top)*j/sum};
			}
			break;
		}
	}
	AnimateStep3(day_id,news_id,(count_step3-1));
}



function WaitLoaded(day_id,news_id){
	if (ajax_reslt!=''){
		$_('sm'+news_id).style.width=$_('par'+day_id).offsetWidth-60;
		$_('sm'+news_id).innerHTML=ajax_reslt;
		$_('sm'+news_id).style.left=0;
		$_('sm'+news_id).style.overflow='visible';
		if (!ie){
			$_('sm'+news_id).style.top=parseInt($_('sm'+news_id).style.top)-getBounds($_('day'+day_id)).top;
		}
		$_('sm'+news_id).style.height='auto';
		$_('sm'+news_id).style.width='auto';
		$_('sm'+news_id).style.position='relative';
		MoveStep5(day_id,news_id);
	}
	else{
		setTimeout('WaitLoaded('+day_id+','+news_id+')',100);
	}
}

function AnimateStep4(day_id,news_id,s_left){
	if (s_left==2){
		$_('sm'+news_id).style.display='none';
		WaitLoaded(day_id,news_id);
		return;
	}
	else{
		$_('sm'+news_id).style.height=$_('sm'+news_id).offsetHeight-mov_step4;
		clearTimeout(tmr4);
		if (loadFast){
			tmr4=setTimeout('AnimateStep4('+day_id+','+news_id+','+(s_left-1)+')',5);
		}
		else{
			tmr4=setTimeout('AnimateStep4('+day_id+','+news_id+','+(s_left-1)+')',50);
		}
	}
}

function MoveStep4(day_id,news_id){
	//mov_step4=($_('par'+day_id).offsetWidth-$_('sm'+news_id).offsetWidth-60)/count_step4;
	mov_step4=$_('sm'+news_id).offsetHeight/count_step4;
	$_('sm'+news_id).style.overflow='hidden';
	AnimateStep4(day_id,news_id,count_step4);
}

function AnimateStep5a(day_id,step,s_left)
{
	if (s_left<1) return;
	$_('div'+day_id).style.height=parseInt($_('div'+day_id).style.height)+step;
	$_('mn'+day_id).style.height=parseInt($_('mn'+day_id).style.height)+step;
	clearTimeout(tmr);
	if (loadFast){
		tmr=setTimeout('AnimateStep5a('+day_id+','+step+','+(s_left-1)+')',5);
	}
	else{
		tmr=setTimeout('AnimateStep5a('+day_id+','+step+','+(s_left-1)+')',20);
	}
}

function AnimateStep5(day_id,news_id,s_left){
	if (s_left==0){
		is_animating=false;
		if (loadFast){
			var arr=new Array();
			var reg=/[^#]*#([0-9]*)-([0-9]{2,})\.([0-9]{2,})\.([0-9]{2,})-(.*)/;
			arr=reg.exec(document.location.href);
			if (arr){
				var dt=new Date(arr[4],arr[3]-1,arr[2],0,0,0);
				var date=dt.getTime()/1000;
				if ((day_id!=date) || (news_id!=arr[1])){
					GetNews(date,arr[1],arr[5]);
				}
			}
			
			loadFast=false;
			$_('loader').style.display='none';
			$_('loader2').style.display='none';
		}
		else{
			loadFast=false;
			$_('loader').style.display='none';
			$_('loader2').style.display='none';
		}
		$_('sm'+news_id).style.overflow='visible';
		$_('sm'+news_id).style.height='auto';
		
		
	}
	else{
		t1=(new Date()).getTime();
		$_('sm'+news_id).style.height=parseInt($_('sm'+news_id).style.height)+mov_step5;
		t2=(new Date()).getTime();

		clearTimeout(tmr5);
		tmr5=setTimeout('AnimateStep5('+day_id+','+news_id+','+(s_left-1)+')',25);
	}
}

function CheckHeight(day_id,news_id,animate){
	h1=getBounds($_('sm'+news_id)).top+parseInt($_('sm'+news_id).offsetHeight)+40-getBounds($_('day'+day_id)).top;
	h2=getBounds($_('sm'+sm_items[day_id][sm_items[day_id].length-1].id)).top-getBounds($_('day'+day_id)).top+$_('sm'+sm_items[day_id][sm_items[day_id].length-1].id).offsetHeight+40;
	
	if (h2>h1){
		h=h2;
	}
	else h=h1;
	if ($_('day'+day_id).offsetHeight!=h){
		if (animate){
			AnimateStep5a(day_id,((h-$_('day'+day_id).offsetHeight)/5),5);
		}
		else{
			$_('mn'+day_id).style.height=h;
			$_('div'+day_id).style.height=h;
			$_('tbl'+day_id).style.height=h;
		}
	}
	ii=arr_days.length;
	for (i=0;i<arr_days.length;i++){
		if (arr_days[i]==day_id){
			ii=i;
			break;
		}
	}
	for (i=ii+1;i<arr_days.length;i++){
		d_id=arr_days[i];
		if (sm_items[d_id][0]){
			obj=$_('sm'+sm_items[d_id][0].id);
			t1=parseInt(obj.style.top);
			t2=getBounds($_('day'+d_id)).top;
			if (obj.style.position=='absolute')
			if ((t1<t2) || ((t1+20)>t2)){
				del=t2-t1+20;
				for (j=0;j<sm_items[d_id].length;j++){
					if (act_div[d_id]!=sm_items[d_id][j].id){
						obj=$_('sm'+sm_items[d_id][j].id);
						obj.style.top=parseInt(obj.style.top)+del;
					}
				}
			}
		}
	}
}

function MoveStep5(day_id,news_id){
	SetOpacity($_('sm'+news_id),0);
	$_('sm'+news_id).style.display='';
	
	mov_step5=$_('sm'+news_id).offsetHeight/count_step5;
	CheckHeight(day_id,news_id,false);
	SetOpacity($_('sm'+news_id),100);
	$_('sm'+news_id).style.height='1px';
	$_('sm'+news_id).style.overflow='hidden';
	
	bounds =getBounds($_('sm'+news_id));
	moveScroll(document.body.scrollTop,getBounds($_('sm'+news_id)).top,'AnimateStep5('+day_id+','+news_id+','+count_step5+')');
}

function AnimateStep6(day_id,news_id,s_left){
	if (s_left==1){
		for (i=0;i<sm_items[day_id].length;i++){
			if (act_div[day_id]==sm_items[day_id][i].id){
				$_('sm'+act_div[day_id]).style.height=sm_items[day_id][i].h+25;
			}
		}
		SetOpacity($_('sm'+act_div[day_id]),0);
		MoveStep7(day_id,news_id);
	}
	else{
		$_('sm'+act_div[day_id]).style.height=$_('sm'+act_div[day_id]).offsetHeight-mov_step6;
		clearTimeout(tmr6);
		tmr6=setTimeout('AnimateStep6('+day_id+','+news_id+','+(s_left-1)+')',25);
	}
}

function MoveStep6(day_id,news_id){
	$_('sm'+act_div[day_id]).style.overflow='hidden';
	mov_step6=$_('sm'+act_div[day_id]).offsetHeight/count_step6;
	clearTimeout(tmr6);
	AnimateStep6(day_id,news_id,count_step6);
}

function AnimateStep7(day_id,news_id,s_left){
	if (s_left==1){
		MoveStep8(day_id,news_id);
	}
	else{
		$_('sm'+act_div[day_id]).style.height=$_('sm'+act_div[day_id]).offsetHeight+mov_step7;
		clearTimeout(tmr7);
		tmr7=setTimeout('AnimateStep7('+day_id+','+news_id+','+(s_left-1)+')',25);
	}
}
function MoveStep7(day_id,news_id){
	var bounds=getBounds($_('sm'+act_div[day_id]));
	$('par'+day_id).removeChild($('sm'+act_div[day_id]));
	document.body.appendChild($_('sm'+act_div[day_id]));
	$_('sm'+act_div[day_id]).style.position='absolute';
	$_('sm'+act_div[day_id]).style.left=bounds.left;
	
	for (i=0;i<sm_items[day_id].length;i++){
		if (sm_items[day_id][i].id==act_div[day_id]){
			if (i!=sm_items[day_id].length-1)
			{
				bounds=getBounds($_('sm'+sm_items[day_id][i+1].id));
			}
			else{
				bounds=getBounds($_('sm'+sm_items[day_id][i-1].id));
				bounds.top=bounds.top+bounds.height+20;
			}
		}
	}
	b=getBounds($_('day'+day_id));
	if (ie){
		$_('sm'+act_div[day_id]).style.top=bounds.top;
	}
	else{
		$_('sm'+act_div[day_id]).style.top=bounds.top;
	}
	$_('sm'+act_div[day_id]).style.width=227;
	for (i=0;i<sm_items[day_id].length;i++){
		if (act_div[day_id]==sm_items[day_id][i].id){
			$_('sm'+act_div[day_id]).innerHTML=sm_items[day_id][i].cont;
			if (sm_items[day_id][i].h==-1){
				sm_items[day_id][i].h=$('hd'+act_div[day_id]).offsetHeight;
			}
			mov_step7=sm_items[day_id][i].h/count_step7;
			break;
		}
	}
	$_('sm'+act_div[day_id]).style.height=25;
	SetOpacity($_('sm'+act_div[day_id]),100);
	clearTimeout(tmr7);
	AnimateStep7(day_id,news_id,count_step7);
}

function AnimateStep8(day_id,news_id,s_left){
	if (s_left==0){
		MoveStep9(day_id,news_id);
		return;
	}
	else{
		for (i=0;i<sm_items[day_id].length;i++){
			if (sm_items[day_id][i].id==act_div[day_id]){
				for (j=i+1;j<sm_items[day_id].length;j++){
					$_('sm'+sm_items[day_id][j].id).style.top=parseFloat($_('sm'+sm_items[day_id][j].id).style.top)+mov_step8;
				}
				break;
			}
		}
		clearTimeout(tmr8);
		tmr8=setTimeout('AnimateStep8('+day_id+','+news_id+','+(s_left-1)+')',25);
	}
}


function MoveStep8(day_id,news_id){
	var arr_b=new Array();
	for (i=0;i<sm_items[day_id].length;i++){
		var bounds=getBounds($_('sm'+sm_items[day_id][i].id));
		arr_b[i]=bounds;
	}
	mov_step8=($_('sm'+act_div[day_id]).offsetHeight+20)/count_step8;
	clearTimeout(tmr8);
	AnimateStep8(day_id,news_id,count_step8);
}

function AnimateStep9(day_id,news_id,s_left){
	if (s_left==0){
		if (!window.opera)
			$_('sm'+act_div[day_id]).style.left=179;
		else
			$_('sm'+act_div[day_id]).style.left=200;
		MoveStep10(day_id,news_id);
		return;
	}
	else{
		$_('sm'+act_div[day_id]).style.left=parseInt($_('sm'+act_div[day_id]).style.left)-27;
		clearTimeout(tmr9);
		tmr9=setTimeout('AnimateStep9('+day_id+','+news_id+','+(s_left-1)+')',25);
	}
}

function MoveStep9(day_id,news_id){
	AnimateStep9(day_id,news_id,count_step9);
}

function AnimateStep10(day_id,news_id,s_left){
	if (s_left==0){
		$_('sm'+news_id).style.left=parseInt($_('sm'+news_id).style.left)-1;
		MoveStep11(day_id,news_id);
		return;
	}
	else{
		$_('sm'+news_id).style.left=parseInt($_('sm'+news_id).style.left)+27;
		clearTimeout(tmr10);
		tmr10=setTimeout('AnimateStep10('+day_id+','+news_id+','+(s_left-1)+')',25);
	}
}


function MoveStep10(day_id,news_id){
		AnimateStep10(day_id,news_id,count_step10);
}

function AnimateStep11(day_id,news_id,s_left){
	if (s_left==0){
		for (i=0;i<sm_items[day_id].length;i++){
			if (news_id==sm_items[day_id][i].id){
				document.body.removeChild($_('sm'+news_id));
				$_('sm'+sm_items[day_id][i].id).style.position='relative';
				$_('sm'+sm_items[day_id][i].id).style.float='left';
				$_('sm'+news_id).style.top=(parseFloat($_('sm'+news_id).style.top)-getBounds($_('day'+day_id)).top)-20;
				$_('sm'+sm_items[day_id][i].id).style.left=0;
				$_('par'+day_id).appendChild($_('sm'+sm_items[day_id][i].id));
			}
		}
		MoveStep12(day_id,news_id);
		return;
	}
	else{
		for (i=0;i<sm_items[day_id].length;i++){
			if (sm_items[day_id][i].id==news_id){
				for (j=i+1;j<sm_items[day_id].length;j++){
					$_('sm'+sm_items[day_id][j].id).style.top=parseFloat($_('sm'+sm_items[day_id][j].id).style.top)-mov_step11;
				}
				break;
			}
		}
		clearTimeout(tmr11);
		tmr11=setTimeout('AnimateStep11('+day_id+','+news_id+','+(s_left-1)+')',25);
	}
}

function MoveStep11(day_id,news_id){

	mov_step11=($_('sm'+news_id).offsetHeight+20)/count_step11;
	AnimateStep11(day_id,news_id,count_step11);
}

function WaitLoaded2(day_id,news_id){
	if (ajax_reslt!=''){

		$_('sm'+news_id).style.width=$_('par'+day_id).offsetWidth-60;
		$_('sm'+news_id).innerHTML=ajax_reslt;
		$_('sm'+news_id).style.left=0;
		$_('sm'+news_id).style.overflow='visible';
		$_('sm'+news_id).style.height='auto';
		$_('sm'+news_id).style.width='auto';
	
		$_('sm'+news_id).style.position='relative';
		MoveStep13(day_id,news_id);
	}
	else{
		setTimeout('WaitLoaded2('+day_id+','+news_id+')',100);
	}
}

function MoveStep12(day_id,news_id){
	mov_step12=$_('sm'+news_id).offsetHeight/count_step12;
	$_('sm'+news_id).style.overflow='hidden';
	h=$_('sm'+news_id).offsetHeight;
	moveResize(1,'sm'+news_id,'WaitLoaded2('+day_id+','+news_id+')');
}

function MoveStep13(day_id,news_id){
	$_('sm'+news_id).style.display='none';
	
	SetOpacity($_('sm'+news_id),0);
	$_('sm'+news_id).style.display='';
	CheckHeight(day_id,news_id,false);
	h=$_('sm'+news_id).offsetHeight;
	$_('sm'+news_id).style.height='1px';
	$_('sm'+news_id).style.overflow='hidden';
	SetOpacity($_('sm'+news_id),100);
	bounds =getBounds($_('sm'+news_id));
	clearTimeout(tmr13);
	moveScroll(document.body.scrollTop,getBounds($_('sm'+news_id)).top,'moveResize('+h+',"sm'+news_id+'","MoveStep14('+day_id+','+news_id+')")');
	//moveScroll(document.body.scrollTop,getBounds($_('sm'+news_id)).top);
	//moveResize(h,"sm"+news_id,"MoveStep14("+day_id+","+news_id+")");
}

function MoveStep14(day_id,news_id)
{
	$_('sm'+news_id).style.overflow='visible';
	$_('sm'+news_id).style.height='auto';
	ajax_reslt='';
	act_div[day_id]=news_id;
	is_animating=false;
	$_('loader').style.display='none';
}


function CalMonths(year){
	var req = new JsHttpRequest();
	$('loader').style.top=document.body.scrollTop;
	$('loader').style.display='';
	req.onreadystatechange = function() {
		if (req.readyState == 4) {
			$('months').innerHTML=req.responseJS.a;
			$('loader').style.display='none';
		}
	}
	req.open(null, '/modules/getcalmonths.php?ajax=1&year='+year, true);
	req.send({});	
}

function CalDays(year,month){
	var req = new JsHttpRequest();
	$('loader').style.top=document.body.scrollTop;
	$('loader').style.display='';
	req.onreadystatechange = function() {
		if (req.readyState == 4) {
			$('days').innerHTML=req.responseJS.a;
			$('loader').style.display='none';
		}
	}
	req.open(null, '/modules/getcaldays.php?ajax=1&year='+year+'&month='+month, true);
	req.send({});	
}

var rows_loaded=new Array();

function AddRow(row_id,day_id){
	var req = new JsHttpRequest();
	$('loader').style.top=document.body.scrollTop;
	$('loader').style.display='';
	req.onreadystatechange = function() {
		if (req.readyState == 4) {
			$('day'+day_id).innerHTML=req.responseJS.a;
			eval(req.responseJS.init);
			date=day_id;
			for (j=0;j<sm_items[date].length;j++){
				sm_items[date][j].h=$('hd'+sm_items[date][j].id).offsetHeight;
				sm_items[date][j].cont=$_('sm'+sm_items[date][j].id).innerHTML;
				
				//$('sm'+sm_items[date][j].id).style.height=sm_items[date][j].h+26;
			}
			$('loader').style.display='none';
			//CheckHeight(
			rows_loaded[day_id]=true;
				
		}
	}
	var dt=new Date();
		dt.setTime(day_id*1000);
		var day=dt.getDate();
		if (day<10) {
			day='0'+day;
		}
		var month=dt.getMonth()+1;
		if (month<10) {
			month='0'+month;
		}
		var year=dt.getYear();
		if (year<1900) {
			year=1900+year;
		}

	req.open(null, '/modules/getday.php?ajax=1&date='+day_id, true);
	req.send({});
	obj=($('tbl').insertRow(row_id)).insertCell(0);
	obj.id='day'+day_id;
	obj.className='n'+(2-(row_id%2));
	arr_days.push(day_id);
	arr_days.sort();
	arr_days.reverse();
	for(i=row_id-1;i<arr_days.length;i++){
		$('day'+arr_days[i]).className='n'+(1+(i%2));
	}
	
}

function AddDay(day_id){
	found=false;
	for(i=0;i<arr_days.length;i++){
		var dt=new Date();
		dt.setTime(arr_days[i]*1000);
		var day=dt.getDate();
		if (day<10) {
			day='0'+day;
		}
		var month=dt.getMonth()+1;
		if (month<10) {
			month='0'+month;
		}
		var year=dt.getYear();
		if (year<1900) {
			year=1900+year;
		}
		//alert(day+'.'+month+'.'+year);
		if (arr_days[i]<day_id){
			found=true;
			if (i!=0){
				if (arr_days[i-1]==day_id){
					break;
				}
			}
			AddRow(i+1,day_id);
			break;
		}
		else{
			if (arr_days[i]==day_id){
				found=true;
				break;
			}
		}
	}
	if (!found){
		AddRow(arr_days.length+1,day_id);
	}
}


function MultiLoad(day_id,news_id,zag,d1,d2,d3,d4){
	$_('loader2').style.display='';
	$_('hh').style.display='none';
	if (d1){
		AddDay(d1);
	}
	if (d2){
		AddDay(d2);
	}
	if (d3){
		AddDay(d3);
	}
	if (d4){
		AddDay(d4);
	}
	TmrMultiLoad(day_id,news_id,zag,d1,d2,d3,d4);
}

function TmrMultiLoad(day_id,news_id,zag,d1,d2,d3,d4){
	flag=true;
	if (d1){
		flag=flag && rows_loaded[d1];
	}
	if (d2){
		flag=flag && rows_loaded[d2];
	}
	if (d3){
		flag=flag && rows_loaded[d3];
	}
	if (d4){
		flag=flag && rows_loaded[d4];
	}
	if (!flag){
		setTimeout('TmrMultiLoad('+day_id+','+news_id+',"'+zag+'",'+d1+','+d2+','+d3+','+d4+')',100);
	}
	else{
		//act_div[day_id]=news_id;
		//mov_opened[day_id]=true;
		CheckHeight(day_id,news_id);
		docResize(day_id);
		$('loader2').style.display='none';
		GetNews(day_id,news_id,zag);
	}
}