$(function(){
	
		 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 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;
			

			
			$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 + '  photos');
		}
	})();
	
	(function(){
		
		var $ResetForm = $('.ibutton reset');
		
		$ResetForm.bind('click', function(e){
			$("input, textarea").val('').change();
		});
		
	})();

	(function(){
		var block = $('.block2 ul li:last-child');
		var newmain = $('.newsListBlock li:last-child'); 
		block.addClass('last');
		newmain.addClass('last');
	})();
		
});