$(function(){
	
	

	
	
	//var divDates = $('.alldates div');
	
		 var browser = navigator.appName;
		  if (browser == "Microsoft Internet Explorer"){
		    var b_version = navigator.appVersion;
		    var re = /\MSIE\s+(\d\.\d\b)/;
		    var res = b_version.match(re);
		    if (res[1] <= 6){
		      (function(){
		    	  var $child = $('.menuTop ul li');
		    	  var $childli = $('.submenu li');
		    			  $child.bind('mouseenter',function(e)
		    					  {
		    					  this.className ='cur hover';
		    			
		    					  }).bind('mouseleave',function(e)
		    						{
		    							this.className='';
		    					    });
		    			  $childli.bind('mouseenter',function(e)
		    					  {
		    					  this.className ='cur2 hover';
		    			
		    					  }).bind('mouseleave',function(e)
		    						{
		    							this.className='';
		    					    });
		      })();
		    }
		  }


	
	
	(function(){
		
		var $labels = $('label._autohide');
		$labels.each(function() {

			var $label = $(this);
			var id = $label.attr('for');
			var $input = $('#'+id);
			
			$input.focus(function(){
				$label.hide();
			}).blur(function(){
				if(!$input.val()){
					$label.show();
				}
			}).change(function(){
				if($input.val()){
					$label.hide();
				}else{
					$label.show();
				}
			});
			
			if ($input.val()) {
				$label.hide();
			}
			
		});

	})();
	
	(function(){
		var $mainnews = $('.wrap li');
		var $img = $('.f img');
		
		$mainnews.bind('mouseenter', function(e){
			var $this = $(this);
			$mainnews.removeClass('act');
			if(this.className== '')  this.className = 'act';	
			var num = $this.index();
			$img.css('display','none');
			$img.eq(num).css('display','block');
		});

	})();
	
	(function(){
		var $videophotovklad = $('.bookmark li');
		var $fotoList = $('.fotoList');
		var $videolist = $('.videoList');
		var $audioList = $('.audioList');
		
		$videophotovklad.bind('mouseenter', function(e){
			var $this = $(this);
			$videophotovklad.removeClass('cur');
			if(this.className=='' || this.className=='last') this.className = 'cur';
			var numb = $this.index();
			if(numb==0)
			{
				$fotoList.css('display','block');
				$videolist.css('display','none');
				$audioList.css('display','none');
			}
			if(numb==1)
			{
				$fotoList.css('display','none');
				$videolist.css('display','block');
				$audioList.css('display','none');
			}
			if(numb==2)
			{
				$fotoList.css('display','none');
				$audioList.css('display','block');
				$videolist.css('display','none');
			}
		});
	})();
	
	
	(function(){
		   var cal= $('.calendarBlock');
		   cal.calendarLite();
		   var call= $('.ccalendarBlock'); 
		   call.calendarLiteLine();  
    })();
   


   
   (function(){
	   $('.table th:gt(4)').addClass("weekend");
   })();
   
   
	(function(){
		
		var $MenuItems = $('.submenu li');
		$MenuItems.bind('mouseenter', function(e){
			this.addClass('cur2');
			
		}).bind('mouseleave', function(e){
			this.removeClass('cur2');
		});
		
	})();
	
	
	(function(){
		var $mainb = $('.mainp').find('img');
		var $lentai = $('.lenta img');
		var $lenta = $('.lenta');
		var $lentaBlock = $('.lentaBlock');
		var $prev = $lentaBlock.find('.prev');
		var $next  = $lentaBlock.find('.next');
		var curIndx = $mainb.filter('.cur').index() || 0;
		var itemWidth = 80 ;		
		var newsLength = $lentai.length;
			
		
		/*$lentai.bind('click',function(){
				
			var $this = $(this);
			var indx = $lentai.index(this);
			$mainb.hide();//removeClass('cur');	
			$mainb.eq(indx).show()//addClass('cur');
			
			});*/

			
			$next.bind('click',function(e){
				var y =true;
				if (curIndx + 1 < newsLength) {
					curIndx++;
					showNewsItem(curIndx);
				}
				return false;
			});
			$prev.bind('click',function(e){
				var y =false;
				if (curIndx > 0) {
					curIndx--;
					showNewsItem(curIndx);
				}
				return false;
			});	
			
			
			
			function showNewsItem(indx){
				curIndx = indx;
				$mainb.hide();
				$mainb.eq(indx).show();
				

				
				upNewsBtns();
			}
			
			function upNewsBtns(){
				if (curIndx == 0) {
					$prev.hide()
				} else {
					$prev.show()
				}
				if (curIndx == (newsLength-1)) {
					$next.hide();
				} else {
					$next.show();
				}
				
				if (curIndx < 4) {
					$('.lenta').css({
						left: 0
					});
					return;
				}
				if (curIndx > newsLength - 4) {
					$('.lenta').css({
						left: -itemWidth * (newsLength - 5)
					});
					return;
				}
				
				$lentai.css({
					left: -itemWidth * (curIndx - 2)
				});
				
			}

	})();
	
	(function(){
		var $note = $('.note');
		var $mainb = $('.mainp').find('img').length;
		if($mainb > 0)
		{
		$note.html('' + $mainb + '  фотографий');
		}
	})();
	
	(function(){
		
		var $ResetForm = $('.ibutton reset');
		
		$ResetForm.bind('click', function(e){
			$("input, textarea").val('').change();
		});
		
	})();

	(function(){
		var newsListBlock = $('.newsListBlock ul li:last-child');
		var block = $('.block2 ul li:last-child');
		newsListBlock.addClass('last');
		block.addClass('last');
	})();
		
});