fl_anim=function(){
	var frame_time=500;//время на один кадр
	var effect_time=500;//время плавного перехода на следующий кадр. входит в полное время кадра
	var clear_time=90;//чистое время на один кадр, без учета времени смены кадров
	var topOffset=0;//Начальное смещение с верху
	var leftOffset=0;//Начальное смещение слева
	var frameHeight=20;//Высота кадра
	var frameWidth=295;//Ширина Кадра
	var type=2;//1-вертикальная, 2-горизонтальная
	var images=Array();// массив всех изображений. содержить путь к изображению, порядковый номер, количество занимаемых кадров
	var images_counter=8;//счетчик всех изображений
	var start_frame=0;//с какого изображения начать
	var curent_frame=0;//изображение которое сейчас в кадре
	var next_frame=0;//изображение которое будет нехт
	var auto_cache=true;//
	var bgClass="anim_bg";//Класс дива, который будет для следующего изображения
	var fgClass="anim_fg";	//класс дива для текущего изображения
	var blockToAnimate;//JavaScrip идентификатор блока, в котором будет производиться анимация
	var itself=this;//идентификактор класса
	var setNextFrame=function(imgNum){//установить следующее изображение на подложку
	var animateInProcess=false;
	var animateStoped=false;
		
	}
	var getCoors=function(imgNum){
		var res={};
		if(type==1){
			
		}else if(type==2){
			
			res.x=	-(leftOffset+frameWidth*imgNum);
			res.y=	topOffset+frameHeight;
		}
		return res
	}
	var setNextFrame=function(imgNum){//установить следующее изображение
		//var imgpath =images[imgNum].path;
		//next_frame=imgNum;
		var offs=getCoors(imgNum)
		
		$(blockToAnimate).find("."+bgClass).css({backgroundPosition:offs.x+"px"+" "+offs.y+"px"});
		//$(blockToAnimate).find("."+bgClass).css({backgroundImage:"URL("+imgpath+")"});
		
		//$(blockToAnimate).find("."+bgClass).html("<img src='"+imgpath+"' />");
	}
	var setCurrentFrame=function(imgNum){//установить текущее изображение
		//var imgpath =images[imgNum].path;
		//curent_frame=imgNum;
		var offs=getCoors(imgNum)
		$(blockToAnimate).find("."+fgClass).css({backgroundPosition:offs.x+"px"+" "+offs.y+"px"});
		//$(blockToAnimate).find("."+fgClass).css({backgroundImage:"URL("+imgpath+")"});
		//$(blockToAnimate).find("."+fgClass).html("<img src='"+imgpath+"' />");//({backgroundImage:"URL("+imgpath+")"});
	}
	next=function(callBack){
//		alert(effect_time);
		if(5!=5){
			$(blockToAnimate).find("."+fgClass).animate({opacity:'0'},effect_time,function(){
			curent_frame=next_frame;
			setCurrentFrame(curent_frame);	
			$(blockToAnimate).find("."+fgClass).css({opacity:'1'});
			next_frame++
			if(next_frame>images_counter-1){
				next_frame=0;
			}
			setNextFrame(next_frame);	
			callBack();																	   
			});
		}else if($.browser.msie){
		next_frame++
			curent_frame=next_frame;
			setCurrentFrame(curent_frame);	
			//$(blockToAnimate).find("."+fgClass).css({opacity:'0'});
			//$(blockToAnimate).find("."+fgClass).css({opacity:'1'});
			
			if(next_frame>images_counter-1){
				next_frame=0;
			}
			setNextFrame(next_frame);
			callBack()
									
			
		}else{
			$(blockToAnimate).find("."+fgClass).animate({opacity:'0'},effect_time,function(){
			curent_frame=next_frame;
			setCurrentFrame(curent_frame);	
			$(blockToAnimate).find("."+fgClass).css({opacity:'1'});
			next_frame++
			if(next_frame>images_counter-1){
				next_frame=0;
			}
			setNextFrame(next_frame);	
			callBack();																	   
			});
		}
		
	}
	this.add_img=function(img_path,length){//добавить изображение
		if(typeof length =='undefined'){
			length=1; 
		}
		images[images_counter]=new Object();
		images[images_counter].path=img_path;
		images[images_counter].mun=images_counter;
		images[images_counter].is_load=false;
		images[images_counter].length=length;
		return images_counter++;
	}
	this.settings=function(params){
		clear_time=frame_time-effect_time;
		if($.browser.msie){
		clear_time=frame_time;
		}
		//nextFrame=startFrame+1;
		//alert(typeof params);
		if(typeof params =='object'){
			
			if(typeof params['canvas']!='undefined'){
				
				blockToAnimate=params['canvas'];
			}
		}
	}
	this.init= function(){
		//alert('');
		itself.settings();
		setCurrentFrame(start_frame);
		setNextFrame(start_frame+1);
		
		
	}
	this.setNext=function(){/*функция вызывается после окончания анимаци смены кадра*/
		
	}
	this.animation= function(){
		
		setTimeout(function(){
			
			next(itself.animation)
		
		},clear_time);
	//	set
	}
	
}
$(document).ready(function(){
$("#content a:has(img)").addClass('big_img');
if(typeof $(".big_img").fancybox!='undefined'){
$(".big_img").fancybox();
}
});
$(document).ready(function(){

	$("#header .win_content_close").click(function(){
		//$("#header .autorize_win").stop();										   
		$("#header .autorize_win").slideToggle('fast',false);
		return false;
	});		
	$("#header .oldfriends").click(function(){
		//$("#header .autorize_win").stop();
		$("#header .autorize_win").slideToggle('fast');
		return false;
	});						

	cofeeAnim=new fl_anim;
	//cofeeAnim.add_img("/images/about_bottom_anim/anim_11.jpg");
	//cofeeAnim.add_img("/images/about_bottom_anim/anim_12.jpg");
	//cofeeAnim.add_img("/images/about_bottom_anim/anim_13.jpg");
	//alert('');
	cofeeAnim.settings({
					   'canvas':$("#anim").get(0)
					   
					   });
	//alert('');
	cofeeAnim.init();
	cofeeAnim.animation();							   
   function anim(){
	   //alert('');
	//$("#bottom_animate .anim_face").css({filter: alpha(opacity = 1)})
	 /*  
	$("#bottom_animate .anim_face").fadeOut(1000 );
	$("#bottom_animate .anim_face").fadeIn(1000 );
	$("#bottom_animate .anim_face").fadeOut(1000 );
	$("#bottom_animate .anim_face").fadeIn(1000 );
	*/
	  /*
	$("#bottom_animate .anim_face").animate({opacity:0},100,function(){
		$("#bottom_animate .anim_face").animate({opacity:1},100,anim);	
	});
	*/
	
   }
   anim();
})

function getElementsByClassName(searchClass, node, tag){
	var classElements = new Array();
	if (node == null)
	{
		node = document;
	}
	if (tag == null)
	{
		tag = '*';
	}
	var els = node.getElementsByTagName(tag);
	var elsLen = els.length;
	var pattern = new RegExp("(^|\\s)" + searchClass + "(\\s|$)");
	for (var i = 0, j = 0; i < elsLen; i++)
	{
		if (pattern.test(els[i].className))
		{
			classElements[j] = els[i];
			j++;
		}
	}
	return classElements;
}

