// JavaScript Document


var autoscroll = function(){
		if ($("#all #content #text #icons li.active").next().length){
			aminate_ico_arr($("#all #content #text #icons li.active").next())
		}else{
			aminate_ico_arr($("#all #content #text #icons li:eq(0)"))
		}
}
var autotime = 5000 //время автоскролла 1000 = 1 сек


$(document).ready(function()
{
var self=this,
  
 $questBlock = $('.questions_block');
 $question = $('.questions span', $questBlock),
  
 $question.click(function() {
  $.thisLink = $(this);
  
  if(! $(this).parent().parent().hasClass('act')){
   $.thisLink.parent().parent().addClass('act');
   $.thisLink.parent().parent().find('.fulltxt').slideDown(500);
   
  } else {
   
   $.thisLink.parent().parent().removeClass('act');
   $.thisLink.parent().parent().find('.fulltxt').slideUp(500);
 
  }
  return false; 
 });



if (($.browser.msie)&&($.browser.version<'8')){

var width = 0
$("#all #menu li:not(:first)").each(function(){
$(this).width($(this).find("a").width()+31)
width += $(this).find("a").width()+31
})
$("#all #menu li:first").width($("#all #menu").width()-width-100)

}

		if ($.cookie('top_bar')==1) {top_bar()}
		
		
		$("#top_bar_content #show_top_bar").click(function(){
			top_bar()
		})

	$("#all #menu li:first").width($("#all #menu li:first").width()+($("#all #menu #back").width()-$("#all #menu ul").width()))
	$("#all #menu li:last a, #footer #nav li:last, #top_bar_content  #logged li:last a").css("border",0)
	$("#footer #nav li:first").css("padding","0 15px 0 0")
	
	$("input:password, input:text, textarea ").css({
		"border":"1px solid #bfbfbf",
		"-moz-border-radius":"3px",
		"-webkit-border-radius":"3px",
		"border-radius":"3px"
	})
	
	$("#all.index #menu #slide #slide_1").click(function(){
	if(!$(this).hasClass('active')) {
		$("#all.index #menu #slide #slide_2").stop().animate({"width":"320px", "left":"280px"},500)
		$("#all.index #menu #slide #slide_1 h2").fadeIn(300)
		$("#all.index #menu #slide #slide_1 .play_img").fadeIn(600)

		$("#all.index #menu #slide #slide_2 h2").fadeOut(300)
		$("#all.index #menu #slide #slide_3 h2").fadeOut(300)	
		
		$("#all.index #menu #slide #slide_2 .slide_text").fadeOut(300)	
		$("#all.index #menu #slide #slide_3 .slide_text").fadeOut(300)	
		
		$(this).stop().animate({"width":"560px"},500,function(){
			$(this).find('.slide_text').fadeIn(200)
			$("#all.index #menu #slide #slide_2").removeClass('active')
			$("#all.index #menu #slide #slide_3").removeClass('active')
			$(this).addClass('active')
		})
		}else{
                        $("#all.index #menu #slide #slide_3 h2").fadeIn(300)
			clear()
			$(this).removeClass('active')
		}
	})
	
	$("#all.index #menu #slide #slide_2").click(function(){
	if(!$(this).hasClass('active')) {
			$("#all.index #menu #slide #slide_1").stop().animate({"width":"100px"},500)
			$("#all.index #menu #slide #slide_1 h2").fadeOut(300)
			$("#all.index #menu #slide #slide_1 .play_img").fadeOut(100)

			$("#all.index #menu #slide #slide_2 h2").fadeIn(300)
			$("#all.index #menu #slide #slide_3 h2").fadeOut(300)	
			
			$("#all.index #menu #slide #slide_1 .slide_text").fadeOut(200)
			$("#all.index #menu #slide #slide_3 .slide_text").fadeOut(200)
			
			$(this).stop().animate({"width":"580px", "left":"20px"},500,function(){
				$(this).find('.slide_text').fadeIn(200)			
				$("#all.index #menu #slide #slide_1").removeClass('active')
				$("#all.index #menu #slide #slide_3").removeClass('active')
				$(this).addClass('active')
			})
		}else{
$("#all.index #menu #slide #slide_3 h2").fadeIn(300)
			clear()
			$(this).removeClass('active')
			}
	})

	$("#all.index #menu #slide #slide_3").click(function(){
	if(!$(this).hasClass('active')) {
			$("#all.index #menu #slide #slide_2").stop().animate({"width":"150px", "left":"10px"},500)
			$("#all.index #menu #slide #slide_1").stop().animate({"width":"130px"},500)
			$("#all.index #menu #slide #slide_1 h2").fadeOut(300)
			$("#all.index #menu #slide #slide_1 .play_img").fadeOut(100)

			$("#all.index #menu #slide #slide_2 h2").fadeOut(300)
			$("#all.index #menu #slide #slide_3 h2").fadeIn(300)	
			
			$("#all.index #menu #slide #slide_2 .slide_text").fadeOut(200)
			$("#all.index #menu #slide #slide_1 .slide_text").fadeOut(200)
			
			$(this).stop().animate({"width":"630px","left":"0px"},500,function(){
				$(this).find('.slide_text').fadeIn(400)			
				$("#all.index #menu #slide #slide_2").removeClass('active')
                                $("#all.index #menu #slide #slide_1").removeClass('active')
				$(this).addClass('active')
			})
		}else{
$("#all.index #menu #slide #slide_3 h2").fadeIn(300)
$("#all.index #menu #slide #slide_3 .slide_text").fadeOut(200)
			clear()

			$(this).removeClass('active')
			}
	})
	
	$("#all #content #text #icons").append('<div id="ico_text" style="width:auto; margin-right:-30px; min-width:300px;"><div id="ico_arr"></div><b class="tl"></b><b class="tr"></b><b class="bl"></b><b class="br"></b><div id="ico_text_00"></div></div>')
	
	$("#all #content #text #icons li:first").each(function(){
		aminate_ico_arr($(this))
	})
	$("#all #content #text #icons li").click(function(){
		aminate_ico_arr($(this))
	})

	$("#all #content #text #icons li").hover(function(){

		clearInterval(auto)
		$(this).addClass('hover')
aminate_ico_arr($(this))
	},function(){

		auto = setInterval( autoscroll , autotime)
		$(this).removeClass('hover')
	})
var auto = setInterval( autoscroll , autotime)

})

function aminate_ico_arr(el){
if (!el.find('.hidden_text').html()) return false
		$("#all #content #text #icons").find("#ico_text_00").html(el.find('.hidden_text').html())
		$("#all #content #text #icons #ico_text").show()
		$("#all #content #text #icons li").removeClass('active')
		el.addClass('active')
		offset = el.offset()
		offset2 = $("#all #content #text #icons").offset()		
		var left = offset.left - offset2.left-16
		if (left<0) left = 0;
		if (left>$("#all #content #text #icons").width()-90) left = $("#all #content #text #icons").width()-90;		
		$("#all #content #text #icons").find("#ico_arr").stop().animate({'left': left}, 200)
}

function clear(){

			$("#all.index #menu #slide #slide_1").animate({"width":"250px"},500)
			$("#all.index #menu #slide #slide_1 h2").fadeIn(250)	
			setTimeout(function(){
				$("#all.index #menu #slide #slide_1 .play_img").fadeIn(600)
			}, 300);	

			$("#all.index #menu #slide #slide_2").animate({"width":"250px","left":"190px"},500)
			$("#all.index #menu #slide #slide_2 h2").fadeIn(250)

			$("#all.index #menu #slide #slide_1 .slide_text").fadeOut(200)		
			$("#all.index #menu #slide #slide_2 .slide_text").fadeOut(200)
}

function top_bar(){

	//$("#all #lk #lk_show_hide").hide()
		
	if (!$("#top_bar_content #show_top_bar").hasClass("active")){
		$("#top_bar_content  #top_content").show();
		$.cookie('top_bar','1')
	}else{
		$("#top_bar_content  #top_content").hide();
		$.cookie('top_bar','0')
	}
	
	$("#top_bar_content #show_top_bar").toggleClass("active")
}

$(document).ready(function(){
			// получаем массив блоков с нужными нам изображениями
			var banners = $("#rotator div").toArray();
			
			// класс с параметрами
			settings = function() {
				this.banners = banners;              // массив блоков с изображениями
				this.sum	 = this.banners.length;  // количество блоков с изображениями
				this.timeIn  = 1000;                 // время для появления
				this.timeOut = 1000;                 // время для скрытия
				this.timeView= 3500;                 // тайм-аут для показа
			}
			
			var obj = new settings();
			if (obj.sum < 1) {
				$("#rotator").html("<p>Изображения для показа не найдены!</p>");			
			} 
			else {
				
				// скрываем все изображения блока #rotator
$("#rotator").css({"minHeight":"40px"});
				$("#rotator div").css({
					"display":"none"
				});
				
				// создаем блок для показа с индикатором загрузки для эффектного начала
				$("#rotator").prepend("<div id='rotator_view' style='display:table; width:220px; height:80px;'><img src='img/load.gif'></div>");

				// запускаем функцию показа
				view (0);
			}
			
			function view (num){
				// инициализируем экземпляр класса settings()
				var obj = new settings();
				// если показали все изображения, показываем их снова
				if (num >= obj.sum) num = 0;
				
				var interval = setInterval (function(){
					// очистка блока показа
					$("#rotator_view *").remove();
					
					// копия изображения в блок показа
					$(obj.banners[num]).clone().prependTo("#rotator_view");
					
					// показ изображения
					$("#rotator_view div").fadeIn(obj.timeIn);
					
					clearInterval(interval);
					num++;
				},obj.timeIn);
				
				// скрытие изображения
				$("#rotator_view div").fadeOut(obj.timeOut);
				
				// снова запускаем сами себя если изображений больше одного 
				if (obj.sum > 1) setTimeout(function(){view(num)},obj.timeIn+obj.timeOut+obj.timeView);
			}
		});
